Exemplo n.º 1
0
 /// <summary>
 /// Associazione dati
 /// </summary>
 /// <param name="allegato"></param>
 private void Fetch(DocsPaWR.Allegato allegato)
 {
     this.LabelTitolo.Text     = "Modifica allegato";
     this.TextCodice.Text      = allegato.versionLabel;
     this.TextDescrizione.Text = allegato.descrizione;
     this.TextNumPag.Text      = allegato.numeroPagine.ToString();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Reperimento allegato selezionato per la modifica dei dati
        /// </summary>
        /// <returns></returns>
        protected DocsPaWR.Allegato GetSelectedAllegato()
        {
            DocsPaWR.Allegato retValue = null;

            string versionId = this.VersionId;

            if (!string.IsNullOrEmpty(versionId))
            {
                DocsPaWR.SchedaDocumento schedaDocumento = this.GetSchedaDocumento();

                if (schedaDocumento != null)
                {
                    foreach (DocsPaWR.Allegato allegato in schedaDocumento.allegati)
                    {
                        if (allegato.versionId.Equals(versionId))
                        {
                            retValue = allegato;
                            break;
                        }
                    }
                }
            }

            return(retValue);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Navigazione verso il dettaglio del documento allegato
        /// </summary>
        protected virtual void NavigateDocument()
        {
            DocsPaWR.Allegato allegato = this.GetSelectedAllegato();

            if (allegato != null)
            {
                DocsPaWR.SchedaDocumento schedaDocumentoAllegato = null;

                if (this.DocumentoInCestino)
                {
                    schedaDocumentoAllegato = DocumentManager.getDettaglioDocumentoDaCestino(this, allegato.docNumber, allegato.docNumber);
                }
                else
                {
                    schedaDocumentoAllegato = DocumentManager.getDettaglioDocumento(this, allegato.docNumber, allegato.docNumber);
                }

                if (schedaDocumentoAllegato != null)
                {
                    DocumentManager.setDocumentoSelezionato(this, schedaDocumentoAllegato);

                    // Impostazione del versionId dell'allegato selezionato nel contesto corrente
                    this.SetCurrentIdOnContext(allegato.versionId);

                    // Navigazione verso il documento allegato,
                    // indicando di forzare la crezione di un nuovo contesto e
                    // se il documento è stato inserito in cestino
                    string url = string.Format("<script>window.open('gestioneDoc.aspx?tab=profilo&allegato=true&forceNewContext=true&daCestino={0}','principale');</script>", schedaDocumentoAllegato.inCestino);
                    this.Response.Write(url);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Funzione per il salvataggio dell'allegato
        /// </summary>
        private void ProceedWithSave()
        {
            string validationMessage;

            if (this.IsValidMask(out validationMessage))
            {
                if (DocumentManager.getBlockAllegati(this) != null && !DocumentManager.getBlockAllegati(this))
                {
                    DocumentManager.setBlockAllegati(this, true);
                    DocsPaWR.Allegato allegato = this.SaveAllegato();

                    if (allegato != null)
                    {
                        this.CloseMask(allegato.versionId);
                    }
                    else
                    {
                        this.RenderMessage("Errore nell'inserimento dell'allegato");
                    }
                }
            }
            else
            {
                this.RenderMessage(validationMessage);
            }
        }
Exemplo n.º 5
0
        private FileRequest ConvertiFileRequestInAllegato(FileRequest fileReq)
        {
            FileRequest file = new DocsPaWR.Allegato();

            file.applicazione          = fileReq.applicazione;
            file.autore                = fileReq.autore;
            file.autoreFile            = fileReq.autoreFile;
            file.cartaceo              = fileReq.cartaceo;
            file.daAggiornareFirmatari = fileReq.daAggiornareFirmatari;
            file.dataAcquisizione      = fileReq.dataAcquisizione;
            file.dataInserimento       = fileReq.dataInserimento;
            file.descrizione           = fileReq.descrizione;
            file.docNumber             = fileReq.docNumber;
            file.docServerLoc          = fileReq.docServerLoc;
            file.fileName              = fileReq.fileName;
            file.fileSize              = fileReq.fileSize;
            file.firmatari             = fileReq.firmatari;
            file.firmato               = fileReq.firmato;
            file.fNversionId           = fileReq.fNversionId;
            file.idPeople              = fileReq.idPeople;
            file.idPeopleDelegato      = fileReq.idPeopleDelegato;
            file.inLibroFirma          = fileReq.inLibroFirma;
            file.msgErr                = fileReq.msgErr;
            file.path = fileReq.path;
            file.repositoryContext = fileReq.repositoryContext;
            file.subVersion        = fileReq.subVersion;
            file.version           = fileReq.version;
            file.versionId         = fileReq.versionId;
            file.versionLabel      = fileReq.versionLabel;

            (file as Allegato).numeroPagine = (FileManager.GetFileRequest(UIManager.DocumentManager.getSelectedAttachId()) as Allegato).numeroPagine;

            return(file);
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
                if (!this.IsPostBack)
                {
                    DocsPaWR.InfoUtente info = new DocsPaWR.InfoUtente();
                    info = UserManager.GetInfoUser();

                    // Reperimento allegato selezionato
                    DocsPaWR.Allegato allegato = DocumentManager.GetSelectedAttachment();

                    if (!this._isCheckedOutDocument)
                    {
                        try
                        {
                            rowMessage.InnerHtml = "Sei sicuro di voler eliminare l'allegato " + allegato.versionLabel + "?";
                        }
                        catch (Exception ex)
                        {
                            // on postback throw n exception
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                UIManager.AdministrationManager.DiagnosticError(ex);
                return;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Task di salvataggio dell'allegato
        /// </summary>
        protected virtual DocsPaWR.Allegato SaveAllegato()
        {
            DocsPaWR.Allegato allegato = null;

            try
            {
                DocsPaWR.SchedaDocumento schedaDocumento = this.GetSchedaDocumento();

                // Reperimento oggetto allegato
                allegato = this.GetSelectedAllegato();

                if (allegato == null)
                {
                    // Modalità di inserimento
                    allegato              = new DocsPaWR.Allegato();
                    allegato.descrizione  = this.TextDescrizione.Text;
                    allegato.numeroPagine = this.NumeroPagine;
                    allegato.docNumber    = schedaDocumento.docNumber;
                    allegato.version      = "0";

                    string idPeopleDelegato = "0";
                    if (UserManager.getInfoUtente().delegato != null)
                    {
                        idPeopleDelegato = UserManager.getInfoUtente().delegato.idPeople;
                    }
                    allegato.idPeopleDelegato = idPeopleDelegato;

                    // Impostazione del repositoryContext associato al documento
                    allegato.repositoryContext = schedaDocumento.repositoryContext;
                    allegato.position          = (schedaDocumento.allegati.Length + 1);
                    allegato = DocumentManager.aggiungiAllegato(allegato);

                    // Inserimento dell'allegato nella scheda documento
                    List <DocsPaWR.Allegato> allegati = new List <DocsPaWR.Allegato>(schedaDocumento.allegati);
                    allegati.Add(allegato);
                    schedaDocumento.allegati = allegati.ToArray();
                }
                else
                {
                    // Modifica dati
                    allegato.descrizione  = this.TextDescrizione.Text;
                    allegato.numeroPagine = this.NumeroPagine;

                    DocumentManager.modificaAllegato(this, allegato, schedaDocumento.docNumber);
                    DocumentManager.setDocumentoSelezionato(this, schedaDocumento);
                }
            }
            catch (Exception ex)
            {
                allegato = null;
            }

            return(allegato);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Reperimento dell'autore o utente delegato alla creazione dell'allegato
        /// </summary>
        /// <param name="allegato"></param>
        /// <returns></returns>
        protected string GetAutoreOrDelegato(DocsPaWR.Allegato allegato)
        {
            string autore;

            if (!string.IsNullOrEmpty(allegato.idPeopleDelegato) && allegato.idPeopleDelegato != "0")
            {
                autore = allegato.idPeopleDelegato + "\nDelegato da " + allegato.autore;
            }
            else
            {
                autore = allegato.autore;
            }

            return(autore);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Funzione per determinare se bisogna visualizzare il controllo per collegare l'allegato al
        /// documento da cui è stato generato per Inoltro
        /// </summary>
        /// <param name="allegato">Informazioni sull'allegato</param>
        /// <returns>True se bisogna visualizzare il controllo</returns>
        protected bool GetIsVisibileSourceButton(DocsPaWR.Allegato allegato)
        {
            // Se non si è in postback, viene individuata e memorizzata l'autorizzazione a
            // visualizzare il controllo (funzionalità di inoltro massivo
            if (!IsPostBack)
            {
                this.IsRoleAuthorizedMassiveForwarding = UserManager.getRuolo(this).funzioni.Where(
                    e => e.codice.Equals("MASSIVE_INOLTRA")).Count() > 0;
            }

            // E' possibile visualizzare la freccia solo se si è abilitati ad effettuare l'inoltro massivo e
            // se la sorgente esiste
            return(this.IsRoleAuthorizedMassiveForwarding &&
                   !String.IsNullOrEmpty(allegato.ForwardingSource) && allegato.ForwardingSource != "-1");
        }
Exemplo n.º 10
0
 /// <summary>
 /// Attachment Button Click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void AttachmentBtn_Click(object sender, EventArgs e)
 {
     ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "function", "<script>reallowOp();</script>", false);
     if (isNewAttachment)
     {
         DocumentManager.setSelectedAttachId(null);
     }
     if (this.IsValid)
     {
         DocsPaWR.Allegato allegato = this.SaveAttachment();
         if (allegato != null)
         {
             this.CloseMask(false);
         }
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Reperimento della data di inserimento dell'allegato
        /// </summary>
        /// <param name="allegato"></param>
        /// <returns></returns>
        protected string GetDataInserimentoAllegatoAsString(DocsPaWR.Allegato allegato)
        {
            string retValue = string.Empty;

            DateTime dataInserimento;

            if (DateTime.TryParse(allegato.dataInserimento, out dataInserimento))
            {
                if (dataInserimento > DateTime.MinValue && dataInserimento < DateTime.MaxValue)
                {
                    return(dataInserimento.ToString("dd/MM/yyyy"));
                }
            }

            return(retValue);
        }
Exemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, System.EventArgs e)
        {
            this.Response.Expires = -1;

            if (!this.IsPostBack)
            {
                DocsPAWA.DocsPaWR.InfoUtente info = new DocsPAWA.DocsPaWR.InfoUtente();
                info = UserManager.getInfoUtente(this.Page);


                string valoreChiave = utils.InitConfigurationKeys.GetValue(info.idAmministrazione, "FE_MAX_LENGTH_DESC_ALLEGATO");
                if (!string.IsNullOrEmpty(valoreChiave))
                {
                    caratteriDisponibili = int.Parse(valoreChiave);
                }

                TextDescrizione.MaxLength = caratteriDisponibili;
                clTesto.Value             = caratteriDisponibili.ToString();
                TextDescrizione.Attributes.Add("onKeyUp", "calcTesto(this,'" + caratteriDisponibili.ToString() + " ','DESCRIZIONE'," + clTesto.ClientID + ")");
                TextDescrizione.Attributes.Add("onchange", "calcTesto(this,'" + caratteriDisponibili.ToString() + " ','DESCRIZIONE'," + clTesto.ClientID + ")");
                if (DocumentManager.getBlockAllegati(this) != null)
                {
                    DocumentManager.setBlockAllegati(this, false);
                }
                this.btn_ok.Attributes.Add("onclick", "window.document.body.style.cursor = 'wait'");

                // Reperimento allegato selezionato
                DocsPaWR.Allegato allegato = this.GetSelectedAllegato();

                this._isCheckedOutDocument = (CheckInOut.CheckInOutServices.IsCheckedOutDocument());

                if (!this._isCheckedOutDocument)
                {
                    if (allegato == null)
                    {
                        // Modalità di inserimento
                        this.FetchNew();
                    }
                    else
                    {
                        // Modalità di modifica dati
                        this.Fetch(allegato);
                    }
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_sostituisciDocPrinc_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            bool isCheckedOut = this.IsDocumentCheckedOut();

            try
            {
                if (!this.GetControlAclDocumento().AclRevocata&&
                    !isCheckedOut)
                {
                    DocsPaWR.Allegato allegato = this.GetSelectedAllegato();

                    if (allegato != null)
                    {
                        DocumentManager.scambiaAllegato(this, this.SchedaDocumento.documenti[0], allegato);

                        this._schedaDocumento = DocumentManager.getDettaglioDocumento(this,
                                                                                      DocumentManager.getInfoDocumento(this.SchedaDocumento).idProfile,
                                                                                      DocumentManager.getInfoDocumento(this.SchedaDocumento).docNumber);

                        DocumentManager.setDocumentoSelezionato(this, this.SchedaDocumento);

                        this.BindGrid();

                        this.PerformSelectionAllegato();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorManager.redirect(this, ex);
            }

            if (isCheckedOut)
            {
                ClientScript.RegisterStartupScript(
                    this.GetType(),
                    "NonScambiabile",
                    "alert('Non è possibile effettuare lo scambio perché il documento pricipale oppure almeno uno dei suoi allegati risulta bloccato.');",
                    true);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_ok_Click(object sender, System.EventArgs e)
        {
            try
            {
                DocsPaWR.Allegato allegato = this.GetAllegatoSelezionato();

                bool removed = DocumentManager.rimuoviAllegato(allegato, this._schedaDocumento);

                if (!removed)
                {
                    this.RenderMessage(MSG_REMOVE_ERROR);
                }
                else
                {
                    //Se vengo dal dettaglio documento e sto rimuovendo un allegato
                    if (_schedaDocumento.allegati.Length == 0)
                    {
                        _schedaDocumento.inCestino = "1";
                        bool returnValue = removed;
                        Response.Write("<script>window.returnValue = " + returnValue.ToString().ToLower() + ";window.close();</script>");
                    }
                    else
                    {
                        //Rimozione dell'allegato dal tab allegati
                        //pulisco anche la parte di destra
                        FileManager.removeSelectedFile(this);

                        List <DocsPaWR.Allegato> allegati = new List <DocsPAWA.DocsPaWR.Allegato>(this._schedaDocumento.allegati);
                        allegati.Remove(allegato);
                        this._schedaDocumento.allegati = allegati.ToArray();
                    }
                    this.CloseMask(true);
                }
            }
            catch (Exception ex)
            {
                ErrorManager.redirect(this, ex);
            }
        }
Exemplo n.º 15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
         if (Request.Form["value"] != null && Request.Form["value"].Length > 0)
         {
             DocsPaWR.Allegato attach = DocumentManager.GetSelectedAttachment();
             foreach (DocsPaWR.Documento d in DocumentManager.getDocumentDetails(this.Page, attach.docNumber, attach.docNumber).documenti)
             {
                 if (d.version.Equals(DocumentManager.getSelectedNumberVersion()))
                 {
                     d.descrizione = Request.Form["value"];
                     DocumentManager.ModifyVersion(d.descrizione);
                     break;
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         UIManager.AdministrationManager.DiagnosticError(ex);
         return;
     }
 }
Exemplo n.º 16
0
        /// <summary>
        /// Attachment Button Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AttachmentBtn_Click(object sender, EventArgs e)
        {
            try {
                DocsPaWR.Allegato allegato = DocumentManager.GetSelectedAttachment();
                SchedaDocumento   doc      = DocumentManager.getSelectedRecord();

                if (allegato != null)
                {
                    ProxyManager.GetWS().DocumentoRimuoviAllegato(allegato, UserManager.GetInfoUser(), doc);

                    // Delete attachment from document in session
                    List <DocsPaWR.Allegato> allegati = new List <DocsPaWR.Allegato>(doc.allegati);
                    allegati.Remove(allegato);
                    doc.allegati = allegati.ToArray();

                    // Update grid index
                    if (this.SelectedPage > (int)Math.Round((allegati.Count / this.PageSize) + 0.49))
                    {
                        this.SelectedPage = (int)Math.Round((allegati.Count / this.PageSize) + 0.49);
                    }

                    // Delete SelectedAttachment session
                    DocumentManager.setSelectedAttachId(null);

                    this.CloseMask();
                }
                else
                {
                    RenderMessage("Errore nell'eliminazione dell'allegato");
                }
            }
            catch (System.Exception ex)
            {
                UIManager.AdministrationManager.DiagnosticError(ex);
                return;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Azione di selezione allegato correntemente selezionato
        /// </summary>
        protected virtual void PerformSelectionAllegato()
        {
            // Reperimento oggetto allegato corrente
            DocsPaWR.Allegato allegato = this.GetSelectedAllegato();

            if (allegato != null)
            {
                FileManager.setSelectedFile(this, allegato);

                // Impostazione del versionId dell'allegato selezionato nel contesto corrente
                this.SetCurrentIdOnContext(allegato.versionId);

                //gestione etichette pdf
                Session.Add("allegato", true);

                this.btn_modifAlleg.Enabled = true;

                if (this.SchedaDocumento.repositoryContext != null ||
                    (this.SchedaDocumento.protocollo != null &&
                     !string.IsNullOrEmpty(this.SchedaDocumento.protocollo.segnatura)))
                {
                    this.btn_rimuoviAlleg.Enabled        = false;
                    this.btn_sostituisciDocPrinc.Enabled = false;
                }
                else
                {
                    this.btn_rimuoviAlleg.Enabled        = true;
                    this.btn_sostituisciDocPrinc.Enabled = true;
                }
            }
            else
            {
                // Nessun allegato selezionato
                FileManager.setSelectedFile(this, null);
                this.SetCurrentIdOnContext(string.Empty);
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Reperimento path dell'icona per la navigazione verso l'allegato
        /// </summary>
        /// <param name="allegato"></param>
        protected string GetNavigateIconPath(DocsPaWR.Allegato allegato)
        {
            string path = string.Empty;

            int result;

            if (Int32.TryParse(allegato.fileSize, out result))
            {
                if (result > 0)
                {
                    path = NAVIGATE_ICON_PATH_ACQUIRED;
                }
                else
                {
                    path = NAVIGATE_ICON_PATH;
                }
            }
            else
            {
                path = NAVIGATE_ICON_PATH;
            }

            return(path);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Reperimento allegato da rimuovere
        /// </summary>
        /// <returns></returns>
        protected DocsPaWR.Allegato GetAllegatoSelezionato()
        {
            DocsPaWR.Allegato retValue = null;


            if (_schedaDocumento.allegati.Length == 0)
            {
                DocsPAWA.DocsPaWR.Allegato[] lista = DocumentManager.getAllegatiPerRimozione(_schedaDocumento.documentoPrincipale.docNumber);
                if (lista != null && lista.Length > 0)
                {
                    foreach (DocsPaWR.Allegato item in lista)
                    {
                        if (item.docNumber == _schedaDocumento.docNumber)
                        {
                            retValue = item;
                            break;
                        }
                    }
                }
            }
            else
            {
                string docNumber = Request.QueryString["docNumber"];
                string versionId = Request.QueryString["versionId"];

                foreach (DocsPaWR.Allegato item in this._schedaDocumento.allegati)
                {
                    if (item.versionId == versionId)
                    {
                        retValue = item;
                        break;
                    }
                }
            }
            return(retValue);
        }
Exemplo n.º 20
0
 /*
  * private string FilterTipologia()
  * {
  *  if (this.rblFilter.SelectedValue.Equals("pec"))
  *  {
  *      return " WHERE exists (" +
  *          "(SELECT 'x' FROM dpa_notifica dn WHERE dn.docnumber=" + SchedaDocumento.docNumber +" and dn.version_id=C.VERSION_ID)" +
  *          "UNION" +
  *          "(SELECT 'x' FROM dpa_notifica dn WHERE dn.docnumber=" + SchedaDocumento.docNumber + " and C.OGGETTO LIKE 'Ricevuta di ritorno delle Mail%')" +
  *          ")";
  *  }
  *  else if (this.rblFilter.SelectedValue.Equals("user"))
  *  {
  *      return "WHERE not exists (" +
  *              "(SELECT 'x' FROM dpa_notifica dn WHERE dn.docnumber=" + SchedaDocumento.docNumber + " and dn.version_id=C.VERSION_ID)" +
  *              "UNION" +
  *              "(SELECT 'x' FROM dpa_notifica dn WHERE dn.docnumber=" + SchedaDocumento.docNumber + " and (C.OGGETTO LIKE 'Ricevuta di ritorno delle Mail%' Or C.OGGETTO LIKE 'Ricevuta di avvenuta%' Or C.OGGETTO LIKE 'Ricevuta di mancata consegna%')" +
  *              "))";
  *  }
  *  else if (this.rblFilter.SelectedValue == InteroperabilitaSemplificataManager.SimplifiedInteroperabilityId)
  *  {
  *      return " WHERE exists (" +
  *          "(SELECT 'x' FROM dpa_notifica dn WHERE dn.docnumber=" + SchedaDocumento.docNumber + " and dn.version_id=C.VERSION_ID)" +
  *          "UNION" +
  *          "(SELECT 'x' FROM dpa_notifica dn WHERE dn.docnumber=" + SchedaDocumento.docNumber + " and (C.OGGETTO LIKE 'Ricevuta di avvenuta%' OR C.OGGETTO LIKE 'Ricevuta di mancata consegna%'))" +
  *          ")";
  *  }
  *  else if(this.rblFilter.SelectedValue.Equals("esterni"))
  *  {
  *      return " WHERE exists (SELECT 'x' FROM VERSIONS v, Profile p WHERE v.CHA_ALLEGATI_ESTERNO = '1'  AND v.docnumber =c.docNumber) ";
  *  }
  *  else
  *  {
  *      return string.Empty;
  *  }
  * }
  */
 /// <summary>
 ///
 /// </summary>
 /// <param name="allegato"></param>
 /// <returns></returns>
 protected string GetCodiceAllegato(DocsPaWR.Allegato allegato)
 {
     return(allegato.versionLabel);
 }
Exemplo n.º 21
0
        /// <summary>
        /// Save Attachment
        /// </summary>
        protected virtual DocsPaWR.Allegato SaveAttachment()
        {
            Allegato                 attachment  = DocumentManager.GetSelectedAttachment();
            SchedaDocumento          documentTab = DocumentManager.getSelectedRecord();
            List <DocsPaWR.Allegato> attachments = new List <DocsPaWR.Allegato>(documentTab.allegati);

            if (attachment == null)
            {
                // Modalità di inserimento
                attachment                 = new DocsPaWR.Allegato();
                attachment.descrizione     = AttachmentDescription.Text;
                attachment.numeroPagine    = AttachmentPagesCount.Text.Length > 0 ? Convert.ToInt32(AttachmentPagesCount.Text) : 0;
                attachment.docNumber       = documentTab.docNumber;
                attachment.dataInserimento = DateTime.Today.ToString();
                attachment.version         = "1";
                attachment.TypeAttachment  = 1;
                string idPeopleDelegato = "0";
                if (UserManager.GetInfoUser().delegato != null)
                {
                    idPeopleDelegato = UserManager.GetInfoUser().delegato.idPeople;
                }
                attachment.idPeopleDelegato = idPeopleDelegato;

                // Impostazione del repositoryContext associato al documento
                attachment.repositoryContext = documentTab.repositoryContext;
                attachment.position          = (documentTab.allegati.Length + 1);
                if (attachment.version != null && attachment.version.Equals("0"))
                {
                    attachment.version = "1";
                }
                try
                {
                    attachment = DocumentManager.AddAttachment(attachment);
                }
                catch (NttDataWAException ex)
                {
                    throw new NttDataWAException(ex.Message, "");
                }
                //calcolo a runtime il versionLabel dell'allegato appena creato
                attachment.versionLabel = string.Format("A{0:0#}", DocumentManager.getSelectedRecord().allegati.Count() + 1);
                // Inserimento dell'allegato nella scheda documento
                attachments.Add(attachment);
                documentTab.allegati = attachments.ToArray();
                DocumentManager.setSelectedRecord(documentTab);
                // Aggiornamento grid index
                this.SelectedPage = (int)Math.Round((attachments.Count / this.PageSize) + 0.49);
            }
            else
            {
                // Modifica dati
                attachment.descrizione  = AttachmentDescription.Text;
                attachment.numeroPagine = AttachmentPagesCount.Text.Length > 0 ? Convert.ToInt32(AttachmentPagesCount.Text) : 0;
                documentTab.allegati    = attachments.ToArray();
                ProxyManager.GetWS().DocumentoModificaAllegato(UserManager.GetInfoUser(), attachment, documentTab.docNumber);
                if (documentTab != null && documentTab.systemId != null && !(documentTab.systemId.Equals(documentTab.systemId)))
                {
                    FileManager.removeSelectedFile();
                }
            }

            return(attachment);
        }
Exemplo n.º 22
0
        protected override string Upload(HttpPostedFile file, string fileName)
        {
            string       result = String.Empty;
            MemoryStream _ms    = null;

            try
            {
                SchedaDocumento          documentTab = DocumentManager.getSelectedRecord();
                List <DocsPaWR.Allegato> attachments = new List <DocsPaWR.Allegato>(documentTab.allegati);
                DocumentManager.setSelectedAttachId(null);
                Allegato attachment = new DocsPaWR.Allegato()
                {
                    descrizione       = Path.GetFileNameWithoutExtension(file.FileName), //file.FileName,
                    numeroPagine      = 1,
                    docNumber         = documentTab.docNumber,
                    dataInserimento   = DateTime.Today.ToString(),
                    version           = "1",
                    TypeAttachment    = 1,
                    idPeopleDelegato  = UserManager.GetInfoUser().delegato != null?UserManager.GetInfoUser().delegato.idPeople : "0",
                    repositoryContext = documentTab.repositoryContext,
                    position          = (documentTab.allegati.Length + 1)
                };

                attachment = DocumentManager.AddAttachment(attachment);
                attachment.versionLabel = string.Format("A{0:0#}", DocumentManager.getSelectedRecord().allegati.Count() + 1);

                attachments.Add(attachment);
                documentTab.allegati = attachments.ToArray();
                DocumentManager.setSelectedRecord(documentTab);

                System.Web.HttpContext.Current.Session["selectedAttachmentId"] = attachment.versionId;

                // aggiungi file all'allegato
                //FileRequest attachFileReq = FileManager.GetFileRequest(attachment.versionId);


                // File DOcumento...
                string path = this._context.Server.MapPath(@"Uploads");
                NttDataWA.DocsPaWR.FileDocumento fileDoc = new NttDataWA.DocsPaWR.FileDocumento();
                fileDoc.name        = fileName;
                fileDoc.fullName    = Path.Combine(path, fileName);
                fileDoc.contentType = NttDataWA.UIManager.FileManager.GetMimeType(fileName);
                fileDoc.length      = file.ContentLength;

                byte[] buffer = new byte[16 * 1024];
                _ms = new MemoryStream();

                int read;
                while ((read = file.InputStream.Read(buffer, 0, buffer.Length)) > 0)
                {
                    _ms.Write(buffer, 0, read);
                }
                fileDoc.content = _ms.ToArray();

                bool _pdf   = "1".Equals((string)System.Web.HttpContext.Current.Session["UploadMassivoConversionePDF"]);
                bool _paper = "1".Equals((string)System.Web.HttpContext.Current.Session["UploadMassivoCartaceo"]);
                bool _pdfConversionSynchronousLC = false;
                if (HttpContext.Current.Session["PdfConversionSynchronousLC"] != null)
                {
                    _pdfConversionSynchronousLC = (bool)HttpContext.Current.Session["PdfConversionSynchronousLC"];
                }

                result = FileManager.uploadFile(null, fileDoc, _paper, _pdf, _pdfConversionSynchronousLC);

                if (!String.IsNullOrWhiteSpace(result))
                {
                    // rimuove l'allegato ocreato
                    attachments.Remove(attachment);
                    bool resultRemove = DocumentManager.RemoveAttachment(1, 1, attachment);
                    DocumentManager.RemoveSelectedAttachId();
                    if (resultRemove)
                    {
                        documentTab.allegati = attachments.ToArray();
                        DocumentManager.setSelectedRecord(documentTab);
                    }
                }


                //if (String.IsNullOrWhiteSpace(documentTab.docNumber))
                //{
                //    var filereq = FileManager.uploadFile(null, fileDoc, false);
                //}
                //else
                //{
                //    error = FileManager.uploadFile(null, fileDoc, _paper, _pdf, _pdfConversionSynchronousLC);
                //}
            }
            catch (Exception ex)
            {
                result = ex.Message;
                _logger.Error(ex.Message, ex);
            }
            return(result);
        }
Exemplo n.º 23
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            try
            {
                Utils.startUp(this);
                this.ErrorPage = "";
                this.Button1.Attributes.Add("onclick", "window.close();");

                bool useHash = false;

                string signType = this.Request.QueryString["signType"];
                if (!String.IsNullOrEmpty(signType))
                {
                    if (signType == "P" || signType == "C")
                    {
                        useHash = true;
                    }
                }

                bool   coSign    = false;
                string cosignStr = this.Request.QueryString["tipoFirma"];
                if (!String.IsNullOrEmpty(cosignStr))
                {
                    if (cosignStr.ToLower().Equals("cosign"))
                    {
                        coSign = true;
                    }
                }

                if (Request.QueryString["tipofirma"] != null)
                {
                    if (!Request.QueryString["tipofirma"].Equals(""))
                    {
                        tipofirma = Request.QueryString["tipofirma"];
                    }
                }
                if (tipofirma.Equals("cosign"))
                {
                    firmabool = true;
                }
                else
                {
                    firmabool = false;
                }
                byte[] ba = Request.BinaryRead(Request.ContentLength);
                DocsPaWR.DocsPaWebService DocsPaWS = ProxyManager.getWS();
                DocsPaWR.FileDocumento    fd       = new DocsPAWA.DocsPaWR.FileDocumento();
                //fd.content=ba;

                ASCIIEncoding ae            = new ASCIIEncoding();
                string        base64content = ae.GetString(ba);

                if (UserManager.getBoolDocSalva(this) == null)
                {
                    if (!IsPostBack)
                    {
                        //	string prova=base64content.Replace(base64content.Substring(4,2),"Ds");
                        DocsPaWR.FileRequest fr = FileManager.getSelectedFile(this);

                        if (!string.IsNullOrEmpty(Request.QueryString["signedAsPdf"]))
                        {
                            // Se il file è in formato pdf, viene modificato il nome del file
                            bool signedAsPdf;
                            bool.TryParse(Request.QueryString["signedAsPdf"], out signedAsPdf);
                            if (signedAsPdf)
                            {
                                fr.fileName += ".pdf";
                            }
                        }

                        fr.dataInserimento = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");

                        if (fr.GetType().Equals(typeof(DocsPAWA.DocsPaWR.Allegato)))
                        {
                            // Creazione di un nuovo allegato per il file firmato
                            DocsPaWR.Allegato currentAllegato = (DocsPAWA.DocsPaWR.Allegato)fr;

                            DocsPaWR.Allegato newAllegato = new DocsPAWA.DocsPaWR.Allegato();
                            newAllegato.descrizione       = currentAllegato.descrizione;
                            newAllegato.numeroPagine      = currentAllegato.numeroPagine;
                            newAllegato.fileName          = fr.fileName;
                            newAllegato.firmatari         = currentAllegato.firmatari;
                            newAllegato.docNumber         = currentAllegato.docNumber;
                            newAllegato.version           = "0";
                            newAllegato.repositoryContext = DocumentManager.getDocumentoInLavorazione().repositoryContext;

                            fr = newAllegato;
                        }

                        bool retValue = false;
                        if (!useHash)
                        {
                            retValue = DocsPaWS.AppendDocumentoFirmato(base64content, firmabool, ref fr, UserManager.getInfoUtente(this));
                        }
                        else
                        {
                            bool pades = (signType == "P");
                            DocsPaWR.MassSignature msReq = new DocsPaWR.MassSignature {
                                fileRequest = fr, base64Signature = base64content, signPades = pades, cosign = coSign
                            };
                            DocsPaWR.MassSignature msRet = DocsPaWS.signDocument(msReq, UserManager.getInfoUtente(this));
                            retValue = msRet.result;
                        }

                        if (!retValue)
                        {
                            logger.Error("Errore nel Page_Load (docs = NULL)");
                            throw new Exception();
                        }

                        FileManager.setSelectedFile(this, fr);
                        DocsPaWR.SchedaDocumento schedaDocumento = DocumentManager.getDocumentoSelezionato(this);

                        if (fr.GetType().Equals(typeof(DocsPAWA.DocsPaWR.Allegato)))
                        {
                            schedaDocumento.allegati = DocumentManager.addAllegato(schedaDocumento.allegati, (DocsPAWA.DocsPaWR.Allegato)fr);
                        }
                        else
                        {
                            schedaDocumento.documenti = DocumentManager.addVersione(schedaDocumento.documenti, (DocsPAWA.DocsPaWR.Documento)fr);
                        }

                        DocumentManager.setDocumentoSelezionato(this, schedaDocumento);
                        UserManager.setBoolDocSalva(this, "salvato");
                    }
                }
            }
            catch (Exception es)
            {
                ErrorManager.setError(this, es);
            }
        }
Exemplo n.º 24
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            bool   retValue      = false;
            bool   isContent     = false;
            bool   issocket      = false;
            string idDocument    = string.Empty;
            string base64content = string.Empty;

            // Put user code to initialize the page here
            try
            {
                this.startUp();
                this.ErrorPage = "";
                if (Request.QueryString["tipofirma"] != null)
                {
                    if (!Request.QueryString["tipofirma"].Equals(""))
                    {
                        tipofirma = Request.QueryString["tipofirma"];
                    }
                }
                if (tipofirma.Equals("cosign"))
                {
                    firmabool = true;
                }
                else
                {
                    firmabool = false;
                }


                if (Request.QueryString["iscontent"] != null)
                {
                    bool.TryParse(Request.QueryString["iscontent"], out isContent);
                }

                if (Request.QueryString["issocket"] != null)
                {
                    bool.TryParse(Request.QueryString["issocket"], out issocket);
                }

                if (Request.QueryString["idDocumento"] != null)
                {
                    idDocument = Request.QueryString["idDocumento"].ToString();
                }

                byte[] ba = null;

                if (!issocket)
                {
                    ba = Request.BinaryRead(Request.ContentLength);
                }
                else
                {
                    string contentFile = Request["contentFile"];
                    //Stream stream=Request.InputStream;
                    if (!String.IsNullOrEmpty(contentFile))
                    {
                        contentFile = contentFile.Replace(' ', '+');
                        contentFile = contentFile.Trim();
                        NttDataWA.Utils.FileJSON file = JsonConvert.DeserializeObject <NttDataWA.Utils.FileJSON>(contentFile);
                        ba = Convert.FromBase64String(file.content);
                    }
                }
                DocsPaWR.DocsPaWebService DocsPaWS = ProxyManager.GetWS();
                DocsPaWR.FileDocumento    fd       = new NttDataWA.DocsPaWR.FileDocumento();
                //fd.content=ba;

                ASCIIEncoding ae = new ASCIIEncoding();
                if (!isContent)
                {
                    base64content = ae.GetString(ba);
                }

                if (UIManager.UserManager.getBoolDocSalva(this) == null)
                {
                    if (!IsPostBack)
                    {
                        //	string prova=base64content.Replace(base64content.Substring(4,2),"Ds");
                        FileRequest fr = null;
                        DocsPaWR.SchedaDocumento schedaDocumento = null;

                        if (string.IsNullOrEmpty(idDocument))
                        {
                            fr = UIManager.FileManager.getSelectedFile();
                        }
                        else
                        {
                            fr = UIManager.FileManager.getSelectedMassSignature(idDocument).fileRequest;
                            FirmaDigitaleMng mmg = new FirmaDigitaleMng();
                            schedaDocumento = mmg.GetSchedaDocumento(idDocument);
                        }

                        if (!string.IsNullOrEmpty(Request.QueryString["signedAsPdf"]))
                        {
                            // Se il file è in formato pdf, viene modificato il nome del file
                            bool signedAsPdf;
                            bool.TryParse(Request.QueryString["signedAsPdf"], out signedAsPdf);
                            if (signedAsPdf)
                            {
                                fr.fileName += ".PdF_convertito"; //SERVE PER IL BACKEND NON MODIFICARLO!!!
                            }
                        }

                        fr.dataInserimento = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");

                        if (fr.GetType().Equals(typeof(DocsPaWR.Allegato)))
                        {
                            // Creazione di un nuovo allegato per il file firmato
                            DocsPaWR.Allegato currentAllegato = (DocsPaWR.Allegato)fr;

                            DocsPaWR.Allegato newAllegato = new DocsPaWR.Allegato();
                            newAllegato.descrizione       = currentAllegato.descrizione;
                            newAllegato.numeroPagine      = currentAllegato.numeroPagine;
                            newAllegato.fileName          = fr.fileName;
                            newAllegato.firmatari         = currentAllegato.firmatari;
                            newAllegato.docNumber         = currentAllegato.docNumber;
                            newAllegato.version           = "0";
                            newAllegato.cartaceo          = false;
                            newAllegato.repositoryContext = UIManager.DocumentManager.GetSelectedAttachment().repositoryContext;

                            fr = newAllegato;
                        }

                        if (isContent)
                        {
                            retValue = DocsPaWS.AppendContentFirmato(ba, firmabool, ref fr, UIManager.UserManager.GetInfoUser());
                        }
                        else
                        {
                            retValue = DocsPaWS.AppendDocumentoFirmato(base64content, firmabool, ref fr, UIManager.UserManager.GetInfoUser());
                        }

                        if (!retValue)
                        {
                            throw new Exception();
                        }

                        UIManager.FileManager.setSelectedFile(fr);
                        if (schedaDocumento == null)
                        {
                            schedaDocumento = UIManager.DocumentManager.getSelectedRecord();
                        }

                        List <DocsPaWR.Allegato> attachments = new List <DocsPaWR.Allegato>(schedaDocumento.allegati);

                        if (UIManager.DocumentManager.getSelectedAttachId() != null)
                        {
                            //attachments.Add((Allegato)fr);
                            //schedaDocumento.allegati = attachments.ToArray();
                            int      index = schedaDocumento.allegati.Select((item, i) => new { obj = item, index = i }).First(item => item.obj.versionId.Equals(UIManager.DocumentManager.GetSelectedAttachment().versionId)).index;
                            Allegato a     = new Allegato();
                            a.applicazione          = fr.applicazione;
                            a.daAggiornareFirmatari = fr.daAggiornareFirmatari;
                            a.dataInserimento       = fr.dataInserimento;
                            a.descrizione           = fr.descrizione;
                            a.docNumber             = fr.docNumber;
                            a.docServerLoc          = fr.docServerLoc;
                            a.fileName          = fr.fileName;
                            a.fileSize          = fr.fileSize;
                            a.firmatari         = fr.firmatari;
                            a.firmato           = fr.firmato;
                            a.idPeople          = fr.idPeople;
                            a.path              = fr.path;
                            a.subVersion        = fr.version;
                            a.version           = fr.version;
                            a.versionId         = fr.versionId;
                            a.versionLabel      = schedaDocumento.allegati[index].versionLabel;
                            a.cartaceo          = fr.cartaceo;
                            a.repositoryContext = fr.repositoryContext;
                            a.TypeAttachment    = 1;
                            //a.numeroPagine = (fr as Allegato).numeroPagine;
                            // modifica necessaria per FILENET (A.B.)
                            if ((fr.fNversionId != null) && (fr.fNversionId != ""))
                            {
                                a.fNversionId = fr.fNversionId;
                            }
                            schedaDocumento.allegati[index] = a;

                            UIManager.DocumentManager.setSelectedAttachId(fr.versionId);
                            UIManager.DocumentManager.setSelectedNumberVersion(a.version);
                            //schedaDocumento.allegati = UIManager.DocumentManager.AddAttachment((Allegato)fr);
                        }
                        else
                        {
                            //fr = UIManager.DocumentManager.AddVersion(fr, false);
                            schedaDocumento.documenti = UIManager.DocumentManager.addVersion(schedaDocumento.documenti, (Documento)fr);
                            UIManager.DocumentManager.setSelectedNumberVersion(fr.version);
                        }

                        UIManager.DocumentManager.setSelectedRecord(schedaDocumento);
                        UIManager.UserManager.setBoolDocSalva(this, "salvato");
                    }
                }
            }
            catch (Exception es)
            {
                ErrorManager.setError(this, es);
            }
        }