protected void btnExcelOut_Click(object sender, EventArgs e) { string strValue = this.hidSave.Value; string fill_ID = this.hidType.Value.ToString(); DataTable dt = new TOaAttLogic().Detail_type(strValue); if (dt.Rows.Count > 0) { string mastPath = System.Configuration.ConfigurationManager.AppSettings["AttPath"].ToString(); string fileName = dt.Rows[0]["ATTACH_NAME"].ToString() + dt.Rows[0]["ATTACH_TYPE"].ToString(); string filePath = mastPath + '\\' + dt.Rows[0]["UPLOAD_PATH"].ToString(); if (File.Exists(filePath) == false) { LigerDialogAlert("附件不存在,下载失败", "error"); } FileInfo fileInfo = new FileInfo(filePath); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(fileName)); Response.AddHeader("Content-Length", fileInfo.Length.ToString()); Response.AddHeader("Content-Transfer-Encoding", "binary"); Response.ContentType = "application/octet-stream"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); Response.WriteFile(fileInfo.FullName); Response.Flush(); Response.End(); } }
public static string deleteDataInfo(string strValue) { bool isSuccess = false; isSuccess = new TOaAttLogic().DeleteInfo(strValue); return(isSuccess == true ? "1" : "0"); }
public static string getNoticeInfo() { string serverPath = "..\\Channels\\OA\\Notice\\Image"; DataTable dt = new TOaNoticeLogic().getTopTenData(); dt.Columns.Add("Path", System.Type.GetType("System.String")); foreach (DataRow row in dt.Rows) { if (row["CONTENT"].ToString().Length > 140) { row["CONTENT"] = row["CONTENT"].ToString().Substring(0, 140) + "..."; } TOaAttVo TOaAttVo = new TOaAttVo(); TOaAttVo.BUSINESS_ID = row["ID"].ToString(); TOaAttVo.BUSINESS_TYPE = "OA_NOTICE"; TOaAttVo TOaAttVoTemp = new TOaAttLogic().Details(TOaAttVo); string strExtent = TOaAttVoTemp.ATTACH_TYPE; string path = serverPath + "\\" + row["ID"].ToString() + strExtent; if (strExtent != "") { row["Path"] = path; } else { row["Path"] = "..\\Channels\\OA\\Notice\\default.gif"; } } string strJson = DataTableToJson(dt); return(strJson); }
protected void showDetail() { TOaAttVo TOaAttVo = new TOaAttVo(); TOaAttVo.BUSINESS_ID = this.Request["id"].ToString(); TOaAttVo.BUSINESS_TYPE = this.Request["filetype"].ToString(); TOaAttVo TOaAttVoTemp = new TOaAttLogic().Details(TOaAttVo); this.ATTACH_NAME.Text = TOaAttVoTemp.ATTACH_NAME; this.DESCRIPTION.Text = TOaAttVoTemp.DESCRIPTION; }
/// <summary> /// 创建原因:查找当前子任务是否已经复制了点位图 /// 创建人:胡方扬 /// 创建日期:2013-07-03 /// </summary> /// <param name="strSubTaskID"></param> /// <returns></returns> public bool GetSubTaskAtt(string strSubTaskID) { bool blFlag = false; TOaAttVo objTOaAttVo = new TOaAttVo(); objTOaAttVo.BUSINESS_ID = strSubTaskID; objTOaAttVo.BUSINESS_TYPE = "SubTask"; DataTable dt = new TOaAttLogic().SelectByTable(objTOaAttVo); if (dt.Rows.Count > 0) { blFlag = true; } return(blFlag); }
private void RtnInfo(string ID, string strFileType) { string json = string.Empty; if (!string.IsNullOrEmpty(this.Request["ID"].ToString())) { ID = this.Request["ID"].ToString();//填报数据的第一行的ID DataTable dts = new TOaAttLogic().DetailZW(ID, strFileType); if (dts.Rows.Count > 0) { string Json = CreateToJson(dts, dts.Rows.Count); Response.ContentType = "application/json;charset=utf-8"; Response.Write(Json); Response.End(); } } }
protected void btnFileClear_Click(object sender, EventArgs e) { //获取主文件路径 string mastPath = System.Configuration.ConfigurationManager.AppSettings["AttPath"].ToString(); TOaAttVo TOaAttVo = new TOaAttVo(); TOaAttVo.BUSINESS_TYPE = this.Request["filetype"].ToString(); TOaAttVo.BUSINESS_ID = this.Request["id"].ToString(); //获取路径信息 DataTable objTable = new TOaAttLogic().SelectByTable(TOaAttVo); if (objTable.Rows.Count > 0) { try { //获取该记录的ID string strId = objTable.Rows[0]["ID"].ToString(); //获取原来文件的路径 string strOldFilePath = objTable.Rows[0]["UPLOAD_PATH"].ToString(); //如果存在的话,删除原来的文件 if (File.Exists(mastPath + "\\" + strOldFilePath)) { File.Delete(mastPath + "\\" + strOldFilePath); } //删除数据库信息 if (new TOaAttLogic().Delete(TOaAttVo)) { this.status.Value = "2"; LigerDialogAlert("附件清除成功", "success"); } else { this.status.Value = "0"; LigerDialogAlert("附件清除失败", "error"); } } catch (Exception ex) { LigerDialogAlert(ex.Message, "error"); } } else { LigerDialogAlert("不存在附件信息", "error"); } }
/// <summary> /// 加载数据 /// </summary> /// <returns></returns> public string frmLoadData() { TOaAttVo TOaAttVo = new TOaAttVo(); TOaAttVo.BUSINESS_ID = this.Request["id"].ToString(); TOaAttVo.BUSINESS_TYPE = "OA_NOTICE"; TOaAttVo TOaAttVoTemp = new TOaAttLogic().Details(TOaAttVo); string strUrl = TOaAttVoTemp.UPLOAD_PATH; string mastPath = System.Configuration.ConfigurationManager.AppSettings["AttPath"].ToString(); string filePath = mastPath + '\\' + strUrl; TOaNoticeVo TOaNoticeVo = new TOaNoticeVo(); TOaNoticeVo.ID = Request["id"].ToString(); TOaNoticeVo TOaNoticeVoTemp = new TOaNoticeLogic().Details(TOaNoticeVo); return(ToJson(TOaNoticeVoTemp)); }
protected void Page_Load(object sender, EventArgs e) { if (Request["action"] != null) { string json = string.Empty; if (!string.IsNullOrEmpty(this.Request["IsInsert"].ToString()) && this.Request["IsInsert"].ToString() == "true") { #region//新增时调用 if (!string.IsNullOrEmpty(this.Request["Save"].ToString()) && !string.IsNullOrEmpty(this.Request["filetype"].ToString())) { string save = this.Request["Save"].ToString(); string fillType = this.Request["filetype"].ToString(); string strResult = this.SaveFWData(save, fillType, ID); json = json = "{\"result\":\"success\",\"ID\":\"" + strResult + "\"}"; Response.ContentType = "application/json;charset=utf-8"; Response.Write(json); Response.End(); } #endregion } else { #region//一开始加载时,或者上传完,点关闭,查询数据 if (!string.IsNullOrEmpty(this.Request["ID"].ToString())) { string ID = this.Request["ID"].ToString();//填报数据的第一行的ID if (ID.IndexOf("First") != -1) { DataTable dts = new TOaAttLogic().DetailFill_ID(ID); if (dts.Rows.Count > 0) { string Json = CreateToJson(dts, dts.Rows.Count); Response.ContentType = "application/json;charset=utf-8"; Response.Write(Json); Response.End(); } } } #endregion } } }
/// <summary> /// 将显示序号前10条任务存储在临时目录 /// </summary> /// <returns></returns> private void loadPicToTemp() { DataTable dt = new TOaNoticeLogic().getTopTenData(); //清空Image临时文件夹下所有的临时文件 string serverPath = HttpRuntime.AppDomainAppPath + "Channels\\OA\\Notice\\Image"; DirectoryInfo di = new DirectoryInfo(serverPath); if (di.Exists) { FileInfo[] files = di.GetFiles(); foreach (FileInfo fi in files) { try { fi.Delete(); } catch (Exception ex) { } } } //将文件库中的文件复制到临时文件目录下 //获取主文件路径 string mastPath = System.Configuration.ConfigurationManager.AppSettings["AttPath"].ToString(); foreach (DataRow row in dt.Rows) { string id = row["ID"].ToString(); TOaAttVo TOaAttVo = new TOaAttVo(); TOaAttVo.BUSINESS_ID = id; TOaAttVo.BUSINESS_TYPE = "OA_NOTICE"; TOaAttVo TOaAttVoTemp = new TOaAttLogic().Details(TOaAttVo); string strExtent = TOaAttVoTemp.ATTACH_TYPE; string Path = TOaAttVoTemp.UPLOAD_PATH; string sumPath = mastPath + '\\' + Path; try { File.Copy(sumPath, serverPath + "\\" + id + strExtent, true); } catch (Exception ex) { } } }
protected void showDetail() { TOaAttVo TOaAttVo = new TOaAttVo(); //======Begin 添加按照附加ID进行加载下载附件信息 胡方扬 2013-01-09======== if (!String.IsNullOrEmpty(this.Request["strAttID"])) { TOaAttVo.ID = this.Request["strAttID"].Trim(); } else { TOaAttVo.BUSINESS_ID = this.Request["id"].ToString(); TOaAttVo.BUSINESS_TYPE = this.Request["filetype"].ToString(); } //======End 添加按照附加ID进行加载下载附件信息 胡方扬 2013-01-09======== TOaAttVo TOaAttVoTemp = new TOaAttLogic().Details(TOaAttVo); this.btnFileName.Text = TOaAttVoTemp.ATTACH_NAME + TOaAttVoTemp.ATTACH_TYPE; this.lblUploadDate.Text = TOaAttVoTemp.UPLOAD_DATE; this.lblUploadPerson.Text = TOaAttVoTemp.UPLOAD_PERSON; this.lblDescription.Text = TOaAttVoTemp.DESCRIPTION; this.hidden.Value = TOaAttVoTemp.UPLOAD_PATH; }
/// <summary> /// 导出、打印发文 /// </summary> /// <param name="fwID">发文ID</param> public void FWExport(string fwID) { //获取基本信息 TOaFwInfoVo objFW = new TOaFwInfoLogic().Details(fwID); FileStream file = new FileStream(HttpContext.Current.Server.MapPath("template/FW.xls"), FileMode.Open, FileAccess.Read); HSSFWorkbook hssfworkbook = new HSSFWorkbook(file); ISheet sheet = hssfworkbook.GetSheet("Sheet1"); //sheet.GetRow(3).GetCell(2).SetCellValue("签发");//签发 //sheet.GetRow(3).GetCell(4).SetCellValue("会签");//会签 //sheet.GetRow(5).GetCell(2).SetCellValue("文件标题");//文件标题 //sheet.GetRow(6).GetCell(2).SetCellValue("附件");//附件 //sheet.GetRow(7).GetCell(2).SetCellValue("主送单位");//主送单位 //sheet.GetRow(8).GetCell(2).SetCellValue("抄报单位");//抄报单位 //sheet.GetRow(8).GetCell(4).SetCellValue("抄送单位");//抄送单位 //sheet.GetRow(11).GetCell(1).SetCellValue("科室审核");//科室审核 //sheet.GetRow(11).GetCell(3).SetCellValue("拟稿人");//拟稿人 //sheet.GetRow(12).GetCell(2).SetCellValue("编号");//编号 //sheet.GetRow(12).GetCell(3).SetCellValue("2013年印发");//印发日期 //sheet.GetRow(13).GetCell(2).SetCellValue("说明");//说明 //sheet.GetRow(14).GetCell(2).SetCellValue("主题词");//主题词 string fwDate = ""; if (!string.IsNullOrEmpty(objFW.FW_DATE)) { DateTime date = Convert.ToDateTime(objFW.FW_DATE); fwDate = string.Format("{0} 年 {1} 月 {2} 日 印发", date.Year, date.Month, date.Day); } else { fwDate = string.Format("年 月 日 印发"); } string fwNo = ""; if (string.IsNullOrEmpty(objFW.YWNO)) { fwNo = string.Format("﹝ ﹞ 号"); } else { fwNo = string.Format("﹝{0}﹞ 号", objFW.FWNO); } TOaAttVo tOaAttVo = new TOaAttVo(); tOaAttVo.BUSINESS_ID = objFW.ID; tOaAttVo.BUSINESS_TYPE = "FWFile"; tOaAttVo = new TOaAttLogic().Details(tOaAttVo); sheet.GetRow(3).GetCell(2).SetCellValue(objFW.ISSUE_INFO); //签发 sheet.GetRow(3).GetCell(4).SetCellValue(objFW.CTS_INFO); //会签 sheet.GetRow(5).GetCell(2).SetCellValue(objFW.FW_TITLE); //文件标题 sheet.GetRow(6).GetCell(2).SetCellValue(tOaAttVo.ATTACH_NAME); //附件 sheet.GetRow(7).GetCell(2).SetCellValue(objFW.ZS_DEPT); //主送单位 sheet.GetRow(8).GetCell(2).SetCellValue(objFW.CB_DEPT); //抄报单位 sheet.GetRow(8).GetCell(4).SetCellValue(objFW.CS_DEPT); //抄送单位 sheet.GetRow(11).GetCell(1).SetCellValue(objFW.APP_INFO); //科室审核 sheet.GetRow(11).GetCell(3).SetCellValue(!string.IsNullOrEmpty(objFW.DRAFT_ID) ? new TSysUserLogic().Details(objFW.APP_ID).REAL_NAME : ""); //拟稿人 sheet.GetRow(12).GetCell(2).SetCellValue(fwNo); //编号 sheet.GetRow(12).GetCell(3).SetCellValue(fwDate); //印发日期 sheet.GetRow(13).GetCell(2).SetCellValue(objFW.REMARK1); //说明 sheet.GetRow(14).GetCell(2).SetCellValue(objFW.SUBJECT_WORD); //主题词 using (MemoryStream stream = new MemoryStream()) { hssfworkbook.Write(stream); HttpContext curContext = HttpContext.Current; // 设置编码和附件格式 curContext.Response.ContentType = "application/vnd.ms-excel"; curContext.Response.ContentEncoding = Encoding.UTF8; curContext.Response.Charset = ""; curContext.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("发文.xls", Encoding.UTF8)); curContext.Response.BinaryWrite(stream.GetBuffer()); curContext.Response.End(); } }
public int uploadResume() { string strImage = @"iVBORw0KGgoAAAANSUhEUgAAACkAAAAnCAMAAACltJG0AAAAD1BMVEX/////AAD0mAAAoekAxCAi laxRAAAABXRSTlMA/////xzQJlIAAAAnSURBVDjLY2AYpoARGQD5TMhgVOWoygEGzMgAyGdBBqMq R1UOJwAApEMGm6Q1FpkAAAAASUVORK5CYIIA "; int tag = 0; FileStream out1 = null; byte[] bs = Convert.FromBase64String(strImage); //获取主文件路径 string mastPath = System.Configuration.ConfigurationManager.AppSettings["AttPath"].ToString(); //获取业务Id string strBusinessId = "9999"; //获取业务类型 string strBusinessType = "PointPoto"; //获取完整文件名称 string strFullName = strBusinessId + ".png"; //获取文件扩展名称 string strExtendName = strFullName.Substring(strFullName.LastIndexOf(".")); string strSerialNumber = GetSerialNumber("attFileId"); //文件夹路径 string strfolderPath = strBusinessType + "\\" + DateTime.Now.ToString("yyyyMMdd"); //新命名的文件名称 string strNewFileName = DateTime.Now.ToString("yyyyMMddHHmm") + "-" + strSerialNumber + strExtendName; //上传的完整路径 string strResultPath = mastPath + "\\" + strfolderPath + "\\" + strNewFileName; //开始上传附件 try { //判断文件夹是否存在,如果不存在则创建 if (Directory.Exists(mastPath + "\\" + strfolderPath) == false) { Directory.CreateDirectory(mastPath + "\\" + strfolderPath); } //判断原来是否已经上传过文件,如果有的话则获取原来已经上传的文件路径 TOaAttVo TOaAttVo = new TOaAttVo(); TOaAttVo.BUSINESS_TYPE = strBusinessType; TOaAttVo.BUSINESS_ID = strBusinessId; //TOaAttVo.ATTACH_NAME = this.ATTACH_NAME.Text.Trim(); DataTable objTable = new TOaAttLogic().SelectByTable(TOaAttVo); if (objTable.Rows.Count > 0) { //如果存在记录 //获取该记录的ID string strId = objTable.Rows[0]["ID"].ToString(); //获取原来文件的路径 string strOldFilePath = objTable.Rows[0]["UPLOAD_PATH"].ToString(); //如果存在的话,删除原来的文件 if (File.Exists(mastPath + "\\" + strOldFilePath)) { File.Delete(mastPath + "\\" + strOldFilePath); } //将新的信息写入数据库 TOaAttVo TOaAttVoTemp = new TOaAttVo(); TOaAttVoTemp.ID = strId; TOaAttVoTemp.ATTACH_NAME = "点位图"; TOaAttVoTemp.ATTACH_TYPE = strExtendName; TOaAttVoTemp.UPLOAD_PATH = strfolderPath + "\\" + strNewFileName; TOaAttVoTemp.UPLOAD_DATE = DateTime.Now.ToString("yyyy-MM-dd"); TOaAttVoTemp.UPLOAD_PERSON = ""; TOaAttVoTemp.DESCRIPTION = "点位图"; TOaAttVoTemp.REMARKS = bs.Length + "KB";//文件的大小 new TOaAttLogic().Edit(TOaAttVoTemp); } else { //如果不存在记录 TOaAttVo TOaAttVoTemp = new TOaAttVo(); TOaAttVoTemp.ID = strSerialNumber; TOaAttVoTemp.BUSINESS_ID = strBusinessId; TOaAttVoTemp.BUSINESS_TYPE = strBusinessType; TOaAttVoTemp.ATTACH_NAME = "点位图"; TOaAttVoTemp.ATTACH_TYPE = strExtendName; TOaAttVoTemp.UPLOAD_PATH = strfolderPath + "\\" + strNewFileName; TOaAttVoTemp.UPLOAD_DATE = DateTime.Now.ToString("yyyy-MM-dd"); TOaAttVoTemp.UPLOAD_PERSON = ""; TOaAttVoTemp.DESCRIPTION = "点位图"; TOaAttVoTemp.REMARKS = bs.Length + "KB";//文件的大小 new TOaAttLogic().Create(TOaAttVoTemp); } if (tag == 0) { out1 = new FileStream(strResultPath, FileMode.CreateNew, FileAccess.Write); } else { out1 = new FileStream(strResultPath, FileMode.Append, FileAccess.Write); } out1.Write(bs, 0, bs.Length); if (out1 != null) { try { out1.Close(); } catch (IOException e) { // TODO Auto-generated catch block } } } catch (Exception ex) { } return(1); }
public string UpdateSubTaskInfo(string workID, string strUser, string JsonSubTask, string JsonPoint, string JsonItem) { string strResult = "false"; var identification = CCFlowFacade.GetFlowIdentification(strUser, long.Parse(workID)); TMisMonitorSubtaskVo objSubtaskVo = new TMisMonitorSubtaskLogic().Details(identification); TMisMonitorTaskVo objTaskVo = new TMisMonitorTaskLogic().Details(objSubtaskVo.TASK_ID); DataTable dtSubTask = JSONToDataTable2(JsonSubTask); DataTable dtPoint = JSONToDataTable2(JsonPoint); DataTable dtItem = JSONToDataTable2(JsonItem); //更新任务的现状信息 if (dtSubTask.Rows.Count > 0) { objSubtaskVo.SAMPLE_ASK_DATE = dtSubTask.Rows[0]["SAMPLE_ASK_DATE"].ToString(); new TMisMonitorSubtaskLogic().Edit(objSubtaskVo); for (int i = 0; i < dtSubTask.Columns.Count; i++) { if (dtSubTask.Columns[i].ColumnName != "TICKET_NUM" && dtSubTask.Columns[i].ColumnName != "SAMPLE_ASK_DATE") { TMisMonitorSampleSkyVo objSampleSky = new TMisMonitorSampleSkyVo(); objSampleSky.SUBTASK_ID = objSubtaskVo.ID; objSampleSky.WEATHER_ITEM = dtSubTask.Columns[i].ColumnName; objSampleSky = new TMisMonitorSampleSkyLogic().Details(objSampleSky); if (objSampleSky.ID.Length > 0) { objSampleSky.WEATHER_INFO = dtSubTask.Rows[0][i].ToString(); new TMisMonitorSampleSkyLogic().Edit(objSampleSky); } else { objSampleSky.ID = GetSerialNumber("TMisMonitorSampleSky"); objSampleSky.SUBTASK_ID = objSubtaskVo.ID; objSampleSky.WEATHER_ITEM = dtSubTask.Columns[i].ColumnName; objSampleSky.WEATHER_INFO = dtSubTask.Rows[0][i].ToString(); new TMisMonitorSampleSkyLogic().Create(objSampleSky); } } } strResult = "true"; } //更新监测点位信息 if (dtPoint.Rows.Count > 0) { for (int i = 0; i < dtPoint.Rows.Count; i++) { TMisMonitorSampleInfoVo objSampleInfoVo = new TMisMonitorSampleInfoVo(); objSampleInfoVo.SUBTASK_ID = objSubtaskVo.ID; objSampleInfoVo.SAMPLE_NAME = dtPoint.Rows[i]["SAMPLE_NAME"].ToString(); objSampleInfoVo = new TMisMonitorSampleInfoLogic().Details(objSampleInfoVo); if (objSampleInfoVo.ID.Length > 0) { objSampleInfoVo.SAMPLE_COUNT = dtPoint.Rows[i]["SAMPLE_COUNT"].ToString(); new TMisMonitorSampleInfoLogic().Edit(objSampleInfoVo); #region 更新点位图 if (dtPoint.Rows[i]["photo"].ToString().Length > 0) { string strImage = dtPoint.Rows[i]["photo"].ToString(); int tag = 0; FileStream out1 = null; byte[] bs = Convert.FromBase64String(strImage); //获取主文件路径 string mastPath = System.Configuration.ConfigurationManager.AppSettings["AttPath"].ToString(); //获取业务Id string strBusinessId = objSampleInfoVo.ID; //获取业务类型 string strBusinessType = "PointPoto"; //获取完整文件名称 string strFullName = strBusinessId + ".png"; //获取文件扩展名称 string strExtendName = strFullName.Substring(strFullName.LastIndexOf(".")); string strSerialNumber = GetSerialNumber("attFileId"); //文件夹路径 string strfolderPath = strBusinessType + "\\" + DateTime.Now.ToString("yyyyMMdd"); //新命名的文件名称 string strNewFileName = DateTime.Now.ToString("yyyyMMddHHmm") + "-" + strSerialNumber + strExtendName; //上传的完整路径 string strResultPath = mastPath + "\\" + strfolderPath + "\\" + strNewFileName; //开始上传附件 try { //判断文件夹是否存在,如果不存在则创建 if (Directory.Exists(mastPath + "\\" + strfolderPath) == false) { Directory.CreateDirectory(mastPath + "\\" + strfolderPath); } //判断原来是否已经上传过文件,如果有的话则获取原来已经上传的文件路径 TOaAttVo TOaAttVo = new TOaAttVo(); TOaAttVo.BUSINESS_TYPE = strBusinessType; TOaAttVo.BUSINESS_ID = strBusinessId; //TOaAttVo.ATTACH_NAME = this.ATTACH_NAME.Text.Trim(); DataTable objTable = new TOaAttLogic().SelectByTable(TOaAttVo); if (objTable.Rows.Count > 0) { //如果存在记录 //获取该记录的ID string strId = objTable.Rows[0]["ID"].ToString(); //获取原来文件的路径 string strOldFilePath = objTable.Rows[0]["UPLOAD_PATH"].ToString(); //如果存在的话,删除原来的文件 if (File.Exists(mastPath + "\\" + strOldFilePath)) { File.Delete(mastPath + "\\" + strOldFilePath); } //将新的信息写入数据库 TOaAttVo TOaAttVoTemp = new TOaAttVo(); TOaAttVoTemp.ID = strId; TOaAttVoTemp.ATTACH_NAME = "点位图"; TOaAttVoTemp.ATTACH_TYPE = strExtendName; TOaAttVoTemp.UPLOAD_PATH = strfolderPath + "\\" + strNewFileName; TOaAttVoTemp.UPLOAD_DATE = DateTime.Now.ToString("yyyy-MM-dd"); TOaAttVoTemp.UPLOAD_PERSON = strUser; TOaAttVoTemp.DESCRIPTION = "点位图"; TOaAttVoTemp.REMARKS = bs.Length + "KB";//文件的大小 new TOaAttLogic().Edit(TOaAttVoTemp); } else { //如果不存在记录 TOaAttVo TOaAttVoTemp = new TOaAttVo(); TOaAttVoTemp.ID = strSerialNumber; TOaAttVoTemp.BUSINESS_ID = strBusinessId; TOaAttVoTemp.BUSINESS_TYPE = strBusinessType; TOaAttVoTemp.ATTACH_NAME = "点位图"; TOaAttVoTemp.ATTACH_TYPE = strExtendName; TOaAttVoTemp.UPLOAD_PATH = strfolderPath + "\\" + strNewFileName; TOaAttVoTemp.UPLOAD_DATE = DateTime.Now.ToString("yyyy-MM-dd"); TOaAttVoTemp.UPLOAD_PERSON = strUser; TOaAttVoTemp.DESCRIPTION = "点位图"; TOaAttVoTemp.REMARKS = bs.Length + "KB";//文件的大小 new TOaAttLogic().Create(TOaAttVoTemp); } if (tag == 0) { out1 = new FileStream(strResultPath, FileMode.CreateNew, FileAccess.Write); } else { out1 = new FileStream(strResultPath, FileMode.Append, FileAccess.Write); } out1.Write(bs, 0, bs.Length); if (out1 != null) { try { out1.Close(); } catch (IOException e) { // TODO Auto-generated catch block } } } catch (Exception ex) { } } #endregion for (int j = 0; j < dtPoint.Columns.Count; j++) { if (dtPoint.Columns[j].ColumnName != "SAMPLE_NAME" && dtPoint.Columns[j].ColumnName != "SAMPLE_COUNT" && dtPoint.Columns[j].ColumnName != "photo") { TBaseAttributeInfoVo objAttributeInfoVo = new TBaseAttributeInfoVo(); objAttributeInfoVo.IS_DEL = "0"; objAttributeInfoVo.ATTRIBUTE_NAME = dtPoint.Columns[j].ColumnName; objAttributeInfoVo = new TBaseAttributeInfoLogic().Details(objAttributeInfoVo); if (objAttributeInfoVo.ID.Length > 0) { string Attribute_Code = objAttributeInfoVo.ID; TBaseAttrbuteValue3Vo objAttValue = new TBaseAttrbuteValue3Vo(); objAttValue.OBJECT_ID = objSampleInfoVo.POINT_ID; objAttValue.ATTRBUTE_CODE = Attribute_Code; objAttValue.IS_DEL = "0"; objAttValue = new TBaseAttrbuteValue3Logic().Details(objAttValue); if (objAttValue.ID == "") { objAttValue.ID = GetSerialNumber("t_base_attribute_value3_id"); objAttValue.IS_DEL = "0"; objAttValue.OBJECT_ID = objSampleInfoVo.POINT_ID; objAttValue.OBJECT_TYPE = objAttributeInfoVo.CONTROL_NAME; objAttValue.ATTRBUTE_CODE = Attribute_Code; objAttValue.ATTRBUTE_VALUE = dtPoint.Rows[i][dtPoint.Columns[j].ColumnName.ToString()].ToString(); new TBaseAttrbuteValue3Logic().Create(objAttValue); } else { objAttValue.ATTRBUTE_VALUE = dtPoint.Rows[i][dtPoint.Columns[j].ColumnName.ToString()].ToString(); new TBaseAttrbuteValue3Logic().Edit(objAttValue); } } } } } } strResult = "true"; } //更新监测项目的信息 if (dtItem.Rows.Count > 0) { for (int i = 0; i < dtItem.Rows.Count; i++) { TMisMonitorSampleInfoVo objSampleInfoVo = new TMisMonitorSampleInfoVo(); objSampleInfoVo.SUBTASK_ID = objSubtaskVo.ID; objSampleInfoVo.SAMPLE_NAME = dtItem.Rows[i]["SAMPLE_NAME"].ToString(); objSampleInfoVo = new TMisMonitorSampleInfoLogic().Details(objSampleInfoVo); if (objSampleInfoVo.ID.Length > 0) { TBaseItemInfoVo objItemInfoVo = new TBaseItemInfoVo(); objItemInfoVo.ITEM_NAME = dtItem.Rows[i]["ITEM_NAME"].ToString(); objItemInfoVo.IS_DEL = "0"; objItemInfoVo = new TBaseItemInfoLogic().Details(objItemInfoVo); TMisMonitorResultVo objResultVo = new TMisMonitorResultVo(); objResultVo.SAMPLE_ID = objSampleInfoVo.ID; objResultVo.ITEM_ID = objItemInfoVo.ID; TMisMonitorResultVo objResultSetVo = new TMisMonitorResultVo(); objResultSetVo.ITEM_RESULT = dtItem.Rows[i]["ITEM_RESULT"].ToString(); new TMisMonitorResultLogic().Edit(objResultSetVo, objResultVo); } } strResult = "true"; } return(strResult); }
protected void btnUpload_Click(object sender, EventArgs e) { string fill_Row_ID = string.Empty; if (this.ATTACH_NAME.Text.Trim() == "") { LigerDialogAlert("请输入文件名称", "error"); return; } if (this.fileUpload.PostedFile.ContentLength >= 20971520) { LigerDialogAlert("上传的文件不能大于20M", "error"); return; } if (this.fileUpload.PostedFile.ContentLength <= 0) { LigerDialogAlert("请选择文件", "error"); return; } //获取主文件路径 string mastPath = System.Configuration.ConfigurationManager.AppSettings["AttPath"].ToString(); //获取业务Id string strBusinessId = this.Request["id"].ToString(); //获取业务类型 string strBusinessType = this.Request["filetype"].ToString(); //获取完整文件名称 string strFullName = this.fileUpload.PostedFile.FileName; //获取填报行ID if (strBusinessType.Equals("SeaFill") || strBusinessType.Equals("DrinkSource") || strBusinessType.Equals("Payfor")) { fill_Row_ID = this.Request["ROW_ID"].ToString(); } //获取文件扩展名称 string strExtendName = strFullName.Substring(strFullName.LastIndexOf(".")); string strSerialNumber = GetSerialNumber("attFileId"); //文件夹路径 string strfolderPath = strBusinessType + "\\" + DateTime.Now.ToString("yyyyMMdd"); //新命名的文件名称 string strNewFileName = DateTime.Now.ToString("yyyyMMddHHmm") + "-" + strSerialNumber + strExtendName; //上传的完整路径 string strResultPath = mastPath + "\\" + strfolderPath + "\\" + strNewFileName; //开始上传附件 try { //判断文件夹是否存在,如果不存在则创建 if (Directory.Exists(mastPath + "\\" + strfolderPath) == false) { Directory.CreateDirectory(mastPath + "\\" + strfolderPath); } this.fileUpload.SaveAs(strResultPath); //判断原来是否已经上传过文件,如果有的话则获取原来已经上传的文件路径 TOaAttVo TOaAttVo = new TOaAttVo(); TOaAttVo.BUSINESS_TYPE = strBusinessType; TOaAttVo.BUSINESS_ID = strBusinessId; //TOaAttVo.ATTACH_NAME = this.ATTACH_NAME.Text.Trim(); DataTable objTable = new TOaAttLogic().SelectByTable(TOaAttVo); if (objTable.Rows.Count > 0) { //如果存在记录 //获取该记录的ID string strId = objTable.Rows[0]["ID"].ToString(); //获取原来文件的路径 string strOldFilePath = objTable.Rows[0]["UPLOAD_PATH"].ToString(); //如果存在的话,删除原来的文件 if (File.Exists(mastPath + "\\" + strOldFilePath)) { File.Delete(mastPath + "\\" + strOldFilePath); } //将新的信息写入数据库 TOaAttVo TOaAttVoTemp = new TOaAttVo(); TOaAttVoTemp.ID = strId; TOaAttVoTemp.ATTACH_NAME = this.ATTACH_NAME.Text.Trim(); TOaAttVoTemp.ATTACH_TYPE = strExtendName; TOaAttVoTemp.UPLOAD_PATH = strfolderPath + "\\" + strNewFileName; TOaAttVoTemp.UPLOAD_DATE = DateTime.Now.ToString("yyyy-MM-dd"); TOaAttVoTemp.UPLOAD_PERSON = LogInfo.UserInfo.REAL_NAME; TOaAttVoTemp.DESCRIPTION = this.DESCRIPTION.Text.Trim(); TOaAttVoTemp.REMARKS = this.fileUpload.PostedFile.ContentLength.ToString() + "KB"; //文件的大小 TOaAttVoTemp.FILL_ID = fill_Row_ID; //行ID if (new TOaAttLogic().Edit(TOaAttVoTemp)) { this.status.Value = "1"; LigerDialogAlert("文件上传成功", "success"); } else { this.status.Value = "0"; LigerDialogAlert("文件上传失败", "error"); } } else { //如果不存在记录 TOaAttVo TOaAttVoTemp = new TOaAttVo(); TOaAttVoTemp.ID = strSerialNumber; TOaAttVoTemp.BUSINESS_ID = strBusinessId; TOaAttVoTemp.BUSINESS_TYPE = strBusinessType; TOaAttVoTemp.ATTACH_NAME = this.ATTACH_NAME.Text.Trim(); TOaAttVoTemp.ATTACH_TYPE = strExtendName; TOaAttVoTemp.UPLOAD_PATH = strfolderPath + "\\" + strNewFileName; TOaAttVoTemp.UPLOAD_DATE = DateTime.Now.ToString("yyyy-MM-dd"); TOaAttVoTemp.UPLOAD_PERSON = LogInfo.UserInfo.REAL_NAME; TOaAttVoTemp.DESCRIPTION = this.DESCRIPTION.Text.Trim(); TOaAttVoTemp.REMARKS = this.fileUpload.PostedFile.ContentLength.ToString() + "KB";//文件的大小 TOaAttVoTemp.FILL_ID = fill_Row_ID; if (new TOaAttLogic().Create(TOaAttVoTemp)) { this.status.Value = "1"; LigerDialogAlert("文件上传成功", "success"); } else { this.status.Value = "0"; LigerDialogAlert("文件上传失败", "error"); } } } catch (Exception ex) { LigerDialogAlert(ex.Message, "error"); } }