Ejemplo n.º 1
0
 public GpsResponse iSetRegionAlarm(int ParamType, string sCarValue, string sPw, ArrayList RegionList)
 {
     GpsResponse response = new GpsResponse(-1L);
     try
     {
         int num = 0;
         string str = "";
         int num2 = 0;
         string str2 = "";
         RegionAlarmList regionAlarmList = new RegionAlarmList();
         string[] strArray = RegionList[0] as string[];
         string[] strArray2 = RegionList[1] as string[];
         int iRegionFeature = 0;
         string str3 = MainForm.myCarList.execChangeCarValue(ParamType, 1, sCarValue);
         if (string.IsNullOrEmpty(str3))
         {
             response.ErrorMsg = string.Format("目标车辆:{0}不存在", sCarValue);
             Record.execFileRecord("插件操作->设置区域报警", response.ErrorMsg);
             return response;
         }
         DataTable table = RemotingClient.Car_GetRegionInfo(str3, iRegionFeature);
         for (int i = 0; i < strArray.Length; i++)
         {
             int num5 = int.Parse(strArray2[i]);
             if (num5 >= 0)
             {
                 ArrayList list2 = new ArrayList();
                 RegionAlarm alarm = new RegionAlarm();
                 num2 = int.Parse(strArray[i]);
                 DataView view = new DataView(table, string.Format("RegionId='{0}'", num2), "", DataViewRowState.CurrentRows);
                 if (view.Count <= 0)
                 {
                     response.ErrorMsg = string.Format("下发区域不存在!", new object[0]);
                     Record.execFileRecord("插件操作->设置区域报警", response.ErrorMsg);
                     return response;
                 }
                 str = view[0]["regionName"].ToString();
                 alarm.newRegionId = num2;
                 alarm.PathName = str;
                 alarm.RegionType = num5;
                 alarm.RegionID = num2;
                 str2 = view[0]["regionDot"].ToString();
                 alarm.AlarmRegionDot = num5 + @"\" + str2.Replace("*", @"\").Trim(new char[] { '\\' });
                 string[] strArray3 = str2.Split(new char[] { '*' });
                 num += strArray3.Length;
                 for (int j = 0; j < (strArray3.Length - 1); j++)
                 {
                     if (string.IsNullOrEmpty(strArray3[j]))
                     {
                         response.ErrorMsg = "解析区域失败!";
                         Record.execFileRecord("插件操作->设置区域报警", response.ErrorMsg);
                         return response;
                     }
                     string[] strArray4 = strArray3[j].Split(new char[] { '\\' });
                     if (strArray4.Length < 2)
                     {
                         response.ErrorMsg = "解析区域失败!";
                         Record.execFileRecord("插件操作->设置区域报警", response.ErrorMsg);
                         return response;
                     }
                     Point point = new Point {
                         Longitude = double.Parse(strArray4[0]),
                         Latitude = double.Parse(strArray4[1])
                     };
                     list2.Add(point);
                     alarm.Points = list2;
                 }
                 regionAlarmList.Add(alarm);
             }
         }
         regionAlarmList.RegionFeature = iRegionFeature;
         regionAlarmList.OrderCode = CmdParam.OrderCode.设置区域报警;
         Response result = RemotingClient.DownData_SetRegionAlarm_FJYD((CmdParam.ParamType) ParamType, sCarValue, sPw, CmdParam.CommMode.未知方式, regionAlarmList);
         return this.execToResponse(result);
     }
     catch (Exception exception)
     {
         Record.execFileRecord("插件操作->设置区域报警", exception.Message);
         response.ErrorMsg = exception.Message;
         return response;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 设置区域报警
        /// </summary>
        /// <param name="ParamType"></param>
        /// <param name="CarValues"></param>
        /// <param name="CarPw"></param>
        /// <param name="CommMode"></param>
        /// <param name="regionAlarmList"></param>
        /// <returns></returns>
        public Response icar_SetRegionAlarm(CmdParam.ParamType ParamType, string CarValues, string CarPw, CmdParam.CommMode CommMode, RegionAlarmList regionAlarmList)
        {
            Response response = new Response();
            base.logMsg.FunctionName = "icar_SetRegionAlarm";
            base.logMsg.Msg = "发送:类型-" + ParamType.ToString() + ",车辆-" + CarValues;
            base.log.WriteLog(base.logMsg);
            if (!base.CheckCar(ParamType, CarValues, CarPw))
            {
                response.ErrorMsg = base.alarmMsg.AlarmText = base.ErrorMsg;
                base.log.WriteAlarm(base.alarmMsg);
                return response;
            }
            if (base.isStartCommon())
            {
                Car car = new Car();
                foreach (Bussiness.CarInfo info in base.carInfoList)
                {
                    try
                    {
                        RegionAlarm alarm;
                        int num = -1;
                        for (int i = 0; i < regionAlarmList.Count; i++)
                        {
                            alarm = (RegionAlarm) regionAlarmList[i];
                            ///////////////////////////////////////////
                            //进行反纠偏处理
                            string LatLngString = alarm.AlarmRegionDot;
                            string[] latlng = LatLngString.Trim(new char[]{'\\'}).Split('\\');
                            LatLngString = latlng[0].ToString() + "\\";
                            for (int j = 0; j < (latlng.Length-1) / 2; j++)
                            {
                                double lng = Convert.ToDouble(latlng[j * 2 + 1]);
                                double lat = Convert.ToDouble(latlng[j * 2 + 2]);
                                GoogleOffset.getMars(ref lng, ref lat);
                                LatLngString = LatLngString + lng.ToString() + "\\" + lat.ToString() + "\\";
                            }
                            if ((latlng.Length/2)*2 == latlng.Length)
                            {
                                LatLngString = LatLngString + latlng[latlng.Length - 1];
                            }
                            alarm.AlarmRegionDot = LatLngString.Trim(new char[]{'\\'});
                            ///////////////////////////////////////////
                            DataTable table = car.GetNewRegionId(info.CarId, alarm.PathName, num);
                            if ((table == null) || (table.Rows.Count == 0))
                            {
                                base.errMsg.ErrorText = string.Format("\"{0}\"获取报警区域ID失败!", info.CarNum);
                                response.ErrorMsg = base.errMsg.ErrorText;
                                base.log.WriteError(base.errMsg);
                                return response;
                            }
                            int num3 = int.Parse(table.Rows[0][0].ToString());
                            alarm.newRegionId = num3;
                            num = num3;
                        }
                        object pvRegions = null;
                        if (regionAlarmList.protocolType == CarProtocolType.非交通厅)
                        {
                            pvRegions = regionAlarmList.pvRegions;
                        }
                        int newOrderId = SendBase.CarCmdSend.GetNewOrderId();
                        base.SaveCmdParm(newOrderId.ToString() + "|" + info.CarId.ToString() + ";");
                        string orderIDParam = response.OrderIDParam;
                        response.OrderIDParam = orderIDParam + newOrderId.ToString() + "|" + info.CarId.ToString() + ";";
                        if ((info.ProtocolName != SendBase.m_ProtocolName) && (regionAlarmList.protocolType == CarProtocolType.交通厅))
                        {
                            base.userInfo.DownCommd.AddCarNewLogData(newOrderId, info.CarNum, "发送", regionAlarmList.OrderCode.ToString(), "失败", "", "终端不支持该协议!");
                            response.ResultCode = 0L;
                            return response;
                        }
                        base.userInfo.DownCommd.AddCarNewLogData(newOrderId, info.CarNum, "发送", regionAlarmList.OrderCode.ToString(), "等待", "", "");
                        car.InsertRegionIntoGisCar(info.CarId, base.WorkId, newOrderId, regionAlarmList.AlarmRegionDot, regionAlarmList.RegionFeature.ToString());
                        RegionAlarmList list = new RegionAlarmList();
                        RegionAlarmList list2 = new RegionAlarmList();
                        RegionAlarmList list3 = new RegionAlarmList();
                        for (int j = 0; j < regionAlarmList.Count; j++)
                        {
                            alarm = (RegionAlarm) regionAlarmList[j];
                            switch (alarm.GetSharpe())
                            {
                                case 1:
                                    list.Add(alarm);
                                    break;

                                case 2:
                                    list2.Add(alarm);
                                    break;

                                case 3:
                                    list3.Add(alarm);
                                    break;
                            }
                            car.UpdateRegionParam(base.WorkId, newOrderId, int.Parse(info.CarId), alarm.RegionID, alarm.param, alarm.toEndTime, alarm.toBackTime, alarm.RegionType & 15, alarm.BeginTime, alarm.EndTime, regionAlarmList.RegionFeature, alarm.AlarmCondition.ToString(), alarm.PlanUpTime, alarm.PlanDownTime, alarm.newRegionId, alarm.AlarmFlag, alarm.MaxSpeed, alarm.HodeTime);
                        }
                        if (regionAlarmList.RegionFeature == 1)
                        {
                            if ((info.ProtocolName == SendBase.m_ProtocolName) && (regionAlarmList.protocolType == CarProtocolType.交通厅))
                            {
                                if (list.Count > 0)
                                {
                                    string content = "";
                                    list.OrderCode = regionAlarmList.OrderCode;
                                    string str2 = list.ToXmlString(base.CalOrderId(base.WorkId, newOrderId), info.SimNum, SendBase.m_ProtocolName, (int) CommMode, "SetRegionAlarm", ref content);
                                    if (!string.IsNullOrEmpty(content))
                                    {
                                        response.ErrorMsg = content + "经纬度数据有问题";
                                        response.ResultCode = -1L;
                                        return response;
                                    }
                                    response.ResultCode = SendBase.CarCmdSend.icar_SendCmdXML(base.WorkId, newOrderId, info.SimNum, SendBase.m_ProtocolName, (int) list.OrderCode, (int) CommMode, str2);
                                }
                                if (list2.Count > 0)
                                {
                                    string str3 = "";
                                    list2.OrderCode = regionAlarmList.OrderCode;
                                    string str4 = list2.ToXmlString(base.CalOrderId(base.WorkId, newOrderId), info.SimNum, SendBase.m_ProtocolName, (int) CommMode, "SetRegionAlarm", ref str3);
                                    if (!string.IsNullOrEmpty(str3))
                                    {
                                        response.ErrorMsg = str3 + "经纬度数据有问题";
                                        response.ResultCode = -1L;
                                        return response;
                                    }
                                    response.ResultCode = SendBase.CarCmdSend.icar_SendCmdXML(base.WorkId, newOrderId, info.SimNum, SendBase.m_ProtocolName, (int) list2.OrderCode, (int) CommMode, str4);
                                }
                                if (list3.Count > 0)
                                {
                                    string str5 = "";
                                    list3.OrderCode = regionAlarmList.OrderCode;
                                    string str6 = list3.ToXmlString(base.CalOrderId(base.WorkId, newOrderId), info.SimNum, SendBase.m_ProtocolName, (int) CommMode, "SetRegionAlarm", ref str5);
                                    if (!string.IsNullOrEmpty(str5))
                                    {
                                        response.ErrorMsg = str5 + "经纬度数据有问题";
                                        response.ResultCode = -1L;
                                        return response;
                                    }
                                    response.ResultCode = SendBase.CarCmdSend.icar_SendCmdXML(base.WorkId, newOrderId, info.SimNum, SendBase.m_ProtocolName, (int) list3.OrderCode, (int) CommMode, str6);
                                }
                            }
                            else
                            {
                                response.ResultCode = SendBase.CarCmdSend.icar_SimpleCmd(base.WorkId, newOrderId, info.SimNum, regionAlarmList.CmdCode, ref pvRegions);
                            }
                        }
                        else
                        {
                            response.ResultCode = SendBase.CarCmdSend.icar_SetMultiRegionAlarm(base.WorkId, newOrderId, info.SimNum, ref pvRegions);
                        }
                        if (response.ResultCode != 0L)
                        {
                            base.alarmMsg.FunctionName = "icar_SetRegionAlarm";
                            base.alarmMsg.AlarmText = string.Concat(new object[] { "workid-", base.WorkId, ",simNum-", info.SimNum, ",OrderCode-", regionAlarmList.OrderCode });
                            base.alarmMsg.Code = response.ResultCode.ToString();
                            base.log.WriteAlarm(base.alarmMsg);
                        }
                        response.ResultCode = 0L;
                        continue;
                    }
                    catch (Exception exception)
                    {
                        base.errMsg.ErrorText = "下发消息指令时发生错误!";
                        response.ErrorMsg = base.ErrorMsg = base.errMsg.ErrorText;
                        base.log.WriteError(base.errMsg, exception);
                    }
                }
                return response;
            }
            response.ErrorMsg = base.ErrorMsg;
            return response;
        }
Ejemplo n.º 3
0
 private bool getRegionAlarmList(bool isStartPoint, ref RegionAlarmList m_RegionAlarmList)
 {
     int num = 0;
     string str = "";
     int num2 = 0;
     string str2 = "";
     string str3 = "";
     string str4 = "";
     int num3 = this.getRegionType(!isStartPoint);
     ArrayList list = new ArrayList();
     RegionAlarm alarm = new RegionAlarm();
     DataRow row = isStartPoint ? (this.lbStartPoint.SelectedItem as DataRowView).Row : (this.lbEndPoint.SelectedItem as DataRowView).Row;
     str = row["RegionName"].ToString() ?? "";
     num2 = Convert.ToInt32(row["RegionId"].ToString());
     alarm.newRegionId = num2;
     alarm.PathName = str;
     alarm.RegionType = num3;
     alarm.RegionID = num2;
     str4 = row["RegionDot"].ToString() ?? "";
     alarm.AlarmRegionDot = num3 + @"\" + str4.Replace("*", @"\").Trim(new char[] { '\\' });
     string[] strArray = str4.Split(new char[] { '*' });
     num += strArray.Length;
     for (int i = 0; i < (strArray.Length - 1); i++)
     {
         if (string.IsNullOrEmpty(strArray[i]))
         {
             MessageBox.Show(ERRORPATHAlARM);
             return false;
         }
         string[] strArray2 = strArray[i].Split(new char[] { '\\' });
         if (strArray2.Length < 2)
         {
             MessageBox.Show(ERRORPATHAlARM);
             return false;
         }
         ParamLibrary.CmdParamInfo.Point point = new ParamLibrary.CmdParamInfo.Point {
             Longitude = double.Parse(strArray2[0]),
             Latitude = double.Parse(strArray2[1])
         };
         list.Add(point);
     }
     alarm.Points = list;
     str2 = "";
     str3 = "";
     string sStr = "";
     string str6 = "";
     string str7 = "";
     alarm.toEndTime = this.getToTime(sStr);
     alarm.toBackTime = this.getToTime(sStr);
     alarm.param = this.GetRegionParam(isStartPoint);
     alarm.PlanUpTime = str6;
     alarm.PlanDownTime = str7;
     alarm.BeginTime = str2;
     alarm.EndTime = str3;
     m_RegionAlarmList.Add(alarm);
     return true;
 }