Beispiel #1
0
        /// <summary>
        /// Subscribes the debug log.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        public static async Task SubscribeDebugLog <T>(T message)
        {
            try
            {
                DebugLoggerModel logmessage = message as DebugLoggerModel;

                LogModel logModel = new LogModel
                {
                    Date            = logmessage.Date,
                    Severity        = (LogSeverity)Enum.Parse(typeof(LogSeverity), logmessage.Severity),
                    Logger          = logmessage.Logger,
                    File            = logmessage.File,
                    Method          = logmessage.Method,
                    Identity        = logmessage.Identity,
                    Message         = logmessage.Message,
                    StackTrace      = logmessage.StackTrace,
                    Exception       = logmessage.Exception,
                    ApplicationCode = logmessage.ApplicationCode,
                    ErrorCode       = logmessage.ErrorCode,
                    MessageData     = logmessage.MessageData,
                    ComponentStatus = logmessage.ComponentStatus
                };

                LogFacade logFacade = new LogFacade();
                Models.BaseResponse <string> businessResponse = logFacade.AddEvent(logModel);
            }
            catch (Exception ex)
            {
            }
        }
        private DateTime GetStartDate()
        {
            // Recupero la data di creazione dell'ultimo log creato.
            var last = LogFacade.GetLastLogDate();

            if (last.HasValue)
            {
                // Resetto i minuti
                last = last.Value.Date;
            }
            // Se ho configurato un limite inferiore di esecuzione e:
            // Non ho nessun log precedentemente creato
            // OPPURE
            // La data di creazione dell'ultimo log è antecedente alla data di limite inferiore
            // SEGUE
            // Imposto la data di limite inferiore da file di configurazione.
            var lowerDateLimit = GetLowerDateLimit();

            if (!last.HasValue || last.Value < lowerDateLimit)
            {
                last = lowerDateLimit;
            }
            FileLogger.Info(Name, "Data ultimo registro inserito: " + last.Value.ToString("dd/MM/yyyy"));

            // Imposto la data di avvio creazione dei registri.
            var retval = last.Value.AddDays(1);

            return(retval);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            string comand = args[0];

            switch (comand)
            {
            case "convert":
                string url  = args[1];
                string path = args[2];

                var logFacade = new LogFacade(
                    new LogService(new LogClient(
                                       WebRequest.CreateHttp(url)
                                       ))
                    , new LogFile(path)
                    );

                logFacade.ConvertLog();
                break;

            default:
                Console.WriteLine("Comand not found");
                break;
            }
        }
        public override void Run(string input, IGlossary glossary)
        {
            this.glossary = glossary;

            glossary.ProcessSynsets(wordnet);

            IEnumerable <string> sentences = nlp.DetectSentences(input);

            foreach (string sentence in sentences)
            {
                IEnumerable <string> words = nlp.Tokenize(sentence);
                IEnumerable <string> tags  = nlp.PosTag(words);

                foreach (Term term in words.Zip(tags, (word, tag) => new Term {
                    PoS = new POS(tag), Word = word
                }))
                {
                    // bag of words
                    bow.AddWord(term.Word.ToLower());
                    // main stuff
                    term.Synset = SelectSynset(term.Word, term.PoS);
                    terms.Add(term);
                    flatRepo.Add(term);
                }
            }

            LogFacade.LogBOW(bow);
        }
Beispiel #5
0
        /// <summary>
        /// 取消审核功能
        /// </summary>
        /// <param name="table">表名称</param>
        /// <param name="refGuid">数据主键</param>
        /// <param name="projGuid">项目主键</param>
        /// <param name="url">当前url</param>
        public static void CannelConfirm(string table, string refGuid, string projGuid, string url)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies["CurrentUserInfo"];
            DataSet    ds     = null;

            if (cookie != null)
            {
                LogFacade log = new LogFacade();
                ds = log.OperatorLog(table, refGuid, refGuid, "取消审核", HttpContext.Current.Server.UrlDecode(cookie["CurrentUserGuid"]), HttpContext.Current.Server.UrlDecode(cookie["CurrentUserDN"]), HttpContext.Current.Server.UrlDecode(cookie["CurrentUserCN"]), projGuid);
            }
            FormatProject.CannelConfirm(table, refGuid, projGuid, url, ds);
        }
Beispiel #6
0
        /// <summary>
        /// 项目信息审核退回
        /// </summary>
        /// <param name="table">表名称</param>
        /// <param name="status">审核状态 1 审核 2 退回</param>
        /// <param name="refGuid">数据主键</param>
        /// <param name="projGuid">项目主键</param>
        /// <param name="remark">意见</param>
        /// <param name="url">当前地址</param>
        /// <returns></returns>
        public static void InfoAction(string table, string status, string refGuid, string projGuid, string remark, string url)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies["CurrentUserInfo"];
            DataSet    ds     = null;

            if (cookie != null)
            {
                LogFacade log = new LogFacade();
                ds = log.OperatorLog(table, refGuid, refGuid, status == "1" ? "审核" : "退回", HttpContext.Current.Server.UrlDecode(cookie["CurrentUserGuid"]), HttpContext.Current.Server.UrlDecode(cookie["CurrentUserDN"]), HttpContext.Current.Server.UrlDecode(cookie["CurrentUserCN"]), projGuid);
            }
            FormatProject.InfoAction(table, status, refGuid, projGuid, remark, ds, url);
        }
Beispiel #7
0
 /// <summary>
 /// Losts the message notification.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="message">The message.</param>
 /// <returns></returns>
 public static async Task LostMessageNotification <T>(T message)
 {
     try
     {
         LostMessageNotification lostMessage = message as LostMessageNotification;
         LogFacade logFacade = new LogFacade();
         Models.BaseResponse <string> businessResponse = logFacade.AddLostEventBudsMessage(lostMessage);
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #8
0
        public void CheckValues()
        {
            //Arrange
            MockLogClient logClient  = new MockLogClient();
            MockLogFile   logFile    = new MockLogFile();
            LogService    logService = new LogService(logClient);
            var           logFacade  = new LogFacade(logService, logFile);

            //Act
            logFacade.ConvertLog();

            //Assert
            Assert.Contains("robots.txt", logFile.content);
            Assert.Contains("myImages", logFile.content);
            Assert.Contains("not-found", logFile.content);
        }
Beispiel #9
0
 private void LogWrite(LogItemModel log)
 {
     ThreadPool.QueueUserWorkItem(new WaitCallback((object state) => {
         var logmodel          = state as LogItemModel;
         ILogFacade _logFacade = new LogFacade();
         if (_logFacade != null)
         {
             try
             {
                 _logFacade.Insert(logmodel);
             }
             catch
             {
             }
         }
     }), log);
 }
Beispiel #10
0
        public override void OnPageLoad(object sender, EventArgs e)
        {
            base.OnPageLoad(sender, e);
            facade        = new LogFacade(this);
            queryFilterVM = new LogQueryFilterVM();
            this.gridSearchCondition.DataContext = queryFilterVM;

            if (!string.IsNullOrEmpty(this.Request.Param))
            {
                int tNum = 0;
                if (int.TryParse(this.Request.Param, out tNum))
                {
                    queryFilterVM.TicketSysNo = tNum.ToString();
                    btnSearch_Click(null, null);
                }
                else
                {
                    Window.Alert("TicketSysNo错误!");
                }
            }
        }
Beispiel #11
0
 public LogController(IPersistWorkerContext context, LogFacade facade)
 {
     _context = context;
     _facade  = facade;
 }
        /// <summary>
        /// Recupera i registri incompleti e ne tenta la rigenerazione.
        /// </summary>
        /// <param name="pjb">Builder del registro</param>
        /// <param name="start">Data limite inferiore di verifica</param>
        /// <param name="end">Data limite superiore di verifica</param>
        private void RestoreJournals(ref ProtocolJournalBuilder pjb, DateTime start, DateTime end)
        {
            // Recupero i registri la cui creazione è rimasta incompleta.
            var brokenLogs = LogFacade.GetBrokenJournals(start, end);

            if (brokenLogs != null && brokenLogs.Count > 0)
            {
                FileLogger.Info(Name, "Registri giornalieri incompleti da riprocessare: " + brokenLogs.Count.ToString(CultureInfo.InvariantCulture));
                var joined = JournalListToString(brokenLogs);
                FileLogger.Info(Name, "Registri da riprocessare: " + joined);

                foreach (var journal in brokenLogs)
                {
                    if (Cancel)
                    {
                        FileLogger.Info(Name, "Chiusura modulo invocata dall'utente.");
                        return;
                    }

                    if (!CheckTimeStamps())
                    {
                        FileLogger.Info(Name, "Recupero Registro annullato per problemi in Verifica Marche Temporali");
                        continue;
                    }

                    try
                    {
                        // Elimino il registro incompleto per predisporne la rigenerazione.
                        var discarded = journal;
                        if (discarded.IdDocument.HasValue)
                        {
                            Services.Biblos.Service.DetachDocument(discarded.Location.DocumentServer, discarded.Location.ProtBiblosDSDB,
                                                                   discarded.IdDocument.Value);
                        }
                        LogFacade.Delete(ref discarded);
                    }
                    catch (Exception ex)
                    {
                        FileLogger.Error(Name, "Errore in cancellazione registro da ripristinare.", ex);
                        SendMessage("Errore in cancellazione registro da ripristinare: " + ex);
                        return;
                    }

                    try
                    {
                        if (journal.ProtocolJournalDate != null)
                        {
                            BuildJournalByDate(ref pjb, journal.ProtocolJournalDate.Value);
                        }
                    }
                    catch (Exception ex)
                    {
                        FileLogger.Error(Name, "Errore in restoreJournals", ex);
                        SendMessage("Errore in restoreJournals: " + ex);
                    }
                }
            }
            else
            {
                FileLogger.Info(Name, "Nessun registro incompleto da riprocessare.");
            }
        }
        /// <summary>
        /// Crea un registro giornaliero di protocollo per la data specificata.
        /// </summary>
        /// <param name="pjb">Builder del registro</param>
        /// <param name="date">Data di cui creare il registro</param>
        private void BuildJournalByDate(ref ProtocolJournalBuilder pjb, DateTimeOffset date)
        {
            try
            {
                // Elimino dai protocolli per la data di cui creare il registro ogni riferimento a precedenti registri.
                LogFacade.ClearProtocolJournalReferencesByDate(date);
            }
            catch (Exception ex)
            {
                string err = "Errore in fase ripristino registro: ClearProtocolJournalReferencesByDate, " + date.Date.ToShortDateString();
                FileLogger.Error(Name, err);
                throw new Exception(err, ex);
            }

            try
            {
                // Imposto la data
                pjb.Date = date.Date;

                // Verifico se devo annullare protocolli
                if (Parameters.CancelBrokenProtocols)
                {
                    FileLogger.Info(Name, "Verifica protocolli da annullare...");
                    foreach (var protocol in pjb.Protocols.Where(
                                 protocol => protocol.IdStatus.HasValue && (protocol.IdStatus.Value == (int)ProtocolStatusId.Errato) &&
                                 (DateTimeOffset.Now - protocol.RegistrationDate).TotalDays > 0)
                             )
                    {
                        var currentProtocol = protocol;
                        currentProtocol.IdStatus          = (int?)ProtocolStatusId.Annullato;
                        currentProtocol.LastChangedReason = Parameters.CancelBrokenProtocolMessage.Trim();
                        ProtocolFacade.Update(ref currentProtocol);
                        FileLogger.Info(Name, String.Format("Annullato protocollo {0}", protocol));
                    }
                }

                FileLogger.Info(Name, "Creazione registro per la data del: " + date.ToString("dd/MM/yyyy"));
                FileLogger.Info(Name, "Protocolli da registrare: " + pjb.Protocols.Count);

                //FileLogger.Info(Name, "Attributi ChainObject: " + pjb.ChainObjectToString());

                // Costruisco il registro.
                pjb.Build();
                FileLogger.Info(Name, "Creazione registro completata.");
                try
                {
                    FileLogger.Info(Name, "Elimino file temporanei: " + pjb.TempName);
                    // Se va tutto a buon fine elimino i file temporanei.
                    pjb.DiscardTempFiles();
                }
                catch (Exception discardTempFilesEx)
                {
                    // Se si verifica un errore in fase di eliminazione dei file temporanei comunque non dismetto il registro creato correttamente.
                    FileLogger.Info(Name, "Si è verificato un errore in: CreateJournals.DiscardTempFiles");
                    FileLogger.Error(Name, discardTempFilesEx.Message, discardTempFilesEx);
                }
            }
            catch (Exception buildEx)
            {
                SendMessage("Errore in creazione Journal Report per il giorno " + date.Date.ToLongDateString());
                FileLogger.Info(Name, "Si è verificato un errore in: CreateJournals.Build");
                FileLogger.Error(Name, buildEx.Message, buildEx);
                FileLogger.Info(Name, "File temporanei preservati per verifiche: " + pjb.TempName);
                throw new Exception("Errore in creazione Journal Report per il giorno " + date.Date.ToLongDateString());
            }
        }
Beispiel #14
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;
        }