void SavePackageTask(TaskRecordEntity taskRecord, int number, ConfigTaskEntity taskConfig, string zoneId = "", DbTransaction trans = null) { if (taskRecord == null || taskConfig == null) { return; } if (taskRecord.Status != 0) { return; } if (taskRecord.CurTimes < number) { taskRecord.CurTimes = number; if (taskRecord.CurTimes >= taskConfig.Times) { taskRecord.Status = 1; } taskRecord.UpdateTime = DateTime.Now; TaskRecordMgr.Update(taskRecord, trans, zoneId); } }
private PopMessageEntity Handler(TaskRecordEntity entity, EnumTaskRequireFunc requireType, int count, int subParam = 0, int thirdParam = 0, string doneKey = "", bool sendByChat = false) { try { if (entity.Status == (int)EnumTaskStatus.Done || entity.Status == (int)EnumTaskStatus.Pending) { return(null); } byte[] doneParam = entity.DoneParam; string stepRecord = entity.StepRecord; int oldTimes = entity.CurTimes; int curTimes = entity.CurTimes; int status = entity.Status; if (doTaskHandler(entity.ManagerId, entity.TaskId, count, ref doneParam, ref stepRecord, ref curTimes, ref status, requireType, subParam, thirdParam, doneKey)) { entity.DoneParam = doneParam; entity.StepRecord = stepRecord; entity.CurTimes = curTimes; entity.Status = status; if (TaskRecordMgr.Update(entity)) { //if (status == (int)EnumTaskStatus.Done) //{ // return ChatHelper.SendTaskFinishPop(entity.ManagerId, entity.TaskId, sendByChat); //} //else if (curTimes != oldTimes) //{ // return ChatHelper.SendTaskProgressPop(entity.ManagerId, entity.TaskId, curTimes, sendByChat); //} } } } catch (Exception ex) { SystemlogMgr.Error("Task Handler", ex); } return(null); }
/// <summary> /// 更新最高杯赛排名 /// </summary> /// <param name="managerId"></param> /// <param name="rank"></param> /// <returns></returns> public MessageCode UpdateDailyCupRank(Guid managerId, int rank) { if (rank == 0) { return(MessageCode.Success); } var taskRecord = TaskRecordMgr.GetManagerTaskList(managerId); if (taskRecord == null || taskRecord.Count == 0) { return(MessageCode.Success); } foreach (var item in taskRecord) { var task = CacheFactory.TaskConfigCache.GetTask(item.TaskId); if (task == null) { continue; } var require = CacheFactory.TaskConfigCache.GetTaskByRequire(item.TaskId); if (require == null) { continue; } if (require.RequireType == (int)EnumTaskRequireFunc.DailyCupRank) { if (rank <= require.RequireSub) { item.CurTimes = rank; item.UpdateTime = DateTime.Now; item.Status = 1; TaskRecordMgr.Update(item); } } } return(MessageCode.Success); }
/// <summary> /// 更新成就背包 /// </summary> /// <param name="managerId">经理ID</param> /// <param name="isOddDays">是否是单日</param> /// <param name="type">任务类型</param> /// <param name="isRank">是否是排名</param> /// <param name="isClear">是否清空数据</param> /// <param name="curTime">数量</param> /// <param name="isOverlay">是否叠加</param> /// <param name="reqsub">二级类型</param> /// <param name="reqthird">三级类型</param> /// <param name="overstate">四级类型</param> public void UpdateAchievementTaskPackage(Guid managerId, bool isOddDays, EnumTaskRequireFunc type, bool isRank, bool isClear, int curTime, bool isOverlay, int reqsub = 0, int reqthird = 0, int overstate = 0, List <TaskRecordEntity> taskRecord = null, DbTransaction trans = null) { var taskList = CacheFactory.TaskConfigCache.GetAchievementTask(type, reqsub, reqthird, overstate); if (taskRecord == null) { taskRecord = TaskRecordMgr.GetManagerTaskList(managerId); } bool isUpdate = true; foreach (var item in taskRecord) { try { if (item.Status != 0) { continue; } if (!taskList.Exists(r => r.TaskId == item.TaskId)) { continue; } var taskConfig = CacheFactory.TaskConfigCache.GetTask(item.TaskId); if (taskConfig == null) { continue; } if (isOddDays) { if (item.UpdateTime.Date != DateTime.Now.Date) { item.CurTimes = 0; } } if (isOverlay) { item.CurTimes += curTime; } else { if (isRank) { if (item.CurTimes > curTime) { item.CurTimes = curTime; } else { isUpdate = false; } } else { if (item.CurTimes < curTime) { item.CurTimes = curTime; } else { isUpdate = false; } } } if (isClear) { item.CurTimes = 0; } if (taskConfig.Times <= item.CurTimes) { item.Status = 1; if (item.CurTimes > taskConfig.Times) { item.CurTimes = taskConfig.Times; } } item.UpdateTime = DateTime.Now; if (isUpdate) { TaskRecordMgr.Update(item, trans); } } catch (Exception ex) { SystemlogMgr.Error("增加成就任务记录", ex); } } }