Esempio n. 1
0
        public static JToken ToJson(ResourceComment c)
        {
            var obj = (JObject)ToJson((BaseComment)c);

            obj["type"] = "ResourceComment";
            return(obj);
        }
Esempio n. 2
0
 protected void replyReply_OnServerClick(object sender, EventArgs e)
 {
     if (!IsOnline)
     {
         SignOn();
         return;
     }
     var x = (sender as HtmlAnchor).Parent.FindControl("replyContent") as HtmlTextArea;
     var id = Guid.Parse(((sender as HtmlAnchor).Parent.FindControl("replyId") as HtmlInputHidden).Value);
     if (string.IsNullOrWhiteSpace(x.Value.Trim()))
     {
         return;
     }
     if (string.IsNullOrWhiteSpace(x.Value.Trim()))
         return;
     var c = new ResourceComment
     {
         Id = HomoryContext.Value.GetId(),
         ParentId = id,
         ResourceId = CurrentResource.Id,
         UserId = CurrentUser.Id,
         Content = x.Value.Trim(),
         Timed = false,
         Level = HomoryContext.Value.ResourceComment.First(o => o.Id == id).Level + 1,
         Time = DateTime.Now,
         State = State.启用
     };
     HomoryContext.Value.ResourceComment.Add(c);
     HomoryContext.Value.ST_Resource(CurrentResource.Id, ResourceOperationType.Comment, 1);
     CurrentResource.Comment += 1;
     var action = new Homory.Model.Action
     {
         Id = HomoryContext.Value.GetId(),
         Id1 = TargetUser.Id,
         Id2 = CurrentResource.Id,
         Id3 = CurrentUser.Id,
         Id4 = id,
         Content1 = x.Value.Trim(),
         Type = ActionType.用户回复评论,
         State = State.启用,
         Time = DateTime.Now,
     };
     HomoryContext.Value.Action.Add(action);
     LogOp(ResourceLogType.回复评论, 1);
     HomoryContext.Value.SaveChanges();
     BindComment();
 }
Esempio n. 3
0
 protected void dotSend_Click(object sender, EventArgs e)
 {
     if (!IsOnline)
     {
         SignOn();
         return;
     }
     if (string.IsNullOrWhiteSpace(dotContent.Text.Trim()))
         return;
     decimal t1, t2;
     decimal? ta, tb;
     decimal.TryParse(startDot.Text.Replace("'", ""), out t1);
     decimal.TryParse(endDot.Text.Replace("'", ""), out t2);
     if (t1 == 0 && t2 == 0)
     {
         ta = tb = (decimal?)null;
     }
     else if (t1 == 0)
     {
         ta = 0;
         tb = t2;
     }
     else if (t2 == 0)
     {
         ta = t1;
         tb = (decimal?)null;
     }
     else
     {
         ta = t1;
         tb = t2;
     }
     var c = new ResourceComment
     {
         Id = HomoryContext.Value.GetId(),
         ParentId = null,
         ResourceId = CurrentResource.Id,
         UserId = CurrentUser.Id,
         Content = dotContent.Text.Trim(),
         Start = ta,
         End = tb,
         Timed = t1 > 0 || t2 > 0,
         Level = 0,
         Time = DateTime.Now,
         State = State.启用
     };
     HomoryContext.Value.ResourceComment.Add(c);
     HomoryContext.Value.ST_Resource(CurrentResource.Id, ResourceOperationType.Comment, 1);
     CurrentResource.Comment += 1;
     var action = new Homory.Model.Action
     {
         Id = HomoryContext.Value.GetId(),
         Id1 = TargetUser.Id,
         Id2 = CurrentResource.Id,
         Id3 = CurrentUser.Id,
         Content1 = dotContent.Text.Trim(),
         Type = ActionType.用户评论资源,
         State = State.启用,
         Time = DateTime.Now,
     };
     HomoryContext.Value.Action.Add(action);
     HomoryContext.Value.SaveChanges();
     dotContent.Text = string.Empty;
     Response.Redirect(Request.Url.PathAndQuery, false);
 }
Esempio n. 4
0
 protected string FormatPeriod(ResourceComment comment)
 {
     if (!comment.Timed.HasValue || !comment.Timed.Value)
         return string.Empty;
     var s = comment.Start.Value.ToString().Split(new char[] { '.' })[0] + "秒";
     var e = " - " + (comment.End.HasValue ? comment.End.Value.ToString().Split(new char[] { '.' })[0] + "秒" : string.Empty);
     return string.Format("<a onclick=\"popup('{1}');\">{0}</a>", s + e, comment.Id);
 }
Esempio n. 5
0
 protected void doComment_OnServerClick(object sender, EventArgs e)
 {
     if (!IsOnline)
     {
         SignOn();
         return;
     }
     if (string.IsNullOrWhiteSpace(comment.Value.Trim()))
         return;
     var c = new ResourceComment
     {
         Id = HomoryContext.Value.GetId(),
         ParentId = null,
         ResourceId = CurrentResource.Id,
         UserId = CurrentUser.Id,
         Content = comment.Value.Trim(),
         Timed = false,
         Level = 0,
         Time = DateTime.Now,
         State = State.启用
     };
     HomoryContext.Value.ResourceComment.Add(c);
     HomoryContext.Value.ST_Resource(CurrentResource.Id, ResourceOperationType.Comment, 1);
     CurrentResource.Comment += 1;
     var action = new Homory.Model.Action
     {
         Id = HomoryContext.Value.GetId(),
         Id1 = TargetUser.Id,
         Id2 = CurrentResource.Id,
         Id3 = CurrentUser.Id,
         Content1 = comment.Value.Trim(),
         Type = ActionType.用户评论资源,
         State = State.启用,
         Time = DateTime.Now,
     };
     HomoryContext.Value.Action.Add(action);
     LogOp(ResourceLogType.评论资源, 1);
     HomoryContext.Value.SaveChanges();
     comment.Value = string.Empty;
     BindComment();
 }