Esempio n. 1
0
        /// <summary> 心跳包\在线客户端线程
        /// </summary>
        public static void _HeartBeatThread()
        {
            while (true)
            {
                if (LoginFlag)
                {
                    int minute = DateTime.Now.Minute;
                    if (minute % 5 == 0 && (minute > 4 || minute == 0))
                    {
                        //服务站在线状态

                        ContolHandler.UpLoadServerStatus();
                        DateTime currentTime = GlobalStaticObj_Server.Instance.CurrentDateTime;

                        foreach (string dbName in _dbList)
                        {
                            //在线用户
                            ContolHandler.UpLoadOnline(dbName, GlobalStaticObj_Server.Instance.UserUploadTime.ToString());
                        }

                        //备份上传时间
                        GlobalStaticObj_Server.Instance.LastUploadTime = currentTime.Ticks.ToString();
                        //写入
                        ConfigManager.SaveConfig(ConfigConst.UserUploadTime,
                                                 GlobalStaticObj_Server.Instance.UserUploadTime, ConfigConst.ConfigPath);
                    }

                    HeartBeatHandler.SendHeartBeat();
                }

                //心跳包间隔
                Thread.Sleep(waitSecond * 1000);
            }
        }
Esempio n. 2
0
 public static string GetStationPeriodValidityFromCloud()
 {
     if (LoginFlag)
     {
         var mp = ServiceAgent.SendAndReceiveMessage(ContolHandler.GetC3Protocol());
         if (mp != null && mp.GetRealProtocol() is ResultProtocol)
         {
             var result = mp.GetRealProtocol() as ResultProtocol;
             if (result.Result == DataSources.EnumResultType.Success.ToString("d"))
             {
                 var lastIndex = result.ToString().LastIndexOf("$", StringComparison.Ordinal);
                 var ticks     = result.ToString().Substring(lastIndex + 1, result.ToString().Length - 1 - lastIndex);
                 return(ticks);
             }
             else
             {
                 string msg = "服务站有效期:" +
                              DataSources.GetDescription(typeof(DataSources.EnumResultType), result.Result);
                 //写入日志
                 Log.writeCloudLog(msg);
                 return(DataSources.GetDescription(typeof(DataSources.EnumResultType), result.Result));
             }
         }
         return("返回协议格式不正确");
     }
     return("无法连接云平台");
 }
Esempio n. 3
0
 /// <summary>
 /// 消息处理
 /// </summary>
 /// <param name="protocol"></param>
 public new void Do(ref bool flag)
 {
     if (this.MessageId == id)
     {
         ContolHandler.Deal(this);
     }
 }
Esempio n. 4
0
        /// <summary> 心跳包\在线客户端线程
        /// </summary>
        public static void _HeartBeatThread()
        {
            try
            {
                var min = 0;
                while (true)
                {
                    if (LoginFlag)
                    {
                        int minute = DateTime.Now.Minute;
                        if (minute % 5 == 0 && (minute > 4 || minute == 0))
                        {
                            FactoryHandler.HandleLocalFacData();
                            //服务站在线状态
                            ContolHandler.UpLoadServerStatus();
                            DateTime currentTime = GlobalStaticObj_Server.Instance.CurrentDateTime;

                            foreach (string dbName in _dbList)
                            {
                                //在线用户
                                ContolHandler.UpLoadOnline(dbName, GlobalStaticObj_Server.Instance.UserUploadTime.ToString());
                            }

                            //备份上传时间
                            GlobalStaticObj_Server.Instance.LastUploadTime = currentTime.Ticks.ToString();
                            //写入
                            ConfigManager.SaveConfig(ConfigConst.UserUploadTime, GlobalStaticObj_Server.Instance.UserUploadTime, ConfigConst.ConfigPath);
                        }
                        //if (min != minute)
                        //{
                        HeartBeatHandler.SendHeartBeat();
                        min = minute;
                        //}
                    }
                    //心跳包间隔
                    Thread.Sleep(waitSecond * 1000);
                }
            }
            catch (Exception ex)
            {
                GlobalStaticObj_Server.CloudPadLogService.WriteLog("云平台", ex);
            }
        }
Esempio n. 5
0
 /// <summary> 写错误日志
 /// </summary>
 public new void ErrorLog()
 {
     ContolHandler.WriteErrorLog(this);
 }