Example #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));
        }
Example #2
0
        /// <summary>
        /// 查询指定路线数据
        /// </summary>
        /// <param name="RegionID">路线ID</param>
        /// <returns></returns>
        public ActionResult GetLineData(int LineID)
        {
            var lines = TerminalSettingsBLL.GetLinesByLineID(LineID);

            return(Json(lines, JsonRequestBehavior.AllowGet));
        }