Exemplo n.º 1
0
        private List <DeviceRolePermission> GetDeviceRolePermissionFromUI()
        {
            var result   = new List <DeviceRolePermission>();
            var selected = DeviceDtos.FindAll(x => x.IsSelected);

            foreach (var checkboxItem in selected)
            {
                var rolePermission = CurrentDeviceRole.DeviceRolePermissions.FirstOrDefault(x => x.DeviceID == checkboxItem.ID);
                if (rolePermission == null)
                {
                    rolePermission = new DeviceRolePermission()
                    {
                        DeviceID     = checkboxItem.ID,
                        DeviceRoleID = CurrentDeviceRole.DeviceRoleID,
                        Enable       = true,
                        STARTDATE    = DateTime.Now,
                    };
                }

                rolePermission.PermissionAction        = (DevicePermissionAction)SelectedPermissionAction;
                rolePermission.AllowedAccessTimeZoneID = SelectedTimezone.TimeZoneID;

                result.Add(rolePermission);
            }
            return(result);
        }
Exemplo n.º 2
0
        private void SyncData()
        {
            DispatcherHelper.CheckBeginInvokeOnUI(async() =>
            {
                string message = "";

                var controller = await DialogCoordinator.Instance.ShowProgressAsync(this, "同步数据", "同步数据中,请稍等");
                controller.SetIndeterminate();

                await Task.Run(() =>
                {
                    try
                    {
                        DSProxy.ResultTypes resultTypes;
                        string[] messages;

                        if (SyncUserType == SyncUserType.SyncDeviceToUser)
                        {
                            var devices = new[] { SelectedDevice };
                            var users   = SelectedSyncUserDtos.Select(u =>
                            {
                                var userId   = string.IsNullOrWhiteSpace(u.Description) ? 0 : u.Description.ToInt32();
                                var userCode = u.ID.ToString();
                                return(new User()
                                {
                                    UserID = userId, UserCode = userCode, Name = u.DisplayName
                                });
                            });

                            resultTypes = new DSProxy.DeviceServiceClient().SyncSystemUsers(devices.ToArray(), users.ToArray(), out messages);
                        }
                        else
                        {
                            var devices = DeviceDtos.FindAll(d => d.IsSelected).Select(dd => new DeviceController()
                            {
                                DeviceID = dd.ID
                            });
                            var users = SelectedSyncUserDtos.Select(u => new User()
                            {
                                UserID = u.ID, Name = u.DisplayName
                            });

                            resultTypes = new DSProxy.DeviceServiceClient().SyncDeviceUsers(devices.ToArray(), DSProxy.SyncOption.Unknown, users.ToArray(), out messages);
                        }

                        message = MessageHandler.GenerateDeviceMessage(resultTypes, messages, "同步数据成功!", "同步数据失败!");
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex);
                        message = "同步数据失败!";
                    }
                });

                await controller.CloseAsync();
                Messenger.Default.Send(new NotificationMessage(message), Tokens.SyncUserView_ShowNotification);
            });
        }
Exemplo n.º 3
0
        private void SyncData()
        {
            DispatcherHelper.CheckBeginInvokeOnUI(async() =>
            {
                string message = "";

                var controller = await DialogCoordinator.Instance.ShowProgressAsync(this, "同步数据", "同步数据中,请稍等");
                controller.SetIndeterminate();

                await Task.Run(() =>
                {
                    try
                    {
                        var devices = DeviceDtos.FindAll(d => d.IsSelected).Select(dd => new DeviceController()
                        {
                            DeviceID = dd.ID
                        });
                        var departments = SelectedSyncDepartmentDtos.Select(u => new Department()
                        {
                            DepartmentID = u.ID
                        });

                        string[] messages;
                        DSProxy.ResultTypes resultTypes = new DSProxy.DeviceServiceClient().SyncDepartmentUsers(departments.ToArray(), devices.ToArray(), out messages);

                        message = MessageHandler.GenerateDeviceMessage(resultTypes, messages, "同步数据成功!", "同步数据失败!");
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex);
                        message = "同步数据失败!";
                    }
                });

                await controller.CloseAsync();

                SendMessage(message);
            });
        }