Exemple #1
0
        public async Task <ActionResult> SendRegionSettings(int LineProperty, string[] Vehicles, long LineID)
        {
            OperationResult valid = null;
            var             line  = TerminalSettingsBLL.GetLinesByLineID((int)LineID);

            if (Vehicles == null || Vehicles.Length == 0)
            {
                valid = new OperationResult()
                {
                    Success = false, Message = "未指定设置的车辆。"
                }
            }
            ;

            else if (line == null || line.Count == 0)
            {
                valid = new OperationResult()
                {
                    Success = false, Message = "数据库中未找到指定的路线。"
                }
            }
            ;

            if (valid != null)
            {
                dynamic settingData = new ExpandoObject();
                settingData.LineProperty = LineProperty;
                settingData.Vehicles     = Vehicles;
                settingData.LineID       = LineID;
                TerminalSettingsBLL.InsertTerminalOperationsLog(
                    base.CurrentUserID,
                    TerminalSettingType.RouteSettings_Add,
                    null,
                    null,
                    false,
                    JsonConvert.SerializeObject(settingData),
                    valid.Message,
                    GetRemoteAddress()
                    );
                return(Json(new OperationResult[] { valid }));
            }

            var tasks = new Task <OperationResult> [Vehicles.Length];

            for (int i = 0; i != Vehicles.Length; i++)
            {
                string[] PlateNumAndTerminalCode = Vehicles[i].Split('#');
                string   PlateNum     = PlateNumAndTerminalCode[0];
                string   TerminalCode = PlateNumAndTerminalCode[1];
                var      client       = new TerminalOperationClient();
                tasks[i] = InternalSendLineSettings((LineProperty)LineProperty, PlateNum, TerminalCode, line, client);
            }

            var result = await Task.WhenAll <OperationResult>(tasks);

            return(Json(result));
        }
Exemple #2
0
        public ActionResult UpdateTerminalSetting(
            [ModelBinder(typeof(BasicArrayBinder <string>))] string[] Vehicles,
            [ModelBinder(typeof(ObjectBinder <TerminalSettingsModel>))] TerminalSettingsModel Settings)
        {
            int userid = GetUserSession().UserId;

            var client    = new TerminalOperationClient();
            var objResult = new List <dynamic>();// 记录每次下发设置的返回结果

            foreach (var v in Vehicles)
            {
                dynamic result = new ExpandoObject();

                // Vehicles当中的记录为 PlateNum#TerminalCode
                string[] PlateNumAndTerminalCode = v.Split('#');
                string   PlateNum     = PlateNumAndTerminalCode[0];
                string   TerminalCode = PlateNumAndTerminalCode[1];

                var response = client.SetTerminalParas(TerminalCode, new TerminalParasSettingData()
                {
                    ParaItems = new TerminalParasData()
                    {
                        终端心跳发送间隔     = Settings.HeartbeatInterval,
                        位置汇报策略       = (LocationReportingStrategy)Settings.LocationReportPolicy,
                        位置汇报方案       = (LocationReportingProgram)Settings.LocationReportTrigger,
                        驾驶员未登录汇报时间间隔 = Settings.StateRepotrInterval_NotLoggedIn,
                        休眠时汇报时间间隔    = Settings.StateRepotrInterval_Sleep,
                        紧急报警时汇报时间间隔  = Settings.StateRepotrInterval_Urgent,
                        缺省时间汇报间隔     = Settings.StateRepotrInterval_General,
                        最高速度         = Settings.MaximumSpeed,
                        超速持续时间       = Settings.OverspeedCheckTime,
                        超速报警预警差值     = Settings.DifferenceOfOverspeedValues,
                        连续驾驶时间门限     = Settings.MaximumDrivingTime,
                        当天累计驾驶时间门限   = Settings.MaximumDrivingTimeToday,
                        疲劳驾驶预警差值     = Settings.DifferenceOfFatigueDrivingTime,
                        最小休息时间       = Settings.MinimumBreakTime,
                        最长停车时间       = Settings.MaximumStoppingTime,
                        车辆里程表读数      = Settings.TotalODO,
                        监听电话号码       = new string[] { Settings.TelphoneNO }
                    }
                });

                // 记录日志
                TerminalSettingsBLL.InsertTerminalOperationsLog(
                    userid, TerminalSettingType.TerminalSetup_Update, PlateNum,
                    TerminalCode, response.State, JsonConvert.SerializeObject(Settings),
                    null, GetRemoteAddress()
                    );

                //保存下发结果以便后面转换为json返回给页面显示
                result.state   = response.State;
                result.message = response.Message;
                objResult.Add(result);
            }
            return(Content(JsonConvert.SerializeObject(objResult)));
        }
Exemple #3
0
        public ActionResult QueryTerminalFlags(
            string Vehicle,
            int[] Settings
            )
        {
            int userid = GetUserSession().UserId;

            var client = new TerminalOperationClient();

            // Vehicle当中的记录为 PlateNum#TerminalCode
            string[] PlateNumAndTerminalCode = Vehicle.Split('#');
            string   PlateNum     = PlateNumAndTerminalCode[0];
            string   TerminalCode = PlateNumAndTerminalCode[1];

            TerminalParaID[] ParamIDs = new TerminalParaID[Settings.Length];
            for (int i = 0; i != Settings.Length; i++)
            {
                ParamIDs[i] = (TerminalParaID)Settings[i];
            }

            var response = client.QuerySpecifiedTerminalParas(TerminalCode, new QuerySpecifiedTerminalParasData()
            {
                TerminalParaIDs = ParamIDs
            });

            var result = new TerminalSettingsModel()
            {
                HeartbeatInterval               = response.ResultData.ParaItems.终端心跳发送间隔,
                LocationReportPolicy            = (int)response.ResultData.ParaItems.位置汇报策略,
                LocationReportTrigger           = (int)response.ResultData.ParaItems.位置汇报方案,
                StateRepotrInterval_NotLoggedIn = response.ResultData.ParaItems.驾驶员未登录汇报时间间隔,
                StateRepotrInterval_Sleep       = response.ResultData.ParaItems.休眠时汇报时间间隔,
                StateRepotrInterval_Urgent      = response.ResultData.ParaItems.紧急报警时汇报时间间隔,
                StateRepotrInterval_General     = response.ResultData.ParaItems.缺省时间汇报间隔,
                MaximumSpeed                   = response.ResultData.ParaItems.最高速度,
                OverspeedCheckTime             = response.ResultData.ParaItems.超速持续时间,
                DifferenceOfOverspeedValues    = response.ResultData.ParaItems.超速报警预警差值,
                MaximumDrivingTime             = response.ResultData.ParaItems.连续驾驶时间门限,
                MaximumDrivingTimeToday        = response.ResultData.ParaItems.当天累计驾驶时间门限,
                DifferenceOfFatigueDrivingTime = response.ResultData.ParaItems.疲劳驾驶预警差值,
                MinimumBreakTime               = response.ResultData.ParaItems.最小休息时间,
                MaximumStoppingTime            = response.ResultData.ParaItems.最长停车时间,
                TotalODO   = response.ResultData.ParaItems.车辆里程表读数,
                TelphoneNO = response.ResultData.ParaItems.监听电话号码.FirstOrDefault()
            };

            TerminalSettingsBLL.InsertTerminalOperationsLog(
                userid, TerminalSettingType.TerminalSetup_Query, PlateNum,
                TerminalCode, response.State, JsonConvert.SerializeObject(new { Vehicle = Vehicle, Settings = Settings }),
                null, GetRemoteAddress()
                );

            return(Content(JsonConvert.SerializeObject(result)));
        }
Exemple #4
0
 private Task <OperationResult> InternalDeleteLineVehicleRelation(int RelationID, TerminalOperationClient client)
 {
     return(Task <OperationResult> .Run(() =>
     {
         var LineInfo = TerminalSettingsBLL.GetLineInformation(base.CurrentUserID, RelationID);
         if (LineInfo.Item1)
         {
             string PlateNum = LineInfo.Item2;
             string TerminalCode = LineInfo.Item3;
             int LineType = LineInfo.Item4;
             long LineID = LineInfo.Item5;
             var response = client.DeleteLine(TerminalCode, new RegionLineDeletionData()
             {
                 IDs = new uint[] { (uint)LineID }
             });
             OperationResult resultElement = null;
             if (!response.State)
             {
                 resultElement = new OperationResult()
                 {
                     Success = false,
                     Message = response.Message
                 };
             }
             else
             {
                 bool success = TerminalSettingsBLL.DeleteLineVehicleRelation(base.CurrentUserID, RelationID);
                 resultElement = new OperationResult()
                 {
                     Success = success,
                     Message = success ? DisplayText.OperationSucceeded : "车机端删除操作成功完成,删除数据库记录出错。"
                 };
             }
             TerminalSettingsBLL.InsertTerminalOperationsLog(
                 base.CurrentUserID, TerminalSettingType.RouteSettings_Delete, PlateNum, TerminalCode, false,
                 RelationID.ToString(), resultElement.Message, GetRemoteAddress()
                 );
             return resultElement;
         }
         else
         {
             string RecordNotExists = "数据库中找不到对应的设置记录。";
             TerminalSettingsBLL.InsertTerminalOperationsLog(
                 base.CurrentUserID, TerminalSettingType.RouteSettings_Delete,
                 null, null, false, RelationID.ToString(), RecordNotExists, GetRemoteAddress()
                 );
             return new OperationResult()
             {
                 Success = false,
                 Message = RecordNotExists
             };
         }
     }));
 }
Exemple #5
0
        public ActionResult UpdatePhoneBookSetting(
            [ModelBinder(typeof(BasicArrayBinder <string>))] string[] Vehicles,
            [ModelBinder(typeof(ObjectBinder <PhoneBookSettingModel>))] PhoneBookSettingModel Settings
            )
        {
            int userid = GetUserSession().UserId;

            var client    = new TerminalOperationClient();
            var objResult = new List <dynamic>();// 记录每次下发设置的返回结果

            foreach (var v in Vehicles)
            {
                dynamic result = new ExpandoObject();

                // Vehicles当中的记录为 PlateNum#TerminalCode
                string[] PlateNumAndTerminalCode = v.Split('#');
                string   PlateNum     = PlateNumAndTerminalCode[0];
                string   TerminalCode = PlateNumAndTerminalCode[1];

                var response = client.SetTelphone(TerminalCode, new TelphoneBookSettingData()
                {
                    TelphoneBookSettingType = (TelphoneBookSettingType)Settings.SettingType,
                    ContactItems            = new ContactItem[]
                    {
                        new ContactItem()
                        {
                            Contact         = Settings.Contact,
                            ContactItemFlag = (ContactItemFlag)Settings.CallType,
                            PhoneNumber     = Settings.Tel
                        }
                    }
                });

                // 记录日志
                TerminalSettingsBLL.InsertTerminalOperationsLog(
                    userid, TerminalSettingType.TextMessage, PlateNum,
                    TerminalCode, response.State, JsonConvert.SerializeObject(Settings),
                    null, GetRemoteAddress()
                    );

                //保存下发结果以便后面转换为json返回给页面显示
                result.state   = response.State;
                result.message = response.Message;
                objResult.Add(result);
            }
            return(Content(JsonConvert.SerializeObject(objResult)));
        }
Exemple #6
0
        public ActionResult SendTextMessage(
            [ModelBinder(typeof(BasicArrayBinder <string>))] string[] Vehicles,
            [ModelBinder(typeof(ObjectBinder <TextMessageModel>))] TextMessageModel Settings)
        {
            int userid = GetUserSession().UserId;

            var client    = new TerminalOperationClient();
            var objResult = new List <dynamic>();// 记录每次下发设置的返回结果

            foreach (var v in Vehicles)
            {
                dynamic result = new ExpandoObject();

                // Vehicles当中的记录为 PlateNum#TerminalCode
                string[] PlateNumAndTerminalCode = v.Split('#');
                string   PlateNum     = PlateNumAndTerminalCode[0];
                string   TerminalCode = PlateNumAndTerminalCode[1];

                var response = client.SendTextInfo(TerminalCode, new TextInformationData()
                {
                    Content             = Settings.MessageText,
                    TextInformationFlag = (TextInformationFlag)Settings.Flags
                });

                // 记录日志
                TerminalSettingsBLL.InsertTerminalOperationsLog(
                    userid, TerminalSettingType.TextMessage, PlateNum,
                    TerminalCode, response.State, JsonConvert.SerializeObject(Settings),
                    null, GetRemoteAddress()
                    );

                //保存下发结果以便后面转换为json返回给页面显示
                result.state   = response.State;
                result.message = response.Message;
                objResult.Add(result);
            }
            return(Content(JsonConvert.SerializeObject(objResult)));
        }
Exemple #7
0
        private Task <OperationResult> InternalAddRegionSettings(
            RegionProperty RegionProperty,
            string PlateNum,
            string TerminalCode,
            List <MapRegionsEditModel> RegionModel,
            TerminalOperationClient client
            )
        {
            return(Task <OperationResult> .Run(() =>
            {
                dynamic settingData = new ExpandoObject();
                settingData.OperationType = RegionSettingType.追加区域;
                settingData.RegionProperty = RegionProperty;
                settingData.Vehicles = new string[] { PlateNum };
                settingData.RegionID = RegionModel[0].ID;

                var exists = TerminalSettingsBLL.RegionVehicleRelationExists(PlateNum, TerminalCode, RegionModel[0].ID);
                if (exists.Item1)
                {
                    var r = new OperationResult()
                    {
                        Success = false,
                        Message = "数据库中已存在与指定车辆、区域对应的设置记录。"
                    };
                    TerminalSettingsBLL.InsertTerminalOperationsLog(
                        base.CurrentUserID,
                        TerminalSettingType.RegionSettings_Add,
                        PlateNum,
                        TerminalCode,
                        false,
                        JsonConvert.SerializeObject(settingData),
                        r.Message,
                        GetRemoteAddress()
                        );
                    return r;
                }

                StringBuilder start = new StringBuilder(), end = new StringBuilder();
                start.Append(RegionModel[0].StartDate == null ? "1601.01.01" : RegionModel[0].StartDate);
                start.Append(" ");
                start.Append(RegionModel[0].StartTime == null ? "00:00:00.000" : RegionModel[0].StartTime);

                end.Append(RegionModel[0].EndDate == null ? "1601.01.01" : RegionModel[0].EndDate);
                end.Append(" ");
                end.Append(RegionModel[0].EndTime == null ? "00:00:00.000" : RegionModel[0].EndTime);

                OperationResultGeneralRep response = null;
                switch (RegionModel[0].RegionsType)
                {
                case 1:        //圆形
                    response = client.SetCircularRegion(TerminalCode, new CircularRegionSettingData()
                    {
                        RegionSettingType = RegionSettingType.追加区域,
                        CircularRegionItems = new CircularRegionItem[]
                        {
                            new CircularRegionItem()
                            {
                                RegionID = (uint)RegionModel[0].ID,
                                CentralPointLatitude = RegionModel[0].CenterLatitude,
                                CentralPointLongitude = RegionModel[0].CenterLongitude,
                                Radius = Convert.ToUInt32(RegionModel[0].Radius),
                                MaxSpeed = Convert.ToUInt16(RegionModel[0].SpeedLimit),
                                OverSpeedDuration = (byte)RegionModel[0].OverSpeedDuration,
                                IsCyclical = RegionModel[0].Periodic,
                                StartDateTime = DateTime.Parse(start.ToString()),
                                EndDateTime = DateTime.Parse(end.ToString()),
                                RegionProperty = (RegionProperty)RegionProperty,
                            }
                        }
                    });
                    break;

                case 2:        //矩形
                    response = client.SetRectangularRegion(TerminalCode, new RectangularRegionSettingData()
                    {
                        RegionSettingType = RegionSettingType.追加区域,
                        RectangularRegionItems = new RectangularRegionItem[]
                        {
                            new RectangularRegionItem()
                            {
                                RegionID = (uint)RegionModel[0].ID,
                                TopLeftPointLatitude = RegionModel[0].LeftUpperLatitude,
                                TopLeftPointLongitude = RegionModel[0].LeftUpperLongitude,
                                BottomRightPointLatitude = RegionModel[0].RightLowerLatitude,
                                BottomRightPointLongitude = RegionModel[0].RightLowerLongitude,
                                MaxSpeed = Convert.ToUInt16(RegionModel[0].SpeedLimit),
                                OverSpeedDuration = (byte)RegionModel[0].OverSpeedDuration,
                                IsCyclical = RegionModel[0].Periodic,
                                StartDateTime = DateTime.Parse(start.ToString()),
                                EndDateTime = DateTime.Parse(end.ToString()),
                                RegionProperty = (RegionProperty)RegionProperty,
                            }
                        }
                    });
                    break;

                case 3:        //多边形
                    break;

                default:
                    break;
                }

                OperationResult resultElement = null;

                if (!response.State)
                {
                    //车机端操作失败
                    resultElement = new OperationResult()
                    {
                        Success = false,
                        Message = response.Message
                    };
                    TerminalSettingsBLL.InsertTerminalOperationsLog(
                        base.CurrentUserID,
                        TerminalSettingType.RegionSettings_Update,
                        PlateNum,
                        TerminalCode,
                        false,
                        JsonConvert.SerializeObject(settingData),
                        resultElement.Message,
                        GetRemoteAddress()
                        );
                }
                else
                {
                    bool success = TerminalSettingsBLL.AddRegionVehicleRelation(PlateNum, TerminalCode, RegionModel[0].ID, (ushort)RegionProperty);
                    resultElement = new OperationResult()
                    {
                        Success = success,
                        Message = success ? DisplayText.OperationSucceeded : "车机端更新操作成功完成,添加数据库记录出错。"
                    };
                    TerminalSettingsBLL.InsertTerminalOperationsLog(
                        base.CurrentUserID,
                        TerminalSettingType.RegionSettings_Update,
                        PlateNum,
                        TerminalCode,
                        success,
                        JsonConvert.SerializeObject(settingData),
                        resultElement.Message,
                        GetRemoteAddress()
                        );
                }
                return resultElement;
            }));
        }
Exemple #8
0
        public async Task <ActionResult> SendRegionSettings(int OperationType, int RegionProperty, string[] Vehicles, long RegionID)
        {
            OperationResult valid  = null;
            var             region = TerminalSettingsBLL.GetRegionsByRegionID((int)RegionID);

            TerminalSettingType SettingType;

            if (OperationType == (int)RegionSettingType.更新区域)
            {
                SettingType = TerminalSettingType.RegionSettings_Update;
            }
            else if (OperationType == (int)RegionSettingType.追加区域)
            {
                SettingType = TerminalSettingType.RegionSettings_Add;
            }
            else
            {
                SettingType = TerminalSettingType.None;
                valid       = new OperationResult()
                {
                    Success = false, Message = "区域设置暂不支持除 更新、追加 之外的其它操作。"
                };
            }

            if (Vehicles == null || Vehicles.Length == 0)
            {
                valid = new OperationResult()
                {
                    Success = false, Message = "未指定设置的车辆。"
                }
            }
            ;

            else if (region == null || region.Count == 0)
            {
                valid = new OperationResult()
                {
                    Success = false, Message = "数据库中未找到指定的区域。"
                }
            }
            ;

            else if (region[0].RegionsType < 1 || region[0].RegionsType > 3)
            {
                valid = new OperationResult()
                {
                    Success = false, Message = "指定的区域类型不受支持。"
                }
            }
            ;

            else if (OperationType == (int)RegionSettingType.更新区域 && region[0].RegionsType == 3)
            {
                return(Json(new OperationResult[] { new OperationResult()
                                                    {
                                                        Success = false, Message = "多边形区域不支持更新操作。"
                                                    } }));
            }

            if (valid != null)
            {
                dynamic settingData = new ExpandoObject();
                settingData.OperationType  = OperationType;
                settingData.RegionProperty = RegionProperty;
                settingData.Vehicles       = Vehicles;
                settingData.RegionID       = RegionID;
                TerminalSettingsBLL.InsertTerminalOperationsLog(
                    base.CurrentUserID,
                    SettingType,
                    null,
                    null,
                    false,
                    JsonConvert.SerializeObject(settingData),
                    valid.Message,
                    GetRemoteAddress()
                    );
                return(Json(new OperationResult[] { valid }));
            }

            var tasks = new Task <OperationResult> [Vehicles.Length];

            for (int i = 0; i != Vehicles.Length; i++)
            {
                string[] PlateNumAndTerminalCode = Vehicles[i].Split('#');
                string   PlateNum     = PlateNumAndTerminalCode[0];
                string   TerminalCode = PlateNumAndTerminalCode[1];
                var      client       = new TerminalOperationClient();
                if (OperationType == (int)RegionSettingType.更新区域)
                {
                    tasks[i] = InternalUpdateRegionSettings((RegionProperty)RegionProperty, PlateNum, TerminalCode, region, client);
                }
                else if (OperationType == (int)RegionSettingType.追加区域)
                {
                    tasks[i] = InternalAddRegionSettings((RegionProperty)RegionProperty, PlateNum, TerminalCode, region, client);
                }
            }

            var result = await Task.WhenAll <OperationResult>(tasks);

            return(Json(result));
        }
Exemple #9
0
        private Task <OperationResult> InternalDeleteRegionVehicleRelation(int RelationID, TerminalOperationClient client)
        {
            return(Task <OperationResult> .Run(() =>
            {
                var RegionInfo = TerminalSettingsBLL.GetRegionInformation(base.CurrentUserID, RelationID);
                if (RegionInfo.Item1)
                {
                    string PlateNum = RegionInfo.Item2;
                    string TerminalCode = RegionInfo.Item3;
                    int RegionType = RegionInfo.Item4;
                    long RegionID = RegionInfo.Item5;
                    OperationResultGeneralRep response;
                    switch (RegionType)
                    {
                    case 1:
                        response = client.DeleteCircularRegion(TerminalCode, new RegionLineDeletionData()
                        {
                            IDs = new uint[] { (uint)RegionID }
                        });
                        break;

                    case 2:
                        response = client.DeleteRectangularRegion(TerminalCode, new RegionLineDeletionData()
                        {
                            IDs = new uint[] { (uint)RegionID }
                        });
                        break;

                    case 3:
                        response = client.DeletePolygonRegion(TerminalCode, new RegionLineDeletionData()
                        {
                            IDs = new uint[] { (uint)RegionID }
                        });
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    OperationResult resultElement = null;
                    if (!response.State)
                    {
                        resultElement = new OperationResult()
                        {
                            Success = false,
                            Message = response.Message
                        };
                    }
                    else
                    {
                        bool success = TerminalSettingsBLL.DeleteRegionVehicleRelation(base.CurrentUserID, RelationID);
                        resultElement = new OperationResult()
                        {
                            Success = success,
                            Message = success ? DisplayText.OperationSucceeded : "车机端删除操作成功完成,删除数据库记录出错。"
                        };
                    }
                    TerminalSettingsBLL.InsertTerminalOperationsLog(
                        base.CurrentUserID, TerminalSettingType.RegionSettings_Delete, PlateNum, TerminalCode, false,
                        RelationID.ToString(), resultElement.Message, GetRemoteAddress()
                        );
                    return resultElement;
                }
                else
                {
                    string RecordNotExists = "数据库中找不到对应的设置记录。";
                    TerminalSettingsBLL.InsertTerminalOperationsLog(
                        base.CurrentUserID, TerminalSettingType.RegionSettings_Delete,
                        null, null, false, RelationID.ToString(), RecordNotExists, GetRemoteAddress()
                        );
                    return new OperationResult()
                    {
                        Success = false,
                        Message = RecordNotExists
                    };
                }
            }));
        }
Exemple #10
0
        private Task <OperationResult> InternalSendLineSettings(
            LineProperty LineProperty,
            string PlateNum,
            string TerminalCode,
            List <MapLinesDetailModel> LineModel,
            TerminalOperationClient client
            )
        {
            return(Task <OperationResult> .Run(() =>
            {
                dynamic settingData = new ExpandoObject();
                settingData.LineProperty = LineProperty;
                settingData.Vehicles = new string[] { PlateNum };
                settingData.LineID = LineModel[0].ID;

                var exists = TerminalSettingsBLL.LineVehicleRelationExists(PlateNum, TerminalCode, LineModel[0].ID);
                if (exists.Item1)
                {
                    var r = new OperationResult()
                    {
                        Success = false,
                        Message = "数据库中已存在与指定车辆、区域对应的设置记录。"
                    };
                    TerminalSettingsBLL.InsertTerminalOperationsLog(
                        base.CurrentUserID,
                        TerminalSettingType.RouteSettings_Add,
                        PlateNum,
                        TerminalCode,
                        false,
                        JsonConvert.SerializeObject(settingData),
                        r.Message,
                        GetRemoteAddress()
                        );
                    return r;
                }

                var LineInflectionPointItems = new LineInflectionPointItem[LineModel.Count];
                for (int i = 0; i != LineModel.Count; i++)
                {
                    LineInflectionPointItems[i] = new LineInflectionPointItem()
                    {
                        PointID = (uint)LineModel[i].OrderID,
                        RoadID = (uint)LineModel[i].ID,
                        PointLatitude = LineModel[i].Latitude,
                        PointLongitude = LineModel[i].Longitude,
                        RoadWidth = (byte)LineModel[i].RoadWidth.GetValueOrDefault(),
                        DrivingTooLongThresholding = (ushort)LineModel[i].MaxSecond.GetValueOrDefault(),
                        DrivingTooLackThresholding = (ushort)LineModel[i].MinSecond.GetValueOrDefault(),
                        MaxSpeed = (ushort)LineModel[i].SpeedLimit.GetValueOrDefault(),
                        OverSpeedDuration = (byte)LineModel[i].OverSpeedDuration.GetValueOrDefault()
                    };

                    if (LineModel[i].IsCheckTime.HasValue && LineModel[i].IsCheckTime.Value)
                    {
                        LineInflectionPointItems[i].RoadProperty |= RoadProperty.行驶时间;
                    }
                    if (LineModel[i].IsCheckSpeed.HasValue && LineModel[i].IsCheckSpeed.Value)
                    {
                        LineInflectionPointItems[i].RoadProperty |= RoadProperty.限速;
                    }
                }

                var response = client.SetLine(TerminalCode, new LineSettingData()
                {
                    LineID = (uint)LineModel[0].ID,
                    IsCyclical = false,
                    LineProperty = LineProperty,
                    StartDateTime = DateTime.Parse(LineModel[0].StartTime),
                    EndDateTime = DateTime.Parse(LineModel[0].EndTime),
                    LineInflectionPointItems = LineInflectionPointItems
                });

                OperationResult resultElement = null;

                if (!response.State)
                {
                    //车机端操作失败
                    resultElement = new OperationResult()
                    {
                        Success = false,
                        Message = response.Message
                    };
                    TerminalSettingsBLL.InsertTerminalOperationsLog(
                        base.CurrentUserID,
                        TerminalSettingType.RouteSettings_Add,
                        PlateNum,
                        TerminalCode,
                        false,
                        JsonConvert.SerializeObject(settingData),
                        resultElement.Message,
                        GetRemoteAddress()
                        );
                }
                else
                {
                    bool success = TerminalSettingsBLL.AddLineVehicleRelation(PlateNum, TerminalCode, exists.Item2.Value, (ushort)LineProperty);
                    resultElement = new OperationResult()
                    {
                        Success = success,
                        Message = success ? DisplayText.OperationSucceeded : "车机端更新操作成功完成,更新数据库记录出错。"
                    };
                    TerminalSettingsBLL.InsertTerminalOperationsLog(
                        base.CurrentUserID,
                        TerminalSettingType.RouteSettings_Add,
                        PlateNum,
                        TerminalCode,
                        success,
                        JsonConvert.SerializeObject(settingData),
                        resultElement.Message,
                        GetRemoteAddress()
                        );
                }
                return resultElement;
            }));
        }