Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Server.ScriptTimeout = 300;

        Label3.Text = "";
        Label4.Text = "";

        if (Label1.Text == "" && Label2.Text == "")
        {
            Label1.Text                    = "1";
            Label2.Text                    = "0";
            Session["Memberships"]         = Memberships.ForOrganization(Organization.PPSE);
            Session["memberAccountLookup"] = new Dictionary <int, bool>();
            Button1.Text                   = "Press OK to converting Person forumaccountIDs to new forum";
        }
        else if (Label1.Text == "1")
        {
            IForumDatabase         forumDatabase       = SwedishForumDatabase.GetDatabase(2, TextBox1.Text);
            Dictionary <int, bool> memberAccountLookup = Session["memberAccountLookup"] as Dictionary <int, bool>;
            Memberships            memberships         = Session["Memberships"] as Memberships;
            int startRec = int.Parse(Label2.Text);

            SetMembers(startRec, forumDatabase, memberAccountLookup, memberships);
            Button1.Text = "continuing setting memberships";
        }

        else if (Label1.Text == "2")
        {
            IForumDatabase forumDatabase = SwedishForumDatabase.GetDatabase(2, TextBox1.Text);
            Session["accountIds"] = forumDatabase.GetAccountList();

            Label1.Text  = "3";
            Label2.Text  = "0";
            Button1.Text = "removing memberships";
        }
        else if (Label1.Text == "3")
        {
            IForumDatabase         forumDatabase       = SwedishForumDatabase.GetDatabase(2, TextBox1.Text);
            Dictionary <int, bool> memberAccountLookup = Session["memberAccountLookup"] as Dictionary <int, bool>;
            int[] accountIds = Session["accountIds"] as int[];

            int startRec = int.Parse(Label2.Text);

            RemoveMembers(startRec, forumDatabase, memberAccountLookup, accountIds);

            Button1.Text = "removing memberships";
        }

        if (Label1.Text == "4")
        {
            Button1.Text = "DONE!";
        }

        if (Label1.Text != "4" && Label1.Text != "" && Label3.Text == "")
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "reloadscript", "document.getElementById('" + Button1.ClientID + "').click();", true);
        }
    }
Beispiel #2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        IForumDatabase db = SwedishForumDatabase.GetDatabase(2, TextBox1.Text);

        int[]         accounts = db.GetAccountList();
        StringBuilder sb       = new StringBuilder();

        foreach (int i in accounts)
        {
            sb.Append("," + i);
        }
        TextBox2.Text = sb.ToString();
    }
Beispiel #3
0
        public static void Run()
        {
            BotLog.Write(1, "SeForumCheck", "Entering");

            Memberships    memberships   = Memberships.ForOrganization(Organization.PPSE);
            IForumDatabase forumDatabase = SwedishForumDatabase.GetDatabase();

            int[] accountIds;
            try
            {
                accountIds = forumDatabase.GetAccountList();
            }
            catch (Exception e)
            {
                ExceptionMail.Send(new Exception("Failed to connect to vBulletin", e), true);
                BotLog.Write(1, "SeForumCheck", "Failed to connect -- exiting");

                return;
            }

            BotLog.Write(1, "SeForumCheck", "Primed db - entering promotion cycle");

            Dictionary <int, bool> memberAccountLookup = new Dictionary <int, bool>();

            // This is kind of suboptimal, but hey, it only runs once a night in the wolf hour.

            Person currentMember = null;

            foreach (Membership membership in memberships)
            {
                if (!membership.Active)
                {
                    continue;
                }

                currentMember = membership.Person;

                try
                {
                    if (currentMember.SwedishForumAccountId != 0)
                    {
                        if (!forumDatabase.IsPartyMember(currentMember.SwedishForumAccountId))
                        {
                            // This guy is not listed as a party member, but should be.

                            BotLog.Write(2, "SeForumCheck", "Promoting " + currentMember.Name);
                            forumDatabase.SetPartyMember(currentMember.SwedishForumAccountId);
                        }

                        memberAccountLookup[currentMember.SwedishForumAccountId] = true;
                    }
                }
                catch (Exception e)
                {
                    // The forum account probably doesn't exist. Just remove it from the profile.

                    BotLog.Write(2, "SeForumCheck", "Exception reading " + currentMember.Name + ": " + e.ToString());

                    try
                    {
                        currentMember.SwedishForumAccountId = 0;
                    }
                    catch (Exception e2)
                    {
                        string logMessage = "Exception removing " + currentMember.Name + "'s forum account: " + e2.ToString();
                        BotLog.Write(2, "SeForumCheck", logMessage);
                        ExceptionMail.Send(new Exception(logMessage, e2));
                    }
                }
            }

            // Now that we have flagged all member accounts as member accounts, flag the rest as
            // non-party members.

            BotLog.Write(1, "SeForumCheck", "Promotion cycle done - entering demotion cycle");

            foreach (int accountId in accountIds)
            {
                if (!memberAccountLookup.ContainsKey(accountId))
                {
                    if (forumDatabase.IsPartyMember(accountId))
                    {
                        BotLog.Write(2, "SeForumCheck", "Demoting forum account " + forumDatabase.GetAccountName(accountId));
                        forumDatabase.SetPartyNonmember(accountId);
                    }
                }
            }
            BotLog.Write(1, "SeForumCheck", "Demotion cycle complete -- exiting");
        }