public ActionResult SubmitFormForWeek(Timesheet.TimesheetForWeek tsfw, string comment) { var us = GetUserTeamId(); if (us == -1) { return(Json(new { success = false, message = "请先在个人设置中设置科室!" }, JsonRequestBehavior.AllowGet)); } if (tsfw != null && tsfw.TimesheetList != null && tsfw.TimesheetList.Count > 0) { var operateTime = DateTime.Now; var startDate = tsfw.TimesheetList.Min(ts => ts.TimesheetDate).Value.ToString("yyyy-MM-dd"); var endDate = tsfw.TimesheetList.Max(ts => ts.TimesheetDate).Value.ToString("yyyy-MM-dd"); var newWorkflowInstanceID = string.Empty; Dictionary <string, string> approverWFIDList = new Dictionary <string, string>(); foreach (var ts in tsfw.TimesheetList) { var nextOperator = GetNextOperator(ts); if (approverWFIDList.ContainsKey(nextOperator)) { newWorkflowInstanceID = approverWFIDList[nextOperator]; } else { newWorkflowInstanceID = Guid.NewGuid().ToString(); approverWFIDList.Add(nextOperator, newWorkflowInstanceID); } if (string.IsNullOrEmpty(ts.WorkflowInstanceID)) { ts.WorkflowInstanceID = newWorkflowInstanceID; } ts.Status = ApproveStatus.Approving; ts.Approver = nextOperator; ts.ApprovedTime = operateTime; AddOrEdit(ts); _alService.AddApproveLog(new ApproveLog.ApproveLog() { WorkflowInstanceID = ts.WorkflowInstanceID, OperateTime = operateTime, Comment = comment, OperateType = "提交", CurrentOperator = Common.CommonHelper.CurrentUser, NextOperator = nextOperator, Creator = Common.CommonHelper.CurrentUser, StartDate = startDate, EndDate = endDate }); } return(Json(new { success = true, message = "提交周工时数据成功!" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "需要提交周工时数据为空!" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult CommApprove(String tsIdList, string comment) { var us = _usService.GetUserSettingList().Where(p => p.UserId == CommonHelper.CurrentUser).FirstOrDefault(); if (!(us != null && us.TeamId != 0)) { return(Json(new { success = false, message = "请先在个人设置中设置科室!" }, JsonRequestBehavior.AllowGet)); } if (!string.IsNullOrEmpty(tsIdList)) { var operateTime = DateTime.Now; var idList = tsIdList.Split(','); foreach (var id in idList) { var ts = _appService.GetTimesheetsByID(int.Parse(id)); ts.Status = ApproveStatus.Approved; ts.Approver = Common.CommonHelper.CurrentUser; ts.ApprovedTime = operateTime; AddOrEdit(ts); _alService.AddApproveLog(new ApproveLog.ApproveLog() { WorkflowInstanceID = ts.WorkflowInstanceID, OperateTime = operateTime, Comment = comment, OperateType = "审批通过", CurrentOperator = Common.CommonHelper.CurrentUser, NextOperator = "", Creator = Common.CommonHelper.CurrentUser }); } return(Json(new { success = true, message = "审批通过工时数据成功!" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "需要审批通过的工时数据为空!" }, JsonRequestBehavior.AllowGet)); } }