/// <summary> /// 作者:Vincen /// 时间:2014.03.28 /// 描述:创建教室 /// </summary> /// <param name="model"></param> /// <param name="createBy"></param> /// <returns></returns> public static bool CreateClassroom(Classroom model, int createBy) { using (var edb = new EmeEntities()) { try { edb.Entry(model).State = EntityState.Added; var result = edb.SaveChanges() > 0; return result; } catch (Exception e) { Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Message), Message = string.Format("BranchBLL-CreateClassroom:{0};{1};{2}", e.Message, e.InnerException, e.HelpLink), IsTreat = false, UserHostAddress = WebHelper.GetCurrentIpAddress(), CreateBy = createBy, CreateTime = DateTime.Now }); return false; } } }
public ActionResult ClassroomCreate(FormCollection fc) { var branchId = Utility.CommonHelper.To<int>(fc["ClassroomCreateBranchId"]); var classroomTypeId = Utility.CommonHelper.To<int>(fc["ClassroomCreateClassroomType"]); var classroomName = fc["ClassroomCreateClassroomName"]; var maxBookNum = Utility.CommonHelper.To<int>(fc["ClassroomCreateMaxBookNum"]); var status = Utility.CommonHelper.To<int>(fc["ClassroomCreateClassroomStatus"]); var renewTime = Utility.CommonHelper.To<DateTime?>(fc["ClassroomCreateRenewTime"]); var model = new Classroom() { BranchId = branchId, ClassroomTypeId = classroomTypeId, ClassroomName = classroomName, MaxBookNum = maxBookNum, Status = status, RenewTime = renewTime, //CreateBy= CreateTime = DateTime.Now }; var result = BranchBLL.CreateClassroom(model, LoginUserManager.CurrLoginUser.UserId); if (result) { WebCommon.Cache.ClassroomCache.SetClassroomCache(model); WebCommon.Cache.ClassroomCache.UpdateClassroomListCache(model); } var search = new SearchClassroomModel() { BranchId = branchId }; return ClassroomList(search, 1); }
/// <summary> /// 作者:Vincen /// 时间:2014.03.28 /// 描述:更新教室列表缓存 /// </summary> /// <param name="room"></param> public static void UpdateClassroomListCache(Classroom room) { if (null == room) { return; } var key = string.Format("{0}{1}", Klist, room.BranchId); var keyList = Icache.Get<List<string>>(key) ?? new List<string>(); ; if (!keyList.Any(p => p.Equals(string.Format("{0}", room.Id)))) { keyList.Add(string.Format("{0}", room.Id)); } Icache.Set(key, keyList, 180 * 24 * 60); }
/// <summary> /// 作者:Vincen /// 时间:2014.04.27 /// 描述:更新教室缓存 /// </summary> /// <param name="room"></param> public static void UpdateClassroomCache(Classroom room) { if (room != null) { Icache.Set(string.Format("{0}{1}", Kword, room.Id), room, 180 * 24 * 60); } }
/// <summary> /// 作者:Vincen /// 时间:2014.04.27 /// 描述:设置教室缓存 /// </summary> /// <param name="room"></param> public static void SetClassroomCache(Classroom room) { if (null == room) return; if (!Icache.IsSet(string.Format("{0}{1}", Kword, room.Id))) { Icache.Set(string.Format("{0}{1}", Kword, room.Id), room, 180 * 24 * 60); } }
/// <summary> /// 作者:Vincen /// 时间:2014.03.28 /// 描述:更新教室 /// </summary> /// <param name="model"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool UpdateClassroom(Classroom model, int loginUserId) { using (var edb = new EmeEntities()) { try { var modelObj = edb.Classroom.FirstOrDefault(p => p.Id == model.Id); if (null == modelObj) return false; modelObj.ClassroomTypeId = model.ClassroomTypeId; modelObj.ClassroomName = model.ClassroomName; modelObj.MaxBookNum = model.MaxBookNum; modelObj.Status = model.Status; modelObj.RenewTime = model.RenewTime; modelObj.UpdateTime = model.UpdateTime; modelObj.UpdateBy = loginUserId; edb.Entry(modelObj).State = EntityState.Modified; var result = edb.SaveChanges() > 0; return result; } catch (Exception e) { Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Message), Message = string.Format("BranchBLL-UpdateClassroom:{0};{1};{2}", e.Message, e.InnerException, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }