Exemple #1
0
        /// <summary>
        /// </summary>
        /// <param name="infoUtente"></param>
        /// <param name="schedaDoc"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        private static bool estrazioneFiles(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.documento.SchedaDocumento schedaDoc, string path)
        {
            System.IO.FileStream fs    = null;
            System.IO.FileStream fsAll = null;

            try
            {
                //estrazione documento principale
                DocsPaVO.documento.Documento doc = getDocumentoPrincipale(schedaDoc);
                string docPrincipaleName         = "Documento_principale." + doc.fileName.Substring(doc.fileName.IndexOf(".") + 1);
                fs = new System.IO.FileStream(path + "\\" + docPrincipaleName, System.IO.FileMode.Create);
                byte[] content = getDocument(infoUtente, doc.docNumber, doc.version, doc.versionId, doc.versionLabel);
                fs.Write(content, 0, content.Length);
                fs.Close();

                //estrazione degli allegati
                for (int i = 0; i < schedaDoc.allegati.Count; i++)
                {
                    DocsPaVO.documento.Allegato all = (DocsPaVO.documento.Allegato)schedaDoc.allegati[i];
                    string allegatoName             = "Allegato_" + i;
                    fsAll = new System.IO.FileStream(path + "\\" + allegatoName + "." + getEstensione(all.fileName), System.IO.FileMode.Create);
                    byte[] all_content = getDocument(infoUtente, all.docNumber, all.version, all.versionId, all.versionLabel);
                    fsAll.Write(all_content, 0, all_content.Length);
                    fsAll.Close();
                }

                return(true);
            }
            catch (Exception e)
            {
//				logger.addMessage("Estrazione del file non eseguita.Eccezione: "+e.ToString());
                logger.Debug("Estrazione del file non eseguita.Eccezione: " + e.ToString());

                if (fs != null)
                {
                    fs.Close();
                }
                if (fsAll != null)
                {
                    fsAll.Close();
                }

                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="infoUtente"></param>
        /// <param name="allegato"></param>
        /// <param name="documento"></param>
        /// <returns></returns>
        public static bool scambiaAllegatoDocumento(DocsPaVO.utente.InfoUtente infoUtente,
                                                    DocsPaVO.documento.Allegato allegato, DocsPaVO.documento.Documento documento)
        {
            // Controllo su stato congelato
            DocumentConsolidation.CanExecuteAction(infoUtente, documento.docNumber, DocumentConsolidation.ConsolidationActionsDeniedEnum.ModifyVersions, true);

            bool retValue = false;

            using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
            {
                DocsPaDocumentale.Documentale.DocumentManager documentManager = new DocsPaDocumentale.Documentale.DocumentManager(infoUtente);

                retValue = documentManager.ScambiaAllegatoDocumento(allegato, documento);

                if (retValue)
                {
                    transactionContext.Complete();
                }
            }

            return(retValue);
        }
Exemple #3
0
        /// <summary>
        /// Rimozione di un allegato
        /// </summary>
        /// <param name="allegato"></param>
        /// <param name="infoUtente"></param>
        public static bool rimuoviAllegato(DocsPaVO.documento.Allegato allegato, DocsPaVO.utente.InfoUtente infoUtente)
        {
            bool retValue = false;

            if (allegato.repositoryContext != null)
            {
                // Rimozione dell'allegato nell'ambito del  repository context
                SessionRepositoryFileManager fm = BusinessLogic.Documenti.SessionRepositoryFileManager.GetFileManager(allegato.repositoryContext);

                // Verifica esistenza file acquisito nel repository context
                if (fm.ExistFile(allegato))
                {
                    fm.RemoveFile(allegato);
                }

                retValue = true;
            }
            else
            {
                // Controllo su stato congelato
                DocumentConsolidation.CanExecuteAction(infoUtente,
                                                       allegato.docNumber,
                                                       DocumentConsolidation.ConsolidationActionsDeniedEnum.RemoveAttatchments, true);

                using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
                {
                    DocsPaDocumentale.Documentale.DocumentManager documentManager = new DocsPaDocumentale.Documentale.DocumentManager(infoUtente);

                    retValue = documentManager.RemoveAttatchment(allegato);

                    if (retValue)
                    {
                        transactionContext.Complete();
                    }
                }
            }

            return(retValue);
        }
Exemple #4
0
        /// <summary>
        /// Modifica dei dati di un allegato
        /// </summary>
        /// <param name="allegato"></param>
        /// <param name="debug"></param>
        public static void modificaAllegato(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.documento.Allegato allegato)
        {
            if (allegato.repositoryContext != null)
            {
                // Modifica allegato gestito mediante il repository context
            }
            else
            {
                // Controllo su stato congelato
                DocumentConsolidation.CanExecuteAction(infoUtente,
                                                       allegato.docNumber,
                                                       DocumentConsolidation.ConsolidationActionsDeniedEnum.ModifyAttatchments, true);

                using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
                {
                    DocsPaDocumentale.Documentale.DocumentManager documentManager = new DocsPaDocumentale.Documentale.DocumentManager(infoUtente);

                    documentManager.ModifyAttatchment(allegato);

                    transactionContext.Complete();
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Inserimento di un nuovo allegato per un documento
        /// </summary>
        /// <param name="infoUtente"></param>
        /// <param name="allegato"></param>
        /// <param name="debug"></param>
        /// <returns></returns>
        private static DocsPaVO.documento.Allegato aggiungiAllegato(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.documento.Allegato allegato, bool statoCongelato)
        {
            using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
            {
                if (allegato.repositoryContext != null)
                {
                    // Inserimento di un allegato nel repositorycontext
                    allegato.version      = "1";                                                                       // Prima versione dell'allegato
                    allegato.versionId    = allegato.position.ToString();                                              // Viene assegnato un nuovo id temporaneo (la sequenza di inserimento)
                    allegato.versionLabel = DocsPaDB.Query_DocsPAWS.Documenti.FormatCodiceAllegato(allegato.position); // Viene creato, in base alla sequenza di inserimento, il codice progressivo

                    // L'allegato viene impostato come non acquisito
                    allegato.subVersion = "!";
                    allegato.fileName   = string.Empty;
                    allegato.fileSize   = "0";
                }
                else
                {
                    if (statoCongelato && allegato.TypeAttachment != 2 && allegato.TypeAttachment != 3)
                    {
                        // Controllo su stato congelato, solo se non si sta creando l'allegato nel repository context
                        DocumentConsolidation.CanExecuteAction(infoUtente,
                                                               allegato.docNumber,
                                                               DocumentConsolidation.ConsolidationActionsDeniedEnum.AddAttatchments, true);
                    }
                    DocsPaDB.Query_DocsPAWS.Documenti doc = new DocsPaDB.Query_DocsPAWS.Documenti();

                    string oldApp  = null;
                    string putfile = "";

                    try
                    {
                        if (allegato.applicazione != null)
                        {
                            if (allegato.applicazione.systemId == null)
                            {
                                allegato.applicazione = BusinessLogic.Documenti.FileManager.getApplicazione(allegato.applicazione.estensione);
                            }

                            logger.Debug("Update della tabella profile");

                            string param = "DOCNUMBER=" + allegato.docNumber;
                            doc.GetApplication(out oldApp, allegato.docNumber, allegato.applicazione.systemId, param);
                        }

                        if (!string.IsNullOrEmpty(allegato.versionLabel))
                        {
                            // L'allegato è già stato creato (ha già la versionLabel),
                            // si sta usando il metodo per fare un'acquisizione sull'allegato
                            putfile = "Y";
                        }

                        DocsPaDocumentale.Documentale.DocumentManager documentManager = new DocsPaDocumentale.Documentale.DocumentManager(infoUtente);
                        //Se l'allegato non è una ricevuta controllo se il doc principale è in libro firma; se il doc principale è in libro firma non è possibile allegare
                        if (allegato.TypeAttachment != 2 && allegato.TypeAttachment != 3 && LibroFirmaManager.IsModificaBloccataPerDocumentoPrincipaleInLF(allegato.docNumber, infoUtente.idAmministrazione))
                        {
                            throw new Exception("Non è possibile creare l'allegato poichè il documento principale è in libro firma");
                        }

                        if (!documentManager.AddAttachment(allegato, putfile))
                        {
                            throw new Exception("Errore nell'inserimento dell'allegato nel documentale");
                        }
                        else
                        {
                            transactionContext.Complete();
                        }
                    }
                    catch (Exception e)
                    {
                        string message = string.Format("Errore nell'inserimento dell'allegato: {0}", e.Message);
                        logger.Debug(message);
                        throw new Exception(message);
                    }
                }
            }

            return(allegato);
        }
Exemple #6
0
        /// <summary>
        /// Riproponi avanzato: ripropone il documento con la copia dell'eventuale documento
        /// principale e degli eventuali allegati
        /// </summary>
        /// <param name="infoUtente"></param>
        /// <param name="ruolo"></param>
        /// <param name="sch"></param>
        /// <returns></returns>
        public static DocsPaVO.documento.SchedaDocumento riproponiConCopiaDoc(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.utente.Ruolo ruolo, DocsPaVO.documento.SchedaDocumento sch)
        {
            string err = "";

            DocsPaVO.documento.SchedaDocumento sd = null;
            bool   daAggiornareUffRef             = false;
            string filepath = "";

            DocsPaVO.documento.FileDocumento fd = null;

            //se arriva sch con solo system_id e docnumber la ricerco
            if (sch != null && sch.protocollo == null)
            {
                sch = BusinessLogic.Documenti.DocManager.getDettaglio(infoUtente, sch.systemId, sch.docNumber);
            }
            sd = new DocsPaVO.documento.SchedaDocumento();
            if (sch.documenti != null && sch.documenti[0] != null &&
                Int32.Parse(((DocsPaVO.documento.FileRequest)sch.documenti[0]).fileSize) > 0)
            {
                sd.appId = sch.appId;
            }
            else
            {
                sd.appId = "ACROBAT";
            }
            if (sd.appId == null)
            {
                sd.appId = "ACROBAT";
            }

            sd.systemId                  = null;
            sd.docNumber                 = null;
            sd.oggetto                   = sch.oggetto;
            sd.idPeople                  = infoUtente.idPeople;
            sd.userId                    = infoUtente.userId;
            sd.registro                  = sch.registro;
            sd.tipoProto                 = "G";
            sd.typeId                    = "LETTERA";
            sd.privato                   = sch.privato;
            sd.mezzoSpedizione           = sch.mezzoSpedizione;
            sd.descMezzoSpedizione       = sch.descMezzoSpedizione;
            sd.tipologiaAtto             = sch.tipologiaAtto;
            sd.predisponiProtocollazione = true;

            //creo un nuovo documento grigio
            logger.Debug("Creazione doc...");
            sd = BusinessLogic.Documenti.DocSave.addDocGrigia(sd, infoUtente, ruolo);

            //Dopo aver creato il documento grigio lo predispongo alla protocollazione
            logger.Debug("Predisponi doc...");
            sd.tipoProto = sch.tipoProto;
            sd.typeId    = sch.typeId;
            sd.predisponiProtocollazione = true;
            switch (sd.tipoProto)
            {
            case "A":
                sd.protocollo = new DocsPaVO.documento.ProtocolloEntrata();
                ((DocsPaVO.documento.ProtocolloEntrata)sd.protocollo).mittente           = ((DocsPaVO.documento.ProtocolloEntrata)sch.protocollo).mittente;
                ((DocsPaVO.documento.ProtocolloEntrata)sd.protocollo).mittenteIntermedio = ((DocsPaVO.documento.ProtocolloEntrata)sch.protocollo).mittenteIntermedio;
                //if (eUffRef)
                //{
                //    ((DocsPaVO.documento.ProtocolloEntrata)sd.protocollo).ufficioReferente = ((DocsPaVO.documento.ProtocolloEntrata)sch.protocollo).ufficioReferente;
                //}
                break;

            case "P":
                sd.protocollo = new DocsPaVO.documento.ProtocolloUscita();
                ((DocsPaVO.documento.ProtocolloUscita)sd.protocollo).mittente              = ((DocsPaVO.documento.ProtocolloUscita)sch.protocollo).mittente;
                ((DocsPaVO.documento.ProtocolloUscita)sd.protocollo).destinatari           = ((DocsPaVO.documento.ProtocolloUscita)sch.protocollo).destinatari;
                ((DocsPaVO.documento.ProtocolloUscita)sd.protocollo).destinatariConoscenza = ((DocsPaVO.documento.ProtocolloUscita)sch.protocollo).destinatariConoscenza;
                //if (eUffRef)
                //{
                //    ((DocsPaVO.documento.ProtocolloUscita)sd.protocollo).ufficioReferente = ((DocsPaVO.documento.ProtocolloUscita)sch.protocollo).ufficioReferente;
                //}
                break;

            case "I":
                sd.protocollo = new DocsPaVO.documento.ProtocolloInterno();
                ((DocsPaVO.documento.ProtocolloInterno)sd.protocollo).mittente              = ((DocsPaVO.documento.ProtocolloInterno)sch.protocollo).mittente;
                ((DocsPaVO.documento.ProtocolloInterno)sd.protocollo).destinatari           = ((DocsPaVO.documento.ProtocolloInterno)sch.protocollo).destinatari;
                ((DocsPaVO.documento.ProtocolloInterno)sd.protocollo).destinatariConoscenza = ((DocsPaVO.documento.ProtocolloInterno)sch.protocollo).destinatariConoscenza;
                //if (eUffRef)
                //{
                //    ((DocsPaVO.documento.ProtocolloInterno)sd.protocollo).ufficioReferente = ((DocsPaVO.documento.ProtocolloInterno)sch.protocollo).ufficioReferente;
                //}
                break;
            }
            sd = BusinessLogic.Documenti.DocSave.save(infoUtente, sd, false, out daAggiornareUffRef, ruolo);
            logger.Debug("Creato documento grigio e predisposto alla protocollazione");

            //Copia del documento principale e degli allegati del vecchio documento
            //nel nuovo documento
            #region copia documento principale e allegati
            DocsPaVO.documento.FileDocumento fdNew = null;
            if (sch.documenti != null && sch.documenti[0] != null &&
                Int32.Parse(((DocsPaVO.documento.FileRequest)sch.documenti[0]).fileSize) > 0)
            {
                try
                {
                    fd = BusinessLogic.Documenti.FileManager.getFile((DocsPaVO.documento.FileRequest)sch.documenti[0], infoUtente);
                    if (fd == null)
                    {
                        throw new Exception("Errore nel reperimento del file principale.");
                    }
                    //copio in un nuovo filerequest perchè putfile lo vuole senza
                    fdNew             = new DocsPaVO.documento.FileDocumento();
                    fdNew.content     = fd.content;
                    fdNew.length      = fd.length;
                    fdNew.name        = fd.name;
                    fdNew.fullName    = fd.fullName;
                    fdNew.contentType = fd.contentType;
                    DocsPaVO.documento.FileRequest fr = (DocsPaVO.documento.FileRequest)sd.documenti[0];
                    if (!BusinessLogic.Documenti.FileManager.putFile(ref fr, fdNew, infoUtente, out err))
                    {
                        throw new Exception(err);
                    }
                    logger.Debug("file principale inserito");
                }
                catch (Exception ex)
                {
                    err = "Errore nel reperimento del file principale : " + ex.Message;
                    if (sd != null && sd.systemId != null && sd.systemId != "")
                    {
                        //se il putFile va in errore devo rimuovere il profile (predisposto appena inserito)
                        BusinessLogic.Documenti.DocManager.ExecRimuoviSchedaMethod(infoUtente, sd);
                        logger.Debug("Eseguita rimozione profilo");
                    }
                    logger.Debug(err);
                    throw ex;
                }
            }
            //ricerca degli allegati
            logger.Debug("Inserimento degli allegati");
            for (int i = 0; sch.allegati != null && i < sch.allegati.Count; i++)
            {
                //estrazione dati dell'allegato
                DocsPaVO.documento.Allegato documentoAllegato = (DocsPaVO.documento.Allegato)sch.allegati[i];
                filepath = documentoAllegato.docServerLoc + documentoAllegato.path;
                string nomeAllegato = documentoAllegato.fileName;
                string numPagine    = documentoAllegato.numeroPagine.ToString();
                string titoloDoc    = documentoAllegato.descrizione;
                logger.Debug("Inserimento allegato " + nomeAllegato);
                DocsPaVO.documento.Allegato all = new DocsPaVO.documento.Allegato();
                all.descrizione = "allegato " + i;
                logger.Debug("docnumber=" + sd.docNumber);
                all.docNumber = sd.docNumber;
                all.fileName  = getFileName(nomeAllegato);
                all.version   = "0";
                //numero pagine
                if (numPagine != null && !numPagine.Trim().Equals(""))
                {
                    all.numeroPagine = Int32.Parse(numPagine);
                }
                //descrizione allegato
                if (titoloDoc != null && !titoloDoc.Trim().Equals(""))
                {
                    all.descrizione = titoloDoc;
                }
                BusinessLogic.Documenti.AllegatiManager.aggiungiAllegato(infoUtente, all);
                logger.Debug("Allegato id=" + all.versionId);
                logger.Debug("Allegato version label=" + all.versionLabel);
                logger.Debug("Inserimento nel filesystem");
                DocsPaVO.documento.FileDocumento fdAllNew = new DocsPaVO.documento.FileDocumento();
                DocsPaVO.documento.FileDocumento fdAll    = null;
                if (Int32.Parse(documentoAllegato.fileSize) > 0)
                {
                    try
                    {
                        fdAll = BusinessLogic.Documenti.FileManager.getFile((DocsPaVO.documento.FileRequest)sch.allegati[i], infoUtente);
                        if (fdAll == null)
                        {
                            throw new Exception("Errore nel reperimento dell'allegato numero" + i.ToString());
                        }
                        fdAllNew.content     = fdAll.content;
                        fdAllNew.length      = fdAll.length;
                        fdAllNew.name        = fdAll.name;
                        fdAllNew.fullName    = fdAll.fullName;
                        fdAllNew.contentType = fdAll.contentType;
                        DocsPaVO.documento.FileRequest fr = (DocsPaVO.documento.FileRequest)all;
                        if (!BusinessLogic.Documenti.FileManager.putFile(ref fr, fdAllNew, infoUtente, out err))
                        {
                            throw new Exception(err);
                        }
                        logger.Debug("Allegato " + i + " inserito");
                    }
                    catch (Exception ex)
                    {
                        err = "Errore nel reperimento dell'allegato numero " + i.ToString() + " : " + ex.Message;
                        if (sd != null && sd.systemId != null && sd.systemId != "")
                        {
                            //se il putFile va in errore devo rimuovere il profile (predisposto appena inserito)
                            BusinessLogic.Documenti.DocManager.ExecRimuoviSchedaMethod(infoUtente, sd);

                            logger.Debug("Eseguita rimozione profilo");
                        }
                        logger.Debug(err);//se non si riesce a prener eil file per problemi vari continuo comunque per arrivare a eseguiTrasmissione
                        throw ex;
                    }
                }
            }
            #endregion

            err = err + " " + sd.docNumber;
            if (sd != null && sd.docNumber != null)
            {
                err = "errore " + err + " documento  rimosso: " + sd.docNumber;
            }
            else
            {
                err = "errore " + err;
            }
            logger.Debug(err);
            sd.predisponiProtocollazione = true;
            return(sd);
        }
Exemple #7
0
        public static DocsPaVO.documento.SchedaDocumento InoltraDoc(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.utente.Ruolo ruolo, DocsPaVO.documento.SchedaDocumento schedaOLD)
        {
            string err = "";

            DocsPaVO.documento.SchedaDocumento schedaNEW = null;
            bool   daAggiornareUffRef = false;
            string filepath           = "";

            DocsPaVO.documento.FileDocumento fd = null;

            //se arriva sch con solo system_id e docnumber la ricerco
            if (schedaOLD != null && schedaOLD.protocollo == null)
            {
                schedaOLD = BusinessLogic.Documenti.DocManager.getDettaglio(infoUtente, schedaOLD.systemId, schedaOLD.docNumber);
            }
            schedaNEW = new DocsPaVO.documento.SchedaDocumento();

            schedaNEW.systemId  = null;
            schedaNEW.docNumber = null;
            schedaNEW.oggetto   = schedaOLD.oggetto;
            schedaNEW.idPeople  = infoUtente.idPeople;
            schedaNEW.userId    = infoUtente.userId;
            schedaNEW.registro  = schedaOLD.registro;
            //schedaNEW.tipoProto = "P";
            schedaNEW.typeId              = "LETTERA";
            schedaNEW.privato             = schedaOLD.privato;
            schedaNEW.mezzoSpedizione     = schedaOLD.mezzoSpedizione;
            schedaNEW.descMezzoSpedizione = schedaOLD.descMezzoSpedizione;
            schedaNEW.tipologiaAtto       = schedaOLD.tipologiaAtto;
            schedaNEW.template            = schedaOLD.template;
            //schedaNEW.predisponiProtocollazione = true;

            //creo un nuovo documento grigio
            logger.Debug("Creazione doc...");
            schedaNEW = BusinessLogic.Documenti.DocSave.addDocGrigia(schedaNEW, infoUtente, ruolo);

            //Dopo aver creato il documento grigio lo predispongo alla protocollazione
            logger.Debug("Predisponi doc...");
            schedaNEW.tipoProto = "P";
            schedaNEW.typeId    = schedaOLD.typeId;
            schedaNEW.predisponiProtocollazione = true;

            schedaNEW.protocollo = new DocsPaVO.documento.ProtocolloUscita();

            DocsPaVO.utente.Corrispondente corr = ruolo.uo;
            ((DocsPaVO.documento.ProtocolloUscita)schedaNEW.protocollo).mittente = corr;
            //((DocsPaVO.documento.ProtocolloUscita)schedaNEW.protocollo).mittente = ((DocsPaVO.documento.ProtocolloUscita)schedaOLD.protocollo).mittente;
            //((DocsPaVO.documento.ProtocolloUscita)schedaNEW.protocollo).destinatari = ((DocsPaVO.documento.ProtocolloUscita)schedaOLD.protocollo).destinatari;
            //((DocsPaVO.documento.ProtocolloUscita)schedaNEW.protocollo).destinatariConoscenza = ((DocsPaVO.documento.ProtocolloUscita)schedaOLD.protocollo).destinatariConoscenza;


            schedaNEW = BusinessLogic.Documenti.DocSave.save(infoUtente, schedaNEW, false, out daAggiornareUffRef, ruolo);
            logger.Debug("Creato documento grigio e predisposto alla protocollazione");

            //Copia del documento principale e degli allegati del vecchio documento
            //nel nuovo documento come allegati
            #region ricerca e copia degli allegati
            logger.Debug("Inserimento degli allegati");
            for (int i = 0; schedaOLD.allegati != null && i < schedaOLD.allegati.Count; i++)
            {
                //estrazione dati dell'allegato
                DocsPaVO.documento.Allegato documentoAllegato = (DocsPaVO.documento.Allegato)schedaOLD.allegati[i];
                filepath = documentoAllegato.docServerLoc + documentoAllegato.path;
                string nomeAllegato = "Inoltro " + documentoAllegato.fileName;
                string numPagine    = documentoAllegato.numeroPagine.ToString();
                string titoloDoc    = documentoAllegato.descrizione;
                logger.Debug("Inserimento allegato " + nomeAllegato);
                DocsPaVO.documento.Allegato all = new DocsPaVO.documento.Allegato();
                all.descrizione = "allegato " + i;
                logger.Debug("docnumber=" + schedaNEW.docNumber);
                all.docNumber = schedaNEW.docNumber;
                all.fileName  = getFileName(nomeAllegato);
                all.version   = "0";
                //numero pagine
                if (numPagine != null && !numPagine.Trim().Equals(""))
                {
                    all.numeroPagine = Int32.Parse(numPagine);
                }
                //descrizione allegato
                if (titoloDoc != null && !titoloDoc.Trim().Equals(""))
                {
                    all.descrizione = "Inoltro " + titoloDoc;
                }
                BusinessLogic.Documenti.AllegatiManager.aggiungiAllegato(infoUtente, all);
                logger.Debug("Allegato id=" + all.versionId);
                logger.Debug("Allegato version label=" + all.versionLabel);
                logger.Debug("Inserimento nel filesystem");
                DocsPaVO.documento.FileDocumento fdAllNew = new DocsPaVO.documento.FileDocumento();
                DocsPaVO.documento.FileDocumento fdAll    = null;
                if (Int32.Parse(documentoAllegato.fileSize) > 0)
                {
                    try
                    {
                        fdAll = BusinessLogic.Documenti.FileManager.getFile((DocsPaVO.documento.FileRequest)schedaOLD.allegati[i], infoUtente);
                        if (fdAll == null)
                        {
                            throw new Exception("Errore nel reperimento dell'allegato numero" + i.ToString());
                        }
                        fdAllNew.content     = fdAll.content;
                        fdAllNew.length      = fdAll.length;
                        fdAllNew.name        = fdAll.name;
                        fdAllNew.fullName    = fdAll.fullName;
                        fdAllNew.contentType = fdAll.contentType;
                        DocsPaVO.documento.FileRequest fr = (DocsPaVO.documento.FileRequest)all;
                        if (!BusinessLogic.Documenti.FileManager.putFile(ref fr, fdAllNew, infoUtente, out err))
                        {
                            throw new Exception(err);
                        }
                        logger.Debug("Allegato " + i + " inserito");
                    }
                    catch (Exception ex)
                    {
                        err = "Errore nel reperimento dell'allegato numero " + i.ToString() + " : " + ex.Message;
                        if (schedaNEW != null && schedaNEW.systemId != null && schedaNEW.systemId != "")
                        {
                            //se il putFile va in errore devo rimuovere il profile (predisposto appena inserito)
                            BusinessLogic.Documenti.DocManager.ExecRimuoviSchedaMethod(infoUtente, schedaNEW);

                            logger.Debug("Eseguita rimozione profilo");
                        }
                        logger.Debug(err);//se non si riesce a prener eil file per problemi vari continuo comunque per arrivare a eseguiTrasmissione
                        throw ex;
                    }
                }
            }
            #endregion
            #region copia documento principale in allegato
            //DocsPaVO.documento.FileDocumento fdNew = null;
            if (schedaOLD.documenti != null && schedaOLD.documenti[0] != null &&
                Int32.Parse(((DocsPaVO.documento.FileRequest)schedaOLD.documenti[0]).fileSize) > 0)
            {
                try
                {
                    fd = BusinessLogic.Documenti.FileManager.getFile((DocsPaVO.documento.FileRequest)schedaOLD.documenti[0], infoUtente);
                    if (fd == null)
                    {
                        throw new Exception("Errore nel reperimento del file principale.");
                    }
                    //copio in un nuovo filerequest perchè putfile lo vuole senza

                    DocsPaVO.documento.Allegato allDocPrinc = new DocsPaVO.documento.Allegato();
                    allDocPrinc.descrizione = "Inoltro documento principale id: " + schedaOLD.docNumber;
                    allDocPrinc.docNumber   = schedaNEW.docNumber;
                    allDocPrinc.fileName    = getFileName(fd.name);
                    allDocPrinc.version     = "0";
                    BusinessLogic.Documenti.AllegatiManager.aggiungiAllegato(infoUtente, allDocPrinc);

                    DocsPaVO.documento.FileDocumento fdAllNew = new DocsPaVO.documento.FileDocumento();
                    DocsPaVO.documento.FileDocumento fdAll    = null;
                    fdAll = BusinessLogic.Documenti.FileManager.getFile((DocsPaVO.documento.FileRequest)schedaOLD.documenti[0], infoUtente);
                    if (fdAll == null)
                    {
                        throw new Exception("Errore nel reperimento del file principale come allegato");
                    }
                    fdAllNew.content     = fdAll.content;
                    fdAllNew.length      = fdAll.length;
                    fdAllNew.name        = fdAll.name;
                    fdAllNew.fullName    = fdAll.fullName;
                    fdAllNew.contentType = fdAll.contentType;
                    DocsPaVO.documento.FileRequest fr = (DocsPaVO.documento.FileRequest)allDocPrinc;
                    if (!BusinessLogic.Documenti.FileManager.putFile(ref fr, fdAllNew, infoUtente, out err))
                    {
                        throw new Exception(err);
                    }
                    logger.Debug("Doc principale inserito come allegato");

                    DocsPaDB.Query_DocsPAWS.Documenti doc = new DocsPaDB.Query_DocsPAWS.Documenti();
                    schedaNEW.allegati = doc.GetAllegati(schedaNEW.docNumber, string.Empty);
                }
                catch (Exception ex)
                {
                    err = "Errore nel reperimento del file principale : " + ex.Message;
                    if (schedaNEW != null && schedaNEW.systemId != null && schedaNEW.systemId != "")
                    {
                        //se il putFile va in errore devo rimuovere il profile (predisposto appena inserito)
                        BusinessLogic.Documenti.DocManager.ExecRimuoviSchedaMethod(infoUtente, schedaNEW);
                        logger.Debug("Eseguita rimozione profilo");
                    }
                    logger.Debug(err);
                    throw ex;
                }
            }
            #endregion



            err = err + " " + schedaNEW.docNumber;
            if (schedaNEW != null && schedaNEW.docNumber != null)
            {
                err = "errore " + err + " documento  rimosso: " + schedaNEW.docNumber;
            }
            else
            {
                err = "errore " + err;
            }
            logger.Debug(err);
            schedaNEW.predisponiProtocollazione = true;
            return(schedaNEW);
        }
Exemple #8
0
 public bool RemoveAttatchment(DocsPaVO.documento.Allegato allegato)
 {
     throw new NotImplementedException();
 }
Exemple #9
0
 /// <summary>
 /// Scambia il file associato ad un allegato con il file associato ad un documento
 /// </summary>
 /// <param name="allegato"></param>
 /// <param name="documento"></param>
 /// <returns></returns>
 public bool ScambiaAllegatoDocumento(DocsPaVO.documento.Allegato allegato, DocsPaVO.documento.Documento documento)
 {
     return(this.Instance.ScambiaAllegatoDocumento(allegato, documento));
 }
Exemple #10
0
 /// <summary>
 /// Rimozione di un allegato
 /// </summary>
 /// <param name="allegato"></param>
 /// <returns></returns>
 public bool RemoveAttatchment(DocsPaVO.documento.Allegato allegato)
 {
     return(this.Instance.RemoveAttatchment(allegato));
 }
Exemple #11
0
 /// <summary>
 /// Modifica di un allegato
 /// </summary>
 /// <param name="allegato"></param>
 public void ModifyAttatchment(DocsPaVO.documento.Allegato allegato)
 {
     this.Instance.ModifyAttatchment(allegato);
 }
Exemple #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="allegato"></param>
 /// <param name="putfile"></param>
 /// <returns></returns>
 public bool AddAttachment(DocsPaVO.documento.Allegato allegato, string putfile)
 {
     return(this.Instance.AddAttachment(allegato, putfile));
 }
Exemple #13
0
 public bool AddAttachment(DocsPaVO.documento.Allegato allegato, string putfile)
 {
     throw new NotImplementedException();
 }
Exemple #14
0
 public bool ScambiaAllegatoDocumento(DocsPaVO.documento.Allegato allegato, DocsPaVO.documento.Documento documento)
 {
     throw new NotImplementedException();
 }
Exemple #15
0
 /// <summary>
 /// Inserimento di un nuovo allegato per un documento(aggiunge un allegato associato ad una notifica PEC)
 /// </summary>
 /// <param name="infoUtente"></param>
 /// <param name="allegato"></param>
 /// <param name="debug"></param>
 /// <returns></returns>
 public static DocsPaVO.documento.Allegato aggiungiAllegatoPEC(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.documento.Allegato allegato)
 {
     return(aggiungiAllegato(infoUtente, allegato, false));
 }
Exemple #16
0
        /// <summary>
        /// Crea una nuova versione da un documento acquisito, se è associato un TSR, verrà unito al documento per creare un TSD
        /// </summary>
        /// <param name="infoUtente"></param>
        /// <param name="fileRequest"></param>
        /// <returns></returns>
        public static DocsPaVO.documento.FileRequest CreateTSDVersion(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.documento.FileRequest fileRequest)
        {
            byte [] lastTSR = BusinessLogic.Interoperabilità.InteroperabilitaUtils.GetTSRForDocument(infoUtente, fileRequest);
            if (lastTSR == null)
            {
                return(null);
            }

            //Conversione in TSD
            DocsPaVO.documento.FileDocumento docFile = FileManager.getFileFirmato(fileRequest, infoUtente, false);
            BusinessLogic.Documenti.DigitalSignature.VerifyTimeStamp vts = new DigitalSignature.VerifyTimeStamp();
            if (vts.Verify(docFile.content, lastTSR).esito != "OK")
            {
                return(null);
            }

            try
            {
                BusinessLogic.Documenti.DigitalSignature.PKCS_Utils.tsd        tsdMgr = new BusinessLogic.Documenti.DigitalSignature.PKCS_Utils.tsd();
                BusinessLogic.Documenti.DigitalSignature.PKCS_Utils.CryptoFile file   = new BusinessLogic.Documenti.DigitalSignature.PKCS_Utils.CryptoFile {
                    Content = docFile.content, Name = docFile.name, MessageFileType = BusinessLogic.Documenti.DigitalSignature.PKCS_Utils.fileType.Binary
                };
                List <BusinessLogic.Documenti.DigitalSignature.PKCS_Utils.CryptoFile> tsrLst  = new List <BusinessLogic.Documenti.DigitalSignature.PKCS_Utils.CryptoFile>();
                BusinessLogic.Documenti.DigitalSignature.PKCS_Utils.CryptoFile        tsrfile = new BusinessLogic.Documenti.DigitalSignature.PKCS_Utils.CryptoFile {
                    Content = lastTSR, MessageFileType = BusinessLogic.Documenti.DigitalSignature.PKCS_Utils.fileType.Binary
                };
                tsrLst.Add(tsrfile);
                docFile.content        = tsdMgr.create(file, tsrLst.ToArray()).Content;
                docFile.estensioneFile = "tsd";
                docFile.fullName       = docFile.fullName + ".tsd";
                docFile.length         = (int)docFile.content.Length;
                docFile.name           = docFile.name + ".tsd";
                docFile.nomeOriginale  = docFile.nomeOriginale + ".tsd";
            }
            catch (Exception e)
            {
                logger.ErrorFormat("Errore creando il TSD!! {0},{1}", e.Message, e.StackTrace);
                return(null);
            }
            DocsPaVO.documento.FileRequest tsdFileReq;
            if (fileRequest.GetType() == typeof(DocsPaVO.documento.Allegato))
            {
                tsdFileReq = new DocsPaVO.documento.Allegato();
                (tsdFileReq as DocsPaVO.documento.Allegato).numeroPagine = (fileRequest as DocsPaVO.documento.Allegato).numeroPagine;
            }
            else
            {
                tsdFileReq = new DocsPaVO.documento.Documento();
            }

            tsdFileReq.docNumber   = fileRequest.docNumber;
            tsdFileReq.descrizione = "Versione creata per conversione in TSD";
            tsdFileReq.firmato     = fileRequest.firmato;
            tsdFileReq             = BusinessLogic.Documenti.VersioniManager.addVersion(tsdFileReq, infoUtente, false);

            if (tsdFileReq != null)
            {
                BusinessLogic.UserLog.UserLog.WriteLog(infoUtente, "DOCUMENTOAGGIUNGIVERSIONE", tsdFileReq.docNumber, string.Format("{0}{1}{2}{3}", "Aggiunta al N.ro Doc.: ", tsdFileReq.docNumber, " la Ver. ", tsdFileReq.version + " di tipo TSD"), DocsPaVO.Logger.CodAzione.Esito.OK);
            }

            else
            {
                BusinessLogic.UserLog.UserLog.WriteLog(infoUtente, "DOCUMENTOAGGIUNGIVERSIONE", tsdFileReq.docNumber, string.Format("{0}{1}{2}{3}", "Aggiunta al N.ro Doc.: ", tsdFileReq.docNumber, " la Ver. ", tsdFileReq.version + " di tipo TSD"), DocsPaVO.Logger.CodAzione.Esito.KO);
            }


            tsdFileReq = BusinessLogic.Documenti.FileManager.putFile(tsdFileReq, docFile, infoUtente);

            List <DocsPaVO.LibroFirma.FirmaElettronica> firmaE = LibroFirma.LibroFirmaManager.GetFirmaElettronicaDaFileRequest(fileRequest);
            bool isFirmatoElettonicamente = firmaE != null && firmaE.Count > 0;

            if (isFirmatoElettonicamente)
            {
                string impronta = string.Empty;
                DocsPaDB.Query_DocsPAWS.Documenti docInfoDB = new DocsPaDB.Query_DocsPAWS.Documenti();
                docInfoDB.GetImpronta(out impronta, tsdFileReq.versionId, tsdFileReq.docNumber);

                foreach (DocsPaVO.LibroFirma.FirmaElettronica firma in firmaE)
                {
                    firma.UpdateXml(impronta, tsdFileReq.versionId, tsdFileReq.version);
                    LibroFirma.LibroFirmaManager.InserisciFirmaElettronica(firma);
                }
            }

            return(tsdFileReq);
        }
Exemple #17
0
        /// <summary>
        /// Reperimento del path
        /// </summary>
        /// <param name="attatchment"></param>
        /// <returns></returns>
        protected string GetAttatchmentFilePath(DocsPaVO.documento.Allegato attatchment)
        {
            string path = this.GetOrCreateAttatchmentFolder(attatchment);

            return(Path.Combine(path, attatchment.version));
        }
Exemple #18
0
        /// <summary>
        /// Verifica se un allegato è profilato o meno
        /// </summary>
        /// <param name="allegato"></param>
        /// <returns></returns>
        public static bool isAllegatoProfilato(DocsPaVO.documento.Allegato allegato)
        {
            DocsPaDB.Query_DocsPAWS.Documenti documentiDb = new DocsPaDB.Query_DocsPAWS.Documenti();

            return(documentiDb.isAllegatoProfilato(allegato.docNumber));
        }
Exemple #19
0
 /// <summary>
 /// Reperimento cartella nel repository per la gestione degli allegati
 /// </summary>
 /// <param name="attatchment"></param>
 /// <returns></returns>
 protected string GetOrCreateAttatchmentFolder(DocsPaVO.documento.Allegato attatchment)
 {
     return(Directory.CreateDirectory(Path.Combine(GetContextRepositoryPath(this.Context), attatchment.versionLabel)).FullName);
 }
Exemple #20
0
        /// <summary>
        /// Reperimento dell'id del documento principale
        /// </summary>
        /// <param name="allegato"></param>
        /// <returns></returns>
        public static string getIdDocumentoPrincipale(DocsPaVO.documento.Allegato allegato)
        {
            DocsPaDB.Query_DocsPAWS.Documenti documentiDb = new DocsPaDB.Query_DocsPAWS.Documenti();

            return(documentiDb.GetIdDocumentoPrincipale(allegato.docNumber));
        }
Exemple #21
0
 public void ModifyAttatchment(DocsPaVO.documento.Allegato allegato)
 {
     throw new NotImplementedException();
 }