예제 #1
0
        private async Task Process(TcpClient acceptedTcpClient)
        {
            var session = new AsyncTcpSocketSession(acceptedTcpClient, _configuration, _configuration.BufferManager, _dispatcher, this);

            if (_sessions.TryAdd(session.SessionKey, session))
            {
                _log.Debug("New session [{0}].", session);
                try
                {
                    await session.Start();
                }
                catch (TimeoutException ex)
                {
                    _log.Error(ex);
                }
                finally
                {
                    AsyncTcpSocketSession throwAway;
                    if (_sessions.TryRemove(session.SessionKey, out throwAway))
                    {
                        _log.Debug("Close session [{0}].", throwAway);
                    }
                }
            }
        }
        public IModelBinder GetBinder(ModelBinderProviderContext context)
        {
            if (typeof(UiFlowScreenModel).IsAssignableFrom(context.Metadata.ModelType))
            {
                using (context.Services.Resolve <IProfiler>().RecordStep($"{GetType().Name}.{nameof(GetBinder)}"))
                {
                    return(new UiFlowStepDataModelBinder(context.Services.Resolve <ILoggerFactory>(), t =>
                    {
                        return _propertyBinders.GetOrAdd(t, type =>
                        {
                            Logger.Debug(() => $"Started adding model binder for {type}");
                            var propertyBinders = new Dictionary <ModelMetadata, IModelBinder>();
                            var metadata = context.MetadataProvider.GetMetadataForType(type);

                            foreach (var property in metadata.Properties)
                            {
                                Logger.Debug(() => $"Started adding property binder for {type}.{property.Name}");
                                propertyBinders.Add(property, context.CreateBinder(property));
                                Logger.Debug(() => $"Added property binder for {type}.{property.Name}");
                            }
                            Logger.Debug(() => $"Added model binder for {type}");
                            return propertyBinders;
                        });
                    }));
                }
            }

            return(null);
        }
예제 #3
0
 public void Debug(string message)
 {
     if (log.IsDebugEnabled)
     {
         log.Debug(message);
     }
 }
        public async Task <IEnumerable <TResponse> > Query <TPaged, TResponse>(TPaged query)
        {
            var id = new RiakObjectId("default", Settings.Bucket, Settings.KeyGenerator(typeof(TPaged), query.ToId()));

            ReadsMeter.Mark();

            if (_tracked.ContainsKey(id))
            {
                return _tracked[id].GetObject <IEnumerable <TResponse> >() ?? new TResponse[] { }
            }
            ;

            var options = new RiakGetOptions {
                BasicQuorum = true, NotFoundOk = false
            };

            options.SetRw(Quorum.WellKnown.Quorum);

            Logger.Debug("Getting query id {0}", id.Key);
            var result = await _client.Async.Get(id, options).ConfigureAwait(false);

            if (!result.IsSuccess)
            {
                Logger.Debug("Failed to get key {0} for query {1} from riak - Error: {2} {3}", id.Key, typeof(TPaged).FullName, result.ResultCode, result.ErrorMessage);

                return(new TResponse[] { });
            }

            _tracked[id] = result.Value;

            return(result.Value.GetObject <IEnumerable <TResponse> >() ?? new TResponse[] { });
        }
예제 #5
0
 public void TestGetCommonInfos()
 {
     for (int i = 0; i < this.commonBitWorker.Length(); i++)
     {
         BitIndex bi = this.commonBitWorker[i];
         logger.Debug($"{0}", bi);
     }
 }
예제 #6
0
        public string Process(string input)
        {
            log.Debug(input);

            Board board = new Board();
            board.Parse(input);
            //log.Debug(JsonConvert.SerializeObject(board.Layers[1]));

            var enemyforces = board.GetEnemyForces();
            log.Debug(JsonConvert.SerializeObject(enemyforces));
            var myforces = board.GetMyForces();
            log.Debug(JsonConvert.SerializeObject(myforces));

            var mysorted = myforces.OrderByDescending(o => o.Count);
            var enemysorted = enemyforces.OrderByDescending(o => o.Count);

            var myfirst = mysorted.First();
            var enemyfirst = enemyforces.First();

            Command command = new Command();

            //int seeds = 10;
            //Random rand = new Random((int)DateTime.Now.Ticks);
            //foreach (Forces myforce in myforces)
            //{
            //    if (myforce.Count == 1)
            //    {
            //        if (seeds > 0)
            //        {
            //            command.AddIncrease(2, myforce.Region);
            //            seeds -= 2;
            //        }
            //        continue;
            //    }

            //    int dir = rand.Next(7);
            //    Point move = Board.Moves[dir];
            //    bool isblock = board.IsBlockAt(myforce.Region.x + move.x, myforce.Region.y + move.y);
            //    if (!isblock)
            //        command.AddMovement(20, myforce.Region, (Direction)(dir + 1));
            //}

            //command.AddIncrease(100, board.MyBase);
            command.AddIncrease(10, myfirst.Region);
            //command.AddMovement(1, board.MyBase, Direction.RightUp);
            //command.AddMovement(100, new Point(1, 2), Direction.Up);

            var thepath = board.FindShortestPath(myfirst.Region, enemyfirst.Region);
            if (thepath != null)
            {
                Direction dir = thepath.First();
                command.AddMovement(myfirst.Count + 10, myfirst.Region, dir);
            }

            string scommand = "message(\'" + command.GenerateCommand() + "\')";
            //log.Info(scommand);
            return scommand;
        }
예제 #7
0
        public void TestCommonGetInfos()
        {
            IList <BitIndex> bitList = this.commonInfo.GetPosInfos();

            foreach (BitIndex bi in bitList)
            {
                logger.Debug($"{0}", bi);
            }
        }
        object IBindingValueProvider.GetValue(DependencyProperty prop, BindingExression be, IDataContextProvider source)
        {
            try
            {
                if (be.Log)
                {
                    _logger.Debug("Requested binding for {owner}.{name} ({propertyType}) expression: '{expression}'",
                                  prop.OwnerType, prop.Name, prop.PropertyType, be.Expression);
                    _logger.Debug("Source: " + source);
                }

                var value = ProvideValueInternal(prop, be, source);
                return(value);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);

                _logger.Warn().Exception(ex)
                .Message("ModelBindingError for {owner}.{name} ({propertyType}) expression: '{expression}'",
                         prop.OwnerType, prop.Name, prop.PropertyType, be.Expression)
                .Write();

                if (ThrowOnErrors)
                {
                    throw;
                }

                return(null);
            }
        }
예제 #9
0
        private static void RegisterApplicationParts(ServiceCollection serviceCollection)
        {
            Log.Debug("Registering application part types.");
            var subCommandTypes = Assembly
                                  .GetExecutingAssembly()
                                  .ExportedTypes
                                  .Where(d => d.GetCustomAttribute <SubCommandAttribute>() != null);

            foreach (var subCommandType in subCommandTypes)
            {
                Log.Debug("Registering subcommand type {type}", subCommandType);
                serviceCollection.AddScoped(subCommandType);
            }
        }
예제 #10
0
        private async Task LogRequest(HttpContext context)
        {
            context.Request.EnableBuffering();

            await using var requestStream = _recyclableMemoryStreamManager.GetStream();
            await context.Request.Body.CopyToAsync(requestStream);

            _logger.Debug($"Http Request Information:{Environment.NewLine}" +
                          $"Schema:{context.Request.Scheme} " +
                          $"Host: {context.Request.Host} " +
                          $"Path: {context.Request.Path} " +
                          $"QueryString: {context.Request.QueryString} " +
                          $"Request Body: {ReadStreamInChunks(requestStream)}");
            context.Request.Body.Position = 0;
        }
        public TranslationsController(ILogger logger, IUOW uow)
        {
            _logger = logger;
            _logger.Debug("InstanceId: " + _instanceId);

            _uow = uow;
        }
        private async Task RunAndWaitExit(Stream input, Stream output)
        {
            var server = await BuildLanguageServer(input, output,
                                                   builder => builder
                                                   .AddNLog()
                                                   .AddLanguageServer(LogLevel.Information)
                                                   .SetMinimumLevel(LogLevel.Trace)
                                                   );

            log.Info("Language Server built and started.");

            server.Shutdown.Subscribe(next =>
            {
                log.Debug($"Shutdown requested: {next}");
                server.Services.GetRequiredService <PublishDiagnosticsRunner>().Stop();
                server.Services.GetRequiredService <RhetosProjectMonitor>().Stop();
                Task.Delay(500).Wait();
            });

            server.Exit.Subscribe(next =>
            {
                log.Info($"Exit requested: {next}");
            });

            await server.WaitForExit;
        }
예제 #13
0
        public void Debug(string msg, params object[] args)
        {
            var msg2 = string.Format("{0} - {1}", _callerClass, msg); // duh .. NLog ${callsite} does not work due to the wrapping

            try
            {
                _logger.Debug(msg2, args);
            }
            catch (Exception ex)
            {
                bool msgParameterOk = !args.Any() || MessageParametersOK(msg2, args);

                if (msgParameterOk)
                {
                    //must be aloging problem
                    LogFallback(ex);
                    LogFallback(msg2);
                }
                else
                {
                    // parameter problem.
                    // The logging can still have a problem, so rety without msg parameters
                    Debug("Message parameter problem! " + msg);
                }
            }
        }
예제 #14
0
        public void Log(LogEntry entry)
        {
            _logger = GetLogger(INFO);
            switch (entry.Severity)
            {
            case LoggingEventType.Debug:
                _logger.Debug(entry.Exception, entry.Message);
                break;

            case LoggingEventType.Information:
                _logger.Info(entry.Exception, entry.Message);
                break;

            case LoggingEventType.Warning:
                _logger.Warn(entry.Exception, entry.Message);
                break;

            case LoggingEventType.Error:
                _logger.Error(entry.Exception);
                break;

            case LoggingEventType.Fatal:
                _logger.Fatal(entry.Exception, entry.Message);
                break;

            default:
                break;
            }
        }
예제 #15
0
        public EFRepositoryFactories(ILogger logger)
        {
            _logger = logger;
            _logger.Debug("InstanceId: " + _instanceId);

            _repositoryFactories = GetCustomFactories();
        }
예제 #16
0
        //this ctor is for testing only, you can give here an arbitrary list of repos
        public EFRepositoryFactories(IDictionary <Type, Func <IDbContext, object> > factories, ILogger logger)
        {
            _logger = logger;
            _repositoryFactories = factories;

            _logger.Debug("InstanceId: " + _instanceId);
        }
예제 #17
0
        public HomeController(ILogger logger, IUOW uow)
        {
            _logger = logger;
            _uow    = uow;

            _logger.Debug("InstanceId: " + _instanceId);
        }
예제 #18
0
        public TranslationsController(ILogger logger, BaseIUOW uow)
        {
            _logger = logger;
            _logger.Debug("InstanceId: " + _instanceId);

            _uow = uow;
        }
예제 #19
0
        public MultiLangStringsController(BaseIUOW uow, ILogger logger)
        {
            _logger = logger;
            _logger.Debug("InstanceId: " + _instanceId);

            _uow = uow;
        }
 public void Debug(string messageFormat, params object[] parameters)
 {
     if (!Log.IsDebugEnabled)
     {
         return;
     }
     Log.Debug(messageFormat, parameters);
 }
예제 #21
0
        private async Task RunAndWaitExit(Stream input, Stream output)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException($"RhetosLanguage server has already been initialized. Two instances is not allowed.");
            }

            Instance = BuildLanguageServer(input, output);
            AddServerCleanupHandlers(Instance, hostLog);

            hostLog.Debug("Language Server built. Awaiting initialize...");
            await Instance.Initialize(cancellationTokenSource.Token);

            hostLog.Debug("Initialized!");

            await Instance.WaitForExit;
        }
예제 #22
0
 public void Debug(object message)
 {
     if (IsDebugEnabled)
     {
         loger.Debug(message);
     }
 }
예제 #23
0
 protected override void Dispose(bool disposing)
 {
     _logger.Debug("InstanceId: " + _instanceId + " Disposing:" + disposing);
     if (disposing)
     {
         //_db.Dispose();
     }
     base.Dispose(disposing);
 }
예제 #24
0
        public EFRepositoryProvider(EFRepositoryFactories repositoryFactories, ILogger logger)
        {
            _repositoryFactories = repositoryFactories;
            _logger = logger;

            _logger.Debug("InstanceId: " + _instanceId);

            Repositories = new Dictionary <Type, object>();
        }
예제 #25
0
        public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager,
                                 IAuthenticationManager authenticationManager, ILogger logger)
        {
            _userManager           = userManager;
            _signInManager         = signInManager;
            _authenticationManager = authenticationManager;
            _logger = logger;

            _logger.Debug("InstanceId: " + _instanceId);
        }
예제 #26
0
파일: UOW.cs 프로젝트: viilveer/vr2_exam
        public UOW(IEFRepositoryProvider repositoryProvider, IDbContext dbContext, ILogger logger)
        {
            _logger = logger;
            _logger.Debug("InstanceId: " + _instanceId);

            DbContext = dbContext;

            repositoryProvider.DbContext = dbContext;
            RepositoryProvider           = repositoryProvider;
        }
예제 #27
0
        /// <inheritdoc />
        public IEnumerable <string> GetFilePaths()
        {
            Log.Debug($"Loading files of {ContentRoot}.");
            var pathInfo = new DirectoryInfo(ContentRoot);

            if (!pathInfo.Exists)
            {
                pathInfo.Create();
            }
            return(Directory.EnumerateFiles(ContentRoot));
        }
        public UserClaimsController(IUOW uow, ILogger logger, ApplicationRoleManager roleManager, ApplicationSignInManager signInManager, ApplicationUserManager userManager, IAuthenticationManager authenticationManager)
        {
            _uow = uow;
            _logger = logger;
            _roleManager = roleManager;
            _signInManager = signInManager;
            _userManager = userManager;
            _authenticationManager = authenticationManager;

            _logger.Debug("InstanceId: " + _instanceId);
        }
        public UserLoginsController(IUOW uow, ILogger logger, ApplicationRoleManager roleManager, ApplicationSignInManager signInManager, ApplicationUserManager userManager, IAuthenticationManager authenticationManager)
        {
            _uow                   = uow;
            _logger                = logger;
            _roleManager           = roleManager;
            _signInManager         = signInManager;
            _userManager           = userManager;
            _authenticationManager = authenticationManager;

            _logger.Debug("InstanceId: " + _instanceId);
        }
예제 #30
0
        public void Test01Add()
        {
            string key   = "jsonTest01";
            string value = "Hello Redis!";

            TestDO expected = new TestDO {
                Key = key, value1 = 111, value2 = new byte[] { 0x01, 0x02, 0x03 }, value3 = value
            };

            //Try add to Redis
            this.cacheHelper.Add(key, expected);
            Assert.True(this.cacheHelper.Exists(key));
            TestDO result = this.cacheHelper.Get(key);

            logger.Debug($"Get add key:value => {0}:{1}", key, result); //It's in Redis
            Assert.NotNull(result);
            Assert.Equal(expected, result);
        }
예제 #31
0
        public WarehouseDbContext(IUserNameResolver userNameResolver, ILogger logger) : base("DbConnectionString")
        {
            _logger           = logger;
            _userNameResolver = userNameResolver;

            _logger.Debug("InstanceId: " + _instanceId);
            Database.SetInitializer(new DatabaseInitializer());
            //Database.SetInitializer(
            //  new MigrateDatabaseToLatestVersion<WarehouseDbContext, MigrationConfiguration>());
#if DEBUG
            Database.Log = s => Trace.Write(s);
#endif
        }
예제 #32
0
        public async Task <ActionResult> Execute(string tabId, int parentId, [FromBody] CustomActionQuery query)
        {
            CustomActionPrepareResult customActionToExecute = null;

            try
            {
                customActionToExecute = _service.PrepareForExecuting(tabId, parentId, query);
                Logger.Debug()
                .Message("Executing custom action url: {url}", customActionToExecute.CustomAction.FullUrl)
                .Write();

                if (!customActionToExecute.IsActionAccessable)
                {
                    throw new SecurityException(customActionToExecute.SecurityErrorMesage);
                }

                if (customActionToExecute.CustomAction.Action.IsInterface)
                {
                    var model = ExecuteCustomActionViewModel.Create(tabId, parentId, query.Ids, customActionToExecute.CustomAction);
                    return(await JsonHtml("ExecuteAction", model));
                }

                return(Json(new { Url = customActionToExecute.CustomAction.FullUrl, PreActionUrl = customActionToExecute.CustomAction.PreActionFullUrl }));
            }
            catch (Exception ex)
            {
                if (customActionToExecute?.CustomAction?.Action == null)
                {
                    throw;
                }

                if (customActionToExecute.CustomAction.Action.IsInterface)
                {
                    return(Json(new { success = false, message = ex.Message }));
                }

                return(Json(MessageResult.Error(ex.Message)));
            }
        }
        public DataBaseContext(ILogger logger) : base ("name = TournamentDBConnection")
        {
            
            _logger = logger;
            _logger.Debug("InstanceId: " + _instanceId);


            //Database.SetInitializer(new MigrateDatabaseToLatestVersion<DataBaseContext,MigrationConfiguration>());
            Database.SetInitializer(new DatabaseInitializer());

#if DEBUG
            Database.Log = s => Trace.Write(s);
#endif
            this.Database.Log = s => _logger.Info((s.Contains("SELECT") || s.Contains("UPDATE") || s.Contains("DELETE") || s.Contains("INSERT")) ? "\n" + s.Trim() : s.Trim());
        }