Пример #1
0
        public void PingClient(object sender, ElapsedEventArgs e)
        {
            _PingClientTimer.Stop();
            try
            {
                using (var context = new CentralDBEntities())
                {
                    //var result2 = stationEntity.Select(x => x.IsActive == true && !x.Identifier.Contains("Webclient") && !x.Identifier.Contains("Mobile")).ToArray();

                    var fromStation = context.Station.Where(it => it.IsActive == true && !it.Identifier.Contains("Webclient") && !it.Identifier.Contains("Mobile"));
                    var result      = fromStation.Select(Mapper.Map <AMS.Broker.Contracts.DTO.Station>).ToArray();
                    if (result.Count() > 0)
                    {
                        foreach (var actstation in result)
                        {
                            string strIp = actstation.LocationDescription;
                            if (strIp != "")
                            {
                                try
                                {
                                    //string _strUrl = "http://" + strIp + ":4532/soap/LoginStatusService";
                                    string          _strUrl = "http://" + strIp + ":6532/ControllerCallBackCommService";
                                    EndpointAddress ar      = new EndpointAddress(_strUrl);
                                    AMS.Broker.WatchDogService.LoginStatusServiceRef.LoginStatusClient _serVice = new AMS.Broker.WatchDogService.LoginStatusServiceRef.LoginStatusClient("WSHttpBinding_ILoginStatus", ar.ToString()); //WSHttpBinding_ILoginStatus
                                    _serVice.Endpoint.Binding.OpenTimeout = TimeSpan.FromSeconds(3);
                                    _serVice.Endpoint.Binding.SendTimeout = TimeSpan.FromSeconds(3);
                                    int nRetVal = _serVice.CheckStatus();
                                    _serVice.Close();
                                    if (nRetVal < 1)
                                    {
                                        actstation.IsActive = false;
                                        context.SaveChanges();
                                        ClearMemory();
                                    }
                                    if (nRetVal == 1)
                                    {
                                        actstation.IsActive = true;
                                        context.SaveChanges();
                                        ClearMemory();
                                    }
                                }
                                catch (Exception ex)
                                {
                                    var station = context.Station.FirstOrDefault(x => x.LocationDescription == strIp);
                                    station.IsActive = false;
                                    context.SaveChanges();
                                    ClearMemory();
                                }
                            }
                        }
                    }
                }

                _PingClientTimer.Start();
            }
            catch (Exception ex)
            {
                _logger.Info("GatewayService PingClient() Exception" + ex.Message);
                InsertBrokerOperationLog.AddProcessLog("GatewayService PingClient() Exception" + ex.Message);
            }
            //get active station
            //ping active station
            //update station status if not ping
        }
Пример #2
0
        //PTZ Handoff
        public void PTZHandoff(string nNvrId, string srePresetNum, string strCamGuid)//For Quadrox only
        {
            try
            {
                InsertIntegrationLog.AddProcessLogIntegration("PTZHandoff nNvrId:" + nNvrId + "--!--PresetNum:" + srePresetNum + "--!--CamGuid:" + strCamGuid);
                NvrDto result     = null;
                int    nPresetNum = Int32.Parse(srePresetNum);

                if (nPresetNum != 0)
                {
                    nPresetNum = nPresetNum - 1;
                }

                if (_nvrService != null)
                {
                    try
                    {
                        int _nNvrId = Int32.Parse(nNvrId);

                        using (var ctx = new CentralDBEntities())
                        {
                            var resultDb = (from nvr in ctx.NVR
                                            where nvr.NvrId == _nNvrId
                                            select nvr).First();
                            if (resultDb != null)
                            {
                                result = new NvrDto()
                                {
                                    Description = resultDb.Description,
                                    InterfaceId = int.Parse(resultDb.InterfaceId.ToString()),
                                    IPAddress   = resultDb.IPAddress,
                                    NvrId       = resultDb.NvrId,
                                    NvrUrl      = resultDb.NvrUrl,
                                    Password    = resultDb.Password,
                                    Port        = int.Parse(resultDb.Port.ToString()),
                                    Username    = resultDb.Username
                                };
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        InsertIntegrationLog.AddProcessLogIntegration("PTZHandoff get nvr details Exception :" + strCamGuid);
                    }

                    if (result != null)
                    {
                        NvrDto _nvr = result;

                        QL.Communication.Server.IServerController server;
                        _nvrService.AddServer(
                            _nvr.IPAddress,
                            _nvr.Port,
                            _nvr.Username,
                            _nvr.Password,
                            ""
                            );   //2020IMAGING

                        if (_nvrService.GetServerController().State == QL.Communication.Server.ServerControllerState.Connected)
                        {
                            InsertIntegrationLog.AddProcessLogIntegration("PTZHandoff  inside if :");

                            QL.Communication.Server.VideoServerEntity serverEntity = _nvrService.GetServer(_nvr.IPAddress);//nvr ipaddress

                            if (_nvrService.GetServerManager().TryGetServer(serverEntity.Id, out server))
                            {
                                var request = new QL.Communication.Messaging.Messages.PtzGoToPresetRequest
                                {
                                    SourceId     = new Guid(strCamGuid),//PTX Camera Guid
                                    PresetNumber = (byte)nPresetNum
                                };

                                server.SendAndGetResponseAsObservable <QL.Communication.Messaging.Messages.EmptyMessage>(request).Subscribe(
                                    ok =>
                                {
                                    InsertIntegrationLog.AddProcessLogIntegration("PTZHandoff  ok :");
                                },
                                    error =>
                                {
                                    InsertIntegrationLog.AddProcessLogIntegration("PTZHandoff error :" + error);
                                });
                            }
                        }
                        else
                        {
                            InsertIntegrationLog.AddProcessLogIntegration("PTZHandoff  inside else :");

                            _nvrService.GetServerController().Connected += (sender, args) =>
                            {
                                QL.Communication.Server.VideoServerEntity serverEntity = _nvrService.GetServer(_nvr.IPAddress);//nvr ipaddress

                                InsertIntegrationLog.AddProcessLogIntegration("PTZHandoff  serverEntity.Id :" + serverEntity.Id);

                                if (_nvrService.GetServerManager().TryGetServer(serverEntity.Id, out server))
                                {
                                    var request = new QL.Communication.Messaging.Messages.PtzGoToPresetRequest
                                    {
                                        SourceId     = new Guid(strCamGuid), //PTX Camera Guid
                                        PresetNumber = (byte)nPresetNum      //_associatedPtzDev.PresetNumber //amit 23 May 16
                                    };
                                    server.SendAndGetResponseAsObservable <QL.Communication.Messaging.Messages.EmptyMessage>(request).Subscribe(
                                        ok =>
                                    {
                                        InsertIntegrationLog.AddProcessLogIntegration("PTZHandoff else ok :");
                                    },
                                        error =>
                                    {
                                        InsertIntegrationLog.AddProcessLogIntegration("PTZHandoff else error :" + error);
                                    });
                                }
                            };
                        }
                    }
                    //
                }
            }
            catch (Exception ex)
            {
                InsertIntegrationLog.AddProcessLogIntegration("PTZHandoff Main catch Exception :" + ex.Message);
                // LogManager.GetCurrentClassLogger().Error(ex.Message);
            }
        }
        public string DoorOpen(string InterfaceId)
        {
            string Message = "MatrixControllerService--DoorOpen -- InterfaceId = " + InterfaceId;

            //InsertBrokerOperationLog.AddProcessLog(Message);
            InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin

            try
            {
                try
                {
                    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
                        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=unlockdoor";
                    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 DoorOpen() Exception" + ex.Message);
                    string Message1 = "MatrixControllerService-DoorOpen -- Exception = " + ex.Message;
                    //InsertBrokerOperationLog.AddProcessLog(Message);
                    InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
                }
            }
            catch (Exception ex)
            {
                _logger.Info("MatrixService DoorOpen() Exception" + ex.Message);
                string Message1 = "MatrixControllerService-DoorOpen -- Exception = " + ex.Message;
                //InsertBrokerOperationLog.AddProcessLog(Message);
                InsertIntegrationLog.AddProcessLogIntegration(Message);//jatin
            }
            finally
            {
                ClearMemory();
            }
            return("Fail");
        }
Пример #4
0
 public DTPEstimationService()
 {
     _dbContext      = new CentralDBEntities();
     _sqlConnService = new SqlConnectionService();
     BaseModel       = new BaseViewModel();
 }
 public DashboardSuperAdminService()
 {
     _dbContext      = new CentralDBEntities();
     _sqlConnService = new SqlConnectionService();
     BaseModel       = new BaseViewModel();
 }
Пример #6
0
 public NotificationService()
 {
     _dbContext = new CentralDBEntities();
 }
Пример #7
0
 public static TEntity ApplyCurrentValues <TEntity>(this CentralDBEntities ctx, TEntity entity) where TEntity : class
 {
     return(((IObjectContextAdapter)ctx).ObjectContext.ApplyCurrentValues <TEntity>(typeof(TEntity).Name, entity));
 }
Пример #8
0
 public static void Logout(this CentralDBEntities context, string authToken, string identifier)
 {
     Logout(context, Guid.Parse(authToken), identifier);
 }
Пример #9
0
 public CompanyService(ICompanyRepository _companyRepository) : base(_companyRepository)
 {
     companyRepository = _companyRepository;
     _sqlConnService   = new SqlConnectionService();
     _dbContext        = new CentralDBEntities();
 }