Exemplo n.º 1
0
        public List <View.Games.CRW.DailyUserRecord> Game_rUserDetail(View.Games.CRW.Game_User user, int _CRWTypeID)
        {
            string sql = "select UserID, CRWTypeID, DateValue, DateDisplay, Max(Level) as Level, Max(UseTime) as UseTime " +
                         " from CRWLog " +
                         " where UserID = ? and " +
                         " CRWTypeID = ? and " +
                         " NextLevel is not null " +
                         " group by UserID, CRWTypeID, DateValue, DateDisplay " +
                         " order by DateValue desc ";

            var taskResult = mDatabase.QueryAsync <View.Games.CRW.CRWLog>(sql, new object[2] {
                user.ID, _CRWTypeID
            });

            List <View.Games.CRW.DailyUserRecord> r = new List <View.Games.CRW.DailyUserRecord>();

            foreach (View.Games.CRW.CRWLog item in taskResult.Result)
            {
                r.Add(new View.Games.CRW.DailyUserRecord()
                {
                    DateDisplay       = item.DateDisplay,
                    Level             = item.Level,
                    MaxLevelName      = new View.Games.CRW.CRW_Level(item.Level, _CRWTypeID).LevelName,
                    MaxUseTime        = item.UseTime.Value,
                    MaxUseTimeDisplay = TimeSpan.FromTicks(item.UseTime.Value).ToStringAdv()
                });
            }

            return(r);
        }
Exemplo n.º 2
0
        public View.Games.CRW.CRWLog CRW_rLog(View.Games.CRW.Game_User args, int argsCRWTypeID)
        {
            // var now = WebDateTime.Now;
            var now   = DateTime.Now;
            var today = now.Date;

            var taskResult = mDatabase.Table <View.Games.CRW.CRWLog>()
                             .Where(i => i.UserID == args.ID && i.CRWTypeID == argsCRWTypeID && i.DateValue == today.Ticks)
                             .OrderByDescending(i => i.UpdateTimeValue)
                             .FirstOrDefaultAsync();

            if (taskResult != null)
            {
                if (taskResult.Result != null)
                {
                    return(taskResult.Result);
                }
            }

            var nearLastest = mDatabase.Table <View.Games.CRW.CRWLog>()
                              .Where(i => i.UserID == args.ID && i.CRWTypeID == argsCRWTypeID)
                              .OrderByDescending(i => i.UpdateTimeValue)
                              .FirstOrDefaultAsync();

            View.Games.CRW.CRWLog toAdd = new View.Games.CRW.CRWLog()
            {
                UserID            = args.ID,
                CRWTypeID         = argsCRWTypeID,
                Level             = 1,
                DateValue         = today.Ticks,
                DateDisplay       = today.ToString("yyyy-MM-dd"),
                UpdateTimeValue   = now.Ticks,
                UpdateTimeDisplay = now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                Percentage        = null,
                NextLevel         = null,
                UseTime           = 0,
                UseTimeDisplay    = "0秒"
            };


            if (nearLastest != null && nearLastest.Result != null)
            {
                var lastestLog = nearLastest.Result;

                toAdd.Level     = lastestLog.Level;
                toAdd.NextLevel = lastestLog.NextLevel;
            }

            CRW_cLog(toAdd);

            return(CRW_rLog(args, argsCRWTypeID));
        }
Exemplo n.º 3
0
        public View.Games.CRW.Game_User CRW_rcUser(View.Games.CRW.Game_User args)
        {
            var taskResult = mDatabase.Table <View.Games.CRW.Game_User>().Where(i => i.Account == args.Account).ToListAsync();

            if (taskResult != null)
            {
                if (taskResult.Result == null || taskResult.Result.Count == 0)
                {
                    var toAdd = new View.Games.CRW.Game_User()
                    {
                        ID = Guid.NewGuid().ToString().ToUpper(), Account = args.Account
                    };
                    mDatabase.InsertAsync(toAdd).Wait();
                    return(this.CRW_rcUser(args));
                }
            }

            return(taskResult.Result[0]);
        }