示例#1
0
		public void SendMatchNotification()
		{
			#region Init thread
			Thread t = new Thread();
			t.DateTime = DateTime.Now;
			t.Enabled = true;
			t.ParentObjectK = 0;
			t.ParentObjectType = Model.Entities.ObjectType.None;
			t.Subject = "DSI Date introduction - " + this.Usr.NickName + " and " + this.DateUsr.NickName;
			t.UsrK = this.UsrK;
			t.Private = true;
			t.IsNews = false;
			t.IsSticky = false;
			t.Update();
			t.UpdateAncestorLinks(null);

			ThreadUsr tu = new ThreadUsr();
			tu.DateTime = DateTime.Now;
			tu.InvitingUsrK = this.UsrK;
			tu.UsrK = this.DateUsrK;
			tu.ThreadK = t.K;
			tu.ChangeStatus(ThreadUsr.StatusEnum.NewInvite);
			tu.StatusChangeObjectK = this.UsrK;
			tu.StatusChangeObjectType = Model.Entities.ObjectType.Usr;
			tu.PrivateChatType = ThreadUsr.PrivateChatTypes.Popup;
			tu.Update();

			ThreadUsr tu1 = new ThreadUsr();
			tu1.DateTime = DateTime.Now;
			tu1.InvitingUsrK = this.DateUsrK;
			tu1.UsrK = this.UsrK;
			tu1.ThreadK = t.K;
			tu1.ChangeStatus(ThreadUsr.StatusEnum.NewInvite);
			tu1.PrivateChatType = ThreadUsr.PrivateChatTypes.Popup;
			tu1.StatusChangeObjectK = this.UsrK;
			tu1.StatusChangeObjectType = Model.Entities.ObjectType.Usr;
			tu1.Update();

			Comment c = new Comment();
			c.DateTime = DateTime.Now;
			if (HttpContext.Current != null)
				c.Ip = Utilities.TruncateIp(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]);
			c.Enabled = true;
			string rel = "";
			if (this.Usr.Relationship1 && this.DateUsr.Relationship1)
				rel += " <b>just friends</b>";
			if (this.Usr.Relationship2 && this.DateUsr.Relationship2)
				rel += (rel.Length > 0 ? " or " : "") + " <b>a bit of a fling</b>";
			if (this.Usr.Relationship3 && this.DateUsr.Relationship3)
				rel += (rel.Length > 0 ? " or " : "") + " <b>love</b>";
			c.Text = "<b>You've both been matched by DSI Date.</b>\n\nYou've selected Yes to each others profiles on the DSI Date page. You're both looking for: " + rel + ".\n\nGet to know each other better in this private conversation.";
			c.ThreadK = t.K;
			c.UsrK = 3526;
			c.DuplicateGuid = Guid.NewGuid();
			c.Update();
			c = new Comment(c.K);

			CommentAlert.Enable(this.Usr, t.K, Model.Entities.ObjectType.Thread);
			CommentAlert.Enable(this.DateUsr, t.K, Model.Entities.ObjectType.Thread);

			t.LastPost = c.DateTime;
			t.LastPostUsrK = c.UsrK;
			t.Update();
			t.UpdateTotalComments(null);
			//t.UpdateTotalParticipants();
			UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob();
			job.ExecuteSynchronously();

			#endregion

			this.MatchThreadK = t.K;
			this.Update();
			UsrDate udRev = new UsrDate(this.DateUsrK, this.UsrK);
			udRev.MatchThreadK = t.K;
			udRev.Update();

			//Email
			Mailer sm = new Mailer();
			sm.RedirectUrl = t.Url();
			sm.Subject = "DSI Date has matched you to " + this.DateUsr.NickName;
			sm.Body = "<p>DSI Date has matched you to " + this.DateUsr.NickNameSafe + ". We've invited you both to a private conversation, where you can get to know each other better.</p>";
			sm.Body += "<p><a href=\"[LOGIN(" + t.Url() + ")]\">Click here to send " + this.DateUsr.NickNameSafe + " a message</a></p>";
			sm.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
			sm.UsrRecipient = this.Usr;
			sm.To = this.Usr.Email;
			sm.Send();

			Mailer sm1 = new Mailer();
			sm1.RedirectUrl = t.Url();
			sm1.Subject = "DSI Date has matched you to " + this.Usr.NickName;
			sm1.Body = "<p>DSI Date has matched you to " + this.Usr.NickNameSafe + ". We've invited you both to a private conversation, where you can get to know each other better.</p>";
			sm1.Body += "<p><a href=\"[LOGIN(" + t.Url() + ")]\">Click here to send " + this.Usr.NickNameSafe + " a message</a></p>";
			sm1.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
			sm1.UsrRecipient = this.DateUsr;
			sm1.To = this.DateUsr.Email;
			sm1.Send();

		}
示例#2
0
		public void FixPromoterQuestions(object o, System.EventArgs e)
		{
			Cambro.Web.Helpers.WriteAlertHeader();

			Cambro.Web.Helpers.WriteAlert("Selecting promoters...", 1);
			Query q = new Query();
			//q.QueryCondition=???
			PromoterSet bs = new PromoterSet(q);
			for (int count = 0; count < bs.Count; count++)
			{
				Promoter c = bs[count];

				try
				{
					Thread t = new Thread(c.QuestionsThreadK);
					t.Subject = c.Name + " promoter questions";
					t.Update();
					// Do work here!
					//c.Update();

					if (count % 10 == 0)
						Cambro.Web.Helpers.WriteAlert("Done " + count + "/" + bs.Count, 2);

				}
				catch(Exception ex)
				{
					Cambro.Web.Helpers.WriteAlert("Exception " + count + "/" + bs.Count + " - " + ex.ToString(), 3);
				}

				bs.Kill(count);

			}
			Cambro.Web.Helpers.WriteAlert("Done!", 3);
			Cambro.Web.Helpers.WriteAlertFooter();
		}
示例#3
0
		private static void CheckToPutThreadInCaptionCompetition(IDiscussable discussable, Thread thread)
		{
			if (Vars.IsCompetitionActive && discussable.ObjectType == Model.Entities.ObjectType.Photo)
			{
				Photo photo = (Photo)discussable;
				if (photo.IsInCaptionCompetition && (!photo.ThreadK.HasValue || !photo.Thread.IsInCaptionCompetition))
				{
					thread.GroupK = Vars.CompetitionGroupK;
					thread.IsInCaptionCompetition = true;
					thread.Update();

					photo.ThreadK = thread.K;
					photo.Update();
				}
			}
		}
示例#4
0
			public MakerReturn Post()
			{
				MakerReturn r = new MakerReturn();
				#region look for duplicate
				Query qDup = new Query();
				qDup.TopRecords = 1;
				qDup.Columns = new ColumnSet(Bobs.Comment.Columns.K, Bobs.Comment.Columns.ThreadK);
				qDup.QueryCondition = new Q(Bobs.Comment.Columns.DuplicateGuid, (Guid)DuplicateGuid);
				CommentSet csDup = new CommentSet(qDup);
				if (csDup.Count > 0)
				{
					r.Success = false;
					r.MessageHtml = "Duplicate thread detected";
					r.Thread = csDup[0].Thread;
					r.Duplicate = true;
					return r;
				}
				#endregion
				#region ensure two parents are different types...
				if (ParentType.Equals(Model.Entities.ObjectType.Group) && GroupK != ParentK)
				{
					r.Success = false;
					r.MessageHtml = "Posting to group, but GroupK!=ParentK";
					return r;
				}
				#endregion
				#region Make sure Group and ParentType are syncronised
				if (GroupK > 0 && ParentType.Equals(Model.Entities.ObjectType.None))
				{
					ParentType = Model.Entities.ObjectType.Group;
					ParentK = GroupK;
				}
				if (GroupK == 0 && ParentType.Equals(Model.Entities.ObjectType.Group))
				{
					GroupK = ParentK;
				}
				#endregion
				#region if we're posting in a group, make sure we are a member
				if (GroupK > 0)
				{
					GroupUsr gu = ParentGroup.GetGroupUsr(PostingUsr);
					if (!PostingUsr.CanGroupMember(gu))
					{
						r.Success = false;
						r.MessageHtml = "You have tried to post a message in the " + ParentGroup.Link() + " group, but you're not currently a member of this group. Check out the group homepage for more information.";
						return r;
					}
				}
				#endregion
				#region ensure both parents map to real objects
				if (!ParentType.Equals(Model.Entities.ObjectType.None))
				{
					if (ParentBob == null)
					{
						r.Success = false;
						r.MessageHtml = "You've tried to post a message in a non-existant chat. Maybe it's been deleted.";
						return r;
					}
				}
				if (GroupK > 0)
				{
					if (ParentGroup == null)
					{
						r.Success = false;
						r.MessageHtml = "You've tried to post a message in a non-existant group. Maybe it's been deleted.";
						return r;
					}
				}
				#endregion
				#region Private
				bool tPrivate = false;
				bool gPrivate = false;
				if (Private)
				{
					if (GroupK == 0)
						tPrivate = true;
					else
						gPrivate = true;
				}
				#endregion
				#region News
				tNews = false;
				tNewsStatus = NewsStatusEnum.None;
				int tNewsLevel = 0;
				int tNewsUsrK = 0;
				int tNewsModeratorUsrK = 0;
				if (News)
				{
					if (tPrivate)
					{
						r.Success = false;
						r.MessageHtml = "You've tried to post private news! How did this happen?";
						return r;
					}
					else if (GroupK == 0)
					{
						r.Success = false;
						r.MessageHtml = "You've tried to post public non-group news. How did this happen?";
						return r;

						//if (PostingUsr.NewsPermissionLevel >= 10 || PostingUsr.IsSuper)
						//{
						//    tNews = true;
						//    tNewsStatus = NewsStatusEnum.Recommended;
						//    tNewsModeratorUsrK = Usr.GetNewsModeratorUsrK();
						//    tNewsLevel = 10;
						//    tNewsUsrK = PostingUsr.K;
						//}
						//else
						//{
						//    tNews = false;
						//    tNewsStatus = NewsStatusEnum.Recommended;
						//    tNewsModeratorUsrK = Usr.GetNewsModeratorUsrK();
						//    tNewsLevel = 0;
						//    tNewsUsrK = PostingUsr.K;
						//}
					}
					else
					{
						GroupUsr gu = ParentGroup.GetGroupUsr(PostingUsr);

						if (PostingUsr.CanGroupNewsAdmin(gu))
						{
							tNews = true;
							tNewsStatus = NewsStatusEnum.Done;
							tNewsLevel = 10;
							tNewsUsrK = PostingUsr.K;
						}
						else
						{
							tNews = false;
							tNewsStatus = NewsStatusEnum.Recommended;
							tNewsLevel = 10;
							tNewsUsrK = PostingUsr.K;
						}
					}
				}
				#endregion
				#region Sealed
				bool tSealed = false;
				if (Sealed)
				{
					if (tPrivate)
						tSealed = true;
				}
				#endregion
				#region Closed
				bool tClosed = false;
				if (Closed)
				{
					tClosed = true;
				}
				#endregion
				#region Review
				bool tReview = false;
				if (Review)
				{
					if (ParentType.Equals(Model.Entities.ObjectType.Event) && GroupK == 0)
					{
						Query qReviews = new Query();
						qReviews.QueryCondition = new And(
							new Q(Columns.UsrK, PostingUsr.K),
							new Q(Columns.ParentObjectType, Model.Entities.ObjectType.Event),
							new Q(Columns.ParentObjectK, ParentK),
							new Q(Columns.IsReview, true)
							);
						qReviews.TopRecords = 1;
						qReviews.Columns = new ColumnSet(Thread.Columns.K);
						ThreadSet tsReviews = new ThreadSet(qReviews);
						if (tsReviews.Count > 0)
						{
							r.Success = false;
							r.MessageHtml = "You've already posted a review. You can only post one review per event.";
							r.Duplicate = true;
							r.Thread = tsReviews[0];
							return r;
						}
						else
							tReview = true;
					}
					else
					{
						r.Success = false;
						r.MessageHtml = "You must post a review in an event chat board.";
						return r;
					}
				}
				#endregion

				if (GroupK > 0)
					CurrentGroupUsr = ParentGroup.GetGroupUsr(PostingUsr);

				Transaction trans = null;//new Transaction();

				NewThread = new Thread();

				try
				{
					#region Create thread
					NewThread.DateTime = DateTime.Now;
					NewThread.Enabled = true;
					NewThread.UsrK = PostingUsr.K;
					NewThread.LastPostUsrK = PostingUsr.K;
					NewThread.Subject = Helpers.Strip(Subject, true, true, true, true);

					NewThread.ParentObjectType = ParentType;
					NewThread.ParentObjectK = ParentK;
					if (GroupK > 0)
						NewThread.GroupK = ParentGroup.K;
					else
						NewThread.GroupK = 0;

					NewThread.Private = tPrivate;
					NewThread.GroupPrivate = gPrivate;
					if (GroupK > 0)
						NewThread.PrivateGroup = ParentGroup.PrivateChat;
					else
						NewThread.PrivateGroup = false;

					NewThread.IsNews = tNews;
					NewThread.NewsStatus = tNewsStatus;
					NewThread.NewsLevel = tNewsLevel;
					NewThread.NewsModeratorUsrK = tNewsModeratorUsrK;
					NewThread.NewsUsrK = tNewsUsrK;

					NewThread.Sealed = tSealed;
					NewThread.Closed = tClosed;
					NewThread.IsReview = tReview;

					NewThread.UpdateAncestorLinksNoUpdate();
					NewThread.Update(trans);

					#endregion

					#region Add PostingUsr ThreadUsr
					CurrentThreadUsr = new ThreadUsr();
					CurrentThreadUsr.DateTime = DateTime.Now;
					CurrentThreadUsr.InvitingUsrK = PostingUsr.K;
					CurrentThreadUsr.UsrK = PostingUsr.K;
					CurrentThreadUsr.ThreadK = NewThread.K;
					CurrentThreadUsr.ChangeStatus(ThreadUsr.StatusEnum.Archived, NewThread.DateTime);
					CurrentThreadUsr.StatusChangeObjectK = PostingUsr.K;
					CurrentThreadUsr.StatusChangeObjectType = Model.Entities.ObjectType.Usr;
					CurrentThreadUsr.Update(trans);
					#endregion

					#region Make the comment
					Comment.Maker cMaker = new Comment.Maker();
					cMaker.Body = Body;
					cMaker.ParentThread = NewThread;
					cMaker.DuplicateGuid = DuplicateGuid;
					cMaker.PostingUsr = PostingUsr;
					cMaker.InviteKs = InviteKs;
					cMaker.AlertedUsrs = AlertedUsrs;
					cMaker.NewThread = true;
					cMaker.CurrentThreadUsr = CurrentThreadUsr;
					cMaker.CurrentGroupUsr = CurrentGroupUsr;
					cMaker.RunAsync = RunAsync;
					cMaker.DisableLiveChatMessage = DisableLiveChatMessage;
					Comment.MakerReturn cReturn = null;
					try
					{
						cReturn = cMaker.Post(trans);
					}
					catch (Exception ex)
					{
						NewThread.DeleteAll(null);
						throw ex;
					}
					#endregion

					

					//SendThreadAlertsJob sendThreadsAlert = new SendThreadAlertsJob(NewThread.K, AlertedUsrs, PostingUsr.K, Subject, InviteKs);
					//if (this.RunAsync)
					//{
					//    sendThreadsAlert.ExecuteAsynchronously();
					//}
					//else
					//{
					//    sendThreadsAlert.ExecuteSynchronously();
					//}

					r.Success = true;
					r.Thread = NewThread;
					r.Comment = cReturn.Comment;
					return r;
				}
				catch (Exception ex)
				{
					//trans.Rollback();
					NewThread.DeleteAll(null);
					throw ex;
				}
				finally
				{
					//trans.Close();
				}
			}
示例#5
0
        public string GetSummary(string url)
        {
            url = url.ToLower();
            var    uri      = new Uri(url);
            string path     = uri.AbsolutePath;
            var    post_str = uri.Fragment;

            Console.WriteLine(url);
            Console.WriteLine(uri.Fragment);

            int post_id = -1;

            if (post_str.Length > 0)
            {
                int.TryParse(post_str.Substring(2), out post_id);
            }

            var    parts    = path.Split('/');
            string board_id = parts[1];
            string id_str   = parts[3];

            if (!int.TryParse(id_str, out int id))
            {
                return("-");
            }

            var board = GetBoard(board_id);

            if (board.Threads.Count == 0 || board.Threads.All(p => p.ID != id))
            {
                var thread = new Thread(id, board);
                thread.Update();

                board.Threads.Add(thread);
            }

            for (int i = 0; i < board.Threads.Count; i++)
            {
                var thread = board.Threads[i];

                if (thread.ID == id)
                {
                    if (post_id > -1)
                    {
                        try
                        {
                            var post    = thread.Posts.First(p => p.ID == post_id);
                            int replies = thread.Posts.Where(p => p.Comment.Contains(">>" + post.ID)).Count();

                            return(string.Format(post_layout,
                                                 FourChanImageResolver.Bold(post.SmartSubject) ?? "(no subject)",
                                                 FourChanImageResolver.Bold(thread.OP.SmartSubject) ?? "(no subject)",
                                                 board_id,
                                                 Utilities.BetterPlural(replies, "reply", 0, 8),
                                                 Utilities.TimeSpanToPrettyString(DateTime.UtcNow - post.PostTime),
                                                 post.Filename > 0 ? string.Format(" | File: {0}", post.FileUrl) : ""));
                        }
                        catch
                        {
                        }
                    }

                    return(string.Format(Layout,
                                         FourChanImageResolver.Bold(thread.OP.SmartSubject) ?? "(no subject)",
                                         board_id,
                                         Utilities.BetterPlural(thread.OP.Replies, "reply", thread.OP.BumpLimit, 8),
                                         Utilities.BetterPlural(thread.OP.Images, "image", thread.OP.ImageLimit, 3),
                                         Utilities.BetterPlural(thread.OP.Posters, "poster", 0, 11),
                                         Utilities.TimeSpanToPrettyString(DateTime.UtcNow - thread.OP.PostTime),
                                         thread.OP.Filename > 0 ? string.Format(" | File: {0}", thread.OP.FileUrl) : ""));
                }
            }

            throw new Exception("nope");
        }