示例#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 static void CreateLol(Comment comment)
		{
			LolSet ls = new LolSet(
				new Query(
					new And(
						new Q(Lol.Columns.CommentK,comment.K),
						new Q(Lol.Columns.UsrK,Usr.Current.K)
					)
				)
			);
			if (ls.Count==0)
			{
				Usr usr = new Usr(comment.UsrK);
				LolSet lolUniqueSet = new LolSet(new Query(new And(
					new Q(Lol.Columns.CommentUsrK,usr.K),
					new Q(Lol.Columns.UsrK,Usr.Current.K))));
				if (lolUniqueSet.Count==0)
					usr.UniqueMadeLol++;
				usr.TotalMadeLol++;
				usr.Update();

				comment.LolCount++;
				comment.Update();

				Lol l = new Lol();
				l.DateTime=DateTime.Now;
				l.CommentK=comment.K;
				l.UsrK=Usr.Current.K;
				l.CommentUsrK=comment.UsrK;
				l.Update();
				l = new Lol(l.K);
				
				//DateTime lastLolDateTime = Usr.Current.LastLol;
						
				Usr.Current.TotalLol++;
				Usr.Current.LastLol = l.DateTime;
				Usr.Current.Update();

				Comment fullComment = new Comment(comment.K);

				if (!fullComment.Thread.Private && !fullComment.Thread.GroupPrivate && !fullComment.Thread.PrivateGroup)
				{

					if (Usr.Current.FacebookConnected && Usr.Current.FacebookStoryLaugh)
					{
						FacebookPost.CreateLaugh(Usr.Current, comment);
					}

					////LaughStub randomChatLaughStub = getLaughStub(ItemType.LaughAlert, new Chat.RoomSpec(RoomType.Laughs).Guid, fullComment);
					//LaughStub randomChatLaughStub = getLaughStub(ItemType.LaughAlert, new Chat.RoomSpec(RoomType.PublicStream).Guid, fullComment);
					//Chat.SendJsonChatItem(randomChatLaughStub);

					LaughStub randomChatLaughStub1 = getLaughStub(ItemType.LaughAlert, new Chat.RoomSpec(RoomType.PublicStream).Guid, fullComment);
					Chat.SendJsonChatItem(randomChatLaughStub1);
				}
				else
				{
					//LaughStub laughStub = getLaughStub(ItemType.LaughAlert, new Chat.RoomSpec(RoomType.Normal, Model.Entities.ObjectType.Thread, fullComment.ThreadK).Guid, fullComment);
					//UsrSet us = Thread.GetAllLoggedInParticipants(fullComment.Thread);
					//Chat.SendJsonChatItem(laughStub, us);
				}

			}
		}
示例#3
0
			public MakerReturn Post(Transaction transaction)
			{
				if (HttpContext.Current!=null)
					HttpContext.Current.Items["VisitComments"]=1;

				MakerReturn r = new MakerReturn();

				#region Look for duplicates
				Query qDuplicate = new Query();
				qDuplicate.QueryCondition=new Q(Comment.Columns.DuplicateGuid,(Guid)DuplicateGuid);
				qDuplicate.Columns=new ColumnSet(Comment.Columns.K, Comment.Columns.IndexInThread, Comment.Columns.ThreadK);
				CommentSet csDuplicate = new CommentSet(qDuplicate);
				if (csDuplicate.Count>0)
				{
					r.Success = false;
					r.Duplicate = true;
					r.Comment = csDuplicate[0];
					return r;
				}
				#endregion
				#region Check permission
				if (!NewThread && !ParentThread.CheckPermissionPost(PostingUsr, CurrentThreadUsr, CurrentGroupUsr))
				{
					r.Success=false;
					r.MessageHtml="You can't post in this topic.";
					return r;
				}
				#endregion
				#region Check for closed thread
				if (!NewThread && ParentThread.Closed)
				{
					r.Success=false;
					r.MessageHtml="This topic is closed - posting is disabled.";
					return r;
				}
				#endregion
			
				#region Create comment
				NewComment = new Comment();
				NewComment.DateTime = DateTime.Now;
				if (HttpContext.Current!=null)
					NewComment.Ip = Utilities.TruncateIp(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]);

				if (ChatItemGuid == null)
					NewComment.ChatItemGuid = Guid.NewGuid();
				else
					NewComment.ChatItemGuid = ChatItemGuid;

				NewComment.Enabled = true;
				NewComment.Text = Body;
				NewComment.ThreadK = ParentThread.K;
				NewComment.UsrK = PostingUsr.K;
				if (!ParentThread.Private)
				{
					PostingUsr.CommentCount++;
					PostingUsr.Update(transaction);
				}
				NewComment.DuplicateGuid = (Guid)DuplicateGuid;
				NewComment.IndexInThread = ParentThread.TotalComments;
				NewComment.Update(transaction);
				#endregion

				#region Update thread
				ParentThread.LastPost=NewComment.DateTime;
				ParentThread.LastPostUsrK=NewComment.UsrK;
				ParentThread.Update(transaction);
				ParentThread.UpdateTotalComments(transaction);
				#endregion
				#region Update / create ThreadUsr
				CurrentThreadUsr.ChangeStatus(ThreadUsr.StatusEnum.Archived, NewComment.DateTime);
				CurrentThreadUsr.ViewDateTime = NewComment.DateTime;
				CurrentThreadUsr.ViewDateTimeLatest = NewComment.DateTime;
				CurrentThreadUsr.ViewComments = ParentThread.TotalComments;
				CurrentThreadUsr.ViewCommentsLatest = ParentThread.TotalComments;
				CurrentThreadUsr.Update(transaction);
				#endregion

				string chatMessageBody = "";
				bool alreadySentChatMessage = false;
				bool commentIsPrivate = ParentThread.Private || ParentThread.GroupPrivate || ParentThread.PrivateGroup;
				if (!DisableLiveChatMessage)
				{
					chatMessageBody = Chat.GetMessageFromCommentBody(Body);

					//If the thread is subject to group privacy and we are inviting people, we should wait until after all the invites have been processed before sending the 
					//message, or we might sent the chat message to people who don't have permission to see the thread
					bool commentIsSubjectToGroupPrivacy = ParentThread.GroupPrivate || ParentThread.PrivateGroup;
					bool canPostImmediatly = !commentIsSubjectToGroupPrivacy || InviteKs.Count == 0;
					if (!NewThread && canPostImmediatly)
					{
						//If we're NOT posting a new thread, we should post the chat message immediatly...
						//if we are posting a new thread, we should wait until after all the invites have been done, so we have a better list of participants.
						sendChatMessageToParticipantsNow(InviteKs, NewComment, ParentThread, PostingUsr, chatMessageBody);
						alreadySentChatMessage = true;
					}

					
					if (!commentIsPrivate)
					{
						//Since we don't invite anyone to this room, we can post immediatly to the random chat room.
						//CommentMessageStub ms = getChatMessage(
						//    //new Chat.RoomSpec(RoomType.RandomChat).Guid,
						//    new Chat.RoomSpec(RoomType.PublicStream).Guid,
						//    ParentThread.GetRoomSpec().Guid,
						//    NewComment,
						//    ParentThread,
						//    PostingUsr,
						//    chatMessageBody);
						//Chat.SendJsonChatItem(ms);

						CommentMessageStub ms1 = getChatMessage(
							new Chat.RoomSpec(RoomType.PublicStream).Guid,
							ParentThread.GetRoomSpec().Guid,
							NewComment,
							ParentThread,
							PostingUsr,
							chatMessageBody);
						Chat.SendJsonChatItem(ms1);
					}

				}

				try
				{
					if (NewThread && !commentIsPrivate && PostingUsr.FacebookConnected)
					{
						bool sentToFacebook = false;

						if (NewComment.Thread.IsReview && PostingUsr.FacebookStoryEventReview)
						{
							FacebookPost.CreateEventReview(PostingUsr, NewComment.Thread, NewComment);
							sentToFacebook = true;
						}

						if (!sentToFacebook && NewComment.Thread.IsNews && PostingUsr.FacebookStoryPostNews)
						{
							FacebookPost.CreateEventReview(PostingUsr, NewComment.Thread, NewComment);
							sentToFacebook = true;
						}

						if (!sentToFacebook && PostingUsr.FacebookStoryNewTopic)
						{
							FacebookPost.CreateNewTopic(PostingUsr, NewComment.Thread, NewComment);
						}
					}
				}
				catch { }

				SendCommentAlertsJob job = new SendCommentAlertsJob(
					this.ParentThread, 
					this.PostingUsr, 
					this.NewComment, 
					this.NewThread, 
					this.AlertedUsrs, 
					this.InviteKs,
					DisableLiveChatMessage,
					alreadySentChatMessage,
					chatMessageBody);

				if (Vars.DevEnv)
				{
					job.ExecuteSynchronously();
				}
				else
				{
					if (this.RunAsync)
						job.ExecuteAsynchronously();
					else
						job.ExecuteSynchronously();
				}

				if (Usr.Current != null && PostingUsr.K != Usr.DsiUsrK)
				{
					Usr.IncrementSpamBotDefeaterCounter(Usr.SpamBotDefeaterCounter.Comments, Usr.Current.K);
				}

				r.Success = true;
				r.Comment = NewComment;
				return r;

			}
		protected void CommentEditSaveClick(object o, EventArgs e)
		{
			if (!Usr.Current.CanGroupNewsAdmin(CurrentGroupUsr))
			{
				throw new Exception("Can't news admin!!!");
			}
			CurrentComment = new Comment(CurrentComment.K);
			if (CommentEditTextBox.Text.Trim().Length == 0)
				throw new DsiUserFriendlyException("No text in comment!");
			CurrentComment.Text = Cambro.Web.Helpers.CleanHtml(CommentEditTextBox.Text);
			if (CurrentComment.K == CurrentComment.Thread.FirstComment.K)
			{
				if (Cambro.Web.Helpers.StripHtml(ThreadSubjectEditBox.Text).Trim().Length == 0)
					throw new DsiUserFriendlyException("No text in subject!");
				CurrentComment.Thread.Subject = Cambro.Web.Helpers.StripHtml(ThreadSubjectEditBox.Text);
				CurrentComment.Thread.Update();
			}
			CurrentComment.Update();
			Response.Redirect(CurrentGroup.UrlApp("admin", "threadk", CurrentThread.K.ToString(), "mode", "news"));
			//((DsiPage)Page).AnchorSkip("CommentK-"+CurrentComment.K.ToString());

		}
示例#5
0
		protected void CommentEditSaveClick(object o, EventArgs e)
		{
			if (!Usr.Current.CanNewsModerator())
			{
				throw new Exception("Can't news admin!!!");
			}
			CurrentComment = new Comment(CurrentComment.K);
			if (CommentEditTextBox.Text.Trim().Length == 0)
				throw new DsiUserFriendlyException("No text in comment!");
			CurrentComment.Text = Cambro.Web.Helpers.CleanHtml(CommentEditTextBox.Text);
			if (CurrentComment.K == CurrentComment.Thread.FirstComment.K)
			{
				if (Cambro.Web.Helpers.StripHtml(ThreadSubjectEditBox.Text).Trim().Length == 0)
					throw new DsiUserFriendlyException("No text in subject!");
				CurrentComment.Thread.Subject = Cambro.Web.Helpers.StripHtml(ThreadSubjectEditBox.Text);
				CurrentComment.Thread.Update();
			}
			CurrentComment.Update();
			((Spotted.Master.DsiPage)Page).AnchorSkip("CommentK-" + CurrentComment.K.ToString());

		}