public static void ServerStart(string str) { Console.WriteLine("Loading Data Access Objects.\n" + "-------------------------------------------"); DAOManager.Initialize(str); Console.WriteLine("Loading Data Files.\n" + "-------------------------------------------"); Data.Data.LoadAll(); Data.Cache.LoadData(); StatsService.Init(); GeoService.Init(); MapService.Init(); QuestEngine.Init(); SkillEngine.Init(); ActionEngine.Init(); SkillsLearnService.Init(); AreaService.Init(); GuildService.Init(); InitMainLoop(); }
static void Main(string[] args) { Console.Title = "YGCore GameServer"; Console.WriteLine("Authors: Jenose\n" + "Authorized representative: netgame.in.th\n\n" + "-------------------------------------------\n"); Stopwatch sw = Stopwatch.StartNew(); Opcode.Init(); Configuration.GetInstance(); Data.LoadAll(); StatsService.GetInstance(); ClientManager.GetInstance(); LSClient.GetInstance(); foreach (var channel in Configuration.GetInstance().Channels) { NetworkFactory.NewInstance(channel.Port); } sw.Stop(); Thread.Sleep(100); Console.WriteLine("-------------------------------------------"); Console.WriteLine(" Server start in {0}", (sw.ElapsedMilliseconds / 1000.0).ToString("0.00s")); Console.WriteLine("-------------------------------------------"); Process.GetCurrentProcess().WaitForExit(); }
public SubHeaderViewModel(SettingsWrapper settingsWrapper, StatsService statsService) { _settingsWrapper = settingsWrapper; PathClickCommand = new RelayCommand(PathClicked); _region = _settingsWrapper.CurrentSettings.Region; _settingsWrapper.SettingChanged(nameof(SettingsJson.InstallDirectory)).Subscribe(s => { InitPath(); }); statsService.StatsStatusChanged.Skip(1).Subscribe(status => { SetStatusChip(status); if (status == StatsStatus.Fetching) { EnableUi = false; ShowProgress = Visibility.Visible; ShowIcon = Visibility.Collapsed; } else { EnableUi = true; ShowProgress = Visibility.Collapsed; ShowIcon = Visibility.Visible; } }); // TODO: Should be called in line 43 initially. It's not. rip. InitPath(); }
public void GetStatsForBot_ExistingBot_ShouldReturnListOfStats() { var databaseContext = DatabaseFactory.Create(); var timeProvider = TimeProviderFactory.Create(); var statsService = new StatsService(databaseContext, timeProvider); databaseContext.Bots.Add(new BotModel { Id = "1", Name = "Bot1", Stats = new List <StatsModel> { new StatsModel { BotId = "1", CreateTime = timeProvider.Get(), ExecutedCommandsCount = 1001 }, new StatsModel { BotId = "1", CreateTime = timeProvider.Get().AddDays(1), ExecutedCommandsCount = 1002 }, new StatsModel { BotId = "1", CreateTime = timeProvider.Get().AddDays(1), ExecutedCommandsCount = 1003 } } }); databaseContext.SaveChanges(); var result = statsService.GetStatsForBot("1"); Assert.Equal(2, result.Count); Assert.Equal(1001, result[0].ExecutedCommandsCount); Assert.Equal(1003, result[1].ExecutedCommandsCount); }
public static void Run() { Server server = new Server(); server.Ports.Add("127.0.0.1", 50001, ServerCredentials.Insecure); server.Services.Add(StatsService.BindService(new ServerImpl())); server.Start(); Thread.Sleep(1000); var client = new StatsService.StatsServiceClient(new Channel("127.0.0.1", 50001, ChannelCredentials.Insecure)); // Three different ways of computing the average of [1,2,3,4]. We're pretty sure it's 2.5 at this point. // Unary operations take one request and send one response. // Our operation includes the whole array of data. UnaryOperation(client).GetAwaiter().GetResult(); // Client streaming operations let the client send many requests and the server sends one response. // The client streams the individual numbers it wants averaged, and the server sends the aggregated response at the end. ClientStreamingOperation(client).GetAwaiter().GetResult(); // Duplex streaming operations let the client send a stream of requests and the server send a stream of responses. // We send the cumulative average after each request in this example. DuplexStreamingOperation(client).GetAwaiter().GetResult(); // Server streaming operations are the opposite of client streaming. One client request results in a stream of server responses. // However, this is left as an exercise to the reader. Thread.Sleep(1000); server.ShutdownAsync().GetAwaiter().GetResult(); }
public int highScore = 0; // highScore of level void Awake() { // Setting up the reference. playerControl = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControl>(); highScore = StatsService.GetHighScore(SceneManager.GetActiveScene().name); }
protected override void OnRun(CancellationToken ct) { try { var newStatsData = StatsService.GetStatsData(); // if the new data is not equal to the previous data, we updated... otherwise, if the update // status is current we should assume the data is current but did not change if (!DataContainer.Data.Equals(newStatsData) || newStatsData.Status == "Current") { DataContainer.Data = newStatsData; DataContainer.Write(); } } catch (Exception) { DataContainer.Data.LastUpdated = DateTime.UtcNow; DataContainer.Write(); throw; } finally { Interval = CalculateInterval(DataContainer.Data.LastUpdated); } }
public PlayerResult Get(int id) { var dataCache = new DataCache(); var player = PlayersService.GetInstance().GetPlayer(id, dataCache); var sports = SportsService.GetInstance().GetSports(); var leagues = LeaguesService.GetInstance().GetLeagues(); var stats = StatsService.GetInstance().GetAllStats(playerID: id, dataCache: dataCache); var statTypes = GamesService.GetInstance().GetStatTypes().OrderBy(s => s.GridDisplayOrder); var playerResult = new PlayerResult() { ID = player.ID, Name = player.Name, Games = player.Games?.Select(g => new PlayerGameResult() { ID = g.ID, GameDate = g.GameDate, Team1Score = g.Team1Score, Team2Score = g.Team2Score }).ToList(), Teams = player.Teams?.Select(t => { var league = leagues.First(l => l.ID == t.LeagueID); var sport = sports.First(s => s.ID == league.SportID); return(new PlayerTeamResult() { ID = t.ID, Name = t.Name, LeagueID = t.LeagueID, Number = t.PlayerNumber, SportID = league.SportID, LeagueName = string.Format("{0} - {1} {2} - {3}", sport.Name, league.StartDate.Year, league.Season.ToString(), league.Name) }); }).OrderBy(t => t.LeagueName).ToList(), HockeyStats = stats .Select(s => ConvertObjects.ConvertType(s)) .Where(s => s.Sport == SportsList.Hockey && leagues.Exists(l => l.ID == s.LeagueID)) .OrderBy(s => leagues.First(l => l.ID == s.LeagueID).StartDate) .ToList(), BaseballStats = stats .Select(s => ConvertObjects.ConvertType(s)) .Where(s => s.Sport == SportsList.Baseball && leagues.Exists(l => l.ID == s.LeagueID)) .OrderBy(s => leagues.First(l => l.ID == s.LeagueID).StartDate) .ToList(), BasketballStats = stats .Select(s => ConvertObjects.ConvertType(s)) .Where(s => s.Sport == SportsList.Basketball && leagues.Exists(l => l.ID == s.LeagueID)) .OrderBy(s => leagues.First(l => l.ID == s.LeagueID).StartDate) .ToList(), HockeyStatTypes = statTypes.Select(s => ConvertObjects.ConvertType(s)).Where(st => st.Sport == SportsList.Hockey).ToList(), BaseballStatTypes = statTypes.Select(s => ConvertObjects.ConvertType(s)).Where(st => st.Sport == SportsList.Baseball).ToList(), BasketballStatTypes = statTypes.Select(s => ConvertObjects.ConvertType(s)).Where(st => st.Sport == SportsList.Basketball).ToList(), }; UpdateStatRow(playerResult.HockeyStats, player, leagues); UpdateStatRow(playerResult.BaseballStats, player, leagues); UpdateStatRow(playerResult.BasketballStats, player, leagues); return(playerResult); }
public MainPage() { InitializeComponent(); _statsService = new StatsService(); GetServerStatus(); }
private void Track(HttpRequest request, HttpResponse response) { // new/returning users daily Nullable <DateTime> lastVisit = GetLastVisit(request, sSnCoreLastVisit); if ((!lastVisit.HasValue) || (lastVisit.Value.AddDays(1) < DateTime.UtcNow)) { // cookie doesn't exist or exists with an invalid value // cookie older than a day HttpCookie lastVisitCookie = new HttpCookie(sSnCoreLastVisit, DateTime.UtcNow.ToString()); lastVisitCookie.Expires = DateTime.UtcNow.AddYears(1); response.Cookies.Add(lastVisitCookie); } // unique users monthly Nullable <DateTime> lastMonthVisit = GetLastVisit(request, sSnCoreLastMonthVisit); if (!lastMonthVisit.HasValue) { // cookie doesn't exist, it has expired within the month HttpCookie lastMonthVisitCookie = new HttpCookie(sSnCoreLastMonthVisit, DateTime.UtcNow.ToString()); DateTime nextmonth = DateTime.UtcNow.AddMonths(1); lastMonthVisitCookie.Expires = new DateTime(nextmonth.Year, nextmonth.Month, 1); response.Cookies.Add(lastMonthVisitCookie); } TransitStatsRequest tsr = new TransitStatsRequest(request, lastVisit, lastMonthVisit); lock (s_Requests) { s_Requests.Add(tsr); } if (s_RequestsLastCommit.Add(s_RequestCommitInterval) >= tsr.Timestamp) { return; } // commit tracked requests lock (s_Requests) { if (s_RequestsLastCommit.Add(s_RequestCommitInterval) < tsr.Timestamp) { try { StatsService.TrackMultipleRequests(s_Requests.ToArray()); } catch (Exception ex) { EventLogManager.WriteEntry(string.Format("Error tracking multiple requests.\n{0}", ex.Message), EventLogEntryType.Warning); } finally { s_Requests.Clear(); s_RequestsLastCommit = tsr.Timestamp; } } } }
public StatsApi(RequestContext request) { _request = request; IStatsService statsService = new StatsService(); _statsController = new StatsController(statsService); }
static void Main() { Console.WriteLine("Starting server..."); using (var system = new ActorsSystem()) using (StatsService.Run(system.Monitor)) { var listener = QueuedActor.Of(new ConnectionListener(Addresses.Listener, system)); system.SubscribeByAddress(listener); var connectionWorkers = QueuedActor.Of(mailbox1 => new RoundRobinActor( id: Addresses.ConnectionWorkers, workerFactory: () => QueuedActor.Of(mailbox2 => new ClientConnectionWorker(system, mailbox2), system.Monitor), degreeOfParallelism: 2, system: system, mailBox: mailbox1)); system.SubscribeByAddress(connectionWorkers); system.Monitor.MonitorActor(connectionWorkers); system.Send(new StartListening()); Console.WriteLine("Server started"); Console.WriteLine("Press any key to exit..."); Console.ReadLine(); } Console.WriteLine("Finished"); }
public HeaderViewModel(ILogger logger, SocketIoService socketIoService, StatsService statsService, SettingsWrapper settingsWrapper) { _logger = logger; _settingsWrapper = settingsWrapper; OpenWebsiteCommand = new RelayCommand(LogoClick); SettingsCommand = new RelayCommand(SettingsClick); QrCodeClickCommand = new RelayCommand(QrCodeClick); ExportStatsCommand = new RelayCommand(async _ => await ExportStatsAsync()); EnableReplayCommand = new RelayCommand(EnableReplays); SwitchThemeCommand = new RelayCommand(SwitchTheme); socketIoService.StateChanged.Subscribe(state => { ConnectionState = state.ToString(); }); statsService.StatsStatusChanged.Subscribe(status => { CanExport = status == StatsStatus.Fetched; }); _settingsWrapper.SettingChanged(nameof(SettingsJson.InstallDirectory)).Subscribe(s => { var path = Path.Combine(_settingsWrapper.CurrentSettings.InstallDirectory, "preferences.xml"); CanEnableReplays = File.Exists(path); }); if (_settingsWrapper.CurrentSettings.DarkMode) { SwitchTheme(); } }
public ActionResult ChartData() { StatsService service = new StatsService(); ChartsViewModel chartVM = service.GetChartsData(); return(Json(chartVM, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult <DsResponse> > GetAntiSynergy(DsRequest request) { Stopwatch sw = new Stopwatch(); sw.Start(); DsResponse response; if (request.Filter == null || request.Filter.isDefault) { string hash = request.GenHash(); if (!memoryCache.TryGetValue(hash, out response)) { response = await StatsService.GetAntiSynergy(context, request); memoryCache.Set(hash, response, CacheService.BuildCacheOptions); } else { logger.LogInformation("antisynergy from cache"); } } else { response = await StatsService.GetAntiSynergy(context, request); } await SetLeaverQuit(request, response); sw.Stop(); logger.LogInformation($"Get AntiSynergy in {sw.ElapsedMilliseconds} ms"); return(response); }
public async Task <ActionResult <TimelineResponse> > GetTimeline(TimelineRequest request) { Stopwatch sw = new Stopwatch(); sw.Start(); TimelineResponse response; if (request.Filter == null || request.Filter.isDefault) { string hash = request.GenHash(); if (!memoryCache.TryGetValue(hash, out response)) { response = StatsService.GetTimeline(request, await GetCmdrStats(request.Player)); memoryCache.Set(hash, response, CacheService.RankingCacheOptions); } else { logger.LogInformation("timeline from cache"); } } else { response = await StatsService.GetCustomTimeline(context, request); } await SetLeaverQuit(request, response); sw.Stop(); logger.LogInformation($"Get Timeline in {sw.ElapsedMilliseconds} ms"); return(response); }
public void Log_ExistingBot_ShouldReturnTrueAndSaveInDatabase() { var databaseContext = DatabaseFactory.Create(); var timeProvider = TimeProviderFactory.Create(); var statsService = new StatsService(databaseContext, timeProvider); databaseContext.Bots.Add(new BotModel { Id = "1", Name = "Bot1" }); databaseContext.SaveChanges(); var stats = new LogStatsDto { BotId = "1", ExecutedCommandsCount = 2, GuildsCount = 3, MembersCount = 4 }; var result = statsService.Log(stats); var loggedStats = databaseContext.Stats.First(); Assert.True(result); Assert.Equal(1, databaseContext.Stats.Count()); Assert.Equal("1", loggedStats.BotId); Assert.Equal(timeProvider.Get(), loggedStats.CreateTime); Assert.Equal(2, loggedStats.ExecutedCommandsCount); Assert.Equal(3, loggedStats.GuildsCount); Assert.Equal(4, loggedStats.MembersCount); }
public static void LevelUp(Player player) { player.LifeStats.LevelUp(); FeedbackService.PlayerLevelUp(player); StatsService.UpdateStats(player); //QuestEngine.PlayerLevelUp(player); }
public List<UserGrowthStats> GetDailyUserGrowthStats(DateTime f, DateTime t) { var ss = new StatsService(); var data = ss.FindDailyUserGrowthStats(f, t); return data; }
public Aspose3DMeasurementController(StorageService storageService, MeasurementService measurementService, StatsService statsService, ILoggerFactory loggerFactory) : base(measurementService, storageService, loggerFactory, ThreeDApp.Measurement, statsService) { OpUpload = CreateOperationKind("upload"); OpReview = CreateOperationKind("review"); OpDownload = CreateOperationKind("download"); }
public static void ServerStart() { Data.Data.LoadAll(); StatsService.Init(); MapService.Init(); InitMainLoop(); }
public void TestOfGettingCategoryWithTheMostAndTheLessQuestions() { //Arrange var questions = new List <Question>() { new Question { Id = 1, QuestionText = "Ile to jest 25 + 25?", CategoryId = 1, Category = new Category() { Id = 1, Name = "Matematyka", IsAccepted = true }, IsAccepted = true }, new Question { Id = 2, QuestionText = "Ile wynosi pierwiastek kwadratowty z 64?", CategoryId = 1, Category = new Category() { Id = 1, Name = "Matematyka", IsAccepted = true }, IsAccepted = true }, new Question { Id = 3, QuestionText = "W którym roku zaczęła się II WŚ?", CategoryId = 2, Category = new Category() { Id = 2, Name = "Historia", IsAccepted = true }, IsAccepted = false } }; var catRepo = new Mock <ICategoryAndQuestionForAdminRepository>(); var userRepo = new Mock <IUsersRolesAndScoresRepository>(); var statsRepo = new Mock <IStatsRepository>(); var config = new MapperConfiguration(conf => { conf.AddProfile(new MappingProfile()); }); var mapper = config.CreateMapper(); catRepo.Setup(s => s.ShowQuestions()).Returns(questions.AsQueryable()); var statsServ = new StatsService(catRepo.Object, userRepo.Object, statsRepo.Object, mapper); var stats = statsServ.GetStatsAboutCatQueAns(); Assert.Equal(questions[2].Category.Name, stats.CategoryWithTheFewestQuestions); Assert.Equal(questions[0].Category.Name, stats.CategoryWithTheMostQuestions); }
public SceneImportContext(ThreeDApp app, StatsService statsService, StorageFileNames fileNames, MetaDataT metaData, int mainFile, FileFormat sourceFormat) { this.app = app; this.statsService = statsService; this.fileNames = fileNames; this.metaData = metaData; this.sourceFormat = sourceFormat; this.mainFile = mainFile; }
public void GetStatsForBot_NonExistingBot_ShouldReturnNull() { var databaseContext = DatabaseFactory.Create(); var timeProvider = TimeProviderFactory.Create(); var statsService = new StatsService(databaseContext, timeProvider); var result = statsService.GetStatsForBot("0"); Assert.Null(result); }
// Example how to test service public ServiceTests() { var service = new StatsService(); // how to get all players from database in clean and concise way service.Players.Get(); // how to get all teams from database in clean and concise way service.Teams.Get(); }
public void Configuration(IAppBuilder app) { Database.SetInitializer(new DropCreateDatabaseIfModelChanges <DbContext>()); ConfigureAuth(app); GlobalConfiguration.Configuration .UseSqlServerStorage(@""); //app.UseHangfireDashboard(); app.UseHangfireServer(); RecurringJob.AddOrUpdate(() => StatsService.Start(), Cron.Hourly); }
private void Init() { Champion = new ChampionService(LeagueApiConfiguration); Game = new GameService(LeagueApiConfiguration); League = new LeagueService(LeagueApiConfiguration); Stats = new StatsService(LeagueApiConfiguration); Summoner = new SummonerService(LeagueApiConfiguration); Team = new TeamService(LeagueApiConfiguration); Static = new StaticService(LeagueApiConfiguration); }
public SoundModule( IQuoteBotRepo quoteBotRepo, StatsService statsService, IAmazonS3 s3Client, IOptions <BotOptions> botOptions) { this.quoteBotRepo = quoteBotRepo; this.statsService = statsService; this.s3Client = s3Client; this.botOptions = botOptions.Value; }
public async Task <ActionResult <DsResponse> > GetCrosstable(DsRequest request) { Stopwatch sw = new Stopwatch(); sw.Start(); var response = StatsService.GetCrosstable(request, await GetCmdrStats(request.Player)); sw.Stop(); logger.LogInformation($"Get Crosstable in {sw.ElapsedMilliseconds} ms"); return(response); }
public static void UpdateCreatureStats(Creature creature) { StatsService.UpdateStats(creature); Player player = creature as Player; if (player != null) { FeedbackService.StatsUpdated(player); } }
public ProblemQueue( ILogger <ProblemQueue> logger, IOptions <Options> options, IServiceProvider sp, IProblemService svc, StatsService statsService, IHttpClientFactory httpClientFactory ) : base(logger, options, sp, httpClientFactory) { Service = svc; Stats = statsService; }
public List<UserGrowthStats> GetUserGrowthStats(DateTime f, DateTime t) { //var cacheHelper = new CacheHelper(HttpContext.Current.Cache); //var data = cacheHelper.Get(CacheKey.ToString(CultureInfo.InvariantCulture)) as List<UserGrowthStats>; //if (data == null) //{ var ss = new StatsService(); var data = ss.FindUserGrowthStats(f, t); //cacheHelper.Add(CacheKey.ToString(CultureInfo.InvariantCulture), data, DateTime.Now.AddMinutes(CacheExpiry)); //} return data; }
public StatManager() { if (_ss == null) _ss = new StatsService(); }