Exemplo n.º 1
0
 /// <summary>
 /// Debugging method
 /// </summary>
 /// <param name="getUserActionRequest"></param>
 /// <returns></returns>
 public GetUserActionResponse GetUserActionById(GetUserActionRequest getUserActionRequest)
 {
     GetUserActionResponse resp = new GetUserActionResponse();
     List<SqlParameter> sqlParam = new List<SqlParameter>();
     List<UserActionInfo> userActionList = new List<UserActionInfo>();
     string sqlStr = null;
     if (getUserActionRequest.Action > 0)
     {
         sqlStr = @"select Id, UserId, Action, Parameter, FulfilledDateTime from UserAction where UserId = @UserId and Action = @Action";
         DBUtility.AddSqlParam(sqlParam, "@UserId", SqlDbType.BigInt, getUserActionRequest.UserId);
         DBUtility.AddSqlParam(sqlParam, "@Action", SqlDbType.BigInt, getUserActionRequest.Action);
     }
     else
     {
         sqlStr = @"select Id, UserId, Action, Parameter, FulfilledDateTime from UserAction where UserId = @UserId";
         DBUtility.AddSqlParam(sqlParam, "@UserId", SqlDbType.BigInt, getUserActionRequest.UserId);
     }
     DataSet ds = DBUtility.ExecuteDataset(sqlStr, sqlParam);
     if(DBUtility.hasResult(ds))
     {
         foreach(DataRow dr in ds.Tables[0].Rows)
         {
             UserActionInfo userAction = new UserActionInfo();
             userAction.Id = Convert.ToInt32(dr["Id"]);
             userAction.UserId = Convert.ToInt32(dr["UserId"]);
             userAction.Action = Convert.ToInt32(dr["Action"]);
             userAction.Parameter = dr["Parameter"].ToString();
             userAction.FulfilledDateTime = Convert.ToDateTime(dr["FulfilledDateTime"]);
             userActionList.Add(userAction);
         }
     }
     resp.UserActionList = userActionList;
     return resp;
 }
Exemplo n.º 2
0
        public List<UserActionInfo> GetUserActionListByID(int userId)
        {
            List<UserActionInfo> userActionList = new List<UserActionInfo>();
            List<SqlParameter> sqlParam = new List<SqlParameter>();
            string sqlStr = @"select
                                ua.Action as Action,
                                ua.Parameter as Parameter,
                                ua.FulfilledDateTime as FulfilledDateTime,
                                at.Name as ActionName,
                                ach.Name as AchievementName,
                                ach.Criteria as AchievementCriteria
                                from UserAction ua
                                join ActionType at on at.Id = ua.Action
                                join Achievement ach on ach.ActionType = ua.Action
                                where ua.UserId = @UserId";

            DBUtility.AddSqlParam(sqlParam, "@UserId", SqlDbType.BigInt, userId);
            DataSet ds = DBUtility.ExecuteDataset(sqlStr, sqlParam);
               //TODO: Add stored procedure to perform add Achievement
            //DataSet ds1 = DBUtility.ExecuteDataset(sqlStr, CommandType.StoredProcedure, sqlParam);
            if(DBUtility.hasResult(ds))
            {
                foreach(DataRow dr in ds.Tables[0].Rows)
                {
                    UserActionInfo info = new UserActionInfo();
                    info.Action = Convert.ToInt32(dr["Action"]);
                    info.Parameter = dr["Parameter"].ToString();
                    info.FulfilledDateTime = Convert.ToDateTime(dr["FulfilledDateTime"]);
                    userActionList.Add(info);
                }
            }
            return userActionList;
        }