Esempio n. 1
0
		public void SendEmails(object o, System.EventArgs e)
		{
			

			if (Page.IsValid && this.MultiBuddyChooser.SelectedUsrKs.Any())
			{
				if (!CurrentPhoto.Validate())
					throw new DsiUserFriendlyException("Photo not enabled!");

				
				
				Thread.Maker m = new Thread.Maker();
				m.DuplicateGuid = ContainerPage.ViewStatePublic["CommentDuplicateGuid"];

				string stripped = MessageHtml.GetPlainText();
				
				m.Subject = stripped.TruncateWithDots(50);

				m.Body = MessageHtml.GetHtml();
				
				m.ParentType = Model.Entities.ObjectType.Photo;
				m.ParentK = CurrentPhoto.K;
				m.Private = true;

				m.InviteKs = this.MultiBuddyChooser.SelectedUsrKs.ToList();
				
				m.PostingUsr = Usr.Current;

				Thread.MakerReturn r = m.Post();
				if (!r.Success && !r.Duplicate)
					throw new Exception(r.MessageHtml);

				Response.Redirect(r.Thread.Url());

				//SendPhotoByEmail(u, name);
				
			}
		}
Esempio n. 2
0
		public void AddThreadPostClick(object o, System.EventArgs e)
		{
			if (Page.IsValid)
			{
				if (Usr.Current == null)
				{
					throw new DsiUserFriendlyException("You can't post until you are logged in!");
				}
				if (ThisUsr.IsSkeleton)
					throw new Exception("Can't send message.");

				if (AddThreadAddBuddy.Checked)
					Usr.Current.AddBuddy(ThisUsr, Usr.AddBuddySource.UsrPageSendPrivateMessage, Buddy.BuddyFindingMethod.Nickname, null);

				Thread.Maker m = new Thread.Maker();
				m.Subject = AddThreadSubjectTextBox.Text;
				m.Body = AddThreadCommentHtml.GetHtml();
				m.ParentType = Model.Entities.ObjectType.None;
				m.DuplicateGuid = ContainerPage.ViewStatePublic["CommentDuplicateGuid"];
				m.Private = true;
				m.InviteKs.Add(ThisUsr.K);
				m.PostingUsr = Usr.Current;
				Thread.MakerReturn r = m.Post();

				if (r.Success || r.Duplicate)
					Response.Redirect(r.Thread.Url());
				else
					throw new Exception(r.MessageHtml);

			}
		}
Esempio n. 3
0
		public static Thread.MakerReturn CreatePublicThread(IDiscussable parentObject, Guid duplicateGuid, string commentHtml, bool isNews, List<int> invitedUsrKs, bool disableLiveChatMessage)
		{
			Thread.Maker m = new Thread.Maker();
			m.PostingUsr = Usr.Current;
			string subject = "";
			if (parentObject is Article)
			{
				subject = Cambro.Misc.Utility.Snip(((Article)parentObject).Title, 50);
			}
			else
			{
				subject = Cambro.Misc.Utility.Snip(Cambro.Web.Helpers.Strip(commentHtml), 50);
			}
			m.Subject = subject;
			m.Body = commentHtml;
			m.ParentType = parentObject.ObjectType;
			m.ParentK = parentObject.K;
			m.DuplicateGuid = duplicateGuid;

			if (isNews)
				m.News = true;

			m.InviteKs = invitedUsrKs;
			m.DisableLiveChatMessage = disableLiveChatMessage;

			Thread.MakerReturn r = m.Post();

			if (r.Success)
			{
				if (parentObject is IHasPrimaryThread && !r.Thread.Private && r.Thread.GroupK == 0)
				{
					((IHasPrimaryThread)parentObject).UpdateSingleThread();
				}
				//if (parentObject is Article && !r.Thread.Private && r.Thread.GroupK == 0)
				//{
				//    Article article = (Article)parentObject;
				//    article.ThreadK = r.Thread.K;
				//    article.Update();
				//    article.UpdateTotalComments(null);
				//}
				//else
				//{
					CheckToPutThreadInCaptionCompetition(parentObject, r.Thread);
				//}
			}
			return r;
		}
Esempio n. 4
0
		public static Thread.MakerReturn CreatePrivateThread(IDiscussable discussable, Guid duplicateGuid, string commentHtml, List<int> invitedUsrKs, bool isSealed)
		{
			Thread.Maker m = new Thread.Maker();
			m.PostingUsr = Usr.Current;
			m.Body = commentHtml;

			string stripped = Cambro.Web.Helpers.StripHtmlDoubleSpacesLineFeeds(m.Body);
			if (stripped.Trim().Length == 0)
				stripped = "[no subject]";

			m.Subject = ((stripped.Length > 50) ? stripped.TruncateWithDots(50) : stripped);

			m.ParentType = discussable.ObjectType;
			m.ParentK = discussable.K;
			m.DuplicateGuid = duplicateGuid;
			m.Private = true;
			m.InviteKs = invitedUsrKs;
			m.Sealed = isSealed;

			Thread.MakerReturn r = m.Post();
			return r;
		}
Esempio n. 5
0
		public static Thread.MakerReturn CreateNewPublicThread(IDiscussable discussable, Guid duplicateGuid, string commentHtml, bool isNews, List<int> invitedUsrKs)
		{
			Thread.Maker m = new Thread.Maker();
			m.PostingUsr = Usr.Current;
			m.Body = commentHtml;
			m.Subject = Cambro.Misc.Utility.Snip(Cambro.Web.Helpers.Strip(m.Body), 50);
			m.ParentType = discussable.ObjectType;
			m.ParentK = discussable.K;
			m.DuplicateGuid = duplicateGuid;

			if (isNews)
				m.News = true;

			m.InviteKs = invitedUsrKs;

			Thread.MakerReturn r = m.Post();

			if (r.Success)
			{
				CheckToPutThreadInCaptionCompetition(discussable, r.Thread);
			}
			return r;
		}
Esempio n. 6
0
		public static Thread.MakerReturn CreateNewThreadInGroup(int groupK, IDiscussable discussable, Guid duplicateGuid, string commentHtml, bool isNews, List<int> invitedUsrKs, bool isPrivate)
		{
			Group g = new Group(groupK);
			GroupUsr gu = g.GetGroupUsr(Usr.Current);
			if (!g.CanMember(Usr.Current, gu))
				throw new DsiUserFriendlyException("You can't post to this group!");

			Thread.Maker m = new Thread.Maker();
			m.PostingUsr = Usr.Current;
			m.Body = commentHtml;

			string stripped = Cambro.Web.Helpers.StripHtmlDoubleSpacesLineFeeds(m.Body);
			if (stripped.Trim().Length == 0)
				stripped = "[no subject]";

			m.Subject = ((stripped.Length > 50) ? (stripped.Substring(0, 47) + "...") : stripped);

			m.ParentType = discussable.ObjectType;
			m.ParentK = discussable.K;
			m.DuplicateGuid = duplicateGuid;
			m.Private = isPrivate;

			if (isNews)
				m.News = true;

			m.InviteKs = invitedUsrKs;
			m.GroupK = g.K;

			Thread.MakerReturn r = m.Post();
			return r;
		}
Esempio n. 7
0
		public void AddQuestionsThread(Usr u, string promoterName)
		{
			#region Add a PM
			//string assemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
			//string body = NVelocityEngineFactory.CreateNVelocityAssemblyEngine(assemblyName, true).Process(new Hashtable(), "Emails.NewPromoterEmail.vm");
			Comment c = new Comment(Vars.DevEnv ? 21036749 : 21053069);
			string body = c.Text;


			List<Usr> salesUsrs = new List<Usr>();
			if (this.SalesUsrK > 0)
				salesUsrs.Add(this.SalesUsr);
			else
			{
				foreach (Usr salesUsr in Usr.GetNewPromoterSalesUsrsNameAndK())
				{
					salesUsrs.Add(salesUsr);
				}
			}

			if (salesUsrs.Count > 0)
			{
				Thread.Maker m = new Thread.Maker();
				m.Subject = promoterName + " promoter questions";
				m.Body = body;
				m.ParentType = Model.Entities.ObjectType.None;
				m.DuplicateGuid = Guid.NewGuid();
				m.Private = true;
				m.PostingUsr = salesUsrs[0];
				for(int i=1; i<salesUsrs.Count; i++)
					m.InviteKs.Add(salesUsrs[i].K);
				m.InviteKs.Add(u.K);

				Thread.MakerReturn r = m.Post();

				this.QuestionsThreadK = r.Thread.K;
				Thread t = r.Thread;
			}
			#endregion
		}
Esempio n. 8
0
		public void AddThreadPost_Click(object o, System.EventArgs e)
		{
			if (!CurrentForumCheckPermissionPost)
				return;

			if (Page.IsValid)
			{
				Usr.KickUserIfNotLoggedIn();

				Thread.Maker m = new Thread.Maker();
				m.DuplicateGuid = ContainerPage.ViewStatePublic["CommentDuplicateGuid"];
				m.Subject = AddThreadSubjectTextBox.Text;
				m.Body = CommentHtml.GetHtml();

				#region Work out the parent / group
				if (ThreadParentType.Equals(Model.Entities.ObjectType.Group) &&
					AddThreadAdvancedCheckBox.Checked &&
					AddThreadEventCheckBox.Checked)
				{
					Event ev = new Event(int.Parse(AddThreadEventDropDown.SelectedValue));
					m.ParentType = Model.Entities.ObjectType.Event;
					m.ParentK = ev.K;
					m.GroupK = ObjectK;
				}
				else if (
					!ThreadParentType.Equals(Model.Entities.ObjectType.Group) &&
					AddThreadAdvancedCheckBox.Checked &&
					AddThreadGroupRadioButton.Checked)
				{
					Group g = new Group(int.Parse(AddThreadGroupDropDown.SelectedValue));
					m.ParentType = ThreadParentType;
					m.ParentK = ObjectK;
					m.GroupK = g.K;
				}
				else
				{
					m.ParentType = ThreadParentType;
					m.ParentK = ObjectK;
					if (ThreadParentType.Equals(Model.Entities.ObjectType.Group))
						m.GroupK = ObjectK;
				}
				#endregion

				if (AddThreadAdvancedCheckBox.Checked &&
					AddThreadNewsCheckBox.Checked)
					m.News = true;

				if (AddThreadAdvancedCheckBox.Checked
					&& AddThreadPrivateRadioButton.Checked
					&& AddThreadSealedCheckBox.Checked)
					m.Sealed = true;

				if (AddThreadAdvancedCheckBox.Checked
					&& AddThreadPrivateRadioButton.Checked)
					m.Private = true;

				if (AddThreadAdvancedCheckBox.Checked
					&& (ThreadParentType.Equals(Model.Entities.ObjectType.Group) || AddThreadGroupRadioButton.Checked)
					&& AddThreadGroupPrivateCheckBox.Checked)
					m.Private = true;

				if (AddThreadAdvancedCheckBox.Checked &&
					(AddThreadInviteCheckBox.Checked || AddThreadPrivateRadioButton.Checked))
				{

					m.InviteKs = new List<int>(this.uiMultiBuddyChooser.SelectedUsrKs);
				}

				m.PostingUsr = Usr.Current;
				Thread.MakerReturn r = m.Post();
				if (!r.Success && !r.Duplicate)
					throw new Exception(r.MessageHtml);

				Response.Redirect(r.Thread.Url());

			}
			else
			{
				ContainerPage.AnchorSkip("NewThread");
			}
		}
Esempio n. 9
0
		public void PickWinners()
		{

			if (!this.Running && !this.WinnersPicked)
			{
				Query q = new Query();
				q.QueryCondition=new And(
					new Q(CompEntry.Columns.CompK,this.K),
					new Q(CompEntry.Columns.Answer,this.CorrectAnswer),
					new Q(CompEntry.Columns.Winner,false),
					new Q(Usr.Columns.IsAdmin,false),
					new Q(Usr.Columns.K,QueryOperator.NotEqualTo,this.OwnerUsrK)
				);
				q.TableElement=new Join(CompEntry.Columns.UsrK,Usr.Columns.K);
				q.OrderBy=new OrderBy(OrderBy.OrderDirection.Random);
				q.TopRecords=this.Winners+this.Winners2+this.Winners3;
				CompEntrySet cs = new CompEntrySet(q);
				int winnerCount = 0;
				foreach (CompEntry ce in cs)
				{
					ce.Winner=true;

					if (winnerCount<this.Winners)
						ce.Prize=1;
					else if (winnerCount<(this.Winners+this.Winners2))
						ce.Prize=2;
					else
						ce.Prize=3;
					
					ce.Update();

					winnerCount++;

				}
				this.WinnersPicked=true;
				this.Update();

				CompEntrySet csEmails = new CompEntrySet(new Query(new Q(CompEntry.Columns.CompK,this.K)));
				Usr DSI = new Usr(8);
				foreach (CompEntry ce in csEmails)
				{
					Mailer sm = new Mailer();
					int threadK = 0;
					if (ce.Winner)
					{
						string prize = this.Prize;
						if (ce.Prize==2)
							prize = this.Prize2;
						if (ce.Prize==3)
							prize = this.Prize3;

						#region Add a PM
						string body = @"<i>This private message has been sent automatically by the DontStayIn competition system.</i>

Congratulations! "+ce.Usr.NickName+@" has won <b>"+prize+@"</b> in the competition. "+this.Owner.NickName+@" is dealing with sorting the prizes out.

The full name of "+ce.Usr.NickName+@" is <i>"+ce.Usr.FirstName+@" "+ce.Usr.LastName+@"</i>. If any more details are needed, e.g. postal address, please post them here.

<a href="""+this.Url()+@""">Click here to go to the competition page</a>";

						Thread.Maker m = new Thread.Maker();
						m.Subject="Congratulations! "+ce.Usr.NickName+@" has won a prize!";
						m.Body=body;
						m.ParentType=Model.Entities.ObjectType.None;
						m.DuplicateGuid=Guid.NewGuid();
						m.Private=true;
						m.PostingUsr=DSI;
						m.InviteKs.Add(ce.Usr.K);
						m.InviteKs.Add(this.Owner.K);

						Thread.MakerReturn r = m.Post();

						threadK = r.Thread.K;
						ce.WinnerThreadK=threadK;
						ce.Update();
						#endregion

						sm.Subject="YOU'VE WON the DontStayIn competition!";
						sm.Body="<p>You have won <b>"+prize+"</b> in our competition. For details of how to claim your prize, click the login link below.</p>";
					}
					else
					{
						sm.Subject="Sorry, you didn't win the DontStayIn competition.";
						sm.Body="<p>Sorry, you didn't win <b>"+this.Prize+"</b> in our competition. To see the winners, click the login link below.</p>";
					}
					if (ce.Winner)
					{
						Thread t = new Thread(threadK);
						sm.RedirectUrl=t.Url();
					}
					else
						sm.RedirectUrl=this.Url();

					sm.TemplateType=Mailer.TemplateTypes.AnotherSiteUser;
					sm.UsrRecipient=ce.Usr;
					sm.Send();
				}
				Mailer smOwner = new Mailer();
				smOwner.Subject="We have drawn the winners in your competition";
				smOwner.Body="<p>We've automatically picked this winner(s) in the <b>"+this.Name+"</b> competition. We've automatically invited you to a private message with each of the winners. Please arrange delivery of their prizes ASAP. To see a list of the winners, please click the login link below.</p>";
				smOwner.RedirectUrl=this.Url();
				smOwner.TemplateType=Mailer.TemplateTypes.AnotherSiteUser;
				smOwner.To=this.Owner.Email;
				smOwner.UsrRecipient=this.Owner;
				smOwner.Send();
			}
		}
Esempio n. 10
0
		public void ReviewSave(object o, System.EventArgs e)
		{
			if (Page.IsValid)
			{
				if (SummaryTextBox.Text.Length > 50)
					throw new Exception("Summary too long");

				int threadK = 0;
				if (CurrentThread == null)
				{
					//save new review
					Thread.Maker m = new Thread.Maker();
					m.Subject = SummaryTextBox.Text;
					m.Body = ReviewHtml.GetHtml();
					m.ParentType = Model.Entities.ObjectType.Event;
					m.ParentK = CurrentEvent.K;
					m.DuplicateGuid = Guid.NewGuid();
					m.Review = true;
					m.PostingUsr = Usr.Current;
					Thread.MakerReturn r = m.Post();

					threadK = r.Thread.K;

				}
				else
				{

					CurrentThread.Subject = Cambro.Web.Helpers.StripHtml(SummaryTextBox.Text);
					CurrentThread.FirstComment.Text = ReviewHtml.GetHtml();
					CurrentThread.FirstComment.Update();
					CurrentThread.FirstComment.IsEdited = true;
					CurrentThread.FirstComment.EditDateTime = DateTime.Now;
					CurrentThread.Update();

					threadK = CurrentThread.K;
				}
				Usr.Current.AttendEvent(CurrentEvent.K, true, null, null);
				Thread t = new Thread(threadK);
				Response.Redirect(t.Url());
			}
		}