コード例 #1
0
ファイル: PlanListViewModel.cs プロジェクト: fflorat/IRAP
        private void Load(Entity.PlanFilter filter)
        {
            //this.IsShowTitleList = true;
            this.PlanList = PlanMGMT.BLL.PlanBLL.Instance.GetPlanList(filter.GenerateFilter(), "InCharge,Status,PlanStart");
            if (this.PlanList == null)
            {
                return;
            }

            if (this.PlanList.Count >= 0)
            {
                this.PlanMsg = "共有 " + this.PlanList.Count + " 条记录,您可点的左侧按钮改变显示模式...";
                if (PlanList.Count > 0)
                {
                    List <string>           uers      = PlanList.Select(x => x.InCharge).Distinct().ToList <string>();
                    List <Model.PlanByName> incharges = new List <Model.PlanByName>();
                    foreach (var u in uers)
                    {
                        incharges.Add(new Model.PlanByName(u, LoginBLL.Instance.GetUserNameByCode(u)));
                    }
                    InChargeList = incharges;
                }
                else
                {
                    InChargeList = null;
                }
            }
        }
コード例 #2
0
ファイル: PlanListViewModel.cs プロジェクト: fflorat/IRAP
        public PlanListViewModel()
        {
            if (!IsInDesignMode)
            {
                Load(filter);
                this._plan       = new PlanMGMT.Model.Plan();
                this.LoadCommand = new ViewModelCommand((Object parameter) =>
                {
                    if (parameter == null)
                    {
                        Load(filter);
                    }
                    else
                    {
                        filter = (Entity.PlanFilter)parameter;
                        Load(filter);
                    }
                });

                #region 温馨提示
                string msg = "您有:" + PlanBLL.Instance.RunningTaskCnt() + "条正在进行中任务,正在为您自动计时\r\n";
                msg += " 您有:" + PlanBLL.Instance.UnStartTaskCnt() + "条未开始任务\r\n";
                msg += " 您有:" + PlanBLL.Instance.StopTaskCnt() + "条暂停中任务\r\n";
                msg += " 您有:" + PlanBLL.Instance.PastTaskCnt() + "条任务已延期\r\n";
                Helper.Instance.ShowPupUp("任务提示!", null, msg);
                #endregion

                this.SaveCommand = new ViewModelCommand((Object parameter) => Save());
                this.AddCommand  = new ViewModelCommand((Object parameter) =>
                {
                    View.PlanEdit edit = new View.PlanEdit();
                    edit.ID            = 0;
                    edit.Closed       += new EventHandler(Edit_Closed);//注册关闭事件
                    edit.Show();
                });
                this.ContextMenuCommand = new ViewModelCommand((Object n) => { TaskListContextClick(n.ToString()); });
                this.TimerCommand       = new ViewModelCommand((Object parameter) =>
                {
                    PlanModel = parameter == null ? null : parameter as Model.Plan;
                    if (this.PlanModel == null || PlanModel.PlanID == 0)
                    {
                        Helper.Instance.AlertWarning("没有任何选中项!");
                        return;
                    }
                    if (PlanModel.Status == 0)
                    {
                        Helper.Instance.AlertConfirm("不可撤销操作!", "是否开始任务?", () =>
                        {
                            try
                            {
                                PlanBLL.Instance.StartPlan(PlanModel.PlanID);
                            }
                            catch (Exception e)
                            {
                                Helper.Instance.AlertError("操作失败:" + e.Message);
                            }
                        });
                    }
                    else if (PlanModel.Status == 1)
                    {
                        Helper.Instance.AlertChoice("不可撤销操作!", "请选择要执行的操作?",
                                                    () =>
                        {
                            try
                            {
                                PlanBLL.Instance.StopPlan(PlanModel.PlanID);
                            }
                            catch (Exception e)
                            {
                                Helper.Instance.AlertError("操作失败:" + e.Message);
                            }
                        },
                                                    () =>
                        {
                            try
                            {
                                PlanBLL.Instance.CompeletePlan(PlanModel.PlanID);
                            }
                            catch (Exception e)
                            {
                                Helper.Instance.AlertError("操作失败:" + e.Message);
                            }
                        });
                    }
                    else if (PlanModel.Status == 2)
                    {
                        Helper.Instance.AlertWarning("您无法操作已经完成的任务");
                    }
                    else if (PlanModel.Status == 3)
                    {
                        Helper.Instance.AlertConfirm(null, "继续开始您的任务?", () =>
                        {
                            try
                            {
                                PlanBLL.Instance.ContinuePlan(PlanModel.PlanID);
                            }
                            catch (Exception e)
                            {
                                Helper.Instance.AlertError("操作失败:" + e.Message);
                            }
                        });
                    }
                    Load(filter);
                });
            }
            this.TaskListItemCommand = new ViewModelCommand((Object m) => TaskListItemClick(m.ToString()));
            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Interval = 60000;//1分钟执行一次
            timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Task);
            timer.Start();
        }