예제 #1
0
 public void AddLog(int Id, string log, ResourceLogType type)
 {
     Task.Factory.StartNew(() =>
     {
         var model = new H_ResourceLogModel
         {
             Id              = 0,
             RLAddDepartId   = 0,
             RLAddDepartName = "",
             RLAddId         = 0,
             RLAddName       = "",
             RLAddTime       = DateTime.Now,
             RLLogType       = type.GetHashCode(),
             RLOutId         = Id,
             RLRemark        = log
         };
         this.Add(model);
     });
 }
예제 #2
0
 public static void LogOp(this Entities db, Guid userId, Guid campusId, ResourceLogType logType, int? value = null)
 {
     var today = DateTime.Today;
     var year = today.Year;
     var month = today.Month;
     var count = db.ResourceLog.Count(o => o.Year == year && o.Month == month && o.Id == userId);
     if (count == 0)
     {
         db.ResourceLog.Add(new ResourceLog
         {
             Id = userId,
             Year = year,
             Month = month,
             Article = 0,
             Courseware = 0,
             Paper = 0,
             Media = 0,
             View = 0,
             Favourite = 0,
             Download = 0,
             Comment = 0,
             Reply = 0,
             Rate = 0,
             Credit = 0,
             TimeStamp = DateTime.Now,
             CampusId = campusId
         });
         db.SaveChanges();
     }
     var ops = db.ResourceLog.First(o => o.Year == year && o.Month == month && o.Id == userId);
     var dict = db.Dictionary.ToList();
     switch (logType)
     {
         case ResourceLogType.下载资源:
             ops.Download++;
             break;
         case ResourceLogType.个人积分:
             ops.Credit += value ?? 0;
             break;
         case ResourceLogType.发布文章:
             ops.Article++;
             ops.Credit += int.Parse(dict.First(o => o.Key == "CreditPublish").Value);
             break;
         case ResourceLogType.发布视频:
             ops.Media++;
             ops.Credit += int.Parse(dict.First(o => o.Key == "CreditPublish").Value);
             break;
         case ResourceLogType.发布试卷:
             ops.Paper++;
             ops.Credit += int.Parse(dict.First(o => o.Key == "CreditPublish").Value);
             break;
         case ResourceLogType.发布课件:
             ops.Courseware++;
             ops.Credit += int.Parse(dict.First(o => o.Key == "CreditPublish").Value);
             break;
         case ResourceLogType.回复评论:
             ops.Reply++;
             ops.Credit += int.Parse(dict.First(o => o.Key == "CreditReply").Value);
             break;
         case ResourceLogType.收藏资源:
             ops.Favourite++;
             ops.Credit += int.Parse(dict.First(o => o.Key == "CreditFavourite").Value);
             break;
         case ResourceLogType.浏览资源:
             ops.View++;
             break;
         case ResourceLogType.评定资源:
             ops.Rate++;
             ops.Credit += int.Parse(dict.First(o => o.Key == "CreditRate").Value);
             break;
         case ResourceLogType.评论资源:
             ops.Comment++;
             ops.Credit += int.Parse(dict.First(o => o.Key == "CreditComment").Value);
             break;
     }
     db.SaveChanges();
 }
예제 #3
0
 protected void LogOp(ResourceLogType type, int? value = null)
 {
     if (!IsOnline)
         return;
     try
     {
         HomoryContext.Value.LogOp(CurrentUser.Id, CurrentCampus.Id, type, value);
     }
     catch
     {
     }
 }
예제 #4
0
 protected void LogOp(ResourceLogType type, int? value = null)
 {
     HomoryContext.Value.LogOp(CurrentUser.Id, CurrentCampus.Id, type, value);
 }