public IHttpActionResult GetTaskUserNodeList([FromBody] TaskUserNodeFilter filter) { if (filter.TaskID == Guid.Empty) { throw new BizException("参数错误"); } var dataCollectList = DataCollectUserOperator.Instance.GetListWithLastTask(new VCollectUserFilter() { TemplateConfigInstanceID = filter.TaskID.ToString() }); var pendingCount = 0; var dataList = dataCollectList.SubCollection.FindAll(x => { var statusExist = false; if (filter.Status == 0) { statusExist = true; } else if (filter.Status == 1) { statusExist = x.Status == 2; } else { statusExist = x.Status != 2; } pendingCount += x.Status != 2 ? 1 : 0; return //状态还没加上 等老吴签入修改了实体类以后进行 (statusExist && (string.IsNullOrEmpty(filter.LoginOrName) || x.UserName.IndexOf(filter.LoginOrName) >= 0 || x.EmployeeName.IndexOf(filter.LoginOrName) >= 0)); }); return(BizResult( new { Nodes = dataList.Select(x => { var userNode = new TaskUserNode(); userNode.ConvertEntity(x); return userNode; }).ToList(), Total = dataCollectList.SubCollection.Count, Pending = pendingCount })); }
public IHttpActionResult ImportTaskUserNode(string businessid) { Guid ret = Guid.Empty; if (string.IsNullOrEmpty(businessid) || !Guid.TryParse(businessid, out ret)) { throw new BizException("参数错误"); } var finder = TemplateConfigInstanceOperator.Instance.GetModel(businessid); if (finder != null) { Helper.Common.CommonValidation.ValidateRoleRight(finder.CreatorLoginName); } var request = HttpContext.Current.Request; var setting = AttachmentOperator.Instance.CommonSetting(); var model = AttachmentOperator.Instance.CommonUpload(businessid, setting.Item1, setting.Item2, setting.Item3); var importLength = 0; var successLength = 0; var errorLength = 0; var repeatLength = 0; var dataStatus = 0; var dataStatusMsg = ""; var successUserList = new List <TaskUserNode>(); var errorDataList = new List <Entity <string> >(); var repeatUserList = new List <LoginUserInfo>(); try { var collectUserList = DataCollectUserOperator.Instance.GetList(businessid).ToList(); //批量追加任务人员 //解析上传上来的excel文件 获取第一列所有的行(不包含表头) Workbook book = new Workbook(setting.Item3); var sheet = book.Worksheets[0]; List <string> accountList = new List <string>(); for (int i = 0; i <= sheet.Cells.MaxDataRow; i++) { var cell = sheet.Cells[i, 0]; var cellValue = cell.StringValue.ToLower(); if (!string.IsNullOrEmpty(cellValue) && !accountList.Contains(cellValue)) { accountList.Add(cell.StringValue); } } var loginUserList = UserInfoOperator.Instance.GetWDUserInfoByLoginNameList(accountList); errorDataList = accountList.Where(x => loginUserList.All(e => e.LoginName.ToLower() != x.ToLower())).Select(x => { var entity = new Entity <string> { Data = "用户不存在", Message = "用户不存在", Status = -1 }; return(entity); }).ToList(); repeatUserList = loginUserList.Where(x => collectUserList.Any(t => t.UserName.ToLower() == x.LoginName)) .ToList(); successUserList = loginUserList.Where( x => repeatUserList.All(t => t.LoginName.ToLower() != x.LoginName.ToLower()) ).Select(x => { TaskUserNode node = new TaskUserNode(); node.ApproveDate = null; node.BusinessID = null; node.ReceiveDate = null; node.TaskUserDeparment = x.UnitName; node.TaskUserLoginName = x.LoginName; node.TaskUserName = x.CNName; node.TaskUserPosition = x.jobName; return(node); }).ToList(); importLength = accountList.Count; successLength = successUserList.Count; errorLength = errorDataList.Count; repeatLength = repeatUserList.Count; dataStatus = 1; dataStatusMsg = "解析成功"; } catch (Exception ex) { dataStatus = 0; dataStatusMsg = ex.Message; } var data = new { status = dataStatus, importlength = importLength, successlength = successLength, errorlength = errorLength, repeatlength = repeatLength, successuserlist = successUserList, errordatalist = errorDataList, repeatuserlist = repeatUserList, statusmsg = dataStatusMsg }; return(BizResult(data)); }