private bool ReadFileData(string filename)
        {
            //
            // If PDF and scanning method is image, then PDF needs to be split into separate images for each page
            // These individual pages then need to be scanned in using the Acusoft toolset (Syncfusion does not support images, only PDF image source files)

            //// Splid PDF into pages
            ////if (Path.GetExtension(fileStatus.fileName).ToLower() == ".pdf")
            ////{
            ////    // Process PDF file ready for scanning - split pages and export multiple .jpg.
            ////    // This is currently dummy code, not yet implimented. See samples from Syncfusion on how to complete, if required
            ////    var zz = ProcessPDF.Main(fileStatus.fileName);
            ////}
            ScanPageStatus scanPageStatus = new ScanPageStatus();
            ProcessImage   processImage   = new ProcessImage();

            scanPageStatus = processImage.ReadFile(filename);

            if (scanPageStatus.rc < 0)
            {
                logger.Error(scanPageStatus.statusMessage);
                return(false);
            }
            if (scanPageStatus.rc == 0)
            {
                logger.Info(scanPageStatus.statusMessage);
            }
            else
            {
                logger.Warn(scanPageStatus.statusMessage);
            }

            return(true);
        }
Exemplo n.º 2
0
        public void Log4NetLogger_LoggingTest()
        {
            string    message       = "Error Message";
            Exception ex            = new Exception();
            string    messageFormat = "Message Format: message: {0}, exception: {1}";

            ILog log = new Log4NetLogger(GetType());

            Assert.IsNotNull(log);

            log.Debug(message);
            log.Debug(message, ex);
            log.DebugFormat(messageFormat, message, ex.Message);

            log.Error(message);
            log.Error(message, ex);
            log.ErrorFormat(messageFormat, message, ex.Message);

            log.Fatal(message);
            log.Fatal(message, ex);
            log.FatalFormat(messageFormat, message, ex.Message);

            log.Info(message);
            log.Info(message, ex);
            log.InfoFormat(messageFormat, message, ex.Message);

            log.Warn(message);
            log.Warn(message, ex);
            log.WarnFormat(messageFormat, message, ex.Message);
        }
        public void When_logging_using_info()
        {
            _logger.Info("Hi");
            _mockedLogger.Verify(l => l.Info("Hi"), Times.Once);

            var ex = new InvalidOperationException();

            _logger.Info("Ooops", ex);
            _mockedLogger.Verify(l => l.Info("Ooops", ex), Times.Once);
        }
Exemplo n.º 4
0
 public void SimpleLogTest()
 {
     var myLogger = new Log4NetLogger(typeof(Log4NetLogger));
     myLogger.Debug("FooBar");
     myLogger.Warning("FooBar");
     myLogger.Error("FooBar");
     myLogger.Error(new Exception(), "FooBar");
     myLogger.Info("FooBar");
     myLogger.Info("FooBar", "Bar");
     Assert.AreEqual(myLogger.IsDebugEnabled, myLogger.IsDebugEnabled); // We don't care about the actual value.
 }
Exemplo n.º 5
0
        public void SimpleLogTest()
        {
            var myLogger = new Log4NetLogger(typeof(Log4NetLogger));

            myLogger.Debug("FooBar");
            myLogger.Warning("FooBar");
            myLogger.Error("FooBar");
            myLogger.Error(new Exception(), "FooBar");
            myLogger.Info("FooBar");
            myLogger.Info("FooBar", "Bar");
            Assert.AreEqual(myLogger.IsDebugEnabled, myLogger.IsDebugEnabled); // We don't care about the actual value.
        }
Exemplo n.º 6
0
        public void CallingMethods()
        {
            var logMock = new LogMock();
            var logger  = new Log4NetLogger(logMock);
            var b       = logger.IsDebugEnabled;

            b = logger.IsErrorEnabled;
            b = logger.IsFatalEnabled;
            b = logger.IsInfoEnabled;
            b = logger.IsWarnEnabled;

            logger.Debug(null);
            logger.Debug(null, null);
            logger.DebugFormat(null, null);

            logger.Error(null);
            logger.Error(null, null);
            logger.ErrorFormat(null, null);

            logger.Warn(null);
            logger.Warn(null, null);
            logger.WarnFormat(null, null);

            logger.Info(null);
            logger.Info(null, null);
            logger.InfoFormat(null, null);

            logger.Fatal(null);
            logger.Fatal(null, null);

            logMock.debug.Should().Be(1);
            logMock.debugException.Should().Be(1);
            logMock.debugFormat.Should().Be(1);
            logMock.info.Should().Be(1);
            logMock.infoException.Should().Be(1);
            logMock.infoFormat.Should().Be(1);
            logMock.warn.Should().Be(1);
            logMock.warnException.Should().Be(1);
            logMock.warnFormat.Should().Be(1);
            logMock.error.Should().Be(1);
            logMock.errorException.Should().Be(1);
            logMock.errorFormat.Should().Be(1);
            logMock.fatal.Should().Be(1);
            logMock.fatalException.Should().Be(1);
            logMock.isDebugEnabled.Should().Be.GreaterThan(1);
            logMock.isInfoEnabled.Should().Be.GreaterThan(1);
            logMock.isWarnEnabled.Should().Be.GreaterThan(1);
            logMock.isErrorEnabled.Should().Be.GreaterThan(1);
            logMock.isFatalEnabled.Should().Be.GreaterThan(1);
        }
Exemplo n.º 7
0
        public void CallingMethods()
        {
            var logMock = new LogMock();
            var logger  = new Log4NetLogger(logMock);
            var b       = logger.IsDebugEnabled;

            b = logger.IsErrorEnabled;
            b = logger.IsFatalEnabled;
            b = logger.IsInfoEnabled;
            b = logger.IsWarnEnabled;

            logger.Debug(null);
            logger.Debug(null, null);
            logger.DebugFormat(null, null);

            logger.Error(null);
            logger.Error(null, null);
            logger.ErrorFormat(null, null);

            logger.Warn(null);
            logger.Warn(null, null);
            logger.WarnFormat(null, null);

            logger.Info(null);
            logger.Info(null, null);
            logger.InfoFormat(null, null);

            logger.Fatal(null);
            logger.Fatal(null, null);

            Assert.That(logMock.debug, Is.EqualTo(1));
            Assert.That(logMock.debugException, Is.EqualTo(1));
            Assert.That(logMock.debugFormat, Is.EqualTo(1));
            Assert.That(logMock.info, Is.EqualTo(1));
            Assert.That(logMock.infoException, Is.EqualTo(1));
            Assert.That(logMock.infoFormat, Is.EqualTo(1));
            Assert.That(logMock.warn, Is.EqualTo(1));
            Assert.That(logMock.warnException, Is.EqualTo(1));
            Assert.That(logMock.warnFormat, Is.EqualTo(1));
            Assert.That(logMock.error, Is.EqualTo(1));
            Assert.That(logMock.errorException, Is.EqualTo(1));
            Assert.That(logMock.errorFormat, Is.EqualTo(1));
            Assert.That(logMock.fatal, Is.EqualTo(1));
            Assert.That(logMock.fatalException, Is.EqualTo(1));
            Assert.That(logMock.isDebugEnabled, Is.GreaterThan(1));
            Assert.That(logMock.isInfoEnabled, Is.GreaterThan(1));
            Assert.That(logMock.isWarnEnabled, Is.GreaterThan(1));
            Assert.That(logMock.isErrorEnabled, Is.GreaterThan(1));
            Assert.That(logMock.isFatalEnabled, Is.GreaterThan(1));
        }
Exemplo n.º 8
0
        public Project Update(Project Project)
        {
            ProjectRepository <Project> Projectrepo = new ProjectRepository <Project>();
            int?rta = Projectrepo.Update(Project);

            if (rta == null)
            {
                return(null);
            }
            else
            {
                SUser    suser = new SUser();
                SProject spro  = new SProject();
                var      user  = suser.GetUserByOffer(Project.IdOffer, 1);
                //var user = suser.GetUserById(new Guid(Project.Offer.IdUser));

                try
                {
                    Log4NetLogger logger2 = new Log4NetLogger();
                    SCategory     scate   = new SCategory();
                    var           cate    = scate.FindCategoryById(Project.IdCategory);
                    logger2.Info("Creación Proyecto:" + Project.Id + "," + "UsuarioOrigen:" + user.UserName + ",Categoria:" + cate.Name);
                }
                catch
                {
                }

                return(Project);
            }
        }
Exemplo n.º 9
0
 public static void Info(string message)
 {
     SPSecurity.RunWithElevatedPrivileges(delegate()
     {
         logger.Info(message);
     });
 }
Exemplo n.º 10
0
        private void RunInfoLogMessageTests(bool withFormattedMessage)
        {
            LogMessageExpectations logMessageExpectations =
                GenerateLogMessageExpectations(withFormattedMessage);

            TargetLoggerMockLoggerSetupProperties targetLoggerSetupProps = TargetLoggerMockLoggerSetupProperties
                                                                           .InfoEnabledWithExpectations(logMessageExpectations);

            Mock <ILog> targetLoggerMock =
                CreateLog4NetLoggerMock(targetLoggerSetupProps);

            Log4NetLogger stakhanoviseLogger =
                new Log4NetLogger(targetLoggerMock.Object);

            if (withFormattedMessage)
            {
                stakhanoviseLogger.InfoFormat(logMessageExpectations.ExpectedMessage, logMessageExpectations.ExpectedMessageArgs);
            }
            else
            {
                stakhanoviseLogger.Info(logMessageExpectations.ExpectedMessage);
            }

            targetLoggerMock.Verify();
        }
        protected void InitDefaults()
        {
            // Check if the required service is already present, then no action is required
            bool pathManagerAvailable = ServiceRegistration.Get <Common.PathManager.IPathManager>(false) != null;

            if (pathManagerAvailable && _pathManagerWrapper != null && _loggerWrapper != null)
            {
                return;
            }

            if (_pathManagerWrapper != null && _loggerWrapper != null)
            {
                return;
            }

            // If running outside of MP2 scope
            if (!pathManagerAvailable)
            {
                ServiceRegistration.Set <Common.Logging.ILogger>(new NoLogger());

                Common.Services.PathManager.PathManager pathManager = new Common.Services.PathManager.PathManager();
                pathManager.InitializeDefaults();

                ServiceRegistration.Set <Common.PathManager.IPathManager>(pathManager);

                Common.Logging.ILogger logger = new Log4NetLogger(pathManager.GetPath(@"<LOG>"));
                logger.Info("MP2IntegrationProvider: Launching in AppDomain {0}...", AppDomain.CurrentDomain.FriendlyName);
            }

            _pathManagerWrapper = new PathManagerWrapper();
            _loggerWrapper      = new LoggerWrapper();
        }
        public static void Build()
        {
            if (_container != null)
            {
                throw new InvalidOperationException("Dependency Container already initialized.");
            }
            // Create Logger
            _logger = new Log4NetLogger();
            _logger.Info(">> Building Container");
            var builder = new ContainerBuilder();

            //Register Global Dependencies
            builder.RegisterInstance(_logger).As <ILogger>().SingleInstance();
            builder.RegisterType <UtcDateTimeProvider>().As <IDateTimeProvider>().SingleInstance();
            builder.RegisterType <AppConfigSettingsProvider>().As <ISettingsProvider>().SingleInstance();
            builder.RegisterType <DefaultPasswordHashProvider>().As <IPasswordHashProvidcer>().SingleInstance();
            builder.RegisterType <DefaultEncryptionProvider>().As <IEncryptionProvider>().SingleInstance();
            builder.RegisterType <DefaultRandomNumberGenerator>().As <IRandomNumberGenerator>().SingleInstance();

            // Running
            //TODO: We should PREVENT direct access to DbContext
            builder.RegisterType <ScpDbContext>().AsSelf().InstancePerRequest();
            builder.RegisterType <ScpUnitOfWork>().As <IScpUnitOfWork>().InstancePerRequest();

            // Autofac Integration
            // Register your MVC controllers. (MvcApplication is the name of
            // the class in Global.asax.)
            builder.RegisterControllers(typeof(MvcApplication).Assembly);

            // OPTIONAL: Register model binders that require DI.
            builder.RegisterModelBinders(typeof(MvcApplication).Assembly);
            builder.RegisterModelBinderProvider();

            // OPTIONAL: Register web abstractions like HttpContextBase.
            builder.RegisterModule <AutofacWebTypesModule>();

            //// OPTIONAL: Enable property injection in view pages.
            //builder.RegisterSource(new ViewRegistrationSource());

            // OPTIONAL: Enable property injection into action filters.
            builder.RegisterFilterProvider();

            // Set the dependency resolver to be Autofac.
            _container = builder.Build();
            DependencyResolver.SetResolver(new AutofacDependencyResolver(_container));
            _logger.Info("<< Building Container");
        }
Exemplo n.º 13
0
        public void InfoTest()
        {
            log4net.Config.XmlConfigurator.Configure(new FileInfo("./Conf/log4net.conf"));
            log4net.ILog  log    = log4net.LogManager.GetLogger("Test");
            Log4NetLogger logger = new Log4NetLogger(log);

            logger.Info($"Test{DateTime.Now}");
        }
Exemplo n.º 14
0
        public async Task Execute(IJobExecutionContext context)
        {
            await Task.Run(() =>
            {
                ///这里可以调用其他项目的Api 模拟http请求
                ///可以访问数据库

                log4NetLogger.Info("******************************************");
                log4NetLogger.Info($"大家好! 欢迎大家来到.Net高级班的Vip课程!{ DateTime.Now} ");
                log4NetLogger.Info("******************************************");

                //Console.WriteLine("");
                //Console.WriteLine("******************************************");
                //Console.WriteLine($"大家好! 欢迎大家来到.Net高级班的Vip课程!{DateTime.Now}");
                //Console.WriteLine("******************************************");
                //Console.WriteLine("");
            });
        }
Exemplo n.º 15
0
        public void WriteToConsoleTest()
        {
            Log4NetLogger logger = new Log4NetLogger();

            logger.Fatal("Fatal message");
            logger.Error("Error message");
            logger.Info("Info message");
            logger.Debug("Debug message");
        }
Exemplo n.º 16
0
        public void DefaultLogger_InfoLog_MessageExposedTest()
        {
            //Arrange
            var messages = new List <Tuple <LogLevel, string, Exception> >();
            var logger   = new Log4NetLogger("Test");

            logger.LogMessageHandler += (x, y, z) => messages.Add(new Tuple <LogLevel, string, Exception>(x, y, z));
            var testMessage   = "Test message";
            var testException = new Exception("Test");

            //Act
            logger.Info(testMessage);
            logger.Info(testException);
            logger.Info(testMessage, testException);
            //Assert
            Assert.AreEqual(3, messages.Count);
            Assert.AreEqual(new Tuple <LogLevel, string, Exception>(LogLevel.Info, testMessage, null), messages[0], "Log entry with message was not exposed correctly.");
            Assert.AreEqual(new Tuple <LogLevel, string, Exception>(LogLevel.Info, string.Empty, testException), messages[1], "Log entry with exception was not exposed correctly.");
            Assert.AreEqual(new Tuple <LogLevel, string, Exception>(LogLevel.Info, testMessage, testException), messages[2], "Log entry with message and exception was not exposed correctly.");
        }
        public void InfoShouldForwardsMessageToInnerInfo()
        {
            var message = "somemessage";
            var mockLog = new Mock <log4net.ILog>();

            mockLog.Setup(x => x.Info(message)).Verifiable();
            ILog tested = new Log4NetLogger(mockLog.Object);

            tested.Info(message);
            mockLog.Verify();
        }
Exemplo n.º 18
0
        /// <summary>
        /// Creates vital core service instances and registers them in <see cref="ServiceRegistration"/>. The optional <paramref name="dataDirectory"/> argument can
        /// be used to startup the application using a custom directory for data storage.
        /// </summary>
        /// <param name="dataDirectory">Path to custom data directory</param>
        public static void RegisterVitalCoreServices(string dataDirectory = null)
        {
            // Insert a dummy while loading the path manager to break circular dependency of logger and path manager. This should not
            // be considered as a hack - simply the logger needs a path managed by the path manager and I don't want to remove log
            // output from the path manager only to prevent the dependency. Maybe we have a better solution in the future.
            ServiceRegistration.Set <ILogger>(new NoLogger());

            Services.PathManager.PathManager pathManager = new Services.PathManager.PathManager();
            pathManager.InitializeDefaults();
            if (!string.IsNullOrEmpty(dataDirectory))
            {
                pathManager.SetPath("DATA", dataDirectory);
            }

            ServiceRegistration.Set <IPathManager>(pathManager);

            ILogger logger = new Log4NetLogger(pathManager.GetPath(@"<LOG>"));

            logger.Info("ApplicationCore: Launching in AppDomain {0}...", AppDomain.CurrentDomain.FriendlyName);

            // Assembly and build information
            FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetCallingAssembly().Location);

            logger.Info("ApplicationCore: Comments:   {0}", fileVersionInfo.Comments);
            logger.Info("ApplicationCore: Copyright:  {0}", fileVersionInfo.LegalCopyright);
            logger.Info("ApplicationCore: Version:    {0}", fileVersionInfo.FileVersion);
            logger.Info("ApplicationCore: Source:     {0}", fileVersionInfo.ProductVersion);
            logger.Info("ApplicationCore: ----------------------------------------------------------");

            logger.Debug("ApplicationCore: Registering ILogger service");
            ServiceRegistration.Set <ILogger>(logger);

            logger.Debug("ApplicationCore: Registering ISettingsManager service");
            ServiceRegistration.Set <ISettingsManager>(new SettingsManager());
        }
Exemplo n.º 19
0
        public IEnumerable <WeatherForecast> GetWeatherForecast()
        {
            var rng = new Random();

            Log4NetLogger.Info(rng.ToString());
            return(Enumerable.Range(1, 5).Select(index => new WeatherForecast
            {
                Date = DateTime.Now.AddDays(index),
                TemperatureC = rng.Next(-20, 55),
                Summary = Summaries[rng.Next(Summaries.Length)]
            })
                   .ToArray());
        }
        public void FormattedInfoShouldForwardsMessageToInnerInfoFormat()
        {
            var format   = "formatted message";
            var args     = new object[] { "arg1", "arg2" };
            var provider = new Mock <IFormatProvider>().Object;
            var mockLog  = new Mock <log4net.ILog>();

            mockLog.Setup(x => x.InfoFormat(provider, format, args)).Verifiable();
            ILog tested = new Log4NetLogger(mockLog.Object);

            tested.Info(provider, format, args);
            mockLog.Verify();
        }
Exemplo n.º 21
0
        public void UpdatePhases(List <OfferPhases> listOfferPhases, int IdOffer)
        {
            OfferRepository <OfferPhases> Offerrepo = new OfferRepository <OfferPhases>();

            Offerrepo.UpdatePhases(listOfferPhases, IdOffer);
            Log4NetLogger logger2 = new Log4NetLogger();
            SUser         suser   = new SUser();

            foreach (var oferfases in listOfferPhases)
            {
                var user = suser.GetUserById(new Guid(oferfases.Offer.IdUser));
                logger2.Info("Actualización Fases Oferta:" + IdOffer + "," + "UsuarioOrigen:" + user.UserName + ",Fase:" + oferfases.Name);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// 同步制定OU路径下的所有子OU和Users
        /// </summary>
        /// <param name="adLDAPPath">OULdAp路径</param>
        public static List <AdModel> GetFirstLevelOUByPath(string[] adLDAPPath)
        {
            List <AdModel> listadMOdel = new List <AdModel>();

            foreach (string path in adLDAPPath)
            {
                string LDAPPath = path + "," + LDAPDomain;

                DirectoryEntry searchRoot = new DirectoryEntry(LDAPPath, ADUser, ADPassword, AuthenticationTypes.Secure);

                if (searchRoot.Properties.Contains("ou"))
                {
                    string rootOuName = searchRoot.Properties["ou"][0].ToString();

                    string id = Convert.ToString(searchRoot.Guid);

                    string  ldapPath = searchRoot.Path;
                    AdModel adMOdel  = new AdModel();
                    adMOdel.Id        = id;
                    adMOdel.LDAPPath  = ldapPath;
                    adMOdel.LoginName = rootOuName;
                    adMOdel.Name      = rootOuName;
                    adMOdel.TypeId    = (int)TypeEnum.OU;
                    adMOdel.ParentId  = "0";

                    listadMOdel.Add(adMOdel);

                    logger.Info("Ldap地址:" + LDAPPath + "获取到第一层OU信息: " + rootOuName + " 用户:" + ADUser);
                }
                else
                {
                    logger.Info("Ldap地址:" + LDAPPath + "未获取到第一层OU信息 " + " 用户:" + ADUser);
                }
            }

            return(listadMOdel);
        }
Exemplo n.º 23
0
        public void Info_LambdaMessage()
        {
            // Prepare
            const string message = "Simple Info";

            logger.SetupGet(o => o.IsInfoEnabled).Returns(() => true);
            logger.Setup(o => o.Info(message)).Verifiable();
            log = new Log4NetLogger(logger.Object);

            // Act
            log.Info(() => message);

            // Assert
            logger.VerifyAll();
        }
Exemplo n.º 24
0
        public async Task <IHttpActionResult> GetCategoriesById(int id)
        {
            Log4NetLogger logger = new Log4NetLogger();

            logger.Info("Hi There this is naveen");

            var clientRequests = await _categoryManager.GetById(id);

            if (clientRequests == null)
            {
                return(NotFound());
            }

            return(Ok(clientRequests));
        }
Exemplo n.º 25
0
        public void Info_NoMessage()
        {
            // Prepare
            const string message = "Simple Info";

            logger.SetupGet(o => o.IsInfoEnabled).Returns(() => false);
            logger.Setup(o => o.Info(message)).Callback(() => counterCall++).Verifiable();
            log = new Log4NetLogger(logger.Object);

            // Act
            log.Info(message);

            // Assert
            Assert.AreEqual(counterCall, 0);
        }
Exemplo n.º 26
0
        public void Info_MessageWithException()
        {
            // Prepare
            const string message = "Exception occurred";
            var          ex      = new Exception(message);

            logger.SetupGet(o => o.IsInfoEnabled).Returns(() => true);
            logger.Setup(o => o.Info(message, ex)).Verifiable();
            log = new Log4NetLogger(logger.Object);

            // Act
            log.Info(message, ex);

            // Assert
            logger.VerifyAll();
        }
Exemplo n.º 27
0
        public Project Insert(Project Project, Persistence.Entities.ProjectUser projectuser)
        {
            ProjectRepository <Project> Projectrepo = new ProjectRepository <Project>();
            int?rta = Projectrepo.Insert(Project, projectuser.IdUser);

            if (rta == null)
            {
                return(null);
            }
            else
            {
                Log4NetLogger logger2 = new Log4NetLogger();

                logger2.Info("Creación Proyecto:" + Project.Id + "," + "UsuarioOrigen:" + projectuser.IdUser + ",Categoria:" + Project.IdCategory);
                return(Project);
            }
        }
Exemplo n.º 28
0
        public Project Insert(Project Project)
        {
            ProjectRepository <Project> Projectrepo = new ProjectRepository <Project>();
            int?rta = Projectrepo.Insert(Project);

            if (rta == null)
            {
                return(null);
            }
            else
            {
                Log4NetLogger logger2 = new Log4NetLogger();
                SCategory     scate   = new SCategory();
                var           cate    = scate.FindCategoryById(Project.IdCategory);
                SOffer        sofer   = new SOffer();
                var           offer   = sofer.Get(Project.IdOffer);
                logger2.Info("Creación Proyecto:" + Project.Id + "," + "UsuarioOrigen:" + offer.IdUser + ",Categoria:" + cate.Name);
                return(Project);
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// WriteToLog method to handle logs by log4Net based on priority and category
        /// </summary>
        /// <param name="message"></param>
        /// <param name="priority"></param>
        /// <param name="category"></param>
        public static void WriteToLog(string message, string priority, string category)
        {
            Log4NetLogger.Info(string.Concat(System.DateTime.Now.ToString(), " - Category : ", category, " - Priority : ", priority));

            // Log4Net Switch case for Exception category
            switch (category)
            {
            case "General":
                Log4NetLogger.Info(message);
                break;

            case "Trace":
                Log4NetLogger.Info(message);
                break;

            case "Error":
                Log4NetLogger.Error(message);
                break;
            }
        }
Exemplo n.º 30
0
        public static void TaskStart()
        {
            log4NetLogger.Info("this is test");

            DateTime startTime = new DateTime(2019, 12, 5, 22, 25, 1);

            Console.WriteLine("任务开始了。。。。");
            //Task.Run(() =>
            //{
            //    while (true)
            //    {
            //        var now = DateTime.Now;
            //        if (now.Year == startTime.Year && now.Month == startTime.Month && now.Day == startTime.Day && now.Hour == startTime.Hour && now.Minute == now.Minute)
            //        {
            //            Console.WriteLine("OK...这里就去提示了!");
            //            break;
            //        }
            //    }
            //});
        }
Exemplo n.º 31
0
        public Offer Insert(Offer Offer)
        {
            OfferRepository <Offer> Offerrepo = new OfferRepository <Offer>();
            SCategory scate = new SCategory();
            var       cate  = scate.FindCategoryById(Offer.CategoryId);

            Offer.DateOffer = DateTime.Now;
            int?rta = Offerrepo.Insert(Offer);

            if (rta == null)
            {
                return(null);
            }
            else
            {
                Offer.Id = (int)rta;
                Log4NetLogger logger2 = new Log4NetLogger();
                SUser         suser   = new SUser();
                var           user    = suser.GetUserById(new Guid(Offer.IdUser));
                logger2.Info("Creación Oferta:" + Offer.TitleOffer + "," + "Por:" + user.UserName + ",Categoria:" + cate.Name);
                return(Offer);
            }
        }
Exemplo n.º 32
0
		public void CallingMethods()
		{
			var logMock = new LogMock();
			var logger = new Log4NetLogger(logMock);
			var b = logger.IsDebugEnabled;
			b = logger.IsErrorEnabled;
			b = logger.IsFatalEnabled;
			b = logger.IsInfoEnabled;
			b = logger.IsWarnEnabled;
			
			logger.Debug(null);
			logger.Debug(null, null);
			logger.DebugFormat(null, null);
			
			logger.Error(null);
			logger.Error(null, null);
			logger.ErrorFormat(null, null);
			
			logger.Warn(null);
			logger.Warn(null, null);
			logger.WarnFormat(null, null);
		
			logger.Info(null);
			logger.Info(null, null);
			logger.InfoFormat(null, null);

			logger.Fatal(null);
			logger.Fatal(null, null);

			logMock.debug.Should().Be(1);
			logMock.debugException.Should().Be(1);
			logMock.debugFormat.Should().Be(1);
			logMock.info.Should().Be(1);
			logMock.infoException.Should().Be(1);
			logMock.infoFormat.Should().Be(1);
			logMock.warn.Should().Be(1);
			logMock.warnException.Should().Be(1);
			logMock.warnFormat.Should().Be(1);
			logMock.error.Should().Be(1);
			logMock.errorException.Should().Be(1);
			logMock.errorFormat.Should().Be(1);
			logMock.fatal.Should().Be(1);
			logMock.fatalException.Should().Be(1);
			logMock.isDebugEnabled.Should().Be.GreaterThan(1);
			logMock.isInfoEnabled.Should().Be.GreaterThan(1);
			logMock.isWarnEnabled.Should().Be.GreaterThan(1);
			logMock.isErrorEnabled.Should().Be.GreaterThan(1);
			logMock.isFatalEnabled.Should().Be.GreaterThan(1);
		}
Exemplo n.º 33
0
        public void Info_NoMessage()
        {
            // Prepare
            const string message = "Simple Info";
            logger.SetupGet(o => o.IsInfoEnabled).Returns(() => false);
            logger.Setup(o => o.Info(message)).Callback(() => counterCall++).Verifiable();
            log = new Log4NetLogger(logger.Object);

            // Act
            log.Info(message);

            // Assert
            Assert.AreEqual(counterCall, 0);
        }
Exemplo n.º 34
0
        public void Info_LambdaMessage()
        {
            // Prepare
            const string message = "Simple Info";
            logger.SetupGet(o => o.IsInfoEnabled).Returns(() => true);
            logger.Setup(o => o.Info(message)).Verifiable();
            log = new Log4NetLogger(logger.Object);

            // Act
            log.Info(() => message);

            // Assert
            logger.VerifyAll();
        }
Exemplo n.º 35
0
		public void CallingMethods()
		{
			var logMock = new LogMock();
			var logger = new Log4NetLogger(logMock);
			var b = logger.IsDebugEnabled;
			b = logger.IsErrorEnabled;
			b = logger.IsFatalEnabled;
			b = logger.IsInfoEnabled;
			b = logger.IsWarnEnabled;
			
			logger.Debug(null);
			logger.Debug(null, null);
			logger.DebugFormat(null, null);
			
			logger.Error(null);
			logger.Error(null, null);
			logger.ErrorFormat(null, null);
			
			logger.Warn(null);
			logger.Warn(null, null);
			logger.WarnFormat(null, null);
		
			logger.Info(null);
			logger.Info(null, null);
			logger.InfoFormat(null, null);

			logger.Fatal(null);
			logger.Fatal(null, null);

			Assert.That(logMock.debug, Is.EqualTo(1));
			Assert.That(logMock.debugException, Is.EqualTo(1));
			Assert.That(logMock.debugFormat, Is.EqualTo(1));
			Assert.That(logMock.info, Is.EqualTo(1));
			Assert.That(logMock.infoException, Is.EqualTo(1));
			Assert.That(logMock.infoFormat, Is.EqualTo(1));
			Assert.That(logMock.warn, Is.EqualTo(1));
			Assert.That(logMock.warnException, Is.EqualTo(1));
			Assert.That(logMock.warnFormat, Is.EqualTo(1));
			Assert.That(logMock.error, Is.EqualTo(1));
			Assert.That(logMock.errorException, Is.EqualTo(1));
			Assert.That(logMock.errorFormat, Is.EqualTo(1));
			Assert.That(logMock.fatal, Is.EqualTo(1));
			Assert.That(logMock.fatalException, Is.EqualTo(1));
			Assert.That(logMock.isDebugEnabled, Is.GreaterThan(1));
			Assert.That(logMock.isInfoEnabled, Is.GreaterThan(1));
			Assert.That(logMock.isWarnEnabled, Is.GreaterThan(1));
			Assert.That(logMock.isErrorEnabled, Is.GreaterThan(1));
			Assert.That(logMock.isFatalEnabled, Is.GreaterThan(1));
		}
Exemplo n.º 36
0
        public void Info_MessageWithException()
        {
            // Prepare
            const string message = "Exception occurred";
            var ex = new Exception(message);
            logger.SetupGet(o => o.IsInfoEnabled).Returns(() => true);
            logger.Setup(o => o.Info(message, ex)).Verifiable();
            log = new Log4NetLogger(logger.Object);

            // Act
            log.Info(message, ex);

            // Assert
            logger.VerifyAll();
        }
 public void FormattedInfoShouldForwardsMessageToInnerInfoFormat()
 {
     var format = "formatted message";
       var args = new object[] { "arg1", "arg2" };
       var provider = new Mock<IFormatProvider>().Object;
       var mockLog = new Mock<log4net.ILog>();
       mockLog.Setup(x => x.InfoFormat(provider, format, args)).Verifiable();
       ILog tested = new Log4NetLogger(mockLog.Object);
       tested.Info(provider, format, args);
       mockLog.Verify();
 }
 public void InfoShouldForwardsMessageToInnerInfo()
 {
     var message = "somemessage";
       var mockLog = new Mock<log4net.ILog>();
       mockLog.Setup(x => x.Info(message)).Verifiable();
       ILog tested = new Log4NetLogger(mockLog.Object);
       tested.Info(message);
       mockLog.Verify();
 }