Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            Dictionary <String, object> res          = new Dictionary <string, object>();
            List <Object> finalList                  = new List <object>();
            IEnumerable <AchievementDefinition> achs = AchievementDefinition.getAll();

            foreach (AchievementDefinition r in achs)
            {
                int nAchs  = 0;
                int nTasks = AchievementPrereq.getPrereqTypes(AchievementPrereq.getPrereqsForAchievement(r.AchievementID), out nAchs);

                Dictionary <string, string> obj = new Dictionary <string, string>();
                obj.Add("Achievement", r.AchievementName);
                obj.Add("Tasks", nTasks.ToString());
                obj.Add("Prerequisites", nAchs.ToString());
                obj.Add("actions", r.AchievementID.ToString());
                obj.Add("AchievementID", r.AchievementID.ToString());
                obj.Add("AchievementDesc", r.AchievementDesc);

                finalList.Add(obj);
            }
            res.Add("data", finalList);
            string json = JsonConvert.SerializeObject(res);

            context.Response.Write(json);
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            mUser = (AppUser)Session[Constants.SESS_KEY_USER];

            if (mUser == null)
            {
                getUserFromCookie();
                if (mUser == null)
                {
                    Response.Redirect("login.aspx");
                    Response.Close();
                    return;
                }
            }
            AchievementID = Request.Params["AchievementID"];
            achievedWhen  = PilotAchievement.WhenAchieved(Guid.Parse(AchievementID), mUser.UserEmail);
            rd            = AchievementDefinition.getAchievementDefinition(Guid.Parse(AchievementID));
            IEnumerable <AchievementPrereq> prereqs = AchievementPrereq.getPrereqsForAchievement(Guid.Parse(AchievementID));

            requirements     = new List <AchievementDefinition>();
            taskrequirements = new List <TaskDefinition>();
            if (prereqs != null && prereqs.Count <AchievementPrereq>() >= 0)
            {
                foreach (AchievementPrereq pcp in prereqs)
                {
                    if (pcp.RequiredAchievementID != null)
                    {
                        AchievementDefinition ad = AchievementDefinition.getAchievementDefinition((Guid)pcp.RequiredAchievementID);
                        if (ad != null)
                        {
                            requirements.Add(ad);
                        }
                    }
                    else if (pcp.TaskID != null)
                    {
                        TaskDefinition ad = TaskDefinition.getTaskDefinition((Guid)pcp.TaskID);
                        if (ad != null)
                        {
                            taskrequirements.Add(ad);
                        }
                    }
                }
            }
        }