예제 #1
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)));
        }
예제 #2
0
        public async Task <ActionResult> QueryTerminalFlags(TerminalSettingsReadModel model)
        {
            // 根据终端号获取终端所属服务器的wcf链接地址
            ActionResult            actionResult = null;
            List <TerminalWCfModel> wcfList      = null;

            if (!this.CheckWCF(model.ListVehicles, out actionResult, out wcfList))
            {
                return(actionResult);
            }
            // 记录错误信息
            string errorMsg = string.Empty;
            OperationResultQueryTerminalParaRespData syncResult;

            try
            {
                var entity = wcfList[0];
                var checkedParamArrayLength  = model.CheckedParamArray.Length;
                TerminalParaID[] paramIDs    = new TerminalParaID[checkedParamArrayLength];
                var    checkedParamArrayData = model.CheckedParamArray;
                string checkedTerminalPara   = PromptInformation.QueryContent + ":";
                for (int i = 0; i < checkedParamArrayLength; i++)
                {
                    paramIDs[i]          = (TerminalParaID)checkedParamArrayData[i];
                    checkedTerminalPara += (TerminalParaID)checkedParamArrayData[i] + ",";
                }

                var tempResult = await this.DoOperation <TerminalParaID[], OperationResultQueryTerminalParaRespData>(wcfList, paramIDs, SyncQuerySpecifiedTerminalParas);

                syncResult = tempResult.Single();
                string setInfo        = checkedTerminalPara.TrimEnd(',');
                string plateNum       = entity.PlateNum;
                string resultResponse = "Code:" + (int)(OperationResultCode)syncResult.Code + ";Message:" + syncResult.Message;

                // 记录日志 文本消息下发 这里拼接sql语句 批量插入
                string valuesSql = string.Format("('{0}','{1}',{2},'{3}',{4},'{5}','{6}',{7},'{8}'),",
                                                 entity.TerminalCode, plateNum, (byte)TerminalSettingTypeEnum.TerminalSetup_Query,
                                                 setInfo, syncResult.State ? 1 : 0, resultResponse, GetRemoteAddress(), base.CurrentUserID, DateTime.Now);
                if (!syncResult.State)
                {
                    //errorMsg += string.Format("<div style='font-weight:bolder;'>{0}:{1}{2}{3}:{4}{5}</div>",
                    //    UIText.TerminalSetting_PlateNumber, plateNum, "<br/>", PromptInformation.FailReason,syncResult.Code.ToString(), "<hr/>");
                    errorMsg += ErrorMesage(plateNum, syncResult.Code.ToString());
                }
                // 插入日志
                TerminalSettingsBLL.BatchInsertTerminalOperationsLog(valuesSql.TrimEnd(','));
            }
            catch (Exception ex)
            {
                LogHelper.TerminalSettingsErrorLog("终端设置读取异常:" + ex.Message);
                return(Json(new { Success = false, Message = PromptInformation.RemotingError }));
            }

            if (string.IsNullOrEmpty(errorMsg))
            {
                #region 返回数据
                var    responseData = syncResult.ResultData.ParaItems;
                string plateColor   = null;
                if (responseData.车牌颜色.HasValue)
                {
                    plateColor = responseData.车牌颜色.ToString();
                }

                dynamic result = new ExpandoObject();
                result.HeartbeatInterval          = responseData.终端心跳发送间隔;
                result.PrimaryServerIP            = responseData.主服务器IP地址或域名;
                result.BackupServerIP             = responseData.备份服务器IP地址或域名;
                result.ServerTCPPort              = responseData.务器TCP端口;
                result.StateRepotrIntervalSleep   = responseData.休眠时汇报时间间隔;
                result.StateRepotrIntervalUrgent  = responseData.紧急报警时汇报时间间隔;
                result.StateRepotrIntervalGeneral = responseData.缺省时间汇报间隔;
                result.MaximumSpeed                   = responseData.最高速度;
                result.OverspeedCheckTime             = responseData.超速持续时间;
                result.MaximumDrivingTime             = responseData.连续驾驶时间门限;
                result.MaximumDrivingTimeToday        = responseData.当天累计驾驶时间门限;
                result.MinimumBreakTime               = responseData.最小休息时间;
                result.MaximumStoppingTime            = responseData.最长停车时间;
                result.DifferenceOfOverspeedValues    = responseData.超速报警预警差值;
                result.DifferenceOfFatigueDrivingTime = responseData.疲劳驾驶预警差值;
                result.TotalODO          = responseData.车辆里程表读数;
                result.MotorNumberPlate  = responseData.公安交通管理部门颁发的机动车号牌;
                result.LicensePlateColor = plateColor;
                #endregion
                return(Json(new { Success = true, Message = JsonConvert.SerializeObject(result) }));
            }
            else
            {
                return(Json(new { Success = false, Message = errorMsg }));
            }
        }