/// <summary> /// Login (basico) a sistema DvTel con ID de Federation (Guid), Username y Password, pasados como parámetros /// </summary> public object LoginGuid(Guid federationId, string username, string password) { intentosReconexion++; try { m_DvtelSystem = DvtelSystemsManagerProvider.Instance.DvtelSystemsManager.Login(federationId, username, password, new LoginCacheRequest(false)); return(true); } catch (Exception errorLoginGuid) { if (errorLoginGuid.Message.Contains("login")) { return(ResponseMethod(CodeStatus.UNAUTHORIZED, errorLoginGuid.Message, null)); } if (intentosReconexion < 3) { if (CopyDll()) { LoginGuid(federationId, username, password); } } return(ResponseMethod(CodeStatus.INTERNAL_SERVER_ERROR, errorLoginGuid.Message, null)); } }
/// <summary> /// Login (basico) a sistema DvTel con ID de Federation (Guid), Username y Password obtenidos desde web.config /// </summary> public object LoginGuid() { intentosReconexion++; try { federationIdSystemDvTel = Guid.Parse(ConfigurationManager.AppSettings["FederationId"]); usernameSystemDvTel = ConfigurationManager.AppSettings["Username"]; passwordSystemDvTel = ConfigurationManager.AppSettings["Password"]; m_DvtelSystem = DvtelSystemsManagerProvider.Instance.DvtelSystemsManager.Login(federationIdSystemDvTel, usernameSystemDvTel, passwordSystemDvTel, new LoginCacheRequest(false)); return(true); } catch (Exception errorLoginGuid) { if (errorLoginGuid.Message.Contains("login")) { return(ResponseMethod(CodeStatus.UNAUTHORIZED, errorLoginGuid.Message, null)); } if (intentosReconexion < 3) { if (CopyDll()) { LoginGuid(); } } return(ResponseMethod(CodeStatus.INTERNAL_SERVER_ERROR, errorLoginGuid.Message, null)); } }
/// <summary> /// Exporta un clip de video de un periodo determinado y de un dispositivo de video determinado /// </summary> public object ExportVideoPTZ(Guid guid, string fromDate, string toDate) { if (LoginGuid() is bool) { if (EstadoDispositivoPtz(guid) is bool) { //obtener video/clips almacenado IReadWriteEntitiesCollection <IRecordableSceneEntity> recordableScenes = DVTel.API.Common .DVTelObjectsFactory.Instance .CreateObject <IReadWriteEntitiesCollection <IRecordableSceneEntity> >(); recordableScenes.Add((IRecordableSceneEntity)entity); IRecordableSceneEntity scene = (IRecordableSceneEntity)entity; IDvtelSystemId dvtelSystem = scene.DvtelSystem; // get a Recording API that belongs to our specific federation (system) IRecordingAPI recordingApi = dvtelSystem.GetAPI <IRecordingAPI>(); // create a filter for the query QueryClipsFilter filter = new QueryClipsFilter(recordableScenes.AsReadOnly(), DateTime.Parse(fromDate), DateTime.Parse(toDate), 1); filter.ArchivingReasons = ArchivingReason.All; filter.ProtectionFilter = ProtectionFilterEnum.NotProtected; bool cropped; var objResponseExportVideo = new ResponseExportVideo(); IReadonlyEntitiesCollection <IClipEntity> clips = recordingApi.QueryClips(filter, out cropped); if (clips != null) { var directoryCompartido = ConfigurationManager.AppSettings["DirectorioCompartido"]; var guidAleatorio = Guid.NewGuid(); var fileName = guidAleatorio + ".mp4"; pathSnapshot = ConfigurationManager.AppSettings["PathSnapshot"] + "\\" + fileName; FileToWfDvtel(".evc", guid, directoryCompartido, pathSnapshot, fromDate, toDate); objResponseExportVideo.idExportSession = guidAleatorio; objResponseExportVideo.path = null; objModelResponseMethod.Status = CodeStatus.OK; objModelResponseMethod.Msg = string.Empty; objModelResponseMethod.Data = objResponseExportVideo; return(ResponseMethod(CodeStatus.OK, string.Empty, objResponseExportVideo)); } return(ResponseMethod(CodeStatus.NOT_FOUND, "Video no encontrado con esos parámetros", null)); } } return(objModelResponseMethod); }
/// <summary> /// Obtiene los datos de un dispositivo de video ,sirve de método auxiliar para la obtención de información. /// </summary> private PTZDevice GetDataPtz(IDvtelSystemId latitudeSystem, IVideoInSceneEntity camera) { objCameraPTZ = new PTZDevice(); var deviceApi = latitudeSystem.GetAPI <IDeviceAPI>(); var ptzClient = deviceApi.AcquirePTZControl(camera); var m_playerAPI = latitudeSystem.GetAPI <IPlayerAPI>(); /*if (ptzClient != null) * {*/ objCameraPTZ.canFocus = ptzClient != null? ptzClient.CanFocus: false; objCameraPTZ.canIris = ptzClient != null ? ptzClient.CanIris : false; objCameraPTZ.canPanTilt = ptzClient != null ? ptzClient.CanPanTilt : false; objCameraPTZ.canZoom = ptzClient != null ? ptzClient.CanZoom : false; objCameraPTZ.isLocked = ptzClient != null ? ptzClient.IsLocked : false; objCameraPTZ.numberOfPatterns = ptzClient != null ? ptzClient.NumberOfPatterns:0; objCameraPTZ.numberOfPresets = ptzClient != null ? ptzClient.NumberOfPresets:0; objCameraPTZ.sceneId = ptzClient != null ? ptzClient.SceneId:Guid.Empty; objCameraPTZ.sessionId = ptzClient != null ? ptzClient.SessionId : Guid.Empty; var locationBaseEntity = ptzClient != null?ptzClient.GetCurrentLocation() : null; if (locationBaseEntity is IPtzMotorNormalized3DLocationEntity) { var location = (IPtzMotorNormalized3DLocationEntity)locationBaseEntity; objCameraPTZ.panValue = location.PanValue.ToString(); objCameraPTZ.tiltValue = location.TiltValue.ToString(); objCameraPTZ.zoomValue = location.ZoomValue.ToString(); } if (locationBaseEntity is IPtzMotor3DLocationEntity) { var absLocation = (IPtzMotor3DLocationEntity)locationBaseEntity; objCameraPTZ.panValue = absLocation.PanValue; objCameraPTZ.tiltValue = absLocation.TiltValue; objCameraPTZ.zoomValue = absLocation.ZoomValue; } PTZDevice.geoLocation geographicLocation = new PTZDevice.geoLocation(); entity = m_DvtelSystem.AdministrationAPI.GetCachedEntity(camera.Id); var objIPTZMotorEntity2 = entity as IPTZMotorEntity; IAdminCenterEntity objIAdminCenterEntity = entity as IAdminCenterEntity; bool isReady = false; ISceneGeoLocationEntity objISceneGeoLocationEntity; objISceneGeoLocationEntity = entity as ISceneGeoLocationEntity; if (objISceneGeoLocationEntity != null) { isReady = true; } objISceneGeoLocationEntity = camera as ISceneGeoLocationEntity; if (objISceneGeoLocationEntity != null) { isReady = true; } dynamic ipstream = camera.GetStreamSourceIp(); var eje = camera.DvtelSystem.CreateEntity <ISceneGeoLocationEntity>(); if (isReady) { geographicLocation.latitude = objISceneGeoLocationEntity.Latitude; geographicLocation.altitude = objISceneGeoLocationEntity.Altitude; geographicLocation.longitude = objISceneGeoLocationEntity.Longitude; objCameraPTZ.geographicLocation = geographicLocation; } eje = entity as ISceneGeoLocationEntity; dynamic entityReferencer = entity.GetEntityReferencers()[0].Entity; try { objCameraPTZ.firmware = entityReferencer.FirmwareVersion; } catch { objCameraPTZ.firmware = string.Empty; } try { objCameraPTZ.model = entityReferencer != null ? entityReferencer.Model : string.Empty; } catch { objCameraPTZ.model = string.Empty; } try { objCameraPTZ.pluginName = entityReferencer != null ? entityReferencer.Plugin.Name : string.Empty; } catch { objCameraPTZ.pluginName = string.Empty; } try { objCameraPTZ.pluginVersion = entityReferencer != null ? entityReferencer.pluginVersion : string.Empty; } catch { objCameraPTZ.pluginVersion = string.Empty; } var DataEntities = camera.ExternalDataEntities; var ExternalPluginWorkspaces = camera.ExternalPluginWorkspaces; var GetActiveSchedules = camera.GetActiveSchedules(); var extendedTypes = camera.GetAllExtendedTypes(); var detetionurl = camera.GetCameraMotionDetectionSettingsUrl(); var metadata = camera.GetEntityMetaData(); var cam_entityref = camera.GetEntityReferencers(); var locationCamera = camera.GetPropertyLocalizationEnum(SceneGeoLocationEntityEnum.Altitude); locationCamera = camera.GetPropertyLocalizationEnum(SceneGeoLocationEntityEnum.Latitude); locationCamera = camera.GetPropertyLocalizationEnum(SceneGeoLocationEntityEnum.Longitude); objCameraPTZ.description = camera.Description; objCameraPTZ.guid = camera.Id; objCameraPTZ.isPtzOnline = camera.IsPtzOnline; objCameraPTZ.logicalId = camera.LogicalId; objCameraPTZ.name = camera.Name; objCameraPTZ.creationTime = camera.CreationTime; objCameraPTZ.isViewable = camera.IsViewable; objCameraPTZ.deviceUrl = camera.GetCameraGeneralPageUrl(); dynamic dyCamera = camera; dynamic dyEntity = entity; dynamic entityDynamic = entity; var logiclaloc = entityDynamic.LogicalLocation; try { foreach (var vEvent in camera.EventHandlers.Values.ToList()) { objCameraPTZ.supportedEvents += vEvent.Caption + " "; } } catch { objCameraPTZ.supportedEvents = ""; } objCameraPTZ.clientsConnectionType = camera.ClientsConnectionType != null?camera.ClientsConnectionType.ToString() : string.Empty; objCameraPTZ.detailedInformation = camera.DetailedInformation; objCameraPTZ.deviceDriverExternalId = camera.DeviceDriver != null?camera.DeviceDriver.ExternalId.ToString() : string.Empty; objCameraPTZ.isAccessible = camera.IsAccessible; objCameraPTZ.isEnabled = camera.IsEnabled; objCameraPTZ.linkedUrl = camera.LinkedUrl != null? camera.LinkedUrl.Url:string.Empty; objCameraPTZ.videoSourceFormat = camera.VideoSourceFormat.ToString(); // dynamic dymLoc=GetLoc try { foreach (var vAddress in camera.Addresses.Values.ToList()) { objCameraPTZ.address += vAddress.Caption + " "; } } catch { objCameraPTZ.address = ""; } objCameraPTZ.timeZone = camera.TimeZone.ToString(); objCameraPTZ.IsPtzLocked = camera.IsPtzLocked; objCameraPTZ.IsPtzEnabled = camera.IsPtzEnabled; //} return(objCameraPTZ); }