当前位置: 首页>>代码示例>>C#>>正文


C# Thread.UrlDiscussion方法代码示例

本文整理汇总了C#中System.Thread.UrlDiscussion方法的典型用法代码示例。如果您正苦于以下问题:C# Thread.UrlDiscussion方法的具体用法?C# Thread.UrlDiscussion怎么用?C# Thread.UrlDiscussion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Thread的用法示例。


在下文中一共展示了Thread.UrlDiscussion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

		protected override void Execute()
		{
			Thread thread = new Thread(ThreadK.Value);
			if (thread.GroupK == 0)
				throw new Exception("Can't send group news emails - thread not in a group!");

			if (!thread.IsNews)
				throw new Exception("Can't send group news emails - thread is not news!");

			Query q = new Query();
			q.TableElement = new TableElement(TablesEnum.Usr);
			q.TableElement = new Join(
				q.TableElement,
				new TableElement(TablesEnum.ThreadUsr),
				QueryJoinType.Left,
				new And(new Q(Usr.Columns.K, ThreadUsr.Columns.UsrK, true), new Q(ThreadUsr.Columns.ThreadK, thread.K)));
			q.TableElement = new Join(
				q.TableElement,
				new TableElement(TablesEnum.GroupUsr),
				QueryJoinType.Inner,
				new And(new Q(Usr.Columns.K, GroupUsr.Columns.UsrK, true), new Q(GroupUsr.Columns.GroupK, thread.GroupK), new Q(GroupUsr.Columns.Status, GroupUsr.StatusEnum.Member)));
			q.QueryCondition = new Q(ThreadUsr.Columns.UsrK, QueryOperator.IsNull, null);
			q.Columns = new ColumnSet(
				Usr.EmailColumns,
				Usr.LinkColumns,
				Usr.Columns.IsLoggedOn,
				Usr.Columns.DateTimeLastPageRequest);
			UsrSet us = new UsrSet(q);

			foreach (Usr u in us)
			{
				ThreadUsr tu = thread.GetThreadUsr(u);
				if (tu.IsNew)
				{
					tu.ChangeStatus(ThreadUsr.StatusEnum.NewGroupNewsAlert, DateTime.Now, false, false);
					tu.StatusChangeObjectK = thread.GroupK;
					tu.StatusChangeObjectType = Model.Entities.ObjectType.Group;
					tu.InvitingUsrK = thread.NewsUsrK;
					tu.Update();

					try
					{
						Mailer usrMail = new Mailer();
						usrMail.Subject = "New news in " + thread.Group.FriendlyName + ": \"" + thread.SubjectSnip(40) + "\"";
						usrMail.Body += "<h1>New news in " + thread.Group.FriendlyName + "</h1>";
						usrMail.Body += "<p>The subject is: \"" + thread.Subject + "\"</p>";
						usrMail.Body += "<p>To read and reply, check out the <a href=\"[LOGIN]\">topic page</a>.</p>";
						usrMail.Body += "<p>If you want to stop getting news alerts for the <i>" + thread.Group.FriendlyName + "</i> group, click the 'Exit this group' button on the <a href=\"[LOGIN(" + thread.Group.Url() + ")]\">group homepage</a>.</p>";
						usrMail.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
						usrMail.RedirectUrl = thread.UrlDiscussion();
						usrMail.UsrRecipient = u;
						usrMail.Bulk = true;
						usrMail.Inbox = true;
						usrMail.Send();
					}
					catch (Exception ex) { Global.Log("e96aef2f-ac6d-4f2f-af84-a67c8e53a638", ex); }

					//try
					//{
					//    if (u.IsLoggedOn && u.DateTimeLastPageRequest > DateTime.Now.AddMinutes(-5))
					//    {
					//        XmlDocument xmlDoc = new XmlDocument();
					//        XmlNode n = xmlDoc.CreateElement("groupNewsAlert");
					//        n.AddAttribute("groupName", thread.Group.Name);
					//        n.AddAttribute("groupUrl", thread.Group.Url());
					//        if (thread.Group.HasPic)
					//            n.AddAttribute("pic", thread.Group.Pic.ToString());
					//        else
					//            n.AddAttribute("pic", "0");
					//        n.AddAttribute("subject", thread.SubjectSnip(50));
					//        n.InnerText = thread.UrlDiscussion();

					//        Chat.SendChatItem(ItemType.GroupNewsAlert, n, DateTime.Now.Ticks, u.K, Guid.NewGuid());



					//        //u.AddChatItem(ChatMessage.ItemTypes.GroupNewsAlert,n,DateTime.Now.Ticks);
					//        //Usr.AddChatItemStatic(ChatMessage.ItemTypes.GroupNewsAlert, n, DateTime.Now.Ticks, Guid.NewGuid(), u.K);
					//    }
					//}
					//catch (Exception ex) { Global.Log("39af266c-ad5e-4ddb-b32c-d1bbad0b5189", ex); }
				}
			}
		}
开发者ID:davelondon,项目名称:dontstayin,代码行数:84,代码来源:SendNewsAlertsJob.cs


注:本文中的System.Thread.UrlDiscussion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。