Esempio n. 1
0
        private static void JobLoggerApp()
        {
            try
            {
                ConsoleConfiguration();
                var container = IocConfigApp.RegisterIoc();
                int result = 0;
                var validations = string.Empty;
                var objJobLogger = JobLogger.GetSingleton();
                var objResponse = Response.GetSingleton();

                Console.WriteLine("Select configuration ");
                Console.WriteLine("1 - File");
                Console.WriteLine("2 - Database");

                int.TryParse(Console.ReadLine(), out result);
                objJobLogger.Configuration = result;

                Console.WriteLine("Select the type of message: ");
                Console.WriteLine("1 - Error");
                Console.WriteLine("2 - Warning");
                Console.WriteLine("3 - Message");
                int.TryParse(Console.ReadLine(), out result);
                objJobLogger.TypeMessage = result;

                Console.WriteLine("Type your message here : ");
                objJobLogger.Message = Console.ReadLine();

                Validar(objJobLogger);

                using (var resolver = container.BeginLifetimeScope())
                {
                    var JobloggerDomain = resolver.ResolveKeyed<IJobloggerDomain>((Configuration)objJobLogger.Configuration);
                    JobLoggerService srv = new JobLoggerService(JobloggerDomain);
                    objResponse = srv.SaveLogger(objJobLogger);
                }

                //ForeColor
                switch (objJobLogger.TypeMessage)
                {
                    case (int)TypeMessage.Error:
                        Console.ForegroundColor = ConsoleColor.Red;
                        break;
                    case (int)TypeMessage.Warning:
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        break;
                    case (int)TypeMessage.Message:
                        Console.ForegroundColor = ConsoleColor.White;
                        break;
                };
                Console.WriteLine(DateTime.Now.ToShortDateString() + ": " + string.Join(string.Empty, objResponse.Message));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
            JobLoggerApp();
        }
Esempio n. 2
0
        public void TestSaveFile()
        {
            var objJobLogger = JobLogger.GetSingleton();
            objJobLogger.Message = "Test File " + DateTime.Now.ToLongDateString() + "Message";
            objJobLogger.Configuration = (int)Configuration.File;
            objJobLogger.TypeMessage = (int)TypeMessage.Error;

            var container = IocConfigTest.RegisterIoc();

            using (var resolver = container.BeginLifetimeScope())
            {
                var JobloggerDomain = resolver.ResolveKeyed<IJobloggerDomain>(Configuration.File);
                JobLoggerService srv = new JobLoggerService(JobloggerDomain);
                Assert.AreEqual(true, srv.SaveLogger(objJobLogger).success);
            }
        }