Exemple #1
0
        /// <summary>
        /// Metodo che esegue la stampa del registro relativo ad una amministrazione
        /// </summary>
        public void PrintRegistro(RegistroConservazionePrint infoPrint)
        {

            logger.Debug("Avvio Stampa - DATI:");
            logger.Debug(string.Format("freq={0}, idrange={1}-{2},  daterange={3}-{4}, user={5}, role={6}",
                infoPrint.printFreq, infoPrint.idLastPrinted, infoPrint.idLastToPrint,
                infoPrint.lastPrintDate.ToString("dd/MM/yyyy"), infoPrint.nextPrintDate.ToString("dd/MM/yyyy"),
                infoPrint.print_userId, infoPrint.print_role));

            RegistroConservazionePrintManager manager = new RegistroConservazionePrintManager();

            //creo un oggetto InfoUtente
            InfoUtente userInfo = this.GetInfoUtenteStampa(infoPrint);

            //creo un ruolo dall'id_gruppo
            //GM 23-7-2013: se non ho un ruolo definito nella tabella di configurazione
            //uso un valore fittizio per evitare errori nell'assegnazione delle visibilità
            Ruolo role = new Ruolo();
            role.idGruppo = "0";
            if(!string.IsNullOrEmpty(infoPrint.print_role))            
                role = BusinessLogic.Utenti.UserManager.getRuoloByIdGruppo(infoPrint.print_role);            
            

            //definisco filtri per la ricerca come nella stampa dei repertori
            List<FiltroRicerca> filters = new List<FiltroRicerca>()
            {
                new FiltroRicerca() {argomento = "id_amm", valore = infoPrint.idAmministrazione},       //id amministrazione
                new FiltroRicerca() {argomento = "next_system_id", valore = infoPrint.idLastPrinted},   //ultimo id stampato
                new FiltroRicerca() {argomento = "last_system_id", valore = infoPrint.idLastToPrint}    //ultimo id da stampare
            };

            //ricavo la frequenza di stampa da stampare nel report
            string printFreq = manager.GetPrintFreq(infoPrint.printFreq);

            //creo la stampa utilizzando i metodi esistenti
            //va definita la classe con il report in businesslogic.reporting (StampeRegistroConservazioneReportGeneratorCommand)
            //e le modalità di estrazione dei dati in docspadb.query_docspaws.reporting.
            FileDocumento fileDocument = BusinessLogic.Reporting.ReportGeneratorCommand.GetReport(
                new DocsPaVO.Report.PrintReportRequest()
                {
                    UserInfo = userInfo,
                    SearchFilters = filters,
                    ReportType = DocsPaVO.Report.ReportTypeEnum.PDF,
                    ReportKey = "StampaRegistroConservazione",
                    ContextName = "StampaRegistroConservazione",
                    AdditionalInformation = String.Format("Stampa del {0} (frequenza di stampa {1})\n\n",DateTime.Now.ToString("dd/MM/yyyy"),printFreq)
                }).Document;

            //inserimento stampa nel gestore documentale

            //apertura contesto transazionale
            using (DocsPaDB.TransactionContext transactionContext = new DocsPaDB.TransactionContext())
            {
                if (userInfo != null && string.IsNullOrEmpty(userInfo.dst))
                    userInfo.dst = BusinessLogic.Utenti.UserManager.getSuperUserAuthenticationToken();

                //creazione scheda documento
                SchedaDocumento document = this.InitializeDocument(userInfo, infoPrint.lastPrintDate, DateTime.Now);

                Ruolo[] roles = new Ruolo[] { };
                //salvataggio documento
                
                string docNumber = this.SaveDocument(userInfo, role, document, fileDocument, out roles);

                if (String.IsNullOrEmpty(docNumber))
                    throw new Exception("Errore durante la creazione della stampa");

                //modifico il tipo_proto del documento inserito in "M"
                if (!manager.UpdateTipoProto(docNumber))
                    throw new Exception("Errore nell'aggiornamento della tipologia protocollo"); 

                //inserisco la stampa nel registro delle stampe
                if (!manager.UpdateRegStampeCons(infoPrint, docNumber))
                    throw new Exception("Errore durante l'aggiornamento dell'anagrafica delle stampe effettuate");

                //aggiorno il campo corrispondente del registro di conservazione
                if (!manager.UpdatePrintedRecords(infoPrint))
                    throw new Exception("Errore nell'aggiornamento del registro di conservazione");
                
                //chiusura transazione
                transactionContext.Complete();

            }

        }