Пример #1
0
        public static void LoadGlobal()
        {
            using (var db = new Database())
            {
                Channels.Clear();
                FullChannels.Clear();
                if (db.Channels.Any())
                {
                    var channelObjects = db.Channels.Include(ch => ch.GroupsChannelIsIn).ThenInclude(groupMembers => groupMembers.Group);
                    foreach (var groupMember in channelObjects)
                    {
                        Channels.Add(groupMember.Name, groupMember.ChannelID);
                        FullChannels.Add(groupMember);
                    }
                }

                PostTargets.Clear();
                foreach (var target in db.PostTargets)
                {
                    PostTargets.Add(target.Name, target.ChannelId);
                }


                Roles.Clear();
                if (db.Roles.Any())
                {
                    foreach (var role in db.Roles)
                    {
                        Roles.Add(role.Name, role.RoleID);
                    }
                }

                ServerID = db.PersistentData
                           .First(x => x.Name == "server_id")
                           .Value;

                InfoRoleManagerMessageId = db.PersistentData
                                           .First(x => x.Name == "rolemanager_message_id")
                                           .Value;

                StarboardStars = db.PersistentData
                                 .First(entry => entry.Name == "starboard_stars")
                                 .Value;

                Level2Stars = db.PersistentData
                              .First(entry => entry.Name == "level_2_stars")
                              .Value;

                Level3Stars = db.PersistentData
                              .First(entry => entry.Name == "level_3_stars")
                              .Value;

                Level4Stars = db.PersistentData
                              .First(entry => entry.Name == "level_4_stars")
                              .Value;

                DecayDays = db.PersistentData
                            .First(entry => entry.Name == "decay_days")
                            .Value;

                IllegalUserNameRegex = new Regex(db.PersistentData
                                                 .First(entry => entry.Name == "illegal_user_name_regex")
                                                 .StringValue, RegexOptions.Singleline | RegexOptions.Compiled);

                XPGainDisabled = db.PersistentData
                                 .First(entry => entry.Name == "xp_disabled")
                                 .Value == 1;

                InviteLinks.Clear();
                foreach (var link in db.InviteLinks)
                {
                    InviteLinks.Add(link);
                }

                ModmailCategoryId = db.PersistentData
                                    .First(entry => entry.Name == "modmail_category_id")
                                    .Value;

                XPGainRangeMin = (int)db.PersistentData
                                 .First(entry => entry.Name == "xp_gain_range_min")
                                 .Value;

                XPGainRangeMax = (int)db.PersistentData
                                 .First(entry => entry.Name == "xp_gain_range_max")
                                 .Value;

                Emotes.Clear();
                if (db.Emotes.Any())
                {
                    foreach (var post in db.Emotes)
                    {
                        Emotes.Add(post.Key, post);
                    }
                }

                StarboardPosts.Clear();
                if (db.StarboardMessages.Any())
                {
                    foreach (var post in db.StarboardMessages)
                    {
                        StarboardPosts.Add(post);
                    }
                }

                ProfanityChecks.Clear();
                if (db.ProfanityChecks.Any())
                {
                    foreach (var word in db.ProfanityChecks)
                    {
                        word.RegexObj = new Regex(word.Word, RegexOptions.Singleline | RegexOptions.Compiled);
                        ProfanityChecks.Add(word);
                    }
                }


                var ReadChannels = db.FAQCommandChannels
                                   .Include(faqComand => faqComand.Command)
                                   .Include(faqComand => faqComand.ChannelGroupReference)
                                   .Include(faqComand => faqComand.CommandChannelEntries)
                                   .OrderBy(command => command.Command.ID)
                                   .ToList();

                FAQCommands.Clear();
                FAQCommandChannels.Clear();

                FAQCommandChannels = ReadChannels;
                FAQCommands        = db.FAQCommands.ToList();

                Commands = db.Commands
                           .Include(co => co.GroupsCommandIsIn).ThenInclude(grp => grp.ChannelGroupReference).ThenInclude(ch => ch.Channels)
                           .ToList();
            }

            ReloadModmailThreads();
        }
Пример #2
0
        public static void LoadGlobal()
        {
            using (var db = new Database())
            {
                Channels.Clear();
                FullChannels.Clear();
                if (db.Channels.Any())
                {
                    var channelObjects = db.Channels.Include(ch => ch.GroupsChannelIsIn).ThenInclude(groupMembers => groupMembers.Group).ToList();
                    foreach (var groupMember in channelObjects)
                    {
                        Channels.Add(groupMember.Name, groupMember.ChannelID);
                        FullChannels.Add(groupMember);
                    }
                }

                PostTargets.Clear();
                foreach (var target in db.PostTargets.ToList())
                {
                    PostTargets.Add(target.Name, target.ChannelId);
                }


                Roles.Clear();
                if (db.Roles.Any())
                {
                    foreach (var role in db.Roles.ToList())
                    {
                        Roles.Add(role.Name, role.RoleID);
                    }
                }

                ServerID = PersistentData.GetConfiguredInt("server_id", db);

                InfoRoleMessageIds = new List <ulong>();
                InfoRoleMessageIds.Add(PersistentData.GetConfiguredInt("rolemanager_message_id", db));
                InfoRoleMessageIds.Add(PersistentData.GetConfiguredInt("rolemanager_message_id_2", db));

                AutoMuteMaxLevel  = PersistentData.GetConfiguredInt("auto_mute_max_level", db);
                AutoMutePingCount = PersistentData.GetConfiguredInt("auto_mute_ping_count", db);

                StarboardStars = PersistentData.GetConfiguredInt("starboard_stars", db);

                Level2Stars = PersistentData.GetConfiguredInt("level_2_stars", db);

                Level3Stars = PersistentData.GetConfiguredInt("level_3_stars", db);

                ModModeRoleId = PersistentData.GetConfiguredInt("mod_mode_role_id", db);

                ModModeRoleColor = Convert.ToUInt32(PersistentData.GetConfiguredString("mod_mode_role_color", db), 16);

                Level4Stars = PersistentData.GetConfiguredInt("level_4_stars", db);

                DecayDays = PersistentData.GetConfiguredInt("decay_days", db);

                LegalUserNameRegex = new Regex(PersistentData.GetConfiguredString("legal_user_name_regex", db), RegexOptions.Singleline | RegexOptions.Compiled);

                XPGainDisabled = PersistentData.GetConfiguredInt("xp_disabled", db) == 1;

                ProfanityVoteThreshold = (int)PersistentData.GetConfiguredInt("profanity_votes_threshold", db);

                InviteLinks.Clear();
                foreach (var link in db.InviteLinks.ToList())
                {
                    InviteLinks.Add(link);
                }

                ModmailCategoryId = PersistentData.GetConfiguredInt("modmail_category_id", db);

                XPGainRangeMin = (int)PersistentData.GetConfiguredInt("xp_gain_range_min", db);

                XPGainRangeMax = (int)PersistentData.GetConfiguredInt("xp_gain_range_max", db);

                FilteredUdWords.Clear();
                FilteredUdWords.AddRange(db.FilteredUDWords);

                Emotes.Clear();
                if (db.Emotes.Any())
                {
                    foreach (var post in db.Emotes.ToList())
                    {
                        Emotes.Add(post.Key, post);
                    }
                }

                TrackedEmotes.Clear();
                if (db.Emotes.Any())
                {
                    foreach (var post in db.Emotes.AsQueryable().Where(e => !e.TrackingDisabled).ToList())
                    {
                        TrackedEmotes.Add(post.Key, post);
                    }
                }
                FeatureFlags.Clear();
                if (db.FeatureFlags.Any())
                {
                    foreach (var featureFlag in db.FeatureFlags.AsQueryable().ToList())
                    {
                        FeatureFlags.Add(featureFlag.FeatureName, featureFlag);
                    }
                }

                StarboardPosts.Clear();
                if (db.StarboardMessages.Any())
                {
                    foreach (var post in db.StarboardMessages.ToList())
                    {
                        StarboardPosts.Add(post);
                    }
                }

                Categories.Clear();
                if (db.Categories.Any())
                {
                    foreach (var category in db.Categories.ToList())
                    {
                        Categories.Add(category);
                    }
                }

                ProfanityChecks.Clear();
                if (db.ProfanityChecks.Any())
                {
                    foreach (var word in db.ProfanityChecks.ToList())
                    {
                        word.RegexObj = new Regex(word.Word, RegexOptions.Singleline | RegexOptions.Compiled);
                        ProfanityChecks.Add(word);
                    }
                }


                var ReadChannels = db.FAQCommandChannels
                                   .Include(faqComand => faqComand.Command)
                                   .Include(faqComand => faqComand.ChannelGroupReference)
                                   .Include(faqComand => faqComand.CommandChannelEntries)
                                   .OrderBy(command => command.Command.ID)
                                   .ToList();

                FAQCommands.Clear();
                FAQCommandChannels.Clear();

                FAQCommandChannels = ReadChannels;
                FAQCommands        = db.FAQCommands.ToList();

                Commands = db.Commands
                           .Include(co => co.GroupsCommandIsIn).ThenInclude(grp => grp.ChannelGroupReference).ThenInclude(ch => ch.Channels)
                           .ToList();
            }

            ReloadModmailThreads();
        }