Ejemplo n.º 1
0
    private void RemoveMembers(int startRecord, IForumDatabase forumDatabase, Dictionary <int, bool> memberAccountLookup, int[] accountIds)
    {
        int recCnt  = -1;
        int recCnt2 = 0;

        foreach (int accountId in accountIds)
        {
            recCnt++;
            if (recCnt < startRecord)
            {
                continue;
            }
            if (!memberAccountLookup.ContainsKey(accountId))
            {
                recCnt2++;
                forumDatabase.SetPartyNonmember(accountId);
            }
            if (recCnt2 > batchsize)
            {
                Label2.Text = "" + (recCnt + 1);
                return;
            }
        }
        Label2.Text = "0";
        Label1.Text = "4";
    }
Ejemplo n.º 2
0
    private void SetMembers(int startRecord, IForumDatabase forumDatabase, Dictionary <int, bool> memberAccountLookup, Memberships memberships)
    {
        Person currentMember = null;
        int    recCnt        = -1;
        int    recCnt2       = 0;

        foreach (Membership membership in memberships)
        {
            recCnt++;
            if (recCnt < startRecord)
            {
                continue;
            }

            if (!membership.Active)
            {
                continue;
            }
            recCnt2++;
            currentMember = membership.Person;
            SetOneMember(forumDatabase, memberAccountLookup, ref currentMember);
            if (recCnt2 > batchsize)
            {
                Label2.Text = "" + (recCnt + 1);
                return;
            }
        }
        Label2.Text = "0";
        Label1.Text = "2";
    }
Ejemplo n.º 3
0
    private void SetOneMember(IForumDatabase forumDatabase, Dictionary <int, bool> memberAccountLookup, ref Person currentMember)
    {
        try
        {
            if (currentMember.Handle != "")
            {
                int currentNewId = forumDatabase.GetAccountId(currentMember.Handle);
                if (currentNewId > 0)
                {
                    //currentMember.SwedishForumAccountId = currentNewId;
                    forumDatabase.SetPartyMember(currentNewId);

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

            try
            {
                //currentMember.SwedishForumAccountId = 0;
            }
            catch (Exception)
            {
            }
        }
    }
Ejemplo n.º 4
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);
        }
    }
Ejemplo n.º 5
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        IForumDatabase db  = SwedishForumDatabase.GetDatabase(2, TextBox1.Text);
        int            pid = int.Parse(TextBox2.Text);
        Person         p   = Person.FromIdentity(pid);
        int            acc = db.GetAccountId(p.Handle);

        Label2.Text = p.Handle + ":" + acc.ToString();
        db.SetPartyNonmember(acc);
        Label1.Text = db.IsPartyMember(acc).ToString();
    }
Ejemplo n.º 6
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();
    }
Ejemplo n.º 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            IForumDatabase forum = SwedishForumDatabase.GetDatabase();

            forum.TestMode = true;

            int forumPostId = forum.CreateNewPost(0, Person.FromIdentity(7838),
                                                  "Nyhetsbrev " + DateTime.Today.ToString("yyyy-MM-dd"),
                                                  "TestTitle", "TestContenttext");

            Response.Write(forumPostId);
        }
        catch (Exception ex)
        {
            if (!System.Diagnostics.Debugger.IsAttached)
            {   // ignore when debugging
                throw ex;
            }
        }
    }
Ejemplo n.º 8
0
    private void SetOneMember(IForumDatabase forumDatabase, Dictionary <int, bool> memberAccountLookup, ref Person currentMember)
    {
        try
        {
            if (currentMember.SwedishForumAccountName != "")
            {
                int currentNewId = forumDatabase.GetAccountId(currentMember.SwedishForumAccountName);
                if (currentNewId > 0)
                {
                    forumDatabase.SetPartyMember(currentNewId);

                    currentMember.SwedishForumAccountId = currentNewId;

                    memberAccountLookup[currentNewId] = true;
                    Label4.Text += "<br>" + currentMember.SwedishForumAccountName + ":" + currentNewId;
                }
            }
        }
        catch (Exception e)
        {
            Label3.Text += "<br>" + currentMember.SwedishForumAccountName + ":" + e.Message;
        }
    }
Ejemplo n.º 9
0
    private void RemoveMembers (int startRecord, IForumDatabase forumDatabase, Dictionary<int, bool> memberAccountLookup, int[] accountIds)
    {
        int recCnt = -1;
        int recCnt2 = 0;

        foreach (int accountId in accountIds)
        {
            recCnt++;
            if (recCnt < startRecord) continue;
            if (!memberAccountLookup.ContainsKey(accountId))
            {
                recCnt2++;
                forumDatabase.SetPartyNonmember(accountId);
            }
            if (recCnt2 > batchsize)
            {
                Label2.Text = "" + (recCnt + 1);
                return;
            }
        }
        Label2.Text = "0";
        Label1.Text = "4";

    }
Ejemplo n.º 10
0
    private void SetOneMember (IForumDatabase forumDatabase, Dictionary<int, bool> memberAccountLookup, ref Person currentMember)
    {
        try
        {
            if (currentMember.SwedishForumAccountName != "")
            {
                int currentNewId = forumDatabase.GetAccountId(currentMember.SwedishForumAccountName);
                if (currentNewId > 0)
                {
                    forumDatabase.SetPartyMember(currentNewId);

                    currentMember.SwedishForumAccountId = currentNewId;

                    memberAccountLookup[currentNewId] = true;
                    Label4.Text += "<br>" + currentMember.SwedishForumAccountName + ":" + currentNewId;
                }
            }
        }
        catch (Exception e)
        {
            Label3.Text += "<br>" + currentMember.SwedishForumAccountName + ":" + e.Message;

        }
    }
Ejemplo n.º 11
0
    private void SetMembers (int startRecord, IForumDatabase forumDatabase, Dictionary<int, bool> memberAccountLookup, Memberships memberships)
    {
        Person currentMember = null;
        int recCnt = -1;
        int recCnt2 = 0;
        foreach (Membership membership in memberships)
        {
            recCnt++;
            if (recCnt < startRecord) continue;

            if (!membership.Active)
            {
                continue;
            }
            recCnt2++;
            currentMember = membership.Person;
            SetOneMember(forumDatabase, memberAccountLookup, ref currentMember);
            if (recCnt2 > batchsize)
            {
                Label2.Text = "" + (recCnt + 1);
                return;
            }
        }
        Label2.Text = "0";
        Label1.Text = "2";

    }
Ejemplo n.º 12
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");
        }
Ejemplo n.º 13
0
    private void SetOneMember (IForumDatabase forumDatabase, Dictionary<int, bool> memberAccountLookup, ref Person currentMember)
    {
        try
        {
            if (currentMember.Handle != "")
            {
                int currentNewId = forumDatabase.GetAccountId(currentMember.Handle);
                if (currentNewId > 0)
                {
                    //currentMember.SwedishForumAccountId = currentNewId;
                    forumDatabase.SetPartyMember(currentNewId);

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

            try
            {
                //currentMember.SwedishForumAccountId = 0;
            }
            catch (Exception)
            {

            }
        }
    }