示例#1
0
        /// <summary>
        /// Funzione per l'estrazione dei dati dal foglio Excel
        /// </summary>
        /// <param name="content">Il contenuto del foglio Excel</param>
        /// <param name="fileName">Il nome da attribuire al file</param>
        /// <returns>L'oggetto con i dati sui documenti da importare</returns>
        public static DocumentRowDataContainer ReadRDEDataFromExcel(
            byte[] content,
            string fileName)
        {
            // Istanziazione del web service
            DocsPaWebService ws = new DocsPaWebService();

            // Impostazione del timeout
            ws.Timeout = System.Threading.Timeout.Infinite;

            // L'oggetto da restiture
            DocumentRowDataContainer toReturn = null;

            // L'eventuale errore avvenuto in fase di estrazione dati
            string errorMessage = String.Empty;

            try
            {
                // Chiamata del metodo web per l'estrazione dei dati dal foglio Excel
                toReturn = ws.ReadRDEDataFromExcel(
                    content,
                    fileName,
                    IsEnabledOwnerProto() ? 2 : 1,
                    out errorMessage);

                // Se si è verificato un errore un esecuzione, viene lanciata un'eccezione con il
                // dettaglio
                if (toReturn == null ||
                    !String.IsNullOrEmpty(errorMessage))
                {
                    throw new Exception(errorMessage);
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(toReturn);
        }
示例#2
0
        protected void BtnUploadHidden_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "reallowOp", "reallowOp();", true);

            if (this.fileUpload != null && !string.IsNullOrEmpty(this.fileUpload.Value) && this.fileUpload.PostedFile.FileName.ToLower().EndsWith("xls"))
            {
                // Nel CallContext inserisco nome del file(con estensione) a partire dal path del file di import
                this.importFileName = Path.GetFileName(this.fileUpload.Value);

                // Prelevamento del contenuto del file
                HttpPostedFile p       = this.fileUpload.PostedFile;
                Stream         fs      = p.InputStream;
                byte[]         content = new byte[fs.Length];
                fs.Read(content, 0, (int)fs.Length);
                fs.Close();

                if (content.Length > 0)
                {
                    // Creazione del nome per il file temporaneo
                    string temporaryFileName = String.Format("{0}.xls", Guid.NewGuid().ToString());

                    // Prelevamento del serverPath
                    string serverPath = utils.getHttpFullPath();

                    try
                    {
                        // Disassociazione delle sorgenti dati
                        this.grdAllegati.DataSource = null;
                        this.grdArrivo.DataSource   = null;
                        this.grdGenerale.DataSource = null;
                        this.grdGrigi.DataSource    = null;
                        this.grdInterni.DataSource  = null;
                        this.grdPartenza.DataSource = null;
                        this.grdAllegati.DataBind();
                        this.grdArrivo.DataBind();
                        this.grdGenerale.DataBind();
                        this.grdGrigi.DataBind();
                        this.grdInterni.DataBind();
                        this.grdPartenza.DataBind();

                        // Reperimento delle informazioni sui documenti da importare
                        string error;
                        DocumentRowDataContainer drdc = ImportDocumentManager.ReadDocumentDataFromExcelFile(
                            content,
                            UserManager.GetInfoUser(),
                            RoleManager.GetRoleInSession(),
                            !this.StampaUnione,
                            out error);

                        if (String.IsNullOrEmpty(error))
                        {
                            // Reperimento del numero massimo di documenti importabili
                            int maxNumber = ImportDocumentManager.GetMaxDocumentsNumber(UserManager.GetInfoUser());

                            // Se maxNumber è più minore del numero di documenti estratti dal foglio excel
                            if (maxNumber < drdc.AttachmentDocument.Length +
                                drdc.GrayDocument.Length +
                                drdc.InDocument.Length +
                                drdc.OutDocument.Length +
                                drdc.OwnDocument.Length)
                            {
                                ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorImportDocumentsMaxNumber', 'warning', '', '" + utils.FormatJs(maxNumber.ToString()) + "');", true);
                                return;
                            }

                            // Creazione di un nuovo oggetto cui delegare l'importazione dei documenti
                            this.importExecutor = new ImportDocumentExecutor(this.StampaUnione);

                            importExecutor.ExecuteImport(
                                new object[] {
                                drdc,
                                utils.getHttpFullPath(),
                                UserManager.GetInfoUser(),
                                RoleManager.GetRoleInSession()
                            });

                            int analyzedDocument, totalDocument;
                            // Si richiedono le statistiche
                            importExecutor.GetStatistics(out analyzedDocument, out totalDocument);

                            // Viene prelevato il report
                            report = importExecutor.GetReport();
                        }
                        else
                        {
                            report            = new ResultsContainer();
                            report.General    = new ImportResult[1];
                            report.General[0] = new ImportResult()
                            {
                                Outcome = OutcomeEnumeration.KO,
                                Message = error
                            };
                        }
                        // Se il report Generale non contiene elementi, viene aggiunto un
                        // result positivo
                        if (report.General == null || report.General.Length == 0)
                        {
                            report.General = new ImportResult[1];

                            report.General[0] = new ImportResult()
                            {
                                Outcome = OutcomeEnumeration.NONE,
                                Message = "Il processo di importazione è terminato."
                            };
                        }

                        // Associazione degli array dei risultati alle varie griglia
                        this.grdGenerale.DataSource = report.General;
                        this.grdArrivo.DataSource   = report.InDocument;
                        this.grdPartenza.DataSource = report.OutDocument;
                        this.grdInterni.DataSource  = report.OwnDocument;
                        this.grdGrigi.DataSource    = report.GrayDocument;
                        this.grdAllegati.DataSource = report.Attachment;

                        // Binding delle sorgenti dati
                        this.grdGenerale.DataBind();
                        this.grdArrivo.DataBind();
                        this.grdPartenza.DataBind();
                        this.grdInterni.DataBind();
                        this.grdGrigi.DataBind();
                        this.grdAllegati.DataBind();

                        this.plcReport.Visible = true;
                        this.upReport.Update();

                        // Creazione del data set per l'esportazione del report di importazione
                        DataSet dataSet = this.GenerateDataSet(report);

                        // Path e nome file del template
                        string templateFilePath = Server.MapPath("formatPdfExport.xml");

                        // Aggiunta nell call context del file documento  con le informazioni
                        // da scivere nel report
                        this.reportImport =
                            global::ProspettiRiepilogativi.Frontend.PdfReport.do_MakePdfReport(
                                global::ProspettiRiepilogativi.Frontend.ReportDisponibili.ReportLogMassiveImport,
                                templateFilePath,
                                dataSet,
                                null);

                        //// Abilitazione pulsante esportazione
                        //this.BtnReportExport.Enabled = true;

                        //link di scarica zip
                        if (this.StampaUnione)
                        {
                            this.lnkDownload.Visible = true;
                        }

                        // Aggiornamento pannello bottoniera
                        //this.BtnImport.Enabled = false;
                        this.UpPnlButtons.Update();
                    }
                    catch (Exception ex)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorCustom', 'error', '', '" + utils.FormatJs(ex.Message) + "');", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorImportDocumentsFileInvalid', 'error', '');", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorImportDocumentsFileInvalid', 'error', '');", true);
            }
        }
示例#3
0
        /// <summary>
        /// Funzione per la lettura dei metadati da un foglio excel
        /// </summary>
        /// <param name="completePath">Il path in cui reprire il file excel</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="isEnabledPregressi">True se è abilitato l'import dei documenti pregressi</param>
        /// <returns>L'oggetto con i metadati estratti dal foglio excel</returns>
        private static DocumentRowDataContainer ReadMetadata(
            string completePath,
            InfoUtente userInfo,
            Ruolo role,
            bool isEnabledPregressi,
            bool isStampaUnione,
            String provider,
            String extendedProperty)
        {
            #region Dichiarazione variabili

            // La stringa di connessione al foglio excel
            string connectionString = String.Empty;

            // L'oggetto utilizzato per connettersi al foglio excel
            OleDbConnection oleConnection = null;

            // L'oggetto utilizzato per eseguire un comando sul file excel
            OleDbCommand oleCommand = null;

            // L'oggetto utilizzato per leggere i dati dal file excel
            OleDbDataReader dataReader = null;

            // L'oggetto da restituire
            DocumentRowDataContainer toReturn;

            #endregion

            #region Connessione al foglio excel

            try
            {
                // Creazione dell'oggetto per la connessione al foglio excel
                oleConnection = ImportUtils.ConnectToFile(provider, extendedProperty, completePath);
            }
            catch (Exception e)
            {
                // Viene rilanciata un'eccezione al livello superiore
                throw new Exception("Errore durante la connessione al file excel. Dettagli: " + e.Message);
            }

            #endregion

            // Creazione dell'oggetto da restituire
            toReturn = new DocumentRowDataContainer();



            #endregion

            #region Selezione dei dati sui documenti in partenza da importare e importazione

            try
            {
                // Creazione della query per la selezione dei dati sui documenti in partenza da importare
                oleCommand = new OleDbCommand("SELECT * FROM [Partenza$]", oleConnection);

                // Esecuzione della query per il recupero dei dati
                dataReader = oleCommand.ExecuteReader();
            }
            catch (Exception e)
            {
                dataReader.Close();
                throw new Exception("Errore durante il recupero dei dati sui documenti in uscita da importare. Dettagli: " + e.Message);
            }

            // Se il recupero dei dati è andato a buon fine, si procede con la loro importazione
            try
            {
                if (dataReader != null)
                {
                    toReturn.OutDocument = new OutDocument().ReadMetaData(dataReader, userInfo, role, isEnabledPregressi);
                }
            }
            catch (Exception e)
            {
                dataReader.Close();
                throw e;
            }
            #endregion

            #region Selezione dei dati sui documenti interni da importare e importazione

            try
            {
                // Creazione della query per la selezione dei dati sui documenti interni da importare
                oleCommand = new OleDbCommand("SELECT * FROM [Interni$]", oleConnection);

                // Esecuzione della query per il recupero dei dati
                dataReader = oleCommand.ExecuteReader();
            }
            catch (Exception e)
            {
                dataReader.Close();
                throw new Exception("Errore durante il recupero dei dati sui documenti interni da importare. Dettagli: " + e.Message);
            }

            // Se il recupero dei dati è andato a buon fine, si procede con la loro importazione
            try
            {
                if (dataReader != null)
                {
                    toReturn.OwnDocument = new OwnDocument().ReadMetaData(dataReader, userInfo, role, isEnabledPregressi);
                }
            }
            catch (Exception e)
            {
                dataReader.Close();
                throw e;
            }

            #endregion

            #region Selezione dei dati sui documenti non protocollati da importare e importazione

            try
            {
                // Creazione della query per la selezione dei dati sui documenti non protocollati da importare
                oleCommand = new OleDbCommand("SELECT * FROM [Non protocollati$]", oleConnection);

                // Esecuzione della query per il recupero dei dati
                dataReader = oleCommand.ExecuteReader();
            }
            catch (Exception e)
            {
                dataReader.Close();
                throw new Exception("Errore durante il recupero dei dati sui documenti non protocollati da importare. Dettagli: " + e.Message);
            }

            // Se il recupero dei dati è andato a buon fine, si procede con la loro importazione
            try
            {
                if (dataReader != null)
                {
                    toReturn.GrayDocument = new GrayDocument().ReadMetaData(dataReader, userInfo, role, isEnabledPregressi);
                }
            }
            catch (Exception e)
            {
                dataReader.Close();
                throw e;
            }

            #endregion

            #region Selezione dei dati sui documenti allegati da importare e importazione
            if (isStampaUnione)
            {
                try
                {
                    // Creazione della query per la selezione dei dati sui documenti allegati da importare
                    oleCommand = new OleDbCommand("SELECT * FROM [Allegati$]", oleConnection);

                    // Esecuzione della query per il recupero dei dati
                    dataReader = oleCommand.ExecuteReader();
                }
                catch (Exception e)
                {
                    dataReader.Close();
                    throw new Exception("Errore durante il recupero dei dati sugli allegati da importare. Dettagli: " + e.Message);
                }

                // Se il recupero dei dati è andato a buon fine, si procede con la loro importazione
                try
                {
                    if (dataReader != null)
                    {
                        toReturn.AttachmentDocument = new Attachment().ReadMetaData(dataReader, userInfo, role, isEnabledPregressi);
                    }
                }
                catch (Exception e)
                {
                    dataReader.Close();
                    throw e;
                }

                #region Selezione dei dati sui documenti in arrivo da importare e importazione

                try
                {
                    // Creazione della query per la selezione dei dati sui documenti in arrivo da importare
                    oleCommand = new OleDbCommand("SELECT * FROM [Arrivo$]", oleConnection);

                    // Esecuzione della query per il recupero dei dati
                    dataReader = oleCommand.ExecuteReader();
                }
                catch (Exception e)
                {
                    dataReader.Close();

                    throw new Exception("Errore durante il recupero dei dati sui documenti in arrivo da importare. Dettagli: " + e.Message);
                }

                // Se il recupero dei dati è andato a buon fine, si procede con la loro importazione
                try
                {
                    if (dataReader != null)
                    {
                        toReturn.InDocument = new InDocument().ReadMetaData(dataReader, userInfo, role, isEnabledPregressi);
                    }
                }
                catch (Exception e)
                {
                    dataReader.Close();
                    throw e;
                }
            }
            else
            {
                toReturn.AttachmentDocument = new List <DocumentRowData>();
                toReturn.InDocument         = new List <DocumentRowData>();
            }
            #endregion

            #region Chiusura connessione

            try
            {
                // Chiusura della connessione
                oleConnection.Close();
            }
            catch (Exception e)
            { }

            #endregion

            // Restituzione del risultato dell'importazione
            return(toReturn);
        }
示例#4
0
        /// <summary>
        /// Funzione per l'importazione dei documenti
        /// </summary>
        /// <param name="completePath">Il path in cui è memorizzato il file temporaneo</param>
        /// <param name="userInfo">Le informazioni sull'utente cha ha lanciato la procedura</param>
        /// <param name="role">Il ruolo con cui è stata lanciata la procedura</param>
        /// <param name="serverPath">L'indirizzo della WA</param>
        /// <param name="isRapidClassificationRequired">True se è richiesta classificazione rapida obbligatoria</param>
        /// <param name="isSmistamentoEnabled">True se è abilitato lo smistamento</param>
        /// <returns></returns>
        private static ResultsContainer CreateDocuments(DocumentRowDataContainer container, InfoUtente userInfo, Ruolo role, string serverPath, bool isRapidClassificationRequired, bool isSmistamentoEnabled, string ftpAddress, String ftpUsername, String ftpPassword, bool isEnabledPregressi)
        {
            #region Dichiarazione variabili

            // La stringa di connessione al foglio excel
            string connectionString = String.Empty;

            // Il risultato dell'elaborazione
            ResultsContainer result = null;

            // La lista di funzioni associate al ruolo
            Funzione[] functions = null;

            // Un booleano utilizzato per tesare se con il ruolo segnalato può creare
            // creato un documento di un certo tipo
            bool canCreateDocuments = false;

            #endregion

            // Creazione della lista dei risultati
            result = new ResultsContainer();

            // Recupero delle funzioni associate al ruolo
            functions = (Funzione[])role.funzioni.ToArray(typeof(Funzione));

            #region Creazione documenti di emergenza in Arrivo

            // Verifica della possibilità di creare documenti in arrivo con il ruolo
            // role
            canCreateDocuments = functions.Where(e => e.codice == "PROTO_IN").FirstOrDefault() != null;

            // Se con il ruolo corrente è possibile creare documenti in arrivo,
            // si procede alla creazione
            if (canCreateDocuments)
            {
                // Se la lista dei documenti in Arrivo in è valorizzata, si procede con l'importazione
                if (container.InDocument != null)
                {
                    result.InDocument.AddRange(new InDocument().ImportDocuments(
                                                   container.InDocument,
                                                   userInfo,
                                                   role,
                                                   serverPath,
                                                   false,
                                                   isRapidClassificationRequired,
                                                   ftpAddress,
                                                   false,
                                                   isSmistamentoEnabled,
                                                   "A",
                                                   ftpUsername,
                                                   ftpPassword,
                                                   isEnabledPregressi));
                }
            }
            else
            {
                // Altrimenti aggiunta di un result negativo
                result.InDocument.Add(new ImportResult()
                {
                    Outcome = ImportResult.OutcomeEnumeration.KO,
                    Message = "Ruolo non abilitato alla creazione di documenti in arrivo."
                });
            }

            #endregion

            #region Creazione documenti di emergenza in Partenza

            // Verifica della possibilità di creare documenti in uscita con il ruolo
            // role
            canCreateDocuments = functions.Where(e => e.codice == "PROTO_OUT").FirstOrDefault() != null;

            // Se con il ruolo corrente è possibile creare documenti in partenza,
            // si procede alla creazione
            if (canCreateDocuments)
            {
                if (container.OutDocument != null)
                {
                    result.OutDocument.AddRange(new OutDocument().ImportDocuments(
                                                    container.OutDocument,
                                                    userInfo,
                                                    role,
                                                    serverPath,
                                                    false,
                                                    isRapidClassificationRequired,
                                                    ftpAddress,
                                                    false,
                                                    isSmistamentoEnabled,
                                                    "P",
                                                    ftpUsername,
                                                    ftpPassword,
                                                    isEnabledPregressi));
                }
            }
            else
            {
                // Altrimenti aggiunta di un result negativo
                result.OutDocument.Add(new ImportResult()
                {
                    Outcome = ImportResult.OutcomeEnumeration.KO,
                    Message = "Utente non abilitato alla creazione di documenti in partenza."
                });
            }

            #endregion

            #region Creazione documenti di emergenza Interni

            // Verifica della possibilità di creare documenti interni con il ruolo
            // role
            canCreateDocuments = functions.Where(e => e.codice == "PROTO_OWN").FirstOrDefault() != null;

            // Se con il ruolo corrente è possibile creare documenti interni,
            // si procede alla creazione
            if (canCreateDocuments)
            {
                if (container.OwnDocument != null)
                {
                    result.OwnDocument.AddRange(new OwnDocument().ImportDocuments(
                                                    container.OwnDocument,
                                                    userInfo,
                                                    role,
                                                    serverPath,
                                                    false,
                                                    isRapidClassificationRequired,
                                                    ftpAddress,
                                                    false,
                                                    isSmistamentoEnabled,
                                                    "I",
                                                    ftpUsername,
                                                    ftpPassword,
                                                    isEnabledPregressi));
                }
            }
            else
            {
                // Altrimenti aggiunta di un result negativo
                result.OwnDocument.Add(new ImportResult()
                {
                    Outcome = ImportResult.OutcomeEnumeration.KO,
                    Message = "Utente non abilitato alla creazione di documenti interni."
                });
            }

            #endregion

            // Restituzione del risultato dell'importazione
            return(result);
        }
示例#5
0
        /// <summary>
        /// Funzione per l'importazione dei documenti RDA
        /// </summary>
        /// <param name="content">Il contenuto del file Excel</param>
        /// <param name="fileName">Il nome da attribuire al file temporaneo</param>
        /// <param name="serverPath">L'indirizzo della WA</param>
        /// <param name="modelPath">Il path in cui sono memorizzati i modelli</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="isRapidClassificationRequired">True se è richiesta classificazione rapida obbligatoria</param>
        /// <param name="isSmistamentoEnabled">True se è abilitato lo smistamento</param>
        /// <param name="sharedDirectoryPath">Il path della cartella condivisa</param>
        /// <param name="provider">Il provider da utilizzare per la connessione</param>
        /// <param name="extendedProperty">Le proprietà estese da utilizzare per l'instaurazione della connessione con il provider</param>
        /// <param name="versionNumber">Il numero di versione dell'importer da utilizzare.
        ///     - 1 per la versione che non contempla i protocolli interni ed i corrispondenti identificati tramite codice
        ///     - 2 per la versione che contempla i protocolli interni ed i corrispondenti identificati tramite codice</param>
        /// <returns>Il report relativo all'importazione RDE</returns>
        public static ResultsContainer CreateRDA(
            byte[] content,
            string fileName,
            string serverPath,
            string modelPath,
            InfoUtente userInfo,
            Ruolo role,
            bool isRapidClassificationRequired,
            bool isSmistamentoEnabled,
            string ftpAddress,
            string provider,
            string extendedProperty,
            int versionNumber,
            String ftpUsername,
            String ftpPassword,
            bool isEnabledPregressi)
        {
            // Il path completo in cui è posizionato il file excel contenente i dati
            // sui documenti da importare
            string completePath = String.Empty;

            // L'oggetto con le informazioni sui documenti RDE da importare
            DocumentRowDataContainer container = null;

            // Il risultato dell'elaborazione
            ResultsContainer result = new ResultsContainer();

            try
            {
                // 1. Creazione del file temporaneo in cui poggiare il foglio
                // excel contenente i dati sui documenti da importare
                completePath = ImportUtils.CreateTemporaryFile(content, modelPath, fileName);

                // 2. Caricamento dei dati contenuti all'interno della cartella Excel
                container = ReadDataFromExcel(provider, extendedProperty, completePath, versionNumber);

                // 3. Creazione dei documenti
                result = CreateDocuments(container, userInfo, role, serverPath, isRapidClassificationRequired, isSmistamentoEnabled, ftpAddress, ftpUsername, ftpPassword, isEnabledPregressi);

                // 4. Cancellazione file temporaneo
                ImportUtils.DeleteTemporaryFile(completePath);
            }
            catch (Exception e)
            {
                // Se il file è stato creato, cancellazione
                if (!String.IsNullOrEmpty(completePath))
                {
                    ImportUtils.DeleteTemporaryFile(completePath);
                }

                // Creazione di un nuovo risultato con i dettagli dell'eccezione
                result.General.Add(new ImportResult()
                {
                    Outcome = ImportResult.OutcomeEnumeration.KO,
                    Message = e.Message
                });
            }

            // 4. Restituzione del risultato
            return(result);
        }
示例#6
0
        /// <summary>
        /// Funzione per la lettura dei dati dal foglio excel.
        /// </summary>
        /// <param name="completePath">Il path in cui è stato salvato il file temporaneo da cui estrarre i dati</param>
        /// <param name="provider">Il provider da utilizzare per la connessione al foglio Excel</param>
        /// <param name="extendedProperty">Le proprietà estese</param>
        /// <param name="versionNumber">Il numero di versione.
        ///     - 1 per la versione che non contempla i protocolli interni ed i corrispondenti identificati tramite codice
        ///     - 2 per la versione che contempla i protocolli interni ed i corrispondenti identificati tramite codice</param>
        /// <returns>L'oggetto con i dati estratti dal foglio excel</returns>
        private static DocumentRowDataContainer ReadDataFromExcel(
            string provider,
            string extendedProperty,
            string completePath,
            int versionNumber)
        {
            #region Dichiarazione variabili

            // L'oggetto da restituire
            DocumentRowDataContainer toReturn;

            // L'oggetto per effettuare la connessione al foglio excel
            OleDbConnection oleConnection;

            // L'oggetto per effettuare le query al foglio excel
            OleDbCommand oleCommand;

            // L'oggetto utilizzato per leggere i dati estratti dal foglio
            OleDbDataReader dataReader;

            #endregion

            // Creazione dell'oggetto con i dati estratti dal foglio excel
            toReturn = new DocumentRowDataContainer();

            #region Connessione al foglio excel

            oleConnection = ImportUtils.ConnectToFile(provider, extendedProperty, completePath);

            #endregion

            try
            {
                #region Estrazione dati

                // Se nel foglio excel sono presenti delle righe con codice identificativo non riconosciuto,
                // viene sollevata un'eccezione
                String notIdentified = GetNotIdentifiedProtoType(oleConnection);
                if (!String.IsNullOrEmpty(notIdentified))
                {
                    throw new Exception("Sono state individuate le seguenti tipologie di documento non valide o non utilizzabili in questo contesto: " + notIdentified);
                }

                // Creazione della query per la selezione dei dati sui documenti in arrivo da importare
                oleCommand = new OleDbCommand("SELECT * FROM [RDE$] WHERE [Tipo Protocollo] = 'A'", oleConnection);

                // Esecuzione della query per il recupero dei dati
                dataReader = oleCommand.ExecuteReader();

                // Lettura dei dati relativi ai protocolli in ingresso
                toReturn.InDocument = ReadDocumentData(dataReader, "A", versionNumber);

                // Creazione della query per la selezione dei dati sui documenti in partenza da importare
                oleCommand = new OleDbCommand("SELECT * FROM [RDE$] WHERE [Tipo Protocollo] = 'P'", oleConnection);

                // Esecuzione della query per il recupero dei dati
                dataReader = oleCommand.ExecuteReader();

                // Lettura dei dati relativi ai protocolli in ingresso
                toReturn.OutDocument = ReadDocumentData(dataReader, "P", versionNumber);

                // Creazione della query per la selezione dei dati sui documenti interni da importare
                oleCommand = new OleDbCommand("SELECT * FROM [RDE$] WHERE [Tipo Protocollo] = 'I'", oleConnection);

                // Esecuzione della query per il recupero dei dati
                dataReader = oleCommand.ExecuteReader();

                // Lettura dei dati relativi ai protocolli in ingresso
                toReturn.OwnDocument = ReadDocumentData(dataReader, "I", versionNumber);

                #endregion
            }
            catch (Exception e)
            {
                // Lancio dell'eccezione
                throw new Exception(String.Format(
                                        "Errore durante la lettura dei dati dal foglio excel. Dettagli: {0}",
                                        e.Message));
            }
            finally
            {
                #region Chiusura connessione

                if (oleConnection.State != System.Data.ConnectionState.Closed)
                {
                    // Chiusura della connessione
                    oleConnection.Close();
                }

                #endregion
            }
            // Restituzione oggetto con i dati estratti dal foglio Excel
            return(toReturn);
        }