示例#1
0
        private void BtnUserAddClick(object sender, RoutedEventArgs e)
        {
            var dialog = new UserCustomizedNewWindow {
                Owner = this
            };

            Log.Debug("BtnUserAddClick__UserCustomizedNewWindow.ShowDialog BEFORE");
            if (dialog.ShowDialog() != true)
            {
                return;
            }

            Log.Debug("BtnUserAddClick__UserCustomizedNewWindow.ShowDialog AFTER");

            if (IsUserExisted(dialog.ExtensionCurrent))
            {
                Log.Debug("BtnUserAddClick__MessageWindow.ShowDialog BEFORE");

                MessageWindow msg = new MessageWindow(
                    Properties.Resources.IDS_ERROR_WINDOW_TITLE,
                    Properties.Resources.IDS_ERR_EXT_EXIST,
                    MessageWindow.ButtonListType.ButtonOk,
                    MessageWindow.IconType.IconError)
                {
                    Owner = this
                };
                msg.ShowDialog();

                Log.Debug("BtnUserAddClick__MessageWindow.ShowDialog AFTER");

                return;
            }

            if (_system.UserInfo.CustomizedUsersAdd(dialog.UserName, dialog.ExtensionCurrent))
            {
                IsModified = true;
                UpdateUsers();
            }
        }
示例#2
0
        private void BtnUserEditClick(object sender, RoutedEventArgs e)
        {
            User user = lstUsers.SelectedItem as User;

            if (user == null)
            {
                return;
            }

            var dialog = new UserCustomizedNewWindow
            {
                Owner             = this,
                UserName          = user.LastName,
                ExtensionPrevious = user.Number,
                ExtensionCurrent  = user.Number
            };

            Log.Debug("BtnUserEditClick__UserCustomizedNewWindow.ShowDialog BEFORE");

            if (dialog.ShowDialog() != true)
            {
                return;
            }

            Log.Debug("BtnUserEditClick__UserCustomizedNewWindow.ShowDialog AFTER");

            if (dialog.IsExtensionChanged && IsUserExisted(dialog.ExtensionCurrent))
            {
                Log.Debug("BtnUserEditClick__MessageWindow.ShowDialog BEFORE");

                MessageWindow msg = new MessageWindow(
                    Properties.Resources.IDS_ERROR_WINDOW_TITLE,
                    Properties.Resources.IDS_ERR_EXT_EXIST,
                    MessageWindow.ButtonListType.ButtonOk,
                    MessageWindow.IconType.IconError)
                {
                    Owner = this
                };
                msg.ShowDialog();

                Log.Debug("BtnUserEditClick__MessageWindow.ShowDialog AFTER");

                return;
            }

            user.LastName = dialog.UserName;
            user.Number   = dialog.ExtensionCurrent;

            //先尝试对混编组中用户进行修改
            try
            {
                foreach (var mixedGroup in _system.UserInfo.MixedGroups)
                {
                    if (mixedGroup.GroupUsers.Contains(user))
                    {
                        string[] tempUsers = new string[mixedGroup.GroupUsers.Count];
                        foreach (var userMixed in mixedGroup.GroupUsers)
                        {
                            tempUsers[mixedGroup.GroupUsers.IndexOf(userMixed)] = userMixed.Number;
                        }

                        try
                        {
                            _system.Proxy.SaveMixedGroupMember(mixedGroup.Id, tempUsers);
                        }
                        catch (Exception ex)
                        {
                            Log.Debug("BtnUserEditClick__MessageBox.Show ex BEFORE");
                            MessageBox.Show(String.Format("对应混编组:{0}信息同步失败!", mixedGroup.Name));
                            Log.Debug("BtnUserEditClick__MessageBox.Show ex AFTER");
                            return;
                        }
                    }
                }
            }
            catch (Exception)
            {
                return;
            }

            IsModified = true;
        }