예제 #1
0
        private void btnPrivateGroupAdd_Click(object sender, RoutedEventArgs e)
        {
            GroupCreationWindow dialog = new GroupCreationWindow();

            dialog.Owner = this;

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

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

            if (_system.UserInfo.GroupGet(dialog.GroupName) != null)
            {
                GroupNameExists();
                return;
            }

            Group group = new Group();

            group.Id           = -1;
            group.Name         = dialog.GroupName;
            group.GroupType    = Group.Type.Private;
            group.IsPendingNew = true;

            try
            {
                int?groupId = _system.Proxy.CreatePrivateGroup(group.Name, _system.LocalUser.Id);
                if (groupId == null)
                {
                    GroupInfoSaveFailed();
                    return;
                }

                group.Id = (int)groupId;
                _system.UserInfo.AddGroup(group);
                cbxGroup.SelectedItem = group;
            }
            catch (Exception)
            {
                GroupInfoSaveFailed();
            }
        }
예제 #2
0
        private void btnMixedGroupsAdd_OnClick(object sender, RoutedEventArgs e)
        {
            GroupCreationWindow dialog = new GroupCreationWindow();

            dialog.Owner = this;

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

            Group tempGroup;

            if (_system.LocalUser != null)
            {
                //时时添加混编组
                int?groupId;
                try
                {
                    groupId = _system.Proxy.CreateMixedGroup(dialog.GroupName, _system.LocalUser.Id);
                    if (groupId == null)
                    {
                        GroupInfoSaveFailed();
                    }
                    else
                    {
                        tempGroup = new Group {
                            GroupType = Group.Type.Mixed, Name = dialog.GroupName, Id = unchecked ((int)groupId)
                        };

                        _system.UserInfo.MixedGroups.Add(tempGroup);
                        this.LvMixedGroups.SelectedItem = tempGroup;
                    }
                }
                catch (Exception)
                {
                    GroupInfoSaveFailed();
                }
            }
        }