private async Task Discover()
        {
            LogStorage.Clear(Logger.Category);
            ViewModel.ProgressInPercentage = 0;

            try
            {
                var progressTracker = _progressTrackerFactory.CreateForDiscovering(value => ViewModel.ProgressInPercentage = value);

                _userSession.DiscoveredVenues = await _discovering.Discover(_userSession.Document, _userSession.ReportLanguage, progressTracker, CancellationTokenSource.Token);

                Logger.Info("Discovering process complete");

                await MainWindow.GoNext();
            }
            catch (Exception ex)
            {
#if DEBUG
                Logger.Error(ex.ToString());
#else
                Logger.Error(ex.Message);
#endif
                Logger.Error("Process stopped due to error");
            }
        }
Пример #2
0
        /// <summary>
        /// Connon storage
        /// </summary>
        /// <param name="loggingLevel"></param>
        /// <param name="message"></param>
        private void LogMessage(LoggingLevel loggingLevel, string message)
        {
            string loggingLevelString = "";

            switch (loggingLevel)
            {
            case LoggingLevel.Info:
                loggingLevelString = "Info";
                break;

            case LoggingLevel.Debug:
                loggingLevelString = "Debug";
                break;

            case LoggingLevel.Warn:
                loggingLevelString = "Warn";
                break;

            case LoggingLevel.Error:
                loggingLevelString = "Error";
                break;

            case LoggingLevel.Fatal:
                loggingLevelString = "Fatal";
                break;

            default:
                break;
            }
            LogStorage.Storage(loggingLevel, $"\r\n---- [{DateTime.Now.ToString()}] {loggingLevelString}:\r\n{message}");
        }
Пример #3
0
        private async Task GenerateReport()
        {
            LogStorage.Clear(Logger.Category);
            ViewModel.ProgressInPercentage = 0;

            try
            {
                var progressTracker = _progressTrackerFactory.CreateForResourceFetching(value => ViewModel.ProgressInPercentage = value);

                (_userSession.GeneratedReportTempPath, _userSession.GeneratedDocument)
                    = await _reportResourceFetcher.Generate(_userSession.Document
                                                            , _userSession.IncludedVenues
                                                            , _userSession.ReportLanguage
                                                            , progressTracker);

                if (LogStorage.HasWarningOrErrors(Logger.Category))
                {
                    Logger.Info(Resources.StepGeneration_GenerateReport_DoneWithIssues);
                }
                else
                {
                    Logger.Info(Resources.StepGeneration_GenerateReport_Done);
                    await MainWindow.GoNext();
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                Logger.Error(ex.ToString());
#else
                Logger.Error(ex.Message);
#endif
                Logger.Error("Process stopped due to error");
            }
        }
Пример #4
0
        public void BeforeEachTests()
        {
            LogStorage.Initialize(new LogConfiguration());
            var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            this.LogDirectoryPath = Path.Combine(documents, "logs");
        }
Пример #5
0
        public LogView(LogStorage storage, int lastLine)
        {
            if (storage == null)
                throw new ArgumentNullException(nameof(storage));
            if (lastLine < 0 || lastLine > storage.Count)
                throw new ArgumentOutOfRangeException(nameof(lastLine));

            this.Storage = storage;
            this.LastLine = lastLine;
        }
Пример #6
0
 private static void SetMainStorages()
 {
     app  = new AppStorage(connection, locker);
     user = new UserStorage(connection, locker);
     log  = new LogStorage(connection, locker);
     file = new FileStorage(connection, locker);
     storages.Add(app);
     storages.Add(user);
     storages.Add(log);
     storages.Add(file);
 }
Пример #7
0
 private void SetMainStorages()
 {
     upload   = new UploadStorage(ref connection, ref locker);
     category = new CategoryStorage(ref connection, ref locker);
     price    = new PriceStorage(ref connection, ref locker);
     product  = new ProductStorage(ref connection, ref locker);
     log      = new LogStorage(ref connection, ref locker);
     storages.Add(log);
     storages.Add(product);
     storages.Add(upload);
     storages.Add(price);
     storages.Add(category);
     CheckTableExists(files_Create);
 }
        private static void CreateLogStorage(LogStorage logStorage)
        {
            if (logStorage == LogStorage.File)
            {
                // Create a new log file for every day
                if (logStartDay != DateTime.Now.DayOfYear)
                {
                    // Close the existing log file writer if it's open
                    if (logWriter != null)
                    {
                        logWriter.Close();
                        logWriter   = null;
                        logStartDay = -1;
                    }

                    string logDirectory = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.LogDirectory);

                    if (!Directory.Exists(logDirectory))
                    {
                        Directory.CreateDirectory(logDirectory);
                    }

                    string logFilename = logDirectory + "\\" + DateTime.Today.ToString("MM-dd-yyyy") + ".log";

                    // Check to see if the log already exists
                    logWriter = (TextWriter) new StreamWriter(logFilename, true, Encoding.UTF8);

                    logStartDay = DateTime.Now.DayOfYear;
                }
            }
            else if (logStorage == LogStorage.SystemEventLog)
            {
                if (logWriter != null)
                {
                    logWriter.Close();
                    logWriter   = null;
                    logStartDay = -1;
                }

                if (eventLog == null)
                {
                    if (!EventLog.SourceExists(Services.PrivateLabelService.ReplaceProductName("CallButler Log")))
                    {
                        EventLog.CreateEventSource(Services.PrivateLabelService.ReplaceProductName("CallButler Log"), Services.PrivateLabelService.ReplaceProductName("CallButler Log"));
                    }

                    // Create an EventLog instance and assign its source.
                    eventLog        = new EventLog();
                    eventLog.Source = Services.PrivateLabelService.ReplaceProductName("CallButler Log");
                    eventLog.Log    = Services.PrivateLabelService.ReplaceProductName("CallButler Log");
                }
            }
            else
            {
                if (logWriter != null)
                {
                    logWriter.Close();
                    logWriter   = null;
                    logStartDay = -1;
                }

                if (eventLog != null)
                {
                    eventLog.Close();
                    eventLog.Dispose();
                    eventLog = null;
                }
            }
        }
Пример #9
0
 /// <summary>
 /// Constructor for LogCommand class
 /// </summary>
 /// <param name="modal">an Image Service Modal instance</param>
 public LogCommand(IImageServiceModal modal)
 {
     //Storing the modal
     m_modal      = modal;
     m_logStorage = LogStorage.Instance;
 }
Пример #10
0
 public void BeforeEachTests()
 {
     LogStorage.Initialize(new LogConfiguration());
     LogDirectoryPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "logs");
     Directory.CreateDirectory(LogDirectoryPath);
 }
Пример #11
0
 public void SetupTests()
 {
     LogStorage.Initialize(new LogConfiguration());
     UserPreferences = new UserPreferences();
     UserPreferences.ClearSaves();
 }
Пример #12
0
        private static void CreateLogStorage(LogStorage logStorage)
        {
            if (logStorage == LogStorage.File)
            {
                // Create a new log file for every day
                if (logStartDay != DateTime.Now.DayOfYear)
                {
                    // Close the existing log file writer if it's open
                    if (logWriter != null)
                    {
                        logWriter.Close();
                        logWriter = null;
                        logStartDay = -1;
                    }

                    string logDirectory = WOSI.Utilities.FileUtils.GetApplicationRelativePath(Properties.Settings.Default.LogDirectory);

                    if (!Directory.Exists(logDirectory))
                    {
                        Directory.CreateDirectory(logDirectory);
                    }

                    string logFilename = logDirectory + "\\" + DateTime.Today.ToString("MM-dd-yyyy") + ".log";

                    // Check to see if the log already exists
                    logWriter = (TextWriter)new StreamWriter(logFilename, true, Encoding.UTF8);

                    logStartDay = DateTime.Now.DayOfYear;
                }
            }
            else if (logStorage == LogStorage.SystemEventLog)
            {
                if (logWriter != null)
                {
                    logWriter.Close();
                    logWriter = null;
                    logStartDay = -1;
                }

                if (eventLog == null)
                {
                    if (!EventLog.SourceExists(Services.PrivateLabelService.ReplaceProductName("CallButler Log")))
                    {
                        EventLog.CreateEventSource(Services.PrivateLabelService.ReplaceProductName("CallButler Log"), Services.PrivateLabelService.ReplaceProductName("CallButler Log"));
                    }

                    // Create an EventLog instance and assign its source.
                    eventLog = new EventLog();
                    eventLog.Source = Services.PrivateLabelService.ReplaceProductName("CallButler Log");
                    eventLog.Log = Services.PrivateLabelService.ReplaceProductName("CallButler Log");
                }
            }
            else
            {
                if (logWriter != null)
                {
                    logWriter.Close();
                    logWriter = null;
                    logStartDay = -1;
                }

                if (eventLog != null)
                {
                    eventLog.Close();
                    eventLog.Dispose();
                    eventLog = null;
                }
            }
        }