public override void RelayMethod(object obj)
        {
            string command = obj.ToString();

            //  Do:应用
            if (command == "Init")
            {
            }
            //  Do:登录成功触发
            else if (command == "LoginModuleSuccessed")
            {
                //  Message:检查是否可以打印
                this.CheckEnblePrint();


                SigningDetailJsonModel model = LoginInfo.Data as SigningDetailJsonModel;

                this.Controls = PrintService.Instance.GetSignPages(LoginInfo.Data as SigningDetailJsonModel);
            }

            if (obj is TPageControl)
            {
                TPageControl control = obj as TPageControl;

                SigningDetailJsonModel entity = LoginInfo.Data as SigningDetailJsonModel;

                string err;


                bool enble = DataManager.DatasManager.PrintEnable(entity.PrintRecord, ModuleManager.ModuleConfig[LoginInfo.ModuleName], out err);

                if (enble)
                {
                    MessageSingleControl.Show("正在打印,请稍等...", 10);

                    control.Print();

                    DataManager.DatasManager.UpdateReportPrintMark(entity.ID, ModuleManager.ModuleConfig[LoginInfo.ModuleName], out err);

                    if (!string.IsNullOrEmpty(err))
                    {
                        MessageSingleControl.Show(err);
                        return;
                    }
                }
                else
                {
                    MessageSingleControl.Show(err);
                    return;
                }
            }
        }
        public override void RelayMethod(object obj)
        {
            string command = obj.ToString();

            //  Do:应用
            if (command == "Init")
            {
            }
            //  Do:取消
            else if (command == "LoginModuleSuccessed")
            {
                //  Message:检查是否可以打印
                this.CheckEnblePrint();

                HEWArchivesDetailDataEntity entity = LoginInfo.Data as HEWArchivesDetailDataEntity;
                this.Controls = PrintService.Instance.GetArchivesPages(entity.Person, entity.ProductInformation.OrgName);
            }

            if (obj is TPageControl)
            {
                TPageControl control = obj as TPageControl;

                HEWArchivesDetailDataEntity entity = LoginInfo.Data as HEWArchivesDetailDataEntity;

                string err;

                bool enble = DataManager.DatasManager.PrintEnable(entity.PrintRecord, ReportTypeEnum.Report_Detail_Archives, out err);

                if (enble)
                {
                    MessageSingleControl.Show("正在打印,请稍等...", 10);

                    control.Print();

                    DataManager.DatasManager.UpdateReportPrintMark(entity.Person.ID, ReportTypeEnum.Report_Detail_Archives, out err);

                    if (!string.IsNullOrEmpty(err))
                    {
                        MessageSingleControl.Show(err);
                        return;
                    }
                }
                else
                {
                    MessageSingleControl.Show(err);
                    return;
                }
            }
        }
Example #3
0
        public MainWindow()
        {
            InitializeComponent();

            this.DataContext = _vm;

            MessageSingleControl.Instance  = this.control_message;
            WaittingSingleControl.Instance = this.control_waitting;

#if DEBUG
            if (ApplicationDomain.Instance.IsWin7())
            {
                this.Width  = 768;
                this.Height = 1024;
            }
            else
            {
                this.Width  = 1280;
                this.Height = 1024;
            }


            this.WindowState = WindowState.Normal;
#endif

            Action <MessageResult> result = l =>
            {
                if (l == MessageResult.TimeOver)
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        //this.control_module.BeginLogin = false;
                        this.control_config.IsShow = false;
                    });
                }
            };

            ServiceManager.DataService.OnCheckCount = () =>
            {
                //if (this.control_module.IsShow || this.control_config.IsShow)
                if (this.control_config.IsShow)
                {
                    MessageSingleControl.ShowWithCancel("操作超时,将自动退出!", 5, result);
                }
            };

            ServiceManager.DataService.StartMonitor();
        }
        public void RelayMethod(object obj)
        {
            string command = obj.ToString();

            //  Do:应用
            if (command == "Test")
            {
                //var collection = ObserveModeleDomain.Instance.GetChildObserveModel();

                //ObserveItemControl itemcontrol = null;

                //ObservableCollection<ChildObserveModel> temp = new ObservableCollection<ChildObserveModel>();

                //for (int i = 0; i < collection.Count; i++)
                //{
                //    var c = collection[i];

                //    if (i % 20 == 0)
                //    {
                //        itemcontrol = new ObserveItemControl();
                //        temp = new ObservableCollection<ChildObserveModel>();
                //        itemcontrol.ChildObserves = temp;
                //        this.Controls.Add(itemcontrol);
                //    }

                //    temp.Add(c);
                //}
            }
            //  Do:取消
            else if (command == "Loaded")
            {
                Action <string, string> scanEventAction = (o, n) =>
                {
                    if (o == null && !string.IsNullOrEmpty(n))
                    {
                        MessageSingleControl.ShowWithError("未识别卡片信息", "请检查卡片是否正确并放置在指定扫描区");
                        ServiceManager.DataService.LogInfo(o);
                        ServiceManager.DataService.LogInfo(n);
                        return;
                    }

                    Action <string, string, string> action = (l, k, m) =>
                    {
                        MessageSingleControl.ShowWithSuccess(k, m);
                        ServiceManager.DataService.LogInfo(l, k, m);
                    };

                    ObserveModeleDomain.Instance.PostGetChildInfo(o, action);
                };

                ObserveModeleDomain.Instance.BegionGetChildID(scanEventAction);
            }

            else if (command == "Init")
            {
                //星期二 2018 - 08 - 01 15:13
                System.Timers.Timer time = new System.Timers.Timer();

                Action action = () =>
                {
                    this.Date = string.Format(("星期{0} {1}"), "日一二三四五六".Substring((int)DateTime.Now.DayOfWeek, 1), DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
                };

                action();

                time.Elapsed += (l, k) =>
                {
                    action();
                };

                time.Interval = 1000 * 30;

                time.Start();


                //定时刷新
                Action action1 = () =>
                {
                    //  Do:刷新统计信息
                    string err;

                    var result = ObserveModeleDomain.Instance.PostGetTotal(out err);

                    if (result == null)
                    {
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            if (!MessageSingleControl.Instance.IsShow)
                            {
                                MessageSingleControl.Show(err);
                            }
                        });
                        return;
                    }

                    this.Step1 = result.Item1;
                    this.Step2 = result.Item2;
                    this.Step3 = result.Item3;
                    this.Step4 = result.Item4;

                    //  Do:刷新列表信息
                    var collection = ObserveModeleDomain.Instance.GetChildObserveModel(out err);

                    if (collection == null)
                    {
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            if (!MessageSingleControl.Instance.IsShow)
                            {
                                MessageSingleControl.Show(err);
                            }
                        });

                        return;
                    }

                    this.Controls.Clear();

                    ObserveItemControl itemcontrol = null;

                    ObservableCollection <ChildObserveModel> temp = new ObservableCollection <ChildObserveModel>();

                    List <UserControl> controls = new List <UserControl>();


                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        for (int i = 0; i < collection.Count; i++)
                        {
                            var c = collection[i];

                            if (i % 20 == 0)
                            {
                                itemcontrol = new ObserveItemControl();
                                temp        = new ObservableCollection <ChildObserveModel>();
                                itemcontrol.ChildObserves = temp;
                                controls.Add(itemcontrol);
                            }

                            temp.Add(c);
                        }

                        this.Controls = controls;
                    });
                };


                Task.Run(() =>
                {
                    while (true)
                    {
                        Thread.Sleep(3000);
                        action1();
                    }
                });
            }
        }
Example #5
0
        public void RelayMethod(object obj)
        {
            string command = obj.ToString();

            //  Do:应用
            if (command == "Test")
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    string err;

                    bool result = GetNumberModuleDomain.Instance.Print(this.PrintAddress, "B045", "张晓小效", this.PrintDate, out err);

                    if (result)
                    {
                        ServiceManager.DataService.LogInfo("打印成功张晓小效");
                    }
                    else
                    {
                        MessageSingleControl.ShowWithSuccess("打印错误!", err);
                    }
                });
            }
            //  Do:取消
            else if (command == "Loaded")
            {
                RelayMethod("Init");

                Action <string, string> scanEventAction = (o, n) =>
                {
                    if (o == null && !string.IsNullOrEmpty(n))
                    {
                        MessageSingleControl.ShowWithError("未识别卡片信息", "请检查卡片是否正确并放置在指定扫描区");
                        ServiceManager.DataService.LogInfo(o);
                        ServiceManager.DataService.LogInfo(n);
                        return;
                    }

                    Action <RegisterEntity, string, string> action = (l, k, m) =>
                    {
                        if (l == null)
                        {
                            return;
                        }

                        MessageSingleControl.ShowWithSuccess(k, m);

                        ServiceManager.DataService.LogInfo(l.code, k, m);

                        if (l.code != "200")
                        {
                            return;
                        }

                        if (GetNumberModuleDomain.Instance.GetConfigPrintLimit() != "1")
                        {
                            return;
                        }

                        ServiceManager.DataService.LogInfo("开始打印" + k);

                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            string err;

                            bool result = GetNumberModuleDomain.Instance.Print(this.PrintAddress, l.rowNum, l.hzxm, this.PrintDate, out err);

                            if (result)
                            {
                                ServiceManager.DataService.LogInfo("打印成功!" + l.hzxm);
                            }
                            else
                            {
                                MessageSingleControl.ShowWithSuccess("打印错误!", err);
                            }
                        });
                    };

                    //mykh=undefined&type=1&no=b1

                    string type     = "0";
                    string no       = null;
                    string code     = o.Trim();
                    string prepayid = null;

                    ServiceManager.DataService.LogInfo(o);

                    if (o.Trim().StartsWith("mykh"))
                    {
                        var result = o.Trim().Split('=', '&');

                        code     = result[0];
                        type     = result[1];
                        prepayid = result[2];
                        no       = result[3];
                    }

                    GetNumberModuleDomain.Instance.PostGetChildInfo(code, type, no, prepayid, action);
                };

                GetNumberModuleDomain.Instance.BegionGetChildID(scanEventAction);
            }

            else if (command == "Init")
            {
                //星期二 2018 - 08 - 01 15:13
                System.Timers.Timer time = new System.Timers.Timer();

                Action action = () =>
                {
                    this.Date = string.Format(("星期{0} {1}"), "日一二三四五六".Substring((int)DateTime.Now.DayOfWeek, 1), DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
                };

                action();

                time.Elapsed += (l, k) =>
                {
                    action();
                };

                time.Interval = 1000 * 30;

                time.Start();


                this.PrintAddress = GetNumberModuleDomain.Instance.GetConfigAddress();

                this.PrintDate = DateTime.Now.ToString("yyyy-MM-dd");
            }
        }
        public void RelayMethod(object obj)
        {
            string command = obj.ToString();

            //  Do:应用
            if (command == "Sumit")
            {
                //  Do:保存配置
                GeneralControlDomain.Instance.SetConfigPrintLimit(this.Config.PrintLimit);
                GeneralControlDomain.Instance.SetConfigStartIndex(this.Config.DefaultIndex);

                //if (!result)
                //{
                //    MessageSingleControl.Show(err);
                //    return;
                //}

                MessageSingleControl.Show("保存成功!");

                this.IsShow = false;
            }

            //  Do:取消
            else if (command == "PasswordLoginClick")
            {
                if (this.PassWord.ToLower() == "tty123")
                {
                    //  Do:显示设置、开机、关机页面
                    this.IsShowConfigMessage = true;

                    //  Do:加载配置
                    this.Config.PrintLimit   = GeneralControlDomain.Instance.GetConfigPrintLimit();
                    this.Config.DefaultIndex = GeneralControlDomain.Instance.GetConfigStartIndex();

                    this.IsShowPassWord = false;
                    this.PassWord       = "";
                }
                else
                {
                    MessageSingleControl.Show("密码错误,请重新输入!");
                    this.PassWord = "";
                }
            }


            else if (command == "PassWordGotFocus")
            {
                GeneralControlDomain.Instance.ShowKeyBoard();
            }

            else if (command == "SetDownClicked")
            {
                Action <MessageResult> Action = l =>
                {
                    if (l == MessageResult.Cancel)
                    {
                    }
                    else if (l == MessageResult.Sumit)
                    {
                        ServiceManager.ToolService.PowerOff();
                    }
                    else
                    {
                    }
                };
                MessageSingleControl.ShowWithCancelAndSumit("确定要关闭计算机?", -9, Action);
            }

            else if (command == "ShutDownAppClicked")
            {
                ServiceManager.ToolService.ShutDown();
            }
        }
        public override void RelayMethod(object obj)
        {
            string command = obj.ToString();

            //  Do:应用
            if (command == "Init")
            {
                //  Message:答题列表

                string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config", "Config.xml");

                if (!File.Exists(configPath))
                {
                    DataManager.DatasManager.Info("配置文件不存在!" + configPath);
                    return;
                }

                XmlTools.Load(configPath);

                List <UserControl> cs = new List <UserControl>();


                var vm = QuetionFactory.Instance.Create();

                int count = vm.Models.Count % 2 == 0 ? vm.Models.Count / 2 : vm.Models.Count / 2 + 1;


                QuetionItemControl control = null;

                for (int i = 0; i < vm.Models.Count; i++)
                {
                    UserControl uc = new UserControl();

                    Button btn = new Button();

                    btn.Content = i;

                    uc.Content = btn;

                    if (i % 2 == 0)
                    {
                        control       = new QuetionItemControl();
                        control.Item1 = vm.Models[i];
                        cs.Add(control);
                    }
                    else
                    {
                        control.Item2 = vm.Models[i];
                    }
                }

                this.QustionList = cs;

#if DEBUG
                //Random r = new Random();

                //foreach (var item in this.QustionList)
                //{
                //    QuetionItemControl quetion = item as QuetionItemControl;

                //    if (quetion.Item1 == null) continue;

                //    quetion.Item1.Collection[r.Next(4)].IsChecked = true;

                //    if (quetion.Item2 == null) continue;

                //    quetion.Item2.Collection[r.Next(4)].IsChecked = true;
                //}
#endif
            }

            //  Do:登录成功触发
            else if (command == "LoginModuleSuccessed")
            {
                //  Message:检查是否可以打印
                this.CheckEnblePrint();


                TCMAndArchivesJsonEntity entity = this.LoginInfo.Data as TCMAndArchivesJsonEntity;

                //  ToDo:测试用
                //entity.TCM = null;

                //  Do:没查询到数据
                if (entity == null || entity.TCM == null)
                {
                    Action <MessageResult> Action = l =>
                    {
                        if (l == MessageResult.Cancel)
                        {
                            //this.ShowQ = true;

                            this.IsLogOffModule = true;
                        }
                        else if (l == MessageResult.Sumit)
                        {
                            this.ShowQ = true;
                        }
                        else
                        {
                            //this.ShowQ = true;
                        }
                    };
                    MessageSingleControl.ShowWithCancelAndSumit("无辨识报告,请进行评估", -9, Action);

                    return;
                }

                this.ShowQ = false;

                //  Message:报表列表
                var result = this.Controls = PrintService.Instance.GetPhysicalPages(entity);
            }

            //  Do:取消
            else if (command == "Button_Save")
            {
                List <string> unCheck = new List <string>();

                foreach (var item in this.QustionList)
                {
                    QuetionItemControl quetion = item as QuetionItemControl;

                    if (quetion.Item1 == null)
                    {
                        continue;
                    }

                    var result = quetion.Item1.Collection.ToList().Exists(l => l.IsChecked);

                    if (!result)
                    {
                        unCheck.Add(quetion.Item1.Index);
                    }

                    if (quetion.Item2 == null)
                    {
                        continue;
                    }

                    result = quetion.Item2.Collection.ToList().Exists(l => l.IsChecked);

                    if (!result)
                    {
                        unCheck.Add(quetion.Item2.Index);
                    }
                }

                Debug.WriteLine("Button_Save");

                if (unCheck.Count > 0)
                {
                    List <string> collection1 = new List <string>();

                    if (unCheck.Count > 7)
                    {
                        collection1.AddRange(unCheck.TakeFromTo(0, 5));
                    }
                    else
                    {
                        collection1.AddRange(unCheck);
                    }

                    Action <MessageResult> ResultAction = l =>
                    {
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            this.PageSelect = collection1[0].ToInt() % 2 == 1? ((int)(collection1[0].ToInt() / 2) + 1):(int)(collection1[0].ToInt() / 2);
                        });
                    };

                    MessageSingleControl.Show("请回答下列问题..." + Environment.NewLine + collection1.Aggregate((l, k) => l + "、 " + k), 3, ResultAction);
                    return;
                }

                //  ToDo:上传
                TCMAndArchivesJsonEntity last = this.LoginInfo.Data as TCMAndArchivesJsonEntity;

                TCMDetailDataEntity entity = new TCMDetailDataEntity();

                entity.ItemDO = new TCMConstitutionItem();

                entity.Tcm = new TCM();

                entity.Tcm.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                List <string> collection = new List <string>();

                foreach (var item in this.QustionList)
                {
                    QuetionItemControl quetion = item as QuetionItemControl;

                    if (quetion.Item1 == null)
                    {
                        continue;
                    }

                    var result = quetion.Item1.Collection.ToList().Find(l => l.IsChecked);

                    collection.Add(result.Value.ToString());

                    if (quetion.Item2 == null)
                    {
                        continue;
                    }

                    result = quetion.Item2.Collection.ToList().Find(l => l.IsChecked);

                    collection.Add(result.Value.ToString());
                }

                entity.Tcm.TZBS = collection.Aggregate((l, k) => l + k);

                Action action = () =>
                {
                    string err;

                    last.TCM = entity;

                    last = DataManager.DatasManager.TCMQualityDiagnosis(last);

                    bool r = DataManager.DatasManager.AddTCMReport(last, out err);

                    if (!r)
                    {
                        MessageSingleControl.Show(err);
                        return;
                    }

                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        this.RelayMethod("LoginModuleSuccessed");
                    });


                    this.ShowQ = false;
                };

                WaittingSingleControl.Show("正在保存,请等待...", action);
            }

            else if (command == "ReWork")
            {
                //  Message:清理數據
                foreach (var item in this.QustionList)
                {
                    QuetionItemControl quetion = item as QuetionItemControl;

                    if (quetion.Item1 == null)
                    {
                        continue;
                    }

                    quetion.Item1.Collection.ToList().ForEach(l => l.IsChecked = false);

                    if (quetion.Item2 == null)
                    {
                        continue;
                    }

                    quetion.Item2.Collection.ToList().ForEach(l => l.IsChecked = false);
                }

                this.PageSelect = 1;
            }


            if (obj is TPageControl)
            {
                TPageControl control = obj as TPageControl;

                TCMAndArchivesJsonEntity entity = LoginInfo.Data as TCMAndArchivesJsonEntity;

                string err;


                bool enble = DataManager.DatasManager.PrintEnable(entity.PrintRecord, ModuleManager.ModuleConfig[LoginInfo.ModuleName], out err);

                if (enble)
                {
                    MessageSingleControl.Show("正在打印,请稍等...", 10);

                    control.Print();

                    DataManager.DatasManager.UpdateReportPrintMark(entity.TCM.Tcm.ID, ModuleManager.ModuleConfig[LoginInfo.ModuleName], out err);

                    if (!string.IsNullOrEmpty(err))
                    {
                        MessageSingleControl.Show(err);
                        return;
                    }
                }
                else
                {
                    MessageSingleControl.Show(err);
                    return;
                }
            }


            ////  Do:取消
            //else if (command == "Qutionlist_GoBack")
            //{
            //    //this.IsShowquetion = true;
            //    this.ShowQ = false;

            //}
        }