Beispiel #1
0
        void Query()
        {
            EnableUI(false);
            var service = new Service.DepartmentService();

            service.OnQueryCompleted += (departs) => {
                if (departs != null)
                {
                    this.Dispatcher.BeginInvoke(new Action <Department[]>((list) => {
                        departments.Clear();
                        List <DepartmentUI> todo = new List <DepartmentUI>();
                        foreach (var v in list)
                        {
                            var node = new DepartmentUI()
                            {
                                Department = v
                            };
                            if (v.ParentDepartment == null)
                            {
                                //
                                departments.Add(node);
                            }
                            else
                            {
                                bool bFind = false;
                                foreach (var item in departments)
                                {
                                    var ret = item.Enumerate(v.ParentDepartment.ID);
                                    if (ret != null)
                                    {
                                        ret.Add(node);
                                        bFind = true;
                                        break;
                                    }
                                }

                                if (!bFind)
                                {
                                    todo.Add(node);
                                }
                            }
                        }
                    }), new object[] { departs });
                }
            };
            service.Query((exp) => {
                MetroUIExtender.Alert(exp.Message);
            });
        }
Beispiel #2
0
        void QueryDepartment()
        {
            EnableUI(false);
            var service = new Service.DepartmentService();

            service.OnQueryCompleted += (departs) => {
                if (departs != null)
                {
                    this.Dispatcher.BeginInvoke(new Action <Department[]>((list) => {
                        departments.Clear();
                        DepartmentUI sel = null;
                        foreach (var v in list)
                        {
                            var node = new DepartmentUI()
                            {
                                Department = v
                            };
                            if (current != null && current.Deparment != null && v.ID == current.Deparment.ID)
                            {
                                sel = node;
                            }
                            departments.Add(node);
                        }

                        if (sel != null)
                        {
                            cboDepart.SelectedItem = sel;
                        }
                        EnableUI(true);
                    }), new object[] { departs });
                }
            };
            service.Query((exp) => {
                EnableUI(true);
                MetroUIExtender.Alert(exp.Message);
            });
        }