示例#1
0
        /// <summary>
        /// 更新xml内容
        /// </summary>
        /// <param name="heartJd"></param>
        public void UpdateHeartVersion(HeartVersion heartJd)
        {
            try
            {
                //XDocument xDoc = XDocument.Load(xmlAddr);
                //xDoc.Root.SetElementValue("Version", heartJd.Version);
                //xDoc.Root.SetElementValue("OverFlowCount", heartJd.OverFlowCount);
                //xDoc.Save(xmlAddr);

                dataBaseDic.Update <ParkDic>(new ParkDic()
                {
                    KeyStr = "Version", ValueStr = heartJd.Version
                }, "Version");
                dataBaseDic.Update <ParkDic>(new ParkDic()
                {
                    KeyStr = "OverFlowCount", ValueStr = heartJd.OverFlowCount.ToString()
                }, "OverFlowCount");
            }
            catch (Exception ex)
            {
                string message = string.Format("{0}:版本更新出错:{1}", DateTime.Now.ToString(), ex.Message);
                if (CommonSettings.IsDev)
                {
                    Console.WriteLine(message);
                }
                LogHelper.Error(message);
                throw ex;
            }
        }
示例#2
0
        /// <summary>
        /// 定时执行心跳任务
        /// </summary>
        public bool HeartCheck()
        {
            try
            {
                HeartVersion heartJd = jdParkBiz.HeartBeatCheckJd();

                if (heartJd.returnCode == "fail")
                {
                    //客户端未验证
                    string message = string.Format("{0}:心跳检测响应Fail:{1}", DateTime.Now.ToString(), heartJd.description);
                    if (CommonSettings.IsDev)
                    {
                        Console.WriteLine(message);
                    }
                    LogHelper.Error(message);
                    return(true);
                }
                if (heartJd.returnCode == "exception")
                {
                    //服务端异常
                    string message = string.Format("{0}:心跳检测响应exception:{1}", DateTime.Now.ToString(), heartJd.description);
                    if (CommonSettings.IsDev)
                    {
                        Console.WriteLine(message);
                    }
                    LogHelper.Error(message);
                    return(true);
                }
                if (heartJd.Version != ParkBiz.version)
                {
                    //版本号不一致需要同步白名单,获取白名单数据成功后,更新版本xml
                    if (UpdateWhiteList(ParkBiz.version))
                    {
                        ParkBiz.version       = heartJd.Version;
                        ParkBiz.overFlowCount = heartJd.OverFlowCount;
                        UpdateHeartVersion(heartJd);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string message = string.Format("{0}:心跳检测出错:{1}", DateTime.Now.ToString(), ex.Message);
                if (CommonSettings.IsDev)
                {
                    Console.WriteLine(message);
                }
                LogHelper.Error(message);
                return(false);
            }
        }