private static ThreadUsrSet GetParticipatingThreadUsrs(Thread thread)
		{
			Query tuQ = new Query();
			tuQ.ReturnCountOnly = true;
			tuQ.QueryCondition = new And(
				ThreadUsr.PrivateCanSeeQ,
				new Q(ThreadUsr.Columns.ThreadK, thread.K));
			ThreadUsrSet tus = new ThreadUsrSet(tuQ);
			return tus;
		}
		private ThreadUsrSet GetWatchingThreadUsrs(int threadK)
		{
			Query tuWatchQ = new Query();
			tuWatchQ.ReturnCountOnly = true;
			tuWatchQ.QueryCondition = new And(
				ThreadUsr.WatchingQ,
				new Q(ThreadUsr.Columns.ThreadK, threadK)
			);
			ThreadUsrSet tuWatchSet = new ThreadUsrSet(tuWatchQ);
			return tuWatchSet;
		}
Example #3
0
		protected void ClearViewDataGeneric(bool AdminOnly)
		{
			Query q = new Query();
			q.TableElement = new Join(
				new Join(ThreadUsr.Columns.ThreadK, Thread.Columns.K),
				new TableElement(TablesEnum.Promoter),
				QueryJoinType.Inner,
				Thread.Columns.K,
				Promoter.Columns.QuestionsThreadK);
			q.NoLock = true;
			ThreadUsrSet tus = new ThreadUsrSet(q);
			Cambro.Web.Helpers.WriteAlertHeader();
			int count = 0;
			foreach (ThreadUsr tu in tus)
			{
				bool doIt = true;
				if (AdminOnly) // if we're only removing this item from Admin's inboxes
				{
					//only make the change if the ThreadUsr is for an admin (leave the thread in the inbox for non-admins)
					doIt = (tu.UsrK == 1 || tu.UsrK == 2 || tu.UsrK == 4 || tu.UsrK == 78392);

					//leave this thread in the inbox if the last post was NOT made by an admin!
					if (!(tu.Thread.LastPostUsrK == 1 ||
						tu.Thread.LastPostUsrK == 2 ||
						tu.Thread.LastPostUsrK == 4 ||
						tu.Thread.LastPostUsrK == 78392))
						doIt = false;
				}

				if (doIt)
				{
					if (tu.IsInbox)
					{
						tu.ChangeStatus(ThreadUsr.StatusEnum.Archived, true);
					}
					tu.ViewDateTime = DateTime.Now;
					tu.ViewComments = tu.Thread.TotalComments;
					tu.ViewDateTimeLatest = DateTime.Now;
					tu.ViewCommentsLatest = tu.Thread.TotalComments;
					tu.Update();
					if (count % 100 == 0)
						Cambro.Web.Helpers.WriteAlert(count.ToString() + "/" + tus.Count + " - ThreadK=" + tu.ThreadK + " - UsrK=" + tu.UsrK, 1);
				}
				count++;
			}
			Cambro.Web.Helpers.WriteAlert("Done", 2);
			Cambro.Web.Helpers.WriteAlertFooter("/admin/promoterpm");
		}
		private int? GetUsrKOfFirstParticipant(int threadK, int threadUsrK)
		{
			try
			{
				Query q = new Query();
				q.NoLock = true;
				q.TopRecords = 1;
				q.QueryCondition = new And(
					ThreadUsr.PrivateCanSeeQ,
					new Q(ThreadUsr.Columns.ThreadK, threadK),
					new Q(ThreadUsr.Columns.UsrK, QueryOperator.NotEqualTo, threadUsrK));
				ThreadUsrSet tusUsr = new ThreadUsrSet(q);
				return tusUsr[0].UsrK;
			}
			catch
			{
				return null;
			}
		}
		void BindParticipants()
		{
			if (!CurrentThread.Private)
				return;

			ParticipantsRefreshAnchor.HRef = ContainerPage.Url.CurrentUrl();

			if (CurrentThread.TotalParticipants > 24 && !ShowAllParticipants)
			{
				ParticipantsListPanel.Visible = false;
				ParticipantsHiddenPanel.Visible = true;
				ParticipantsLabel.Text = (CurrentThread.TotalParticipants == 1 ? "is " : "are ") + CurrentThread.TotalParticipants.ToString("#,##0") + (CurrentThread.TotalParticipants == 1 ? " participant" : " participants");
			}
			else
			{
				ParticipantsListPanel.Visible = true;
				ParticipantsHiddenPanel.Visible = false;
				Query q = new Query();
				q.QueryCondition = new And(
					new Q(ThreadUsr.Columns.ThreadK, CurrentThreadK),
					new Q(ThreadUsr.Columns.Status, QueryOperator.NotEqualTo, ThreadUsr.StatusEnum.Deleted));
				q.OrderBy = new OrderBy(
					new OrderBy(Buddy.Columns.FullBuddy, OrderBy.OrderDirection.Descending),
					new OrderBy(new Column(ThreadUsr.Columns.UsrK, Usr.Columns.NickName)));
				q.Columns = new ColumnSet(
					ThreadUsr.Columns.ThreadK,
					ThreadUsr.Columns.Status,
					ThreadUsr.Columns.InvitingUsrK,
					ThreadUsr.Columns.DateTime,
					ThreadUsr.Columns.UsrK,
					new JoinedColumnSet(ThreadUsr.Columns.UsrK, Usr.LinkColumns, Usr.Columns.Email, Usr.Columns.FirstName, Usr.Columns.LastName, Usr.Columns.IsSkeleton, Usr.Columns.AddedByUsrK),
					ThreadUsr.Columns.InvitingUsrK,
					new JoinedColumnSet(ThreadUsr.Columns.InvitingUsrK, Usr.LinkColumns),
					Buddy.Columns.FullBuddy);
				q.TableElement = new Join(
					new TableElement(TablesEnum.ThreadUsr),
					new TableElement(new Column(ThreadUsr.Columns.UsrK, Usr.Columns.K)),
					QueryJoinType.Inner,
					ThreadUsr.Columns.UsrK,
					new Column(ThreadUsr.Columns.UsrK, Usr.Columns.K));
				q.TableElement = new Join(
					q.TableElement,
					new TableElement(new Column(ThreadUsr.Columns.InvitingUsrK, Usr.Columns.K)),
					QueryJoinType.Left,
					ThreadUsr.Columns.InvitingUsrK,
					new Column(ThreadUsr.Columns.InvitingUsrK, Usr.Columns.K));
				q.TableElement = new Join(
					q.TableElement,
					new TableElement(TablesEnum.Buddy),
					QueryJoinType.Left,
					new And(
						new Q(ThreadUsr.Columns.UsrK, Buddy.Columns.UsrK, true),
						new Q(Buddy.Columns.BuddyUsrK, Usr.Current.K),
						new Q(Buddy.Columns.FullBuddy, true)));

				ThreadUsrSet tus = new ThreadUsrSet(q);

				if (tus.Count > 24 && !ShowAllParticipants)
				{
					ParticipantsListPanel.Visible = false;
					ParticipantsHiddenPanel.Visible = true;
					ParticipantsLabel.Text = (tus.Count == 1 ? "is " : "are ") + tus.Count.ToString("#,##0") + (tus.Count == 1 ? " participant" : " participants");
				}
				else
				{
					ParticipantsDataList.DataSource = tus;
					if (tus.Count > 12)
					{
						ParticipantsDataList.ItemTemplate = this.LoadTemplate("/Templates/ThreadUsrs/Small.ascx");
						ParticipantsDataList.RepeatColumns = 1;
					}
					else if (tus.Count > 4)
					{
						ParticipantsDataList.ItemTemplate = this.LoadTemplate("/Templates/ThreadUsrs/Medium.ascx");
					}
					else
					{
						ParticipantsDataList.ItemTemplate = this.LoadTemplate("/Templates/ThreadUsrs/Large.ascx");
					}
					ParticipantsDataList.DataBind();
				}
			}

		}
Example #6
0
		public static void MoveAndysClients()
		{

			Console.WriteLine("==========================");
			Console.WriteLine("MoveAndysClients");
			Console.WriteLine("==========================");
			Console.WriteLine("Press any key...");

			Random r = new Random();
			Console.ReadLine();

			int promoterMessageId = 4134345;
			int salesUsrKToDistribute = 1586161;
			Usr salesUsrToDistribute = new Usr(salesUsrKToDistribute);

			Console.WriteLine("Selecting promoters...");
			Query q = new Query();

			//	if (Vars.DevEnv)
			//	{
			//	q.TopRecords = 100;
			//	q.QueryCondition = new Q(Promoter.Columns.SalesUsrK, 383296);
			//}
			//	else
			//	{
			q.QueryCondition = new And(
				new Q(Promoter.Columns.SalesUsrK, salesUsrKToDistribute),
				new Or(
					new Q(Promoter.Columns.LastMessage, QueryOperator.IsNull, null),
					new Q(Promoter.Columns.LastMessage, QueryOperator.NotEqualTo, promoterMessageId)
				)
			);
			//	}
			q.OrderBy = new OrderBy(Promoter.Columns.K);
			PromoterSet bs = new PromoterSet(q);
			Console.WriteLine("Done selecting promoters...");

			Query salesPersonsQuery = new Query(new And(new Q(Usr.Columns.SalesTeam, 2), new Q(Usr.Columns.K, QueryOperator.NotEqualTo, salesUsrKToDistribute)));
			UsrSet promoterSalesUsrs = new UsrSet(salesPersonsQuery);

			Usr dave = new Usr(4);
			Usr owain = new Usr(421097);

			for (int count = 0; count < bs.Count; count++)
			{
				Promoter c = bs[count];

				try
				{


					Usr newSalesUsr = owain;

					c.SalesUsrK = newSalesUsr.K;
					c.RecentlyTransferred = true;

					c.AddNote("Sales contact changed from " + salesUsrToDistribute.NickName + " to " + newSalesUsr.NickName, Guid.NewGuid(), dave, true);

					Console.Write("{0}/{1} - Assigning to " + newSalesUsr.NickName + " - sending to {2}", count, bs.Count, c.Name);

					Thread t = new Thread(c.QuestionsThreadK);
					//	t.IsNews = true;
					//	t.Update();

					try
					{
						ThreadUsr tuRo = new ThreadUsr(c.QuestionsThreadK, salesUsrKToDistribute);
						tuRo.Delete();
						UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob(t);
						job.ExecuteSynchronously();

					}
					catch { }

					if (true)
					{
						Query q2 = new Query();
						q2.QueryCondition = new Q(ThreadUsr.Columns.ThreadK, c.QuestionsThreadK);
						ThreadUsrSet tus2 = new ThreadUsrSet(q2);

						Console.Write(".");

						foreach (ThreadUsr tu in tus2)
						{
							try
							{
								tu.ChangeStatus(ThreadUsr.StatusEnum.Archived, false);
								tu.Update();
								Console.Write(".");
							}
							catch
							{
								Console.Write("X");
							}
						}
					}

					Console.Write(".");

					Comment.Maker m = t.GetCommentMaker();
Example #7
0
		private void CheckForNullStatusChangeObjectAndBind(GridView gridView, Panel panel, ThreadUsrSet tus)
		{
			List<ThreadUsr> threadUsrs = new List<ThreadUsr>();
			try
			{
				tus.Reset();

				//global::Cache.Instances.Main.Store(new Cache.CacheKey(global::Cache.CacheKeyPrefix.SpamQueryResults, "Panel", panel.ClientID), tus);
				if (tus.Count == 0)
				{
					panel.Visible = false;
				}
				else
				{
					foreach (ThreadUsr tu in tus)
					{
						if (tu.StatusChangeObject != null)
						{
							//object cachedJobStatus = global::Cache.Instances.Main.Get(new global::Cache.CacheKey(global::Cache.CacheKeyPrefix.UpdateThreadUsrJobStatus, "UsrK", Usr.Current.K.ToString(), "StatusChangeObjectType",
							//                                                      tu.StatusChangeObjectType.ToString(), "StatusChangeObjectK", tu.StatusChangeObjectK.ToString()).ToString());
							//if (cachedJobStatus == null || Bobs.JobProcessor.Job.JobStatus.Failed == (Bobs.JobProcessor.Job.JobStatus)cachedJobStatus)
								threadUsrs.Add(tu);
							//else
							//    cachedJobStatus = cachedJobStatus;
						}
					}
					if (threadUsrs.Count > 0)
					{
						panel.Visible = true;
						if ((gridView.PageIndex + 1) * gridView.PageCount > threadUsrs.Count)
							gridView.PageIndex = Convert.ToInt32(Math.Floor((double)(threadUsrs.Count / gridView.PageCount)));
						gridView.DataSource = threadUsrs;
						gridView.DataBind();
					}
					else
					{
						panel.Visible = false;
					}
				}
			}
			catch (Exception ex)
			{
				if(Vars.DevEnv)
					ErrorStatusMessage(ex);
			}
		}
Example #8
0
		//protected void RemoveAllArticleLinkButton_Click(object sender, EventArgs eventArgs)
		//{
		//    try
		//    {
		//        Usr.Current.UpdateThreadUsrs(ThreadUsr.StatusEnum.Archived, ThreadUsr.StatusEnum.NewWatchedForumAlert, Model.Entities.ObjectType.Article);
		//        BindWatchArticlePanel();
		//        ((Spotted.Master.DsiPage)Page).AnchorSkip("WatchArticlePanelAnchor");
		//    }
		//    catch (Exception ex)
		//    {
		//        ErrorStatusMessage(ex);
		//    }
		//}

		//protected void IgnoreAllArticleLinkButton_Click(object sender, EventArgs eventArgs)
		//{
		//    try
		//    {
		//        Usr.Current.UpdateThreadUsrs(ThreadUsr.StatusEnum.Ignore, ThreadUsr.StatusEnum.NewWatchedForumAlert, Model.Entities.ObjectType.Article);
		//        BindWatchArticlePanel();
		//        ((Spotted.Master.DsiPage)Page).AnchorSkip("WatchArticlePanelAnchor");
		//    }
		//    catch (Exception ex)
		//    {
		//        ErrorStatusMessage(ex);
		//    }
		//}
		#endregion

		#region WatchOtherThreadPanel
		protected void BindWatchOtherThreadPanel()
		{
			Query q = new Query();
			q.ExtraSelectElements.Add("count", "COUNT(*)");
			q.QueryCondition = new And(new Q(ThreadUsr.Columns.UsrK, Usr.Current.K),
									   new Q(ThreadUsr.Columns.Status, ThreadUsr.StatusEnum.UnArchived));
			q.Columns = new ColumnSet();

			ThreadUsrSet tus = new ThreadUsrSet(q);
			int count = 0;
			if (tus.Count == 1 && tus[0].ExtraSelectElements["count"] != DBNull.Value)
				count = Convert.ToInt32(tus[0].ExtraSelectElements["count"]);

			WatchOtherThreadPanel.Visible = count > 0;
			if (count > 0)
			{
				NumberOfTopicsFromWatchingOtherThreadLabel.Text = Utilities.Link(UrlInfo.PageUrl("inbox", "statusenum", Convert.ToInt32(ThreadUsr.StatusEnum.UnArchived).ToString()), count.ToString() + " other topic" + (count > 1 ? "s" : ""));

				// Get job status from Memcached
				object cachedJobStatus = global::Caching.Instances.Main.Get(new global::Caching.CacheKey(global::Caching.CacheKeyPrefix.UpdateThreadUsrJobStatus, "UsrK", Usr.Current.K.ToString(), "StatusChangeObjectType",
																			  null, "StatusChangeObjectK", null).ToString());
				if (cachedJobStatus != null && (Bobs.JobProcessor.Job.JobStatus.Queued == (Bobs.JobProcessor.Job.JobStatus)cachedJobStatus || Bobs.JobProcessor.Job.JobStatus.Running == (Bobs.JobProcessor.Job.JobStatus)cachedJobStatus))
				{
					WatchOtherTopicOptionsPanel.Visible = false;
					WatchOtherTopicOptionsLabel.Visible = true;
					WatchOtherTopicOptionsLabel.Text = PROCESSING_HTML;
				}
			}

			SetupTopicOptionsDropDownList(OtherTopicOptionsDropDownList);
		}
Example #9
0
		protected void BindInvitePanel()
		{
			try
			{
				Query q = new Query();
				q.GroupBy = new GroupBy(new GroupBy(ThreadUsr.Columns.InvitingUsrK), new GroupBy(ThreadUsr.Columns.StatusChangeObjectType), new GroupBy(ThreadUsr.Columns.StatusChangeObjectK), new GroupBy(ThreadUsr.Columns.Status));
				q.ExtraSelectElements.Add("count", "COUNT(*)");
				q.QueryCondition = new And(new Q(ThreadUsr.Columns.UsrK, Usr.Current.K),
										   new Q(ThreadUsr.Columns.InvitingUsrK, QueryOperator.NotEqualTo, Usr.Current.K),
										   new Q(ThreadUsr.Columns.InvitingUsrK, QueryOperator.NotEqualTo, 0),
										   new Q(ThreadUsr.Columns.Status, ThreadUsr.StatusEnum.NewInvite));

				q.TableElement = new Join(new Join(ThreadUsr.Columns.ThreadK, Thread.Columns.K),
										  new TableElement(TablesEnum.GroupUsr),
										  QueryJoinType.Left,
										  new And(new Q(Thread.Columns.GroupK, GroupUsr.Columns.GroupK, true),
												  new Q(GroupUsr.Columns.UsrK, Usr.Current.K),
												  new Q(GroupUsr.Columns.Status, GroupUsr.StatusEnum.Member)));

				q.QueryCondition = new And(q.QueryCondition,
										   new Or(new Q(Thread.Columns.GroupPrivate, false),
												  new Q(GroupUsr.Columns.UsrK, Usr.Current.K)),
										   new Or(new Q(Thread.Columns.PrivateGroup, false),
												  new Q(GroupUsr.Columns.UsrK, Usr.Current.K)));

				q.TopRecords = 100;
				q.OrderBy = new OrderBy("COUNT(*) DESC");
				q.Columns = new ColumnSet(ThreadUsr.Columns.InvitingUsrK, ThreadUsr.Columns.StatusChangeObjectType, ThreadUsr.Columns.StatusChangeObjectK, ThreadUsr.Columns.Status);
				ThreadUsrSet tus = new ThreadUsrSet(q);

				CheckForNullStatusChangeObjectAndBind(InviteGridView, InvitePanel, tus);
			}
			catch (Exception ex)
			{
				if (Vars.DevEnv)
					ErrorStatusMessage(ex);
			}
		}
Example #10
0
		private static ThreadUsrSet GetAllArchivedThreadUsrs(Thread parentThread, Usr postingUsr)
		{
			Query q = new Query();
			q.QueryCondition = new And(
				new Q(ThreadUsr.Columns.UsrK, QueryOperator.NotEqualTo, postingUsr.K),
				new Q(ThreadUsr.Columns.ThreadK, parentThread.K),
				new Q(ThreadUsr.Columns.Status, ThreadUsr.StatusEnum.Archived));
			ThreadUsrSet tus = new ThreadUsrSet(q);
			return tus;
		}
Example #11
0
		public void FixQuestionsThreadUsrs()
		{
			if (this.QuestionsThreadK > 0 && this.AdminUsrs.Count > 0)
			{
				try
				{
					Thread questionsThread = new Thread(this.QuestionsThreadK);

					Query questionsQuery = new Query(new Q(ThreadUsr.Columns.ThreadK, this.QuestionsThreadK));
					questionsQuery.Columns = new ColumnSet(ThreadUsr.Columns.ThreadK, ThreadUsr.Columns.UsrK);
					ThreadUsrSet threadUsrs = new ThreadUsrSet(questionsQuery);
					UsrSet salesTeam2 = Usr.GetNewPromoterSalesUsrsNameAndK();
					bool removeUsr;
					for (int i = threadUsrs.Count - 1; i >= 0; i--)
					{
						removeUsr = true;
						if (this.SalesUsrK > 0 && this.SalesUsrK == threadUsrs[i].UsrK)
						{
							removeUsr = false;
						}
						else
						{
							if (this.SalesUsrK == 0)
							{
								salesTeam2.Reset();
								foreach (Usr salesUsr in salesTeam2)
								{
									if (threadUsrs[i].UsrK == salesUsr.K)
									{
										removeUsr = false;
										break;
									}
								}
							}
							if (removeUsr)
							{
								this.AdminUsrs.Reset();
								foreach (Usr promoterUsr in this.AdminUsrs)
								{
									if (threadUsrs[i].UsrK == promoterUsr.K)
									{
										removeUsr = false;
										break;
									}
								}
							}
						}
						if (removeUsr)
							threadUsrs[i].Delete();
					}

					if (this.SalesUsrK > 0)
						questionsThread.AddThreadUsrWithoutInvite(this.SalesUsrK);
					else
					{
						salesTeam2.Reset();
						foreach (Usr salesUsr in salesTeam2)
						{
							questionsThread.AddThreadUsrWithoutInvite(salesUsr.K);
						}
					}

					this.AdminUsrs.Reset();
					foreach (Usr promoterUsr in this.AdminUsrs)
					{
						questionsThread.AddThreadUsrWithoutInvite(promoterUsr.K);
					}
					
					UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob(questionsThread);
					job.ExecuteSynchronously();
				}
				catch(Exception ex)
				{
					Utilities.AdminEmailAlert("Exception occurred in Promoter.FixQuestionsThreadUsrs() for promoter " + this.Name + " (" + this.K.ToString() + ")", 
												"Exception occurred in Promoter.FixQuestionsThreadUsrs() for promoter " + this.Name + " (" + this.K.ToString() + ")", ex, this);
				}
			}
		}