Example #1
0
        //private void Handle70Message(string strMsg)
        //{
        //    string strcarID, strLSH, strCCXH;
        //    if (strMsg.Substring(0, 1) == "(" && strMsg.Substring(strMsg.Length - 1, 1) == ")")
        //    {
        //        strcarID = GetValueByKey(strMsg, "ID");
        //        strLSH = GetValueByKey(strMsg, "LSH");
        //        if (strcarID != "")
        //        {
        //            if (strLSH.Length == 21)
        //            {
        //                strCCXH = strLSH.Substring(strLSH.Length - 2, 2);
        //                strLSH = strLSH.Substring(0, strLSH.Length - 2);
        //                VehInfo vi = new VehInfo(strLSH, strCCXH);
        //                if (_VehMap.ContainsKey(strcarID))
        //                {
        //                    _VehMap[strcarID] = vi;
        //                }
        //                else
        //                {
        //                    _VehMap.Add(strcarID, vi);
        //                }
        //            }
        //            else if (strLSH.Length == 19)
        //            {
        //                if (_VehMap.ContainsKey(strcarID))
        //                {
        //                    if (_VehMap[strcarID].LSH != strLSH)
        //                    {
        //                        VehInfo vi = new VehInfo(strLSH, "");
        //                        _VehMap[strcarID] = vi;
        //                    }
        //                }
        //                else
        //                {
        //                    VehInfo vi = new VehInfo(strLSH, "");
        //                    _VehMap.Add(strcarID, vi);
        //                }
        //            }
        //            else
        //            {
        //                return;
        //            }
        //        }
        //    }
        //}

        private void Handle40Message(string strMsg)
        {
            string strcarID, strLSH, strCCXH;

            try
            {
                strcarID = GetValueByKey(strMsg, "ID");
                strLSH   = GetValueByKey(strMsg, "LSH");
                if (_VehMap.ContainsKey(strcarID))
                {
                    TimeSpan ts = DateTime.Now - _VehMap[strcarID];
                    if (ts.TotalMinutes < SysParameters.VehInfoInterval)
                    {
                        return;
                    }
                }
                if (strMsg.Substring(0, 1) == "(" && strMsg.Substring(strMsg.Length - 1, 1) == ")")
                {
                    switch (strLSH.Length)
                    {
                    case 12:
                    case 19:
                        strCCXH = "";
                        break;

                    case 14:
                    case 21:
                        strCCXH = strLSH.Substring(strLSH.Length - 2, 2);
                        strLSH  = strLSH.Substring(0, strLSH.Length - 2);
                        break;

                    default:
                        strLSH  = "";
                        strCCXH = "";
                        break;
                    }
                    List <VEHICLEHISTROYSTATE> aci = getData.getNewLSVehInfo(strcarID, strLSH, strCCXH);
                    if (aci.Count > 0)
                    {
                        IDataExChangeDataAccess Data = DataAccess.GetDataExChangeDataAccess();
                        Data.insertNewLSVehInfo(aci);
                        if (_VehMap.ContainsKey(strcarID))
                        {
                            _VehMap[strcarID] = DateTime.Now;
                        }
                        else
                        {
                            _VehMap.Add(strcarID, DateTime.Now);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("", ex);
            }
        }
Example #2
0
 /// <summary>
 ///  操作线程
 /// </summary>
 private void SyncLcoalInfo()
 {
     while (true)
     {
         try
         {
             if (n_ALAEM > SysParameters.InsertInterval)
             {
                 List <ALARM_EVENT_INFO> aci = getData.getNewEventInfo();
                 if (aci.Count > 0)
                 {
                     IDataExChangeDataAccess Data = DataAccess.GetDataExChangeDataAccess();
                     Data.insertNewEventInfo(aci);
                 }
                 n_ALAEM = 0;
             }
             if (n_Veh > (SysParameters.InsertInterval / 5))
             {
                 List <VEHICLEREALSTATUS> aci = getData.getNewSSVehInfo();
                 if (aci.Count > 0)
                 {
                     IDataExChangeDataAccess Data = DataAccess.GetDataExChangeDataAccess();
                     Data.insertNewSSVehInfo(aci);
                 }
                 n_Veh = 0;
             }
         }
         catch (Exception ex)
         {
             n_ALAEM = 0;
             n_Veh   = 0;
             LOG.LogHelper.WriteLog("程序异常!", ex);
         }
         n_ALAEM++;
         n_Veh++;
         Thread.Sleep(60 * 1000);
     }
 }