예제 #1
0
        /// <summary>
        /// Reperimento proprietà allegato
        /// </summary>
        /// <param name="allegato"></param>
        /// <param name="infoUtente"></param>
        /// <returns></returns>
        public static CorteContentServices.CategoryType[] getAttachmentProperties(Allegato allegato, InfoUtente infoUtente)
        {
            List <MetadataType> metaDataList = new List <MetadataType>();

            metaDataList.Add(OCSUtils.getMetadataItem(DocsPaObjectType.TypeDocumentoAllegato.AUTORE, infoUtente.userId));
            metaDataList.Add(OCSUtils.getMetadataItem(DocsPaObjectType.TypeDocumentoAllegato.DOC_NUMBER, DocsPaServices.DocsPaQueryHelper.getDocNumberDocumentoPrincipale(allegato.docNumber)));
            metaDataList.Add(OCSUtils.getMetadataItem(DocsPaObjectType.TypeDocumentoAllegato.ATTACHID, allegato.docNumber));
            metaDataList.Add(OCSUtils.getMetadataItem(DocsPaObjectType.TypeDocumentoAllegato.DESCRIZIONE, allegato.descrizione));
            metaDataList.Add(OCSUtils.getMetadataItem(DocsPaObjectType.TypeDocumentoAllegato.NUM_PAGINE, allegato.numeroPagine.ToString()));

            if (!string.IsNullOrEmpty(allegato.versionLabel))
            {
                metaDataList.Add(OCSUtils.getMetadataItem(DocsPaObjectType.TypeDocumentoAllegato.CODICE, allegato.versionLabel.ToString()));
            }

            List <CategoryType> retValue = new List <CategoryType>();

            CategoryType categoryType = new CategoryType();

            categoryType.name         = DocsPaObjectType.ObjectTypes.CATEGOTY_ALLEGATO;
            categoryType.metadataList = metaDataList.ToArray();
            retValue.Add(categoryType);

            return(retValue.ToArray());
        }
예제 #2
0
        /// <summary>
        /// Metodo per l'aggiunta dell'allegato al documento spedito
        /// </summary>
        /// <param name="documentId">Id del documento a aggiungere l'allegato</param>
        /// <param name="recData">Contenuto della ricevuta</param>
        /// <param name="userInfo">Informazioni sull'utente da utilizzare per l'aggiunta dell'allegato</param>
        /// <param name="messageId">Identificativo del messaggio</param>
        /// <param name="proofDate">Data di generazione della ricevuta</param>
        /// <param name="receiverCode">Codice del destinatario che ha generato la mancata consegna</param>
        /// <param name="senderUrl">Url del mittente</param>
        private static void AddAttachmentToDocument(String documentId, byte[] recData, InfoUtente userInfo, String messageId, DateTime proofDate, String receiverCode, String senderUrl)
        {
            // Creazione dell'oggetto allegato
            Allegato a = new Allegato();

            // Impostazione delle proprietà dell'allegato
            a.descrizione = String.Format("Ricevuta di mancata consegna - " + receiverCode);

            a.docNumber      = documentId;
            a.version        = "0";
            a.numeroPagine   = 1;
            a.TypeAttachment = 3;
            try
            {
                // Aggiunta dell'allegato al documento principale
                a = AllegatiManager.aggiungiAllegato(userInfo, a);

                // Set del flag in CHA_ALLEGATI_ESTERNO in Versions
                BusinessLogic.Documenti.AllegatiManager.setFlagAllegati_PEC_IS_EXT(a.versionId, a.docNumber, "I");

                // Associazione dell'immagine all'allegato
                FileDocumento fileDocument = new FileDocumento()
                {
                    content = recData, length = recData.Length, name = "MancataConsegna.pdf"
                };
                FileRequest request = a as FileRequest;
                String      err;
                FileManager.putFileRicevuteIs(ref request, fileDocument, userInfo, out err);

                // Aggiunta della notifica alla tabella delle notifiche
                SaveProofInRegistry(a, messageId, receiverCode, senderUrl, proofDate, documentId);


                if (!String.IsNullOrEmpty(err))
                {
                    SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(documentId, true,
                                                                                    String.Format("Errore durante l'associazione della ricevuta di mancata consegna al documento"));
                }
                else
                {
                    SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(documentId, false,
                                                                                    String.Format("Ricevuta di mancata consegna associata correttamente al documento"));
                }
            }
            catch (Exception e)
            {
                string message = e.Message + " " + e.StackTrace;
                message = message.Length > 3700 ? message.Substring(0, 3700) : message;
                SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(documentId, true,
                                                                                String.Format("Errore durante l'aggiunta dell'allegato con la ricevuta di mancata consegna al documento " + documentId + " : " + message));
            }
        }
예제 #3
0
        /// <summary>
        /// Funzione per la creazione dell'allegato
        /// </summary>
        /// <param name="rowData">L'oggetto con le informazioni sull'allegato da creare</param>
        /// <param name="userInfo">Le informazioni sull'utente che ha lanciato la procedura</param>
        /// <param name="role">Il ruolo con cui è stata lanciata la procedura</param>
        /// <param name="identificationData">I dati identificativi dell'allegato</param>
        /// <param name="sharedDirectoryPath">Il path i cui è posizionato il file da allegare al documento</param>
        /// <param name="importResults">L'oggetto con le informazioni sul documento cui si desidera aggiungere l'allegato</param>
        protected void CreateDocument(DocumentRowData rowData, InfoUtente userInfo, Ruolo role, out string identificationData, string ftpAddress, ImportResult importResults, String ftpUsername, String ftpPassword)
        {
            #region Dichiarazione variabili

            // L'allegato da agggiungere
            Allegato attachment = null;

            #endregion

            // Se il documento non è stato creato, eccezione
            if (String.IsNullOrEmpty(importResults.DocNumber))
            {
                throw new Exception("Il documento cui si desidera aggiungere un allegato non è stato creato con successo.");
            }

            // Creazione dell'oggetto Allegato
            attachment = this.CreateAttachmentObject(
                rowData.Obj,
                importResults.DocNumber);

            // Aggiunta dell'allegato al documento
            try
            {
                AllegatiManager.aggiungiAllegato(userInfo, attachment);
            }
            catch
            {
                throw new Exception("Errore durante l'aggiunta dell'allegato al documento specificato.");
            }

            // Acquisizione del file (se specificato il path)
            if (!String.IsNullOrEmpty(rowData.Pathname))
            {
                this.AcquireFile(
                    rowData.Pathname,
                    rowData.AdminCode,
                    userInfo,
                    ftpAddress,
                    attachment,
                    ftpUsername,
                    ftpPassword,
                    rowData);
            }



            // Impostazione delle informazioni sull'allegato creato
            identificationData = String.Format(
                "Id documento: {0}",
                attachment.docNumber);
        }
예제 #4
0
        private void ImpostaSchedaLavorazione()
        {
            string CodArt, Allegato;

            CodArt = codArticoloTextBox.Text;
            DataRow[] riga;
            riga = target2021DataSet.Tables["DettArticoli"].Select("codice_articolo='" + CodArt + "' AND lavorazione=2");
            try
            {
                Allegato      = Convert.ToString(riga[0]["Allegato"]);
                textBox5.Text = Allegato.ToString();
            }
            catch { textBox5.Text = "Scheda non trovata"; }
        }
예제 #5
0
        /// <summary>
        /// Funzione per la creazione dell'oggetto Allegato con le informazioni sull'allegato
        /// da creare
        /// </summary>
        /// <param name="description">La descrizione dell'allegato</param>
        /// <param name="docNumber">Il doc number del documento principale</param>
        /// <returns>L'oggetto con le informazioni sull'allegato creato</returns>
        private Allegato CreateAttachmentObject(string description, string docNumber)
        {
            // L'oggetto da restituire
            Allegato toReturn;

            // Creazione dell'allegato
            toReturn = new Allegato();

            // Impostazione della descrizione dell'allegato
            toReturn.descrizione = description;

            // Impostazione del docNumber
            toReturn.docNumber = docNumber;

            // Restituzione dell'oggetto creato
            return(toReturn);
        }
예제 #6
0
        /// <summary>
        /// Metodo per inserire la ricevuta nel registro delle ricevute
        /// </summary>
        /// <param name="attachment">Allegato da aggiungere</param>
        /// <param name="messageId">Identificativo del messaggio di interoperabilità</param>
        /// <param name="receiverCode">Codice del destinatario per cui è stata generata la ricevuta</param>
        /// <param name="senderUrl">Url del mittente della spedizione</param>
        /// <param name="proofDate">Data di generazione della ricevuta</param>
        /// <param name="documentId">Id del documento cui aggiungere l'allegato</param>
        private static void SaveProofInRegistry(Allegato attachment, String messageId, String receiverCode, String senderUrl, DateTime proofDate, String documentId)
        {
            TipoNotifica not = InteroperabilitaManager.ricercaTipoNotificaByCodice("avvenuta-consegna");

            InteroperabilitaManager.inserimentoNotifica(
                new DocsPaVO.DatiCert.Notifica()
                {
                    consegna = "1",
                    data_ora = proofDate.ToString("dd/MM/yyyy HH:mm:ss"),
                    destinatario = receiverCode,
                    docnumber = documentId,
                    idTipoNotifica = not.idTipoNotifica,
                    mittente = senderUrl,
                    msgid = messageId,
                    risposte = String.Empty,
                    oggetto = "Ricevuta di avvenuta consegna"
                },
                attachment.versionId);
        }
예제 #7
0
        /// <summary>
        /// Save Version
        /// </summary>
        protected virtual string SaveVersion()
        {
            // Modalità di inserimento
            Allegato    a       = new Allegato();
            Documento   docMain = new Documento();
            FileRequest fileReq;

            //add a version attached
            if (DocumentManager.getSelectedAttachId() != null)
            {
                a.descrizione = this.VersionDescription.Text;
                a.docNumber   = FileManager.GetFileRequest(DocumentManager.getSelectedAttachId()).docNumber;
                var obj = FileManager.GetFileRequest(DocumentManager.getSelectedAttachId()) as Allegato;
                if (obj != null)
                {
                    a.numeroPagine = obj.numeroPagine;
                }
                fileReq = a;
            }
            else //add a version doc main
            {
                docMain.docNumber   = FileManager.GetFileRequest().docNumber;
                docMain.descrizione = this.VersionDescription.Text;
                //parte relativa alla data arrivo
                //SchedaDocumento doc = DocumentManager.getDocumentDetails(this.Page, docMain.docNumber, docMain.docNumber);
                SchedaDocumento doc = DocumentManager.getSelectedRecord();
                docMain.dataArrivo = doc.documenti[doc.documenti.Length - 1].dataArrivo;
                fileReq            = docMain;
            }

            try
            {
                bool toSend = true;
                fileReq = DocumentManager.AddVersion(fileReq, toSend);
                //ABBATANGELI - evita errore addVersion subito dopo upload da repository
                Session["fileDoc"] = null;
                return(fileReq.version);
            }
            catch (NttDataWAException ex)
            {
                throw new NttDataWAException(ex.Message, "");
            }
        }
예제 #8
0
        private static SchedaDocumento CreateSchedaDocumentoFromAttestato(AttestatoVO att, InfoUtente infoUtente, Ruolo ruolo, string idRegistro)
        {
            SchedaDocumento sd  = DocManager.NewSchedaDocumento(infoUtente);
            Oggetto         ogg = new Oggetto();

            ogg.idRegistro  = idRegistro;
            ogg.descrizione = att.Oggetto;
            sd.oggetto      = ogg;
            // Impostazione del registro
            sd.registro = RegistriManager.getRegistro(idRegistro);
            // Impostazione del tipo atto
            sd.tipoProto                 = "";
            sd.template                  = ProfilazioneDocumenti.getTemplateById(att.IdTemplate);
            sd.tipologiaAtto             = new TipologiaAtto();
            sd.tipologiaAtto.descrizione = sd.template.DESCRIZIONE;
            sd.tipologiaAtto.systemId    = sd.template.SYSTEM_ID.ToString();
            sd.daAggiornareTipoAtto      = true;
            sd = DocSave.addDocGrigia(sd, infoUtente, ruolo);
            Allegato all = new Allegato();

            all.descrizione = "ALL1";
            all.docNumber   = sd.docNumber;
            all.version     = "0";
            string idPeopleDelegato = "0";

            if (infoUtente.delegato != null)
            {
                idPeopleDelegato = infoUtente.delegato.idPeople;
            }
            all.idPeopleDelegato = idPeopleDelegato;

            // Impostazione del repositoryContext associato al documento
            all.repositoryContext = sd.repositoryContext;
            all.position          = 1;
            Allegato resAll = AllegatiManager.aggiungiAllegato(infoUtente, all);

            sd.allegati = new ArrayList();
            sd.allegati.Add(resAll);
            return(sd);
        }
예제 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static ValidationResultInfo UndoCheckOutDocument()
        {
            ValidationResultInfo retValue = null;

            if (IsSelectedTabAllegati())
            {
                Allegato tempAll = UIManager.DocumentManager.GetSelectedAttachment();
                if (tempAll != null)
                {
                    CheckOutStatus checkOutStatus = UIManager.DocumentManager.GetCheckOutDocumentStatus(UIManager.DocumentManager.GetSelectedAttachment().docNumber);
                    retValue = _webServices.UndoCheckOutDocument(checkOutStatus, GetInfoUtente());
                }
            }
            else
            {
                if (CheckOutAppletContext.Current != null && CheckOutAppletContext.Current.Status != null)
                {
                    CheckOutStatus checkOutStatus = CheckOutAppletContext.Current.Status;

                    retValue = _webServices.UndoCheckOutDocument(checkOutStatus, GetInfoUtente());

                    if (retValue.Value)
                    {
                        CheckOutAppletContext.Current = null;
                    }
                }
                else
                {
                    retValue             = new ValidationResultInfo();
                    retValue.Value       = true;
                    retValue.BrokenRules = new BrokenRule[0];
                }
            }

            return(retValue);
        }
예제 #10
0
        public Allegato Create(Stream stream, string fileName, string idPadre, string tipoPadre)
        {
            var extension = Path.GetExtension(fileName);
            var nomeFile = Path.GetFileName(fileName);
            if (!string.IsNullOrEmpty(extension))
                nomeFile = nomeFile.Replace(extension, "");

            nomeFile = nomeFile.Length > 100 ? nomeFile.Substring(0, 100) : nomeFile;

            var docToSave = new Allegato
            {
                Descrizione = nomeFile,
                Estensione = extension,
                IDPadre = idPadre,
                TipoPadre = tipoPadre
            };

            _repositoryAllegati.SaveOrUpdate(docToSave);

            using (var ms = new MemoryStream())
            {
                stream.CopyTo(ms);

                _fileBlobManager.Set(new Blob
                {
                    Name = AttachmentHelper.BuildFileName(docToSave), //salva su azure con nome file = ID.estensione
                    MimeType = AttachmentHelper.GetExtensionMimeType(extension),
                    Data = ms.ToArray(),
                });
            }

            return docToSave;
        }
예제 #11
0
 public CheckOutAppletContext(Allegato allegato)
 {
     this._allegato = allegato;
 }
예제 #12
0
 /// <summary>
 /// Verifica se un allegato risulta acquisito o meno
 /// </summary>
 /// <param name="allegato"></param>
 /// <returns></returns>
 public bool IsAcquired(Allegato allegato)
 {
     return(allegato.fileName != null && allegato.fileName != string.Empty &&
            allegato.fileSize != null && allegato.fileSize != "0");
 }
예제 #13
0
        protected void SignatureSelectedItemsConfirm_Click(object sender, EventArgs e)
        {
            bool noDigitalSign = true;

            try
            {
                ReportSignatureSelected = new MassiveOperationReport();
                //MassiveOperationReport report = new MassiveOperationReport();
                MassiveOperationUtils.ItemsStatus = null;
                MassiveOperationReport.MassiveOperationResultEnum result;
                string             oggetto = string.Empty;
                string             details;
                string             popupCall     = string.Empty;
                List <FileRequest> fileReqToSign = new List <FileRequest>();
                this.ListIdDocumentSigned = new List <string>();
                Allegato  attach;
                Documento doc;

                #region AVANZAMENTO ITER
                List <ElementoInLibroFirma> listElementAdvancementProcess = (from i in this.ListaElementiLibroFirma
                                                                             where i.TipoFirma.Equals(LibroFirmaManager.TypeEvent.ADVANCEMENT_PROCESS) && i.StatoFirma.Equals(TipoStatoElemento.DA_FIRMARE)
                                                                             select i).ToList();
                if (listElementAdvancementProcess != null && listElementAdvancementProcess.Count > 0)
                {
                    foreach (ElementoInLibroFirma element in listElementAdvancementProcess)
                    {
                        if (string.IsNullOrEmpty(element.InfoDocumento.IdDocumentoPrincipale))
                        {
                            doc = new Documento()
                            {
                                descrizione  = element.InfoDocumento.Oggetto,
                                docNumber    = element.InfoDocumento.Docnumber,
                                versionId    = element.InfoDocumento.VersionId,
                                version      = element.InfoDocumento.NumVersione.ToString(),
                                versionLabel = element.InfoDocumento.NumAllegato.ToString(),
                                inLibroFirma = true
                            };
                            fileReqToSign.Add(doc as FileRequest);
                        }
                        else
                        {
                            attach = new Allegato()
                            {
                                descrizione  = element.InfoDocumento.Oggetto,
                                docNumber    = element.InfoDocumento.Docnumber,
                                versionId    = element.InfoDocumento.VersionId,
                                version      = element.InfoDocumento.NumVersione.ToString(),
                                versionLabel = element.InfoDocumento.NumAllegato.ToString(),
                                inLibroFirma = true
                            };
                            fileReqToSign.Add(attach as FileRequest);
                        }
                    }
                    bool isAdvancementProcess      = true;
                    List <FirmaResult> firmaResult = LibroFirmaManager.PutElectronicSignatureMassive(fileReqToSign, isAdvancementProcess);

                    if (firmaResult != null)
                    {
                        foreach (FirmaResult r in firmaResult)
                        {
                            if (string.IsNullOrEmpty(r.errore))
                            {
                                result  = MassiveOperationReport.MassiveOperationResultEnum.OK;
                                details = "Avanzamento iter avvenuto con successo";
                                oggetto = r.fileRequest.descrizione;
                                ReportSignatureSelected.AddReportRow(
                                    oggetto,
                                    result,
                                    details);
                                ListIdDocumentSigned.Add(r.fileRequest.docNumber);
                            }
                            else
                            {
                                result  = MassiveOperationReport.MassiveOperationResultEnum.KO;
                                oggetto = r.fileRequest.descrizione;
                                details = String.Format(
                                    "Si sono verificati degli errori durante la procedura di avanzamento. {0}",
                                    r.errore);
                                ReportSignatureSelected.AddReportRow(
                                    oggetto,
                                    result,
                                    details);
                            }
                        }
                    }
                }
                #endregion

                #region SOTTOSCRIZIONE

                fileReqToSign.Clear();
                List <ElementoInLibroFirma> listElementSubscription = (from i in this.ListaElementiLibroFirma
                                                                       where i.TipoFirma.Equals(LibroFirmaManager.TypeEvent.VERIFIED) && i.StatoFirma.Equals(TipoStatoElemento.DA_FIRMARE)
                                                                       select i).ToList();
                if (listElementSubscription != null && listElementSubscription.Count > 0)
                {
                    foreach (ElementoInLibroFirma element in listElementSubscription)
                    {
                        if (string.IsNullOrEmpty(element.InfoDocumento.IdDocumentoPrincipale))
                        {
                            doc = new Documento()
                            {
                                descrizione  = element.InfoDocumento.Oggetto,
                                docNumber    = element.InfoDocumento.Docnumber,
                                versionId    = element.InfoDocumento.VersionId,
                                version      = element.InfoDocumento.NumVersione.ToString(),
                                versionLabel = element.InfoDocumento.NumAllegato.ToString(),
                                tipoFirma    = element.TipoFirmaFile,
                                inLibroFirma = true
                            };
                            fileReqToSign.Add(doc as FileRequest);
                        }
                        else
                        {
                            attach = new Allegato()
                            {
                                descrizione  = element.InfoDocumento.Oggetto,
                                docNumber    = element.InfoDocumento.Docnumber,
                                versionId    = element.InfoDocumento.VersionId,
                                version      = element.InfoDocumento.NumVersione.ToString(),
                                versionLabel = element.InfoDocumento.NumAllegato.ToString(),
                                tipoFirma    = element.TipoFirmaFile,
                                inLibroFirma = true
                            };
                            fileReqToSign.Add(attach as FileRequest);
                        }
                    }
                    bool isAdvancementProcess      = false;
                    List <FirmaResult> firmaResult = LibroFirmaManager.PutElectronicSignatureMassive(fileReqToSign, isAdvancementProcess);

                    if (firmaResult != null)
                    {
                        foreach (FirmaResult r in firmaResult)
                        {
                            if (string.IsNullOrEmpty(r.errore))
                            {
                                result  = MassiveOperationReport.MassiveOperationResultEnum.OK;
                                details = "Sottoscrizione avvenuta con successo";
                                oggetto = r.fileRequest.descrizione;
                                ReportSignatureSelected.AddReportRow(
                                    oggetto,
                                    result,
                                    details);
                                ListIdDocumentSigned.Add(r.fileRequest.docNumber);
                            }
                            else
                            {
                                result  = MassiveOperationReport.MassiveOperationResultEnum.KO;
                                oggetto = r.fileRequest.descrizione;
                                details = String.Format(
                                    "Si sono verificati degli errori durante la procedura di sottoscrizione. {0}",
                                    r.errore);
                                ReportSignatureSelected.AddReportRow(
                                    oggetto,
                                    result,
                                    details);
                            }
                        }
                    }
                }

                #endregion

                #region DIGITALE
                ListCheck  = new Dictionary <String, String>();
                ListToSign = new Dictionary <string, FileToSign>();

                //FIRMA PADES
                fileReqToSign.Clear();
                List <ElementoInLibroFirma> listElementSignPADES = (from i in this.ListaElementiLibroFirma
                                                                    where i.TipoFirma.Equals(LibroFirmaManager.TypeEvent.SIGN_PADES) && i.StatoFirma.Equals(TipoStatoElemento.DA_FIRMARE)
                                                                    select i).ToList();
                string     idDocumento    = null;
                string     fileExstention = "PDF";
                FileToSign file           = null;
                String     isFirmato      = null;
                String     signType       = null;

                if (listElementSignPADES != null && listElementSignPADES.Count > 0)
                {
                    noDigitalSign = false;
                    foreach (ElementoInLibroFirma element in listElementSignPADES)
                    {
                        idDocumento = "P" + element.InfoDocumento.Docnumber;
                        ListCheck.Add(idDocumento, idDocumento);
                        isFirmato = element != null ? element.FileOriginaleFirmato : "0";
                        signType  = element != null ? element.TipoFirmaFile : TipoFirma.NESSUNA_FIRMA;
                        if (this.ListToSign != null)
                        {
                            if (!this.ListToSign.ContainsKey(idDocumento))
                            {
                                file = new FileToSign(fileExstention, isFirmato, signType);
                                this.ListToSign.Add(idDocumento, file);
                            }
                            else
                            {
                                file               = this.ListToSign[idDocumento];
                                file.signed        = isFirmato;
                                file.fileExtension = fileExstention;
                            }
                        }
                    }
                }

                //FIRMA CADES
                fileReqToSign.Clear();
                List <ElementoInLibroFirma> listElementSignCADES = (from i in this.ListaElementiLibroFirma
                                                                    where i.TipoFirma.Equals(LibroFirmaManager.TypeEvent.SIGN_CADES) && i.StatoFirma.Equals(TipoStatoElemento.DA_FIRMARE)
                                                                    select i).ToList();
                if (listElementSignCADES != null && listElementSignCADES.Count > 0)
                {
                    noDigitalSign = false;
                    foreach (ElementoInLibroFirma element in listElementSignCADES)
                    {
                        idDocumento = "C" + element.InfoDocumento.Docnumber;
                        ListCheck.Add(idDocumento, idDocumento);
                        isFirmato = element != null ? element.FileOriginaleFirmato : "0";
                        signType  = element != null ? element.TipoFirmaFile : TipoFirma.NESSUNA_FIRMA;
                        if (this.ListToSign != null)
                        {
                            if (!this.ListToSign.ContainsKey(idDocumento))
                            {
                                isFirmato = element != null ? element.FileOriginaleFirmato : "0";
                                file      = new FileToSign(fileExstention, isFirmato, signType);
                                this.ListToSign.Add(idDocumento, file);
                            }
                            else
                            {
                                file               = this.ListToSign[idDocumento];
                                file.signed        = isFirmato;
                                file.fileExtension = fileExstention;
                                file.signType      = signType;
                            }
                        }
                    }
                }

                #endregion

                if (noDigitalSign)
                {
                    DigitalSignatureSelectedItem();
                }
                else
                {
                    switch (tipoSupportoFirma)
                    {
                    case "H":
                        HttpContext.Current.Session["CommandType"] = null;
                        popupCall = "ajaxModalPopupMassiveSignatureHSM();";
                        break;

                    case "L":
                        componentType = UserManager.getComponentType(Request.UserAgent);
                        if (componentType == Constans.TYPE_ACTIVEX || componentType == Constans.TYPE_SMARTCLIENT)
                        {
                            popupCall = "ajaxModalPopupMassiveDigitalSignature();";
                        }
                        else if (componentType == Constans.TYPE_APPLET)
                        {
                            HttpContext.Current.Session["CommandType"] = null;
                            popupCall = "ajaxModalPopupMassiveDigitalSignatureApplet();";
                        }
                        else if (componentType == Constans.TYPE_SOCKET)
                        {
                            HttpContext.Current.Session["CommandType"] = null;
                            popupCall = "ajaxModalPopupMassiveDigitalSignatureSocket();";
                        }
                        break;
                    }
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "MassiveSignatureHSM", popupCall, true);
                }
            }
            catch (System.Exception ex)
            {
                UIManager.AdministrationManager.DiagnosticError(ex);
                return;
            }
        }
예제 #14
0
 private static void RemoveFromCloudRepositoryInternal(IFileBlobManager manager, Allegato allegato)
 {
     manager.Remove(BuildFileName(allegato));
 }
예제 #15
0
 public static void RemoveFromCloudRepository(Allegato allegato)
 {
     AbsContainer.Using<IFileBlobManager>(el => RemoveFromCloudRepositoryInternal(el, allegato));
 }
예제 #16
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);
            }
        }
예제 #17
0
        public bool ManageAttachXML_Suap(ref DocsPaVO.documento.SchedaDocumento schedaDocOriginale, DocsPaVO.utente.InfoUtente infoUtenteInterop, string mailFrom)
        {
            if (schedaDocOriginale.template == null)
            {
                return(false);
            }

            if (schedaDocOriginale.template.DESCRIZIONE.ToUpper() != "ENTESUAP")
            {
                return(false);
            }

            XmlParsing.suap.SuapManager sm = new XmlParsing.suap.SuapManager("ENTESUAP");

            //refresh
            DocsPaVO.documento.SchedaDocumento schedaDoc = BusinessLogic.Documenti.DocManager.getDettaglio(infoUtenteInterop, schedaDocOriginale.docNumber, schedaDocOriginale.docNumber);

            string xmlResult = sm.ExportEnteSuapXML(infoUtenteInterop, schedaDoc, mailFrom);

            if (String.IsNullOrEmpty(xmlResult))
            {
                return(false);
            }



            Allegato allEntesuap = null;


            foreach (Allegato all in schedaDoc.allegati)
            {
                string originalName = BusinessLogic.Documenti.FileManager.getOriginalFileName(infoUtenteInterop, all);
                if ((originalName != null) && (originalName.ToLowerInvariant().Equals("entesuap.xml")))
                {
                    allEntesuap = all;
                    break;
                }
            }

            //Add del File xml come filedocumento:
            DocsPaVO.documento.FileDocumento fdAllNew = new DocsPaVO.documento.FileDocumento();
            fdAllNew.content     = Encoding.UTF8.GetBytes(xmlResult);
            fdAllNew.length      = fdAllNew.content.Length;
            fdAllNew.name        = "ENTESUAP.XML";
            fdAllNew.fullName    = fdAllNew.name;
            fdAllNew.contentType = "text/xml";
            string err;

            if (allEntesuap != null)
            {
                FileDocumento fd     = BusinessLogic.Documenti.FileManager.getFile(allEntesuap, infoUtenteInterop);
                string        xmlAll = System.Text.ASCIIEncoding.ASCII.GetString(fd.content);
                //
                if (XmlParsing.suap.SuapManager.compareEnteSuapXml(xmlAll, xmlResult))
                {
                    return(true);
                }
                else
                {
                    FileRequest fileReq = new Documento();
                    fileReq.docNumber   = allEntesuap.docNumber;
                    fileReq.descrizione = "Versione creata per modifiche apportate ai dati contenuti nel file ENTESUAP.xml";
                    DocsPaVO.documento.FileRequest fr = VersioniManager.addVersion(fileReq, infoUtenteInterop, false);


                    if (!BusinessLogic.Documenti.FileManager.putFile(ref fr, fdAllNew, infoUtenteInterop, out err))
                    {
                        throw new Exception(err);
                    }
                    else
                    {
                        SchedaDocumento sdNew = BusinessLogic.Documenti.DocManager.getDettaglio(infoUtenteInterop, schedaDoc.docNumber, schedaDoc.docNumber);
                        schedaDocOriginale.allegati = sdNew.allegati;
                        return(true);
                    }
                }
            }
            else
            {
                DocsPaVO.documento.Allegato allegato = new DocsPaVO.documento.Allegato();
                allegato.descrizione  = "ENTESUAP.XML";
                allegato.numeroPagine = 1;
                allegato.docNumber    = schedaDoc.docNumber;
                allegato.version      = "0";
                allegato = BusinessLogic.Documenti.AllegatiManager.aggiungiAllegato(infoUtenteInterop, allegato);

                DocsPaVO.documento.FileRequest fr = (DocsPaVO.documento.FileRequest)allegato;
                if (!BusinessLogic.Documenti.FileManager.putFile(ref fr, fdAllNew, infoUtenteInterop, out err))
                {
                    throw new Exception(err);
                }
                else
                {
                    SchedaDocumento sdNew = BusinessLogic.Documenti.DocManager.getDettaglio(infoUtenteInterop, schedaDoc.docNumber, schedaDoc.docNumber);
                    schedaDocOriginale.allegati = sdNew.allegati;
                    return(true);
                }
            }


            //presume insuccesso (mai na gioa)..
            //return false;
        }
예제 #18
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string base64content = string.Empty;

            // Put user code to initialize the page here
            try
            {
                this.startUp();
                this.ErrorPage = "";

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

                hashSigned = Request.Form["signedDoc"];
                if (hashSigned == null)
                {
                    byte[] ba = Request.BinaryRead(Request.ContentLength);
                    hashSigned = System.Text.ASCIIEncoding.ASCII.GetString(ba);
                }
                isPades = false;

                string strPades = Request.QueryString["isPades"];
                bool.TryParse(strPades, out isPades);

                DocsPaWR.MassSignature massSignature = UIManager.FileManager.getSelectedMassSignature(idDocument);
                massSignature.base64Signature = hashSigned;
                massSignature.signPades       = isPades;

                DocsPaWR.DocsPaWebService DocsPaWS = ProxyManager.GetWS();
                massSignature = DocsPaWS.signDocument(massSignature, UIManager.UserManager.GetInfoUser());

                FileRequest fr = massSignature.fileRequest;
                UIManager.FileManager.setSelectedFile(fr);
                DocsPaWR.SchedaDocumento schedaDocumento = UIManager.DocumentManager.getSelectedRecord();
                //List<DocsPaWR.Allegato> attachments = new List<DocsPaWR.Allegato>(schedaDocumento.allegati);

                if (schedaDocumento != null)
                {
                    if (schedaDocumento.allegati != null && 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);
                }
            }
            catch (Exception es)
            {
                ErrorManager.setError(this, es);
            }
        }
예제 #19
0
        /// <summary>
        /// Funzione per l'acquisizione del file da associare ad un allegato
        /// </summary>
        /// <param name="path">Il path relativo del file da caricare</param>
        /// <param name="administrationCode">Il codice dell'amministrazione</param>
        /// <param name="userInfo">Le informazioni sull'utente che ha lanciato la procedura</param>
        /// <param name="ftpAddress">L'indirizzo a cui è possibile recuperare le informazioni sul file</param>
        /// <param name="attachment">L'allegato a cui associare il file</param>
        protected void AcquireFile(string path, string administrationCode, InfoUtente userInfo, string ftpAddress, Allegato attachment, String ftpUsername, String ftpPassword, DocumentRowData rowData)
        {
            #region Dichiarazione Variabili

            // Il contenuto del file
            byte[] fileContent;

            // L'oggetto fileRequest
            FileRequest fileRequest;

            // L'oggetto fileDocumento
            FileDocumento fileDocumento;

            #endregion

            #region Lettura file documento

            try
            {
                // Apertura, lettura e chiusura del file
                //fileContent = ImportUtils.DownloadFileFromFTP(
                //     ftpAddress,
                //     String.Format("{0}/{1}/{2}",
                //         administrationCode,
                //         userInfo.userId,
                //         path),
                //     ftpUsername,
                //     ftpPassword);

                // nuova versione, i file vengono presi in locale e caricati dagli utenti in locale nella procedura di import

                fileContent = ImportUtils.DounloadFileFromUserTempFolder(rowData, userInfo, true);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }

            #endregion

            #region Creazione dell'oggetto fileDocumento

            // Creazione dell'oggetto fileDocumento
            fileDocumento = new FileDocumento();

            // Impostazione del nome del file
            fileDocumento.name = Path.GetFileName(path);

            // Impostazione del full name
            fileDocumento.fullName = path;

            // Impostazione del path
            fileDocumento.path = Path.GetPathRoot(path);

            // Impostazione della grandezza del file
            fileDocumento.length = fileContent.Length;

            // Impostazione del content del documento
            fileDocumento.content = fileContent;

            #endregion

            #region Creazione dell'oggetto fileRequest

            fileRequest = (FileRequest)attachment;

            #endregion

            #region Acquisizione del file

            try
            {
                FileManager.putFile(fileRequest, fileDocumento, userInfo);
            }
            catch (Exception e)
            {
                // Aggiunta del problema alla lista dei problemi
                throw new Exception("Errore durante l'upload del file.");
            }

            #endregion
        }
예제 #20
0
        /// <summary>
        /// Aggiornamento stato di sessione
        /// </summary>
        protected virtual void RefreshState()
        {
            try
            {
                // NB:
                // Importante mantenere l'impostazione a null di questo flag,
                // utilizzato poi dalla pagina "docSalva.aspx".
                // Se lo si toglie, la firma multipla non funziona.
                // Grazie, utilizzo sessione selvaggio!
                UIManager.UserManager.setBoolDocSalva(this, null);

                FirmaDigitaleMng         mng             = new FirmaDigitaleMng();
                DocsPaWR.SchedaDocumento schedaDocumento = mng.GetSchedaDocumento(this.IdDocumento);

                if (schedaDocumento != null)
                {
                    bool consolidated = false;

                    if (((Convert.ToInt32(schedaDocumento.accessRights) > 0) && (Convert.ToInt32(schedaDocumento.accessRights) < 45)))
                    {
                        // Non si posseggono i diritti per firmare il documento (attesa accettazione, stato finale, prot. annullati)
                        throw new ApplicationException("Non si posseggono i diritti per firmare il documento");
                    }

                    if (schedaDocumento.checkOutStatus != null)
                    {
                        // Documento bloccato
                        throw new ApplicationException("Il documento risulta bloccato");
                    }


                    if ((schedaDocumento.protocollo != null) && (schedaDocumento.protocollo.protocolloAnnullato != null))
                    {
                        // Prot. annullato
                        throw new ApplicationException("Il documento risulta annullato");
                    }

                    if (schedaDocumento.ConsolidationState != null &&
                        schedaDocumento.ConsolidationState.State > DocsPaWR.DocumentConsolidationStateEnum.None)
                    {
                        // Il documento risulta consolidato, non può essere firmato digitalmente
                        consolidated = true;
                    }

                    if (consolidated)
                    {
                        throw new ApplicationException("Il documento risulta in stato consolidato");
                    }
                }
                else
                {
                    throw new ApplicationException("Errore nel reperimento dei metadati del documento");
                }

                DocsPaWR.FileRequest fileRequest = null;

                if (schedaDocumento.documenti != null && schedaDocumento.documenti.Length > 0)
                {
                    if (Request.QueryString["fromDoc"] != null && Request.QueryString["fromDoc"].Equals("1"))
                    {
                        //Emanuela 16-04-2014: modifica per consetire la firma anche degli allegati
                        //fileRequest = UIManager.FileManager.getSelectedFile();
                        fileRequest = schedaDocumento.documenti[0];
                        if (UIManager.DocumentManager.getSelectedAttachId() != null)
                        {
                            FileRequest fileReqTemp = FileManager.GetFileRequest(UIManager.DocumentManager.getSelectedAttachId());

                            Allegato a = new Allegato();
                            a.applicazione          = fileRequest.applicazione;
                            a.daAggiornareFirmatari = fileRequest.daAggiornareFirmatari;
                            a.dataInserimento       = fileRequest.dataInserimento;
                            a.descrizione           = fileRequest.descrizione;
                            a.docNumber             = fileRequest.docNumber;
                            a.docServerLoc          = fileRequest.docServerLoc;
                            a.fileName          = fileRequest.fileName;
                            a.fileSize          = fileRequest.fileSize;
                            a.firmatari         = fileRequest.firmatari;
                            a.firmato           = fileRequest.firmato;
                            a.idPeople          = fileRequest.idPeople;
                            a.path              = fileRequest.path;
                            a.subVersion        = fileRequest.version;
                            a.version           = fileRequest.version;
                            a.versionId         = fileRequest.versionId;
                            a.versionLabel      = fileRequest.versionLabel;
                            a.cartaceo          = fileRequest.cartaceo;
                            a.repositoryContext = fileRequest.repositoryContext;
                            a.TypeAttachment    = 1;
                            a.numeroPagine      = (fileReqTemp as Allegato).numeroPagine;

                            if ((fileRequest.fNversionId != null) && (fileRequest.fNversionId != ""))
                            {
                                a.fNversionId = fileRequest.fNversionId;
                            }

                            fileRequest = a;
                        }
                    }
                    else
                    {
                        schedaDocumento = DocumentManager.getDocumentListVersions(this.Page, this.IdDocumento, this.IdDocumento);
                        fileRequest     = schedaDocumento.documenti[0];
                        // fileRequest = schedaDocumento.documenti[0];
                    }

                    int fileSize;
                    Int32.TryParse(fileRequest.fileSize, out fileSize);

                    if (fileSize == 0)
                    {
                        throw new ApplicationException("Nessun file acquisito per il documento");
                    }

                    #region VERIFICA DIMENSIONE MASSIMA FILE
                    int maxDimFileSign = 0;
                    if (!string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UserManager.GetUserInSession().idAmministrazione, Utils.DBKeys.FE_DO_BIG_FILE_MIN.ToString())) &&
                        !Utils.InitConfigurationKeys.GetValue(UserManager.GetUserInSession().idAmministrazione, Utils.DBKeys.FE_DO_BIG_FILE_MIN.ToString()).Equals("0"))
                    {
                        maxDimFileSign = Convert.ToInt32(Utils.InitConfigurationKeys.GetValue(UserManager.GetUserInSession().idAmministrazione, Utils.DBKeys.FE_DO_BIG_FILE_MIN.ToString()));
                    }
                    if (maxDimFileSign > 0 && Convert.ToInt32(fileSize) > maxDimFileSign)
                    {
                        string maxSize = Convert.ToString(Math.Round((double)maxDimFileSign / 1048576, 3));
                        string msg     = "La dimensione del file supera il limite massimo consentito per la firma. Il limite massimo consentito e' " + maxSize + " Mb";
                        throw new ApplicationException(msg);
                    }
                    #endregion

                    if (string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString())) || !Utils.InitConfigurationKeys.GetValue(UIManager.UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_REQ_CONV_PDF.ToString()).Equals("1"))
                    {
                        if (!this.IsFormatSupportedForSign(fileRequest))
                        {
                            throw new ApplicationException("Formato file non ammesso per la firma");
                        }
                    }
                }

                if (fileRequest != null)
                {
                    // Impostazione scheda documento in sessione
                    // NB: Ultima operazione nei controlli

                    //Emanuela 17-04-2014: commentato perchè dal tab allegati alla chiusura della popup, dopo la firma, tornando nel tab profilo, caricava il
                    //profilo dell'allegato
                    //UIManager.DocumentManager.setSelectedRecord(schedaDocumento);

                    // Impostazione metadati file selezionato
                    UIManager.FileManager.setSelectedFile(fileRequest);

                    //ABBATANGELI MASSSIGNATURE HASH

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

                    bool   pades     = false;
                    string tipoPades = this.Request.QueryString["pades"];
                    if (!string.IsNullOrEmpty(tipoPades))
                    {
                        if (tipoPades.ToLower().Equals("true"))
                        {
                            pades = true;
                        }
                    }

                    string extFile     = Path.GetExtension(fileRequest.fileName);
                    bool   isPadesSign = fileRequest.tipoFirma == TipoFirma.PADES || fileRequest.tipoFirma == TipoFirma.PADES_ELETTORNICA;
                    bool   firmato     = (!string.IsNullOrEmpty(fileRequest.firmato) && fileRequest.firmato.Trim() == "1");

                    if (!firmato && cosign)
                    {
                        throw new ApplicationException("Impossibile apporre la firma parallela perche' il file non risulta essere firmato");
                    }

                    if (firmato && extFile.ToUpper() == ".P7M" && pades)
                    {
                        throw new ApplicationException("Impossibile firmare PADES un file firmato CADES");
                    }

                    if (firmato && isPadesSign && !pades && cosign)
                    {
                        throw new ApplicationException("Impossibile cofirmare CADES un file firmato PADES");
                    }

                    NttDataWA.UIManager.FileManager.setMassSignature(fileRequest, cosign, pades, IdDocumento);
                }
                else
                {
                    throw new ApplicationException("Errore nel reperimento dell'ultima versione del documento");
                }
            }
            catch (Exception ex)
            {
                string exMessage = !String.IsNullOrEmpty(ex.Message) && ex.Message.Length < 200 ? ex.Message : "Errore generico";
                //FirmaDigitaleResultManager.SetData(
                //            new FirmaDigitaleResultStatus
                //            {
                //                Status = false,
                //                StatusDescription = exMessage,
                //                IdDocument = this.IdDocumento
                //            }
                //    );
                if (this.Response != null)
                {
                    this.Response.StatusCode = 500;
                    this.Response.Write(exMessage);
                    this.Response.End();
                    this.Response.Flush();
                    //throw new ApplicationException(exMessage);
                }
                //this.Response.StatusCode = -1;
                //this.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                //this.Response.Status = "999";
                //this.Response.StatusDescription = ex.Message;
                //this.Response.End();
                //throw new ApplicationException(ex.Message);

                //DocsPAWA.Logger.log("statusCode = " + this.Response.StatusCode);
                //DocsPAWA.Logger.log("StatusDescription = " + this.Response.StatusDescription);

                //DocsPAWA.Logger.logException(ex);
            }
        }
예제 #21
0
 public static string BuildFileName(Allegato allegato)
 {
     return allegato.Id + allegato.Estensione;
 }
예제 #22
0
        /// <summary>
        /// Metodo per l'aggiunta dell'allegato al documento
        /// </summary>
        /// <param name="documentId">Id del documento cui aggiungere l'allegato</param>
        /// <param name="recData">Contenuto della ricevuta</param>
        /// <param name="userInfo">Inormazioni sull'utente utilizzato per la generazione dell'allegato</param>
        /// <param name="messageId">Identificativo del messaggio ricevuto</param>
        /// <param name="proofDate">Data di generazione della ricevuta</param>
        /// <param name="receiverCode">Codice del destinatario per cui generare la ricevuta</param>
        /// <param name="senderUrl">Url del mittente</param>
        private static void AddAttachmentToDocument(String documentId, byte[] recData, InfoUtente userInfo, String messageId, DateTime proofDate, String receiverCode, String senderUrl)
        {
            // Creazione dell'oggetto allegato
            Allegato a = new Allegato();

            // Impostazione delle proprietà dell'allegato
            a.descrizione = String.Format("Ricevuta di avvenuta consegna - " + receiverCode);

            a.docNumber = documentId;
            a.version = "0";
            a.numeroPagine = 1;
            a.TypeAttachment = 3;
            try
            {
                bool usingTransactionContext = string.IsNullOrEmpty(DocsPaUtils.Configuration.InitConfigurationKeys.GetValue("0", "BE_NOT_USING_TRANSACTION_CONTEXT")) ||
                    !DocsPaUtils.Configuration.InitConfigurationKeys.GetValue("0", "BE_NOT_USING_TRANSACTION_CONTEXT").Equals("1");
                // Aggiunta dell'allegato al documento principale
                if (usingTransactionContext)
                {
                    using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
                    {
                        logger.Debug("INIZIO aggiungiAllegato per il documento " + documentId);
                        a = AllegatiManager.aggiungiAllegato(userInfo, a);
                        logger.Debug("FINE aggiungiAllegato per il documento " + documentId + ". Id allegato creato: " + a.docNumber + " con id versione: " + a.versionId);

                        // Set del flag in CHA_ALLEGATI_ESTERNO in Versions
                        logger.Debug("INIZIO setFlagAllegati_PEC_IS_EXT per l'allegato con docnumber" + a.docNumber + "e version id: " + a.versionId + ". Documento principale:" + documentId);
                        bool resultSetFlag = BusinessLogic.Documenti.AllegatiManager.setFlagAllegati_PEC_IS_EXT(a.versionId, a.docNumber, "I");
                        logger.Debug("FINE setFlagAllegati_PEC_IS_EXT per l'allegato " + a.docNumber + "con esito: " + resultSetFlag + ". Documento principale:" + documentId);

                        // Associazione dell'immagine all'allegato
                        FileDocumento fileDocument = new FileDocumento() { content = recData, length = recData.Length, name = "AvvenutaConsegna.pdf" };
                        FileRequest request = a as FileRequest;
                        String err;
                        logger.Debug("INIZIO putFile per l'allegato " + a.docNumber);
                        FileManager.putFileRicevuteIs(ref request, fileDocument, userInfo, out err);
                        logger.Debug("FINE putFile per l'allegato " + a.docNumber);

                        // Aggiunta della notifica alla tabella delle notifiche
                        SaveProofInRegistry(a, messageId, receiverCode, senderUrl, proofDate, documentId);


                        if (!String.IsNullOrEmpty(err))
                        {
                            logger.Error("Errore durante la procedura di putfile per l'allegato: " + a.docNumber + ". Testo dell'errore: " + err);
                            SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(documentId, true,
                                String.Format("Errore durante l'associazione della ricevuta di avvenuta consegna inviata da al documento"));
                        }
                        else
                        {
                            logger.Debug("Putfile avvenuta correttamente per l'allegato  " + a.docNumber);
                            SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(documentId, false,
                                String.Format("Ricevuta di avvenuta consegna associata correttamente al documento"));
                        }

                        if (resultSetFlag && string.IsNullOrEmpty(err))
                        {
                            transactionContext.Complete();
                        }
                    }
                }
                else
                {
                    logger.Debug("INIZIO aggiungiAllegato per il documento " + documentId);
                    a = AllegatiManager.aggiungiAllegato(userInfo, a);
                    logger.Debug("FINE aggiungiAllegato per il documento " + documentId + ". Id allegato creato: " + a.docNumber + " con id versione: " + a.versionId);

                    // Set del flag in CHA_ALLEGATI_ESTERNO in Versions
                    logger.Debug("INIZIO setFlagAllegati_PEC_IS_EXT per l'allegato con docnumber" + a.docNumber + "e version id: " + a.versionId + ". Documento principale:" + documentId);
                    bool resultSetFlag = BusinessLogic.Documenti.AllegatiManager.setFlagAllegati_PEC_IS_EXT(a.versionId, a.docNumber, "I");
                    logger.Debug("FINE setFlagAllegati_PEC_IS_EXT per l'allegato " + a.docNumber + "con esito: " + resultSetFlag + ". Documento principale:" + documentId);

                    // Associazione dell'immagine all'allegato
                    FileDocumento fileDocument = new FileDocumento() { content = recData, length = recData.Length, name = "AvvenutaConsegna.pdf" };
                    FileRequest request = a as FileRequest;
                    String err;
                    logger.Debug("INIZIO putFile per l'allegato " + a.docNumber);
                    FileManager.putFileRicevuteIs(ref request, fileDocument, userInfo, out err);
                    logger.Debug("FINE putFile per l'allegato " + a.docNumber);

                    // Aggiunta della notifica alla tabella delle notifiche
                    SaveProofInRegistry(a, messageId, receiverCode, senderUrl, proofDate, documentId);


                    if (!String.IsNullOrEmpty(err))
                    {
                        logger.Error("Errore durante la procedura di putfile per l'allegato: " + a.docNumber + ". Testo dell'errore: " + err);
                        SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(documentId, true,
                            String.Format("Errore durante l'associazione della ricevuta di avvenuta consegna inviata da al documento"));
                    }
                    else
                    {
                        logger.Debug("Putfile avvenuta correttamente per l'allegato  " + a.docNumber);
                        SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(documentId, false,
                            String.Format("Ricevuta di avvenuta consegna associata correttamente al documento"));
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error("Errore in AddAttachmentToDocument per l'allegato: " + a.docNumber + ". Errore: " + e.Message);
                string message = e.Message + " " + e.StackTrace;
                message = message.Length > 3700 ? message.Substring(0, 3700) : message;
                SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(documentId, true,
                    String.Format("Errore durante l'aggiunta dell'allegato con la ricevuta di avvenuta consegna al documento " + documentId + " : " + message));
            }
        }
예제 #23
0
 public static string BuildPrintFileName(Allegato allegato)
 {
     return allegato.Descrizione + allegato.Estensione;
 }
예제 #24
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);
        }
예제 #25
0
        /// <summary>
        /// Metodo per l'aggiunta degli allegati ad un documento
        /// </summary>
        /// <param name="docNumber">Numero del documento cui aggiungere gli allegati</param>
        /// <param name="attachments">Informazioni sugli allegati da creare</param>
        /// <param name="userInfo">Informazioni sull'utente utilizzato per la creazione del predisposto in ingresso</param>
        /// <param name="senderAdministrationId">Id dell'amministrazione mittente della richiesta di interoperabilità</param>
        /// <param name="senderFileManagerUrl">Url del file manager per il download dell'eventuale file associato ad un allegato</param>
        private static void AddAttachments(String docNumber, List <DocumentInfo> attachments, InfoUtente userInfo, String senderAdministrationId, String senderFileManagerUrl)
        {
            int i = 0;

            foreach (DocumentInfo attachment in attachments)
            {
                // Creazione dell'oggetto allegato
                Allegato a = new Allegato();

                // Impostazione delle proprietà dell'allegato
                if (String.IsNullOrEmpty(attachment.Name))
                {
                    a.descrizione = String.Format("Allegato {0}", i);
                }
                else
                {
                    a.descrizione = attachment.Name;
                }

                a.docNumber    = docNumber;
                a.fileName     = InteroperabilitaSegnatura.getFileName(attachment.FileName);
                a.version      = "0";
                a.numeroPagine = attachment.NumberOfPages;

                // Aggiunta dell'allegato al documento principale
                try
                {
                    a = AllegatiManager.aggiungiAllegato(userInfo, a);
                }
                catch (Exception ex)
                {
                    SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(
                        docNumber,
                        true,
                        String.Format("Errore durante l'aggiunta dell'allegato '{0}'. Messaggio eccezione: {1}",
                                      a.descrizione,
                                      ex.Message));

                    throw new CreatingDocumentException(
                              String.Format("Errore durante l'aggiunta dell'allegato '{0}'", attachment.Name));
                }
                string errPutFile = "";
                try
                {
                    // Associazione dell'immagine all'allegato
                    FileRequest request = a as FileRequest;
                    if (!String.IsNullOrEmpty(attachment.FileName))
                    {
                        SimplifiedInteroperabilityFileManager.DownloadFile(
                            attachment,
                            senderAdministrationId,
                            request,
                            userInfo,
                            senderFileManagerUrl,
                            out errPutFile);
                    }

                    if (!string.IsNullOrEmpty(errPutFile))
                    {
                        throw new Exception("Errore durante l'associazione dell'immagine al documento principale");
                    }
                }
                catch (Exception e)
                {
                    SimplifiedInteroperabilityLogAndRegistryManager.InsertItemInLog(
                        a.docNumber,
                        true,
                        String.Format("Errore durante l'associazione dell'immagine per l'allegato '{0}'. Messaggio eccezione: {1}",
                                      a.descrizione,
                                      e.Message));
                    if (!string.IsNullOrEmpty(errPutFile) && errPutFile.Contains("formato file"))
                    {
                        throw new DownloadDocumentException(
                                  String.Format("Errore durante l'associazione dell'immagine all'allegato '{0}'. {1} destinataria.", attachment.Name, errPutFile));
                    }
                    else
                    {
                        throw new DownloadDocumentException(
                                  String.Format("Errore durante l'associazione dell'immagine all'allegato '{0}'", attachment.Name));
                    }
                }
                i++;
            }
        }