public FileInUpload GetFileInUpload(string strIdentity, DocsPaVO.utente.InfoUtente infoUtente) { //hashFile non viene piĆ¹ considerato logger.Debug("INIZIO Metodo GetFileInUpload in DocsPaDb.Query_DocsPAWS.UploadFiles"); FileInUpload retVal = null; try { string query; DataSet ds = new DataSet(); DocsPaUtils.Query q = DocsPaUtils.InitQuery.getInstance().getQuery("S_DPA_UPLOAD_FILE"); //q.setParam("fileHash", hashFile); q.setParam("identity", strIdentity); q.setParam("IdUtente", infoUtente.idPeople); //q.setParam("fileName", fileName); //q.setParam("fileDescription", fileDescription); query = q.getSQL(); logger.Debug("GetFileInUpload: " + query); if (this.ExecuteQuery(out ds, "UPLOAD_FILE", query)) { if (ds.Tables["UPLOAD_FILE"] != null && ds.Tables["UPLOAD_FILE"].Rows.Count > 0) { retVal = new FileInUpload(); foreach (DataRow row in ds.Tables["UPLOAD_FILE"].Rows) { retVal.IdUtente = row["Id_People"].ToString(); retVal.IdRuolo = row["Id_Ruolo"].ToString(); retVal.ChunkNumber = Convert.ToInt32(row["File_Part"].ToString()); //retVal.FileHash = hashFile; retVal.FileName = row["File_Name"].ToString(); retVal.FileDescription = row["File_Description"].ToString(); retVal.FileSenderPath = row["Sender_Path"].ToString(); retVal.FileSize = Convert.ToInt64(row["File_Size"].ToString()); retVal.MachineName = row["Sender_Name"].ToString(); retVal.TotalChunkNumber = Convert.ToInt32(row["Total_Part"].ToString()); retVal.RepositoryPath = row["File_Path"].ToString(); retVal.Order = Convert.ToInt32(row["Num_Order"].ToString()); retVal.StrIdentity = row["UnicStr"].ToString(); } } } } catch (Exception e) { logger.Error("Errore nel Metodo GetFileInUpload in DocsPaDb.Query_DocsPAWS.UploadFiles " + e.Message); return(null); } logger.Debug("FINE Metodo GetFileInUpload in DocsPaDb.Query_DocsPAWS.UploadFiles"); return(retVal); }
/// <summary> /// Creazione di un file in upload per l'utente loggato /// </summary> /// <param name="fileInUpload"></param> /// <param name="infoUtente"></param> /// <returns></returns> public bool InsertFileInUpload(FileInUpload fileInUpload, DocsPaVO.utente.InfoUtente infoUtente) { bool retVal = false; logger.Debug("Inizio Metodo InsertFileInUpload in DocsPaDb.Query_DocsPAWS.UploadFiles"); if (fileInUpload != null) { try { BeginTransaction(); DocsPaUtils.Query q = DocsPaUtils.InitQuery.getInstance().getQuery("I_DPA_UPLOAD_FILE"); string idProcesso = string.Empty; q.setParam("Id_People", infoUtente.idPeople); q.setParam("Id_Ruolo", fileInUpload.IdRuolo); q.setParam("File_Hash", fileInUpload.FileHash); q.setParam("Sender_Name", fileInUpload.MachineName); q.setParam("Sender_Path", fileInUpload.FileSenderPath); q.setParam("File_Name", fileInUpload.FileName); q.setParam("File_Description", fileInUpload.FileDescription); q.setParam("File_Size", fileInUpload.FileSize.ToString()); q.setParam("File_Part", fileInUpload.ChunkNumber.ToString()); q.setParam("Total_Part", fileInUpload.TotalChunkNumber.ToString()); q.setParam("File_Path", fileInUpload.RepositoryPath); q.setParam("Ordine", fileInUpload.Order.ToString()); q.setParam("identity", fileInUpload.StrIdentity); string query = q.getSQL(); logger.Debug("InsertFileInUpload: " + query); if (ExecuteNonQuery(query)) { CommitTransaction(); retVal = true; } else { throw new Exception("Errore durante la creazione del record nella tabella DPA_UPLOAD_FILE: " + query); } } catch (Exception e) { RollbackTransaction(); logger.Error("Errore in DocsPaDb.Query_DocsPAWS.UploadFiles - Metodo InsertFileInUpload", e); retVal = false; } } logger.Debug("Fine Metodo InsertFileInUpload in DocsPaDb.Query_DocsPAWS.UploadFiles"); return(retVal); }
public List <FileInUpload> GetListFilesUploaded(DocsPaVO.utente.InfoUtente infoUtente) { List <FileInUpload> listFilesOnServer = new List <FileInUpload>(); try { string query; DataSet ds = new DataSet(); DocsPaUtils.Query q = DocsPaUtils.InitQuery.getInstance().getQuery("S_DPA_BIGFILE_LIST"); q.setParam("IdUtente", infoUtente.idPeople); q.setParam("IdRuolo", infoUtente.idGruppo); //q.setParam("not", (incomplete?"":"not")); query = q.getSQL(); logger.Debug("GetListFilesCompletati: " + query); if (this.ExecuteQuery(out ds, "UPLOADED_FILE_LIST", query)) { if (ds.Tables["UPLOADED_FILE_LIST"] != null && ds.Tables["UPLOADED_FILE_LIST"].Rows.Count > 0) { foreach (DataRow row in ds.Tables["UPLOADED_FILE_LIST"].Rows) { FileInUpload retVal = new FileInUpload(); retVal.IdUtente = row["Id_People"].ToString(); retVal.IdRuolo = row["Id_Ruolo"].ToString(); retVal.ChunkNumber = Convert.ToInt32(row["File_Part"].ToString()); retVal.FileHash = row["File_Hash"].ToString(); retVal.FileName = row["File_Name"].ToString(); retVal.FileDescription = row["File_Description"].ToString(); retVal.FileSenderPath = row["Sender_Path"].ToString(); retVal.FileSize = Convert.ToInt64(row["File_Size"].ToString()); retVal.MachineName = row["Sender_Name"].ToString(); retVal.TotalChunkNumber = Convert.ToInt32(row["Total_Part"].ToString()); retVal.RepositoryPath = row["File_Path"].ToString(); retVal.Order = Convert.ToInt32(row["Num_Order"].ToString()); retVal.StrIdentity = row["UnicStr"].ToString(); listFilesOnServer.Add(retVal); } } } } catch (Exception e) { logger.Error("Errore nel Metodo GetListFilesCompletati in DocsPaDb.Query_DocsPAWS.UploadFiles " + e.Message); } return(listFilesOnServer); }
private NttDataWA.DocsPaWR.FileDocumento NewFileDoc(FileInUpload fileSelected) { NttDataWA.DocsPaWR.FileDocumento fileDoc = new NttDataWA.DocsPaWR.FileDocumento(); fileDoc.name = fileSelected.FileName; fileDoc.fullName = System.IO.Path.Combine(fileSelected.RepositoryPath, fileSelected.FileName); fileDoc.contentType = NttDataWA.UIManager.FileManager.GetMimeType(fileSelected.FileName); fileDoc.length = int.Parse(fileSelected.FileSize.ToString());//this.fileUpload.PostedFile.ContentLength;// ContentLength;// .FileSize; fileDoc.nomeOriginale = fileSelected.StrIdentity; SetSessionValue("fileDoc", fileDoc); SetSessionValue("personalFileSelected", fileSelected); return(fileDoc); }
protected void gridViewResult_SelectedIndexChanged(Object sender, EventArgs e) { //GridViewRow row = grdfileList.SelectedRow; int indexSelected = grdfileList.SelectedRow.RowIndex; FileInUpload fileSelected = ListaFileDisponibili[indexSelected]; //InfoUtente infoUtente = UserManager.GetInfoUser(); NttDataWA.DocsPaWR.FileDocumento fileDoc = new NttDataWA.DocsPaWR.FileDocumento(); fileDoc.name = fileSelected.FileName; fileDoc.fullName = System.IO.Path.Combine(fileSelected.RepositoryPath, fileSelected.FileName); fileDoc.contentType = NttDataWA.UIManager.FileManager.GetMimeType(fileSelected.FileName); fileDoc.length = int.Parse(fileSelected.FileSize.ToString());//this.fileUpload.PostedFile.ContentLength;// ContentLength;// .FileSize; fileDoc.nomeOriginale = fileSelected.StrIdentity; SetSessionValue("fileDoc", fileDoc); SetSessionValue("personalFileSelected", fileSelected); }
protected void gridViewResult_RowCommand(Object sender, GridViewCommandEventArgs e) { string msg = string.Empty; string msgError = string.Empty; FileInUpload fileSelected = null; NttDataWA.DocsPaWR.FileDocumento fileDoc = null; //int indexSelected = grdfileList.SelectedRow.RowIndex; string rowIndex = string.Empty; switch (e.CommandName) { //Redirect al grigio contenente l'allegato selezionato case "DeleteFile": rowIndex = (((e.CommandSource as CustomImageButton).Parent.Parent as GridViewRow).FindControl("systemIdElemento") as Label).Text; fileSelected = (from v in ListaFileDisponibili where v.StrIdentity.Equals(rowIndex) select v).FirstOrDefault(); fileDoc = NewFileDoc(fileSelected); //fileSelected = (FileInUpload)GetSessionValue("personalFileSelected"); msgError = FileManager.DeletePersonalFile(this, fileDoc, fileSelected.FileName, fileSelected.FileDescription); if (string.IsNullOrEmpty(msgError)) { GridViewResult_Bind(); } else { msg = "ErrorFileUpload_custom"; msgError = msgError.Equals("ErrorAcquiredDocument") ? Utils.Languages.GetMessageFromCode(msgError, UserManager.GetUserLanguage()) : msgError; ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('" + Utils.utils.FormatJs(msg) + "', 'error', '', '" + Utils.utils.FormatJs(msgError) + "');} else {parent.ajaxDialogModal('" + Utils.utils.FormatJs(msg) + "', 'error', '', '" + Utils.utils.FormatJs(msgError) + "');}; reallowOp();", true); } return; case "AddFile": rowIndex = (((e.CommandSource as LinkButton).Parent.Parent as GridViewRow).FindControl("systemIdElemento") as Label).Text; fileSelected = (from v in ListaFileDisponibili where v.StrIdentity.Equals(rowIndex) select v).FirstOrDefault(); fileDoc = NewFileDoc(fileSelected); //fileDoc = (NttDataWA.DocsPaWR.FileDocumento)GetSessionValue("fileDoc"); //fileSelected = (FileInUpload)GetSessionValue("personalFileSelected"); msgError = FileManager.uploadPersonalFile(this, fileDoc, fileSelected.FileName, fileSelected.FileDescription); if (string.IsNullOrEmpty(msgError)) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "function", "<script>reallowOp();</script>", false); ScriptManager.RegisterClientScriptBlock(this.UpUpdateButtons, this.UpUpdateButtons.GetType(), "closeAJM", "parent.closeAjaxModal('RepositoryView','selected');", true); } else { msg = "ErrorFileUpload_custom"; msgError = msgError.Equals("ErrorAcquiredDocument") ? Utils.Languages.GetMessageFromCode(msgError, UserManager.GetUserLanguage()) : msgError; ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('" + Utils.utils.FormatJs(msg) + "', 'error', '', '" + Utils.utils.FormatJs(msgError) + "');} else {parent.ajaxDialogModal('" + Utils.utils.FormatJs(msg) + "', 'error', '', '" + Utils.utils.FormatJs(msgError) + "');}; reallowOp();", true); } return; case "Description": rowIndex = (((e.CommandSource as LinkButton).Parent.Parent as GridViewRow).FindControl("systemIdElemento") as Label).Text; fileSelected = (from v in ListaFileDisponibili where v.StrIdentity.Equals(rowIndex) select v).FirstOrDefault(); fileDoc = NewFileDoc(fileSelected); msg = "PersonalFileDetails"; msgError = fileSelected.FileDescription; ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('" + Utils.utils.FormatJs(msg) + "', 'check', '', '" + Utils.utils.FormatJs(msgError) + "');} else {parent.ajaxDialogModal('" + Utils.utils.FormatJs(msg) + "', 'check', '', '" + Utils.utils.FormatJs(msgError) + "');}; reallowOp();", true); return; case "UpdateGrid": GridViewResult_Bind(); return; default: ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "function", "<script>reallowOp();</script>", false); break; } }
protected void gridViewResult_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { FileInUpload elemento = e.Row.DataItem as FileInUpload; if (!string.IsNullOrEmpty(elemento.StrIdentity)) { bool isIncomplete = (elemento.TotalChunkNumber != elemento.ChunkNumber); e.Row.CssClass += " NormalRow"; string descriptionFile = ""; if (!string.IsNullOrEmpty(elemento.FileDescription)) { descriptionFile = " [" + elemento.FileDescription + "]"; } if (isIncomplete) { int percentage = (elemento.TotalChunkNumber > 0?(elemento.ChunkNumber * 100) / elemento.TotalChunkNumber:0); string[] splitName = elemento.FileSenderPath.Split('\\'); string fileNameUncompressed = splitName[splitName.Length - 1]; string reformatFileName = FileNameReconfigurated(fileNameUncompressed); string pathImgFileType = FileManager.getFileIconSmall(this, FileManager.getEstensioneIntoSignedFile(reformatFileName)); (e.Row.FindControl("lblPercentage") as Label).Text = percentage.ToString() + " %"; (e.Row.FindControl("imgPercentage") as Image).ImageUrl = ProgressImgPath(percentage); (e.Row.FindControl("lblNomeFile") as LinkButton).Text = reformatFileName;// +descriptionFile; (e.Row.FindControl("lblNomeFile") as LinkButton).CommandName = "UpdateGrid"; (e.Row.FindControl("lblNomeFile") as LinkButton).ToolTip = Utils.Languages.GetLabelFromCode("RepositoryUpdate", language); if (descriptionFile.Length < 70) { (e.Row.FindControl("lblDescrizione") as Label).Text = descriptionFile; } else { (e.Row.FindControl("lblDescrizione") as Label).Text = descriptionFile.Substring(0, 67) + "..."; (e.Row.FindControl("lblDescrizione") as Label).ToolTip = descriptionFile; } //if (descriptionFile.Length < 30) //{ // (e.Row.FindControl("lkbDescrizione") as LinkButton).Visible = false; // (e.Row.FindControl("lblDescrizione") as Label).Text = descriptionFile; //} //else //{ // (e.Row.FindControl("lblDescrizione") as Label).Visible = false; // (e.Row.FindControl("lkbDescrizione") as LinkButton).Visible = true; // (e.Row.FindControl("lkbDescrizione") as LinkButton).CommandName = "Description"; // (e.Row.FindControl("lkbDescrizione") as LinkButton).Text = descriptionFile.Substring(0, 17) + "..."; //} (e.Row.FindControl("imgFile") as Image).ImageUrl = pathImgFileType; ((CustomImageButton)e.Row.FindControl("imgDeleteFile")).Visible = false; //(e.Row.FindControl("imgDeleteFile") as Image).CommandName = false; } else { (e.Row.FindControl("lblNomeFile") as LinkButton).Text = FileNameReconfigurated(elemento.FileName);// +descriptionFile; //Text='<%# Bind("FileName") %>' (e.Row.FindControl("lblNomeFile") as LinkButton).CommandName = "AddFile"; (e.Row.FindControl("lblNomeFile") as LinkButton).ToolTip = Utils.Languages.GetLabelFromCode("RepositoryAdd", language); //(e.Row.FindControl("lblDescrizione") as Label).Text = descriptionFile; (e.Row.FindControl("lkbDescrizione") as LinkButton).Visible = false; if (descriptionFile.Length < 70) { (e.Row.FindControl("lblDescrizione") as Label).Text = descriptionFile; } else { (e.Row.FindControl("lblDescrizione") as Label).Text = descriptionFile.Substring(0, 67) + "..."; (e.Row.FindControl("lblDescrizione") as Label).ToolTip = descriptionFile; } //if (descriptionFile.Length < 30) //{ // (e.Row.FindControl("lkbDescrizione") as LinkButton).Visible = false; // (e.Row.FindControl("lblDescrizione") as Label).Text = descriptionFile; //} //else //{ // (e.Row.FindControl("lblDescrizione") as Label).Visible = false; // (e.Row.FindControl("lkbDescrizione") as LinkButton).Visible = true; // (e.Row.FindControl("lkbDescrizione") as LinkButton).CommandName = "Description"; // (e.Row.FindControl("lkbDescrizione") as LinkButton).Text = descriptionFile.Substring(0, 17) + "..."; //} string pathImgFileType = FileManager.getFileIconSmall(this, FileManager.getEstensioneIntoSignedFile(elemento.FileName)); (e.Row.FindControl("imgFile") as Image).ImageUrl = pathImgFileType; (e.Row.FindControl("lblPercentage") as Label).Text = Utils.Languages.GetLabelFromCode("PersonalFileView_Complete", language); (e.Row.FindControl("imgPercentage") as Image).ImageUrl = ProgressImgPath(-1); ((CustomImageButton)e.Row.FindControl("imgDeleteFile")).ImageUrl = "../Images/Icons/delete2.png"; ((CustomImageButton)e.Row.FindControl("imgDeleteFile")).OnMouseOverImage = "../Images/Icons/delete2.png"; ((CustomImageButton)e.Row.FindControl("imgDeleteFile")).OnMouseOutImage = "../Images/Icons/delete2.png"; ((CustomImageButton)e.Row.FindControl("imgDeleteFile")).ToolTip = Utils.Languages.GetLabelFromCode("RepositoryDelete", language); //for (int i = 0; i < (e.Row.Cells.Count - 1); i++) //{ // if (i == 0) //{ // e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(this.grdfileList, "Select$" + e.Row.RowIndex); // e.Row.Attributes["style"] = "cursor:pointer"; //} //e.Row.Cells[i].Attributes["onClick"] = "$('#grid_rowindex').val('" + e.Row.RowIndex.ToString() + "');__doPostBack('UpGrid');disallowOp('ContentPlaceHolderContent');return false;"; //} } } } }
/// <summary> /// Aggiornamento del record relativo al file in upload /// </summary> /// <param name="fileInUpload"></param> /// <param name="infoUtente"></param> /// <returns></returns> public bool UpdateFileInUpload(FileInUpload fileInUpload, DocsPaVO.utente.InfoUtente infoUtente) { bool retVal = false; logger.Debug("Inizio Metodo UploadFileInUpload in DocsPaDb.Query_DocsPAWS.UploadFiles"); if (fileInUpload != null) { try { BeginTransaction(); DocsPaUtils.Query q = DocsPaUtils.InitQuery.getInstance().getQuery("U_DPA_UPLOAD_FILE"); string idProcesso = string.Empty; q.setParam("identity", fileInUpload.StrIdentity); //q.setParam("fileName", fileInUpload.FileName); //q.setParam("fileDescription", fileInUpload.FileDescription); q.setParam("File_Name", fileInUpload.FileName); q.setParam("File_Description", fileInUpload.FileDescription); q.setParam("File_Part", fileInUpload.ChunkNumber.ToString()); q.setParam("IdRuolo", fileInUpload.IdRuolo); q.setParam("IdUtente", infoUtente.idPeople); //q.setParam("fileHash", fileInUpload.FileHash); q.setParam("TotalChunk", fileInUpload.TotalChunkNumber.ToString()); q.setParam("File_Path", fileInUpload.RepositoryPath); q.setParam("Ordine", fileInUpload.Order.ToString()); if (fileInUpload.ChunkNumber == fileInUpload.TotalChunkNumber) { if (dbType == "SQL") { q.setParam("End_Date", "GETDATE()"); } else { q.setParam("End_Date", "sysDate"); } } else { q.setParam("End_Date", "null"); } string query = q.getSQL(); logger.Debug("UploadFileInUpload: " + query); if (ExecuteNonQuery(query)) { CommitTransaction(); retVal = true; } else { throw new Exception("Errore durante l'aggiornamento del record nella tabella DPA_UPLOAD_FILE: " + query); } } catch (Exception e) { RollbackTransaction(); logger.Error("Errore in DocsPaDb.Query_DocsPAWS.UploadFiles - Metodo UploadFileInUpload", e); retVal = false; } } logger.Debug("Fine Metodo UploadFileInUpload in DocsPaDb.Query_DocsPAWS.UploadFiles"); return(retVal); }