Example #1
0
 /// <summary>
 /// 启动服务
 /// </summary>
 /// <param name="args"></param>
 protected override void OnStart(string[] args)
 {
     if (NVR.DeviceIP == "" || NVR.DevicePort == default(Int32) || NVR.UserName == "" || NVR.Password == "")
     {
         WriteLog("Please input IP, Port, User name and Password!");
         return;
     }
     //设置报警回调函数
     HikHelper.SetAlarmCallBack();
     // 设备登录
     NVRLoginUserID = HikHelper.NetDVRLogin(NVR);
     // 设备布防
     AiServiceThread = new Thread(CollectArgManage)
     {
         IsBackground = true
     };
     AiServiceThread.Start();
 }
Example #2
0
        /// <summary>
        /// 终止服务
        /// </summary>
        protected override void OnStop()
        {
            // 撤防
            if (AlarmHandleID != null)
            {
                var res = HikHelper.NetDVRCloseAlarmChan(AlarmHandleID);
            }

            //注销登录
            if (NVRLoginUserID != null)
            {
                HikHelper.NetDVRLogout(NVRLoginUserID);
            }
            //释放SDK资源,在程序结束之前调用
            HikHelper.NetDVRClearup();
            // 清空日志
            var fPath = AppDomain.CurrentDomain.BaseDirectory + "/log/";

            FileHelper.DeleteFolderFiles(fPath, "");
            //this.Stop();
        }
Example #3
0
 public Service1()
 {
     InitializeComponent();
     // SDK初始化
     if (!HikHelper.NetDVRInit())
     {
         Environment.Exit(0);
         return;
     }
     NVR = new HikvisionNvr()
     {
         DeviceIP   = ConfigurationManager.AppSettings.Get("NVR_IP").ToString(),
         DevicePort = Convert.ToInt16(ConfigurationManager.AppSettings.Get("NVR_Port").ToString()),
         UserName   = ConfigurationManager.AppSettings.Get("NVR_UserName").ToString(),
         Password   = ConfigurationManager.AppSettings.Get("NVR_Password").ToString()
     };
     //设置SDK 日志
     HikHelper.NetDVRSetLogToFile();
     //设置透传报警信息类型
     HikHelper.NetDVRSetSDKLocalCfg();
 }
Example #4
0
 private void CollectArgManage()
 {
     AlarmHandleID = HikHelper.NetDVRSetupAlarm(NVRLoginUserID);
 }