示例#1
0
 private void BtnSave_Click(object sender, RoutedEventArgs e)
 {
     groupManager.AddGroup(new GroupMaster()
     {
         GroupName = txtName.Text, GroupDesc = txtDesc.Text, CreatedBy = 100
     });
 }
示例#2
0
        public void Confirm(object obj)
        {
            if (obj == null)
            {
                return;
            }

            CommandArgs args   = (CommandArgs)obj;
            var         player = args.Player ?? TSPlayer.Server;

            //Get the TShock group manager and setup the new vanilla group
            GroupManager gm    = TShock.Groups;
            Group        group = CreateVanillaGroupObject();

            if (!gm.GroupExists(GroupName))
            {
                gm.AddGroup(name: GroupName, parentname: null, permissions: group.Permissions, chatcolor: Group.defaultChatColor);
            }
            else
            {
                gm.UpdateGroup(name: GroupName, parentname: null, permissions: group.Permissions, chatcolor: Group.defaultChatColor, suffix: null, prefix: null);
            }
            //Retrieve the group again just so that the object state is synced with db state
            group = gm.GetGroupByName(GroupName);

            //Get the TShock user manager, select all non-superadmin groups, and change their group to the new vanilla group
            UserAccountManager um = TShock.UserAccounts;

            um.GetUserAccounts().Where(u => u.Group != "superadmin" && u.Group != "owner").ForEach(u => um.SetUserGroup(u, GroupName));

            //Update all active player's groups, as long as they're not a superadmin
            foreach (var ply in TShock.Players)
            {
                if (ply?.Group == null || ply.Group is SuperAdminGroup)
                {
                    continue;
                }

                ply.Group = group;
            }

            //Set the default group for any new guests joining
            Group.DefaultGroup = group;

            //Update the TShock config file so all new guest users will be assigned to the vanilla group
            TShockConfig tsConfig = TShock.Config;

            tsConfig.Settings.DefaultGuestGroupName        = GroupName;
            tsConfig.Settings.DefaultRegistrationGroupName = GroupName;
            //Write the config file so that this change persists
            tsConfig.Write(TShockConfigPath);

            player.SendSuccessMessage("Server has successfully been configured for vanilla gameplay.");
        }
示例#3
0
 public long AddGroup(GroupObject group)
 {
     try
     {
         return(_groupManager.AddGroup(group));
     }
     catch (Exception ex)
     {
         ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
示例#4
0
        private void Add(PointBlankPlayer executor, string[] args)
        {
            if (args.Length < 3)
            {
                UnturnedChat.SendMessage(executor, Translations["Base_NotEnoughArgs"], ConsoleColor.Red);
                return;
            }
            if (Group.Exists(args[1]))
            {
                UnturnedChat.SendMessage(executor, Translations["Group_Exists"], ConsoleColor.Red);
                return;
            }

            GroupManager.AddGroup(args[1], args[2], false, -1, Color.clear);
            UnturnedChat.SendMessage(executor, Translations["Group_Added"], ConsoleColor.Green);
        }
        /// <summary>
        /// グループ追加
        /// </summary>
        public void AddGroup()
        {
            var url      = this.textBoxUrl.Text;
            var username = this.textBoxUser.Text;
            var password = this.textBoxPassword.Text;

            var gm = new GroupManager(url, username, password);

            gm.ThrowSharePointException += (_sender, _e) => {
                throw new ApplicationException(_e.ErrorMessage);
            };

            var tbl = this.gridCsv.ToDataTable();
            var gls = tbl.Select(r => new {
                グループ名 = r["グループ名"].ToString(),
                説明    = r["説明"].ToString(),
            }).ToList();

            var addGroups = new List <string>();

            gls.ForEach(gi => {
                var name        = gi.グループ名;
                var description = gi.説明;

                gm.AddGroup(name, description, g => {
                    addGroups.Add(g.Title);
                });
            });

            var sb = new StringBuilder();

            if (addGroups.Any())
            {
                sb.AppendLine("グループを登録しました。");
                addGroups.ForEach(title => {
                    sb.AppendLine(title);
                });
            }
            else
            {
                sb.AppendLine("グループを追加しませんでした。");
            }

            this.ShowMessageBox(sb.ToString());
        }
示例#6
0
 public ActionResult CreateGroup(group model)
 {
     if (ModelState.IsValid)
     {
         GroupManager GM = new GroupManager();
         if (!GM.doesGroupExist(model.group_name))
         {
             GM.AddGroup(model, User.Identity.Name);
             return(RedirectToAction("Groups", "Account"));
         }
         else
         {
             ModelState.AddModelError("", "Group name is already in use.");
         }
     }
     // somthing went wrong so return to page if there is an error
     return(View(model));
 }
示例#7
0
        private void Grid_Drop(object sender, System.Windows.DragEventArgs e)
        {
            Mouse.OverrideCursor = Cursors.Wait;

            string channelName = e.Data.GetData(typeof(string)).ToString();

            var group = GroupManager.GetGroup(ChartName);

            if (group != null)
            {
                if (group.GetAttribute(channelName) == null)
                {
                    GroupManager.GetGroup(ChartName).AddAttribute(channelName, ColorManager.GetChartColor, 1);
                }
            }
            else
            {
                if (!channelNames.Contains(channelName))
                {
                    channelNames.Add(channelName);

                    string oldName = ChartName;

                    var temporaryGroup = GroupManager.GetGroup($"Temporary{GroupManager.TemporaryGroupIndex}");

                    while (temporaryGroup != null)
                    {
                        GroupManager.TemporaryGroupIndex++;
                        temporaryGroup = GroupManager.GetGroup($"Temporary{GroupManager.TemporaryGroupIndex}");
                    }

                    ChartName = $"Temporary{GroupManager.TemporaryGroupIndex}";

                    GroupManager.AddGroup(GroupManager.MakeGroupWirhAttributes(ChartName, channelNames));
                    ((DriverlessMenu)MenuManager.GetTab(TextManager.DriverlessMenuName).Content).ReplaceChannelWithTemporaryGroup(oldName, ChartName);
                }
            }

            GroupManager.SaveGroups();
            ((GroupSettings)((SettingsMenu)MenuManager.GetTab(TextManager.SettingsMenuName).Content).GetTab(TextManager.GroupsSettingsName).Content).InitGroups();
            ((DriverlessMenu)MenuManager.GetTab(TextManager.DriverlessMenuName).Content).BuildCharts();

            Mouse.OverrideCursor = null;
        }
示例#8
0
        private void btnAddGroup_Click(object sender, RoutedEventArgs e)
        {
            string groupName = this.txtGroupName.Text;

            if (groupName.Length > 1 && groupName.Length <= 100)
            {
                try
                {
                    if (_groupMgr.AddGroup(_accessToken.UserID, groupName))
                    {
                        PopulateGroupList();
                        this.txtGroupName.Clear();
                        this.lblSuccess.Content = "Success!";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#9
0
        private void AddGroupPopUpCardButton_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            AddGroupPopUpCardButton.Background = ConvertColor.ConvertStringColorToSolidColorBrush(ColorManager.Secondary100);

            Mouse.OverrideCursor = Cursors.Wait;

            if (!AddGroupNameTextBox.Text.Equals(string.Empty))
            {
                AddGroupGridBackground.Visibility = Visibility.Hidden;
                AddGroupGrid.Visibility           = Visibility.Hidden;

                var group = new Group(GroupManager.LastGroupID++, AddGroupNameTextBox.Text);
                GroupManager.AddGroup(group);
                GroupManager.SaveGroups();
                ActiveGroupID            = group.ID;
                AddGroupNameTextBox.Text = string.Empty;
                InitGroups();
                UpdateChannels();
                ((DriverlessMenu)MenuManager.GetTab(TextManager.DriverlessMenuName).Content).InitializeGroupItems();
                // ((Diagrams)MenuManager.GetTab(TextManager.DiagramsMenuName).Content).InitTabs();
            }

            Mouse.OverrideCursor = null;
        }
示例#10
0
        protected override void Seed(com.GreenThumb.MVC.Models.ApplicationDbContext context)
        {
            var userStore   = new UserStore <ApplicationUser>(context);
            var userManager = new UserManager <ApplicationUser>(userStore);

            const string userName = "******";
            const string password = "******";

            if (!context.Users.Any(u => u.UserName.Equals(userName)))
            {
                var user = new ApplicationUser()
                {
                    UserName
                        = userName,
                    Email
                        = "*****@*****.**",
                    FirstName
                        = "System",
                    LastName
                        = "Administrator"
                };



                IdentityResult result = userManager.Create(user, password);
                context.Roles.AddOrUpdate(r => r.Name, new IdentityRole()
                {
                    Name = "Administrator"
                });
                context.SaveChanges();

                userManager.AddToRole(user.Id, "Administrator");
                var gt_userManager = new UserManager();

                int userId = 0;

                if (!gt_userManager.ConfirmUserExists(userName, password))
                {
                    if (!gt_userManager.AddNewUserPasswordChange(new User()
                    {
                        UserName
                            = user.UserName,
                        FirstName
                            = user.FirstName,
                        LastName
                            = user.LastName,
                        EmailAddress
                            = user.Email,
                        Zip
                            = "00000"
                    }, password))
                    {
                        throw new InvalidOperationException("User could not be created on the previous database.");
                    }
                    else
                    {
                        UserManager uManager = new UserManager();
                        int         id       = uManager.GetUserId("admin");

                        string groupName = WebConfigurationManager.AppSettings["ExpertGroup"];

                        GroupManager groupManager = new GroupManager();
                        groupManager.AddGroup(id, groupName);

                        int groupId = groupManager.RetrieveGroupByName(groupName).GroupID;

                        new GardenManager().AddGarden(new Garden()
                        {
                            UserID
                                = id,
                            GardenDescription
                                = "Tasks to be completed by experts to fill the system.",
                            GardenName
                                = "Expert Tasks",
                            GroupID
                                = groupId,
                            GardenRegion
                                = "Unknown"
                        });
                    }
                }

                userId = gt_userManager.GetUserId(userName);

                userManager.AddClaim(user.Id, new Claim("GTUserID", userId.ToString()));
                userManager.AddClaim(user.Id, new Claim(ClaimTypes.GivenName, user.FirstName));
                userManager.AddClaim(user.Id, new Claim(ClaimTypes.Surname, user.LastName));

                context.SaveChanges();
            }

            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //
        }
示例#11
0
 public void CreateGroup()
 {
     Assert.IsTrue(Groups.AddGroup("test1", "heal") != "");
     Assert.IsTrue(Groups.GroupExists("test1"));
     Assert.IsTrue(TShock.Utils.GetGroup("test1").HasPermission("heal"));
 }
 public void CreateGroup()
 {
     groupManager.AddGroup(nameInput.text, descriptionInput.text);
     pageManager.ChangePage(2);
     groupManager.AddGroupButton(nameInput.text, "1");
 }
示例#13
0
        public void GroupCreation(GroupCreationDto groupcreationDto)
        {
            Group group = mapper.FromGroupCreationDtoToGroup(groupcreationDto);

            groupManager.AddGroup(group);
        }