public void DeleteTempFiles()
        {
            string strPathTemp    = Storage.VideoRepository; //System.Configuration.ConfigurationManager.AppSettings["VideoRepository"];
            string strVideoFile   = strPathTemp + "\\Temp";
            string strSearchParam = "*.*";

            string[] files    = Directory.GetFiles(strVideoFile + "\\", strSearchParam, SearchOption.TopDirectoryOnly);
            int      numFiles = files.Length;

            for (int i = 0; i < numFiles; i++)
            {
                string file = files[i].ToString();
                try
                {
                    if (File.Exists(file))
                    {
                        File.Delete(file);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Info("Mediaintegration DeleteTempFiles() Exception:" + ex.Message);
                    string Message1 = "Mediaintegration-DeleteTempFiles -- Exception = " + ex.Message;
                    //InsertBrokerOperationLog.AddProcessLog(Message1);
                    InsertIntegrationLog.AddProcessLogIntegration(Message1);//jatin
                }
            }
        }
 public string DoorOpen(string strCmd, string CntrIp, string CntrPort)
 {
     try
     {
         try
         {
             int    nChannel   = Int32.Parse(strCmd);
             string strCmdNew  = "lO,1," + nChannel.ToString() + ",36,";
             string strCommand = GetCommand(strCmdNew);
             string result     = TCP(CntrIp, CntrPort, strCommand, "1000");
             return("Suc");
         }
         catch (Exception ex)
         {
             Logger.Info("ACSIntegrationService DoorOpen() Exception" + ex.Message);
             string Message = "ACSIntegrationService--DoorOpen() Function Exception  = " + ex.Message;
             //InsertBrokerOperationLog.AddProcessLog(Message);
             InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
         }
     }
     catch (Exception ex)
     {
         Logger.Info("ACSIntegrationService DoorOpen() Exception" + ex.Message);
         string Message = "ACSIntegrationService--DoorOpen() Function Exception 1  = " + ex.Message;
         //InsertBrokerOperationLog.AddProcessLog(Message);
         InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
     }
     finally
     {
         ClearMemory();
     }
     return("Fail");
 }
        internal static NvrCameraAdapterService Initialise()
        {
            try
            {
                _logger.Info("------------------------------------");
                _logger.Info("starting NvrCamerasService service");

                var service        = new NvrCameraAdapterService();
                var controllerHost = new ServiceHost(service);

                controllerHost.Open();

                _logger.Info("listening at {0}", controllerHost.Description.Endpoints[0].ListenUri);
                _logger.Info("------------------------------------");

                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);   //amit 04112016

                return(service);
            }
            catch (Exception ex)
            {
                _logger.Info("NvrCameraAdapterService Initialise() Exception:" + ex.Message);
                string Message = "NvrCameraAdapterService--- Initialise Exception:" + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            return(null);
        }
        public static string SerializeObject(IEnumerable <AlertDTO> graph)
        {
            try
            {
                var    serializer = new DataContractJsonSerializer(typeof(IEnumerable <AlertDTO>));
                string jsonCode;

                using (var ms = new MemoryStream())
                {
                    serializer.WriteObject(ms, graph);
                    jsonCode = Encoding.Default.GetString(ms.ToArray());
                }
                return(jsonCode);
            }
            catch (Exception ex)
            {
                Logger.Info("ACSIntegrationService SerializeObject Exception" + ex.Message);
                string Message = "ACSIntegrationService--SerializeObject Exception  = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            finally
            {
                ClearMemoryStatic();
            }
            return(null);
        }
Exemple #5
0
        public IEnumerable <object> GetCameraAdditionalInfo(NvrDto nvr)
        {
            try
            {
                var cameraInfoRequest = new AdditionalCameraInfoRequest();

                var camerasInfoCollection = ExecuteRequest <AdditionalCameraInfoResponse, IEnumerable <Object> >(nvr, cameraInfoRequest,
                                                                                                                 result =>
                {
                    var camerasInfos = result.CamerasInfoCollection;
                    return(camerasInfos);
                },
                                                                                                                 exception => _logger.Error("Failed to get camera info collection from server. Error information:\r\n{0}", exception));

                return(camerasInfoCollection.EmptyIfNull());
            }
            catch (Exception ex)
            {
                _logger.Info("NvrService GetCameraAdditionalInfo() Exception:" + ex.Message);
                string Message = "NvrService-GetCameraAdditionalInfo -- Exception = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            finally
            {
                ClearMemory();
            }
            return(null);
        }
        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) //amit 04112016
        {
            _logger.Info("CameraControlService Service Unhandled UI Exception" + (e.ExceptionObject as Exception).Message);
            string Message3 = "CameraControlService Service  CurrentDomain_UnhandledException() Unhandled UI Exception:" + (e.ExceptionObject as Exception).Message;

            InsertIntegrationLog.AddProcessLogIntegration(Message3);
        }
        public IEnumerable <DeviceDto> GetCameras(string nvr)
        {
            try
            {
                //TODO: inject service
                var nvrDto     = Deserialize <NvrDto>(nvr);
                var nvrService = new NvrService();
                nvrService.Initialize();
                var cameras = nvrService.GetCameras(nvrDto);

                return(cameras);
            }
            catch (Exception ex)
            {
                _logger.Info("NvrCameraAdapterService GetCameras() Exception:" + ex.Message);
                string Message = "NvrCameraAdapterService--- GetCameras Exception:" + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            finally
            {
                ClearMemory();
            }
            return(null);
        }
        private static IEnumerable <AlertDTO> DeserializeAlerts(string alerts)
        {
            try
            {
                var serializer = new DataContractJsonSerializer(typeof(IEnumerable <AlertDTO>));
                IEnumerable <AlertDTO> alertDto = null;
                using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(alerts)))
                {
                    alertDto = serializer.ReadObject(stream) as IEnumerable <AlertDTO>;
                }

                return(alertDto);
            }
            catch (Exception ex)
            {
                Logger.Info("ACSIntegrationService DeserializeAlerts Exception" + ex.Message);

                string Message = "ACSIntegrationService--DeserializeAlerts Exception  = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            finally
            {
                ClearMemoryStatic();
            }
            return(null);
        }
        public string DoorClose(string InterfaceId)
        {
            try
            {
                string Message = "MatrixControllerService--DoorClose -- InterfaceId = " + InterfaceId;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin

                AlarmPanelDTO _alarmPanel  = null;
                long          _InterfaceId = long.Parse(InterfaceId);
                using (var ctx = new CentralDBEntities())
                {
                    var resultDb = (from nvr in ctx.alarmPanel
                                    where nvr.InterfaceId == _InterfaceId
                                    select nvr).First();
                    //  _alarmPanel = Mapper.Map<AlarmPanelDTO>(resultDb);    //amit 06102016 manual mapping

                    //amit 06102016 manual mapping
                    if (resultDb != null)
                    {
                        _alarmPanel = new AlarmPanelDTO();
                        _alarmPanel.InterfaceDeviceIP   = resultDb.InterfaceDeviceIP;
                        _alarmPanel.InterfaceDevicePort = resultDb.InterfaceDevicePort;
                        _alarmPanel.AlarmPanelTypeId    = resultDb.AlarmPanelTypeId;
                        _alarmPanel.EventTypeTemplateId = resultDb.EventTypeTemplateId;
                    }
                }
                var _url = "http://" + _alarmPanel.InterfaceDeviceIP + ":" + _alarmPanel.InterfaceDevicePort +

                           "/device.cgi/command?action=lockdoor";
                string     urlParameters = "";// "/" + _alert.AlertId.ToString() + "/" + "1";
                HttpClient client        = new HttpClient();
                client.BaseAddress = new Uri(_url);

                // Add an Accept header for JSON format.
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));

                // List data response.
                HttpResponseMessage response = client.GetAsync(urlParameters).Result;  // Blocking call!
                if (response.IsSuccessStatusCode)
                {
                    return("Suc");
                }
                return("Fail");
            }
            catch (Exception ex)
            {
                _logger.Info("MatrixService DoorClose() Exception" + ex.Message);
                string Message = "MatrixControllerService-DoorClose -- Exception = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            finally
            {
                ClearMemory();
            }
            return("Fail");
        }
        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) //amit 04112016
        {
            Logger.Info("ACSIntegrationService   Unhandled UI Exception" + (e.ExceptionObject as Exception).Message);
            string Message = "ACSIntegrationService--Unhandled UI Exception  = " + (e.ExceptionObject as Exception).Message;

            //InsertBrokerOperationLog.AddProcessLog(Message);
            InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
        }
        internal static void Initialise(NVRServiceAct nvrService)
        {
            try
            {
                _logger.Info("");
                _logger.Info("-----------------------------------l-");
                _logger.Info("starting CameraControlService service");

                _nvrService = nvrService;

                Uri httpUrl = new Uri("https://localhost:6530/CameraControlService");
                //Create ServiceHost
                WebServiceHost serviceHost
                    = new WebServiceHost(typeof(CameraControlService), httpUrl);

                WebHttpBinding _webhttpbis = new WebHttpBinding(WebHttpSecurityMode.Transport);
                _webhttpbis.MaxReceivedMessageSize         = 1073741823;
                _webhttpbis.ReceiveTimeout                 = TimeSpan.Parse("00:10:00");
                _webhttpbis.CloseTimeout                   = TimeSpan.Parse("00:10:00");
                _webhttpbis.OpenTimeout                    = TimeSpan.Parse("00:10:00");
                _webhttpbis.SendTimeout                    = TimeSpan.Parse("00:10:00");
                _webhttpbis.MaxBufferPoolSize              = 524288;
                _webhttpbis.CrossDomainScriptAccessEnabled = true;
                var endpoint = serviceHost.AddServiceEndpoint(typeof(ICameraControlService), _webhttpbis, "");//WSHttpBinding

                ServiceThrottlingBehavior throttleBehavior = new ServiceThrottlingBehavior
                {
                    MaxConcurrentCalls     = 500,
                    MaxConcurrentInstances = 500,
                    MaxConcurrentSessions  = 500,
                };

                serviceHost.Description.Behaviors.Add(throttleBehavior);
                WebHttpBehavior behavior = new WebHttpBehavior();
                behavior.DefaultOutgoingResponseFormat = WebMessageFormat.Json;

                endpoint.Behaviors.Add(behavior);

                serviceHost.Open();

                _logger.Info("CameraControlService service started successfully");

                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); //amit 04112016

                return;                                                                                                             //service;
            }
            catch (Exception ex)
            {
                _logger.Info("GeoTrackingService Initialise() Exception" + ex.Message);
                string Message = "GeoTrackingService-Initialise() -- Exception  = " + ex.Message;
                InsertIntegrationLog.AddProcessLogIntegration(Message);
                return;
            }
            finally
            {
            }
            return;
        }
Exemple #12
0
 public IclockACSIntegrationService()
 {
     try
     {
         // _alertCreationService = alertCreationService;
     }
     catch (Exception ex)
     {
         _logger.Info("IclockACSIntegrationService Service constructor Exception" + ex.Message);
         InsertIntegrationLog.AddProcessLogIntegration("IclockACSIntegrationService Service constructor Exception" + ex.Message);//jatin
     }
 }
Exemple #13
0
 public static void ClearMemoryStatic()
 {
     try
     {
         GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
         GC.WaitForPendingFinalizers();
     }
     catch (Exception ex)
     {
         string Message = "IclockACSTransaction Service -ClearMemoryStatic() -- Exception = " + ex.Message;
         //InsertBrokerOperationLog.AddProcessLog(Message);
         InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
     }
 }
Exemple #14
0
 private void Register <T>(object instance, string name = null)
 {
     try
     {
         _componentsManager.RegisterInstance(typeof(T), name, instance);
     }
     catch (Exception ex)
     {
         _logger.Info("NvrService Register() Exception:" + ex.Message);
         string Message = "NvrService-NvrService Register -- Exception = " + ex.Message;
         //InsertBrokerOperationLog.AddProcessLog(Message);
         InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
     }
 }
 public void ClearMemory()
 {
     try
     {
         GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
         GC.WaitForPendingFinalizers();
     }
     catch (Exception ex)
     {
         string Message = "NvrCameraAdapterService-ClearMemory -- Exception = " + ex.Message;
         //InsertBrokerOperationLog.AddProcessLog(Message);
         InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
     }
 }
Exemple #16
0
 private void Register <T1, T2>(string name = null, bool singlethon = false)
 {
     try
     {
         _componentsManager.RegisterType(typeof(T1), typeof(T2), name, singlethon);
     }
     catch (Exception ex)
     {
         _logger.Info("NvrService Register() Exception:" + ex.Message);
         string Message = "NvrService-NvrService Register-- Exception = " + ex.Message;
         //InsertBrokerOperationLog.AddProcessLog(Message);
         InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
     }
 }
Exemple #17
0
        public IEnumerable <VideoAlarmEvent> GetVideoAlarms(NvrDto nvr, IEnumerable <Guid> sources)
        {
            try
            {
                var alarmRequest = new AlarmsEventsRequestMessageExtended
                {
                    StartDate      = DateTime.Now.ToUniversalTime().AddDays(-1),
                    EndDate        = DateTime.Now,
                    MaxTransaction = 100,
                    PosModeEnabled = false,
                    Sources        = sources,
                    SearchString   = string.Empty
                };

                var alarmsEventsResult = ExecuteRequest <AlarmsEventsResponseMessageExtended, IEnumerable <VideoAlarmEvent> >(nvr, alarmRequest,
                                                                                                                              result =>
                {
                    var alarmEvents = result.Events.Select(alarmEvent => new VideoAlarmEvent
                    {
                        AlarmId     = alarmEvent.AlarmId,
                        AlarmName   = alarmEvent.AlarmName,
                        Cameras     = alarmEvent.Cameras,
                        Date        = alarmEvent.Date,
                        Deactivated = alarmEvent.Deactivated,
                        Description = alarmEvent.Description,
                        EventId     = alarmEvent.EventId,
                        Priority    = alarmEvent.Priority
                    }).ToList();
                    return(alarmEvents);
                },
                                                                                                                              exception => _logger.Error("Failed to get video alarms for server. Error information:\r\n{0}", exception));

                return(alarmsEventsResult.EmptyIfNull());
            }
            catch (Exception ex)
            {
                _logger.Info("NvrService GetVideoAlarms() Exception:" + ex.Message);
                string Message = "NvrService-GetVideoAlarms -- Exception = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            finally
            {
                ClearMemory();
            }
            return(null);
        }
Exemple #18
0
 private void RegisterApplicationComponents()
 {
     try
     {
         _configurationManager = new ConfigurationManagerStub();
         _componentsManager    = new ComponentsManager(_configurationManager, null, null);
         _componentsManager.Run();
         RegisterComponents();
     }
     catch (Exception ex)
     {
         _logger.Info("NvrService RegisterApplicationComponents() Exception:" + ex.Message);
         string Message = "NvrService-RegisterApplicationComponents -- Exception = " + ex.Message;
         //InsertBrokerOperationLog.AddProcessLog(Message);
         InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
     }
 }
Exemple #19
0
 private void ResolveApplicationComponents()
 {
     try
     {
         _videoServersModel = _componentsManager.Resolve <IVideoServersModel>();
         _componentsManager.Resolve <ICamerasManager>();
         this.camerasManager = this._componentsManager.Resolve <ICamerasManager>();
         // camerasManager.Resolve<ICamerasManager>();
         _videoServersManager = _componentsManager.Resolve <IVideoServersManager>();
     }
     catch (Exception ex)
     {
         _logger.Info("NvrService ResolveApplicationComponents() Exception:" + ex.Message);
         string Message = "NvrService-ResolveApplicationComponents -- Exception = " + ex.Message;
         //InsertBrokerOperationLog.AddProcessLog(Message);
         InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
     }
 }
        public static string GetCRCCheksum(string message)
        {
            try
            {
                int      result       = new int();
                string   ResultChksum = string.Empty;
                int      Len          = message.Length;
                string[] hex          = new string[Len];
                //======== Ascii conversion =========================================
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                byte[] ba = encoding.GetBytes(message);

                for (int i = 0; i <= ba.Length - 1; i++)
                {
                    hex[i] = String.Format("{0:X}", ba[i]);
                    if (i >= 1)
                    {
                        if (result == 0)
                        {
                            result = Convert.ToInt32(hex[0].ToString(), 16) ^ Convert.ToInt32(hex[i].ToString(), 16);
                        }
                        else
                        {
                            result = result ^ Convert.ToInt32(hex[i].ToString(), 16);
                        }
                    }
                }
                return(result.ToString("X"));
            }
            catch (Exception ex)
            {
                Logger.Info("ACSIntegrationService GetCRCCheksum() Exception" + ex.Message);

                string Message = "ACSIntegrationService--GetCRCCheksum() Function Exception 1  = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
                return(string.Empty);
            }
            finally
            {
                ClearMemoryStatic();
            }
        }
        internal static ACSIntegrationService Initialise()
        {
            try
            {
                _logger.Info("");
                _logger.Info("------------------------------------");
                _logger.Info("starting ACS Integration service");

                var service = new ACSIntegrationService();

                var controllerHost = new ServiceHost(service);

                foreach (var endpoint in controllerHost.Description.Endpoints)
                {
                    if (endpoint.Binding is WSHttpBinding)
                    {
                        (endpoint.Binding as WSHttpBinding).MaxReceivedMessageSize = Int32.MaxValue;
                        (endpoint.Binding as WSHttpBinding).MaxBufferPoolSize      = Int32.MaxValue;
                    }
                }
                controllerHost.Open();

                //
                //ACSIntegrationClass ObjAcs = new ACSIntegrationClass();
                //ObjAcs.StartUDPServer();
                //

                _logger.Info("listening at {0}", controllerHost.Description.Endpoints[0].ListenUri);
                _logger.Info("------------------------------------");

                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);   //amit 04112016

                return(service);
            }
            catch (Exception ex)
            {
                Logger.Info("ACSIntegrationService start Exception" + ex.Message);
                string Message = "ACSIntegrationService--start Exception  = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            return(null);
        }
        internal static IMatrixControllerService Initialise()
        {
            try
            {
                _logger.Info("");
                _logger.Info("------------------------------------");
                _logger.Info("starting ANPR Service");



                var service = new MatrixControllerService();

                var controllerHost = new ServiceHost(service);

                foreach (var endpoint in controllerHost.Description.Endpoints)
                {
                    if (endpoint.Binding is WSHttpBinding)
                    {
                        (endpoint.Binding as WSHttpBinding).MaxReceivedMessageSize = Int32.MaxValue;
                        (endpoint.Binding as WSHttpBinding).MaxBufferPoolSize      = Int32.MaxValue;
                    }
                }
                controllerHost.Open();
                _logger.Info("IMatrix Service Started Successfully");

                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);   //amit 04112016

                return(service);
            }
            catch (Exception ex)
            {
                _logger.Info("IMatrixControllerService Initialise() Exception" + ex.Message);

                string Message = "MatrixControllerService-Initialise -- Exception = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }

            return(null);
        }
Exemple #23
0
        private void RegisterComponents()
        {
            try
            {
                Register <IConfigurationManager>(_configurationManager);
                Register <IMessageDispatcherFactory, DefaultMessageDispatcherFactory>();
                Register <IConnection, TcpConnection>(ConnectionProtocol.Tcp.ToString());
                Register <IPropertyBagSerializer, PropertyBagBinarySerializer>(MessageFormat.Binary.ToString());
                Register <IPropertyBagFactory, MemoryPropertyBagFactory>();
                Register <IAuthenticatorFactory, NtlmAuthenticatorFactory>(AuthenticationProtocol.Ntlm.ToString());
                Register <IServerController, ServerController>();
                Register <IServerControllerFactory>(new ServerControllerFactory(_componentsManager, TimeSpan.FromMinutes(1)));
                Register <IVideoServersModel, VideoServersModel>(null, true);
                Register <IVideoServersManager, VideoServersManager>(null, true);
                Register <ICamerasManager, CamerasManager>();

                _videoServersModel   = _componentsManager.Resolve <IVideoServersModel>();
                _camerasManager      = _componentsManager.Resolve <ICamerasManager>();
                _videoServersManager = _componentsManager.Resolve <IVideoServersManager>();

                string strPathTemp = Storage.VideoRepository;// System.Configuration.ConfigurationManager.AppSettings["VideoRepository"];
                this.exportDir     = strPathTemp + "\\Temp";
                this.exportService = new MediaExportService(_videoServersManager, new DataPartsSavingService(this.exportDir, MinFreeSpaceForVisualWarning));

                /* _thumbnailsService = new RecordingThumbnailsService(_videoServersManager);
                 * _thumbnailsCacheService = new RecordingThumbnailsCacheService(thumbnailsCasheDir, 1*100);
                 *
                 * _recordingThumbnailsProviderFactory = new RecordingThumbnailsProviderFactory(_thumbnailsService,
                 *                                                                            _thumbnailsCacheService);*/
            }
            catch (Exception ex)
            {
                _logger.Info("NvrService RegisterComponents() Exception:" + ex.Message);
                string Message = "NvrService-RegisterComponents -- Exception = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }

            // Register<IShell, Shell>();
        }
        public string DoorOpen(string strCmd, string CntrIp, string CntrPort)
        {
            try
            {
                string Message = "Acs integration class -DoorOpen()-- Command = " + strCmd + "-- CntrIp = " + CntrIp + "-- CntrPort = " + CntrPort;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin


                string strCommand = GetCommand(strCmd);

                TcpClient tcpClient = new TcpClient();
                tcpClient.Connect(CntrIp, Int32.Parse(CntrPort));
                NetworkStream networkStream      = tcpClient.GetStream();
                StreamReader  clientStreamReader = new StreamReader(networkStream);
                StreamWriter  clientStreamWriter = new StreamWriter(networkStream);
                clientStreamWriter.Write(strCommand);

                char[] buf = new char[1024];
                while (true)
                {
                    clientStreamReader.Read(buf, 1, 5);
                    if (buf != null)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Info("ACSIntegrationClass DoorOpen Exception" + ex.Message);
                string Message = "Acs integration class -DoorOpen()-- Exception" + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }

            return("Fail");
        }
        public string GetCommand(string strCmd)
        {
            try
            {
                string CHECKSUM = GetCRCCheksum("$" + CharValue("1") + strCmd);
                strCmd = "$" + CharValue("1") + strCmd + CHECKSUM + "\r\n";

                string strInPut = strCmd;// +strCmd;
                return(strInPut);
            }
            catch (Exception ex)
            {
                Logger.Info("ACSIntegrationService GetCommand() Exception" + ex.Message);
                string Message = "ACSIntegrationService--GetCommand() Function Exception 1  = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            finally
            {
                ClearMemory();
            }
            return("");
        }
Exemple #26
0
        // Make it service locator like
        private IServerController InitializeServer(NvrDto nvrDto)
        {
            try
            {
                var videoServerEntity = new VideoServerEntity
                {
                    Address      = nvrDto.IPAddress,
                    Id           = Guid.NewGuid(),
                    Name         = nvrDto.Description,
                    Port         = nvrDto.Port,
                    UserName     = nvrDto.Username,
                    UserPassword = nvrDto.Password,
                    UserDomain   = string.Empty
                };

                _videoServersModel.AddServer(videoServerEntity);
                var serverController = _videoServersManager.GetServer(videoServerEntity.Id);
                serverController.ServerControllerError += (s, e) =>
                {
                    _logger.Error("Server error: {0}", e.Error);
                };

                return(serverController);
            }
            catch (Exception ex)
            {
                _logger.Info("NvrService InitializeServer() Exception:" + ex.Message);
                string Message = "NvrService-InitializeServer -- Exception = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            finally
            {
                ClearMemory();
            }
            return(null);
        }
        public static string CharValue(string a)
        {
            //char value = (char)(Convert.ToInt32(a) + 48);
            //return value.ToString();
            try
            {
                string value = "";
                value = Convert.ToChar((Convert.ToInt32(a) + 48)).ToString();

                return(value.ToString());
            }
            catch (Exception ex)
            {
                Logger.Info("ACSIntegrationService CharValue() Exception" + ex.Message);
                string Message = "ACSIntegrationService--CharValue() Function Exception 1  = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            finally
            {
                ClearMemoryStatic();
            }
            return(null);
        }
Exemple #28
0
        public IEnumerable <VideoAlarmEvent> GetVideoAlarms(NvrDto nvr, IEnumerable <DeviceDto> nvrDevices)
        {
            try
            {
                var devices =
                    nvrDevices.EmptyIfNull()
                    .Where(dto => dto.InterfaceId == nvr.InterfaceId)
                    .Select(device => Guid.Parse(device.CameraGUID));

                return(GetVideoAlarms(nvr, devices));
            }
            catch (Exception ex)
            {
                _logger.Info("NvrService GetVideoAlarms() Exception:" + ex.Message);
                string Message = "NvrService-GetVideoAlarms -- Exception = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            finally
            {
                ClearMemory();
            }
            return(null);
        }
Exemple #29
0
        internal static IclockACSIntegrationService Initialise()//IAlertsGetOperationService alertservice
        {
            try
            {
                _logger.Info("");
                _logger.Info("");
                _logger.Info("------------------------------------");
                _logger.Info("starting IclockACSTransaction Service.");

                InsertIntegrationLog.AddProcessLogIntegration("");
                InsertIntegrationLog.AddProcessLogIntegration("------------------------------------");
                InsertIntegrationLog.AddProcessLogIntegration("starting IclockACS TransactionService.");//jatin

                var service = new IclockACSIntegrationService();
                // var controllerHost = new ServiceHost(service);
                // controllerHost.Open();
                //
                Uri httpUrl = new Uri("https://localhost:6530/IclockACSIntegrationService");

                WebServiceHost controllerHost
                    = new WebServiceHost(typeof(IclockACSIntegrationService), httpUrl);

                WebHttpBinding _webhttpbis = new WebHttpBinding(WebHttpSecurityMode.Transport);

                _webhttpbis.ReceiveTimeout                 = TimeSpan.Parse("00:10:00");
                _webhttpbis.CloseTimeout                   = TimeSpan.Parse("00:10:00");
                _webhttpbis.OpenTimeout                    = TimeSpan.Parse("00:10:00");
                _webhttpbis.SendTimeout                    = TimeSpan.Parse("00:10:00");
                _webhttpbis.MaxBufferPoolSize              = 2147483647; //524288;
                _webhttpbis.MaxReceivedMessageSize         = 2147483647; //1073741823;
                _webhttpbis.MaxBufferSize                  = 2147483647; //1073741823;
                _webhttpbis.CrossDomainScriptAccessEnabled = true;

                XmlDictionaryReaderQuotas myReaderQuotas = new XmlDictionaryReaderQuotas();
                myReaderQuotas.MaxStringContentLength = 2147483647;
                myReaderQuotas.MaxArrayLength         = 2147483647;
                myReaderQuotas.MaxBytesPerRead        = 2147483647;
                myReaderQuotas.MaxDepth = 2147483647;
                myReaderQuotas.MaxNameTableCharCount = 2147483647;

                _webhttpbis.GetType().GetProperty("ReaderQuotas").SetValue(_webhttpbis, myReaderQuotas, null);

                var endpoint = controllerHost.AddServiceEndpoint(typeof(IIclockACSIntegrationService), _webhttpbis, "");//WSHttpBinding

                ServiceThrottlingBehavior throttleBehavior = new ServiceThrottlingBehavior
                {
                    MaxConcurrentCalls     = 500,
                    MaxConcurrentInstances = 500,
                    MaxConcurrentSessions  = 500,
                };

                controllerHost.Description.Behaviors.Add(throttleBehavior);
                WebHttpBehavior behavior = new WebHttpBehavior();
                behavior.DefaultOutgoingResponseFormat = WebMessageFormat.Json;
                endpoint.Behaviors.Add(behavior);
                controllerHost.Open();

                //if (cams3SdkUser == null)
                //{
                //    cams3SdkUser = new Cams3SdkUser();
                //}
                //
                _logger.Info(string.Format("listening at {0}", controllerHost.Description.Endpoints[0].ListenUri));
                _logger.Info("------------------------------------");
                _logger.Info("");
                InsertIntegrationLog.AddProcessLogIntegration(string.Format("listening at " + controllerHost.Description.Endpoints[0].ListenUri)); //jatin
                InsertIntegrationLog.AddProcessLogIntegration("------------------------------------");
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);                //amit 04112016

                return(service);
            }
            catch (Exception ex)
            {
                _logger.Info("IclockACSTransactionService Initialise() Exception" + ex.Message);
            }
            return(null);
        }
        private void _sequenceTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                _sequenceTimer.Stop();

                ////Read all the Image file Tickets and process them
                string   strSsa   = "";
                string   strPath  = Storage.AlertMediaTicket;//System.Configuration.ConfigurationManager.AppSettings["AlertMediaTicket"];
                string[] files    = Directory.GetFiles(strPath + "\\", "AlertMediaImage_*.tkt", SearchOption.TopDirectoryOnly);
                int      numFiles = files.Length;

                for (int i = 0; i < numFiles; i++)
                {
                    string   file     = files[i].ToString();
                    string   contents = File.ReadAllText(file);
                    string[] nIds     = contents.Split(',');
                    if (nIds.Length > 0)
                    {
                        try
                        {
                            _media = new AlertMediaintegration(_nvrServices);
                            _media.GetAlertImage(nIds[0], nIds[1], nIds[2], nIds[3], nIds[4], nIds[5], nIds[6], nIds[7], file);
                            //Task taskA = Task.Factory.StartNew(() =>  _media.GetAlertImage(nIds[0], nIds[1], nIds[2], nIds[3], nIds[4], nIds[5], nIds[6], nIds[7], file));
                            //taskA.Wait();
                            Thread.Sleep(10000);
                        }
                        catch (Exception ex)
                        {
                            Logger.Info("Mediaintegration _sequenceTimer_Tick() Exception:" + ex.Message);

                            string Message1 = "Mediaintegration-_sequenceTimer_Tick -- Exception = " + ex.Message;
                            //InsertBrokerOperationLog.AddProcessLog(Message1);
                            InsertIntegrationLog.AddProcessLogIntegration(Message1);//jatin
                        }
                    }
                }


                ////Read all the PlayBack file Tickets and process them
                ////Delete all exisitng files from Temp Derectory

                DeleteTempFiles();
                string   strPathPlyBack = Storage.AlertMediaTicket;//System.Configuration.ConfigurationManager.AppSettings["AlertMediaTicket"];
                string[] filesplayBack  = Directory.GetFiles(strPathPlyBack + "\\", "AlertMediaPlayBack_*.tkt", SearchOption.TopDirectoryOnly);
                int      numFilesply    = filesplayBack.Length;

                for (int i = 0; i < numFilesply; i++)
                {
                    string   file     = filesplayBack[i].ToString();
                    string   contents = File.ReadAllText(file);
                    string[] nIds     = contents.Split(',');
                    if (nIds.Length > 0)
                    {
                        try
                        {
                            _media = new AlertMediaintegration(_nvrServices);
                            _media.GetAlertPlayBack(nIds[0], nIds[1], nIds[2], nIds[3], nIds[4], nIds[5], nIds[6], nIds[7], file);
                            //Task taskA = Task.Factory.StartNew(() =>  _media.GetAlertImage(nIds[0], nIds[1], nIds[2], nIds[3], nIds[4], nIds[5], nIds[6], nIds[7], file));
                            Thread.Sleep(10000);
                            while (_media.IsCompleted == false)
                            {
                                int ya = 0;
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.Info("Mediaintegration _sequenceTimer_Tick() Exception:" + ex.Message);
                            string Message1 = "Mediaintegration-_sequenceTimer_Tick -- Exception 1= " + ex.Message;
                            //InsertBrokerOperationLog.AddProcessLog(Message1);
                            InsertIntegrationLog.AddProcessLogIntegration(Message1);//jatin
                        }
                    }
                }

                ////Read all the IR Attched Caemra Playback file Tickets and process them
                ////Delete all exisitng files from Temp Derectory

                DeleteTempFiles();
                strPathPlyBack = Storage.AlertMediaTicket;//System.Configuration.ConfigurationManager.AppSettings["AlertMediaTicket"];
                filesplayBack  = Directory.GetFiles(strPathPlyBack + "\\", "IRCameraPlayBack_*.tkt", SearchOption.TopDirectoryOnly);
                numFilesply    = filesplayBack.Length;

                for (int i = 0; i < numFilesply; i++)
                {
                    string   file     = filesplayBack[i].ToString();
                    string   contents = File.ReadAllText(file);
                    string[] nIds     = contents.Split(',');
                    if (nIds.Length > 0)
                    {
                        try
                        {
                            _media = new AlertMediaintegration(_nvrServices);
                            _media.GetIRPlayBack(nIds[0], nIds[1], nIds[2], nIds[3], nIds[4], nIds[5], nIds[6], nIds[7], nIds[8], file);
                            //Task taskA = Task.Factory.StartNew(() =>  _media.GetAlertImage(nIds[0], nIds[1], nIds[2], nIds[3], nIds[4], nIds[5], nIds[6], nIds[7], file));
                            Thread.Sleep(10000);
                            while (_media.IsCompleted == false)
                            {
                                int ya = 0;
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.Info("Mediaintegration _sequenceTimer_Tick() Exception:" + ex.Message);
                            string Message1 = "Mediaintegration-_sequenceTimer_Tick -- Exception 2= " + ex.Message;
                            //InsertBrokerOperationLog.AddProcessLog(Message1);
                            InsertIntegrationLog.AddProcessLogIntegration(Message1);//jatin
                        }
                    }
                }

                ////Read all the Bookmark Attched Caemra Playback file Tickets and process them
                ////Delete all exisitng files from Temp Derectory

                DeleteTempFiles();
                strPathPlyBack = Storage.AlertMediaTicket; //System.Configuration.ConfigurationManager.AppSettings["AlertMediaTicket"];
                filesplayBack  = Directory.GetFiles(strPathPlyBack + "\\", "CameraDeviceBookMark_*.tkt", SearchOption.TopDirectoryOnly);
                numFilesply    = filesplayBack.Length;

                for (int i = 0; i < numFilesply; i++)
                {
                    string   file     = filesplayBack[i].ToString();
                    string   contents = File.ReadAllText(file);
                    string[] nIds     = contents.Split(',');
                    if (nIds.Length > 0)
                    {
                        try
                        {
                            _media = new AlertMediaintegration(_nvrServices);
                            _media.GetBookmarkPlayBack(nIds[0], nIds[1], nIds[2], nIds[3], nIds[4], nIds[5], nIds[6], nIds[7], nIds[8], file);
                            //Task taskA = Task.Factory.StartNew(() =>  _media.GetAlertImage(nIds[0], nIds[1], nIds[2], nIds[3], nIds[4], nIds[5], nIds[6], nIds[7], file));
                            Thread.Sleep(10000);
                            while (_media.IsCompleted == false)
                            {
                                int ya = 0;
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.Info("Mediaintegration _sequenceTimer_Tick() Exception:" + ex.Message);
                            string Message1 = "Mediaintegration-_sequenceTimer_Tick -- Exception 3= " + ex.Message;
                            //InsertBrokerOperationLog.AddProcessLog(Message1);
                            InsertIntegrationLog.AddProcessLogIntegration(Message1);//jatin
                        }
                    }
                }


                _sequenceTimer.Start();
            }
            catch (Exception ex)
            {
                Logger.Info("Mediaintegration _sequenceTimer_Tick() Exception:" + ex.Message);
                string Message1 = "Mediaintegration-_sequenceTimer_Tick -- Exception 4= " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message1);
                InsertIntegrationLog.AddProcessLogIntegration(Message1);//jatin
                _sequenceTimer.Start();
            }
        }