Ejemplo n.º 1
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.º 2
0
    protected void Button1_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.SetPartyMember(acc);
        Label1.Text = db.IsPartyMember(acc).ToString();
    }
Ejemplo n.º 3
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.º 4
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.º 5
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.º 6
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)
            {

            }
        }
    }