Example #1
0
        public StatArgs()
        {
            this.status   = TSStat.None;
            this.progress = 0;
            this.message  = String.Empty;
            this.ctime    = DateTime.Now;
            this.ptime    = new DateTime();

            this.abort = false;
        }
Example #2
0
        public async Task <ActionResult <TSStat> > Get(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "stat")] HttpRequest req,
            ILogger log)
        {
            await CosmosAPI.cosmosDBClientSetting.SetSetting(Guid.Empty, "LatsStatRequest", "ts", TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));

            ClaimsPrincipal User = MyTokenValidator.Authenticate(req, AllowedRoles, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));

            if (User != null)
            {
                Guid   userID   = Guid.Parse(LocalFunctions.CmdGetValueFromClaim(User.Claims, "UserID", 10, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod())));
                string userName = LocalFunctions.CmdGetValueFromClaim(User.Claims, "UserName", 10, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));

                if (!userID.Equals(Guid.Empty))
                {
                    if (!userName.Equals("demouser"))
                    {
                        TSUser tsUser = await CosmosAPI.cosmosDBClientUser.GetUser(new TSUser { ID = userID }, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));

                        if (tsUser != null)
                        {
                            if (!tsUser.IsLive)
                            {
                                tsUser.IsLive = true;
                                await CosmosAPI.cosmosDBClientUser.UpdateUser(tsUser, true, TodosCosmos.LocalFunctions.AddThisCaller(new List <string>(), MethodBase.GetCurrentMethod()));
                            }
                        }
                    }
                }
            }

            TSStat stat = new TSStat
            {
                IPsCount       = await GetStat("IPAddressesCount"),
                VisitsCount    = await GetStat("VisitsCount"),
                UsersCount     = await GetStat("UsersCount"),
                LiveUsersCount = await GetStat("LiveUsersCount"),
                TodosCount     = await GetStat("TodosCount"),
                LikesCount     = await GetStat("LikesCount"),
                DislikesCount  = await GetStat("DislikesCount"),
                FeedbackCount  = await GetStat("FeedbackCount"),
            };



            return(stat);
            // return new OkObjectResult(JsonSerializer.ToString(stat));
        }
Example #3
0
 private void upAll(DateTime ct, DateTime pt, int p, TSStat s, string m)
 {
     this.stat.ctime = ct;
     this.stat.ptime = pt;
     this.upAll(p, s, m);
 }
Example #4
0
 private void upAll(int p, TSStat s, string m)
 {
     this.stat.message = m;
     this.upPS(p, s);
 }
Example #5
0
 private void upMS(TSStat s, string m)
 {
     this.stat.status = s;
     this.upMesg(m);
 }
Example #6
0
 private void upPS(int p, TSStat s)
 {
     this.stat.progress = p;
     this.upStat(s);
 }
Example #7
0
 private void upStat(TSStat s)
 {
     this.stat.status = s;
     this.upEvent();
 }