コード例 #1
0
        public object Clone()
        {
            FileRequest fr;

            if (this.GetType().Equals(typeof(Documento)))
            {
                fr = new Documento();
            }
            else if (this.GetType().Equals(typeof(Allegato)))
            {
                fr = new Allegato();
            }
            else
            {
                fr = new FileRequest();
            }
            fr.dataInserimento = dataInserimento;
            fr.descrizione     = descrizione;
            fr.docNumber       = docNumber;
            fr.docServerLoc    = docServerLoc;
            fr.path            = path;
            fr.fileName        = fileName;
            fr.idPeople        = idPeople;
            fr.versionId       = versionId;
            fr.version         = version;
            fr.subVersion      = subVersion;
            fr.versionLabel    = versionLabel;
            fr.fileSize        = fileSize;
            fr.applicazione    = applicazione;
            fr.firmatari       = firmatari;
            return(fr);
        }
コード例 #2
0
        /// <summary>
        /// Rimozione di un allegato
        /// </summary>
        /// <param name="allegato"></param>
        /// <returns></returns>
        public bool RemoveAttatchment(DocsPaVO.documento.Allegato allegato)
        {
            bool retValue = false;

            // Creazione contesto transazionale
            using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
            {
                // nota: se cancello prima il docuemnto su docspa non riesco a risalire all'id su OCS
                // a meno chè non uso una ricerca ma al momento danno problemi!!!
                retValue = this.DocumentManagerOCS.RemoveAttatchment(allegato);

                if (retValue)
                {
                    // Se la nuova gestione degli allegati non risulta abilitata,
                    // il documento allegato viene rimosso direttamente
                    DocsPaDB.Query_DocsPAWS.Documenti dbDocumenti = new DocsPaDB.Query_DocsPAWS.Documenti();

                    // Reperimento dell'oggetto InfoDocumento relativo all'allegato
                    DocsPaVO.documento.InfoDocumento infoDocumentoAllegato = dbDocumenti.GetInfoDocumento(this.InfoUtente.idGruppo, this.InfoUtente.idPeople, allegato.docNumber, false);

                    retValue = ((DocsPaDocumentale_ETDOCS.Documentale.DocumentManager) this.DocumentManagerETDOCS).Remove(new DocsPaVO.documento.InfoDocumento[1] {
                        infoDocumentoAllegato
                    }, false);
                }

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

            return(retValue);
        }
コード例 #3
0
        /// <summary>
        /// Rimozione di un allegato
        /// </summary>
        /// <param name="allegato"></param>
        /// <returns></returns>
        public bool RemoveAttatchment(DocsPaVO.documento.Allegato allegato)
        {
            bool retValue = false;

            // Creazione contesto transazionale
            using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
            {
                // Se la nuova gestione degli allegati non risulta abilitata,
                // il documento allegato viene rimosso direttamente
                DocsPaDB.Query_DocsPAWS.Documenti dbDocumenti = new DocsPaDB.Query_DocsPAWS.Documenti();

                // Reperimento dell'oggetto InfoDocumento relativo all'allegato
                DocsPaVO.documento.InfoDocumento infoDocumentoAllegato = dbDocumenti.GetInfoDocumento(this.InfoUtente.idGruppo, this.InfoUtente.idPeople, allegato.docNumber, false);

                retValue = ((DocsPaDocumentale_ETDOCS.Documentale.DocumentManager) this.DocumentManagerETDOCS).Remove(new DocsPaVO.documento.InfoDocumento[1] {
                    infoDocumentoAllegato
                }, false);

                //quando funziona lo mettiamo in linea.. LL
                //if (retValue)
                //    retValue = this.DocumentManagerDocumentum.RemoveAttatchment(allegato);

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

            return(retValue);
        }
コード例 #4
0
        /// <summary>
        /// Inserimento di un allegato
        /// </summary>
        /// <param name="allegato"></param>
        /// <param name="putfile"></param>
        /// <returns></returns>
        public bool AddAttachment(DocsPaVO.documento.Allegato allegato, string putfile)
        {
            bool retValue = false;

            // Creazione contesto transazionale
            using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
            {
                logger.Debug("Aggiungi allegato su ETDOCS");
                retValue = this.DocumentManagerETDOCS.AddAttachment(allegato, putfile);

                if (retValue)
                {
                    logger.Debug("Creato allegato su ETDOCS con docnumer: " + allegato.docNumber + ". Aggiungo l'allegato su DOCUMENTUM");
                    retValue = this.DocumentManagerDocumentum.AddAttachment(allegato, putfile);
                    if (!retValue)
                    {
                        logger.Debug("Errore durante la creazione dell'allegato su DOCUMENTUM con docnumber " + allegato.docNumber);
                    }
                }
                else
                {
                    logger.Debug("Errore durante la creazione dell'allegato su ETDOCS");
                }

                if (retValue)
                {
                    logger.Debug("Allegato creato correttamente con docnumber " + allegato.docNumber);
                    transactionContext.Complete();
                }
            }

            return(retValue);
        }
コード例 #5
0
        private DocsPaVO.InstanceAccess.Metadata.Allegato[] getAllegati(DocsPaVO.documento.SchedaDocumento schDoc, InstanceAccessDocument doc, DocsPaVO.utente.InfoUtente infoUtente)
        {
            if (schDoc.allegati == null)
            {
                return(null);
            }
            if (schDoc.allegati.Count == 0)
            {
                return(null);
            }

            List <DocsPaVO.InstanceAccess.Metadata.Allegato> lstAll = new List <DocsPaVO.InstanceAccess.Metadata.Allegato>();

            foreach (object a in schDoc.allegati)
            {
                DocsPaVO.InstanceAccess.Metadata.Allegato allegato = new DocsPaVO.InstanceAccess.Metadata.Allegato();
                DocsPaVO.documento.Allegato all = a as DocsPaVO.documento.Allegato;
                if (all != null && (from att in doc.ATTACHMENTS where att.ID_ATTACH.Equals(all.docNumber) select att.ENABLE).FirstOrDefault())
                {
                    allegato.Descrizione = all.descrizione;
                    allegato.ID          = all.docNumber;
                    //allegato.Tipo = "manuale"; //Cablato , per ora.. poi si vedrà
                    string tipoAllegato = "";
                    switch (all.TypeAttachment)
                    {
                    case 1:
                        tipoAllegato = "Allegato Utente";
                        break;

                    case 2:
                        tipoAllegato = "Allegato PEC";
                        break;

                    case 3:
                        tipoAllegato = "Allegato IS";
                        break;

                    case 4:
                        tipoAllegato = "Allegato Esterno";
                        break;

                    default:
                        tipoAllegato = "Non specificato";
                        break;
                    }
                    allegato.Tipo = tipoAllegato;

                    if (!string.IsNullOrEmpty(all.fileSize) && Convert.ToInt32(all.fileSize) > 0)
                    {
                        FileDocumento fd = BusinessLogic.Documenti.FileManager.getFile(all, infoUtente);
                        allegato.File = getFileDetail(fd, all, infoUtente);
                    }
                    lstAll.Add(allegato);
                }
            }
            return(lstAll.ToArray());
        }
コード例 #6
0
        private bool ScambiaFile(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.documento.Allegato allegato, DocsPaVO.documento.Documento documento)
        {
            bool retValue = false;

            using (DocsPaDB.DBProvider dbProvider = new DocsPaDB.DBProvider())
            {
                DataRow rowDocumento = this.GetDatiScambiaAllegato(documento.versionId, dbProvider);
                DataRow rowAllegato  = this.GetDatiScambiaAllegato(allegato.versionId, dbProvider);

                // Aggiornamento record VERSIONS per l'allegato con i dati del documento
                retValue = this.UpdateVersionScambiaAllegato(allegato.versionId,
                                                             DocsPaUtils.Data.DataReaderHelper.GetValue <object>(rowDocumento, "SUBVERSION", false).ToString(),
                                                             DocsPaUtils.Data.DataReaderHelper.GetValue <object>(rowDocumento, "CARTACEO", true, string.Empty).ToString(),
                                                             DocsPaUtils.Data.DataReaderHelper.GetValue <object>(rowDocumento, "SCARTA_FASC_CARTACEA", true, string.Empty).ToString(),
                                                             dbProvider);

                if (retValue)
                {
                    // Aggiornamento record VERSIONS per il documento con i dati dell'allegato
                    retValue = this.UpdateVersionScambiaAllegato(documento.versionId,
                                                                 DocsPaUtils.Data.DataReaderHelper.GetValue <object>(rowAllegato, "SUBVERSION", false).ToString(),
                                                                 DocsPaUtils.Data.DataReaderHelper.GetValue <object>(rowAllegato, "CARTACEO", true, string.Empty).ToString(),
                                                                 DocsPaUtils.Data.DataReaderHelper.GetValue <object>(rowAllegato, "SCARTA_FASC_CARTACEA", true, string.Empty).ToString(),
                                                                 dbProvider);
                }

                if (retValue)
                {
                    // Aggiornamento record COMPONENTS per l'allegato con i dati del documento
                    //bisogna calcolare il path: in realtà quello che cambia è solo l'estensione del file
                    string pathDocumento = DocsPaUtils.Data.DataReaderHelper.GetValue <object>(rowDocumento, "PATH", true, string.Empty).ToString();
                    string pathAllegato  = DocsPaUtils.Data.DataReaderHelper.GetValue <object>(rowAllegato, "PATH", true, string.Empty).ToString();
                    string estDoc        = pathDocumento.Substring(pathDocumento.LastIndexOf("."));
                    string estAll        = pathAllegato.Substring(pathAllegato.LastIndexOf("."));
                    string newPathDoc    = documento.docNumber + estAll;
                    string newPathAll    = allegato.docNumber + estDoc;
                    retValue = this.UpdateComponentsScambiaAllegato(allegato.versionId,
                                                                    //DocsPaUtils.Data.DataReaderHelper.GetValue<object>(rowDocumento, "PATH", true, string.Empty).ToString(),
                                                                    newPathAll,
                                                                    DocsPaUtils.Data.DataReaderHelper.GetValue <object>(rowDocumento, "FILE_SIZE", true, string.Empty).ToString(),
                                                                    DocsPaUtils.Data.DataReaderHelper.GetValue <object>(rowDocumento, "VAR_IMPRONTA", true, string.Empty).ToString(), dbProvider);

                    if (retValue)
                    {
                        // Aggiornamento record COMPONENTS per il documento con i dati dell'allegato
                        retValue = this.UpdateComponentsScambiaAllegato(documento.versionId,
                                                                        //DocsPaUtils.Data.DataReaderHelper.GetValue<object>(rowAllegato, "PATH", true, string.Empty).ToString(),
                                                                        newPathDoc,
                                                                        DocsPaUtils.Data.DataReaderHelper.GetValue <object>(rowAllegato, "FILE_SIZE", true, string.Empty).ToString(),
                                                                        DocsPaUtils.Data.DataReaderHelper.GetValue <object>(rowAllegato, "VAR_IMPRONTA", true, string.Empty).ToString(),
                                                                        dbProvider);
                    }
                }
            }

            return(retValue);
        }
コード例 #7
0
        private Metadata.Documento.Allegato[] getAllegati(DocsPaVO.documento.SchedaDocumento schDoc, DocsPaVO.utente.InfoUtente infoUtente)
        {
            if (schDoc.allegati == null)
            {
                return(null);
            }
            if (schDoc.allegati.Count == 0)
            {
                return(null);
            }

            List <Metadata.Documento.Allegato> lstAll = new List <Documento.Allegato>();

            foreach (object a in schDoc.allegati)
            {
                DocsPaConservazione.Metadata.Documento.Allegato allegato = new Metadata.Documento.Allegato();
                DocsPaVO.documento.Allegato all = a as DocsPaVO.documento.Allegato;
                if (all != null)
                {
                    allegato.Descrizione = all.descrizione;
                    allegato.ID          = all.docNumber;
                    //allegato.Tipo = "manuale"; //Cablato , per ora.. poi si vedrà
                    string tipoAllegato = "";
                    switch (all.TypeAttachment)
                    {
                    case 1:
                        tipoAllegato = "Allegato Utente";
                        break;

                    case 2:
                        tipoAllegato = "Allegato PEC";
                        break;

                    case 3:
                        tipoAllegato = "Allegato IS";
                        break;

                    case 4:
                        tipoAllegato = "Allegato Esterno";
                        break;

                    default:
                        tipoAllegato = "Non specificato";
                        break;
                    }
                    allegato.Tipo = tipoAllegato;

                    FileDocumento fd = BusinessLogic.Documenti.FileManager.getFile(all, infoUtente);
                    allegato.File = getFileDetail(fd, all, infoUtente);
                    lstAll.Add(allegato);
                }
            }
            return(lstAll.ToArray());
        }
コード例 #8
0
 /// <summary>
 /// Modifica di un allegato
 /// </summary>
 /// <param name="allegato"></param>
 public void ModifyAttatchment(DocsPaVO.documento.Allegato allegato)
 {
     try
     {
         this.DocumentManagerETDOCS.ModifyAttatchment(allegato);
     }
     catch (Exception ex)
     {
         string errorMessage = string.Format("Errore nella modifica dell'allegato: {0}", ex.Message);
         logger.Debug(errorMessage, ex);
     }
 }
コード例 #9
0
        /// <summary>
        /// Modifica di un allegato
        /// </summary>
        /// <param name="allegato"></param>
        public void ModifyAttatchment(DocsPaVO.documento.Allegato allegato)
        {
            // Creazione contesto transazionale
            using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
            {
                this.DocumentManagerETDOCS.ModifyAttatchment(allegato);

                this.DocumentManagerOCS.ModifyAttatchment(allegato);

                transactionContext.Complete();
            }
        }
コード例 #10
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)
        {
            bool retValue = false;

            try
            {
                retValue = this.DocumentManagerETDOCS.ScambiaAllegatoDocumento(allegato, documento);
            }
            catch (Exception ex)
            {
                string errorMessage = string.Format("Errore nell'operazione 'ScambiaAllegatoDocumento': {0}", ex.Message);
                logger.Debug(errorMessage, ex);

                retValue = false;
            }

            return(retValue);
        }
コード例 #11
0
        /// <summary>
        /// Inserimento di un allegato
        /// </summary>
        /// <param name="allegato"></param>
        /// <param name="putfile"></param>
        /// <returns></returns>
        public bool AddAttachment(DocsPaVO.documento.Allegato allegato, string putfile)
        {
            bool retValue = false;

            // Creazione contesto transazionale
            using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
            {
                retValue = this.DocumentManagerETDOCS.AddAttachment(allegato, putfile);



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

            return(retValue);
        }
コード例 #12
0
        public string InviaRelata(byte[] fileReleata, String Stato, string token)
        {
            AlboToken   at        = new AlboToken();
            AlboTokenVO tvo       = at.DecryptToken(token);
            String      docNumber = tvo.DocNumber;
            String      nomeFile  = "Relata.pdf";

            string IdAmministrazione = BusinessLogic.Utenti.UserManager.getIdAmmUtente(tvo.userID);

            DocsPaVO.utente.Utente utente = BusinessLogic.Utenti.UserManager.getUtente(tvo.userID, IdAmministrazione);
            utente.dst = BusinessLogic.Utenti.UserManager.getSuperUserAuthenticationToken();
            if (utente == null)
            {
                throw new ApplicationException(string.Format("Utente {0} non trovato", tvo.userID));
            }

            DocsPaVO.utente.Ruolo[] ruoli = (DocsPaVO.utente.Ruolo[])BusinessLogic.Utenti.UserManager.getRuoliUtente(utente.idPeople).ToArray(typeof(DocsPaVO.utente.Ruolo));

            if (ruoli != null && ruoli.Length > 0)
            {
                throw new ApplicationException("L'utente non non risulta associato ad alcun ruolo");
            }

            DocsPaVO.utente.InfoUtente infoUtente = new DocsPaVO.utente.InfoUtente(utente, ruoli[0]);

            DocsPaVO.documento.Allegato all = new DocsPaVO.documento.Allegato();
            all.descrizione = "Relata di Pubblicazione";

            all.docNumber    = docNumber;
            all.fileName     = nomeFile;
            all.version      = "0";
            all.numeroPagine = 1;
            DocsPaVO.documento.Allegato allIns = null;
            String err = String.Empty;

            try
            {
                allIns = BusinessLogic.Documenti.AllegatiManager.aggiungiAllegato(infoUtente, all);
            }
            catch (Exception ex)
            {
                logger.DebugFormat("Problemi nell'inserire l'allegato per la relata di pubblicazione {0} \r\n {1}", ex.Message, ex.StackTrace);
            }

            try
            {
                DocsPaVO.documento.SchedaDocumento sd    = BusinessLogic.Documenti.DocManager.getDettaglioNoSecurity(infoUtente, docNumber);
                DocsPaVO.documento.FileDocumento   fdAll = new DocsPaVO.documento.FileDocumento();
                fdAll.content = fileReleata;
                fdAll.length  = fileReleata.Length;

                fdAll.name = nomeFile;
                fdAll.bypassFileContentValidation = true;
                DocsPaVO.documento.FileRequest fRAll = (DocsPaVO.documento.FileRequest)sd.documenti[0];
                fRAll = (DocsPaVO.documento.FileRequest)all;
                if (fdAll.content.Length > 0)
                {
                    logger.Debug("controllo se esiste l'ext");
                    if (!BusinessLogic.Documenti.DocManager.esistiExt(nomeFile))
                    {
                        BusinessLogic.Documenti.DocManager.insertExtNonGenerico(nomeFile, "application/octet-stream");
                    }

                    if (!BusinessLogic.Documenti.FileManager.putFile(ref fRAll, fdAll, infoUtente, out err))
                    {
                        logger.Debug("errore durante la putfile");
                    }
                }
            }
            catch (Exception ex)
            {
                if (err == "")
                {
                    err = string.Format("Errore nel reperimento del file allegato: {0}.  {1}", nomeFile, ex.Message);
                }
                BusinessLogic.Documenti.AllegatiManager.rimuoviAllegato(all, infoUtente);
                logger.Debug(err);
            }


            //Mettere il cambio di stato.

            return("OK");
        }
コード例 #13
0
 private static string GetNomeDocumento(DocsPaVO.documento.Allegato allegato)
 {
     return(GetValidName(allegato.docNumber));
 }
コード例 #14
0
        private static string cleanOriginalFileNameAllegato(DocsPaVO.utente.InfoUtente infoUtente, DocsPaVO.documento.InfoDocumento documento, DocsPaVO.documento.Allegato allegato)
        {
            string nomeDocumento    = GetNomeDocumento(documento);
            string nomeAllegato     = GetNomeDocumento(allegato);
            string originalFileName = getOriginalFileName(infoUtente, allegato.docNumber);
            string nameSepa         = "_";

            if (originalFileName.Contains(nomeDocumento))
            {
                originalFileName = originalFileName.Replace(nomeDocumento, String.Empty);
            }

            if (originalFileName.Contains(nomeAllegato))
            {
                originalFileName = originalFileName.Replace(nomeAllegato, String.Empty);
            }

            if (originalFileName.EndsWith("_"))
            {
                originalFileName = originalFileName.Remove(originalFileName.Length - 1);
            }

            string AllSepa = "-All-";

            string nome = String.Format("{0}{1}{2}", String.Format("{0}{1}{2}", nomeDocumento, AllSepa, nomeAllegato), nameSepa, originalFileName);

            return(nome);
        }
コード例 #15
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;
        }
コード例 #16
0
        public bool ManageAttachXML(DocsPaVO.documento.SchedaDocumento schedaDocOriginale, DocsPaVO.documento.SchedaDocumento schedaDocCopiato, string IdRuoloMittenteFisico, DocsPaVO.utente.InfoUtente infoUtenteInterop)
        {
            //****************************************************************************************************************//
            // Modifica Evolutiva di Giordano Iacozzilli Data: 27/04/2012
            //
            // La presidenza del Consiflio dei Ministri richiede la possibilità di inviare via Interoperabilità interna,
            // al Registro dell'Ufficio UBRRAC un file Xml contenente un insieme di dati integrativi associati ad alcune tipologie
            // di documenti prodotti dai centri di spesa per una successiva elaboraizone dal sistema OpenDGov.
            //
            //Workflow:
            // 1) Controllo presenza su db del codice FE_ATTACH_XML nella Config Globali
            // 2) Se il controllo è ok, verifico che il tipo doc sia compreso nella lista dei tipi ammessi(GET DEI TIPI DOC COL PIPE DAL DB).
            // 3) Verifico che il mio Ruolo abbia la visibilità su tutti i campi, altrimenti nada.
            // 4) Creo L'xml e lo allego alla scheda Doc
            //
            //****************************************************************************************************************//

            //Doppio controllo, interop Semplificata e Xml Attach.
            if (System.Configuration.ConfigurationManager.AppSettings["INTEROP_INT_NO_MAIL"] != null &&
                System.Configuration.ConfigurationManager.AppSettings["INTEROP_INT_NO_MAIL"].ToString() != "0")
            {
                //1) Controllo presenza su db del codice FE_ATTACH_XML nella Config Globali
                if (GET_XML_ATTACH())
                {
                    //Get Template.
                    DocsPaVO.ProfilazioneDinamica.Templates template = (schedaDocOriginale.template);
                    string err = string.Empty;
                    //verifico che il tipo doc sia compreso nella lista dei tipi ammessi
                    if (template != null && GET_TIPI_ATTI_CUSTOM().Contains(ClearString(GetDescrTipoAtto(template.ID_TIPO_ATTO, infoUtenteInterop.idAmministrazione))))
                    {
                        DocsPaVO.ProfilazioneDinamica.AssDocFascRuoli _ass = new AssDocFascRuoli();
                        //Verifico che il mio Ruolo abbia la visibilità su tutti i campi, altrimenti nada.
                        int _totCampi  = template.ELENCO_OGGETTI.Count;
                        int _ContCampi = 0;

                        for (int i = 0; i < template.ELENCO_OGGETTI.Count; i++)
                        {
                            OggettoCustom oggettoCustom = (OggettoCustom)template.ELENCO_OGGETTI[i];
                            // visibilità.
                            _ass = ProfilazioneDinamica.ProfilazioneDocumenti.getDirittiCampoTipologiaDoc(IdRuoloMittenteFisico, template.SYSTEM_ID.ToString(), oggettoCustom.SYSTEM_ID.ToString());
                            if (_ass.VIS_OGG_CUSTOM == "1")
                            {
                                _ContCampi = _ContCampi + 1;
                            }
                        }

                        //Verifico che il mio Ruolo abbia la visibilità su tutti i campi
                        if (_ContCampi == _totCampi)
                        {
                            if (schedaDocCopiato.documenti != null && schedaDocCopiato.documenti[0] != null)
                            {
                                try
                                {
                                    Dictionary <string, string> _dict = new Dictionary <string, string>();
                                    foreach (OggettoCustom oggettoCustom in template.ELENCO_OGGETTI)
                                    {
                                        _dict.Add(oggettoCustom.DESCRIZIONE, oggettoCustom.VALORE_DATABASE);
                                    }
                                    //Creo L'xml e lo allego alla scheda Doc
                                    XmlDocument xDocDaAllegare = new XmlDocument();
                                    xDocDaAllegare = CreateXmlToAttach(_dict, schedaDocCopiato, GetDescrTipoAtto(template.ID_TIPO_ATTO, infoUtenteInterop.idAmministrazione));

                                    DocsPaVO.documento.Allegato allegato = null;

                                    //Add Allegato:
                                    allegato              = new DocsPaVO.documento.Allegato();
                                    allegato.descrizione  = GetDescrTipoAtto(template.ID_TIPO_ATTO, infoUtenteInterop.idAmministrazione) + "_XML";
                                    allegato.numeroPagine = 1;
                                    allegato.docNumber    = schedaDocCopiato.docNumber;
                                    allegato.version      = "0";
                                    allegato.position     = (schedaDocOriginale.allegati.Count + 1);

                                    allegato = BusinessLogic.Documenti.AllegatiManager.aggiungiAllegato(infoUtenteInterop, allegato);

                                    //Add del File xml come filedocumento:
                                    DocsPaVO.documento.FileDocumento fdAllNew = new DocsPaVO.documento.FileDocumento();
                                    fdAllNew.content     = Encoding.UTF8.GetBytes(xDocDaAllegare.OuterXml);
                                    fdAllNew.length      = Encoding.UTF8.GetBytes(xDocDaAllegare.OuterXml).Length;
                                    fdAllNew.name        = GetDescrTipoAtto(template.ID_TIPO_ATTO, infoUtenteInterop.idAmministrazione) + "_XML" + ".xml";
                                    fdAllNew.fullName    = fdAllNew.name;
                                    fdAllNew.contentType = "text/xml";
                                    DocsPaVO.documento.FileRequest fr = (DocsPaVO.documento.FileRequest)allegato;
                                    if (!BusinessLogic.Documenti.FileManager.putFile(ref fr, fdAllNew, infoUtenteInterop, out err))
                                    {
                                        throw new Exception(err);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    err = ex.Message;
                                    throw ex;
                                }
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }