Exemple #1
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);
        }
Exemple #2
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);
        }