private async Task UpdateAsync(StatisticsType type, int valueToAdd, string team = "")
        {
            var q = this.repository.Query;

            if (type == StatisticsType.MinutesPlayedByAllPlayers)
            {
                team = "";
            }

            var st = await q.FirstOrDefaultAsync(s => s.Type.Equals(type) && s.TeamName.Equals(team));

            if (st == null)
            {
                st          = new Statistic();
                st.Type     = type;
                st.Name     = type.ToString();
                st.TeamName = team;
                await this.repository.AddAsync(st);

                await this.repository.SaveAsync();
            }

            st.Name   = type.ToString();
            st.Total += valueToAdd;

            this.repository.Update(st);
            await this.repository.SaveAsync();
        }
예제 #2
0
        /// <summary>
        /// 得到某段时间内某类的用户名
        /// </summary>
        /// <param name="UserID">用户ID</param>
        public List <string> GetNamesByTypeAndPeriod(DateTime StartDate, DateTime EndDate, StatisticsType Type)
        {
            string type = Type.ToString();
            var    q    = _entities.Where(x => x.DS_Date >= StartDate && x.DS_Date < EndDate);

            switch (type)
            {
            case "准点":
                break;

            case "迟到":
                q = q.Where(x => x.DS_ComeLateCount > 0);
                break;

            case "早退":
                q = q.Where(x => x.DS_LeaveEarlyCount > 0);
                break;

            case "未签到":
            case "未签退":
                q = q.Where(x => (x.DS_NoSignInCount > 0 || x.DS_NoSignOutCount > 0) && x.DS_IsAbsent == 0);
                break;

            case "旷工":
                q = q.Where(x => x.DS_IsAbsent == 1);
                break;

            default:
                break;
            }
            return(q.Select(o => o.DS_UserID).Distinct().ToList());
        }
예제 #3
0
        /// <summary>
        /// 根据用户ID和日期,统计的类型返回用户某天的考勤日志数量
        /// </summary>
        /// <param name="ATID">用户ID</param>
        /// <param name="Date">日期</param>
        /// <param name="Type">统计的类型</param>
        public int GetDayCountByType(string UserID, DateTime Date, StatisticsType Type)
        {
            string   type  = Type.ToString();
            DateTime Start = Date.Date;
            DateTime End   = Date.AddDays(1).Date;

            return(_entities.Where(x => x.AL_UserID == UserID && x.AL_Date >= Start && x.AL_Date < End && x.AL_Status == type).Count());
        }
예제 #4
0
        public IStatistics GetStatsByType(StatisticsType type)
        {
            foreach (var stats in Statistics)
            {
                if (stats.Subtitle.Contains(type.ToString()))
                {
                    return(stats);
                }
            }

            throw new Exception();
        }
예제 #5
0
        /// <summary>
        /// Get order history statistics data from Warframe Market.
        /// </summary>
        /// <param name="code">Item code</param>
        /// <param name="type">Chart data are from live or closed</param>
        /// <returns></returns>
        public async Task <Statistics> GetWarframeMarketStatisticsAsync(string code, StatisticsType type)
        {
            string route = Statics.WM_STATISTICS_URL + $"{code}?platform={Platform}&type={type.ToString().ToLower()}";
            var    data  = await NetworkTools.GetEntityAsync <Statistics>(route, Token, ExceptionAction);

            return(data);
        }