示例#1
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);
				}

			}
		}
示例#2
0
		public string LolUsrListHtml(out bool me, int meK)
		{
			me = false;
			if (this.LolCount > 0)
			{			
				StringBuilder sb = new StringBuilder();

				Query q = new Query();
				q.QueryCondition = new Q(Lol.Columns.CommentK, this.K);
				q.TableElement = new Join(Lol.Columns.UsrK, Usr.Columns.K);
				q.Columns = Usr.LinkColumns;
				q.NoLock = true;
				q.OrderBy = new OrderBy(Lol.Columns.DateTime, OrderBy.OrderDirection.Descending);
				q.TopRecords = 100;
				UsrSet us = new UsrSet(q);
				for (int i = 0; i < us.Count; i++)
				{
					if (us[i].K == meK)
						me = true;

					sb.Append("<a href=\"");
					sb.Append(us[i].Url());
					sb.Append("\"");
					sb.Append(us[i].Rollover);
					sb.Append(">");
					sb.Append(us[i].NickNameSafe);
					sb.Append("</a>");
					//txt += "<a href=\"" + us[i].Url() + "\"" + us[i].Rollover + ">" + us[i].NickNameSafe + "</a>";

					if (i == us.Count - 2)
						sb.Append(" and ");
					//txt += " and ";
					else if (i != us.Count - 1)
						sb.Append(", ");
						//txt += ", ";
				}
				if (!me && this.LolCount > 100)
				{
					LolSet meLol = new LolSet(new Query(new And(new Q(Lol.Columns.CommentK, this.K), new Q(Lol.Columns.UsrK, meK))));
					me = meLol.Count > 0;
				}
				if (sb.Length > 0)
				{
					if (this.LolCount > 100)
					{
						sb.Insert(0, " people laughed at this - the latest are: ");
						sb.Insert(0, this.LolCount.ToString("#,##0"));
						sb.Append("<br>");
						//this.LolCount.ToString("#,##0") + " people laughed at this - the latest are: " + txt + "<br>";
					}
					else
					{
						sb.Insert(0, "Who laughed: ");
						sb.Append("<br>");
						//txt = "Who laughed: " + txt + "<br>";
					}
				}
				return sb.ToString();
				
			}
			else
				return string.Empty;
		}