Esempio n. 1
0
        private static string JournalLogToString(ProtocolJournalLog log)
        {
            var builder = new StringBuilder();

            if (log.LogDate != null)
            {
                builder.AppendFormat("LogDate: {0}\n", log.LogDate.Value.ToString(CultureInfo.InvariantCulture));
            }
            if (log.ProtocolJournalDate != null)
            {
                builder.AppendFormat("ProtocolJournalDate: {0}\n", log.ProtocolJournalDate.Value.ToString(CultureInfo.InvariantCulture));
            }
            builder.AppendFormat("SystemComputer: {0}\n", log.SystemComputer);
            builder.AppendFormat("SystemUser: {0}\n", log.SystemUser);
            if (log.StartDate != null)
            {
                builder.AppendFormat("StartDate: {0}\n", log.StartDate.Value.ToString(CultureInfo.InvariantCulture));
            }
            if (log.EndDate != null)
            {
                builder.AppendFormat("EndDate: {0}\n", log.EndDate.Value.ToString(CultureInfo.InvariantCulture));
            }
            builder.AppendFormat("ProtocolTotal: {0}\n", log.ProtocolTotal);
            builder.AppendFormat("ProtocolRegister: {0}\n", log.ProtocolRegister);
            builder.AppendFormat("ProtocolError: {0}\n", log.ProtocolError);
            builder.AppendFormat("ProtocolCancelled: {0}\n", log.ProtocolCancelled);
            builder.AppendFormat("ProtocolActive: {0}\n", log.ProtocolActive);
            builder.AppendFormat("ProtocolOthers: {0}\n", log.ProtocolOthers);
            builder.AppendFormat("IdDocument: {0}\n", log.IdDocument);
            builder.AppendFormat("idLocation: {0}\n", log.Location != null ? log.Location.Id.ToString(CultureInfo.InvariantCulture) : String.Empty);
            builder.AppendFormat("LogDescription: {0}\n", log.LogDescription);
            return(builder.ToString());
        }
Esempio n. 2
0
 /// <summary>
 /// Reinizializza i singleton.
 /// </summary>
 private void DiscardBuilder()
 {
     _protocolFinder = null;
     _protocols      = null;
     _journalLog     = null;
     _journalPrint   = null;
     _name           = null;
     _tempName       = null;
     //_chainObject = null;
 }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        public void Build()
        {
            var log = new ProtocolJournalLog
            {
                Location            = JournalLog.Location,
                LogDescription      = JournalLog.LogDescription,
                ProtocolActive      = JournalLog.ProtocolActive,
                ProtocolCancelled   = JournalLog.ProtocolCancelled,
                ProtocolRegister    = JournalLog.ProtocolRegister,
                ProtocolError       = JournalLog.ProtocolError,
                ProtocolOthers      = JournalLog.ProtocolOthers,
                ProtocolTotal       = JournalLog.ProtocolTotal,
                LogDate             = JournalLog.LogDate,
                ProtocolJournalDate = JournalLog.ProtocolJournalDate,
                StartDate           = JournalLog.StartDate,
                EndDate             = null
            };

            FileLogger.Debug(LoggerName, "Salvo l'oggetto JournalLog:\n" + JournalLogToString(log));
            LogFacade.Save(ref log);
            JournalLog = log;

            FileLogger.Debug(LoggerName, "Cerco i Protocolli da inserire...");
            if (Protocols.Count > 0)
            {
                FileLogger.Debug(LoggerName, String.Format("{0} Protocolli da registrare.", Protocols.Count));

                // Scrivo il registro su disco.
                var destination = Path.Combine(OutputPath, TempName);
                FileLogger.Debug(LoggerName, "File di destinazione: " + destination);

                try
                {
                    //Salvo il pdf del registro
                    FileLogger.Debug(LoggerName, "Generazione report RDLC.");
                    JournalPrint.Report.DoPrint().SavePdf(new DirectoryInfo(OutputPath), TempName, String.Empty);
                    FileLogger.Debug(LoggerName, "Creazione registro avvenuta con successo: " + destination);
                }
                catch (Exception ex)
                {
                    JournalLog.LogDescription = "Errore in fase di Creazione PDF";
                    throw new Exception("Errore in fase di Creazione PDF", ex);
                }

                // Eseguo firma e marcatura temporale del registro (se richiesto).
                if (ApplySign)
                {
                    try
                    {
                        destination = ProtocolJournalTools.SignEngine.SignDocument(destination);
                        FileLogger.Debug(LoggerName, "Firma eseguita con successo: " + destination);
                        Name = Name + ".p7m";
                    }
                    catch (Exception ex)
                    {
                        JournalLog.LogDescription = "Errore in fase di firma Registro";
                        throw new Exception("Errore in fase di firma Registro.", ex);
                    }
                }

                // Eseguo firma e marcatura temporale del registro (se richiesto).
                if (ApplyTimeStamp)
                {
                    try
                    {
                        destination = ProtocolJournalTools.SignEngine.TimeStampDocument(destination);
                        FileLogger.Debug(LoggerName, "Marcatura temporale eseguita con successo: " + destination);
                        Name = Name + ".p7x";
                    }
                    catch (Exception ex)
                    {
                        JournalLog.LogDescription = "Errore in fase di marcatura temporale Registro";
                        throw new Exception("Errore in fase di marcatura temporale Registro.", ex);
                    }
                }

                try
                {
                    JournalLog.IdDocument = ProtocolJournalTools.SaveJournalToBiblos(Location,
                                                                                     GetDocument(destination, Name, Location.ProtBiblosDSDB));
                    FileLogger.Debug(LoggerName, "Documento salvato con successo: " + JournalLog.IdDocument);
                }
                catch (Exception ex)
                {
                    JournalLog.LogDescription = "Errore in fase di salvataggio Registro";
                    throw new Exception("Errore in fase di salvataggio Registro.", ex);
                }
            }
            else
            {
                FileLogger.Debug(LoggerName, "Nessun protocollo da registrare.");
            }

            JournalLog.EndDate = DateTime.Now;
            log = JournalLog;
            LogFacade.Update(ref log);
            JournalLog = log;
        }