public ActionResult CreateDist(int?dist_idx) { DistMasterModel distMaster = null; if (dist_idx != null) { distMaster = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel() { dist_idx = dist_idx }); } else { distMaster = new DistMasterModel(); } if (distMaster.finish_date == "") { ConfigModel finishTerm = Mapper.Instance().QueryForObject <ConfigModel>("Common.selConfig", new ConfigModel { comm_section = "DIST", comm_code = "EXPIRE_TERM" }); distMaster.finish_dt = DateTime.Now.AddDays(Convert.ToInt32(finishTerm.comm_value)); } ViewBag.distMaster = distMaster; return(View()); }
public JsonResult SetDistFinish(DistMasterModel distModel) { try { if (distModel.dist_idx == null) { throw new Exception(Resources.Resource.res0219); /*잘못된 호출입니다*/ } distModel.dist_st = "DF"; Mapper.Instance().Update("DIST.udtDistMaster", distModel); Mapper.Instance().Update("DIST.udtDistReceiverStatus", new DistReceiverModel { dist_idx = distModel.dist_idx, recv_dist_st = "DF" }); DistMasterModel distMaster = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel { dist_idx = distModel.dist_idx }); LogCtrl.SetLog(distModel, eActionType.CompulsionExpire, this.HttpContext, distMaster.dist_title); return(Json("1")); } catch (Exception ex) { return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
public JsonResult GetDistEoBomList(int?dist_idx, int?eo_idx) { try { DistMasterModel dist = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel() { dist_idx = dist_idx }); //ViewBag.dist_st = dist.dist_st; //ItfPartMaster partMaster = Mapper.Instance().QueryForObject<ItfPartMaster>("Part.selEoKeyPartInfo", eo_idx); var bomList = Mapper.Instance().QueryForList <ItfBomInfo>("Part.selPartBom", new ItfBomInfo { dist_idx = dist_idx, eo_idx = eo_idx, recv_us = Convert.ToInt32(Session["USER_IDX"]) }); if (dist.dist_st == "DF" || dist.dist_st == "DD") { foreach (ItfBomInfo bom in bomList) { bom.part_file_cnt = 0; } } return(Json(bomList)); } catch (Exception ex) { return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
public JsonResult SetDistEoInfo(DistEoModel distEo) { try { bool isNew = distEo.dist_idx == null ? true : false; Mapper.Instance().BeginTransaction(); // 신규 if (isNew) { distEo.dist_idx = SetDistMaster(new DistMasterModel() { eo_fl = "Y", dist_st = "CR", create_us = Convert.ToInt32(Session["USER_IDX"]) }); Mapper.Instance().Insert("DIST.insDistEo", distEo); } else { DistEoModel compareEo = Mapper.Instance().QueryForObject <DistEoModel>("DIST.selDistEo", new DistEoModel() { dist_idx = distEo.dist_idx }); // 기존 EO에 속한 파일이 있을 경우 지워버린다. if (compareEo != null) { Mapper.Instance().Delete("DIST.delDistRecvEoFile", new DistRecvFileModel { dist_idx = distEo.dist_idx, eo_idx = compareEo.eo_idx }); Mapper.Instance().Update("DIST.udtDistEo", distEo); } else { Mapper.Instance().Insert("DIST.insDistEo", distEo); } SetUdtDistMaster(new DistMasterModel { dist_idx = distEo.dist_idx }); } SetRecieverLinkFile(distEo.dist_idx); DistMasterModel dist = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel() { dist_idx = distEo.dist_idx }); LogCtrl.SetLog(distEo, eActionType.DistEoSave, this.HttpContext, dist.dist_title); Mapper.Instance().CommitTransaction(); return(Json(distEo.dist_idx)); } catch (Exception ex) { Mapper.Instance().RollBackTransaction(); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
public MailContent(DistMasterModel pDistMaster, UserModel pFromUserModel, DistReceiverModel pToUserModel, HttpRequestBase Request) { distMaster = pDistMaster; fromUserModel = pFromUserModel; toUserModel = pToUserModel; mailContentLink = string.Format(mailContentLink, Request.Url.Authority); }
public int SetDistMaster(DistMasterModel distMaster) { int distIDX = (int)Mapper.Instance().Insert("DIST.insDistMaster", distMaster); LogCtrl.SetLog(new DistMasterModel { dist_idx = distIDX }, eActionType.DistInsert, this.HttpContext, distMaster.dist_title); return(distIDX); }
public JsonResult GetFinishDistList() { ConfigModel distRecvDay = Mapper.Instance().QueryForObject <ConfigModel>("Common.selConfig", new ConfigModel { comm_section = "MAIN", comm_code = "MAIN_FINISH_DIST_DATE" }); DistMasterModel dist = new DistMasterModel(); dist.finish_dt = DateTime.Now.AddDays((Convert.ToInt32(distRecvDay.comm_value))); return(Json(Mapper.Instance().QueryForList <DistMasterModel>("DIST.selDistMaster", dist))); }
public JsonResult GetRecvList(DistMasterModel searchModel) { try { searchModel.recv_us = Convert.ToInt32(Session["USER_IDX"]); return(Json(Mapper.Instance().QueryForList <DistMasterModel>("Recv.selReciverDistInfo", searchModel))); } catch (Exception ex) { return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
public JsonResult GetLatestDistList() { ConfigModel distRecvDay = Mapper.Instance().QueryForObject <ConfigModel>("Common.selConfig", new ConfigModel { comm_section = "MAIN", comm_code = "MAIN_DIST_LIST_DATE" }); DistMasterModel dist = new DistMasterModel(); dist.dist_sdt = DateTime.Now.AddDays((Convert.ToInt32(distRecvDay.comm_value) * -1)).ToString("yyyy-MM-dd"); dist.dist_edt = DateTime.Now.ToString("yyyy-MM-dd"); var retList = Mapper.Instance().QueryForList <DistMasterModel>("DIST.selDistMaster", dist); return(Json(retList)); }
public void SetMailInfo(DistMasterModel distMaster, UserModel fromUserModel, List <DistReceiverModel> toUserList) { try { foreach (DistReceiverModel recv in toUserList) { MailContent content = new MailContent(distMaster, fromUserModel, recv, Request); MailList.Add(content); } } catch (Exception ex) { throw ex; } }
public JsonResult SetDelDistReceiver(List <DistReceiverModel> receiverModel) { try { Mapper.Instance().BeginTransaction(); DistMasterModel dist = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel() { dist_idx = receiverModel[0].dist_idx }); SetUdtDistMaster(new DistMasterModel { dist_idx = receiverModel[0].dist_idx }); foreach (DistReceiverModel distRecv in receiverModel) { // 1. 수신자에 속한 배포 파일 삭제 Mapper.Instance().Delete("DIST.delDistRecvFile", new DistRecvFileModel { dist_idx = distRecv.dist_idx, recv_idx = distRecv.recv_idx }); // 2. 수신자 삭제 int i = (int)Mapper.Instance().Delete("DIST.delDistReceiver", new DistReceiverModel { dist_idx = distRecv.dist_idx, recv_idx = distRecv.recv_idx }); LogCtrl.SetLog(distRecv, eActionType.DistReceiverDelete, this.HttpContext, dist.dist_title); if (i == 0) { throw new Exception(Resources.Resource.res0312);//수신자 삭제가 실패했습니다 } } Mapper.Instance().CommitTransaction(); return(Json(1)); } catch (Exception ex) { Mapper.Instance().RollBackTransaction(); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
public int UpdateDistStatus(NpgsqlTransaction tran, DistMasterModel dist) { try { if (!dbCon.IsDBConnected) { dbCon.DBConnect(); } string sQuery = "UPDATE dist_master SET dist_st = '{0}' WHERE dist_idx = {1}"; sQuery = string.Format(sQuery, dist.dist_st, dist.dist_idx); int res = dbCon.DBExecuteQuery(tran, sQuery); return(res); } catch (Exception ex) { throw ex; } }
public JsonResult SetTempSaveDistMaster(DistMasterModel saveModel, List <DistReceiverModel> recvList) { try { bool isNew = saveModel.dist_idx == null ? true : false; Mapper.Instance().BeginTransaction(); if (isNew) { saveModel.dist_idx = SetDistMaster(new DistMasterModel() { eo_fl = "Y", dist_st = "CR", create_us = Convert.ToInt32(Session["USER_IDX"]) }); } SetUdtDistMaster(saveModel); if (recvList != null) { foreach (DistReceiverModel recv in recvList) { recv.dist_idx = saveModel.dist_idx; Mapper.Instance().Update("DIST.udtDistReceiver", recv); } } Mapper.Instance().CommitTransaction(); return(Json(saveModel.dist_idx)); } catch (Exception ex) { Mapper.Instance().RollBackTransaction(); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
public JsonResult SetChangeDistFinishDate(DistMasterModel distModel) { try { if (distModel.finish_date == "") { throw new Exception(Resources.Resource.res0220); } //"날짜가 설정되지 않았습니다." Mapper.Instance().Update("DIST.udtDistMaster", distModel); Mapper.Instance().Update("DIST.udtDistReceiverFinishdate", new DistReceiverModel { dist_idx = distModel.dist_idx, recv_finish_dt = distModel.finish_dt }); return(Json(distModel.finish_date)); } catch (Exception ex) { return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
/// <summary> /// 수신자가 다운로드 받는 함수 /// </summary> /// <param name="dist_file_idx"></param> /// <returns></returns> public ActionResult DistFileDownload(int?dist_file_idx) { System.IO.Stream fStream = null; string fileOrgName = string.Empty; string fileConvName = string.Empty; string filePath = string.Empty; DistRecvFileModel distFile = Mapper.Instance().QueryForObject <DistRecvFileModel>("DIST.selDistRecvFile", new DistRecvFileModel { dist_file_idx = dist_file_idx, recv_us = Convert.ToInt32(Session["USER_IDX"]) }); DistMasterModel dist = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel { dist_idx = distFile.dist_idx }); if (distFile == null) { throw new Exception(Resources.Resource.res0320);//잘못된 파일을 호출하셨습니다. } if (dist.dist_st == "CR") { throw new Exception("배포가 진행되지 않는 파일입니다."); } if (dist.dist_st == "DF" && distFile.recv_dist_st == "DF") { throw new Exception(Resources.Resource.res0297);//배포가 만료된 파일입니다. } fileOrgName = distFile.file_org_nm; fileConvName = distFile.file_conv_nm; if (distFile.is_itf == "N") { filePath = System.Configuration.ConfigurationManager.AppSettings["LocalFilePath"].ToString() + "\\" + distFile.dist_idx; } else { filePath = System.Configuration.ConfigurationManager.AppSettings["EoFilePath"].ToString() + "\\" + distFile.part_no; } if (!CommonUtil.IsFile(filePath, fileConvName)) { ViewBag.Massage = Resources.Resource.res0366; // 파일이 없습니다. return(View()); } if (fileConvName.ToLower().Contains(".pdf")) { PdfWatermark watermark = new PdfWatermark(); string watermarkFile = watermark.SetWaterMarkPdf(filePath, fileConvName, Convert.ToInt32(Session["USER_IDX"]), CommonUtil.GetRemoteIP(this.Request)); fStream = CommonUtil.FileStream(watermarkFile); } else { fStream = CommonUtil.FileStream(filePath, fileConvName); } LogCtrl.SetLog(distFile, eActionType.FileDown, this.HttpContext, distFile.file_org_nm); if (Request.Browser.Browser == "IE" || Request.Browser.Browser == "InternetExplorer") { return(File(fStream, MediaTypeNames.Application.Octet, HttpUtility.UrlEncode(fileOrgName, System.Text.Encoding.UTF8))); } else { return(File(fStream, MediaTypeNames.Application.Octet, fileOrgName)); } }
public JsonResult SetReDist(DistMasterModel distModel) { try { if (distModel == null) { throw new Exception(Resources.Resource.res0219);//잘못된 호출입니다 } if (distModel.dist_idx == null) { throw new Exception(Resources.Resource.res0219);//잘못된 호출입니다 } Mapper.Instance().BeginTransaction(); var recvList = Mapper.Instance().QueryForList <DistReceiverModel>("DIST.selDistReceiver", new DistReceiverModel { dist_idx = distModel.dist_idx }); ConfigModel disuseTerm = Mapper.Instance().QueryForObject <ConfigModel>("Common.selConfig", new ConfigModel { comm_section = "DIST", comm_code = "EXPIRE_TERM" }); DateTime now = DateTime.Now; DateTime finishDate = now.AddDays(Convert.ToInt32(disuseTerm.comm_value)); distModel.dist_st = "DS"; distModel.finish_dt = finishDate; int recvUpdate = Mapper.Instance().Update("DIST.udtDistReceiverFinishdate", new DistReceiverModel { dist_idx = distModel.dist_idx, recv_finish_dt = finishDate, recv_dist_st = "DS" }); if (recvUpdate <= 0) { throw new Exception(Resources.Resource.res0313);//수신자 상태를 수정하지 못했습니다 } int distIdx = Mapper.Instance().Update("DIST.udtDistMaster", new DistMasterModel { dist_idx = distModel.dist_idx, finish_dt = finishDate, dist_st = "DS" }); if (distIdx <= 0) { throw new Exception(Resources.Resource.res0295);//"배포 상태를 수정하지 못했습니다." } Mapper.Instance().CommitTransaction(); return(Json("1")); } catch (Exception ex) { Mapper.Instance().RollBackTransaction(); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
public JsonResult StartDist(DistMasterModel distModel, List <DistReceiverModel> recvList) { try { Mapper.Instance().BeginTransaction(); if (recvList == null) { throw new Exception(Resources.Resource.res0311);// 선택 된 수신자가 없습니다 } var distFileList = Mapper.Instance().QueryForList <DistRecvFileModel>("DIST.selDistRecvFile", new DistRecvFileModel { dist_idx = distModel.dist_idx, use_fl = "Y" }); if (distFileList.Count == 0) { throw new Exception(Resources.Resource.res0296);//"배포 할 파일이 없습니다." } TimeSpan TS = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")) - DateTime.Parse(distModel.finish_date); int diffDay = TS.Days; if (diffDay >= 0) { throw new Exception(Resources.Resource.res0294);//만료일은 금일 보다 이후여야 합니다 } //selConfig //DIST EXPIRE_TERM 10 //DIST DISCARD_TERM 20 // ConfigModel disuseTerm = Mapper.Instance().QueryForObject <ConfigModel>("Common.selConfig", new ConfigModel { comm_section = "DIST", comm_code = "DISCARD_TERM" }); DateTime now = DateTime.Now; distModel.dist_st = "DS"; distModel.dist_dt = now; SetUdtDistMaster(distModel); foreach (DistReceiverModel recv in recvList) { recv.recv_finish_dt = distModel.finish_dt; recv.recv_dist_st = "DS"; Mapper.Instance().Update("DIST.udtDistReceiver", recv); } DistMasterModel distMaster = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel { dist_idx = distModel.dist_idx }); UserModel distUsr = Mapper.Instance().QueryForObject <UserModel>("User.selUser", new UserModel { us_idx = distMaster.create_us }); List <DistReceiverModel> distRecvList = Mapper.Instance().QueryForList <DistReceiverModel>("DIST.selDistReceiver", new DistReceiverModel { dist_idx = distModel.dist_idx }).Cast <DistReceiverModel>().ToList(); // Transaction 이 걸려 있어 임시로 데이터 대입 distMaster.dist_dt = now; distMaster.finish_dt = distModel.finish_dt; distMaster.dist_title = distModel.dist_title; distMaster.dist_msg = distModel.dist_msg; DistMail smtpMail = new DistMail(Request); smtpMail.SetMailInfo(distMaster, distUsr, distRecvList); smtpMail.SendMail(); LogCtrl.SetLog(distModel, eActionType.DistStart, this.HttpContext, distModel.dist_title); Mapper.Instance().CommitTransaction(); return(Json(1)); } catch (Exception ex) { Mapper.Instance().RollBackTransaction(); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
public ActionResult DistAllFileDownload(int?dist_idx) { if (dist_idx == null) { throw new Exception(Resources.Resource.res0598);//잘못된 호출방식입니다. } DistMasterModel dist = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel { dist_idx = dist_idx }); DistReceiverModel recv = Mapper.Instance().QueryForObject <DistReceiverModel>("DIST.selDistReceiver", new DistReceiverModel { dist_idx = dist_idx, recv_us = Convert.ToInt32(Session["USER_IDX"]) }); if (dist.dist_st == "CR") { throw new Exception(Resources.Resource.res0328);//"해당 배포 파일은 다운로드 할 수 없습니다." } if (dist.dist_st == "DF" && recv.recv_dist_st == "DF") { throw new Exception(Resources.Resource.res0297);//배포가 만료된 파일입니다. } var distFile = Mapper.Instance().QueryForList <DistRecvFileModel>("DIST.selDistRecvFile", new DistRecvFileModel { dist_idx = dist_idx, recv_us = Convert.ToInt32(Session["USER_IDX"]) }); List <string[]> files = new List <string[]>(); foreach (DistRecvFileModel recvFile in distFile) { //System.IO.Stream fStream = null; string fileOrgName = recvFile.file_org_nm; string fileConvName = recvFile.file_conv_nm; string filePath = string.Empty; if (recvFile.is_itf == "N") { filePath = System.Configuration.ConfigurationManager.AppSettings["LocalFilePath"].ToString() + "\\" + recvFile.dist_idx; } else { filePath = System.Configuration.ConfigurationManager.AppSettings["EoFilePath"].ToString() + "\\" + recvFile.part_no; } string downloadFileFullPath = string.Empty; if (!CommonUtil.IsFile(filePath, fileConvName)) { ViewBag.Massage = Resources.Resource.res0366; // 파일이 없습니다. return(View("Common/DistFileDownload")); } if (fileConvName.ToLower().Contains(".pdf")) { PdfWatermark watermark = new PdfWatermark(); downloadFileFullPath = watermark.SetWaterMarkPdf(filePath, fileConvName, Convert.ToInt32(Session["USER_IDX"]), CommonUtil.GetRemoteIP(this.Request)); } else { downloadFileFullPath = Path.Combine(filePath, fileConvName); } files.Add(new string[] { downloadFileFullPath, recvFile.file_org_nm }); LogCtrl.SetLog(recvFile, eActionType.FileDown, this.HttpContext, "전체 다운로드 : " + dist.dist_title); } using (var memoryStream = new MemoryStream()) { using (ZipArchive ziparchive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true)) { for (int i = 0; i < files.Count; i++) { if (System.IO.File.Exists(files[i][0].ToString())) { ziparchive.CreateEntryFromFile(files[i][0].ToString(), files[i][1].ToString()); } } } return(File(memoryStream.ToArray(), "application/zip", HttpUtility.UrlEncode(dist.dist_title + ".zip", System.Text.Encoding.UTF8))); } }
public JsonResult SetDistReceiver(int?dist_idx, List <DistReceiverModel> receiverModel) { try { Mapper.Instance().BeginTransaction(); DistMasterModel dist = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel() { dist_idx = dist_idx }); if (dist_idx == null) { dist_idx = SetDistMaster(new DistMasterModel() { eo_fl = "Y", dist_st = "CR", create_us = Convert.ToInt32(Session["USER_IDX"]) }); } else { SetUdtDistMaster(new DistMasterModel { dist_idx = dist_idx }); } var prevRecvList = Mapper.Instance().QueryForList <DistReceiverModel>("DIST.selDistReceiver", new DistReceiverModel { dist_idx = dist_idx }); foreach (DistReceiverModel recv in receiverModel) { var chkRecv = from rcv in prevRecvList where rcv.recv_us == recv.recv_us select rcv; if (chkRecv.Count() > 0) { continue; } else { recv.dist_idx = dist_idx; Mapper.Instance().Insert("DIST.insDistReceiver", recv); LogCtrl.SetLog(recv, eActionType.DistReceiverSave, this.HttpContext, dist.dist_title); } } SetRecieverLinkFile(dist_idx); Mapper.Instance().CommitTransaction(); return(Json(dist_idx)); } catch (Exception ex) { Mapper.Instance().RollBackTransaction(); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
public JsonResult GetTempDistList(DistMasterModel searchModel) { searchModel.create_us = Convert.ToInt32(Session["USER_IDX"]); return(Json(Mapper.Instance().QueryForList <DistMasterModel>("DIST.selDistMaster", searchModel))); }
public JsonResult GetDistList(DistMasterModel searchModel) { return(Json(Mapper.Instance().QueryForList <DistMasterModel>("DIST.selDistMaster", searchModel))); }
public int SetUdtDistMaster(DistMasterModel distMaster) { LogCtrl.SetLog(distMaster, eActionType.DistSave, this.HttpContext, distMaster.dist_title); return((int)Mapper.Instance().Update("DIST.udtDistMaster", distMaster)); }