Example #1
0
        private IEnumerable <DirectoryFile> ScanFolder()
        {
            List <DirectoryFile> fileList = new List <DirectoryFile>();

            string[] fileListString = Directory.GetFiles(FolderName);
            foreach (var file in fileListString)
            {
                DirectoryFile newFile = new DirectoryFile
                {
                    FileName   = file,
                    FolderName = FolderName
                };
                ClassLogger.Info(file.Substring(FolderName.Length + 1, 3).ToUpper());
                string extension = Path.GetExtension(file);
                switch (extension.ToUpper())
                {
                case ".OFX":
                    newFile.DirectoryFileType = FileType.Expense;
                    break;

                case ".CSV":
                    switch (file.Substring(FolderName.Length + 1, 3).ToUpper())
                    {
                    case "INV":
                        newFile.DirectoryFileType = FileType.Invoice;
                        break;

                    case "EXP":
                        newFile.DirectoryFileType = FileType.Expense;
                        break;

                    case "BAN":
                        newFile.DirectoryFileType = FileType.Expense;
                        break;

                    default:
                        newFile.DirectoryFileType = FileType.Invalid;
                        break;
                    }
                    break;

                default:
                    newFile.DirectoryFileType = FileType.Invalid;
                    break;
                }
                if (!(newFile.DirectoryFileType == FileType.Invalid))
                {
                    fileList.Add(newFile);
                }
            }
            return(fileList);
        }
Example #2
0
        public void Stop()
        {
            try
            {
                ClassLogger.Info("Stopping Service...");
                const int timeout = 7 * 60;
                _c.Stop();

                const ServiceControllerStatus targetStatus = ServiceControllerStatus.Stopped;
                _c.WaitForStatus(targetStatus, TimeSpan.FromSeconds(timeout));
            }
            catch (Exception ex)
            {
                ClassLogger.Error("Error in stopping service: {0}", ex);
            }
        }
        public void TestClassLogger()
        {
            var inMemoryProvider = new InMemoryDatabaseProvider();

            TheLog.AddProvider(inMemoryProvider, LogLevel.Info);
            TheLog.FilterThreshold = LogLevel.Info;

            _logger.Info("Test");
            _logger.Trace("Test2");
            _logger.Error("Test");

            Assert.AreEqual(2, inMemoryProvider.Messages.Count);
            Assert.IsTrue(inMemoryProvider.Messages[0].LogMessage.Category.Contains("LoggingTests"));

            inMemoryProvider.ClearLog();
            _logger.Error("Test", "ABC");
            Assert.IsTrue(inMemoryProvider.Messages[0].LogMessage.Category.Contains("LoggingTests"));
            Assert.IsTrue(inMemoryProvider.Messages[0].LogMessage.Category.Contains("ABC"));
        }
        public void TestClassLoggerLevel()
        {
            TheLog.FilterThreshold = LogLevel.Trace;
            TheLog.AddProvider(InMemoryDatabaseProvider.TheOne, LogLevel.Trace);
            var database = InMemoryDatabaseProvider.TheOne;

            var classLogger = new ClassLogger(typeof(LoggingTests));

            classLogger.Trace("Test");
            Assert.AreEqual(LogLevel.Trace, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel);
            classLogger.Debug("Test");
            Assert.AreEqual(LogLevel.Debug, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel);
            classLogger.Info("Test");
            Assert.AreEqual(LogLevel.Info, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel);
            classLogger.Warn("Test");
            Assert.AreEqual(LogLevel.Warn, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel);
            classLogger.Error("Test");
            Assert.AreEqual(LogLevel.Error, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel);
            classLogger.Fatal("Test");
            Assert.AreEqual(LogLevel.Fatal, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel);

            classLogger.Log(LogLevel.Debug, "Message");
            Assert.AreEqual(LogLevel.Debug, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel);
        }
Example #5
0
 private void OnChanged(object source, FileSystemEventArgs e)
 {
     _isDirty = true;
     ClassLogger.Info("Folder changed, repository marked as dirty.");
 }
Example #6
0
 public void OnStop()
 {
     ClassLogger.Info("Service Stopped - XService");
 }
Example #7
0
 public void OnStart(string[] args)
 {
     ClassLogger.Info("Service Started - XService");
 }