protected string GetdataList() { REQUESTCODE uResponse = REQUESTCODE.EXECUTE_FAIL; TESTDATAREQ vrReq = new TESTDATAREQ(); vrReq.dwStartDate = (uint)int.Parse(DateTime.Now.AddMonths(-6).ToString("yyyyMMdd")); vrReq.dwEndDate = (uint)int.Parse(DateTime.Now.AddMonths(1).ToString("yyyyMMdd")); UNIACCOUNT AccInfo = (UNIACCOUNT)Session["LOGIN_ACCINFO"]; //vrReq.dwAccNo = 256491; vrReq.dwStatus = (uint)UNITESTDATA.DWSTATUS.TDSTAT_UPLOADED | (uint)UNITESTDATA.DWSTATUS.TDSTAT_DOWNLOADED; vrReq.szReqExtInfo.szOrderKey = "dwSubmitDate"; vrReq.szReqExtInfo.szOrderMode = "DESC"; UNITESTDATA[] vtResult; uResponse = m_Request.Account.TestDataGet(vrReq, out vtResult); if (uResponse != REQUESTCODE.EXECUTE_SUCCESS) { string szErrMsg = "获取失败:" + m_Request.szErrMessage; return(szErrMsg); } else { string szHtml = ""; if (vtResult.Length == 0) { szHtml = "<tr><td colspan='10' style='padding:10px;width:100%;text-align:center;'>无上传记录,列表为空</td></tr>"; } else { szHtml = ""; for (int i = 0; i < vtResult.Length; i++) { uint dwSubmitDate = (uint)vtResult[i].dwSubmitDate; string szDate = (dwSubmitDate / 10000) + "-" + ((dwSubmitDate / 100) % 100) + "-" + (dwSubmitDate % 100) + " " + Get1970Time((uint)vtResult[i].dwSubmitTime); if (i % 2 == 0) { szHtml += "<tr class='odd'>"; } else { szHtml += "<tr>"; } szHtml += "<td class='tbltd'>" + vtResult[i].szDisplayName.ToString() + "</td>"; szHtml += "<td class='tbltd'>" + vtResult[i].szTrueName + "</td>"; szHtml += "<td class='tbltd'>" + szDate + "</td>"; szHtml += "<td class='tbltd'>" + vtResult[i].szDevName.ToString() + "</td>"; szHtml += "<td class='tbltd'>" + ConvertSize(vtResult[i].dwFileSize) + "</td>"; szHtml += "<td class='tbltd status' stat='" + vtResult[i].dwStatus + "'>" + ConvertSta(vtResult[i].dwStatus) + "</td>"; szHtml += "<td class='tbltd'><a class='click' onclick='window.open(\"dlData.aspx?id=" + vtResult[i].dwSID.ToString() + "\");setTimeout(\"location.href=location.href;\",500);'>下载</a> | " + "<a class='click' onclick='delAct(\"del_data\",\"" + vtResult[i].dwSID.ToString() + "\")'>删除</a></td>"; szHtml += "</tr>"; } } return(szHtml); } }
protected void Page_Load(object sender, EventArgs e) { TESTDATAREQ vrParameter = new TESTDATAREQ(); UNITESTDATA[] vrResult; string szPID = Request["dwPID"]; GetPageCtrlValue(out vrParameter.szReqExtInfo); if (!IsPostBack) { dwStartDate.Value = DateTime.Now.AddMonths(-2).ToString("yyyy-MM-dd"); dwEndDate.Value = DateTime.Now.ToString("yyyy-MM-dd"); } string szKey = Request["szGetKey"]; if (szKey != null && szKey != "") { vrParameter.dwDevID = Parse(szKey); } UNIACCOUNT account = new UNIACCOUNT(); if (szPID != null && GetAccByLogonName(szPID, out account)) { vrParameter.dwAccNo = account.dwAccNo; } if (vrParameter.szReqExtInfo.szOrderKey == null || vrParameter.szReqExtInfo.szOrderKey == "") { vrParameter.szReqExtInfo.szOrderKey = "dwSubmitTime"; vrParameter.szReqExtInfo.szOrderMode = "desc"; } vrParameter.dwStartDate = DateToUint(dwStartDate.Value); vrParameter.dwEndDate = DateToUint(dwEndDate.Value); if (m_Request.Account.TestDataGet(vrParameter, out vrResult) == REQUESTCODE.EXECUTE_SUCCESS) { for (int i = 0; i < vrResult.Length; i++) { m_szOut += "<tr>"; m_szOut += "<td data-displayname=" + vrResult[i].szDisplayName.ToString() + " data-id=" + vrResult[i].dwSID.ToString() + ">" + vrResult[i].szTrueName + "(" + vrResult[i].szPID + ")" + "</td>"; m_szOut += "<td>" + vrResult[i].szDevName.ToString() + "</td>"; m_szOut += "<td>" + vrResult[i].szLabName + "</td>"; m_szOut += "<td>" + Get1970Date(vrResult[i].dwSubmitTime, "MM-dd HH:mm") + "</td>"; m_szOut += "<td>" + vrResult[i].szDisplayName.ToString() + "</td>"; m_szOut += "<td>" + GetFileSizeString((double)vrResult[i].dwFileSize) + "</td>"; m_szOut += "<td><div class='OPTD'></div></td>"; m_szOut += "</tr>"; } UpdatePageCtrl(m_Request.Account); } PutBackValue(); }
protected void Page_Load(object sender, EventArgs e) { base.LoadPage(); string path = ConfigurationManager.AppSettings["dataFilePath"]; if (!string.IsNullOrEmpty(path)) { m_szFilePath = @path; } if (Session["LOGIN_ACCINFO"] == null) { Response.Redirect("Default.aspx"); } if (!Directory.Exists(m_szFilePath)) { Response.Write("文件路径错误!"); return; } REQUESTCODE uResponse = REQUESTCODE.EXECUTE_FAIL; TESTDATAREQ vrReq = new TESTDATAREQ(); vrReq.dwSID = Convert.ToUInt32(Request["ID"]); UNITESTDATA[] vtResult; uResponse = m_Request.Account.TestDataGet(vrReq, out vtResult); if (uResponse != REQUESTCODE.EXECUTE_SUCCESS) { m_szErrMsg = "下载失败:" + m_Request.szErrMessage; } else if (vtResult.Length == 0) { m_szErrMsg = "找不到文件"; } else { vtResult[0].dwStatus = new UniDW((uint)UNITESTDATA.DWSTATUS.TDSTAT_DOWNLOADED); uResponse = m_Request.Account.TestDataChgStat(vtResult[0]); string szUniFSPath = vtResult[0].szLocation.ToString(); string szUserFileName = vtResult[0].szDisplayName.ToString(); string szsubDate = vtResult[0].dwSubmitDate.ToString(); int nLast = szUniFSPath.LastIndexOf("\\"); if (szUserFileName.LastIndexOf(".") <= 0) { string szUniFSPath2; if (szUniFSPath.EndsWith(".uni")) { szUniFSPath2 = szUniFSPath.Substring(0, szUniFSPath.Length - 4); } else { szUniFSPath2 = szUniFSPath; } int nLast2 = szUniFSPath2.LastIndexOf("."); if (nLast2 > nLast) { szUserFileName += szUniFSPath2.Substring(nLast2); } } //string szWebPath = "temp\\"; //if (szUniFSPath[nLast] == '\\') //{ // nLast++; //} //szWebPath += szsubDate + "\\" + szUniFSPath.Substring(nLast);//szsubDate+"\\"+GetFileCount() + szUniFSPath.Substring(nLast); string szWebPath = "temp\\"; if (szUniFSPath[nLast] == '\\') { nLast++; } szWebPath += szsubDate; string szResult = ""; string szCmd; string szFilePath = Server.MapPath(szWebPath); if (!Directory.Exists(szFilePath)) { Directory.CreateDirectory(szFilePath); } szFilePath += "\\" + szUniFSPath.Substring(nLast); string szEncodeFilepath = ""; if (m_bEncode) { szEncodeFilepath = szFilePath;//+ ".uni"; } else { szEncodeFilepath = szFilePath;//+ ".unf"; } if (string.IsNullOrEmpty(m_szFilePath)) { szCmd = Server.MapPath(".") + "\\UniFTPClient.exe GET \"" + szEncodeFilepath + "\" \"" + szUniFSPath + "\""; szResult = WinExec(szCmd); } else { int nIndex = szUniFSPath.IndexOf('\\'); string szFileServerFILES = m_szFilePath + szUniFSPath.Substring(nIndex); //Response.Write(szFileServerFILES + "," + szEncodeFilepath); //return; if (!File.Exists(szFileServerFILES)) { Response.Write("文件不存在!"); return; } if (!File.Exists(szEncodeFilepath)) { File.Copy(szFileServerFILES, szEncodeFilepath); } szResult = "OK"; } if (szResult.IndexOf("ERROR") >= 0) { m_szErrMsg = "下载文件失败"; } else { if (m_bEncode) { szCmd = Server.MapPath(".") + "\\EncodeFile.exe Decode #password# \"" + szEncodeFilepath + "\" \"" + szFilePath + "\""; szResult = WinExec(szCmd); File.Delete(szEncodeFilepath); } else { this.Response.Write("szEncodeFilepath=" + szEncodeFilepath + "<br />" + szFilePath); // File.Move(szEncodeFilepath, szFilePath); szResult = "OK"; } if (szResult.IndexOf("ERROR") >= 0) { m_szErrMsg = "下载文件失败"; } else { FileInfo fi = new FileInfo(szFilePath); if (fi.Length > 1024 * 1024) { //Response.Redirect(szWebPath); System.IO.Stream iStream = null; byte[] buffer = new Byte[10000]; int length; long dataToRead; try { iStream = new System.IO.FileStream(szFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read); dataToRead = iStream.Length; Response.Clear(); Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(szUserFileName, System.Text.Encoding.UTF8)); Response.AppendHeader("Content-Length", dataToRead.ToString()); while (dataToRead > 0) { if (Response.IsClientConnected) { length = iStream.Read(buffer, 0, 10000); Response.OutputStream.Write(buffer, 0, length); Response.Flush(); buffer = new Byte[10000]; dataToRead = dataToRead - length; } else { dataToRead = -1; } } } catch (Exception ex) { Response.Write("Error : " + ex.Message); } if (iStream != null) { iStream.Close(); } File.Delete(szFilePath); } else { Response.Clear(); Response.ContentType = "application/x-download"; //application/octet-stream Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(szUserFileName, System.Text.Encoding.UTF8)); Response.Flush(); Response.WriteFile(szFilePath); Response.Flush(); File.Delete(szFilePath); Response.End(); } } } } }