Пример #1
0
        private void WriteLog(DeviceCommViewModel.DeviceName diviceName, string com = null, string intUsed = null, string Param = null)
        {
            string log = lcSaveDevice.Text + _space;

            log += lcDeviceName.Text + _colon + diviceName.ToString() + _space;
            log += lcComName.Text + _colon + com + _space;
            if (intUsed != null)
            {
                log += lcUseDevice.Text + _colon + (intUsed.Trim() == "1" ? lcUseDevice.Text : lcNotUseDevice.Text);
            }
            if (Param != null)
            {
                try
                {
                    if (diviceName == DeviceCommViewModel.DeviceName.LicenseRecog || diviceName == DeviceCommViewModel.DeviceName.SecurityCamera)
                    {
                        object o = JsonNewtonsoft.FromJSON(Param);
                        if (o is JObject && o != null)
                        {
                            log += _space + gcUserName.Text + _colon + (o as JObject)["userName"].ToString() + _space;
                            log += _space + lcPassword2.Text + _colon + (o as JObject)["Password"].ToString() + _space;
                        }
                    }
                    if (diviceName == DeviceCommViewModel.DeviceName.Plat)
                    {
                        log += lcPlatNum.Text + _colon + Param + _space;
                    }
                }
                catch { }
            }
            ErrorLog.SystemLog(DateTime.Now, log);
        }
Пример #2
0
        private void sbSave_Click(object sender, EventArgs e)
        {
            SimpleButton[] buttons = { sbRefresh, sbSave };
            ButtonEnable(false, buttons);
            //获取旧的参数,保存失败则回溯
            DTDeviceInfo dt = DeviceCommViewModel.VM.PlatEntities;
            PlatParam    pp = new PlatParam();

            pp.platNum           = tePlatNumber.Text.ToString();
            pp.unloadInvalidData = ceUnloadData.Checked;
            string param = JsonNewtonsoft.ToJSON(pp);

            bool rs = SaveDeviceComChanges(
                DeviceCommViewModel.DeviceName.Plat,
                cbeCommunication.Text, null, param);

            if (!rs)
            {
                BackDeviceComChanges(dt);
            }
            ButtonEnable(true, buttons);
            RefreshUI();
            if (!rs)
            {
                return;
            }

            DeviceNotifyEventArgs args = new DeviceNotifyEventArgs();

            args.Key   = "PlatDevice";
            args.Param = param;
            onDeviceNotify(args);
        }
Пример #3
0
 /// <summary>
 /// 站点设置被修改后下发命令通知服务端
 /// </summary>
 private void SendCmdToSOA()
 {
     try
     {
         OtherParamInfo oth = new OtherParamInfo();
         oth.StationNumber   = teID.Text;
         oth.Name            = teStationName.Text;
         oth.Longitude       = teLangitude.Text;
         oth.Latitude        = teLatitude.Text;
         oth.Highly          = Convert.ToDouble(teHighly.Text);
         oth.Slope           = Convert.ToDouble(teSlope.Text);
         oth.DetialedAddress = teDetialedAddress.Text;
         oth.Tips            = meTips.Text;
         oth.StationType     = cbeStationType.SelectedIndex;
         string str = JsonNewtonsoft.ToJSON(oth);
         if (str != "")
         {
             BusinessServiceHelper.Instanse.ExecuteBusiness(ExternalBusinessCmd.SetStationInfo, str);
         }
     }
     catch (Exception ex)
     {
         ErrorLog.Error(ex.ToString());
     }
 }
 private void sbSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtNO.Text.Trim() == "" || txtCO.Text.Trim() == "" || txtHC.Text.Trim() == "" || mmTips.Text.Trim() == "")
         {
             XtraMessageBox.Show(Program.infoResource.GetLocalizedString(language.InfoId.InputNotNull));
         }
         else
         {
             string          log  = Program.infoResource.GetLocalizedString(language.InfoId.LimitingInfoChange);
             CarLimitingInfo info = new CarLimitingInfo();
             GasolineCarInfo gaso = new GasolineCarInfo();
             gaso.NOLimiting       = Convert.ToDouble(txtNO.Text);
             gaso.COLimiting       = Convert.ToDouble(txtCO.Text);
             gaso.HCLimiting       = Convert.ToDouble(txtHC.Text);
             info.GasolimitCarInfo = gaso;
             string str = JsonNewtonsoft.ToJSON(info);
             if (str != "")
             {
                 BusinessResult br = BusinessServiceHelper.Instanse.ExecuteBusiness(ExternalBusinessCmd.SetCarLimitInfo, str, BusinessType.Set);
                 if (br == null || !br.Result)
                 {
                     XtraMessageBox.Show(Program.infoResource.GetLocalizedString(language.InfoId.SaveFail));
                     log += Program.infoResource.GetLocalizedString(language.InfoId.OperateFail);
                     ErrorLog.SystemLog(DateTime.Now, log, this.OwnerForm.GetUserName());
                     return;
                 }
             }
             ResultDataViewModel.VM.Execute(new List <object> {
                 ResultDataViewModel.ExecuteCommand.ec_InsertGasolineLimiting,
                 System.DateTime.Now,
                 txtNO.Text,
                 txtCO.Text,
                 txtHC.Text,
                 mmTips.Text
             });
             log += lcNOLimiting.Text + ":" + txtNO.Text;
             log += lcCOLimiting.Text + ":" + txtCO.Text;
             log += lcHCLimiting.Text + ":" + txtHC.Text;
             log += lcTips.Text + ":" + mmTips.Text;
             if (ResultDataViewModel.VM.InsertGasolineLimitingResult)
             {
                 log += Program.infoResource.GetLocalizedString(language.InfoId.OpearteSuccess);
                 XtraMessageBox.Show(Program.infoResource.GetLocalizedString(language.InfoId.SaveCompleted));
             }
             else
             {
                 log += Program.infoResource.GetLocalizedString(language.InfoId.OperateFail);
                 XtraMessageBox.Show(Program.infoResource.GetLocalizedString(language.InfoId.SaveFail));
             }
             ErrorLog.SystemLog(DateTime.Now, log, this.OwnerForm.GetUserName());
         }
     }
     catch (Exception ex)
     {
         ErrorLog.Error(ex.ToString());
     }
 }
Пример #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     listView1.Items.Clear();
     //数据验证
     if (!string.IsNullOrWhiteSpace(tbx_Dh.Text.Trim()) && !string.IsNullOrWhiteSpace(tbx_Phone.Text.Trim()))
     {
         KdApiSearchDemo demo = new KdApiSearchDemo();
         //获取控件值
         string dh     = tbx_Dh.Text.Trim();
         string phone  = tbx_Phone.Text.Trim();
         string bsCode = comboBox1.SelectedValue.ToString();
         //接受返回值
         string result = demo.getOrderTracesByJson(dh, phone, bsCode);
         List <LogisticsModel> logisticsList = new List <LogisticsModel>();
         if (!string.IsNullOrWhiteSpace(result))
         {
             //Json转化实体类
             LogisticsInfoResultModel logisticsModelList = JsonNewtonsoft.FromJSON <LogisticsInfoResultModel>(result);
             if (logisticsModelList != null && logisticsModelList.Traces != null && logisticsModelList.Traces.Count() > 0)
             {
                 //接收快递信息列表,按最新时间倒序排列
                 logisticsList = logisticsModelList.Traces.OrderByDescending(x => x.AcceptTime).ToList();
             }
         }
         if (logisticsList != null && logisticsList.Count() > 0)
         {
             listView1.BeginUpdate();   //数据更新,UI暂时挂起,直到EndUpdate绘制控件,可以有效避免闪烁并大大提高加载速度
             int i = 0;
             foreach (var trace in logisticsList)
             {
                 //绑定数据
                 ListViewItem lvi = new ListViewItem();
                 //lvi.Text第一列
                 lvi.Text = trace.AcceptTime.ToString();
                 //第二列,第三列、第四列以此类推,与第一列不同
                 lvi.SubItems.Add(trace.AcceptStation);
                 //设置最新一条记录的样式区别于其他记录
                 if (i == 0)
                 {
                     lvi.Font = new Font("仿宋", 12, FontStyle.Bold);
                     //设置字体颜色
                     lvi.ForeColor = Color.Blue;
                 }
                 listView1.Items.Add(lvi);
                 i++;
             }
             listView1.EndUpdate();
         }
         else
         {
             MessageBox.Show("未获取到快递信息", "提示");
         }
     }
     else
     {
         MessageBox.Show("快递单号与收件人手机号不能为空", "提示");
     }
 }
Пример #6
0
        /// <summary>
        /// 查询相机 ip,用户名,密码,端口号
        /// </summary>
        /// <returns></returns>
        private bool LoadCameraParam()
        {
            List <object> lsDevice = ResultDataViewModel.VM.Devices;

            if (lsDevice == null || lsDevice.Count < 1)
            {
                ErrorLog.Error(TIPS_DeviceListIsNull);
                return(false);
            }
            for (int i = 0; i < lsDevice.Count; i++)
            {
                if (lsDevice[i] is DTDeviceInfo)
                {
                    try
                    {
                        DTDeviceInfo dt = lsDevice[i] as DTDeviceInfo;
                        if (dt.Name.Value.ToString().Trim() == CameraName)
                        {
                            string  param = dt.Param.Value.ToString();
                            JObject dp    = JsonNewtonsoft.FromJSON(param) as JObject;
                            JToken  jt;
                            dp.TryGetValue("userName", out jt);
                            UserName = jt.ToString();
                            dp.TryGetValue("Password", out jt);
                            PassWord = jt.ToString();
                            string CommInfo = dt.Commuunication.Value.ToString();
                            if (String.IsNullOrEmpty(CommInfo))
                            {
                                ErrorLog.Error(TIPS_CommInfoIsNull);
                                return(false);
                            }
                            ResultDataViewModel.VM.Execute(new List <object> {
                                ResultDataViewModel.ExecuteCommand.ec_QueryCommunicationInfo,
                                CommInfo
                            });
                            if (ResultDataViewModel.VM.QueryComSingleEntities == null || ResultDataViewModel.VM.QueryComSingleEntities.Count < 1)
                            {
                                ErrorLog.Error(TIPS_CommInfoIsNull);
                                //          lcVedioTips.Text = ;
                                return(false);
                            }
                            DTCommunicationInfo dtCom = ResultDataViewModel.VM.QueryComSingleEntities[0] as DTCommunicationInfo;
                            IpAddress = dtCom.IP.Value.ToString().Trim();
                            Port      = Convert.ToInt32(dtCom.PortNumberTCP.Value.ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        ErrorLog.Error(ex.ToString());
                        //      lcVedioTips.Text = TIPS_Error;
                        return(false);
                    }
                }
            }
            return(true);
        }
Пример #7
0
        internal static void updateInventoryQueryStartDateTime(int shopId, DateTime dateTime)
        {
            IDictionary <string, string> textParams = new Dictionary <string, string>();

            textParams.Add("shopId", shopId.ToString());
            textParams.Add("inventoryQueryStartDateTime", dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            textParams.Add("loginToken", AppConstant.loginToken);
            string resJson = new HttpUtils().DoPost(AppConstant.updateInventoryQueryStartDateTimeUrl, textParams);
            BaseResponse <Object> baseResponse = JsonNewtonsoft.FromJSON <BaseResponse <Object> >(resJson);
        }
Пример #8
0
        private void saveOrder(int shopId, string orderJson, string orderItemsJson)
        {
            IDictionary <string, string> textParams = new Dictionary <string, string>();

            textParams.Add("shopId", shopId.ToString());
            textParams.Add("orderJson", orderJson);
            textParams.Add("orderItemsJson", orderItemsJson);
            textParams.Add("loginToken", AppConstant.loginToken);
            String resJson = new HttpUtils().DoPost(AppConstant.saveOrderUrl, textParams);
            BaseResponse <Object> baseResponse = JsonNewtonsoft.FromJSON <BaseResponse <Object> >(resJson);
        }
Пример #9
0
        private void saveInventory(List <InventorySupply> list)
        {
            IDictionary <string, string> textParams = new Dictionary <string, string>();

            textParams.Add("shopId", shopId.ToString());
            textParams.Add("inventoryJson", JsonNewtonsoft.ToJSON(list));
            textParams.Add("loginToken", AppConstant.loginToken);
            String resJson = new HttpUtils().DoPost(AppConstant.saveInventoryUrl, textParams);
            BaseResponse <Object> baseResponse = JsonNewtonsoft.FromJSON <BaseResponse <Object> >(resJson);

            AppConstant.SynTaskInfo.InventoryTask.SynDataNumber += list.Count;
        }
Пример #10
0
        private void dealOrder(int shopId, Order order)
        {
            String dealInfo = "dealOrder AmazonOrderId: " + order.AmazonOrderId;

            AppConstant.SynTaskInfo.OrderTask.dealInfoAppend(dealInfo);
            List <OrderItem> orderItems     = getOrderItems(order.AmazonOrderId);
            String           orderItemsJson = JsonNewtonsoft.ToJSON(orderItems);
            String           orderJson      = JsonNewtonsoft.ToJSON(order);

            saveOrder(shopId, orderJson, orderItemsJson);
            ShopService.updateLastUpdatedAfter(shopId, order.LastUpdateDate);
            AppConstant.SynTaskInfo.OrderTask.SynDataNumber += 1;
            lastUpdatedAfter = order.LastUpdateDate;
        }
Пример #11
0
        internal static Entity.BaseResponse <CurrentUserInfo> login(string userName, string password)
        {
            IDictionary <string, string> textParams = new Dictionary <string, string>();

            textParams.Add("userName", userName);
            textParams.Add("password", password);
            String resJson = new HttpUtils().DoPost(AppConstant.clientLoginUrl, textParams);
            BaseResponse <CurrentUserInfo> baseResponse = JsonNewtonsoft.FromJSON <BaseResponse <CurrentUserInfo> >(resJson);

            if (baseResponse.isSuccessd())
            {
                AppConstant.loginToken = baseResponse.Data.LoginToken;
            }
            return(baseResponse);
        }
        internal static string getConfigByKey(string key)
        {
            IDictionary <string, string> textParams = new Dictionary <string, string>();

            textParams.Add("keyName", key);
            textParams.Add("loginToken", AppConstant.loginToken);
            String resJson = new HttpUtils().DoPost(AppConstant.getConfigByKeyUrl, textParams);
            BaseResponse <SysConfig> baseResponse = JsonNewtonsoft.FromJSON <BaseResponse <SysConfig> >(resJson);

            if (baseResponse.isSuccessd())
            {
                return(baseResponse.Data.KeyValue);
            }
            return(null);
        }
Пример #13
0
        protected override void InitializeBindings()
        {
            mvvmContext1.SetViewModel(typeof(DeviceCommViewModel), DeviceCommViewModel.VM);
            fluent = mvvmContext1.OfType <DeviceCommViewModel>();

            AddBinding(fluent.SetBinding(cbeCommunication, ce => ce.Text, x => x.PlatEntities, m => {
                if (m == null || m.Commuunication.Value == null)
                {
                    return(null);
                }
                return(m.Commuunication.Value.ToString());
            }));
            AddBinding(fluent.SetBinding(tePlatNumber, lc => lc.Text, x => x.PlatEntities, m => {
                if (m == null || m.Param.Value == null)
                {
                    return(null);
                }
                object o = JsonNewtonsoft.FromJSON(m.Param.Value.ToString());
                if (o is JObject)
                {
                    return((o as JObject)["platNum"].ToString());
                }
                return(m.Param.Value.ToString());
            }));
            AddBinding(fluent.SetBinding(ceUnloadData, lc => lc.Checked, x => x.PlatEntities, m => {
                if (m == null || m.Param.Value == null)
                {
                    return(ceUnloadData.Checked);
                }
                object o = JsonNewtonsoft.FromJSON(m.Param.Value.ToString());
                if (o is JObject)
                {
                    return((o as JObject)["unloadInvalidData"].ToString().Trim().ToLower() == "true");
                }
                return(ceUnloadData.Checked);
            }));
            DeviceCommViewModel.VM.ModelChanged += (sender, arg) =>
            {
                if (arg.ModelName == typeof(DeviceCommViewModel).Name)
                {
                    action();
                }
            };
            RefreshUI();
            base.InitializeBindings();
        }
Пример #14
0
        private void sbSave_Click(object sender, EventArgs e)
        {
            SimpleButton[] buttons = { sbRefresh, sbSave };
            ButtonEnable(false, buttons);
            if (tePassword.Text.Trim() == null || teUserName.Text.Trim() == null)
            {
                XtraMessageBox.Show("用户名和密码不能为空");
            }
            //获取旧的参数,保存失败则回溯
            DTDeviceInfo dt = DeviceCommViewModel.VM.LicenseRecogEntities;

            CameraUserAndPwd cup = new CameraUserAndPwd();

            cup.userName = teUserName.Text;
            cup.Password = tePassword.Text;
            string param = JsonNewtonsoft.ToJSON(cup);
            bool   rs    = SaveDeviceComChanges(
                DeviceCommViewModel.DeviceName.LicenseRecog,
                cbeCommunication.Text,
                null,
                param
                );

            if (!rs)
            {
                BackDeviceComChanges(dt);
            }
            ButtonEnable(true, buttons);
            RefreshUI();
            if (!rs)
            {
                return;
            }
            DeviceNotifyEventArgs args = new DeviceNotifyEventArgs();

            args.Key   = "LicenseRecognitionDevice";
            args.Param = param;
            onDeviceNotify(args);
            //if (rs) XtraMessageBox.Show("保存成功");
            //else XtraMessageBox.Show("保存失败");
        }
Пример #15
0
        internal static BaseResponse <Shop> getCurrentUserShop()
        {
            String macAddress = GetSystemInfo.getMacAddr_Local();
            string loginToken = AppConstant.loginToken;

            if (String.IsNullOrEmpty(macAddress))
            {
                return(BaseResponse <Shop> .failMessage("macAddress不能为空"));
            }
            if (String.IsNullOrEmpty(loginToken))
            {
                return(BaseResponse <Shop> .failMessage("loginToken不能为空"));
            }
            IDictionary <string, string> textParams = new Dictionary <string, string>();

            textParams.Add("macAddress", macAddress);
            textParams.Add("loginToken", loginToken);
            string resJson = new HttpUtils().DoPost(AppConstant.getCurrentUserShopUrl, textParams);
            BaseResponse <Shop> baseResponse = JsonNewtonsoft.FromJSON <BaseResponse <Shop> >(resJson);

            return(baseResponse);
        }
Пример #16
0
        /// <summary>
        /// 发送设备信息给SOA
        /// </summary>
        /// <param name="args"></param>
        public void SendDeviceInfoToSOA(List <object> args)
        {
            SendDeviceToSOAEntities.Result = false;
            if (args.Count < 3)
            {
                return;
            }
            try
            {
                DeviceInfo info = new DeviceInfo();
                info.Name          = args[0] == null ? "" : args[0].ToString();
                info.Communication = args[1] == null ? "" : args[1].ToString();
                info.Used          = args[2] == null ? -1 : Convert.ToInt32(args[2]);
                info.Param         = args[3] == null ? "" : args[3].ToString();

                SendDeviceToSOAEntities = DeviceCommBusinessServerHelper.Instanse.ExecuteBusiness(DeviceConfigUpdate, JsonNewtonsoft.ToJSON(info), BusinessType.Set);
            }
            catch (Exception ex)
            {
            }
        }
Пример #17
0
        protected override void InitializeBindings()
        {
            try
            {
                mvvmContext1.SetViewModel(typeof(ResultDataViewModel), ResultDataViewModel.VM);
                fluent = mvvmContext1.OfType <ResultDataViewModel>();
                #region AddBinding
                AddBinding(fluent.SetBinding(lcTestingnumvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = m[0];
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("UniqueKey", out value))
                        {
                            return(value.ToString());
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcResultvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("Result", out value))
                        {
                            if (value.ToString().Equals("1"))
                            {
                                //合格
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Qualified));
                            }
                            else if (value.ToString().Equals("0"))
                            {
                                //不合格
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Disqualified));
                            }
                            else if (value.ToString().Equals("2"))
                            {
                                //无效
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Invalid));
                            }
                        }
                    }
                    return("0");
                }));

                AddBinding(fluent.SetBinding(lcNOvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("NO", out value) && value.ToString() != "")
                        {
                            return(Convert.ToDouble(value.ToString()).ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcHCvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("HC", out value) && value.ToString() != "")
                        {
                            return(Convert.ToDouble(value.ToString()).ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcCOvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("CO", out value) && value.ToString() != "")
                        {
                            return(Convert.ToDouble(value.ToString()).ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcCO2value, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("CO2", out value) && value.ToString() != "")
                        {
                            return(Convert.ToDouble(value.ToString()).ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcOpSmokevalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("OpSmoke", out value) && value.ToString() != "")
                        {
                            return(Convert.ToDouble(value.ToString()).ToString("f2"));
                        }
                        ;
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcLicensenumvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("CarNumber", out value))
                        {
                            return(value.ToString());
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcBlacknessvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("Ⅰ");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("Blackness", out value) && value.ToString() != "")
                        {
                            return(ConvertIntToRoma(value.ToString()));
                        }
                    }
                    return("Ⅰ");
                }));
                AddBinding(fluent.SetBinding(lcLicensecolorvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("CarNumberColor", out value))
                        {
                            if (value == null || value.ToString() == "")
                            {
                                return("0");
                            }
                            enumCarNumberColor rs;
                            Enum.TryParse <enumCarNumberColor>(value.ToString().Trim(), out rs);
                            switch (rs)
                            {
                            case enumCarNumberColor.Color_Blue:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Blue));

                            case enumCarNumberColor.Color_Yellow:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Yellow));

                            case enumCarNumberColor.Color_White:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.White));

                            case enumCarNumberColor.Color_Black:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Black));

                            case enumCarNumberColor.Color_Green:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Green));

                            case enumCarNumberColor.Color_Blackness:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Blackness));

                            default:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.OtherColor));
                            }
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcBodycolorvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("CarColor", out value))
                        {
                            if (value == null || value.ToString() == "")
                            {
                                return("0");
                            }
                            enumBodyColor rs;
                            Enum.TryParse <enumBodyColor>(value.ToString().Trim(), out rs);
                            switch (rs)
                            {
                            case enumBodyColor.Color_Other:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.OtherColor));

                            case enumBodyColor.Color_White:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.White));

                            case enumBodyColor.Color_Silvery:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Silvery));

                            case enumBodyColor.Color_Gray:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Gray));

                            case enumBodyColor.Color_Black:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Black));

                            case enumBodyColor.Color_Red:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Red));

                            case enumBodyColor.Color_Darkblue:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.DarkBlue));

                            case enumBodyColor.Color_Blue:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Blue));

                            case enumBodyColor.Color_Yellow:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Yellow));

                            case enumBodyColor.Color_Green:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Green));

                            case enumBodyColor.Color_Brown:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Brown));

                            case enumBodyColor.Color_Pink:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Pink));

                            case enumBodyColor.Color_Violet:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Violet));

                            case enumBodyColor.Color_Darkgrey:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.DarkGrey));

                            case enumBodyColor.Color_Cyan:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Cyan));

                            default:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.UnfindColor));
                            }
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcLicenseTypeValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return(Program.infoResource.GetLocalizedString(language.InfoId.UnfindColor));
                    }
                    ;
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("LicenseType", out value))
                        {
                            if (value == null || value.ToString() == "")
                            {
                                return(Program.infoResource.GetLocalizedString(language.InfoId.UnfindColor));
                            }
                            ;
                            switch (Convert.ToInt32(value))
                            {
                            case (int)enumLicenseType.VCA_STANDARD92_PLATE:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.VCA_STANDARD92_PLATE));

                            case (int)enumLicenseType.VCA_STANDARD02_PLATE:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.VCA_STANDARD02_PLATE));

                            case (int)enumLicenseType.VCA_WJPOLICE_PLATE:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.VCA_WJPOLICE_PLATE));

                            case (int)enumLicenseType.VCA_JINGCHE_PLATE:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.VCA_JINGCHE_PLATE));

                            case (int)enumLicenseType.STANDARD92_BACK_PLATE:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.STANDARD92_BACK_PLATE));

                            case (int)enumLicenseType.VCA_SHIGUAN_PLATE:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.VCA_SHIGUAN_PLATE));

                            case (int)enumLicenseType.VCA_NONGYONG_PLATE:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.VCA_NONGYONG_PLATE));

                            case (int)enumLicenseType.VCA_MOTO_PLATE:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.VCA_MOTO_PLATE));

                            case (int)enumLicenseType.NEW_ENERGY_PLATE:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.NEW_ENERGY_PLATE));

                            default:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.UnfindColor));
                            }
                        }
                    }
                    return(Program.infoResource.GetLocalizedString(language.InfoId.UnfindColor));;
                }));
                AddBinding(fluent.SetBinding(lcVehicleTypeValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return(Program.infoResource.GetLocalizedString(language.InfoId.VTR_RESULT_OTHER));
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("VehicleType", out value))
                        {
                            if (value == null || value.ToString() == "")
                            {
                                return(Program.infoResource.GetLocalizedString(language.InfoId.VTR_RESULT_OTHER));
                            }
                            int index = Convert.ToInt32(value);
#if VerticalDistribution
                            language.InfoId infoId = language.InfoId.VTR_RESULT_CLASSIFY_OTHER;
                            int claIdx             = Utils.ClassifyVehicleType(index);
                            return(Program.infoResource.GetLocalizedString(infoId + claIdx - 1));
#else
                            if (index < 0 || index > 26)
                            {
                                return(Program.infoResource.GetLocalizedString(language.InfoId.VTR_RESULT_OTHER));
                            }
#endif
                        }
                    }
                    return(Program.infoResource.GetLocalizedString(language.InfoId.UnfindColor));
                }));
                AddBinding(fluent.SetBinding(lcFuelTypeValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("CarType", out value))
                        {
                            if (value == null || value.ToString() == "")
                            {
                                return("");
                            }
                            switch (value.ToString().Trim())
                            {
                            case "A":
                                return(Program.infoResource.GetLocalizedString(language.InfoId.GasolineCar));

                            case "B":
                                return(Program.infoResource.GetLocalizedString(language.InfoId.DieselCar));

                            case "Z":
                                return(Program.infoResource.GetLocalizedString(language.InfoId.OtherFuelCar));

                            default:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.OtherFuelCar));
                            }
                        }
                    }
                    return("");
                }));
                AddBinding(fluent.SetBinding(lcConfidenceValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("Confidence", out value) && value.ToString() != "")
                        {
                            return((Convert.ToDouble(value.ToString())).ToString("f2"));
                        }
                    }
                    return("0");
                }));

                AddBinding(fluent.SetBinding(lcSpeedvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("Speed", out value) && value.ToString() != "")
                        {
                            return((Convert.ToDouble(value.ToString()) * 3.6).ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcVSPvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("VSP", out value) && value.ToString() != "")
                        {
                            return(Convert.ToDouble(value.ToString()).ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcAccelerationvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("Acceleration", out value) && value.ToString() != "")
                        {
                            return(Convert.ToDouble(value.ToString()).ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcTemperaturevalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("Temperature", out value) && value.ToString() != "")
                        {
                            return(Convert.ToDouble(value.ToString()).ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcHumidityvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("Humidity", out value) && value.ToString() != "")
                        {
                            return(Convert.ToDouble(value.ToString()).ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcWindDirectionvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("WindDirection", out value))
                        {
                            return(Convert.ToDouble(value.ToString()).ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcWindSpeedvalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("WindSpeed", out value) && value.ToString() != "")
                        {
                            return(Convert.ToDouble(value.ToString()).ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcPressurevalue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("Pressure", out value) && value.ToString() != "")
                        {
                            return(Convert.ToDouble(value.ToString()).ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcSO2Value, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("SO2", out value) && value.ToString() != "")
                        {
                            float fBefore = Convert.ToSingle(value.ToString());
                            float fAfter  = Utils.UnitConvert(fBefore, Utils.UnitTypes.ugm3, Unit.SO2, 64);
                            return(fAfter.ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcO3value, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("O3", out value) && value.ToString() != "")
                        {
                            float fBefore = Convert.ToSingle(value.ToString());
                            float fAfter  = Utils.UnitConvert(fBefore, Utils.UnitTypes.ugm3, Unit.O3, 48);
                            return(fAfter.ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcNO2value, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("NO2", out value) && value.ToString() != "")
                        {
                            float fBefore = Convert.ToSingle(value.ToString());
                            float fAfter  = Utils.UnitConvert(fBefore, Utils.UnitTypes.ugm3, Unit.NO2, 46);
                            return(fAfter.ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcPM10value, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("PM10", out value) && value.ToString() != "")
                        {
                            float fBefore = Convert.ToSingle(value.ToString());
                            float fAfter  = Utils.UnitConvert(fBefore, Utils.UnitTypes.ugm3, Unit.PM10, 1);
                            return(fAfter.ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcPM25value, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("PM2Point5", out value) && value.ToString() != "")
                        {
                            float fBefore = Convert.ToSingle(value.ToString());
                            float fAfter  = Utils.UnitConvert(fBefore, Utils.UnitTypes.ugm3, Unit.PM25, 1);
                            return(fAfter.ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcCOValueAQ, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("COAir", out value) && value.ToString() != "")
                        {
                            float fBefore = Convert.ToSingle(value.ToString());
                            float fAfter  = Utils.UnitConvert(fBefore, Utils.UnitTypes.mgm3, Unit.CO, 28);
                            return(fAfter.ToString("f2"));
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcPM2, ce => ce.Text, x => x.AirQuality.Param, m => {
                    string unit = RealtimeMonitorViewModel.VM.getDeviceParam(c_AirQuality, lcPM2.Tag.ToString()).Replace("m3", "m³");
                    if (String.IsNullOrEmpty(unit))
                    {
                        unit = "ug/m³";
                    }
                    return(c_PM25Name + c_LeftParen + unit + c_RightParen);
                }));
                AddBinding(fluent.SetBinding(lcPM10AQ, ce => ce.Text, x => x.AirQuality.Param, m => {
                    string unit = RealtimeMonitorViewModel.VM.getDeviceParam(c_AirQuality, lcPM10AQ.Name.Substring(2, 4)).Replace("m3", "m³");
                    if (String.IsNullOrEmpty(unit))
                    {
                        unit = "ug/m³";
                    }
                    return(c_PM10Name + c_LeftParen + unit + c_RightParen);
                }));
                AddBinding(fluent.SetBinding(lcNO2AQ, ce => ce.Text, x => x.AirQuality.Param, m => {
                    string unit = RealtimeMonitorViewModel.VM.getDeviceParam(c_AirQuality, lcNO2AQ.Name.Substring(2, 3)).Replace("m3", "m³");
                    if (String.IsNullOrEmpty(unit))
                    {
                        unit = "ug/m³";
                    }
                    return(c_NO2Name + c_LeftParen + unit + c_RightParen);
                }));
                AddBinding(fluent.SetBinding(lcO3AQ, ce => ce.Text, x => x.AirQuality.Param, m => {
                    string unit = RealtimeMonitorViewModel.VM.getDeviceParam(c_AirQuality, lcO3AQ.Name.Substring(2, 2)).Replace("m3", "m³");
                    if (String.IsNullOrEmpty(unit))
                    {
                        unit = "ug/m³";
                    }
                    return(c_O3Name + c_LeftParen + unit + c_RightParen);
                }));
                AddBinding(fluent.SetBinding(lcSO2AQ, ce => ce.Text, x => x.AirQuality.Param, m => {
                    string unit = RealtimeMonitorViewModel.VM.getDeviceParam(c_AirQuality, lcSO2AQ.Name.Substring(2, 3)).Replace("m3", "m³");
                    if (String.IsNullOrEmpty(unit))
                    {
                        unit = "ug/m³";
                    }
                    return(c_SO2Name + c_LeftParen + unit + c_RightParen);
                }));
                AddBinding(fluent.SetBinding(lcCOAQ, ce => ce.Text, x => x.AirQuality.Param, m => {
                    string unit = RealtimeMonitorViewModel.VM.getDeviceParam(c_AirQuality, lcCOAQ.Name.Substring(2, 2)).Replace("m3", "m³");
                    if (String.IsNullOrEmpty(unit))
                    {
                        unit = "mg/m³";
                    }
                    return(c_COName + c_LeftParen + unit + c_RightParen);
                }));



                Messenger.Default.Register <ucPluginBase.DeviceNotifyEventArgs>(this, (args) => {
                    if (!args.Key.Contains(c_AirQuality))
                    {
                        return;
                    }
                    RealtimeMonitorViewModel.VM.Devices = null;
                    SetUnit();
                    action();
                });


                #endregion
                ResultDataViewModel.VM.ModelChanged += (sender, arg) =>
                {
                    if (arg.ModelName == typeof(ResultDataViewModel).Name)
                    {
                        action();
                    }
                };

                base.InitializeBindings();
            }
            catch (Exception ex)
            {
                ErrorLog.Error(ex.StackTrace.ToString());
            }
        }
Пример #18
0
        protected override void InitializeBindings()
        {
            try
            {
                //      RefreshChartInfo(index);
                mvvmContext1.SetViewModel(typeof(ResultDataViewModel), ResultDataViewModel.VM);
                fluent = mvvmContext1.OfType <ResultDataViewModel>();
                #region AddBinding
                AddBinding(fluent.SetBinding(lcNODCvalue, lc => lc.Text, x => x.ExhaustDetailData, m =>
                {
                    if (m == null)
                    {
                        return("0");
                    }
                    return(m.OriginalNO.ToString("f2"));
                }));
                AddBinding(fluent.SetBinding(lcHCDCvalue, lc => lc.Text, x => x.ExhaustDetailData, m =>
                {
                    if (m == null)
                    {
                        return("0");
                    }
                    return(m.OriginalHC.ToString("f2"));
                }));
                AddBinding(fluent.SetBinding(lcCODCvalue, lc => lc.Text, x => x.ExhaustDetailData, m =>
                {
                    if (m == null)
                    {
                        return("0");
                    }
                    return(m.OriginalCO.ToString("f2"));
                }));
                AddBinding(fluent.SetBinding(lcCO2DCvalue, lc => lc.Text, x => x.ExhaustDetailData, m =>
                {
                    if (m == null)
                    {
                        return("0");
                    }
                    return(m.OriginalCO2.ToString("f2"));
                }));


                AddBinding(fluent.SetBinding(lcT1Value, lc => lc.Text, x => x.ExhaustDetailData, m =>
                {
                    if (m == null)
                    {
                        return("0");
                    }
                    return(m.T12.ToString());
                }));
                AddBinding(fluent.SetBinding(lcT2value, lc => lc.Text, x => x.ExhaustDetailData, m =>
                {
                    if (m == null)
                    {
                        return("0");
                    }
                    return(m.T13.ToString());
                }));
                AddBinding(fluent.SetBinding(lcLightIntensityValue, lc => lc.Text, x => x.ExhaustDetailData, m =>
                {
                    if (m == null)
                    {
                        return("0");
                    }
                    return(m.RealIntensity.ToString());
                }));

                AddBinding(fluent.SetBinding(lcCOValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    try
                    {
                        if (m == null || m.Count == 0)
                        {
                            return("0");
                        }
                        object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                        if (o is JObject)
                        {
                            JObject jo   = (o as JObject);
                            string value = jo["CO"].ToString();
                            if (!string.IsNullOrEmpty(value))
                            {
                                return(Convert.ToDouble(value).ToString("f2"));
                            }
                        }
                    }
                    catch (Exception ex) { ErrorLog.Error(ex.ToString()); }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcNOValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    try
                    {
                        if (m == null || m.Count == 0)
                        {
                            return("0");
                        }
                        object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                        if (o is JObject)
                        {
                            JObject jo   = (o as JObject);
                            string value = jo["NO"].ToString();
                            if (!string.IsNullOrEmpty(value))
                            {
                                return(Convert.ToDouble(value).ToString("f2"));
                            }
                        }
                    }
                    catch (Exception ex) { ErrorLog.Error(ex.ToString()); }

                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcHCValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    try
                    {
                        if (m == null || m.Count == 0)
                        {
                            return("0");
                        }
                        object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                        if (o is JObject)
                        {
                            JObject jo   = (o as JObject);
                            string value = jo["HC"].ToString();
                            if (!string.IsNullOrEmpty(value))
                            {
                                return(Convert.ToDouble(value).ToString("f2"));
                            }
                        }
                    }
                    catch (Exception ex) { ErrorLog.Error(ex.ToString()); }

                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcCO2Value, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    try
                    {
                        if (m == null || m.Count == 0)
                        {
                            return("0");
                        }
                        object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                        if (o is JObject)
                        {
                            JObject jo   = (o as JObject);
                            string value = jo["CO2"].ToString();
                            if (!string.IsNullOrEmpty(value))
                            {
                                return(Convert.ToDouble(value.ToString()).ToString("f2"));
                            }
                        }
                    }
                    catch (Exception ex) { ErrorLog.Error(ex.ToString()); }

                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcOpsmokeValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    try
                    {
                        if (m == null || m.Count == 0)
                        {
                            return("0");
                        }
                        object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                        if (o is JObject)
                        {
                            JObject jo   = (o as JObject);
                            string value = jo["OpSmoke"].ToString();
                            if (!string.IsNullOrEmpty(value))
                            {
                                return(Convert.ToDouble(value.ToString()).ToString("f2"));
                            }
                        }
                    }
                    catch (Exception ex) { ErrorLog.Error(ex.ToString()); }

                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcBlacknessValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    try
                    {
                        if (m == null || m.Count == 0)
                        {
                            return("0");
                        }
                        object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                        if (o is JObject)
                        {
                            JObject jo   = (o as JObject);
                            string value = jo["Blackness"].ToString();
                            if (!string.IsNullOrEmpty(value))
                            {
                                return(ConvertIntToRoma(value.ToString()));
                            }
                        }
                    }
                    catch (Exception ex) { ErrorLog.Error(ex.ToString()); }

                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcNumberValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    try
                    {
                        if (m == null || m.Count == 0)
                        {
                            return("0");
                        }
                        object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                        if (o is JObject)
                        {
                            JObject jo   = (o as JObject);
                            string value = jo["UniqueKey"].ToString();
                            if (!string.IsNullOrEmpty(value))
                            {
                                return(value.ToString());
                            }
                        }
                    }
                    catch (Exception ex) { ErrorLog.Error(ex.ToString()); }

                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcResultValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    try
                    {
                        if (m == null || m.Count == 0)
                        {
                            return("0");
                        }
                        object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                        if (o is JObject)
                        {
                            JObject jo   = (o as JObject);
                            string value = jo["Result"].ToString();
                            switch (Convert.ToInt32(value) + 1)
                            {
                            case 1:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Disqualified));

                            case 2:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Qualified));

                            case 3:
                                return(Program.infoResource.GetLocalizedString(language.InfoId.Invalid));
                            }
                        }
                    }
                    catch (Exception ex) { ErrorLog.Error(ex.ToString()); }

                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcT1Value, lc => lc.Text, x => x.ExhaustDetailData, m => { return(m.T12.ToString()); }));
                AddBinding(fluent.SetBinding(lcT2value, lc => lc.Text, x => x.ExhaustDetailData, m => { return(m.T13.ToString()); }));
                AddBinding(fluent.SetBinding(lcLightIntensityValue, lc => lc.Text, x => x.ExhaustDetailData, m => { return(m.RealIntensity.ToString()); }));
                ResultDataViewModel.VM.ModelChanged += (sender, arg) =>
                {
                    if (arg.ModelName == typeof(ResultDataViewModel).Name || arg.ModelName == typeof(ResultDataViewModel.ExhaustDetailDataModel).Name)
                    {
                        action();
                    }
                };
                #endregion
                base.InitializeBindings();

                RefreshChartInfo(index);
            }
            catch (Exception ex)
            {
            }
        }
Пример #19
0
        protected override void InitializeBindings()
        {
            mvvmContext1.SetViewModel(typeof(DeviceCommViewModel), DeviceCommViewModel.VM);
            fluent = mvvmContext1.OfType <DeviceCommViewModel>();
            AddBinding(fluent.SetBinding(ceUsedPm, ce => ce.CheckState, x => x.SecurityCameraEntities, m => {
                if (m == null || m.Used.Value == null)
                {
                    return(CheckState.Checked);
                }
                return(m.Used.Value.ToString() == "1" ? CheckState.Checked : CheckState.Unchecked);
            }));
            AddBinding(fluent.SetBinding(cbeCommunication, ce => ce.Text, x => x.SecurityCameraEntities, m => {
                if (m == null || m.Commuunication.Value == null)
                {
                    return(null);
                }
                return(m.Commuunication.Value.ToString());
            }));
            AddBinding(fluent.SetBinding(teUserName, ce => ce.Text, x => x.SecurityCameraEntities, m => {
                try
                {
                    if (m == null || m.Param.Value == null)
                    {
                        return("");
                    }
                    object o = JsonNewtonsoft.FromJSON(m.Param.Value.ToString());
                    if (o is JObject)
                    {
                        JObject jo   = (o as JObject);
                        string value = jo["userName"].ToString();
                        return(value);
                    }
                    return("");
                }
                catch { return(""); }
            }));
            AddBinding(fluent.SetBinding(tePassword, ce => ce.Text, x => x.SecurityCameraEntities, m => {
                try
                {
                    if (m == null || m.Param.Value == null)
                    {
                        return("");
                    }
                    object o = JsonNewtonsoft.FromJSON(m.Param.Value.ToString());
                    if (o is JObject)
                    {
                        JObject jo   = (o as JObject);
                        string value = jo["Password"].ToString();
                        return(value);
                    }
                    return("");
                }
                catch { return(""); }
            }));

            DeviceCommViewModel.VM.ModelChanged += (sender, arg) =>
            {
                if (arg.ModelName == typeof(DeviceCommViewModel).Name)
                {
                    action();
                }
            };
            RefreshUI();
            base.InitializeBindings();
        }
Пример #20
0
        protected override void InitializeBindings()
        {
            try
            {
                string uniqueKey = ucEdata.GetUniqueKeyByIndex(iIndex);
                _GalleryItemGroup.Items.Add(_farPicture);
                _GalleryItemGroup.Items.Add(_nearPicture);
                gcPicture.Gallery.Groups.Add(_GalleryItemGroup);
                gcPicture.Gallery.ItemSize = new Size(gcPicture.Width - 6, gcPicture.Height / 2 - 6);
                //      ResultDataViewModel.VM.Execute(new List<object> { ResultDataViewModel.ExecuteCommand.ec_QueryDetialInfo, iIndex,uniqueKey });
                //       ShowUC(iIndex);
                mvvmContext1.SetViewModel(typeof(ResultDataViewModel), ResultDataViewModel.VM);
                Messenger.Default.Register <string>(this, typeof(ResultDataViewModel).Name, action);
                fluent = mvvmContext1.OfType <ResultDataViewModel>();

                AddBinding(fluent.SetBinding(this, t => t.FarPicturePath, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("PicFarPath", out value))
                        {
                            return(value.ToString());
                        }
                    }
                    return("");
                }));
                AddBinding(fluent.SetBinding(this, t => t.NearPicturePath, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("PicNearPath", out value))
                        {
                            return(value.ToString());
                        }
                    }
                    return("");
                }));
                AddBinding(fluent.SetBinding(lcStationNameValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("Station", out value) && value.ToString() != "")
                        {
                            return(value.ToString());
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcLongitudeValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("Longitude", out value) && value.ToString() != "")
                        {
                            return(value.ToString());
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcLatitudeValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("Latitude", out value) && value.ToString() != "")
                        {
                            return(value.ToString());
                        }
                    }
                    return("0");
                }));
                AddBinding(fluent.SetBinding(lcSlopeValue, lc => lc.Text, x => x.DetialInfoEntities, m =>
                {
                    if (m == null || m.Count == 0)
                    {
                        return("0");
                    }
                    object o = JsonNewtonsoft.FromJSON(m[0].ToString());
                    if (o is JObject)
                    {
                        JObject jo = (o as JObject);
                        JToken value;
                        if (jo.TryGetValue("Slope", out value) && value.ToString() != "")
                        {
                            return(value.ToString());
                        }
                    }
                    return("0");
                }));


                RealtimeMonitorViewModel.VM.ModelChanged += (sender, arg) => {
                    if (arg.ModelName == typeof(ResultDataViewModel).Name)
                    {
                        action();
                    }
                };
                base.InitializeBindings();
            }
            catch (Exception ex)
            {
                ErrorLog.Error(ex.StackTrace.ToString());
            }
        }
        private void sbSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtNO.Text.Trim() == "" || txtOpSmoke.Text.Trim() == "" || txtBlackness.Text.Trim() == "" || mmTips.Text.Trim() == "" || (ceOpSmoke.Checked == true && txtOpSmokeSetting.Text.Trim() == ""))
                {
                    XtraMessageBox.Show(Program.infoResource.GetLocalizedString(language.InfoId.InputNotNull));
                }
                else
                {
                    string          log    = Program.infoResource.GetLocalizedString(language.InfoId.LimitingInfoChange);
                    CarLimitingInfo info   = new CarLimitingInfo();
                    DieselCarInfo   diesel = new DieselCarInfo();
                    diesel.NOLimiting        = Convert.ToDouble(txtNO.Text);
                    diesel.OpSmokeLimiting   = Convert.ToDouble(txtOpSmoke.Text);
                    diesel.BlacknessLimiting = Convert.ToInt32(ConvertRomaToInt(txtBlackness.Text));
                    info.DieselCarLimitInfo  = diesel;
                    info.JudgeOpSmoke        = ceOpSmoke.Checked ? 1 : 0;
                    info.JudgeOpSmokeValue   = Convert.ToDouble(txtOpSmokeSetting.Text == ""?"0": txtOpSmokeSetting.Text);
                    info.JudgeYellowCar      = ceYellowCar.Checked ? 1 : 0;
                    string          str = JsonNewtonsoft.ToJSON(info);
                    BusinessMessage msg = new BusinessMessage();
                    msg.BusinessCommand = ExternalBusinessCmd.SetCarLimitInfo;
                    msg.BusinessParam   = str;
                    msg.BusiType        = BusinessType.Set;
                    msg.BusiPriority    = BusinessPriority.Highest;
                    if (str != "")
                    {
                        BusinessResult br = BusinessServiceHelper.Instanse.ExecuteBusiness(msg);
                        if (br == null || !br.Result)
                        {
                            XtraMessageBox.Show(Program.infoResource.GetLocalizedString(language.InfoId.SaveFail));
                            log += Program.infoResource.GetLocalizedString(language.InfoId.OperateFail);
                            ErrorLog.SystemLog(DateTime.Now, log, this.OwnerForm.GetUserName());
                            return;
                        }
                    }

                    ResultDataViewModel.VM.Execute(new List <object> {
                        ResultDataViewModel.ExecuteCommand.ec_InsertDieselCarLimiting,
                        System.DateTime.Now,
                        txtNO.Text,
                        txtOpSmoke.Text,
                        ConvertRomaToInt(txtBlackness.Text),
                        ceOpSmoke.EditValue,
                        ceYellowCar.EditValue,
                        txtOpSmokeSetting.Text,
                        mmTips.Text
                    });

                    log += lcNOLimiting.Text + ":" + txtNO.Text + ",";
                    log += lcOpSmokeLimiting.Text + ":" + txtOpSmoke.Text + ",";
                    log += lcBlacknessLimiting.Text + ":" + txtBlackness.Text + ",";
                    log += lcSelect.Text + ":" + (ceOpSmoke.Checked ? ceOpSmoke.Text + txtOpSmokeSetting.Text : "") + (ceYellowCar.Checked ? ceYellowCar.Text : "");
                    log += lcTips.Text + " " + mmTips.Text + ",";
                    if (ResultDataViewModel.VM.InsertDieselCarLimitingResult)
                    {
                        log += Program.infoResource.GetLocalizedString(language.InfoId.OpearteSuccess);
                        XtraMessageBox.Show(Program.infoResource.GetLocalizedString(language.InfoId.SaveCompleted));
                    }
                    else
                    {
                        log += Program.infoResource.GetLocalizedString(language.InfoId.OperateFail);
                        XtraMessageBox.Show(Program.infoResource.GetLocalizedString(language.InfoId.SaveFail));
                    }
                    ErrorLog.SystemLog(DateTime.Now, log, this.OwnerForm.GetUserName());
                }
            }
            catch (Exception ex)
            {
                ErrorLog.Error(ex.ToString());
            }
        }