private void RestartDevice(Camera camera)
        {
            if (null == camera)
            {
                return;
            }

            MetroUIExtender.Progress("正在重启设备......", "请稍等......", true,
                                     (controller) =>
            {
                controller.Canceled += (ss, ee) =>
                {
                    controller.CloseAsync();
                };
                controller.Closed += (ss, ee) =>
                {
                    if (!controller.IsCanceled)
                    {
                    }
                };
            },
                                     (controller) =>
            {
                var serviceC = new Service.CameraService();
                serviceC.OnRestartDeviceCompleted += () => {
                    controller.CloseAsync();
                };
                serviceC.RestartDevice(camera, (exp) => {
                    controller.SetMessage(exp.Message);
                    controller.SetCancelable(true);
                });
            });
        }
        void Query()
        {
            EnableUI(false);
            var service = new Service.CheckinService();

            service.OnQueryCompleted += (departs) => {
                if (departs != null)
                {
                    this.Dispatcher.BeginInvoke(new Action <CheckinRecord[]>((list) => {
                        ruleList.Clear();
                        foreach (var v in list)
                        {
                            ruleList.Add(new CheckinRecordUI()
                            {
                                Record = v
                            });
                        }
                        EnableUI(true);
                    }), new object[] { departs });
                }
            };
            service.Query(currentQuery, (exp) => {
                this.Dispatcher.BeginInvoke(new Action(() => {
                    EnableUI(true);
                    MetroUIExtender.Alert(exp.Message);
                }), null);
            });
        }
        void Query()
        {
            EnableUI(false);
            var service = new Service.CameraService();

            service.OnQueryCompleted += (departs) => {
                if (departs != null)
                {
                    this.Dispatcher.BeginInvoke(new Action <Camera[]>((list) => {
                        cameraList.Clear();
                        foreach (var v in list)
                        {
                            cameraList.Add(new CameraUI()
                            {
                                Camera = v
                            });
                        }
                        EnableUI(true);
                    }), new object[] { departs });
                }
            };
            service.Query((exp) => {
                this.Dispatcher.BeginInvoke(new Action(() => {
                    EnableUI(true);
                    MetroUIExtender.Alert(exp.Message);
                }), null);
            });
        }
Beispiel #4
0
        void QueryRules()
        {
            var service = new Service.AttendanceRuleService();

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

                        if (sel != null)
                        {
                            cboRule.SelectedItem = sel;
                        }
                        EnableUI(true);
                    }), new object[] { departs });
                }
            };
            service.Query((exp) => {
                EnableUI(true);
                MetroUIExtender.Alert(exp.Message);
            });
        }
 private void OnButtonOKClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var username = textUserName.Text;
         var email    = textEmail.Text;
         var password = textPassword.Password;
         var confirm  = textConfirm.Password;
         var service  = new Service.AccountService();
         service.OnRegisterCompleted += () => {
             this.Dispatcher.BeginInvoke(new Action(() => {
                 if (null != OnClose)
                 {
                     OnClose();
                 }
             }), null);
         };
         service.Register(username, email, password, confirm, (exp) => {
             this.Dispatcher.BeginInvoke(new Action <string>((msg) => {
                 MetroUIExtender.Alert(msg);
             }), new object[] { exp.Message });
         });
     }
     catch (Exception exp)
     {
         MetroUIExtender.Alert(exp.Message);
     }
 }
        void Query()
        {
            EnableUI(false);
            var service = new Service.EmployeeService();

            service.OnQueryCompleted += (departs) => {
                if (departs != null)
                {
                    this.Dispatcher.BeginInvoke(new Action <Employee[]>((list) => {
                        employeeList.Clear();
                        foreach (var v in list)
                        {
                            employeeList.Add(new EmployeeUI()
                            {
                                Employee = v
                            });
                            //employeeList.Add(new EmployeeUI() { Employee = new Employee() { Name = "宫兆新", Position = "主任" } });
                        }
                        EnableUI(true);
                    }), new object[] { departs });
                }
            };
            service.Query((exp) => {
                this.Dispatcher.BeginInvoke(new Action(() => {
                    EnableUI(true);
                    MetroUIExtender.Alert(exp.Message);
                }), null);
            });
        }
Beispiel #7
0
        private void OnButtonOKClick(object sender, RoutedEventArgs e)
        {
            if (current != null)
            {
                //
                try
                {
                    var sel = cboDepart.SelectedItem as DepartmentUI;
                    if (null != sel)
                    {
                        current.Deparment = sel.Department;
                    }

                    var selRule = cboRule.SelectedItem as AttendanceRule;
                    if (null != selRule)
                    {
                        current.AttendanceRule = selRule;
                    }

                    current.Cameras.Clear();
                    foreach (var c in cameras)
                    {
                        if (c.IsChecked)
                        {
                            var r = new EmployeeCameraRelation()
                            {
                                CameraID   = c.Camera.ID,
                                EmployeeID = current.ID,
                            };
                            current.Cameras.Add(r);
                        }
                    }

                    //
                    var service = new Service.EmployeeService();
                    service.OnSaveCompleted += (depart) => {
                        this.Dispatcher.BeginInvoke(new Action(() => {
                            if (null != OnClose)
                            {
                                OnClose();
                            }
                        }), null);
                    };
                    EnableUI(false);
                    service.Save(current, (exp) => {
                        this.Dispatcher.BeginInvoke(new Action <string>((msg) => {
                            EnableUI(true);
                            MetroUIExtender.Alert(msg);
                        }), new object[] { exp.Message });
                    });
                }
                catch (Exception exp)
                {
                    MetroUIExtender.Alert(exp.Message);
                }
            }
        }
Beispiel #8
0
        private async void MenuItem_DeleteNode_Click(object sender, RoutedEventArgs e)
        {
            var ret = await MetroUIExtender.Confirm("确定要删除这个节点?");

            if (ret == MahApps.Metro.Controls.Dialogs.MessageDialogResult.Affirmative)
            {
                //删除
            }
        }
        void Query()
        {
            EnableUI(false);
            var service = new Service.AttendanceRuleService();

            service.OnQuerySpecialCompleted += (departs) => {
                if (departs != null)
                {
                    this.Dispatcher.BeginInvoke(new Action <SpecialAttendanceRule[]>((list) => {
                        specialRuleList.Clear();
                        foreach (var v in list)
                        {
                            specialRuleList.Add(new SpecialAttendanceRuleUI()
                            {
                                SpecialAttendanceRule = v
                            });
                        }
                        EnableUI(true);
                    }), new object[] { departs });
                }
            };
            service.OnQueryCompleted += (departs) => {
                if (departs != null)
                {
                    this.Dispatcher.BeginInvoke(new Action <AttendanceRule[]>((list) => {
                        ruleList.Clear();
                        foreach (var v in list)
                        {
                            ruleList.Add(new AttendanceRuleUI()
                            {
                                AttendanceRule = v
                            });
                        }
                        EnableUI(true);
                    }), new object[] { departs });
                }
            };
            service.Query((exp) => {
                this.Dispatcher.BeginInvoke(new Action(() => {
                    EnableUI(true);
                    MetroUIExtender.Alert(exp.Message);
                }), null);
            });
            service.QuerySpecial((exp) => {
                this.Dispatcher.BeginInvoke(new Action(() => {
                    EnableUI(true);
                    MetroUIExtender.Alert(exp.Message);
                }), null);
            });
        }
Beispiel #10
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 #11
0
        void QueryCameras()
        {
            var service = new Service.CameraService();

            service.OnQueryCompleted += (departs) => {
                if (departs != null)
                {
                    this.Dispatcher.BeginInvoke(new Action <Camera[]>((list) => {
                        cameras.Clear();
                        foreach (var v in list)
                        {
                            var c = new CameraUI()
                            {
                                Camera = v
                            };
                            //如果在列表中,选中
                            if (current != null)
                            {
                                bool bExists = false;

                                foreach (var l in current.Cameras)
                                {
                                    if (l.CameraID == v.ID)
                                    {
                                        bExists = true;
                                        break;
                                    }
                                }

                                if (bExists)
                                {
                                    c.IsChecked = true;
                                }
                            }
                            cameras.Add(c);
                        }

                        EnableUI(true);
                    }), new object[] { departs });
                }
            };
            service.Query((exp) => {
                EnableUI(true);
                MetroUIExtender.Alert(exp.Message);
            });
        }
        private async void OnItemButtonDeleteClick(object sender, RoutedEventArgs e)
        {
            var btn    = sender as Button;
            var camera = btn.DataContext as CameraUI;

            if (null == camera)
            {
                return;
            }

            var ret = await MetroUIExtender.Confirm("您确定要删除该设备吗?");

            if (ret == MahApps.Metro.Controls.Dialogs.MessageDialogResult.Affirmative)
            {
                //删除
                cameraList.Remove(camera);
            }
        }
 private void OnButtonOKClick(object sender, RoutedEventArgs e)
 {
     if (current != null)
     {
         var service = new Service.DepartmentService();
         service.OnSaveCompleted += (depart) => {
             this.Dispatcher.BeginInvoke(new Action(() => {
                 if (null != OnClose)
                 {
                     OnClose();
                 }
             }), null);
         };
         service.Save(current, (exp) => {
             this.Dispatcher.BeginInvoke(new Action <string>((msg) => {
                 MetroUIExtender.Alert(msg);
             }), new object[] { exp.Message });
         });
     }
 }
        private async void OnCameraDelete(Camera obj)
        {
            var ret = await MetroUIExtender.Confirm("您确定要删除该设备吗?");

            if (ret == MahApps.Metro.Controls.Dialogs.MessageDialogResult.Affirmative)
            {
                //删除
                CameraUI camera = null;
                foreach (var v in cameraList)
                {
                    if (v.Camera.ID == obj.ID)
                    {
                        camera = v;
                        break;
                    }
                }
                if (null != camera)
                {
                    cameraList.Remove(camera);
                }
            }
        }
Beispiel #15
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);
            });
        }
Beispiel #16
0
        private void UploadFile(string filepath, int flag)
        {
            var    fi       = new System.IO.FileInfo(filepath);
            string filename = fi.Name;

            MetroUIExtender.Progress("正在上传文件......", "请稍等......", true,
                                     (controller) =>
            {
                controller.Canceled += (ss, ee) =>
                {
                    controller.CloseAsync();
                };
                controller.Closed += (ss, ee) =>
                {
                    if (!controller.IsCanceled)
                    {
                        //显示图片
                        var fs      = System.IO.File.OpenRead(filepath);
                        var decoder = BitmapDecoder.Create(fs, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
                        switch (flag)
                        {
                        case 1:
                            imageFirst.Source = decoder.Frames[0];
                            break;

                        case 2:
                            imageSecond.Source = decoder.Frames[0];
                            break;

                        case 3:
                            imageThird.Source = decoder.Frames[0];
                            break;
                        }
                    }
                };
            },
                                     (controller) =>
            {
                var data    = System.IO.File.ReadAllBytes(filepath);
                var service = new Service.PhotoImageService();
                service.OnUploadCompleted += (file) =>
                {
                    if (null != current)
                    {
                        switch (flag)
                        {
                        case 1:
                            current.FirstPhoto = file;
                            break;

                        case 2:
                            current.SecondPhoto = file;
                            break;

                        case 3:
                            current.ThirdPhoto = file;
                            break;
                        }
                    }
                    controller.CloseAsync();
                };
                service.Upload(data, filename, (exp) =>
                {
                    controller.SetMessage(exp.Message);
                    controller.SetCancelable(true);
                });
            });
        }
        private void ChangeLogo(string filepath, Camera camera)
        {
            if (null == camera)
            {
                return;
            }

            var    fi       = new System.IO.FileInfo(filepath);
            string filename = fi.Name;

            MetroUIExtender.Progress("正在上传文件......", "请稍等......", true,
                                     (controller) =>
            {
                controller.Canceled += (ss, ee) =>
                {
                    controller.CloseAsync();
                };
                controller.Closed += (ss, ee) =>
                {
                    if (!controller.IsCanceled)
                    {
                        CameraUI ui = null;
                        foreach (var v in cameraList)
                        {
                            if (v.Camera.ID == camera.ID)
                            {
                                ui = v;
                                break;
                            }
                        }
                        if (ui != null)
                        {
                            ui.ChangeLogo(camera.Logo);
                        }
                    }
                };
            },
                                     (controller) =>
            {
                var data    = System.IO.File.ReadAllBytes(filepath);
                var service = new Service.PhotoImageService();
                service.OnUploadCompleted += (file) =>
                {
                    //在设备中更改数据
                    if (file != null)
                    {
                        camera.Logo                     = file;
                        camera.PhotoImageID             = file.ID;
                        var serviceC                    = new Service.CameraService();
                        serviceC.OnChangeLogoCompleted += () => {
                            controller.CloseAsync();
                        };
                        serviceC.ChangeLogo(camera, (exp) => {
                            controller.SetMessage(exp.Message);
                            controller.SetCancelable(true);
                        });
                    }
                    else
                    {
                        controller.CloseAsync();
                    }
                };
                service.Upload(data, filename, (exp) =>
                {
                    controller.SetMessage(exp.Message);
                    controller.SetCancelable(true);
                });
            });
        }