public ActionResult Create(CheckPlanEnity model) { var resultModel = new RespResultCountViewModel(); try { if (_checkplanService.IsExistUserId(model.UserId)) { resultModel.code = -1; resultModel.msg = "该人员已有计划 请勿再次添加!"; return(Ok(resultModel)); } model.Id = ConstDefine.CreateGuid(); model.CreateTime = DateTime.Now; model.DeleteMark = 1; bool result = _checkplanService.Insert(model); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败:" + ex.Message; return(Ok(resultModel)); } }
public ActionResult Create(AllPowerfulDrugEntity model) { var resultModel = new RespResultCountViewModel(); try { AllPowerfulDrugEntity allpowerfulEntity = _mapper.Map <AllPowerfulDrugEntity>(model); allpowerfulEntity.CrowId = ConstDefine.CreateGuid(); allpowerfulEntity.DrugCode = model.DrugCode; allpowerfulEntity.DrugName = model.DrugName; allpowerfulEntity.CommonName = model.CommonName; bool result = _decisionAnalysisService.Insert(allpowerfulEntity); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "新增失败" + ex.ToString(); return(Ok(resultModel)); } }
public ActionResult CreateNotice(HiddenDangersNoticeEntity model) { var resultModel = new RespResultCountViewModel(); try { model.Id = ConstDefine.CreateGuid(); model.CreateTime = DateTime.Now; model.DeleteMark = 1; model.States = "1"; model.IsSupervisor = _hiddenService.GetIsSupervisor(model.ReportId); bool result = _hiddenService.CreateNotice(model); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败:" + ex.Message; return(Ok(resultModel)); } }
public ActionResult Create(DepartmentEntity model) { var resultModel = new RespResultCountViewModel(); try { #region 验证 if (string.IsNullOrEmpty(model.Name)) { resultModel.code = -1; resultModel.msg = "部门名称不允许为空!"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(model.OrgId)) { resultModel.code = -1; resultModel.msg = "机构代码不允许为空!"; return(Ok(resultModel)); } if (_departmentService.ExistFullName(model.Name, model.Id)) { resultModel.code = -1; resultModel.msg = "已存在相同部门名称!"; return(Ok(resultModel)); } if (_departmentService.ExistEnCode(model.BH, model.Id)) { resultModel.code = -1; resultModel.msg = "已存在相同部门编号!"; return(Ok(resultModel)); } #endregion model.Id = ConstDefine.CreateGuid(); model.CreateTime = DateTime.Now; model.DeleteMark = 1;//删除标记,原来为0 bool result = _departmentService.Insert(model); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败:" + ex.Message; return(Ok(resultModel)); } }
public ActionResult InsertOrUpdate(string drugcode, string drugname, string commoname) { string crowid = ConstDefine.CreateGuid(); var resultModel = new RespResultCountViewModel(); try { if (string.IsNullOrEmpty(drugcode)) { resultModel.code = -1; resultModel.msg = "药品编码不能为空!"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(drugname)) { resultModel.code = -1; resultModel.msg = "药品名称不能为空!"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(commoname)) { resultModel.code = -1; resultModel.msg = "通用名称不能为空!"; return(Ok(resultModel)); } if (_decisionAnalysisService.IsExsitsDrugCode(drugcode)) { resultModel.code = -1; resultModel.msg = "药品编码为“" + drugcode + "”且名称为“" + drugname + "”的药品已存在,不能录入到系统!"; return(Ok(resultModel)); } bool result = _decisionAnalysisService.InsertOrUpdate(crowid, drugcode, drugname, commoname); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "新增失败" + ex.ToString(); return(Ok(resultModel)); } }
public ActionResult Create(JobRiskEntity model) { var resultModel = new RespResultCountViewModel(); try { #region 验证 if (string.IsNullOrEmpty(model.OrgId) || string.IsNullOrEmpty(model.DepId) || string.IsNullOrEmpty(model.RoleId)) { resultModel.code = -1; resultModel.msg = "存在必填项!"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(model.RiskPointBH) || string.IsNullOrEmpty(model.UserId)) { resultModel.code = -1; resultModel.msg = "存在必填项!"; return(Ok(resultModel)); } if (_jobriskService.IsExist(model.UserId, model.RiskPointBH, model.Id)) { resultModel.code = -1; resultModel.msg = "请勿为同一个分配相同的风险点!"; return(Ok(resultModel)); } #endregion model.Id = ConstDefine.CreateGuid(); model.CreateTime = DateTime.Now; model.DeleteMark = 1; bool result = _jobriskService.Insert(model); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败:" + ex.Message; return(Ok(resultModel)); } }
public ActionResult Create(RiskUnitEntity model) { var resultModel = new RespResultCountViewModel(); try { #region 验证 if (string.IsNullOrEmpty(model.OrgId)) { resultModel.code = -1; resultModel.msg = "存在必填项!"; return(Ok(resultModel)); } model.UnitBH = model.UnitOneCode + "/" + model.UnitTwoCode + "/" + model.UnitThreeCode; model.UnitName = model.UnitOneName + "/" + model.UnitTwoName + "/" + model.UnitThreeName; if (_riskunitmanageService.IsExist(model.OrgId, model.UnitBH, model.Id)) { resultModel.code = -1; resultModel.msg = "请勿重复添加风险单元编号!"; return(Ok(resultModel)); } #endregion model.Id = ConstDefine.CreateGuid(); model.CreateTime = DateTime.Now; model.DeleteMark = 1; bool result = _riskunitmanageService.Insert(model); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败:" + ex.Message; return(Ok(resultModel)); } }
public ActionResult Create(DataDictDto model) { RespResultViewModel resultModel = new RespResultCountViewModel(); try { #region 验证 if (string.IsNullOrEmpty(model.ItemName)) { resultModel.code = -1; resultModel.msg = "名称不允许为空"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(model.ItemCode)) { resultModel.code = -1; resultModel.msg = "编码不允许为空"; return(Ok(resultModel)); } if (_dataDictService.ExistFullName(model.DataType, model.ItemName, model.CRowId, User.GetCurrentUserOrganizeId())) { resultModel.code = -1; resultModel.msg = "已存在相同名称!"; return(Ok(resultModel)); } if (_dataDictService.ExistEnCode(model.DataType, model.ItemCode, model.CRowId, User.GetCurrentUserOrganizeId())) { resultModel.code = -1; resultModel.msg = "已存在相同编号!"; return(Ok(resultModel)); } #endregion DataDictEntity dataDictEntity = _mapper.Map <DataDictEntity>(model); dataDictEntity.ItemName = model.ItemName; dataDictEntity.CRowId = ConstDefine.CreateGuid(); dataDictEntity.CreateUserId = User.GetCurrentUserId(); dataDictEntity.CreateUserName = User.GetCurrentUserName(); dataDictEntity.CreateDate = DateTime.Now; dataDictEntity.DeleteMark = 1; dataDictEntity.ModifyDate = System.DateTime.Now; dataDictEntity.ModifyUserId = ""; dataDictEntity.ModifyUserName = ""; dataDictEntity.OrgId = User.GetCurrentUserOrganizeId(); bool result = _dataDictService.Insert(dataDictEntity); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败" + ex.ToString(); return(Ok(resultModel)); } }
public ActionResult Upload(IFormCollection Files, string registerCode, string describe) { List <CheckComplaintDetailEntity> checkComplaintDetails = new List <CheckComplaintDetailEntity>(); try { //var form = Request.Form;//直接从表单里面获取文件名不需要参数 string dd = Files["File"]; var form = Files;//定义接收类型的参数 Hashtable hash = new Hashtable(); string fileCode = fileCode = registerCode; IFormFileCollection cols = Request.Form.Files; if (cols == null || cols.Count == 0) { return(Ok(new { code = -1, msg = "没有上传文件", data = hash })); } if (string.IsNullOrEmpty(fileCode)) { return(Ok(new { code = -4, msg = "请选择档案目录" })); } int i = 0; foreach (IFormFile file in cols) { i++; //定义文件数组后缀格式 string[] LimitFileType = { ".JPG", ".JPEG", ".PNG", ".GIF", ".PNG", ".BMP", ".DOC", ".DOCX", ".XLS", ".XLSX", ".TXT", ".PDF" }; string[] LimitFileType1 = { ".JPG", ".JPEG", ".PNG", ".GIF", ".PNG", ".BMP" }; string[] LimitFileType2 = { ".DOC", ".DOCX", ".XLS", ".XLSX", ".TXT", ".PDF" }; //获取文件后缀是否存在数组中 string currentPictureExtension = Path.GetExtension(file.FileName).ToUpper(); if (LimitFileType.Contains(currentPictureExtension)) { string filetype = string.Empty; //1图片、2文本 if (LimitFileType1.Contains(currentPictureExtension)) { filetype = "1"; } if (LimitFileType2.Contains(currentPictureExtension)) { filetype = "2"; } // var uppath = "E:/znsh/Platform_ZNSH/uploads/" + fileCode + "/" ; var uppath = XYDbContext.UPLOADPATH + "疑点结论上传/" + fileCode + "/"; var lookpath = "/" + fileCode + "/"; var new_path = Path.Combine(uppath, file.FileName); var path = Path.Combine(Directory.GetCurrentDirectory(), new_path); if (!Directory.Exists(uppath)) { Directory.CreateDirectory(uppath); } using (var stream = new FileStream(path, FileMode.Create)) { byte[] fileByte = new byte[file.Length]; //用文件的长度来初始化一个字节数组存储临时的文件 Stream fileStream = file.OpenReadStream(); //建立文件流对象 string fileNameNew = Path.GetFileNameWithoutExtension(file.FileName); //int a = int.Parse(fileNameNew.Substring(fileNameNew.Length - 4, 4)); string CheckComplainId = _afterCheckService.ReturnCheckComplainId(registerCode); if (string.IsNullOrEmpty(CheckComplainId)) { return(Ok(new { status = -6, message = "上传出错!" })); } CheckComplaintDetailEntity checkComplaintDetailEntity = new CheckComplaintDetailEntity() { ComplaintDetailCode = ConstDefine.CreateGuid(), CheckComplainId = CheckComplainId, ImageName = file.FileName, ImageSize = (int)(file.Length) / 1024, ImageUrl = "/疑点结论上传" + lookpath + file.FileName,//上线时需更改 CreateUserId = User.GetCurrentUserId(), CreateUserName = User.GetCurrentUserName(), CreateTime = DateTime.Now, Datatype = "2", //疑点结论上传标识 FilesType = filetype }; checkComplaintDetails.Add(checkComplaintDetailEntity); UserInfo userInfo = new UserInfo { UserId = User.GetCurrentUserId(), UserName = User.GetCurrentUserName(), InstitutionCode = User.GetCurrentUserOrganizeId(), InstitutionName = User.GetCurrentUserOrganizeName() }; //文件保存到数据库里面去 bool flage = _afterCheckService.AddDescribe(registerCode, checkComplaintDetailEntity, describe, userInfo); if (flage) { //再把文件保存的文件夹中 file.CopyTo(stream); hash.Add("file", "/" + new_path); } } } else { return(Ok(new { status = -2, message = "请上传指定格式的图片", data = hash })); } } using (var redisdb = _redisDbContext.GetRedisIntance()) { redisdb.SAdd(fileCode, checkComplaintDetails); redisdb.Expire(fileCode, 86400);//设置缓存时间 } return(Ok(new { status = 0, message = "上传成功", data = hash })); } catch (Exception ex) { return(Ok(new { status = -3, message = "上传失败", data = ex.Message })); } }
public ActionResult Create(OrganizeDto model) { var resultModel = new RespResultCountViewModel(); try { #region 验证 if (string.IsNullOrEmpty(model.OrgName)) { resultModel.code = -1; resultModel.msg = "机构名称不允许为空!"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(model.OrgCode)) { resultModel.code = -1; resultModel.msg = "机构代码不允许为空!"; return(Ok(resultModel)); } if (_organizeService.ExistFullName(model.OrgName, model.OrganizeId)) { resultModel.code = -1; resultModel.msg = "已存在相同机构名称!"; return(Ok(resultModel)); } if (_organizeService.ExistEnCode(model.OrgCode, model.OrganizeId)) { resultModel.code = -1; resultModel.msg = "已存在相同机构代码!"; return(Ok(resultModel)); } #endregion if (model.ParentId == null) { model.ParentId = "0"; } OrganizeEntity organizeEntity = _mapper.Map <OrganizeEntity>(model); organizeEntity.OrgBrevityCode = CommonHelper.GetPinyinCode(organizeEntity.OrgName); organizeEntity.OrganizeId = ConstDefine.CreateGuid(); organizeEntity.CreateDate = DateTime.Now; organizeEntity.CreateUserId = User.GetCurrentUserId(); organizeEntity.CreateUserName = User.GetCurrentUserName(); organizeEntity.DeleteMark = 1;//删除标记,原来为0 bool result = _organizeService.Insert(organizeEntity); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败:" + ex.Message; return(Ok(resultModel)); } }
public ActionResult CreateReport(List <IFormFile> files, HiddenDangersReportEntity model) { var resultModel = new RespResultCountViewModel(); if (string.IsNullOrEmpty(model.CheckTableId)) { resultModel.code = -1; resultModel.msg = "缺少CheckTableId!"; return(Ok(resultModel)); } try { model.Id = ConstDefine.CreateGuid(); model.CreateTime = DateTime.Now; model.DeleteMark = 1; model.PushMark = 0; model.States = "1"; model.TBUserId = User.GetCurrentUserId(); model.TBUserName = User.GetCurrentUserRealName(); model.OrgId = User.GetCurrentUserOrganizeId(); model.OrgName = User.GetCurrentUserOrganizeName(); if (User.GetCurrentUserIsAdmin() == "1") //管理员的话 提交的是挂牌督办的上报 { model.IsSupervisor = "1"; } else { model.IsSupervisor = "0"; } //if (_hiddenService.IsSecondReport(model.CheckTableId)) //{ // resultModel.code = -1; // resultModel.msg = "已上报 请勿重复提交"; // return Ok(resultModel); //} var filesPath = XYDbContext.HiddenDangerPath + "/" + User.GetCurrentUserOrganizeId() + "/Report"; if (!Directory.Exists(filesPath)) { Directory.CreateDirectory(filesPath); } int i = 0; foreach (var formFile in files) { if (formFile.Length > 0) { var filePath = Path.Combine(filesPath, formFile.FileName); using (var stream = new FileStream(filePath, FileMode.Create)) { formFile.CopyTo(stream); stream.Flush(); } model.ImageUrl += "/HiddenDangers/" + User.GetCurrentUserOrganizeId() + "/Report/" + formFile.FileName + ","; } } if (!string.IsNullOrEmpty(model.ImageUrl)) { model.ImageUrl = model.ImageUrl.Substring(0, model.ImageUrl.Length - 1); } bool result = _hiddenService.CreateReport(model, User.GetCurrentUserOrganizeId(), User.GetCurrentUserId(), User.GetCurrentUserRealName()); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败:" + ex.Message; return(Ok(resultModel)); } }
public ActionResult Create(RiskPointEntity model) { var resultModel = new RespResultCountViewModel(); try { #region 验证 if (string.IsNullOrEmpty(model.OrgId)) { resultModel.code = -1; resultModel.msg = "机构Id不能为空!"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(model.BH)) { resultModel.code = -1; resultModel.msg = "编号不能为空!"; return(Ok(resultModel)); } model.RiskPointBH = model.RiskUnitBH + "-" + model.BH; if (_riskmanageService.IsExist(model.OrgId, model.RiskPointBH, model.Id)) { resultModel.code = -1; resultModel.msg = "请勿重复添加风险点编号!"; return(Ok(resultModel)); } #endregion model.Id = ConstDefine.CreateGuid(); model.CreateTime = DateTime.Now; model.DeleteMark = 1; //创建目录 string activeDir = XYDbContext.QRPath; string newPath = activeDir + "/" + model.OrgName; if (!Directory.Exists(newPath))//如果不存在就创建 dir 文件夹 { Directory.CreateDirectory(newPath); } #region 生成二维码 RiskPointDto riskPointDto = new RiskPointDto(); riskPointDto.RiskBH = model.RiskPointBH; riskPointDto.RiskName = model.Name; riskPointDto.OrgId = model.OrgId; riskPointDto.OrgName = model.OrgName; string jsonStr = JsonConvert.SerializeObject(riskPointDto); var bitmap = _qrcodeService.GetQRCode(jsonStr, 10); var QRUrl = "/" + Guid.NewGuid().ToString() + ".bmp"; var path = newPath + QRUrl; #endregion model.QRCodeUrl = path; bool result = _riskmanageService.Insert(model); if (result) { bitmap.Save(path, System.Drawing.Imaging.ImageFormat.Bmp); resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败:" + ex.Message; return(Ok(resultModel)); } }
public ActionResult Create(ModuleDto moduleModel) { var resultModel = new RespResultCountViewModel(); try { #region 验证 if (string.IsNullOrEmpty(moduleModel.ModuleName)) { resultModel.code = -1; resultModel.msg = "名称不允许为空"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(moduleModel.ModuleCode)) { resultModel.code = -1; resultModel.msg = "编号不允许为空"; return(Ok(resultModel)); } if (!_moduleService.ExistEnCode(moduleModel.ModuleCode, moduleModel.ModuleId)) { resultModel.code = -1; resultModel.msg = "已存在相同功能编号"; return(Ok(resultModel)); } if (!_moduleService.ExistFullName(moduleModel.ModuleName, moduleModel.ModuleId)) { resultModel.code = -1; resultModel.msg = "已存在相同功能名称"; return(Ok(resultModel)); } #endregion ModuleEntity moduleEntity = _mapper.Map <ModuleEntity>(moduleModel); moduleEntity.ModuleName = moduleModel.ModuleName; moduleEntity.ModuleId = ConstDefine.CreateGuid(); moduleEntity.DeleteMark = 1; moduleEntity.CreateUserId = User.GetCurrentUserId(); moduleEntity.CreateUserName = User.GetCurrentUserName(); moduleEntity.CreateDate = DateTime.Now; bool result = _moduleService.Insert(moduleEntity); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败:" + ex.Message; resultModel.data = null; return(Ok(resultModel)); } }
public ActionResult Create(JobEntity model) { var resultModel = new RespResultCountViewModel(); try { #region 验证 if (string.IsNullOrEmpty(model.Name)) { resultModel.code = -1; resultModel.msg = "岗位名称不允许为空"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(model.DepId)) { resultModel.code = -1; resultModel.msg = "部门Id不允许为空"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(model.OrgId)) { resultModel.code = -1; resultModel.msg = "机构Id不允许为空"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(model.JobCode)) { resultModel.code = -1; resultModel.msg = "岗位编号不允许为空"; return(Ok(resultModel)); } if (_jobService.CheckIsJobBHRepeat(model.JobCode, model.Id, model.DepId, model.OrgId)) { resultModel.code = -1; resultModel.msg = "已存在相同岗位编号"; return(Ok(resultModel)); } if (_jobService.CheckIsJobNameRepeat(model.Name, model.Id, model.DepId, model.OrgId)) { resultModel.code = -1; resultModel.msg = "已存在相同岗位名称"; return(Ok(resultModel)); } #endregion model.Id = ConstDefine.CreateGuid(); model.CreateTime = DateTime.Now; model.DeleteMark = 1; bool result = _jobService.Insert(model); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败!"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败!" + ex.ToString(); return(Ok(resultModel)); } }
public IActionResult CommintFK(IFormCollection Files, string jsonArray, string registerCode, string fkcount) { JsonArray jsonObject = JsonConvert.DeserializeObject <JsonArray>(jsonArray); var resultCountModel = new RespResultCountViewModel(); Hashtable hash = new Hashtable(); string fileCode = "";//申诉主表编码 try { UserInfo userInfo = new UserInfo { UserId = User.GetCurrentUserId(), UserName = User.GetCurrentUserName(), InstitutionCode = User.GetCurrentUserOrganizeId(), InstitutionName = User.GetCurrentUserOrganizeName() }; //改ID为申诉主表的主键CheckComplainId if (!string.IsNullOrEmpty(fkcount) && fkcount == "1") { fileCode = _complaintMZService.Commint("2", jsonObject, registerCode, userInfo); } else if (!string.IsNullOrEmpty(fkcount) && fkcount == "2") { fileCode = _complaintMZService.Commint("22", jsonObject, registerCode, userInfo); } IFormFileCollection cols = Request.Form.Files; if (cols == null || cols.Count == 0) { return(Ok(new { code = -1, msg = "没有上传文件", data = hash })); } if (string.IsNullOrEmpty(fileCode)) { return(Ok(new { code = -4, msg = "请选择档案目录" })); } int i = 0; foreach (IFormFile file in cols) { i++; //定义文件数组后缀格式 string[] LimitFileType = { ".JPG", ".JPEG", ".PNG", ".GIF", ".PNG", ".BMP", ".DOC", ".DOCX", ".XLS", ".XLSX", ".TXT", ".PDF" }; string[] LimitFileType1 = { ".JPG", ".JPEG", ".PNG", ".GIF", ".PNG", ".BMP" }; string[] LimitFileType2 = { ".DOC", ".DOCX", ".XLS", ".XLSX", ".TXT", ".PDF" }; //获取文件后缀是否存在数组中 string currentPictureExtension = Path.GetExtension(file.FileName).ToUpper(); if (LimitFileType.Contains(currentPictureExtension)) { string filetype = string.Empty; //1图片、2文本 if (LimitFileType1.Contains(currentPictureExtension)) { filetype = "1"; } if (LimitFileType2.Contains(currentPictureExtension)) { filetype = "2"; } if (!string.IsNullOrEmpty(fkcount) && fkcount == "2") { var uppath = XYDbContext.UPLOADPATH + "医院二次反馈上传/" + fileCode + "/"; var lookpath = "/" + fileCode + "/"; var new_path = Path.Combine(uppath, file.FileName); var path = Path.Combine(Directory.GetCurrentDirectory(), new_path); if (!Directory.Exists(uppath)) { Directory.CreateDirectory(uppath); } using (var stream = new FileStream(path, FileMode.Create)) { byte[] fileByte = new byte[file.Length]; //用文件的长度来初始化一个字节数组存储临时的文件 Stream fileStream = file.OpenReadStream(); //建立文件流对象 string fileNameNew = Path.GetFileNameWithoutExtension(file.FileName); //int a = int.Parse(fileNameNew.Substring(fileNameNew.Length - 4, 4)); Check_ComplaintDetail_MZLEntity checkComplaintDetailEntity = new Check_ComplaintDetail_MZLEntity() { ComplaintDetailCode = ConstDefine.CreateGuid(), CheckComplainId = fileCode, ImageName = file.FileName, ImageSize = (int)(file.Length) / 1024, ImageUrl = "/医院二次反馈上传" + lookpath + file.FileName,//上线时需更改 CreateUserId = User.GetCurrentUserId(), CreateUserName = User.GetCurrentUserName(), CreateTime = DateTime.Now, Datatype = "2", //二次反馈 FilesType = filetype }; //文件保存到数据库里面去 bool flag = _afterCheckService.Add2(checkComplaintDetailEntity); if (flag) { //再把文件保存的文件夹中 file.CopyTo(stream); hash.Add("file", "/" + new_path); } } #region 第二次反馈时 删除第一次反馈上传文件 再重新创建 待用 //if (_afterCheckService.DeleteFiles(fileCode)) //{ // if (CommonHelper.DeleteDir(XYDbContext.UPLOADPATH + "医院反馈上传/" + fileCode)) // { // if (!Directory.Exists(uppath)) // { // Directory.CreateDirectory(uppath); // } // using (var stream = new FileStream(path, FileMode.Create)) // { // byte[] fileByte = new byte[file.Length];//用文件的长度来初始化一个字节数组存储临时的文件 // Stream fileStream = file.OpenReadStream();//建立文件流对象 // string fileNameNew = Path.GetFileNameWithoutExtension(file.FileName); // //int a = int.Parse(fileNameNew.Substring(fileNameNew.Length - 4, 4)); // CheckComplaintDetailEntity checkComplaintDetailEntity = new CheckComplaintDetailEntity() // { // ComplaintDetailCode = ConstDefine.CreateGuid(), // CheckComplainId = fileCode, // ImageName = file.FileName, // ImageSize = (int)(file.Length) / 1024, // ImageUrl = "/医院反馈上传" + lookpath + file.FileName,//上线时需更改 // CreateUserId = User.GetCurrentUserId(), // CreateUserName = User.GetCurrentUserName(), // CreateTime = DateTime.Now, // Datatype = "2", //二次反馈 // FilesType = filetype // }; // //文件保存到数据库里面去 // bool flag = _afterCheckService.Add(checkComplaintDetailEntity); // if (flag) // { // //再把文件保存的文件夹中 // file.CopyTo(stream); // hash.Add("file", "/" + new_path); // } // } // } // else // { // return Ok(new { code = -1, msg = "删除附件失败 请联系管理员!" }); // } //} //else //{ // return Ok(new { code = 1, msg = "原有附件已删除!" }); //} #endregion } else { var uppath = XYDbContext.UPLOADPATH + "医院初次反馈上传/" + fileCode + "/"; var lookpath = "/" + fileCode + "/"; var new_path = Path.Combine(uppath, file.FileName); var path = Path.Combine(Directory.GetCurrentDirectory(), new_path); if (!Directory.Exists(uppath)) { Directory.CreateDirectory(uppath); } using (var stream = new FileStream(path, FileMode.Create)) { byte[] fileByte = new byte[file.Length]; //用文件的长度来初始化一个字节数组存储临时的文件 Stream fileStream = file.OpenReadStream(); //建立文件流对象 string fileNameNew = Path.GetFileNameWithoutExtension(file.FileName); //int a = int.Parse(fileNameNew.Substring(fileNameNew.Length - 4, 4)); Check_ComplaintDetail_MZLEntity checkComplaintDetailEntity = new Check_ComplaintDetail_MZLEntity() { ComplaintDetailCode = ConstDefine.CreateGuid(), CheckComplainId = fileCode, ImageName = file.FileName, ImageSize = (int)(file.Length) / 1024, ImageUrl = "/医院初次反馈上传" + lookpath + file.FileName,//上线时需更改 CreateUserId = User.GetCurrentUserId(), CreateUserName = User.GetCurrentUserName(), CreateTime = DateTime.Now, Datatype = "1", //医院初次反馈 FilesType = filetype }; //文件保存到数据库里面去 bool flag = _afterCheckService.Add2(checkComplaintDetailEntity); if (flag) { //再把文件保存的文件夹中 file.CopyTo(stream); hash.Add("file", "/" + new_path); } } } } else { return(Ok(new { status = -2, message = "请上传指定格式的图片", data = hash })); } } return(Ok(new { status = 0, message = "上传成功", data = hash })); } catch (Exception ex) { return(Ok(new { status = -3, message = "上传失败", data = ex.Message })); } }
public ActionResult CreateRecheck(List <IFormFile> files, HiddenDangersRecheckEntity model) { var resultModel = new RespResultCountViewModel(); try { if (string.IsNullOrEmpty(model.States) || string.IsNullOrEmpty(model.ReportId)) { resultModel.code = -1; resultModel.msg = "存在必填项!"; return(Ok(resultModel)); } if (_hiddenService.IsSecondRecheck(model.ReportId)) { resultModel.code = -1; resultModel.msg = "已复查 请勿重复提交"; return(Ok(resultModel)); } model.Id = ConstDefine.CreateGuid(); model.ReTime = DateTime.Now; model.DeleteMark = 1; model.ReUserId = User.GetCurrentUserId(); model.ReUserName = User.GetCurrentUserRealName(); model.IsSupervisor = _hiddenService.GetIsSupervisor(model.ReportId); var filesPath = XYDbContext.HiddenDangerPath + "/" + User.GetCurrentUserOrganizeId() + "/Recheck"; if (!Directory.Exists(filesPath)) { Directory.CreateDirectory(filesPath); } foreach (var formFile in files) { if (formFile.Length > 0) { var filePath = Path.Combine(filesPath, formFile.FileName); using (var stream = new FileStream(filePath, FileMode.Create)) { formFile.CopyTo(stream); stream.Flush(); } model.ReImageUrl += "/HiddenDangers/" + User.GetCurrentUserOrganizeId() + "/Recheck/" + formFile.FileName + ","; } } if (!string.IsNullOrEmpty(model.ReImageUrl)) { model.ReImageUrl = model.ReImageUrl.Substring(0, model.ReImageUrl.Length - 1); } bool result = _hiddenService.CreateRecheck(model); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败:" + ex.Message; return(Ok(resultModel)); } }
public ActionResult Create(RiskClassIficationEntity model) { var resultModel = new RespResultCountViewModel(); var testid = User.GetCurrentUserOrganizeId().ToString(); try { #region 验证 if (string.IsNullOrEmpty(model.OrgId) || string.IsNullOrEmpty(model.RiskPointBH)) { resultModel.code = -1; resultModel.msg = "存在必填项!"; return(Ok(resultModel)); } //if (_riskclassificationService.IsExist(model.OrgId, model.RiskPointBH, model.Id)) //{ // resultModel.code = -1; // resultModel.msg = "请勿重复添加风险点编号!"; // return Ok(resultModel); //} #endregion model.Id = ConstDefine.CreateGuid(); model.CreateTime = DateTime.Now; model.DeleteMark = 1; model.RiskR = model.SeverityS * model.PossibleL; if (model.RiskR >= 12 && model.RiskR <= 20) { model.RiskLevel = "1"; } if (model.RiskR >= 8 && model.RiskR <= 10) { model.RiskLevel = "2"; } if (model.RiskR >= 4 && model.RiskR <= 6) { model.RiskLevel = "3"; } if (model.RiskR < 4) { model.RiskLevel = "4"; } bool result = _riskclassificationService.Insert(model); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; } else { resultModel.code = -1; resultModel.msg = "新增失败"; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败:" + ex.Message; return(Ok(resultModel)); } }
public ActionResult Create(UserDto model) { var resultModel = new RespResultCountViewModel(); try { #region 验证 if (string.IsNullOrEmpty(model.UserName)) { resultModel.code = -1; resultModel.msg = "用户名不允许为空"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(model.Password)) { resultModel.code = -1; resultModel.msg = "密码不允许为空"; return(Ok(resultModel)); } if (string.IsNullOrEmpty(model.OrganizeId)) { resultModel.code = -1; resultModel.msg = "所属机构不允许为空"; return(Ok(resultModel)); } if (_userService.IsExistByUserName(model.UserName, model.UserId)) { resultModel.code = -1; resultModel.msg = "该用户已存在!"; return(Ok(resultModel)); } #endregion UserEntity userEntity = _mapper.Map <UserEntity>(model); userEntity.UserId = ConstDefine.CreateGuid(); userEntity.CreateDate = DateTime.Now; userEntity.CreateUserId = User.GetCurrentUserId(); userEntity.CreateUserName = User.GetCurrentUserName(); userEntity.DeleteMark = 1; bool result = _userService.Insert(userEntity); if (result) { resultModel.code = 0; resultModel.msg = "新增成功"; resultModel.data = null; } else { resultModel.code = -1; resultModel.msg = "新增失败"; resultModel.data = null; } return(Ok(resultModel)); } catch (Exception ex) { resultModel.code = -1; resultModel.msg = "操作失败:" + ex.Message; resultModel.data = null; return(Ok(resultModel)); } }