using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using ETS_Data; using NLog; namespace ETS_WS.WebUserControls { public partial class mod_myTempFile : System.Web.UI.UserControl { protected Logger lg; protected void Page_Load(object sender, EventArgs e) { lg = LogManager.GetCurrentClassLogger(); if (!Page.IsPostBack) { doUpdate(); } } /// /// verifica dir temp utente /// private void checkDirUpload() { fileMover.checkDir(WebShipUtils.mng.UserTempPath); } #if false /// /// path caricamento temporaneo utente /// protected string UserTempPath { get { string path = ""; // prima il path try { if (utils.obj.StringSessionObj("UserTempPath") != "") { path = utils.obj.StringSessionObj("UserTempPath"); } else { path = string.Format("{0}/{1}", utils.obj.confReadString("tempUplDir"), utils.obj.currUser_FS); utils.obj.setSessionVal("UserTempPath", path); } } catch (Exception exc) { lg.Info("errore check directory: {0}", exc); } return path; } } #endif /// /// seleziona/deseleziona le righe indicate... /// /// /// protected void btnSelAll_Click(object sender, EventArgs e) { // seleziono tutti i valori visibili nel datagrid CheckBox chkbox = ((CheckBox)sender); bool isChecked = chkbox.Checked; if (!isChecked) { chkbox.ToolTip = "Seleziona tutti"; } else { chkbox.ToolTip = "Deseleziona tutti"; } foreach (GridViewRow riga in grView.Rows) { ((CheckBox)riga.FindControl("chkSelect")).Checked = isChecked; } } /// /// forza update visualizzazione /// public void doUpdate() { checkDirUpload(); grView.DataBind(); //ods.DataBind(); } /// /// modalità di editing metadati attiva/disattiva /// public bool editMode { get { return utils.obj.BoolSessionObj("editMyDocsMetadata"); } set { utils.obj.setSessionVal("editMyDocsMetadata", value); grView.DataBind(); } } /// /// /// /// /// public string downloadLink(object nome) { string answ = ""; try { answ = string.Format(@"{0}\{1}", WebShipUtils.mng.UserTempPath, nome); } catch { } return answ; } /// /// restituisce il nome di un icona (nel formato nome_icona.png) dal filetype (*.fileType) /// /// /// public string imgFromName(object nome) { string answ = "undef.png"; string tipo = ""; int posPunto = -1; try { tipo = nome.ToString(); posPunto = tipo.LastIndexOf("."); tipo = tipo.Substring(posPunto, tipo.Length - posPunto).Replace(".", ""); // ora faccio switch x "raggruppare" tipo di files switch (tipo) { case "jpg": case "png": case "tif": case "gif": tipo = "image"; break; case "txt": case "doc": case "rtf": case "docx": case "odt": case "xls": case "xlsx": case "ods": case "ppt": case "pptx": case "odx": tipo = "office"; break; case "zip": case "rar": case "7zip": case "gz": case "tgz": tipo = "compress"; break; case "avi": case "divx": case "xvid": tipo = "video"; break; case "eml": tipo = "email"; break; case "exe": case "msi": tipo = "program"; break; case "pdf": case "eps": tipo = "pdf"; break; default: tipo = "unknown"; break; } answ = string.Format("{0}.png", tipo); } catch { } return string.Format(@"~\images\{0}", answ); } /// /// sposta i files selezionati da area temp ad archivio /// /// public bool spostaTempSel() { bool answ = false; // recupero metadati da sessione... docMetaDataSet docsData = WebShipUtils.mng.currMetaData; //check del path string pathDest = docsData.path; // verifico path presente if (pathDest != "") { // verifico se è comunicazione red = riservata string comPath = ""; if (!docsData.isRed) { comPath = utils.obj.confReadString("archiveDir"); } else { comPath = utils.obj.confReadString("archiveDirRed"); } // aggiunto al path cartella archivio corretta... pathDest = string.Format("{0}{1}", comPath, docsData.path); // verifico path valido o creo... fileMover.checkDir(pathDest); string nomeFile = ""; string redattore = utils.obj.currUserNomeCognome; // usa utente corrente // sposto i files selezionati secondo i dati in sessione foreach (GridViewRow riga in grView.Rows) { if (((CheckBox)riga.FindControl("chkSelect")).Checked) { // devo salvare file con le info relative... nomeFile = ((HyperLink)riga.FindControl("hlNome")).Text; WebShipUtils.archiviaFile(docsData, WebShipUtils.mng.UserTempPath, pathDest, nomeFile, redattore); } } } WebShipUtils.dateIsOk(DateTime.Now); grView.DataBind(); return answ; } /// /// effettua mass delete (se richiesto) /// /// /// protected void btnDeleteSel_Click(object sender, EventArgs e) { string nomeFile = ""; foreach (GridViewRow riga in grView.Rows) { if (((CheckBox)riga.FindControl("chkSelect")).Checked) { nomeFile = ((HyperLink)riga.FindControl("hlNome")).Text; fileMover.obj.eliminaFile(WebShipUtils.mng.UserTempPath, nomeFile); } } grView.DataBind(); } } }