Esempio n. 1
0
        public async Task chooseWeeklyWinner(object obj)
        {
            var wdaydiff = DateTime.Now.EndOfWeek(18, 0, 0, 0) - DateTime.Now;

            //var wdaydiff = DateTime.Now.NextFiveMinutes() - DateTime.Now;

            if (wdaydiff.TotalMinutes >= 0 && wdaydiff.TotalMinutes <= 1)
            {
                if ((int)Math.Floor(wdaydiff.TotalSeconds) < 1)
                {
                    var luckymeWeeklyWinnersId = await ChooseWinnerAsync("weekly", EntityTypes.Luckyme);

                    var selectedLuckyMes = context.LuckyMes.Where(i => luckymeWeeklyWinnersId.Contains(i.Id));

                    //Put a dummy weekly luckyme
                    DummyService.FixLuckyMeWeeklyDummy();

                    if (selectedLuckyMes?.Count() > 0)
                    {
                        //send the selected daily luckyme winner to the UI
                        await WinnerSelectionHub.Clients.All.SendAsync("weeklyLuckymeWinner", selectedLuckyMes.Select(i => new LuckyMeParticipantDTO
                        {
                            Id           = i.Id,
                            UserName     = i.User.FirstName + " " + i.User.LastName,
                            UserId       = i.UserId,
                            AmountStaked = i.Amount.ToString("0.##"),
                            AmountToWin  = i.AmountToWin.ToString("0.##"),
                            Status       = i.Status,
                            DateDeclared = i.DateDeclared
                        }));

                        //clear all current daily luckyme participants
                        await StakersHub.Clients.All.SendAsync("getCurrentWeeklyLuckymeParticipants", DataHub.GetWeeklyLuckymeParticipants());
                    }
                    else
                    {
                        //send a blank winner
                        await WinnerSelectionHub.Clients.All.SendAsync("weeklyLuckymeWinner", new List <LuckyMeParticipantDTO>(){ new LuckyMeParticipantDTO
                                                                                                                                  {
                                                                                                                                      UserName     = "******",
                                                                                                                                      UserId       = "",
                                                                                                                                      AmountStaked = "",
                                                                                                                                      AmountToWin  = ""
                                                                                                                                  } });
                    }


                    await WinnerSelectionHub.Clients.All.SendAsync("ongoingWeeklyDraw", false);

                    await WinnerSelectionHub.Clients.All.SendAsync("ongoingWeeklyDraw", false);
                }
                else if ((int)Math.Floor(wdaydiff.TotalSeconds) > 1)
                {
                    await WinnerSelectionHub.Clients.All.SendAsync("ongoingWeeklyDraw", true);
                }
            }
            else
            {
                await CountdownHub.Clients.All.SendAsync("getWeeklyTime", wdaydiff.Days, wdaydiff.Hours, wdaydiff.Add(TimeSpan.FromMinutes(-1)).Minutes, wdaydiff.Seconds);
            }
        }
        public void LoadTextResource(DataHub dataHub, Assembly assembly, string resourceName, DataPath path)
        {
            var content = embeddedResourceUtils.GetLocalEmbeddedResourceText(assembly, resourceName);

            dataHub.Add(path, content);
        }
Esempio n. 3
0
 public CommandController(ISensorRepository sensorRepository, DataHub hub)
 {
     _sensorRepository = sensorRepository;
     _hub = hub;
 }
 public BoostrapGlobals(DataHub dataHub)
 {
     this.dataHub = dataHub;
 }
Esempio n. 5
0
 public DataController(ISensorRepository dataRepository, DataHub hub)
 {
     _dataRepository = dataRepository;
     _hub            = hub;
 }