Example #1
0
 public Response icar_SendRawPackage(CmdParam.ParamType paramType_0, string string_1, string string_2, CmdParam.CommMode commMode_0, SimpleCmd simpleCmd_0)
 {
     Response response = new Response();
     string str = "";
     foreach (string[] strArray in simpleCmd_0.CmdParams)
     {
         string str8 = str;
         str = str8 + "命令码-" + simpleCmd_0.OrderCode.ToString() + ",参数-" + this.method_5(strArray, 0) + ";";
     }
     base.WriteLog(paramType_0.ToString(), string_1 + "," + str);
     if (!base.CheckCar(paramType_0, string_1, string_2))
     {
         response.ErrorMsg = base.ErrorMsg;
         return response;
     }
     if (!base.isStartCommon())
     {
         response.ErrorMsg = base.ErrorMsg;
         return response;
     }
     if ((simpleCmd_0.CmdParams != null) && (simpleCmd_0.CmdParams.Count > 0))
     {
         int newOrderId = -1;
         object objectArg = null;
         byte[] bytes = null;
         foreach (Bussiness.CarInfo info in base.carInfoList)
         {
             try
             {
                 foreach (string[] strArray2 in simpleCmd_0.CmdParams)
                 {
                     newOrderId = SendBase.CarCmdSend.GetNewOrderId();
                     base.SaveCmdParm(newOrderId.ToString() + "|" + info.CarId.ToString() + ";");
                     string orderIDParam = response.OrderIDParam;
                     response.OrderIDParam = orderIDParam + newOrderId.ToString() + "|" + info.CarId.ToString() + ";";
                     base.AddUpDataLog(newOrderId, info.CarNum, simpleCmd_0.OrderCode.ToString(), this.method_5(strArray2, (int) simpleCmd_0.OrderCode));
                     if (simpleCmd_0.OrderCode == CmdParam.OrderCode.回拔坐席电话指令)
                     {
                         bytes = Encoding.GetEncoding("gb2312").GetBytes(strArray2[0]);
                         byte[] array = new byte[15];
                         bytes.CopyTo(array, 0);
                         objectArg = array;
                     }
                     if (simpleCmd_0.OrderCode == CmdParam.OrderCode.设置油耗仪参数)
                     {
                         objectArg = new Oix().GetObjectArg(strArray2);
                     }
                     if (simpleCmd_0.OrderCode == CmdParam.OrderCode.设置出入口分段超速报警)
                     {
                         Car car = new Car();
                         string[] strArray3 = simpleCmd_0.CmdParams[0] as string[];
                         Hashtable hashtable = new Hashtable();
                         for (int i = 0; i < (strArray3.Length / 8); i++)
                         {
                             if (!hashtable.Contains(strArray3[i * 8]))
                             {
                                 car.Car_AddPassWayPathIdToTmp(info.CarId, base.WorkId, newOrderId, strArray3[i * 8], strArray3[(i * 8) + 1], (Convert.ToDouble(strArray3[(i * 8) + 6]) > 0.0) ? ((int) Convert.ToDouble(strArray3[(i * 8) + 6])) : ((int) Convert.ToDouble(strArray3[(i * 8) + 7])));
                                 hashtable[strArray3[i * 8]] = null;
                             }
                         }
                         objectArg = simpleCmd_0.pvArg;
                     }
                     if (info.ProtocolName == SendBase.m_ProtocolName)
                     {
                         if (simpleCmd_0.OrderCode == CmdParam.OrderCode.设置关键区域)
                         {
                             TrafficRawPackage package = new TrafficRawPackage {
                                 OrderCode = CmdParam.OrderCode.命令透传,
                                 SubOrderCode = simpleCmd_0.OrderCode
                             };
                             Car car2 = new Car();
                             StringBuilder builder = new StringBuilder();
                             builder.Append((strArray2.Length / 8).ToString("X4"));
                             for (int j = 0; j < strArray2.Length; j += 8)
                             {
                                 builder.Append(Convert.ToInt32(strArray2[j]).ToString("X8"));
                                 builder.Append(Convert.ToByte(strArray2[j + 1]).ToString("X2"));
                                 builder.Append(((int) (Convert.ToDouble(strArray2[j + 2]) * 1000000.0)).ToString("X8"));
                                 builder.Append(((int) (Convert.ToDouble(strArray2[j + 3]) * 1000000.0)).ToString("X8"));
                                 if (string.IsNullOrEmpty(strArray2[j + 5]))
                                 {
                                     builder.Append(Convert.ToInt32(strArray2[j + 4]).ToString("X8"));
                                     builder.Append("00000000");
                                 }
                                 else
                                 {
                                     builder.Append(((int) (Convert.ToDouble(strArray2[j + 4]) * 1000000.0)).ToString("X8"));
                                     builder.Append(((int) (Convert.ToDouble(strArray2[j + 5]) * 1000000.0)).ToString("X8"));
                                 }
                                 builder.Append(Convert.ToByte(strArray2[j + 6]).ToString("X2"));
                                 builder.Append(Convert.ToInt32(strArray2[j + 7]).ToString("X8"));
                                 if (car2.SetCriticalRegionToTmp(info.CarId, base.WorkId, newOrderId, strArray2[j], strArray2[j + 6], strArray2[j + 7]) != 0)
                                 {
                                     base.WriteError(base.WorkId.ToString(), info.SimNum, simpleCmd_0.OrderCode.ToString() + "-参数保存失败-" + strArray2[j] + "," + strArray2[j + 6] + "," + strArray2[j + 7]);
                                 }
                             }
                             package.strText = builder.ToString();
                             string conntent = "";
                             string str3 = package.ToXmlString(base.CalOrderId(base.WorkId, newOrderId), info.SimNum, SendBase.m_ProtocolName, (int) commMode_0, "SendRawPackage", ref conntent);
                             response.ResultCode = SendBase.CarCmdSend.icar_SendCmdXML(base.WorkId, newOrderId, info.SimNum, SendBase.m_ProtocolName, (int) package.OrderCode, (int) commMode_0, str3);
                         }
                         else if (simpleCmd_0.OrderCode == CmdParam.OrderCode.设置出入口分段超速报警)
                         {
                             TrafficRawPackage package2 = new TrafficRawPackage {
                                 OrderCode = CmdParam.OrderCode.命令透传,
                                 SubOrderCode = simpleCmd_0.OrderCode
                             };
                             StringBuilder builder2 = new StringBuilder();
                             byte[] pvArg = (byte[]) simpleCmd_0.pvArg;
                             if (pvArg != null)
                             {
                                 for (int k = 0; k < pvArg.Length; k++)
                                 {
                                     if (((k + 1) % 0x16) == 1)
                                     {
                                         byte[] buffer4 = new byte[4];
                                         for (int m = 0; m < 4; m++)
                                         {
                                             buffer4[m] = pvArg[k + m];
                                         }
                                         k += 3;
                                         builder2.Append(BitConverter.ToInt32(buffer4, 0).ToString("X8"));
                                     }
                                     else
                                     {
                                         builder2.Append(pvArg[k].ToString("X2"));
                                     }
                                 }
                             }
                             package2.strText = builder2.ToString();
                             string str4 = "";
                             string str5 = package2.ToXmlString(base.CalOrderId(base.WorkId, newOrderId), info.SimNum, SendBase.m_ProtocolName, (int) commMode_0, "SendRawPackage", ref str4);
                             response.ResultCode = SendBase.CarCmdSend.icar_SendCmdXML(base.WorkId, newOrderId, info.SimNum, SendBase.m_ProtocolName, (int) package2.OrderCode, (int) commMode_0, str5);
                         }
                         else
                         {
                             string str6 = "";
                             string str7 = simpleCmd_0.ToXmlString(base.CalOrderId(base.WorkId, newOrderId), info.SimNum, SendBase.m_ProtocolName, (int) commMode_0, "SimpleCmd", ref str6);
                             response.ResultCode = SendBase.CarCmdSend.icar_SendCmdXML(base.WorkId, newOrderId, info.SimNum, SendBase.m_ProtocolName, (int) simpleCmd_0.OrderCode, (int) commMode_0, str7);
                         }
                     }
                     else
                     {
                         response.ResultCode = SendBase.CarCmdSend.icar_SendRawPackage(base.WorkId, newOrderId, info.SimNum, simpleCmd_0.CmdCode, ref objectArg, commMode_0);
                     }
                     if (response.ResultCode != 0L)
                     {
                         base.WriteError(base.WorkId.ToString(), info.SimNum, simpleCmd_0.OrderCode.ToString());
                     }
                 }
             }
             catch (Exception exception)
             {
                 response.ErrorMsg = "下发消息指令时发生错误,错误详细信息:" + exception.Message;
                 base.log.WriteError(base.errMsg, exception);
             }
         }
         return response;
     }
     response.ResultCode = -1L;
     response.ErrorMsg = "下发参数为空!";
     return response;
 }
Example #2
0
        public Response icar_SimpleCmd(CmdParam.ParamType ParamType, string CarValues, string CarPw, CmdParam.CommMode CommMode, SimpleCmd simpleCmd)
        {
            Response response = new Response();
            string paramDisc = simpleCmd.GetParamDisc();
            base.WriteLog(ParamType.ToString(), CarValues + paramDisc);
            if (!base.CheckCar(ParamType, CarValues, CarPw))
            {
                response.ErrorMsg = base.ErrorMsg;
                return response;
            }
            string strErrorMsg = string.Empty;
            if (simpleCmd.CheckData(out strErrorMsg) != 0)
            {
                response.ErrorMsg = strErrorMsg;
                return response;
            }
            if (!base.isStartCommon())
            {
                response.ErrorMsg = base.ErrorMsg;
                return response;
            }
            object pvArg = null;
            int newOrderId = -1;
            foreach (Bussiness.CarInfo info in base.carInfoList)
            {
                try
                {
                    if (simpleCmd.OrderCode == CmdParam.OrderCode.设置车台参数)
                    {
                        response.ResultCode = new Car().UpdateCarconfigOnDuty(info.CarId, simpleCmd.OnDuty, simpleCmd.CloseGSM, simpleCmd.CloseDail);
                    }
                    newOrderId = SendBase.CarCmdSend.GetNewOrderId();
                    base.SaveCmdParm(newOrderId.ToString() + "|" + info.CarId.ToString() + ";");
                    string orderIDParam = response.OrderIDParam;
                    response.OrderIDParam = orderIDParam + newOrderId.ToString() + "|" + info.CarId.ToString() + ";";
                    base.AddUpDataLog(newOrderId, info.CarNum, simpleCmd.OrderCode.ToString(), paramDisc);
                    switch (simpleCmd.CmdCode)
                    {
                        case CmdParam.CmdCode.取消区域报警:
                            new Car().InsertRegionIdsIntoGisCar(info.CarId, base.WorkId.ToString(), newOrderId.ToString(), simpleCmd.RegionIds);
                            break;

                        case CmdParam.CmdCode.取消路线报警:
                            new Car().InsertPathIdsIntoGisCar(info.CarId, base.WorkId.ToString(), newOrderId.ToString(), simpleCmd.RegionIds.Trim(new char[] { '\\' }).Equals("0") ? "" : simpleCmd.RegionIds);
                            break;

                        case CmdParam.CmdCode.配置串口参数:
                            if (response.ResultCode == 0L)
                            {
                                new Car().InsertGpsCarDeviceParam(info.CarId, base.WorkId, newOrderId, simpleCmd.Com1Device, simpleCmd.Com2Device);
                            }
                            break;
                    }
                    if (info.ProtocolName == SendBase.m_ProtocolName)
                    {
                        int orderID = base.CalOrderId(base.WorkId, newOrderId);
                        string conntent = string.Empty;
                        simpleCmd.TransformCode = CmdParam.TrafficProtocolCodeExchange2((int) simpleCmd.OrderCode);
                        string str4 = string.Empty;
                        if (simpleCmd.CmdCode == CmdParam.CmdCode.取消区域报警)
                        {
                            try
                            {
                                string[] strArray = simpleCmd.RegionIds.Split(@"\".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                                string[] strArray2 = simpleCmd.RegionTypes.Split(@"\".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                                if (strArray2.Length <= 0)
                                {
                                    throw new Exception();
                                }
                                List<string> list = new List<string>();
                                List<string> list2 = new List<string>();
                                for (int i = 1; i <= 3; i++)
                                {
                                    for (int j = 0; j < strArray2.Length; j++)
                                    {
                                        if (strArray2[j].Equals(i.ToString()))
                                        {
                                            list.Add(strArray[j]);
                                            list2.Add(i.ToString());
                                        }
                                    }
                                    if (list.Count != 0)
                                    {
                                        simpleCmd.RegionIds = string.Join(@"\", list.ToArray());
                                        simpleCmd.RegionTypes = string.Join(@"\", list2.ToArray());
                                        str4 = simpleCmd.ToXmlString(orderID, info.SimNum, SendBase.m_ProtocolName, (int) CommMode, "SimpleCmd", ref conntent);
                                        list.Clear();
                                        list2.Clear();
                                        response.ResultCode = SendBase.CarCmdSend.icar_SendCmdXML(base.WorkId, newOrderId, info.SimNum, SendBase.m_ProtocolName, simpleCmd.TransformCode, (int) CommMode, str4);
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                base.userInfo.DownCommd.AddCarNewLogData(newOrderId, info.CarNum, "发送", simpleCmd.OrderCode.ToString(), "失败", "", "终端不支持该命令");
                                response.ErrorMsg = "终端不支持该命令";
                            }
                        }
                        else if ((simpleCmd.OrderCode != CmdParam.OrderCode.取消出入口分段超速报警) && (simpleCmd.OrderCode != CmdParam.OrderCode.取消所有关键区域))
                        {
                            if ((simpleCmd.OrderCode == CmdParam.OrderCode.取消偏移路线报警) && simpleCmd.RegionIds.Trim(new char[] { '\\' }).Equals("0"))
                            {
                                simpleCmd.RegionIds = "";
                            }
                            str4 = simpleCmd.ToXmlString(orderID, info.SimNum, SendBase.m_ProtocolName, (int) CommMode, "SimpleCmd", ref conntent);
                            response.ResultCode = SendBase.CarCmdSend.icar_SendCmdXML(base.WorkId, newOrderId, info.SimNum, SendBase.m_ProtocolName, simpleCmd.TransformCode, (int) CommMode, str4);
                        }
                        else
                        {
                            TrafficRawPackage package = new TrafficRawPackage {
                                OrderCode = CmdParam.OrderCode.命令透传,
                                SubOrderCode = simpleCmd.OrderCode,
                                strText = ""
                            };
                            str4 = package.ToXmlString(base.CalOrderId(base.WorkId, newOrderId), info.SimNum, SendBase.m_ProtocolName, -1, "SendRawPackage", ref conntent);
                            response.ResultCode = SendBase.CarCmdSend.icar_SendCmdXML(base.WorkId, newOrderId, info.SimNum, SendBase.m_ProtocolName, (int) package.OrderCode, -1, str4);
                        }
                    }
                    else
                    {
                        pvArg = simpleCmd.pvArg;
                        response.ResultCode = SendBase.CarCmdSend.icar_SimpleCmd(base.WorkId, newOrderId, info.SimNum, simpleCmd.CmdCode, ref pvArg);
                    }
                    if (response.ResultCode != 0L)
                    {
                        base.WriteError(base.WorkId.ToString(), info.SimNum, simpleCmd.OrderCode.ToString());
                    }
                    response.ResultCode = 0L;
                }
                catch (Exception exception)
                {
                    response.ErrorMsg = "下发消息指令时发生错误,错误详细信息:" + exception.Message;
                }
            }
            return response;
        }
Example #3
0
 public Response icar_SetCommonCmd(CmdParam.ParamType paramType_0, string string_1, string string_2, CmdParam.CommMode commMode_0, SimpleCmd simpleCmd_0)
 {
     Response response = new Response();
     string str = "";
     if ((simpleCmd_0.CmdParams != null) && (simpleCmd_0.CmdParams.Count > 0))
     {
         foreach (string[] strArray in simpleCmd_0.CmdParams)
         {
             string str6 = str;
             str = str6 + "命令码-" + simpleCmd_0.OrderCode.ToString() + ",参数-" + this.method_5(strArray, 0) + ";";
         }
     }
     base.WriteLog(paramType_0.ToString(), string_1 + "," + str);
     if (!base.CheckCar(paramType_0, string_1, string_2))
     {
         response.ErrorMsg = base.ErrorMsg;
         return response;
     }
     if (!base.isStartCommon())
     {
         response.ErrorMsg = base.ErrorMsg;
         return response;
     }
     object obj2 = null;
     int newOrderId = -1;
     foreach (Bussiness.CarInfo info in base.carInfoList)
     {
         try
         {
             newOrderId = SendBase.CarCmdSend.GetNewOrderId();
             int num2 = 0;
             base.SaveCmdParm(newOrderId.ToString() + "|" + info.CarId.ToString() + ";");
             string orderIDParam = response.OrderIDParam;
             response.OrderIDParam = orderIDParam + newOrderId.ToString() + "|" + info.CarId.ToString() + ";";
             if ((simpleCmd_0.CmdParams != null) && (simpleCmd_0.CmdParams.Count > 0))
             {
                 if (info.ProtocolName == SendBase.m_ProtocolName)
                 {
                     string conntent = "";
                     string str5 = simpleCmd_0.ToXmlString(base.CalOrderId(base.WorkId, newOrderId), info.SimNum, SendBase.m_ProtocolName, (int) commMode_0, "SimpleCmd", ref conntent);
                     base.AddUpDataLog(newOrderId, info.CarNum, simpleCmd_0.OrderCode.ToString(), conntent);
                     response.ResultCode = SendBase.CarCmdSend.icar_SendCmdXML(base.WorkId, newOrderId, info.SimNum, SendBase.m_ProtocolName, (int) simpleCmd_0.OrderCode, (int) commMode_0, str5);
                 }
                 else
                 {
                     foreach (string[] strArray2 in simpleCmd_0.CmdParams)
                     {
                         base.AddUpDataLog(newOrderId, info.CarNum, simpleCmd_0.OrderCode.ToString(), this.method_5(strArray2, (int) simpleCmd_0.OrderCode));
                         obj2 = this.method_6(strArray2);
                         response.ResultCode = SendBase.CarCmdSend.icar_SetCommonCmd(base.WorkId, newOrderId, info.SimNum, simpleCmd_0.CmdCode, ref obj2, commMode_0);
                         if ((simpleCmd_0.CmdParams.Count - num2) > 1)
                         {
                             Thread.Sleep(0x7d0);
                         }
                         num2++;
                         if (response.ResultCode != 0L)
                         {
                             base.WriteError(base.WorkId.ToString(), info.SimNum, simpleCmd_0.OrderCode.ToString());
                         }
                     }
                 }
             }
             else
             {
                 base.AddUpDataLog(newOrderId, info.CarNum, simpleCmd_0.OrderCode.ToString(), "");
                 if (info.ProtocolName == SendBase.m_ProtocolName)
                 {
                     string str2 = string.Empty;
                     string str3 = simpleCmd_0.ToXmlString(base.CalOrderId(base.WorkId, newOrderId), info.SimNum, SendBase.m_ProtocolName, (int) commMode_0, "SimpleCmd", ref str2);
                     response.ResultCode = SendBase.CarCmdSend.icar_SendCmdXML(base.WorkId, newOrderId, info.SimNum, SendBase.m_ProtocolName, (int) simpleCmd_0.OrderCode, (int) commMode_0, str3);
                 }
                 else
                 {
                     response.ResultCode = SendBase.CarCmdSend.icar_SetCommonCmd(base.WorkId, newOrderId, info.SimNum, simpleCmd_0.CmdCode, ref obj2, commMode_0);
                 }
                 if (response.ResultCode != 0L)
                 {
                     base.WriteError(base.WorkId.ToString(), info.SimNum, simpleCmd_0.OrderCode.ToString());
                 }
                 else if (simpleCmd_0.OrderCode == CmdParam.OrderCode.LBS位置查询)
                 {
                     base.userInfo.CarFilter.UpdatePosSearchFlag(simpleCmd_0.OrderCode.ToString(), newOrderId, info.CarId);
                 }
             }
         }
         catch (Exception exception)
         {
             response.ErrorMsg = "下发消息指令时发生错误,错误详细信息:" + exception.Message;
             base.log.WriteError(base.errMsg, exception);
         }
     }
     return response;
 }