예제 #1
0
 /// <summary> 接收保存数据 
 /// </summary>
 /// <param name="state"></param>
 /// <returns></returns>
 private static void SaveData(object state)
 {
     if (state is AnnounceProtocol)
     {
         AnnounceProtocol protocol = state as AnnounceProtocol;
         DataTable dt = JsonHelper.JsonToDataTable(protocol.Json, TableName,true);
         if (dt == null || dt.Rows.Count == 0)
         {
             return;
         }
         bool result = false;
         string id = "announcement_id";
         Dictionary<string, string> dicFileds = new Dictionary<string, string>();
         foreach (DataColumn dc in dt.Columns)
         {
             if (dc.ColumnName != id)
             {
                 dicFileds.Add(dc.ColumnName, dt.Rows[0][dc.ColumnName].ToString());
             }
         }
         if (protocol.Operation.Equals(DataSources.EnumOperationType.Add.ToString("d")))
         {
             if (dt.Columns.Contains(id))
             {
                 dicFileds.Add(id, dt.Rows[0][id].ToString());
             }
             foreach (string db in AutoTask.GetDatabaseList())
             {
                 //添加数据
                 result = DBHelper.Submit_AddOrEdit("添加云平台公告信息", db, dt.TableName, "", "", dicFileds);
             }
         }
         else if (protocol.Operation.Equals(DataSources.EnumOperationType.Update.ToString("d")))
         {
             if (dt.Columns.Contains(id))
             {
                 foreach (string db in AutoTask.GetDatabaseList())
                 {
                     //修改数据
                     result = DBHelper.Submit_AddOrEdit("修改云平台公告信息", db, dt.TableName, id, dt.Rows[0][id].ToString(), dicFileds);
                 }
             }
         }
         ResultProtocol rp = new ResultProtocol();
         rp.StationId = protocol.StationId;
         rp.SerialNumber = protocol.SerialNumber;
         rp.MessageId = protocol.MessageId;
         rp.SubMessageId = protocol.SubMessageId;
         rp.TimeSpan = protocol.TimeSpan;
         rp.SerialNumberLock = true;
         if (result)
         {
             rp.Result = DataSources.EnumResultType.Success.ToString("d");
         }
         else
         {
             rp.Result = DataSources.EnumResultType.Fail.ToString("d");
         }
         ServiceAgent.AddSendQueue(rp);
     }
 }
예제 #2
0
 /// <summary> 车厂数据处理 
 /// </summary>
 /// <param name="protocol"></param>
 public static void Deal(FactoryProtocol protocol)
 {
     bool result = false;
     DataTable dt = JsonHelper.JsonToDataTable(BaseCodeHelper.DeCode(protocol.Json));           
     if (dt != null && dt.Rows.Count > 0)
     {
         ServiceStationDataModel ssdm = new ServiceStationDataModel(dt.Rows[0]);
         //处理车厂数据
         result = DealFactoryData(ssdm);
     }
     //返回成功/失败信息
     ResultProtocol rp = new ResultProtocol();
     rp.StationId = protocol.StationId;
     rp.SerialNumber = protocol.SerialNumber;          
     rp.SubMessageId = protocol.SubMessageId;
     rp.TimeSpan = protocol.TimeSpan;
     rp.SerialNumberLock = true;
     if (result)
     {
         rp.Result = DataSources.EnumResultType.Success.ToString("d");
     }
     else
     {
         rp.Result = DataSources.EnumResultType.Fail.ToString("d");
     }
     ServiceAgent.AddSendQueue(rp);
 }
예제 #3
0
 /// <summary> 处理收到的控制信息 
 /// </summary>
 /// <param name="state"></param>
 private static void SaveData(object state)
 {
     if (state is ControlProtocol)
     {
         ControlProtocol protocol = state as ControlProtocol;
         bool result = false;
         //保存至数据库,并返回成功/失败信息
         Dictionary<string, string> dicFileds = new Dictionary<string, string>();
         if (protocol.SubMessageId == SubMessageId3)
         {
             result = DBHelper.Submit_AddOrEdit("更新有效期信息", "HXC_000", "tb_signing_info", "sign_id", GlobalStaticObj_Server.Instance.StationID, new Dictionary<string, string> { { "protocol_expires_time", protocol.Date } });
         }
         else
         {
             if (protocol.ControlType.Equals(DataSources.EnumControlType.UnAvailble.ToString("d")))
             {
                 dicFileds.Add("status", DataSources.EnumStatus.Stop.ToString("d"));
             }
             else if (protocol.ControlType.Equals(DataSources.EnumControlType.Availble.ToString("d")))
             {
                 dicFileds.Add("status", DataSources.EnumStatus.Start.ToString("d"));
             }
         
             if (dicFileds.Count > 0)
             {
                 //协议里包含帐套信息
                 result = DBHelper.Submit_AddOrEdit("修改用户信息", GlobalStaticObj_Server.Instance.CurrAccDbName, "sys_user", "user_id", "", dicFileds);
             }
         }
         ResultProtocol rp = new ResultProtocol();
         rp.StationId = protocol.StationId;
         rp.SerialNumber = protocol.SerialNumber;
         rp.MessageId = protocol.MessageId;
         rp.SubMessageId = protocol.SubMessageId;
         rp.TimeSpan = protocol.TimeSpan;
         rp.SerialNumberLock = true;
         if (result)
         {
             rp.Result = DataSources.EnumResultType.Success.ToString("d");
         }
         else
         {
             rp.Result = DataSources.EnumResultType.Fail.ToString("d");
         }
         ServiceAgent.AddSendQueue(rp);
     }
 }