Beispiel #1
0
        /// <summary>
        /// 取消配对
        /// </summary>
        /// <param name="deviceCode"></param>
        private void CancelMatch(string deviceCode, string deviceID)
        {
            Conditions con = new Conditions();

            con.AddItem("DeviceID", deviceID);
            con.AddItem("DeviceCode", deviceCode);

            // 发送配对消息
            ResultWindow     resultWindow = WindowsHelper.ShowDialogWindow <ResultWindow>(this, MsgType.DeviceCancelPair, MsgType.DeviceCancelPairResult, con, TryFindResource("GatherCancelPairing").ToString());
            MessageBoxResult msgBoxResult = resultWindow.MessageBoxResult;

            if (msgBoxResult == MessageBoxResult.Cancel)
            {
                tbMsg.Text = TryFindResource("GatherCancelPairOverTime").ToString();
            }
            else if (msgBoxResult == MessageBoxResult.Yes)
            {
                NewMessageBox.Show(TryFindResource("GatherCancelPairSuccess").ToString(), this);
                tbMsg.Text = string.Empty;
                btnCanelMatch.Visibility = Visibility.Hidden;
            }
            else if (msgBoxResult == MessageBoxResult.No)
            {
                DevicePairInfo devicePairInfo = resultWindow.ResultValue as DevicePairInfo;
                if (devicePairInfo.ResultCode == 2)
                {
                    NewMessageBox.Show(TryFindResource("GatherCancelPairFail").ToString(), this);
                }
                else
                {
                    NewMessageBox.Show(TryFindResource("GatherCancelPairFailed").ToString(), this);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 配对信息返回结果
        /// </summary>
        /// <param name="msgType"></param>
        /// <param name="value"></param>
        private void AnalyzeDevicePairResult(MsgType msgType, string value)
        {
            App.Current.Dispatcher.Invoke(new Action(() =>
            {
                DevicePairInfo devicePairInfo = XmlUnityConvert.XmlDeserialize <DevicePairInfo>(value);
                ResultWindow resultWindow     = CheckResultMsg(msgType);
                if (resultWindow == null)
                {
                    return;
                }

                if (devicePairInfo.ResultCode == 0)
                {
                    resultWindow.SuccessCloseWindow();
                    if (msgType == MsgType.DevicePairResult)
                    {
                        DeviceInfoHelper.DevicePairInfo(devicePairInfo);
                    }
                    else
                    {
                        // 取消配对
                        DeviceInfoHelper.DeviceCancelPair(devicePairInfo.DeviceCode ?? string.Empty);
                    }
                }
                else
                {
                    resultWindow.FailedCloseWindow(devicePairInfo);
                }
            }));
        }
Beispiel #3
0
        /// <summary>
        /// 正常警员配对
        /// </summary>
        private void MatchDeviceByNormalPolice(string forceMatch = "0")
        {
            // 普通警员:先判断是否此设备和自己配对,如果是则弹出配对窗口,里面只有自己可以选择,否则提示不能操作
            if (deviveInfo.IsMatchOrRegist == Model.IsMatchOrRegist.Matched)
            {
                EditorMatchByNormal();
            }
            else
            {
                Conditions con = new Conditions();
                con.AddItem("UserID", AppConfigInfos.LimitsUserInfos.UserID);
                con.AddItem("DeviceID", deviveInfo.DeviceCode);
                con.AddItem("UserName", AppConfigInfos.CurrentUserInfos.UserName);
                con.AddItem("UserCode", AppConfigInfos.CurrentUserInfos.UserCode);
                con.AddItem("OrgID", AppConfigInfos.CurrentUserInfos.OrgID);
                con.AddItem("OrgName", AppConfigInfos.CurrentUserInfos.OrgName);
                con.AddItem("ForceMatch", forceMatch);

                // 发送配对消息
                ResultWindow     resultWindow = WindowsHelper.ShowDialogWindow <ResultWindow>(parentWindow, MsgType.DevicePair, MsgType.DevicePairResult, con, TryFindResource("GatherPairing").ToString());
                MessageBoxResult msgBoxResult = resultWindow.MessageBoxResult;
                if (msgBoxResult == MessageBoxResult.Cancel)
                {
                    NewMessageBox.Show(TryFindResource("GatherPairOverTime").ToString(), parentWindow);
                }
                else if (msgBoxResult == MessageBoxResult.Yes)
                {
                    NewMessageBox.Show(TryFindResource("GatherPairSuccess").ToString(), parentWindow);
                    ModelResponsible.Instance.SendOperationLog("CollectDevicePair");
                }
                else if (msgBoxResult == MessageBoxResult.No)
                {
                    DevicePairInfo devicePairInfo = resultWindow.ResultValue as DevicePairInfo;
                    if (devicePairInfo.ResultCode == 2)
                    {
                        // 已配对
                        MessageBoxResult messageBoxResult = NewMessageBox.Show(string.Format(TryFindResource("GatherAlreadyPair").ToString(), devicePairInfo.ResultMsg), MessageBoxButton.YesNo, parentWindow);
                        if (messageBoxResult == MessageBoxResult.Yes)
                        {
                            MatchDeviceByNormalPolice("1");
                        }
                    }
                    else
                    {
                        string msg = (TryFindResource("GatherPairCode_" + devicePairInfo.ResultCode) ?? string.Empty).ToString();
                        msg = string.IsNullOrEmpty(msg) ? TryFindResource("GatherPairCode_-1").ToString() : msg;
                        NewMessageBox.Show(msg, parentWindow);
                    }
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 更新配对信息
        /// </summary>
        /// <param name="devicePairInfo"></param>
        public static void DevicePairInfo(DevicePairInfo devicePairInfo)
        {
            DeviveInfo deviveInfo = GatherViewModel.DeviveInfoList.Find(p => p.DeviceCode.Equals(devicePairInfo.DeviceID));

            if (deviveInfo != null)
            {
                deviveInfo.MatchUserID     = devicePairInfo.UserID;
                deviveInfo.MatchUserName   = devicePairInfo.UserName;
                deviveInfo.OrgID           = devicePairInfo.OrgID;
                deviveInfo.MatchUserCode   = devicePairInfo.UserCode;
                deviveInfo.MatchOrgName    = devicePairInfo.OrgName;
                deviveInfo.MatchTime       = devicePairInfo.MatchTime;
                deviveInfo.IsMatchOrRegist = IsMatchOrRegist.Matched;
            }
        }
Beispiel #5
0
        /// <summary>
        /// 配对
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMatch_Click(object sender, RoutedEventArgs e)
        {
            tbMsg.Text = string.Empty;
            btnCanelMatch.Visibility = Visibility.Hidden;

            if ((DeviveInfo.IsMatchOrRegist == IsMatchOrRegist.Registered &&
                 string.IsNullOrEmpty(autoCmb.SelectValue)) ||
                (DeviveInfo.IsMatchOrRegist == IsMatchOrRegist.Matched &&
                 !string.IsNullOrEmpty(autoCmb.Text) &&
                 string.IsNullOrEmpty(autoCmb.SelectValue)))
            {
                tbMsg.Text = TryFindResource("GatherPairInfoError").ToString();
                return;
            }

            DeviveInfo selectDevice = GatherViewModel.DeviveInfoList.Find(p => p.DeviceCode.Equals(DeviveInfo.DeviceCode));

            if (selectDevice == null)
            {
                NewMessageBox.Show(string.Format(TryFindResource("GatherDeviceRemove").ToString(), DeviveInfo.DeviceCode));
                return;
            }

            if (DeviveInfo.IsMatchOrRegist == IsMatchOrRegist.Matched && DeviveInfo.MatchUserID.Equals(autoCmb.SelectValue))
            {
                NewMessageBox.Show(TryFindResource("GatherPairInfoNoChange").ToString());
                // 编辑配对如果用户没有选择其他用户点击配置,则直接结束
                this.Close();
                return;
            }

            Conditions con = new Conditions();

            if (!string.IsNullOrEmpty(autoCmb.SelectValue))
            {
                // 配对
                UserInfos matchUserInfo = AppConfigInfos.LimitsUserInfos.Users.UserList.Find(p => p.UserID.Equals(autoCmb.SelectValue));

                con.AddItem("UserID", autoCmb.SelectValue);
                con.AddItem("DeviceID", DeviveInfo.DeviceCode);
                con.AddItem("UserName", matchUserInfo == null ? string.Empty : matchUserInfo.UserName);
                con.AddItem("UserCode", matchUserInfo == null ? string.Empty : matchUserInfo.UserCode);
                con.AddItem("OrgID", matchUserInfo == null ? string.Empty : matchUserInfo.OrgID);
                con.AddItem("OrgName", matchUserInfo == null ? string.Empty : matchUserInfo.OrgName);
                con.AddItem("ForceMatch", "0"); // 调度员没有取消后再配对协议
            }
            else
            {
                // 选择为空的则为取消配对
                CancelMatch(DeviveInfo.DeviceCode, (DeviveInfo.DeviceID ?? string.Empty).ToString());
                this.Close();
                return;
            }

            // 发送配对消息
            ResultWindow     resultWindow = WindowsHelper.ShowDialogWindow <ResultWindow>(this, MsgType.DevicePair, MsgType.DevicePairResult, con, TryFindResource("GatherPairing").ToString());
            MessageBoxResult msgBoxResult = resultWindow.MessageBoxResult;

            if (msgBoxResult == MessageBoxResult.Cancel)
            {
                tbMsg.Text = TryFindResource("GatherPairOverTime").ToString();
            }
            else if (msgBoxResult == MessageBoxResult.Yes)
            {
                if (isPair)
                {
                    ModelResponsible.Instance.SendOperationLog("CollectDevicePair");
                }
                else
                {
                    ModelResponsible.Instance.SendOperationLog("CollectDeviceEditor");
                }

                this.Close();
            }
            else if (msgBoxResult == MessageBoxResult.No)
            {
                DevicePairInfo devicePairInfo = resultWindow.ResultValue as DevicePairInfo;
                if (devicePairInfo.ResultCode == 2)
                {
                    // 已配对
                    tbMsg.Text = string.Format(TryFindResource("GatherPairMarkStart").ToString(), devicePairInfo.ResultMsg);
                    btnCanelMatch.Visibility = Visibility.Visible;
                    btnCanelMatch.Tag        = devicePairInfo.ResultMsg + "," + devicePairInfo.DeviceID; // 记录已配对DeviceCode
                }
                else
                {
                    string msg = (TryFindResource("GatherPairCode_" + devicePairInfo.ResultCode) ?? string.Empty).ToString();
                    msg        = string.IsNullOrEmpty(msg) ? TryFindResource("GatherPairCode_-1").ToString() : msg;
                    tbMsg.Text = msg;
                }
            }
        }