protected void Page_Load(object sender, EventArgs e) { if (Request.Params["filePath"] != null) { DocUploader du = new DocUploader(); du.GetFullXML(Request.Params["filePath"].ToString()); Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "CloseWindow", "<script>self.close();</script>"); } else if (Request.Params["redline"] != null) { filePath = Request.Params["redline"].ToString().Replace("@@@", "\\").Replace("/", "\\") + ".dwf"; fileSubpath = Request.Params["relFileName"].ToString().ToLower().Replace(".dwf", "_Redline.dwf").Replace("@@@", "\\"); docSharePath = ConfigurationManager.AppSettings["docSharedPath"]; CheckIfRedLineFileSaved(); } else if (Request.Params["downloadDocPath"] != null) { filePath = Request.Params["downloadDocPath"].ToString(); fileSubpath = Request.Params["relFileName"].ToString(); filePath = Microsoft.JScript.GlobalObject.unescape(filePath); fileSubpath = Microsoft.JScript.GlobalObject.unescape(fileSubpath); string docBasePath = ConfigurationManager.AppSettings["docBasePath"]; DownloadTheNewlyUploadedDocument(filePath, fileSubpath, docBasePath); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "CloseWindow", "<script>self.close();</script>"); } }
void fileUploadTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { try { fileTransferInitiatorTimer.Enabled = false; DocUploader uploaderService = new DocUploader(); if (uploaderService.CheckFileExist(filePath)) { CleanShareDirectory(); //*** Save in local connection kit repository for local users string docBasePath = ConfigurationManager.AppSettings["docBasePath"]; string targetPath = Path.Combine(docBasePath, fileSubpath); string subdirectoryPath = targetPath.Substring(0, targetPath.LastIndexOf("\\")); if (!Directory.Exists(subdirectoryPath)) { Directory.CreateDirectory(subdirectoryPath); } FileInfo fi = new FileInfo(targetPath); if (fi.Exists) { fi.Delete(); } new FileInfo(filePath).CopyTo(targetPath); //*** Upload to remote server string msg = uploaderService.UploadDocument(filePath, fileSubpath); if (msg.Equals(string.Empty)) { Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Success", "<script>alert('Redline Success Uploaded');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Error", "<script>alert('Fail to upload redline');</script>"); } StopTimer(); } else { if (currentLoopCounter >= TimerLoop) { StopTimer(); Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Error", "<script>alert('Fail to upload redline after trying sevaral times.');</script>"); } else { fileTransferInitiatorTimer.Enabled = true; } } currentLoopCounter++; } catch (Exception ex) { LogWriter.WriteLog("Redline upload and local save error: " + ex.Message); } }
void DownloadTheNewlyUploadedDocument(string srcPath, string fileSubpath, string docBasePath) { try { DocUploader uploaderService = new DocUploader(); string tgtPath = Path.Combine(docBasePath, fileSubpath); uploaderService.DownloadTheNewlyUploadedDocument(srcPath, tgtPath); } catch (Exception exp) { LogWriter.WriteLog(exp.Message); } }