/// <summary> /// Upload file to the server /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { if (aUploadFile.UploadedFiles.Count > 0) { WizardFile.MoveTo(WizardStep2); FileName = Path.GetFileNameWithoutExtension(aUploadFile.UploadedFiles[0].FileName); ExtensionName = Path.GetExtension(aUploadFile.UploadedFiles[0].FileName); FileSize = Convert.ToInt32(aUploadFile.UploadedFiles[0].ContentLength); Bytes = new byte[aUploadFile.UploadedFiles[0].InputStream.Length]; aUploadFile.UploadedFiles[0].InputStream.Read(Bytes, 0, (int)aUploadFile.UploadedFiles[0].InputStream.Length); String pathServerTemp = Server.MapPath("Portals/0/Images/Temp/"); if (!Directory.Exists(pathServerTemp)) { Directory.CreateDirectory(pathServerTemp); } try { File.WriteAllBytes(pathServerTemp + FileName + ExtensionName, Bytes); } catch (Exception ex) { } WizardFile.ActiveStepIndex = 1; Clear(); CreateFile.Visible = true; UpdateFile.Visible = false; } }
//protected void filecalidad_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) //{ // string pathDirectoryPadre = ""; // string newfilename=""; // int unicode = 65; // bool bit = false; // if( addfoliocalidad02.Text.Length>0 && addfoliocalidad03.Text.Length>0) // bit=true; // if(bit==true) // { // //Verificar la subida de archivos // pathDirectoryPadre = HttpContext.Current.ApplicationInstance.Server.MapPath("~/filecert") + "\\" + Session["getIdCentroUsr"].ToString(); // if (!Directory.Exists(pathDirectoryPadre)) // { // System.IO.Directory.CreateDirectory(pathDirectoryPadre.ToString()); // } // foreach (Telerik.Web.UI.UploadedFile f in filecalidad.UploadedFiles) // { // string caracter = char.ConvertFromUtf32(unicode); // filecalidad.TargetFolder = "~/filecert" + "\\" + Session["getIdCentroUsr"].ToString(); // newfilename = string.Format("{0}{1}_{2}{3}", addfoliocalidad.Text.Trim().ToString(), addfoliocalidad03.Text.Trim().ToString(),caracter.ToString(), e.File.GetExtension()); // Session["getFilePdfCAN"] = newfilename.ToString(); // if(!File.Exists(Path.Combine(Server.MapPath(filecalidad.TargetFolder), newfilename))) // { // f.SaveAs(Path.Combine(Server.MapPath(filecalidad.TargetFolder), newfilename),true); // unicode++; // } // } // //e.File.SaveAs(Path.Combine(Server.MapPath(filecalidad.TargetFolder), newfilename)); // } //} protected void rAsyncPDF_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { bool bit = false; if (addfoliocantidad02.Text.Length > 0 && addfoliocantidad03.Text.Length > 0) { bit = true; } if (bit == true) { //string pathDirectoryPadre = HttpContext.Current.ApplicationInstance.Server.MapPath("~/reportes") + "\\" + Session["getIdAgencia"].ToString(); string pathDirectoryPadre = HttpContext.Current.ApplicationInstance.Server.MapPath("~/filecert") + "\\" + Session["getIdCentroUsr"].ToString(); //rAsyncPDF.TargetFolder = "~/reportes" + "\\" + Session["getIdAgencia"].ToString(); //+"\\" + Session["getIdTramite"] + e.File.GetExtension(); ; rAsyncPDF.TargetFolder = "~/filecert" + "\\" + Session["getIdCentroUsr"].ToString(); //+"\\" + Session["getIdTramite"] + e.File.GetExtension(); if (!Directory.Exists(pathDirectoryPadre)) { System.IO.Directory.CreateDirectory(pathDirectoryPadre.ToString()); //System.IO.Directory.CreateDirectory(pathDirectoryHijo.ToString()); } string newfilename = string.Format("{0}{1}{2}", addfoliocantidad.Text.Trim().ToString(), addfoliocantidad03.Text.Trim().ToString(), e.File.GetExtension()); Session["getFilePdfCAL"] = newfilename.ToString(); if (System.IO.File.Exists(Path.Combine(Server.MapPath(rAsyncPDF.TargetFolder), newfilename))) { System.IO.File.Delete(Path.Combine(Server.MapPath(rAsyncPDF.TargetFolder), newfilename)); } e.File.SaveAs(Path.Combine(Server.MapPath(rAsyncPDF.TargetFolder), newfilename)); } }
protected void RadAsyncUpload3_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { try { string strPath = "ProjectFlagship"; string fileName, strFileName = ""; string ext = ""; strFileName = txtTitle.Text.Trim().Replace(" ", "").ToString(); fileName = e.File.FileName; fileName = fileName.Substring(fileName.LastIndexOf("\\") + 1); string strDate = System.DateTime.Now.ToString(); strDate = strDate.Replace("/", ""); strDate = strDate.Replace("-", ""); strDate = strDate.Replace(":", ""); strDate = strDate.Replace(" ", ""); ext = fileName.Substring(fileName.LastIndexOf(".")); fileName = strFileName + "_" + strDate + ext; string path = Server.MapPath("~/" + strPath + "/" + fileName); Session["FlagshipImg"] = fileName; e.File.SaveAs(path); } catch { } }
protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { try { string strPath = "RIDGImages"; string fileName = ""; string ext = ""; fileName = e.File.FileName; fileName = fileName.Substring(fileName.LastIndexOf("\\") + 1); string strDate = System.DateTime.Now.ToString(); strDate = strDate.Replace("/", ""); strDate = strDate.Replace("-", ""); strDate = strDate.Replace(":", ""); strDate = strDate.Replace(" ", ""); ext = fileName.Substring(fileName.LastIndexOf(".")); fileName = fileName.Substring(0, fileName.LastIndexOf(".")); fileName = fileName + "_" + strDate + ext; string path = Server.MapPath("~/" + strPath + "/" + fileName); Session["RIDGImages"] = fileName; e.File.SaveAs(path); } catch { } }
/// <summary> /// 選擇檔案後觸發的上傳檔案事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void rauXLSXUpload_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { if (rauXLSXUpload.UploadedFiles.Count > 0) // 判斷是否有上傳檔案 { List <string> lsTempPath = new List <string>(); foreach (Telerik.Web.UI.UploadedFile postedFile in rauXLSXUpload.UploadedFiles) // 巡覽上傳的所有檔案 { if (postedFile != null) { string extensionName = System.IO.Path.GetExtension(postedFile.FileName); if (extensionName.Equals(".xls") || extensionName.Equals(".xlsx")) // 沒有 { using (FileStream filestream = postedFile.InputStream as FileStream) using (ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook(filestream)) { lsTempPath.Add(filestream.Name); ClosedXML.Excel.IXLWorksheet sheet = null; try { sheet = wb.Worksheets.Worksheet("Sheet1"); } catch { sheet = wb.Worksheets.Worksheet("工作表1"); } if (sheet == null) // 找不到工作表就離開 { break; } ktxtTABLE_NAME.Text = sheet.Cell(1, 1).GetString(); // 表格名稱 int rowIndex = 3; DataTable dtSource = getDefalutTable(); // 每次都當最新的 while (!sheet.Cell(rowIndex, 2).IsEmpty()) // 欄位名稱是空的 { DataRow ndr = dtSource.NewRow(); ndr["PK"] = sheet.Cell(rowIndex, 1).GetString().ToUpper().Trim(); // 鍵值 ndr["COLUMN_NAME"] = sheet.Cell(rowIndex, 2).GetString().ToUpper().Trim(); // 欄位名稱 ndr["DATA_TYPE"] = sheet.Cell(rowIndex, 3).GetString().ToUpper().Trim(); // 欄位類型 ndr["ALLOW_NULL"] = sheet.Cell(rowIndex, 4).GetString().ToUpper().Trim(); // 允許NULL ndr["DEFAULT_VALUE"] = ""; // 預設值 ndr["COLUMN_DESC"] = sheet.Cell(rowIndex, 5).GetString().ToUpper().Trim(); // 說明 dtSource.Rows.Add(ndr); rowIndex++; } ViewState["gvColumns"] = dtSource; gvColumns.DataSource = ViewState["gvColumns"]; gvColumns.DataBind(); } } } } // 刪除暫存檔 foreach (string _tmpPath in lsTempPath) { File.Delete(_tmpPath); } } }
protected void asyncUpload_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { List <t_LanguageTranslate> list = languageBL.FindAll(x => x.Language == language && x.Noted.Contains("/Supervisor/Device/All.aspx")).ToList(); var up_download_upload_confirm = list.Where(x => x.ControlId.Contains("up_download_upload_confirm")).FirstOrDefault(); lblMessage.Visible = true; if (string.IsNullOrEmpty(txtSerial.Text)) { lblMessage.Text = "Please input seri ."; txtSerial.Focus(); return; } string targetFolder = asyncUpload.TargetFolder; string newName = "_" + txtSerial.Text + "_" + _stringUT.RemoveSign4VietnameseString(e.File.GetName()); e.File.SaveAs(System.IO.Path.Combine(Server.MapPath(targetFolder), newName)); var dbTransmitterFile = _transmitterFileBL.GetTransmitterFile(newName); t_Transmitter_Files transmitterFile = new t_Transmitter_Files(); transmitterFile.FileName = newName; transmitterFile.MIMEType = e.File.ContentType; transmitterFile.Path = System.IO.Path.Combine(Server.MapPath(targetFolder), transmitterFile.FileName); transmitterFile.TransmitterSerial = txtSerial.Text; transmitterFile.Size = (int)e.File.ContentLength; transmitterFile.UploadDate = DateTime.Now; if (dbTransmitterFile != null) { try { _transmitterFileBL.UpdateTransmitterFile(transmitterFile, dbTransmitterFile); //lblMessage.Text = "Đã upload file mới."; lblMessage.Text = up_download_upload_confirm.Contents; } catch (Exception ex) { lblMessage.Text = "Lỗi: " + ex.Message; //throw; } } else { try { _transmitterFileBL.InsertTransmitterFile(transmitterFile); lblMessage.Text = "file uploaded ."; } catch (Exception ex) { lblMessage.Text = ex.Message; //throw; } } BindFile(); }
protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { try { int filesizeInBytes = int.Parse(e.File.ContentLength.ToString()); Session["FileSize"] = filesizeInBytes; string filename = e.File.FileName; Session["FileName"] = filename; } catch { } }
/// <summary> /// Upload files related to the organization /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { count++; if (RadAsyncUpload1.UploadedFiles.Count > 0 && count == 1) { string FileName = Path.GetFileName(RadAsyncUpload1.UploadedFiles[RadAsyncUpload1.UploadedFiles.Count - 1].FileName); string extensionName = Path.GetExtension(RadAsyncUpload1.UploadedFiles[RadAsyncUpload1.UploadedFiles.Count - 1].FileName); FileName = Guid.NewGuid().ToString(); RadAsyncUpload1.UploadedFiles[RadAsyncUpload1.UploadedFiles.Count - 1].SaveAs( Server.MapPath(PortalSettings.HomeDirectory + "ModIma/TempImages/" + FileName + extensionName)); imgInstitution.ImageUrl = PortalSettings.HomeDirectory + "ModIma/TempImages/" + FileName + extensionName; } }
protected void rapSignature_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { var tempFolderpath = Server.MapPath("~/University/CooperationRequest/Signatures/temp/"); var radTempFolderPath = Server.MapPath("~/App_Data/RadUploadTemp/"); var fileName = ((FileStream)e.File.InputStream).Name.Split('\\').Last(); if (File.Exists(tempFolderpath + fileName)) { File.Delete(tempFolderpath + fileName); } File.Copy(radTempFolderPath + fileName, tempFolderpath + fileName); var nc = "?nc=" + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + DateTime.Now.Millisecond; imgSignature.ImageUrl = "~/University/CooperationRequest/Signatures/temp/" + fileName + nc; e.File.InputStream.Close(); }
protected void uplLogoUpload_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { Session["UploadFileName"] = e.File.FileName; //Thumbnail.Width = Unit.Pixel(200); //Thumbnail.Height = Unit.Pixel(150); //if (File.Exists(Server.MapPath(@"/Images/" + e.File.FileName))) //{ // Thumbnail.ImageUrl = Server.MapPath(@"/Images/" + e.File.FileName); //} //using (Stream stream = e.File.InputStream) //{ // byte[] imageData = new byte[stream.Length]; // stream.Read(imageData, 0, (int)stream.Length); // Thumbnail.DataValue = imageData; //} }
protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { //check file size //if (e.File.ContentLength < 5000) //{ //} string filename = DateTime.Now.ToString("yyyyMMdd") + "_" + Guid.NewGuid().ToString() + e.File.GetExtension(); Session.Add("filename", filename); var physicalSavePath = MapPath(Config.UploadInvoiceVirtualPath) + filename; //Save physical file on disk e.File.SaveAs(physicalSavePath, true); //Add receipt to uploaded iamge //create upload receipt record }
/// <summary> /// 上傳檔案後觸發事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void rauVersionListUpload_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { if (rauVersionListUpload.UploadedFiles.Count > 0) // 判斷是否有上傳檔案 { DataTable dtSource = gvFILE_VERSION.DataTable; //List<string> lsTempPath = new List<string>(); foreach (Telerik.Web.UI.UploadedFile postedFile in rauVersionListUpload.UploadedFiles) // 巡覽上傳的所有檔案 { if (postedFile != null) { string extensionName = System.IO.Path.GetExtension(postedFile.FileName); if (extensionName.Equals(".kytlist")) { using (FileStream filestream = postedFile.InputStream as FileStream) using (StreamReader sReader = new StreamReader(filestream, Encoding.UTF8)) { /*** * FileVersionList.kytlist * [ * { * "FILE_ID": "CDS_TAIFLEX_WKFFIELDS_UC_TAIFLEX_PRK_ASCX", * "FILE_NAME": "UC_TAIFLEX_PRK.ascx", * "FILE_PATH": "CDS\TAIFLEX\WKFFIELDS\UC_TAIFLEX_PRK.ascx", * "FILE_VERSION": "1.0.0.0", * "FILE_SHA": "SHA-2", * "MODIFY_TIME": "2020/06/18 16:59", * "PROCESSOR_KEY": "" * }, * { * "FILE_ID": "CDS_TAIFLEX_WKFFIELDS_UC_TAIFLEX_PRK_ASCX_CS", * "FILE_NAME": "UC_TAIFLEX_PRK.ascx.cs", * "FILE_PATH": "CDS\TAIFLEX\WKFFIELDS\UC_TAIFLEX_PRK.ascx.cs", * "FILE_VERSION": "1.0.0.0", * "FILE_SHA": "SHA-2", * "MODIFY_TIME": "2020/06/18 16:59", * "PROCESSOR_KEY": "" * } * ] * * ***/ /*** * FileVersionList.kytlist * [ * { * "FILE_ID": "CDS_TAIFLEX_WKFFIELDS_UC_TAIFLEX_PRK_ASCX", * "FILE_NAME": "UC_TAIFLEX_PRK.ascx", * "FILE_PATH": "CDS\TAIFLEX\WKFFIELDS\UC_TAIFLEX_PRK.ascx" * }, * { * "FILE_ID": "CDS_TAIFLEX_WKFFIELDS_UC_TAIFLEX_PRK_ASCX_CS", * "FILE_NAME": "UC_TAIFLEX_PRK.ascx.cs", * "FILE_PATH": "CDS\TAIFLEX\WKFFIELDS\UC_TAIFLEX_PRK.ascx.cs" * } * ] * ***/ JArray jaKYTList = null; try { jaKYTList = JArray.Parse(sReader.ReadToEnd()); foreach (JObject _joKYTFile in jaKYTList.Children <JObject>()) { if (_joKYTFile.Property("FILE_ID") != null) // 這一組裡面有FILE_ID才做 { DataRow[] _drs = dtSource.Select(string.Format("FILE_ID = '{0}'", _joKYTFile["FILE_ID"])); // FILE_ID是PK,有找到就是已經存在 if (_drs.Length == 0) // 不存在於現在的清單中 { DataRow ndr = dtSource.NewRow(); foreach (JProperty _jpKYTFile in _joKYTFile.Properties()) { if (!dtSource.Columns.Contains(_jpKYTFile.Name)) { dtSource.Columns.Add(new DataColumn(_jpKYTFile.Name, typeof(string))); } switch (_jpKYTFile.Name) { case "FILE_ID": case "FILE_NAME": case "FILE_PATH": ndr[_jpKYTFile.Name] = _jpKYTFile.Value; // 新增新的檔案清單 break; case "PROCESSOR_KEY": ndr[_jpKYTFile.Name] = Current_CPUID; // 記錄自己的CPU ID break; case "FILE_SHA": ndr["FILE_COMPARE_SHA"] = _jpKYTFile.Value; // 將來源資料的雜湊值記錄到比對的欄位內 break; } } ndr["IS_NEWFILE"] = true; // 是新檔案 dtSource.Rows.Add(ndr); } else // 現在的清單已經有了 { _drs[0]["FILE_COMPARE_SHA"] = _joKYTFile["FILE_SHA"]; // 將來源資料的雜湊值記錄到比對的欄位內 } } } } catch (Exception ex) { KYTUtilLibs.KYTDebugLog.Log(KYTLog.DebugLog.LogLevel.Error, string.Format(@"QickCheckCompareVersion_Simple.rauVersionListUpload_FileUploaded.ParseJSON.ERROR:{0}", ex.Message)); } } } else if (extensionName.Equals(".zip") || extensionName.Equals(".rar")) // 是RAR或ZIP壓縮檔 { #region 將上傳檔案複製,並且解壓縮 string DirPath = Path.Combine(Request.PhysicalApplicationPath, "CDS", "TempExtract"); if (CheckDirectoryExists(DirPath)) { string filePath = Path.Combine(DirPath, postedFile.FileName); postedFile.SaveAs(filePath); string ExtractPath = Path.Combine(DirPath, Path.GetFileNameWithoutExtension(postedFile.FileName)); // 解壓縮到壓縮檔名稱的資料夾 DeCompressRar(filePath, ExtractPath); #endregion 將上傳檔案複製,並且解壓縮 #region 將收納檔案輸出成kytlist格式 JArray jaMainSource = new JArray(); #region 巡覽資料夾及檔案並收納 string[] files = Directory.GetFiles(ExtractPath, "*.*", SearchOption.AllDirectories); foreach (string _file in files) { JObject joOneFile = new JObject(); string relativePath = _file.Replace(ExtractPath, ""); string FILE_PATH = relativePath.Substring(1, relativePath.Length - 1); string FILE_ID = FILE_PATH.Replace("\\", "_"); string FILE_NAME = Path.GetFileName(_file); string FILE_SHA = ""; using (FileStream stream = File.OpenRead(_file)) { FILE_SHA = getSHA256String(stream); } joOneFile.Add(new JProperty("FILE_ID", FILE_ID)); // 檔案所屬的KEY joOneFile.Add(new JProperty("FILE_NAME", FILE_NAME)); // 檔案名稱 joOneFile.Add(new JProperty("FILE_PATH", FILE_PATH)); // 檔案相對路徑 joOneFile.Add(new JProperty("FILE_VERSION", "1.0.0.0")); // 檔案版本 joOneFile.Add(new JProperty("FILE_SHA", FILE_SHA)); // 檔案雜湊值 joOneFile.Add(new JProperty("PROCESSOR_KEY", Current_CPUID)); // CPU ID joOneFile.Add(new JProperty("MODIFY_TIME", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))); // 最後驗證時間 jaMainSource.Add(joOneFile); } #endregion 巡覽資料夾及檔案並收納 #endregion 將收納檔案輸出成kytlist格式 #region 儲存到暫存位置 string kytlistPath = Path.Combine(DirPath, string.Format("FileVersionList.{0}.kytlist", Path.GetFileNameWithoutExtension(postedFile.FileName))); //using (StreamWriter sw = new StreamWriter(kytlistPath, false, Encoding.UTF8)) //{ // sw.WriteLine(jaMainSource.ToString()); //} SystemStreamWriter(kytlistPath, jaMainSource.ToString()); #endregion 儲存到暫存位置 #region kytlist檔案清單 if (File.Exists(kytlistPath)) { ScriptManager.RegisterClientScriptBlock( UpdatePanel1, UpdatePanel1.GetType(), Guid.NewGuid().ToString(), string.Format(@" window.location = '{0}?filepath={1}'; " , Page.ResolveUrl("~/CDS/KYTUtils/WebService/FORMPRINT/DownFileWithPath.ashx") , HttpUtility.UrlEncode(kytlistPath)), true); } else { ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), Guid.NewGuid().ToString(), @" document.addEventListener('DOMContentLoaded', function() { alert('找不到清單檔, 請聯繫系統管理員'); }); ", true); } #endregion kytlist檔案清單 #region 刪除壓縮檔以及解壓縮的資料夾 try { File.Delete(filePath); Directory.Delete(ExtractPath, true); } catch (Exception ex) { KYTUtilLibs.KYTDebugLog.Log(KYTLog.DebugLog.LogLevel.Error, string.Format(@"QickCheckCompareVersion_Simple.rauVersionListUpload_FileUploaded.Extract.Delete.ERROR:{0}", ex.Message)); } #endregion 刪除壓縮檔以及解壓縮的資料夾 } else { ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), Guid.NewGuid().ToString(), string.Format(@" document.addEventListener('DOMContentLoaded', function() { alert('無法建立{0}'); }); ", DirPath), true); } } } } // 刪除暫存檔 //foreach (string _tmpPath in lsTempPath) //{ // File.Delete(_tmpPath); //} gvFILE_VERSION.DataSource = dtSource; gvFILE_VERSION.DataBind(); } }
protected void AsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { try { //GUARDAMOS LOS RESULTADOS DE LA ACTIVIDAD int r = AsyncUpload1.UploadedFiles.Count; int no_ = 0; int id_request = Convert.ToInt32(hdnIdRequestBond.Value == "" ? "0" : hdnIdRequestBond.Value); if (no_ == 0 && id_request == 0) { Toast.Error("Seleccione un empleado.", this); } else { string name = ""; DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath("~/"));//path localDateTime localDate = DateTime.Now; string path_local = "files/documents/temp/"; string directory = dirInfo.ToString() + path_local; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } name = Path.GetFileNameWithoutExtension(e.File.FileName) + Path.GetExtension(e.File.FileName); if (id_request > 0) { //si hay un id de bono, quiere decir que es una actualizacion y agregamos en la base de datos int id_request_bonds = id_request; RutasArchivosCOM rutas = new RutasArchivosCOM(); string path_local2 = @rutas.path(1); string directory2 = path_local2 + id_request_bonds.ToString() + @"\"; if (!Directory.Exists(@directory2)) { Directory.CreateDirectory(@directory2); } files_requests_bonds file = new files_requests_bonds(); file.path = @directory2 + name.Trim().Replace(@"\", "/"); file.file_name = name.Trim(); file.size = Convert.ToDecimal(e.File.ContentLength); file.content_type = e.File.ContentType; string source = file.path; string path = @directory2 + file.file_name; file.login = Session["usuario"] as string; file.path = "UploadedFiles/" + id_request_bonds.ToString() + "/"; file.id_request_bond = id_request_bonds; BonosCOM bonos = new BonosCOM(); int id_file_request = bonos.AgregarArchivo(file); if (id_file_request > 0) { e.File.SaveAs(path); AgregarDocumento(path, file.file_name, file.content_type, Convert.ToDecimal(file.size)); CargarTablaArchivos(); Toast.Success("Documento guardado correctamente.", "Mensaje del sistema", this); } else { Toast.Error("Error al guardar archivo.", this); } } else { e.File.SaveAs(directory + name.Trim()); AgregarDocumento(directory + name.Trim(), name.Trim(), e.File.ContentType, Convert.ToDecimal(e.File.ContentLength)); CargarTablaArchivos(); Toast.Success("Documento guardado correctamente.", "Mensaje del sistema", this); } } } catch (Exception ex) { Toast.Error("Error al guardar documento: " + ex.Message, this); } finally { InitTables(); } }
protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { //check file size //if (e.File.ContentLength < 5000) //{ //} string filename = DateTime.Now.ToString("yyyyMMdd") + "_" + Guid.NewGuid().ToString() + e.File.GetExtension(); var physicalSavePath = MapPath(Config.UploadInvoiceVirtualPath) + filename; //Save physical file on disk e.File.SaveAs(physicalSavePath, true); //Add receipt to uploaded iamge //create upload receipt record ClientManager.insertRedemptionByPointReceipt( (Guid)Membership.GetUser().ProviderUserKey, filename, Config.ClientId, (int)RedemptionByPointReceiptState.PENDING_PROCESS, 0, 0, "", null); var client = ClientManager.getClient(Config.ClientId); string emailLogoUrl = Config.SiteRootUrl + client.logoimagename; Hashtable values = new Hashtable(); values.Add("[/logo/]", emailLogoUrl); values.Add("[/SiteRootUrl/]", Config.SiteRootUrl); var redemptionMember = ClientManager.getRedemptionMember((Guid)Membership.GetUser().ProviderUserKey); bool canSendEmail = EmailManager.SendClaimPointAckMail( Membership.GetUser().Email, redemptionMember.firstname, values, this.Response); // e.IsValid = true; /* * BtnSubmit.Visible = false; * RefreshButton.Visible = true; * RadAsyncUpload1.Visible = false; * * var liItem = new HtmlGenericControl("li"); * liItem.InnerText = e.File.FileName; * * * if (totalBytes < MaxTotalBytes) * { * // Total bytes limit has not been reached, accept the file * e.IsValid = true; * totalBytes += e.File.ContentLength; * } * else * { * // Limit reached, discard the file * e.IsValid = false; * } * * if (e.IsValid) * { * * ValidFiles.Visible = true; * ValidFilesList.Controls.AddAt(0, liItem); * * } * else * { * * InvalidFiles.Visible = true; * InValidFilesList.Controls.AddAt(0, liItem); * }*/ }
protected void Sg_Site_Assy_file_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { }
protected void aUploadFileUpdate_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { }
protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { //check file size //if (e.File.ContentLength < 5000) //{ //} if ((Request.QueryString["userid"] != null) || (Request.QueryString["clientid"] != null)) { string userid = Request.QueryString["userid"]; MembershipUser aMembershipUser = Membership.GetUser(new Guid(userid)); int clientId = int.Parse(Request.QueryString["clientid"]); string filename = DateTime.Now.ToString("yyyyMMdd") + "_" + Guid.NewGuid().ToString() + e.File.GetExtension(); var physicalSavePath = MapPath(Config.UploadInvoiceVirtualPath) + filename; //Save physical file on disk e.File.SaveAs(physicalSavePath, true); //Add receipt to uploaded iamge //create upload receipt record ClientManager.insertRedemptionByPointReceipt( (Guid)aMembershipUser.ProviderUserKey, filename, clientId, (int)RedemptionByPointReceiptState.PENDING_PROCESS, 0, 0, "", null); var client = ClientManager.getClient(clientId); string emailpath = Config.MainSiteRootUrl + client.siterelativepath + client.logoimagename; Hashtable values = new Hashtable(); values.Add("[/logo/]", emailpath); var redemptionMember = ClientManager.getRedemptionMember((Guid)aMembershipUser.ProviderUserKey); //bool canSendEmail = EmailManager.SendClaimPointAckMail( // aMembershipUser.Email, // redemptionMember.firstname, // values, client.clientid, this.Response); Logger.LogInfo(Membership.GetUser().UserName + "- submitted claimpoint username :"******"client ID :" + clientId , this.GetType()); //string emailpath = Config.MainSiteRootUrl + client.siterelativepath + client.logoimagename; //Hashtable values = new Hashtable(); //values.Add("[/logo/]", emailpath); //var redemptionMember = ClientManager.getRedemptionMember(UserId); //bool canSendEmail = EmailManager.SendClaimPointApprovalMail( // membershipUser.Email, // redemptionMember.firstname, // values, client.emailphysicalpath); // e.IsValid = true; /* * BtnSubmit.Visible = false; * RefreshButton.Visible = true; * RadAsyncUpload1.Visible = false; * * var liItem = new HtmlGenericControl("li"); * liItem.InnerText = e.File.FileName; * * * if (totalBytes < MaxTotalBytes) * { * // Total bytes limit has not been reached, accept the file * e.IsValid = true; * totalBytes += e.File.ContentLength; * } * else * { * // Limit reached, discard the file * e.IsValid = false; * } * * if (e.IsValid) * { * * ValidFiles.Visible = true; * ValidFilesList.Controls.AddAt(0, liItem); * * } * else * { * * InvalidFiles.Visible = true; * InValidFilesList.Controls.AddAt(0, liItem); * }*/ } }
protected void Sg_Spl_Info_file_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { }
/// <summary> /// 選擇檔案後觸發的上傳檔案事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void rauDOCXUpload_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { if (rauDOCXUpload.UploadedFiles.Count > 0) // 判斷是否有上傳檔案 { foreach (Telerik.Web.UI.UploadedFile postedFile in rauDOCXUpload.UploadedFiles) // 巡覽上傳的所有檔案 { if (postedFile != null) { string extensionName = System.IO.Path.GetExtension(postedFile.FileName); if (extensionName.Equals(".doc") || extensionName.Equals(".docx")) // 沒有 { HttpContext current = HttpContext.Current; string tempFile = current.Server.MapPath(@"~\App_Data\temp.docx"); // 輸出資料夾路徑 if (!Directory.Exists(Path.GetDirectoryName(tempFile))) // 若暫存資料夾不存在則建立 { try { Directory.CreateDirectory(Path.GetDirectoryName(tempFile)); } catch (Exception ex) { KYTUtilLibs.KYTDebugLog.Log(DebugLog.LogLevel.Error, string.Format("UC_TAIYUEN_FEE_N::列印::建立資料夾失敗::原因:{0}", ex.Message)); }; } if (File.Exists(tempFile)) { File.Delete(tempFile); } using (FileStream filestream = postedFile.InputStream as FileStream) { using (var outputFileStream = File.Create(tempFile)) { filestream.Seek(0, SeekOrigin.Begin); filestream.CopyTo(outputFileStream); } } if (chkForce.Checked) { //File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[$<", ">$]")); //File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[<", ">$]")); //File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[$<", ">]")); //File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[$<", "$]")); //File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[$", ">$]")); //File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[<", ">]")); //File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[", ">]")); //File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[<", "]")); File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[", "]")); } else { File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[$", "$]")); //File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[$<", ">$]")); //File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[<", ">$]")); //File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[$<", ">]")); //File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[$<", "$]")); //File.WriteAllBytes(tempFile, KYTIDocument.KYTIDocx.MakeTemplate(tempFile, "[$", ">$]")); } ScriptManager.RegisterClientScriptBlock( UpdatePanel1, UpdatePanel1.GetType(), Guid.NewGuid().ToString(), string.Format(@" document.addEventListener('DOMContentLoaded', function() {{ window.location = '{0}?filepath={1}'; }}); " , Page.ResolveUrl("~/CDS/KYTUtils/WebService/FORMPRINT/DownFileWithPath.ashx") , HttpUtility.UrlEncode(tempFile)), true); } } } } }
protected void Sg_CUTLIST_file_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e) { }