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"; }
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(); }
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"; }
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"); }