public ActionResult CSaveForm(CCardEntity entity) { try { var user = OperatorProvider.Provider.Current(); var Bll = new CarcOrCardBLL(); var list = new List <CCardEntity>(); list.Add(entity); Bll.CSaveForm(list, user.UserId); return(Success("操作成功。")); } catch (Exception ex) { return(Error(ex.Message)); } }
/// <summary> /// card to carc /// </summary> public CarcEntity ToCard(CCardEntity entity) { var rEntity = new CarcEntity(); rEntity.CDangerousList = entity.CDangerousList; foreach (var item in rEntity.CDangerousList) { item.Cid = null; item.Id = null; foreach (var CMeasure in item.Measure) { CMeasure.Id = null; CMeasure.Cmid = null; } } rEntity.Id = null; rEntity.WorkArea = entity.WorkArea; rEntity.WorkName = entity.WorkName; rEntity.MainOperation = entity.MainOperation; rEntity.DataType = "carc"; return(rEntity); }
private List <CCardEntity> GetData(Worksheet sheet, int titleIndex, string userid) { var userbll = new UserBLL(); var user = userbll.GetEntity(userid); var deptBll = new DepartmentBLL(); var allDept = deptBll.GetAll(); var total = 0; var deptuser = userbll.GetList(user.DepartmentId, 10000, 1, out total); var result = new List <CCardEntity>(); for (int i = titleIndex + 1; i <= sheet.Cells.MaxDataRow; i++) { var workname = sheet.Cells[i, 1].StringValue; if (string.IsNullOrEmpty(workname)) { throw new Exception(string.Format("行 {0} 工作任务为空!", i + 1)); } var deptList = sheet.Cells[i, 2].StringValue; if (string.IsNullOrEmpty(deptList)) { throw new Exception(string.Format("行 {0} 部门为空!", i + 1)); } foreach (var item in deptList.Split(',')) { if (string.IsNullOrEmpty(item)) { continue; } var entity = new CCardEntity(); entity.WorkName = workname; var ck = allDept.FirstOrDefault(x => x.FullName == item); if (ck == null) { throw new Exception(string.Format("行 {0} 部门不存在!", i + 1)); } var getEntity = result.FirstOrDefault(x => x.WorkName == entity.WorkName && x.DeptName == item); if (getEntity == null) { entity.DeptId = ck.DepartmentId; entity.DeptCode = ck.EnCode; entity.DeptName = ck.FullName; #region var job = getNewData(userid, entity.DeptId); var DutyNameList = sheet.Cells[i, 3].StringValue; if (string.IsNullOrEmpty(DutyNameList)) { throw new Exception(string.Format("行 {0} 岗位为空!", i + 1)); } var DutyId = string.Empty; foreach (var duty in DutyNameList.Split(',')) { if (string.IsNullOrEmpty(duty)) { continue; } var ckduty = job.FirstOrDefault(x => x.FullName == duty); if (ckduty == null) { throw new Exception(string.Format("行 {0} 岗位不存在!", i + 1)); } DutyId += ckduty.RoleId + ","; } DutyId = DutyId.Substring(0, DutyId.Length - 1); entity.DutyId = DutyId; entity.DutyName = DutyNameList; var WorkArea = sheet.Cells[i, 4].StringValue; //if (string.IsNullOrEmpty(WorkArea)) //{ // throw new Exception(string.Format("行 {0} 区域为空!", i + 1)); //} entity.WorkArea = WorkArea; var MainOperation = sheet.Cells[i, 5].StringValue; if (string.IsNullOrEmpty(MainOperation)) { throw new Exception(string.Format("行 {0} 主要步骤为空!", i + 1)); } entity.MainOperation = MainOperation; var dangers = new CDangerousEntity(); var DangerName = sheet.Cells[i, 6].StringValue; if (string.IsNullOrEmpty(DangerName)) { throw new Exception(string.Format("行 {0} 危害名称为空!", i + 1)); } dangers.DangerName = DangerName; var DangerSource = sheet.Cells[i, 7].StringValue; if (string.IsNullOrEmpty(DangerName)) { throw new Exception(string.Format("行 {0} 风险描述为空!", i + 1)); } dangers.DangerSource = DangerSource; var Measurelist = sheet.Cells[i, 8].StringValue; if (string.IsNullOrEmpty(Measurelist)) { throw new Exception(string.Format("行 {0} 采取的控制措施为空!", i + 1)); } dangers.Measure = new List <CMeasureEntity>(); foreach (var Measures in Measurelist.Split('\n')) { if (string.IsNullOrEmpty(Measures)) { continue; } var Measure = new CMeasureEntity(); Measure.Measure = Measures; dangers.Measure.Add(Measure); } entity.CDangerousList = new List <CDangerousEntity>(); entity.CDangerousList.Add(dangers); #endregion result.Add(entity); } else { var dangers = new CDangerousEntity(); var DangerName = sheet.Cells[i, 6].StringValue; if (string.IsNullOrEmpty(DangerName)) { throw new Exception(string.Format("行 {0} 危害名称为空!", i + 1)); } dangers.DangerName = DangerName; var DangerSource = sheet.Cells[i, 7].StringValue; if (string.IsNullOrEmpty(DangerName)) { throw new Exception(string.Format("行 {0} 风险描述为空!", i + 1)); } dangers.DangerSource = DangerSource; var Measurelist = sheet.Cells[i, 8].StringValue; if (string.IsNullOrEmpty(Measurelist)) { throw new Exception(string.Format("行 {0} 采取的控制措施为空!", i + 1)); } dangers.Measure = new List <CMeasureEntity>(); foreach (var Measures in Measurelist.Split('\n')) { if (string.IsNullOrEmpty(Measures)) { continue; } var Measure = new CMeasureEntity(); Measure.Measure = Measures; dangers.Measure.Add(Measure); } getEntity.CDangerousList.Add(dangers); } } } return(result); }