public List <UserCampLog> GetUserCampLogList(ref DataPage dp, UserCampLog searchUserCampLog) { Expression <Func <UserCampLog, bool> > exp = CreateDydaminWhereAndExpression <UserCampLog>(searchUserCampLog); List <UserCampLog> list = GetEntityQueryList(ref dp, exp, p => p.LogId); List <UserCampLog> resultlist = list.Select(p => new UserCampLog { UserId = p.UserId, AreaId = p.AreaId, AvatarId = p.AvatarId, Sex = p.Sex, CampId = p.CampId, AvatarName = p.AvatarName, LogId = p.LogId, CreateTime = p.CreateTime, LoginName = p.LoginName }).ToList <UserCampLog>(); return(resultlist); }
public List <UserCampLog> GetUserCampLogList(ref DataPage dp, UserCampLog searchUserCampLog) { _admin = new CampEventsAdminService.CampEventsAdminServiceClient(); List <UserCampLog> lists = new List <UserCampLog>(); try { lists = _admin.GetUserCampLogList(ref dp, searchUserCampLog); _admin.Close(); return(lists); } catch (Exception ex) { _admin.CloseCatch(ex, "GetUserCampLogList failed"); return(lists); } }
/// <summary> /// 列表 /// </summary> /// <param name="searchSort">用来搜索的实例</param> /// <returns></returns> public ActionResult UserCampLogList(DataPage dp, UserCampLog model) { model.CreateTime = defaultDate; List <UserCampLog> lists = new List <UserCampLog>(); if (Request["btnExportExcel"] == null)//导出Excel { lists = CampEventsBll.GetUserCampLogList(ref dp, model); GetDataPage(dp); } else { dp.PageSize = 0; lists = CampEventsBll.GetUserCampLogList(ref dp, model); string fileName = "nothing"; if (lists.Count() > 0) { fileName = "UserCampLogList" + lists.Count() + "_Item"; } Dictionary <string, Func <UserCampLog, string> > showFields = new Dictionary <string, Func <UserCampLog, string> >(); showFields.Add("LogId", z => "'" + z.LogId.ToString()); showFields.Add("UserId", z => "'" + z.UserId.ToString()); showFields.Add("LoginName", z => "'" + z.LoginName.ToString()); showFields.Add("AreaId", z => "'" + z.AreaId.ToString()); showFields.Add("AvatarId", z => "'" + z.AvatarId.ToString()); showFields.Add("AvatarName", z => "'" + z.AvatarName.ToString()); showFields.Add("Sex", z => "'" + z.Sex.ToString()); showFields.Add("CampId", z => "'" + z.CampId.ToString()); showFields.Add("CreateTime", z => "'" + z.CreateTime.ToString()); ObjectUtil.Common.ExcelHelper2 <UserCampLog> elh = new ObjectUtil.Common.ExcelHelper2 <UserCampLog>(lists, null, showFields); elh.FileWebSaveAs(Response, fileName); } //记录日志 Log(string.Format("查看[UserCampLog]列表页面 搜索数据:{0}", model.ToString())); return(View(lists)); }
public ResultInfo UserChooseCamp(UserInfo userinfo) { string source = "ChooseCamp"; ResultInfo resultinfo = new ResultInfo() { Result = ErrorCode.JoinCampFailed }; bool IsExists = ctx.UserCampLogs.Any(p => p.AreaId == userinfo.AreaId && p.AvatarId == userinfo.AvatarId && p.UserId == userinfo.UserId); bool CampIsExists = ctx.CampConfigs.Any(p => p.CampId == userinfo.CampId); int LoginPoints = ctx.DailyTaskConfigs.Where(p => p.TaskConfigId == 1).Select(p => p.GetPoints).SingleOrDefault(); if (IsExists) { resultinfo.Result = ErrorCode.RepeatJoinFailed; return(resultinfo); } if (LoginPoints < 1 || !CampIsExists) { resultinfo.Result = ErrorCode.CampErrorFailed; return(resultinfo); } int FirstCampPeople = ctx.CampConfigs.Where(p => p.CampId == userinfo.CampId).Select(p => p.CurrentPeople).SingleOrDefault(); long FirstCampPoints = ctx.CampConfigs.Where(p => p.CampId == userinfo.CampId).Select(p => p.CurrentPoints).SingleOrDefault(); int SecondCampPeople = ctx.CampConfigs.Where(p => p.CampId != userinfo.CampId).Select(p => p.CurrentPeople).SingleOrDefault(); //阵营相差人数上限(对比人数差) int PeopleNumLimit = ctx.BasicConfigs.Where(p => p.BasicId == 1).Select(p => p.ConfigValue).SingleOrDefault(); //阵营人数调整起始值(对比总人数) int PeopleAdjustNum = ctx.BasicConfigs.Where(p => p.BasicId == 2).Select(p => p.ConfigValue).SingleOrDefault(); //总人数 int TotalPeople = FirstCampPeople + SecondCampPeople; //人数差 int PeopleDiff = System.Math.Abs(FirstCampPeople - SecondCampPeople); if (PeopleDiff > PeopleNumLimit && TotalPeople > PeopleAdjustNum && FirstCampPeople > SecondCampPeople) { resultinfo.Result = ErrorCode.CampLimitFailed; return(resultinfo); } UserCampLog usercamplog = new UserCampLog() { UserId = userinfo.UserId, AreaId = userinfo.AreaId, AvatarId = userinfo.AvatarId, CampId = userinfo.CampId, LoginName = userinfo.LoginName, Sex = userinfo.Sex, AvatarName = userinfo.AvatarName }; ctx.UserCampLogs.Add(usercamplog); Wallet wallet = new Wallet() { UserId = userinfo.UserId, AreaId = userinfo.AreaId, AvatarId = userinfo.AvatarId, AvatarName = userinfo.AvatarName, CampId = userinfo.CampId, RecordDate = System.DateTime.Now, Source = source, BalancePoints = LoginPoints, DailyGetPoints = LoginPoints, FromId = usercamplog.LogId, FinishedTaskNum = 1 }; ctx.Wallets.Add(wallet); using (DbContextTransaction ts = ctx.Database.BeginTransaction()) { int joinrs = ctx.SaveChanges(); if (joinrs == 2) { int updaters = ctx.CampConfigs.Where(p => p.CampId == usercamplog.CampId && p.CurrentPeople == FirstCampPeople && p.CurrentPoints == FirstCampPoints).Update(p => new CampConfig { CurrentPeople = FirstCampPeople + 1, CurrentPoints = FirstCampPoints + LoginPoints }); if (updaters == 1) { ts.Commit(); resultinfo.Result = ErrorCode.Succuess; return(resultinfo); } else { ts.Rollback(); resultinfo.Result = ErrorCode.JoinCampFailed; return(resultinfo); } } } return(resultinfo); }
public List <UserCampLog> GetUserCampLogList(ref DataPage dp, UserCampLog searchUserCampLog) { return(_dal.GetUserCampLogList(ref dp, searchUserCampLog)); }