コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="counterId"></param>
        /// <param name="registryId"></param>
        /// <param name="rfId"></param>
        /// <param name="userInfo"></param>
        /// <param name="role"></param>
        public void GeneratePrintRepertorio(String counterId, String registryId, String rfId, InfoUtente userInfo, Ruolo role)
        {
            // Risultato dell'operazione
            //SchedaDocumento document = null;

            // Controllo dello stato del repertorio per la particolare istanza
            DocsPaDB.Query_DocsPAWS.RegistriRepertorioPrintManager manager = new DocsPaDB.Query_DocsPAWS.RegistriRepertorioPrintManager();

            String message;

            // Si può stampare solo se l'istanza è chiusa
            if (this.CheckPrintCondition(counterId, registryId, rfId /*, out lastPrintedNumber, out lastNumberToPrint*/, out message))
            {
                // Recupero delle informazioni sui repertori da stampare
                List <RepertorioPrintRange> ranges = manager.GetRepertoriPrintRanges(counterId, registryId, rfId, false);

                foreach (var range in ranges)
                {
                    GeneratePrint(counterId, registryId, rfId, userInfo, role, range.Year.ToString(), range.FirstNumber.ToString(), range.LastNumber.ToString());

                    if (!manager.UpdateLastPrintendNumber(counterId, range.LastNumber.ToString(), rfId, registryId))
                    {
                        throw new Exception("Errore durante l'aggiornamento dell'anagrafica dei repertori");
                    }
                }
            }
            else
            {
                throw new Exception(message);
            }

            // Restituzione documento creato
            //return document;
        }
コード例 #2
0
        public string GeneratePrintByRanges(string anno, string counterId, string numRepStart, string numRepEnd, string idRegistro, string dataStampa, bool ultimastampa)
        {
            string retVal = "";

            logger.Info("START");
            DocsPaDB.Query_DocsPAWS.Conservazione dbCons = new DocsPaDB.Query_DocsPAWS.Conservazione();

            // uguale al metodo precedente tranne che per questo pezzo.
            //DocsPaVO.areaConservazione.StampaRegistro stReg = dbCons.getInfoStampaReperiorio(idDoc);

            DocsPaVO.areaConservazione.StampaRegistro stReg = new DocsPaVO.areaConservazione.StampaRegistro();

            stReg.anno          = anno;
            stReg.idRepertorio  = counterId;
            stReg.numProtoStart = numRepStart;
            if (!string.IsNullOrEmpty(numRepEnd))
            {
                stReg.numProtoEnd = numRepEnd;
            }
            stReg.idRegistro           = idRegistro;
            stReg.dtaStampaTruncString = dataStampa;

            DocsPaDB.Query_DocsPAWS.RegistriRepertorioPrintManager manager = new DocsPaDB.Query_DocsPAWS.RegistriRepertorioPrintManager();

            List <RegistroRepertorioPrint> reg1 = manager.GetRegistersToPrintByCounter(stReg.idRepertorio);

            foreach (RegistroRepertorioPrint print in reg1)
            {
                if (print.RegistryId == stReg.idRegistro || print.RFId == stReg.idRegistro)
                {
                    logger.DebugFormat("Stampa del repertorio {0} della tipologia {5}, per l'anno {1}, su registro {2} o RF {3}, responsabile {4}",
                                       print.CounterDescription, stReg.anno, print.RegistryId, print.RFId, print.PrinterUser.userId, print.TipologyDescription);

                    InfoUtente userInfo = new InfoUtente()
                    {
                        idAmministrazione = print.PrinterUser.idAmministrazione,
                        idCorrGlobali     = print.PrinterUser.systemId,
                        idGruppo          = print.PrinterRole.idGruppo,
                        idPeople          = print.PrinterUser.idPeople,
                        userId            = print.PrinterUser.userId
                    };

                    //RepertorioPrintRange rpr = manager.GetRepertoriPrintRangesByYear(counterId, print.RegistryId, print.RFId, year);
                    // Generazione filtri per la stampa
                    List <FiltroRicerca> filters = null;
                    string minX = stReg.numProtoStart;
                    if (!ultimastampa)
                    {
                        string maxX = stReg.numProtoEnd;
                        logger.DebugFormat("Limite inferiore {0}, superiore {1}", minX, maxX);

                        filters = new List <FiltroRicerca>()
                        {
                            new FiltroRicerca()
                            {
                                argomento = "idCounter", valore = stReg.idRepertorio
                            },
                            new FiltroRicerca()
                            {
                                argomento = "idRegistry", valore = print.RegistryId
                            },
                            new FiltroRicerca()
                            {
                                argomento = "idRf", valore = print.RFId
                            },
                            new FiltroRicerca()
                            {
                                argomento = "year", valore = stReg.anno
                            },
                            new FiltroRicerca()
                            {
                                argomento = "lastPrintedNumber", valore = minX
                            },
                            new FiltroRicerca()
                            {
                                argomento = "lastNumberToPrint", valore = maxX
                            },
                            new FiltroRicerca()
                            {
                                argomento = "RECUPERO_evitaMod", valore = "true"
                            }
                        };
                    }
                    else
                    {
                        logger.DebugFormat("Limite inferiore {0}", minX);

                        filters = new List <FiltroRicerca>()
                        {
                            new FiltroRicerca()
                            {
                                argomento = "idCounter", valore = stReg.idRepertorio
                            },
                            new FiltroRicerca()
                            {
                                argomento = "idRegistry", valore = print.RegistryId
                            },
                            new FiltroRicerca()
                            {
                                argomento = "idRf", valore = print.RFId
                            },
                            new FiltroRicerca()
                            {
                                argomento = "year", valore = stReg.anno
                            },
                            new FiltroRicerca()
                            {
                                argomento = "lastPrintedNumber", valore = minX
                            }
                        };
                    }

                    // Creazione della stampa
                    FileDocumento fileDocument = BusinessLogic.Reporting.ReportGeneratorCommand.GetReport(
                        new DocsPaVO.Report.PrintReportRequest()
                    {
                        UserInfo              = userInfo,
                        SearchFilters         = filters,
                        ReportType            = DocsPaVO.Report.ReportTypeEnum.PDF,
                        ReportKey             = "StampaRegistriRepertori",
                        ContextName           = "StampaRegistriRepertori",
                        AdditionalInformation = String.Format(" Stampa del repertorio per l'anno {0} dal n. {1} al n. {2} - stampa di recupero del giorno {3}. La presente stampa riporta tutte le registrazioni giornaliere di repertorio nell'intervallo indicato. Si è resa necessaria in quanto problematiche tecniche del sistema avevano inizialmente impedito la corretta stampa.", stReg.anno, minX, numRepEnd, dataStampa)
                    }).Document;

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

                        // Reperimento del nome della tipologia
                        string tipologia = manager.GetNomeTipologia(stReg.idRepertorio);

                        // Creazione della scheda documento
                        SchedaDocumento document = InitializeDocument(userInfo, print.RegistryId, print.RFId, stReg.anno, minX, numRepEnd, tipologia);
                        document.oggetto.descrizione += " - RECUPERO";

                        Ruolo[] roles = new Ruolo[] { };
                        // Salvataggio del documento
                        String docNumber = this.SaveDocument(userInfo, print.PrinterRole, document, fileDocument, out roles);

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

                        retVal = docNumber;

                        // Aggiornamento del registro delle stampe e del prossimo numero da stampare
                        if (!manager.UpdatePrinterManager(stReg.idRepertorio, minX, numRepEnd, docNumber, print.RegistryId, print.RFId, stReg.anno))
                        {
                            throw new Exception("Errore durante l'aggiornamento dell'anagrafica delle stampe effettuate");
                        }

                        int rights = 0;
                        // Assegnazione della visibilità della stampa al responsabile di repertorio (se impostato)
                        if (!BusinessLogic.utenti.RegistriRepertorioPrintManager.AssignDocumentVisibilityToResponsable(userInfo, docNumber, stReg.idRepertorio, print.RFId, print.RegistryId, out rights))
                        {
                            throw new Exception("Errore assegnazione visiblità a ruolo responsabile");
                        }

                        // Se ci sono ruoli superiori, viene assegnata la visibilità
                        foreach (Ruolo r in roles)
                        {
                            if (!BusinessLogic.utenti.RegistriRepertorioPrintManager.AssignDocumentVisibilityToRole(userInfo, docNumber, stReg.idRepertorio, print.RFId, print.RegistryId, r.idGruppo, rights))
                            {
                                throw new Exception(String.Format("Errore assegnazione visiblità al ruolo {0}", r.codice));
                            }
                        }

                        //assegnazione visibilità nel caso di repertori di tipologia/RF
                        if ((string.IsNullOrEmpty(print.RFId) && string.IsNullOrEmpty(print.RegistryId)) ||
                            (!string.IsNullOrEmpty(print.RFId)))
                        {
                            DocsPaDB.Utils.Gerarchia gerarchia = new DocsPaDB.Utils.Gerarchia();
                            object[] supRolePrinter            = gerarchia.getGerarchiaSup(print.PrinterRole, ((DocsPaVO.utente.Registro)print.PrinterRole.registri[0]).systemId, null, DocsPaVO.trasmissione.TipoOggetto.DOCUMENTO).ToArray();
                            foreach (Ruolo r in supRolePrinter)
                            {
                                if (!BusinessLogic.utenti.RegistriRepertorioPrintManager.AssignDocumentVisibilityToRole(userInfo, docNumber, stReg.idRepertorio, print.RFId, print.RegistryId, r.idGruppo, rights))
                                {
                                    throw new Exception(String.Format("Errore assegnazione visiblità al ruolo {0}", r.codice));
                                }
                            }
                        }

                        // Completamento transazione
                        transactionContext.Complete();
                    }

                    if (!string.IsNullOrEmpty(retVal))
                    {
                        DocsPaDB.Query_DocsPAWS.Report dbreport = new DocsPaDB.Query_DocsPAWS.Report();
                        dbreport.UpdStampaExp(retVal, stReg.dtaStampaTruncString);
                    }
                }
            }
            return(retVal);
        }
コード例 #3
0
        public void GeneratePrintByYear(string counterId, string year)
        {
            logger.Info("START");
            DocsPaDB.Query_DocsPAWS.RegistriRepertorioPrintManager manager = new DocsPaDB.Query_DocsPAWS.RegistriRepertorioPrintManager();

            List <RegistroRepertorioPrint> reg1 = manager.GetRegistersToPrintByCounter(counterId);

            foreach (RegistroRepertorioPrint print in reg1)
            {
                logger.DebugFormat("Stampa del repertorio {0} della tipologia {5}, per l'anno {1}, su registro {2} o RF {3}, responsabile {4}",
                                   print.CounterDescription, year, print.RegistryId, print.RFId, print.PrinterUser.userId, print.TipologyDescription);
                InfoUtente userInfo = new InfoUtente()
                {
                    idAmministrazione = print.PrinterUser.idAmministrazione,
                    idCorrGlobali     = print.PrinterUser.systemId,
                    idGruppo          = print.PrinterRole.idGruppo,
                    idPeople          = print.PrinterUser.idPeople,
                    userId            = print.PrinterUser.userId
                };

                RepertorioPrintRange rpr = manager.GetRepertoriPrintRangesByYear(counterId, print.RegistryId, print.RFId, year);
                // Generazione filtri per la stampa
                if (rpr != null && rpr.LastNumber != null && rpr.LastNumber != 0 && (rpr.LastNumber - rpr.FirstNumber) > 0)
                {
                    string minX = rpr.FirstNumber.ToString();
                    string maxX = rpr.LastNumber.ToString();
                    logger.DebugFormat("Limite inferiore {0}, superiore {1}", minX, maxX);

                    List <FiltroRicerca> filters = new List <FiltroRicerca>()
                    {
                        new FiltroRicerca()
                        {
                            argomento = "idCounter", valore = counterId
                        },
                        new FiltroRicerca()
                        {
                            argomento = "idRegistry", valore = print.RegistryId
                        },
                        new FiltroRicerca()
                        {
                            argomento = "idRf", valore = print.RFId
                        },
                        new FiltroRicerca()
                        {
                            argomento = "year", valore = year
                        },
                        new FiltroRicerca()
                        {
                            argomento = "lastPrintedNumber", valore = minX
                        },
                        new FiltroRicerca()
                        {
                            argomento = "lastNumberToPrint", valore = maxX
                        }
                    };

                    // Creazione della stampa
                    FileDocumento fileDocument = BusinessLogic.Reporting.ReportGeneratorCommand.GetReport(
                        new DocsPaVO.Report.PrintReportRequest()
                    {
                        UserInfo              = userInfo,
                        SearchFilters         = filters,
                        ReportType            = DocsPaVO.Report.ReportTypeEnum.PDF,
                        ReportKey             = "StampaRegistriRepertori",
                        ContextName           = "StampaRegistriRepertori",
                        AdditionalInformation = String.Format(" Stampa del repertorio per l'anno {0} dal n. {1} al n. {2}. La presente stampa riporta tutte le registrazioni giornaliere di repertorio nell'intervallo indicato. Si è resa necessaria in quanto problematiche tecniche del sistema avevano inizialmente impedito la regolare stampa.", year, minX, maxX)
                    }).Document;

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

                        // Reperimento del nome della tipologia
                        string tipologia = manager.GetNomeTipologia(counterId);

                        // Creazione della scheda documento
                        SchedaDocumento document = InitializeDocument(userInfo, print.RegistryId, print.RFId, year, minX, maxX, tipologia);

                        document.oggetto.descrizione += " - RECUPERO";
                        Ruolo[] roles = new Ruolo[] { };
                        // Salvataggio del documento
                        String docNumber = this.SaveDocument(userInfo, print.PrinterRole, document, fileDocument, out roles);

                        if (String.IsNullOrEmpty(docNumber))
                        {
                            throw new Exception("Errore durante la creazione della stampa");
                        }
                        // Aggiornamento del registro delle stampe e del prossimo numero da stampare
                        if (!manager.UpdatePrinterManager(counterId, minX, maxX, docNumber, print.RegistryId, print.RFId, year))
                        {
                            throw new Exception("Errore durante l'aggiornamento dell'anagrafica delle stampe effettuate");
                        }

                        int rights = 0;
                        // Assegnazione della visibilità della stampa al responsabile di repertorio (se impostato)
                        if (!BusinessLogic.utenti.RegistriRepertorioPrintManager.AssignDocumentVisibilityToResponsable(userInfo, docNumber, counterId, print.RFId, print.RegistryId, out rights))
                        {
                            throw new Exception("Errore assegnazione visiblità a ruolo responsabile");
                        }

                        // Se ci sono ruoli superiori, viene assegnata la visibilità
                        foreach (Ruolo r in roles)
                        {
                            if (!BusinessLogic.utenti.RegistriRepertorioPrintManager.AssignDocumentVisibilityToRole(userInfo, docNumber, counterId, print.RFId, print.RegistryId, r.idGruppo, rights))
                            {
                                throw new Exception(String.Format("Errore assegnazione visiblità al ruolo {0}", r.codice));
                            }
                        }

                        //assegnazione visibilità nel caso di repertori di tipologia/RF
                        if ((string.IsNullOrEmpty(print.RFId) && string.IsNullOrEmpty(print.RegistryId)) ||
                            (!string.IsNullOrEmpty(print.RFId)))
                        {
                            DocsPaDB.Utils.Gerarchia gerarchia = new DocsPaDB.Utils.Gerarchia();
                            object[] supRolePrinter            = gerarchia.getGerarchiaSup(print.PrinterRole, ((DocsPaVO.utente.Registro)print.PrinterRole.registri[0]).systemId, null, DocsPaVO.trasmissione.TipoOggetto.DOCUMENTO).ToArray();
                            foreach (Ruolo r in supRolePrinter)
                            {
                                if (!BusinessLogic.utenti.RegistriRepertorioPrintManager.AssignDocumentVisibilityToRole(userInfo, docNumber, counterId, print.RFId, print.RegistryId, r.idGruppo, rights))
                                {
                                    throw new Exception(String.Format("Errore assegnazione visiblità al ruolo {0}", r.codice));
                                }
                            }
                        }

                        // Completamento transazione
                        transactionContext.Complete();
                    }
                }
            }
        }