/// <summary>
        /// 从模板窗口传递一个命令副本到主窗口编辑界面
        /// </summary>
        /// <param name="data"></param>
        private void NewEdittingCmd(MsgDispatchCommand data)
        {
            int count = ((AppVM)DataContext).CachedCmds.Count +
                        ((AppVM)DataContext).SendingCmds.Count +
                        ((AppVM)DataContext).SendCmds.Count;

            data.CmdSN = (count + 1).ToString();

            //新命令的上下文数据
            var appVM = (AppVM)DataContext;

            appVM.CurrentCmd = data;

            CmdParagraph.Inlines.Clear();

            var lst = data.Content.ToString().Split(new string[] { "***" }, StringSplitOptions.None);

            for (int i = 0; i < lst.Length; i++)
            {
                Run r = new Run(lst[i]);
                CmdParagraph.Inlines.Add(r);

                if (i != lst.Length - 1)
                {
                    Hyperlink hl = new Hyperlink();
                    hl.Inlines.Add(new Run("        "));
                    CmdParagraph.Inlines.Add(hl);
                }
            }
        }
        /// <summary>
        /// 设置当前命令为指定值
        /// </summary>
        /// <param name="cmd"></param>
        private void SetCurrentCmd(MsgDispatchCommand cmd)
        {
            ((AppVM)DataContext).CurrentCmd = cmd;

            CmdParagraph.Inlines.Clear();
            CmdParagraph.Inlines.Add(new Run(cmd.Content.ToString()));
        }
        /// <summary>
        /// 处理网络广播到本地的下达命令
        /// </summary>
        /// <param name="cmd"></param>
        private void TransmitCmd(MsgDispatchCommand cmd)
        {
            var result = ((AppVM)DataContext).CachedCmds.Where(i => i.CmdSN == cmd.CmdSN);

            ((AppVM)DataContext).CachedCmds.Remove(result.First());

            ((AppVM)DataContext).SendingCmds.Insert(0, cmd);
            ((AppVM)DataContext).CurrentCmd = cmd;

            CmdParagraph.Inlines.Clear();
            CmdParagraph.Inlines.Add(new Run(cmd.Content.ToString()));

            cmd.CmdState = CmdState.已下达;
        }
        /// <summary>
        /// 处理网络广播到本地的缓存命令
        /// </summary>
        /// <param name="cmd"></param>
        private void UpdateCacheCmd(MsgDispatchCommand cmd)
        {
            var result = ((AppVM)DataContext).CachedCmds.Where(i => i.CmdSN == cmd.CmdSN);

            if (result.Count() != 0)
            {
                if (((AppVM)DataContext).CachedCmds.Count != 0)
                {
                    ((AppVM)DataContext).CachedCmds.Remove(result.First());
                }
            }

            ((AppVM)DataContext).CachedCmds.Insert(0, cmd);
            ((AppVM)DataContext).CurrentCmd = cmd;

            CmdParagraph.Inlines.Clear();
            CmdParagraph.Inlines.Add(new Run(cmd.Content.ToString()));

            cmd.CmdState = CmdState.已缓存;
        }
        /// <summary>
        /// 处理网络广播到本地的申请消息
        /// </summary>
        /// <param name="cmd"></param>
        private void ApproveCmd(MsgDispatchCommand cmd)
        {
            var user   = ConfigurationManager.ConnectionStrings["User"].ConnectionString;
            var result = cmd.Targets.Where(i => i.Name == user);

            // 这里客户端的用户应该是"值班主任"
            if (result.Count() != 0)
            {
                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;

                if (MessageBox.Show("当前命令正在申请批准,请审阅并选择是否批准", "操作提示", MessageBoxButton.YesNo, MessageBoxImage.Warning) ==
                    MessageBoxResult.Yes)
                {
                    cmd.Approve();
                    CacheExecute(null, null);
                }
            }
        }
Example #6
0
        /// <summary>
        /// 接收调度命令,并显示签收窗口
        /// </summary>
        /// <param name="cmd"></param>
        private void ReceiveCmd(MsgDispatchCommand cmd)
        {
            var targets = cmd.Targets.Where(i => i.IsSelected == true &&
                                            i.Name == ConfigurationManager.ConnectionStrings["ClientName"].ConnectionString);

            if (targets.Count() != 0)
            {
                var appVM       = (AppVM)DataContext;
                var receivedLst = appVM.ReceivedCmds;
                receivedLst.Insert(0, cmd);

                if (Application.Current.Windows.OfType <ReceiveCommandWindow>().Count() == 0)
                {
                    ReceiveCommandWindow window = new ReceiveCommandWindow(receivedLst);
                    window.Show();
                }
                else
                {
                    var window = Application.Current.Windows.OfType <ReceiveCommandWindow>().First();
                    window.WindowState = WindowState.Normal;
                    Application.Current.Windows.OfType <ReceiveCommandWindow>().First().ChangeCmd(cmd);
                }
            }
        }
Example #7
0
 public void ChangeCmd(MsgDispatchCommand cmd)
 {
     cmdsLb.SelectedItem = cmd;
     CmdGrid.DataContext = cmd;
 }