Hi,
I created My Plugin with MIP SDK and I would to get date and time of the first and the last recording by camera. These values (my_start, my_end) I’ll use like parameters to exported some data with new VideoOS.Platform.Data.DBExporter().
foreach (Item camera in _cameraItems){
// DateTime my_start = First Recording by camera
//DateTime my_end = Last Recording by camera
VideoOS.Platform.Data.IExporter _exporter = new VideoOS.Platform.Data.DBExporter() { Encryption = false, IncludePlayer =true};
_exporter.CameraList = new List() { camera };
_exporter.Init();
_exporter.StartExport(my_start, my_end);
}
Can you help me?
I used a RawVideoSource and the GetBegin() and GetEnd() methods in my implementation of Get-PlaybackInfo in MilestonePSTools. Here’s an excerpt from that cmdlet:
RawVideoSource src = null;
try
{
var cameraId = Camera != null ? new Guid(Camera.Id) : CameraId;
var item = Configuration.Instance.GetItem(Connection.CurrentSite.FQID.ServerId, cameraId,
Kind.Camera);
if (item == null)
{
WriteWarning(
$"Configuration not available for camera with ID {cameraId}. It might be disabled.");
return;
}
src = new RawVideoSource(item);
src.Init();
RawVideoSourceDataList begin = null;
RawVideoSourceDataList end = null;
try
{
var any = src.GoToWithResult(DateTime.UtcNow, "Any");
if (!any)
{
throw new InvalidOperationException($"No video in database for {item.Name} ({cameraId})");
}
begin = src.GetBegin();
end = src.GetEnd();
var beginTimestamp = begin.List.OrderBy(r => r.DateTime).First().DateTime;
var endTimestamp = end.List.OrderBy(r => r.DateTime).Last().DateTime;
var obj = new PSObject();
obj.Members.Add(new PSNoteProperty("Begin",
UseLocalTime ? beginTimestamp.ToLocalTime() : beginTimestamp));
obj.Members.Add(new PSNoteProperty("End",
UseLocalTime ? endTimestamp.ToLocalTime() : endTimestamp));
obj.Members.Add(new PSNoteProperty("Retention", DateTime.UtcNow - beginTimestamp));
WriteObject(obj);
}
finally
{
begin?.Dispose(true);
end?.Dispose(true);
}
}
catch (PipelineStoppedException)
{
throw;
}
catch (CommunicationMIPException)
{
WriteWarning($"Unable to connect to {src?.Item.Name} ({src?.Item.FQID.ObjectId})");
}
catch (Exception ex)
{
WriteError(
new ErrorRecord(
ex,
ex.Message,
ErrorCategory.ReadError,
src));
}
finally
{
src?.Close();
}