Ejemplo n.º 1
0
        private async void CheckCmd(object sender, RoutedEventArgs e)
        {
            if (CmdGrid.DataContext != null)
            {
                var cmd = (MsgDispatchCommand)CmdGrid.DataContext;

                MsgCommandSign check = new MsgCommandSign(cmd.CmdSN, DateTime.Now.ToString(),
                                                          ConfigurationManager.ConnectionStrings["ClientName"].ConnectionString,
                                                          ConfigurationManager.ConnectionStrings["User"].ConnectionString);

                try
                {
                    await Task.Run(() =>
                    {
                        check.Category = MsgCategoryEnum.CommandSign;
                        IO.SendMsg(check, "DSIM.Command.Sign");
                    });

                    cmd.OneTargetSigned(check);
                }
                catch (Exception except)
                {
                    MessageBox.Show(except.Message);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 代签下达的命令
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void AgentSignExecute(object sender, ExecutedRoutedEventArgs e)
        {
            var cmd = ((AppVM)DataContext).CurrentCmd;

            if (cmd.IsApproving)
            {
                var oldCmd = ((AppVM)DataContext).CachedCmds.Where(i => i.CmdSN == cmd.CmdSN).First();
                ((AppVM)DataContext).CachedCmds.Remove(oldCmd);
                ((AppVM)DataContext).CachedCmds.Insert(0, cmd);
                ((AppVM)DataContext).CurrentCmd = cmd;

                cmd.Approve(true);
                CacheExecute(null, null);
            }
            else
            {
                var agentTarget = (Target)((DataGridCell)e.OriginalSource).DataContext;

                MsgCommandSign check = new MsgCommandSign(cmd.CmdSN, DateTime.Now.ToString(),
                                                          ConfigurationManager.ConnectionStrings["ClientName"].ConnectionString,
                                                          ConfigurationManager.ConnectionStrings["User"].ConnectionString)
                {
                    IsAgentSign = true,
                    AgentTarget = agentTarget.Name
                };

                try
                {
                    await Task.Run(() =>
                    {
                        check.Category = MsgCategoryEnum.CommandAgentSign;
                        IO.SendMsg(check, "DSIM.Command.AgentSign");
                    });
                }
                catch (Exception except)
                {
                    MessageBox.Show(except.Message);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 接收代签命令,并显示签收窗口
        /// </summary>
        /// <param name="data"></param>
        private void AgentSignCmd(MsgCommandSign data)
        {
            if (data.AgentTarget == ConfigurationManager.ConnectionStrings["ClientName"].ConnectionString)
            {
                var appVM = (AppVM)DataContext;
                var cmd   = appVM.ReceivedCmds.Where(i => i.CmdSN == data.CmdSN).First();

                cmd.OneTargetSigned(data);

                if (Application.Current.Windows.OfType <ReceiveCommandWindow>().Count() == 0)
                {
                    ReceiveCommandWindow window = new ReceiveCommandWindow(appVM.ReceivedCmds);
                    window.Show();
                    window.ChangeCmd(cmd);
                }
                else
                {
                    var window = Application.Current.Windows.OfType <ReceiveCommandWindow>().First();
                    window.WindowState = WindowState.Normal;
                    Application.Current.Windows.OfType <ReceiveCommandWindow>().First().ChangeCmd(cmd);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 处理网络广播到本地的签收回执
        /// </summary>
        /// <param name="data"></param>
        private void TargetSignCmd(MsgCommandSign data)
        {
            var cmd = ((AppVM)DataContext).SendingCmds.Where(i => i.CmdSN == data.CmdSN).First();

            cmd.OneTargetSigned(data);

            if (cmd.CmdState == CmdState.已签收)
            {
                ((AppVM)DataContext).SendingCmds.Remove(cmd);
                ((AppVM)DataContext).SendCmds.Insert(0, cmd);
            }

            ((AppVM)DataContext).ReceivedCmds.Insert(0, data);

            var speed = ((AppVM)DataContext).SpeedCmds.Where(i => i.CmdSN == data.CmdSN);

            if (speed.Count() != 0)
            {
                if (cmd.CmdState == CmdState.已签收)
                {
                    speed.First().CmdState = CmdState.已签收;
                }
            }
        }