public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string rowStr = context.Request["row"] ?? string.Empty; string validStartDate = context.Request["validStartDate"] ?? string.Empty; if (string.IsNullOrEmpty(rowStr)) { ResOutput(context, "不能设定目标为空文件的生效日期!"); } if (string.IsNullOrEmpty(validStartDate)) { ResOutput(context, "时间值设定有误!"); } ModelView.DmsFileView dmsFileView = null; try { dmsFileView = Common.JsonHelper.DeserializeJsonToObject <ModelView.DmsFileView>(rowStr); } catch (Exception) { dmsFileView = null; } if (dmsFileView == null) { ResOutput(context, "不能设定目标为空文件的生效日期!"); } Ctrl.Bll.DmsFileBll dmsFileBll = new Ctrl.Bll.DmsFileBll(); ResOutput(context, dmsFileBll.SetValidDate(dmsFileView, validStartDate)); }
/// <summary> /// 视图类转实体类 /// </summary> /// <param name="view">视图类</param> /// <returns>实体类</returns> private Model.TableModel.Dms_file View2Model(ModelView.DmsFileView view) { Model.TableModel.Dms_file model = new Model.TableModel.Dms_file(); if (string.IsNullOrEmpty(view.id)) { model.id = Common.Md5Operate.CreateGuidId(); } else { model.id = view.id; } GlobalDataCtrl globalDataCtrl = new GlobalDataCtrl(); model.file_no = string.IsNullOrEmpty(view.file_no) ? globalDataCtrl.GetNextNoByTblName("mpo_item") : view.file_no; model.file_name = System.IO.Path.GetFileNameWithoutExtension(view.file_info); model.file_extension = System.IO.Path.GetExtension(view.file_info); model.file_type_no = string.IsNullOrEmpty(view.file_type_no) ? "01" : view.file_type_no; model.file_type_name = view.file_type_name; model.file_version = string.IsNullOrEmpty(view.file_version) ? "1" : view.file_version; model.file_desc = view.file_desc; model.eqm_no = string.IsNullOrEmpty(view.eqm_no) ? "EqmNo" : view.eqm_no; model.file_md5 = string.IsNullOrEmpty(view.file_md5) ? "FileMd5" : view.file_md5; model.is_passed = string.IsNullOrEmpty(view.is_passed) ? false : (view.is_passed == "是"?true:false); model.file_status = string.IsNullOrEmpty(view.file_status) ? "未确认" : view.file_status; model.ralate_file_name = view.ralate_file_name; DateTime tmpDt = DateTime.Now; model.valid_date_start = string.IsNullOrEmpty(view.valid_date_start) ? (DateTime?)null : (DateTime.TryParse(view.valid_date_start, out tmpDt) ? tmpDt : (DateTime?)null); model.valid_date_end = string.IsNullOrEmpty(view.valid_date_end) ? (DateTime?)null : (DateTime.TryParse(view.valid_date_end, out tmpDt) ? tmpDt : (DateTime?)null); return(model); }
/// <summary> /// 数据更新 /// </summary> /// <param name="newValue">更新后对象</param> /// <returns>影响记录条数</returns> public int Update(ModelView.DmsFileView newValue) { Model.TableModel.Dms_file model = View2Model(newValue); List <Model.TableModel.Dms_file> modelList = new List <Model.TableModel.Dms_file>(); modelList.Add(model); return(DbEngine.QueryInt <Model.TableModel.Dms_file>("update", modelList)); }
/// <summary> /// 审核流程的建立 /// </summary> /// <param name="dfv">要发起审核流程的文件信息</param> /// <param name="userNo">用户名</param> /// <returns>处理结果</returns> public string CreateApprove(ModelView.DmsFileView dfv, string userNo) { if (dfv == null) { return("文件不存在!"); } //获取第一个审核流程视图 ApoItemCtrl aic = new ApoItemCtrl(); ModelView.ApoItemView aiv = aic.GetFirst(dfv.file_type_name); if (aiv == null) { return("未找到审核流程!"); } //获取下一个审核流程视图 ModelView.ApoItemView aivNext = aic.GetNext(aiv.apo_no, aiv.apo_item_no); if (aivNext == null) { return("该审核流程有误!"); } //用户构建 GlobalDataCtrl gdc = new GlobalDataCtrl(); string userName = gdc.GetStrByField("user_name", "sys_user", "user_no", userNo); //文件视图及审核流程视图创建Act视图并处理 ModelView.ApoActView aav = new ModelView.ApoActView(); aav.id = string.Empty; aav.status_no = "310"; aav.status_name = "已确认"; aav.act_no = string.Empty; aav.apo_no = aiv.apo_no; aav.apo_item_no = aiv.apo_item_no; aav.apo_item_name = aiv.apo_item_name; aav.apo_index = aiv.apo_index; aav.next_item_no = aiv.next_item_no; aav.next_item_name = aivNext.apo_item_name; aav.next_user_name = aivNext.apo_user_name; aav.act_desc = dfv.file_desc; aav.act_result = "通过"; aav.act_step = "0"; aav.act_user_no = userNo; aav.act_user_name = userName; aav.act_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); aav.ralate_no = dfv.file_no; aav.ralate_file_name = dfv.file_name; aav.ralate_file_extension = dfv.file_extension; aav.ralate_type_no = dfv.file_type_no; aav.step_finished = "否"; aav.apo_finished = "否"; aav.dept_no = string.Empty; aav.dept_name = string.Empty; //数据写入 ApoActCtrl aac = new ApoActCtrl(); return(aac.Insert(aav) > 0 ? "success" : "数据写入失败!"); }
/// <summary> /// 审核驳回 /// </summary> /// <param name="lastApoActView">前一审核动作视图</param> /// <param name="dmsFileView">要驳回审核的文件信息</param> /// <param name="userNo">用户名</param> /// <returns>处理结果</returns> public string RejectApprove(ModelView.ApoActView lastApoActView, ModelView.DmsFileView dmsFileView, string userNo) { string res = string.Empty; //获取下一个处理的流程视图 ApoItemCtrl apoItemCtrl = new ApoItemCtrl(); ModelView.ApoItemView nextApoItemView = apoItemCtrl.GetNext(lastApoActView.apo_no, lastApoActView.apo_item_no); if (nextApoItemView == null) { return("文件审核流程设定有误!"); } if (nextApoItemView.apo_user_no.ToLower() != userNo.ToLower()) { return("您无权审核此文件!"); } if (lastApoActView.act_result == "驳回") { return("无法驳回已驳回的文件,请重传!"); } //获取第一次发起的审核动作 ApoActCtrl apoActCtrl = new ApoActCtrl(); ModelView.ApoActView firstApoActView = apoActCtrl.GetFirst(dmsFileView.file_no); if (firstApoActView == null) { return("不存在对应的审核发起记录!"); } //确认上一流程 lastApoActView.step_finished = "是"; apoActCtrl.Update(lastApoActView); //按照驳回流程构造当前动作 lastApoActView.id = string.Empty; lastApoActView.status_name = "已确认"; lastApoActView.status_no = "310"; lastApoActView.act_no = string.Empty; lastApoActView.apo_item_no = nextApoItemView.apo_item_no; lastApoActView.apo_item_name = nextApoItemView.apo_item_name; lastApoActView.apo_index = nextApoItemView.apo_index; lastApoActView.next_item_no = firstApoActView.apo_item_no; lastApoActView.next_item_name = firstApoActView.apo_item_name; lastApoActView.next_user_name = firstApoActView.act_user_name; lastApoActView.act_result = "驳回"; int intTmp = 1; lastApoActView.act_step = (int.TryParse(lastApoActView.act_step, out intTmp) ? intTmp + 1 : 1).ToString(); lastApoActView.act_user_no = userNo; GlobalDataCtrl gdc = new GlobalDataCtrl(); lastApoActView.act_user_name = gdc.GetStrByField("user_name", "sys_user", "user_no", userNo); lastApoActView.act_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); lastApoActView.step_finished = "是"; lastApoActView.apo_finished = "否"; //数据写入 return(FinishApprove(lastApoActView)); }
/// <summary> /// 分页查询 /// </summary> /// <param name="where">where子句</param> /// <param name="orderBy">排序子句</param> /// <param name="pageSize">页面大小</param> /// <param name="pageIndex">页面索引</param> /// <param name="total">out参数,返回总记录条数</param> /// <returns>视图对象列表</returns> public List <ModelView.DmsFileView> GetListPage(string where, Dictionary <string, string> orderBy, int pageSize, int pageIndex, out int total) { List <Model.TableModel.Dms_file> list = DbEngine.QueryPage <Model.TableModel.Dms_file>("dms_file", pageIndex, pageSize, where, orderBy, out total); List <ModelView.DmsFileView> res = new List <ModelView.DmsFileView>(); foreach (Model.TableModel.Dms_file item in list) { ModelView.DmsFileView model = Model2View(item); res.Add(model); } return(res); }
/// <summary> /// 分页查询 /// </summary> /// <param name="where">where子句</param> /// <param name="orderBy">排序子句</param> /// <param name="pageSize">页面大小</param> /// <param name="pageIndex">页面索引</param> /// <returns>最终结果字符串</returns> public string GetListPage(string where, Dictionary <string, string> orderBy, int pageSize, int pageIndex) { int total = 0; List <Model.TableModel.Dms_file> list = DbEngine.QueryPage <Model.TableModel.Dms_file>("dms_file", pageIndex, pageSize, where, orderBy, out total); List <ModelView.DmsFileView> res = new List <ModelView.DmsFileView>(); foreach (Model.TableModel.Dms_file item in list) { ModelView.DmsFileView model = Model2View(item); res.Add(model); } return(Common.JsonHelper.SerializeObject(new { total = total, rows = res })); }
/// <summary> /// 数据插入 /// </summary> /// <param name="newValue">新插入的值</param> /// <returns>影响记录条数</returns> public int Insert(ModelView.DmsFileView newValue) { try { Model.TableModel.Dms_file model = View2Model(newValue); Ctrl.Bll.ApoActBll apoActBll = new Bll.ApoActBll(); apoActBll.CreateApprove(Model2View(model), newValue.login_user_no); List <Model.TableModel.Dms_file> modelList = new List <Model.TableModel.Dms_file>(); modelList.Add(model); return(DbEngine.QueryInt <Model.TableModel.Dms_file>("Insert", modelList)); } catch (Exception) { throw; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string msg = "success"; string dmsFile = context.Request["dmsFile"] ?? "OBJECT"; if (!string.IsNullOrEmpty(dmsFile) && dmsFile != "OBJECT") { ModelView.DmsFileView dmsFileView = Common.JsonHelper.DeserializeJsonToObject <ModelView.DmsFileView>(dmsFile); Ctrl.Bll.DmsFileBll dmsFileBll = new Ctrl.Bll.DmsFileBll(); msg = dmsFileBll.DeleteFile(dmsFileView); } else { msg = "要删除的文件目标不存在"; } context.Response.Write(Common.JsonHelper.SerializeObject(new { msg = msg })); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string objNeedOperate = context.Request["objNeedOperate"] ?? "OBJECT"; if (!string.IsNullOrEmpty(objNeedOperate) && objNeedOperate != "OBJECT") { ModelView.DmsFileView dmsFileView = Common.JsonHelper.DeserializeJsonToObject <ModelView.DmsFileView>(objNeedOperate); Ctrl.Bll.FtpBll ftp = new Ctrl.Bll.FtpBll(); //配置信息读取 string ftpHostIp = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "ftpHost", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string ftpRelativePath = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "mainFtpPath", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string ftpBackupPath = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "backupFtpPath", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string writeUserNo = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "writeUserNo", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string writeUserPwd = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "writeUserPwd", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string readUserNo = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "readUserNo", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string readUserPwd = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "readUserPwd", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string tmpPath = AppDomain.CurrentDomain.BaseDirectory + "Tmp"; string msg = ftp.FtpDownload(tmpPath, ftpRelativePath, ftpHostIp, readUserNo, readUserPwd, dmsFileView); context.Response.Write(Common.JsonHelper.SerializeObject(new { msg = msg })); } }
/// <summary> /// 删除文件 /// </summary> /// <param name="fileView">文件视图</param> /// <returns>删除结果</returns> public string DeleteFile(ModelView.DmsFileView fileView) { if (fileView == null) { return("操作目标对象为空!"); } ApoActCtrl apoActCtrl = new ApoActCtrl(); bool b = apoActCtrl.DeleteByRalate(fileView.file_no) > 0; if (b) { DmsFileCtrl dmsFileCtrl = new DmsFileCtrl(); b = dmsFileCtrl.Delete(fileView) > 0; if (b) { FtpBll ftpBll = new FtpBll(); //配置信息读取 string ftpHostIp = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "ftpHost", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string ftpRelativePath = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "mainFtpPath", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string ftpBackupPath = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "backupFtpPath", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string writeUserNo = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "writeUserNo", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string writeUserPwd = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "writeUserPwd", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string readUserNo = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "readUserNo", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string readUserPwd = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "readUserPwd", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string tmpPath = AppDomain.CurrentDomain.BaseDirectory + "Tmp"; string res = ftpBll.FtpDelete(ftpRelativePath, ftpHostIp, writeUserNo, writeUserPwd, fileView); return(res); } else { return("文件记录删除失败!"); } } else { return("删除动作记录失败!"); } }
/// <summary> /// 设定文件生效日期 /// </summary> /// <param name="fileView"></param> /// <param name="dateStr">生效起始日期字符串</param> /// <returns></returns> public string SetValidDate(ModelView.DmsFileView fileView, string dateStr) { if (fileView == null) { return("无法设定目标文件为空的文件生效日期"); } DmsFileCtrl dmsFileCtrl = new DmsFileCtrl(); List <ModelView.DmsFileView> list = dmsFileCtrl.GetList(fileView.file_no, fileView.eqm_no, fileView.file_type_no); DateTime dtTmp = DateTime.Now; DateTime dtStart = (DateTime.TryParse(dateStr, out dtTmp) ? dtTmp : DateTime.Now).Date; DateTime dtStop = dtStart - new TimeSpan(0, 0, 1); string validDateStart = dtStart.ToString("yyyy-MM-dd HH:mm:ss.fff"); string validDateEnd = dtStop.ToString("yyyy-MM-dd HH:mm:ss.fff"); List <ModelView.DmsFileView> list2Update = new List <ModelView.DmsFileView>(); foreach (ModelView.DmsFileView item in list) { item.valid_date_end = validDateEnd; list2Update.Add(item); } fileView.valid_date_start = validDateStart; list2Update.Add(fileView); return(dmsFileCtrl.Update(list2Update) > 0 ? "success" : "生效日期数据写入失败!"); }
/// <summary> /// 实体类转视图类 /// </summary> /// <param name="model">实体类</param> /// <returns>视图类</returns> private ModelView.DmsFileView Model2View(Model.TableModel.Dms_file model) { ModelView.DmsFileView view = new ModelView.DmsFileView(); view.id = model.id; view.file_no = model.file_no; view.file_name = model.file_name; view.file_extension = model.file_extension; view.file_info = model.file_name + model.file_extension; view.file_type_no = model.file_type_no; view.file_type_name = model.file_type_name; view.file_version = model.file_version; view.file_desc = model.file_desc; view.eqm_no = model.eqm_no; view.file_md5 = model.file_md5; view.is_passed = model.is_passed?"是":"否"; view.file_status = model.file_status; view.ralate_file_name = model.ralate_file_name; view.valid_date_start = model.valid_date_start.HasValue ? ((DateTime)model.valid_date_start).ToString("yyyy-MM-dd") : string.Empty; view.valid_date_end = model.valid_date_end.HasValue ? ((DateTime)model.valid_date_end).ToString("yyyy-MM-dd HH:mm:ss.fff") : string.Empty; return(view); }
/// <summary> /// 审核通过 /// </summary> /// <param name="lastApoActView">前一审核动作视图</param> /// <param name="dmsFileView">要发起审核流程的文件信息</param> /// <param name="userNo">用户名</param> /// <returns>处理结果</returns> public string PassApprove(ModelView.ApoActView lastApoActView, ModelView.DmsFileView dmsFileView, string userNo)//文件类型对应审核类型编号 { string res = "success"; //获取下一个处理的流程视图 ApoItemCtrl apoItemCtrl = new ApoItemCtrl(); ModelView.ApoItemView nextApoItemView = apoItemCtrl.GetNext(lastApoActView.apo_no, lastApoActView.apo_item_no); if (nextApoItemView == null) { return("文件审核流程设定有误!"); } if (nextApoItemView.apo_user_no.ToLower() != userNo.ToLower()) { return("您无权审核此文件!"); } if (lastApoActView.act_result == "驳回") { return("无法通过已驳回的文件,请重传!"); } //获取最后一个处理的流程视图 ModelView.ApoItemView lastApoItemView = apoItemCtrl.GetLast(lastApoActView.apo_no); //确认上一流程 lastApoActView.step_finished = "是"; ApoActCtrl apoActCtrl = new ApoActCtrl(); apoActCtrl.Update(lastApoActView); //按照结束流程构造当前动作 lastApoActView.id = string.Empty; lastApoActView.status_name = "已确认"; lastApoActView.status_no = "310"; lastApoActView.act_no = string.Empty; lastApoActView.apo_item_no = nextApoItemView.apo_item_no; lastApoActView.apo_item_name = nextApoItemView.apo_item_name; lastApoActView.apo_index = nextApoItemView.apo_index; lastApoActView.next_item_no = nextApoItemView.next_item_no; lastApoActView.next_item_name = string.Empty; lastApoActView.next_user_name = string.Empty; lastApoActView.act_result = "通过"; int intTmp = 1; lastApoActView.act_step = (int.TryParse(lastApoActView.act_step, out intTmp) ? intTmp + 1 : 1).ToString(); lastApoActView.act_user_no = userNo; GlobalDataCtrl gdc = new GlobalDataCtrl(); lastApoActView.act_user_name = gdc.GetStrByField("user_name", "sys_user", "user_no", userNo); lastApoActView.act_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); lastApoActView.step_finished = "是"; lastApoActView.apo_finished = "是"; ////如果是最后一个,同意的同时添加流程结束处理,即更新现有流程,同时更新文件状态 if (nextApoItemView.apo_item_no == lastApoItemView.apo_item_no) { res = FinishApprove(lastApoActView); if (res == "success") { dmsFileView.is_passed = "是"; dmsFileView.file_status = "使用中"; res = UpdateFile(dmsFileView); } } else { ModelView.ApoItemView nextLowerApoItemView = apoItemCtrl.GetNext(lastApoActView.apo_no, lastApoActView.apo_item_no); if (nextLowerApoItemView == null) { return("文件审核流程设定有误!"); } lastApoActView.next_item_name = nextLowerApoItemView.apo_item_name; lastApoActView.next_user_name = nextLowerApoItemView.apo_user_name; lastApoActView.step_finished = "否"; lastApoActView.apo_finished = "否"; res = Move2NextApprove(lastApoActView); } return(res); }
/// <summary> /// Ftp文件删除操作 /// </summary> /// <param name="ftpRelativePath">ftp的相对目标路径</param> /// <param name="hostIp">ftp主机IP</param> /// <param name="userNo">ftp用户名</param> /// <param name="userPwd">ftp用户密码</param> /// <param name="viewModel">文件视图对象</param> /// <returns>操作结果</returns> public string FtpDelete(string ftpRelativePath, string hostIp, string userNo, string userPwd, ModelView.DmsFileView viewModel) { if (viewModel == null) { return("操作对象不能为空!"); } string msg = "success"; string fileOperateName = viewModel.file_md5 + "_" + System.IO.Path.GetFileNameWithoutExtension(viewModel.file_info) + System.IO.Path.GetExtension(viewModel.file_info); msg = Common.FTPStreamHelper.DelFile(fileOperateName, ftpRelativePath, hostIp, userNo, userPwd) ? "success" : "Ftp删除文件失败!"; return(msg); }
/// <summary> /// ftp文件移动操作 /// </summary> /// <param name="ftpSourcePath">Ftp文件原始路径</param> /// <param name="destinyPath">Ftp文件目标路径</param> /// <param name="fullTmpPath">Ftp文件中转路径</param> /// <param name="hostIp">ftp主机IP</param> /// <param name="userNo">ftp用户名</param> /// <param name="userPwd">ftp用户密码</param> /// <param name="viewModel">文件视图对象</param> /// <returns>操作结果</returns> public string FtpRemove(string ftpSourcePath, string destinyPath, string fullTmpPath, string hostIp, string userNo, string userPwd, ModelView.DmsFileView viewModel) { if (viewModel == null) { return("操作对象不能为空!"); } string msg = "success"; string filefullPath = string.Empty; string fileOperateName = viewModel.file_md5 + "_" + System.IO.Path.GetFileNameWithoutExtension(viewModel.file_info) + System.IO.Path.GetExtension(viewModel.file_info); filefullPath = fullTmpPath.EndsWith("\\") ? fullTmpPath + fileOperateName : fullTmpPath + "\\" + fileOperateName; File.Delete(filefullPath); if (!Common.FTPStreamHelper.DownloadFile(fullTmpPath, ftpSourcePath, fileOperateName, hostIp, userNo, userPwd)) { return("Ftp故障,文件移动失败!"); } if (!Common.FTPStreamHelper.DelFile(fileOperateName, ftpSourcePath, hostIp, userNo, userPwd)) { return("Ftp故障,文件移动失败!"); } MemoryStream ms = Common.MemeoryOperater.File2MemoryStream(filefullPath); msg = FtpAdd(ms, ftpSourcePath, hostIp, userNo, userPwd, viewModel); msg = msg == "success" ? msg : "文件移动:" + msg; File.Delete(filefullPath); return(msg); }
/// <summary> /// 文件信息的审核通过的写入 /// </summary> /// <param name="dmsFileView">要更新的文件视图</param> /// <returns>更新的消息</returns> private string UpdateFile(ModelView.DmsFileView dmsFileView) { DmsFileCtrl dmsfileCtrl = new DmsFileCtrl(); return(dmsfileCtrl.Update(dmsFileView) > 0?"success":"文件信息写入失败!"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string msg = "success"; string rowStr = context.Request["row"] ?? string.Empty; if (string.IsNullOrEmpty(rowStr)) { ResOutput(context, "操作对象为空,请重试!"); } ModelView.DmsFileView fileView = Common.JsonHelper.DeserializeJsonToObject <ModelView.DmsFileView>(rowStr); HttpCookie cookies = context.Request.Cookies["MesCookie"]; string cookieStr = string.Empty; if (cookies == null || string.IsNullOrEmpty(cookies.Value)) { //context.Response.Redirect("/LoginForm.aspx"); } else { cookieStr = cookies.Value; } var obj = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(cookieStr) as JToken; //fileView.login_user_no = obj["userNo"].ToString(); //fileView.login_user_name = obj["userName"].ToString(); Ctrl.GlobalDataCtrl gdc = new Ctrl.GlobalDataCtrl(); string fileInfo = context.Request["fileInfo"] ?? string.Empty; if (string.IsNullOrEmpty(fileInfo)) { ResOutput(context, "无法读取目标文件信息!"); } //获取客户端上传的文件集合 HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; if (files.Count != 1) { ResOutput(context, "只能上传单一文件,请确认文件数量!"); } try { MemoryStream ms = new MemoryStream(files[0].ContentLength); ms.Write(Common.MemeoryOperater.Stream2Byte(files[0].InputStream), 0, files[0].ContentLength); //配置信息读取 string ftpHostIp = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "ftpHost", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string ftpRelativePath = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "mainFtpPath", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string ftpBackupPath = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "backupFtpPath", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string writeUserNo = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "writeUserNo", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string writeUserPwd = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "writeUserPwd", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string readUserNo = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "readUserNo", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string readUserPwd = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "readUserPwd", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string tmpPath = AppDomain.CurrentDomain.BaseDirectory + "Tmp"; Ctrl.Bll.FtpBll ftp = new Ctrl.Bll.FtpBll(); msg = ftp.FtpAdd(ms, ftpRelativePath, ftpHostIp, writeUserNo, writeUserPwd, fileView, fileInfo); } catch (Exception) { ResOutput(context, "传入数据有误!"); } ResOutput(context, msg); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string msg = "success"; //获取传入的参数及校验 string approveResult = context.Request["approveResult"] ?? "APPROVERESULT"; if (string.IsNullOrEmpty(approveResult) || approveResult == "APPROVERESULT") { ResOutPut(context, "审核结果不合法!"); } string rowFile = context.Request["rowFile"] ?? "ROWFILE"; if (string.IsNullOrEmpty(rowFile) && rowFile == "ROWFILE") { ResOutPut(context, "文件信息有误!"); } string rowApoAct = context.Request["rowApoAct"] ?? "ROWAPPROVE"; if (string.IsNullOrEmpty(rowApoAct) && rowApoAct == "ROWAPPROVE") { ResOutPut(context, "审核信息有误!"); } //获取当前用户 HttpCookie cookies = context.Request.Cookies["MesCookie"]; string cookieStr = string.Empty; if (cookies == null || string.IsNullOrEmpty(cookies.Value)) { //context.Response.Redirect("/LoginForm.aspx"); } else { cookieStr = cookies.Value; } var obj = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(cookieStr) as JToken; string userNo = obj == null ? string.Empty : ((obj["userNo"] ?? string.Empty).ToString()); //类构建 ModelView.DmsFileView dmsFileView = Common.JsonHelper.DeserializeJsonToObject <ModelView.DmsFileView>(rowFile); ModelView.ApoActView apoActView = Common.JsonHelper.DeserializeJsonToObject <ModelView.ApoActView>(rowApoAct); //dfv.login_user_no = obj["userNo"].ToString(); //dfv.login_user_name = obj["userName"].ToString(); Ctrl.Bll.ApoActBll apoActBll = new Ctrl.Bll.ApoActBll(); if (approveResult == "通过") { try { msg = apoActBll.PassApprove(apoActView, dmsFileView, userNo); } catch (Exception) { ResOutPut(context, "审核通过失败"); } } else if (approveResult == "驳回") { try { msg = apoActBll.RejectApprove(apoActView, dmsFileView, userNo); } catch (Exception) { ResOutPut(context, "审核驳回失败"); } } else { ResOutPut(context, "审核结果不合法!"); } ResOutPut(context, msg); }
/// <summary> /// FTP文件添加操作 /// </summary> /// <param name="msFile">内存流中的文件</param> /// <param name="ftpRelativePath">ftp的相对目标路径</param> /// <param name="hostIp">ftp主机IP</param> /// <param name="userNo">ftp用户名</param> /// <param name="userPwd">ftp用户密码</param> /// <param name="viewModel">文件视图对象</param> /// <returns>操作结果</returns> public string FtpAdd(MemoryStream msFile, string ftpRelativePath, string hostIp, string userNo, string userPwd, ModelView.DmsFileView viewModel) { if (viewModel == null) { return("操作对象不能为空!"); } //生成文件md5值 viewModel.file_md5 = Common.Md5Operate.GetMD5FromMemoryStream(msFile); string fileExtension = System.IO.Path.GetExtension(viewModel.file_info); string fileOperateName = viewModel.file_md5 + "_" + System.IO.Path.GetFileNameWithoutExtension(viewModel.file_info) + fileExtension; if (viewModel.file_type_no.ToLower() == "08" || viewModel.file_type_no.ToLower() == "09")//bom和pms { if (!(fileExtension.ToLower() == ".xls" || fileExtension.ToLower() == ".xlsx")) { return("文件格式不正确!"); } } //文件格式校验 List <string> exts = new List <string>(); exts.Add(".doc"); exts.Add(".docx"); exts.Add(".xls"); exts.Add(".xlsx"); exts.Add(".ppt"); exts.Add(".ppts"); if (!exts.Contains(fileExtension.ToLower())) { return("文件格式不正确!"); } //校验文件是否存在 if (Common.FTPStreamHelper.FtpExistFile(ftpRelativePath, fileOperateName, hostIp, userNo, userPwd)) { return("不能上传已存在的文件!"); } if (Common.FTPStreamHelper.UploadFile(msFile, fileOperateName, ftpRelativePath, hostIp, userNo, userPwd)) { Ctrl.DmsFileCtrl dfc = new DmsFileCtrl(); if (dfc.Insert(viewModel) > 0) { return("success"); } else { Common.FTPStreamHelper.DelFile(fileOperateName, ftpRelativePath, hostIp, userNo, userPwd); return("数据写入失败!"); } } else { return("Ftp文件上传失败!"); } }
/// <summary> /// 更新操作 /// </summary> /// <param name="jsonStr">更新后对象的json序列化字符串</param> /// <returns>影响记录条数</returns> public int Update(string jsonStr) { ModelView.DmsFileView model = Common.JsonHelper.DeserializeJsonToObject <ModelView.DmsFileView>(jsonStr); return(Update(model)); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string msg = "success"; string rowStr = context.Request["row"] ?? string.Empty; if (string.IsNullOrEmpty(rowStr)) { ResOutput(context, "操作对象为空,请重试!"); } ModelView.DmsFileView fileView = Common.JsonHelper.DeserializeJsonToObject <ModelView.DmsFileView>(rowStr); HttpCookie cookies = context.Request.Cookies["MesCookie"]; string cookieStr = string.Empty; if (cookies == null || string.IsNullOrEmpty(cookies.Value)) { //context.Response.Redirect("/LoginForm.aspx"); } else { cookieStr = cookies.Value; } var obj = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(cookieStr) as JToken; fileView.login_user_no = obj["userNo"].ToString(); fileView.login_user_name = obj["userName"].ToString(); Ctrl.GlobalDataCtrl gdc = new Ctrl.GlobalDataCtrl(); if (string.IsNullOrEmpty(gdc.GetStrByField("file_type_name", "dms_file_type", "file_type_no", fileView.file_type_no))) { ResOutput(context, "文件类型选择有误!"); } string operate = context.Request["operate"] ?? string.Empty; if (!string.IsNullOrEmpty(operate) && (operate.ToLower() != "add" || operate.ToLower() == "update")) { ResOutput(context, string.Format("操作:{0}非法!", operate)); } //获取客户端上传的文件集合 HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; if (files.Count != 1) { ResOutput(context, "只能上传单一文件,请确认文件数量!"); } MemoryStream ms = new MemoryStream(files[0].ContentLength); ms.Write(Common.MemeoryOperater.Stream2Byte(files[0].InputStream), 0, files[0].ContentLength); //配置信息读取 string ftpHostIp = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "ftpHost", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string ftpRelativePath = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "mainFtpPath", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string ftpBackupPath = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "backupFtpPath", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string writeUserNo = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "writeUserNo", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string writeUserPwd = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "writeUserPwd", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string readUserNo = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "readUserNo", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string readUserPwd = Common.ConfigHelper.GetConfigValueFromXml("ftpSet", "readUserPwd", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml"); string tmpPath = AppDomain.CurrentDomain.BaseDirectory + "Tmp"; try { Ctrl.Bll.FtpBll ftp = new Ctrl.Bll.FtpBll(); switch (operate.ToLower()) { case "add": msg = ftp.FtpAdd(ms, ftpRelativePath, ftpHostIp, writeUserNo, writeUserPwd, fileView); break; case "update": msg = ftp.FtpRemove(ftpRelativePath, ftpBackupPath, tmpPath, ftpHostIp, writeUserPwd, writeUserPwd, fileView); if (msg == "success") { msg = ftp.FtpAdd(ms, ftpRelativePath, ftpHostIp, writeUserNo, writeUserPwd, fileView); } break; default: ResOutput(context, string.Format("操作:{0}非法!", operate)); break; } } catch (Exception) { ResOutput(context, "传入数据有误!"); } ResOutput(context, msg); }
/// <summary> /// ftp文件下载操作 /// </summary> /// <param name="destinyPath">ftp下载路径</param> /// <param name="currentPath">ftp相对路径</param> /// <param name="hostIp">主机IP</param> /// <param name="userNo">ftp用户名</param> /// <param name="userPwd">ftp密码</param> /// <param name="viewModel">文件类型</param> /// <returns>结果消息</returns> public string FtpDownload(string destinyPath, string currentPath, string hostIp, string userNo, string userPwd, ModelView.DmsFileView viewModel) { if (viewModel == null) { return("操作对象不能为空!"); } string fileOperateName = viewModel.file_md5 + "_" + System.IO.Path.GetFileNameWithoutExtension(viewModel.file_info) + System.IO.Path.GetExtension(viewModel.file_info); string fileFullPath = destinyPath.EndsWith("\\") ? destinyPath + fileOperateName : destinyPath + "\\" + fileOperateName; System.IO.File.Delete(fileFullPath); if (!Common.FTPStreamHelper.DownloadFile(destinyPath, currentPath, fileOperateName, hostIp, userNo, userPwd)) { return("Ftp故障,文件移动失败!"); } string fileNameNew = System.IO.Path.GetFileNameWithoutExtension(viewModel.file_info) + System.IO.Path.GetExtension(viewModel.file_info); string fileFullPathNew = destinyPath.EndsWith("\\") ? destinyPath + fileNameNew : destinyPath + "\\" + fileNameNew; System.IO.File.Copy(fileFullPath, fileFullPathNew, true); System.IO.File.Delete(fileFullPath); return("success"); }
/// <summary> /// FTP文件添加操作 /// </summary> /// <param name="msFile">内存流中的文件</param> /// <param name="ftpRelativePath">ftp的相对目标路径</param> /// <param name="hostIp">ftp主机IP</param> /// <param name="userNo">ftp用户名</param> /// <param name="userPwd">ftp用户密码</param> /// <param name="viewModel">文件信息</param> /// <param name="fileInfo">附件信息(名称+拓展名)</param> /// <returns>操作结果</returns> public string FtpAdd(MemoryStream msFile, string ftpRelativePath, string hostIp, string userNo, string userPwd, ModelView.DmsFileView viewModel, string fileInfo) { if (string.IsNullOrEmpty(fileInfo)) { return("目标文件信息无法读取!"); } string fileExtension = System.IO.Path.GetExtension(fileInfo); string fileOperateName = fileInfo; //文件格式校验 List <string> exts = new List <string>(); exts.Add(".doc"); exts.Add(".docx"); exts.Add(".xls"); exts.Add(".xlsx"); exts.Add(".ppt"); exts.Add(".ppts"); if (!exts.Contains(fileExtension.ToLower())) { return("文件格式不正确!"); } //校验文件是否存在 if (Common.FTPStreamHelper.FtpExistFile(ftpRelativePath, fileOperateName, hostIp, userNo, userPwd)) { return("不能上传已存在的文件!"); } if (Common.FTPStreamHelper.UploadFile(msFile, fileOperateName, ftpRelativePath, hostIp, userNo, userPwd)) { viewModel.ralate_file_name = fileInfo; Ctrl.DmsFileCtrl dfc = new DmsFileCtrl(); if (dfc.Update(viewModel) > 0) { return("success"); } else { Common.FTPStreamHelper.DelFile(fileOperateName, ftpRelativePath, hostIp, userNo, userPwd); return("数据写入失败!"); } } else { return("Ftp文件上传失败!"); } }