示例#1
0
 public GameConfig(string name, Game game, D3API d3api)
 {
     Name          = name;
     Game          = game;
     _configValues = new Dictionary <string, string>();
     D3API         = d3api;
 }
示例#2
0
    protected void btnSearchBattleTag_Click(object sender, EventArgs e)
    {
        bool debug = false; //set this ito false to activate profile search

        if (debug)
        {
            lblSearchStatus.Text = "Sorry this service is not yet avalible yet, check back soon";
        }
        else
        {
            /*search order
             * 1. first it will look for the node that match the battletag
             * 2. if the node dosen't match it will start to fetch the profile using the blizzard diablo 3 web api
             * 3. else it fails and a text is written out
             */
            if (currentNode.Descendants(BattleTagProfile.documentTypeAlias).Items.Any(x => x.Name == TxtbSearchBattleTag.Text))
            {
                battletagProfile = currentNode.Descendants(x => x.NodeTypeAlias == BattleTagProfile.documentTypeAlias && x.Name == TxtbSearchBattleTag.Text).Items.First();
                Response.Redirect(currentNode.Descendants(ProfilePage.documentTypeAlias).Items.First().Url + "?id=" + battletagProfile.Id);
            }
            else
            {
                dynamic careerProfile = null;
                string  battleTag     = null;
                try
                {
                    api           = new D3API(HostName.en_GB);
                    careerProfile = api.getCareerProfile(TxtbSearchBattleTag.Text);
                    battleTag     = careerProfile.battleTag;
                }
                catch (Exception exception)
                {
                    string d = exception.ToString();
                    lblSearchStatus.Text = "Sorry we could't find your profile, please check if your spelled your battletag correctly!";
                }


                if (!string.IsNullOrWhiteSpace(battleTag))
                {
                    User     admin       = User.GetUser(0);
                    Document profilesDoc = new Document(1060);

                    Document createdProfile = d3pServices.CreateDiablo3Profile(profilesDoc, careerProfile, admin);
                    if (createdProfile.Published)
                    {
                        Response.Redirect(currentNode.Descendants(ProfilePage.documentTypeAlias).Items.First().Url + "?id=" + createdProfile.Id);
                    }
                }
                else
                {
                    lblSearchStatus.Text = "Sorry we could't find your profile, please check if your spelled your battletag correctly!";
                }
            }
        }
    }
示例#3
0
        public dynamic GetCareerProfile(string battletag)
        {
            D3API   api;
            dynamic careerProfile = null;

            try
            {
                api           = new D3API(HostName.en_GB);
                careerProfile = api.getCareerProfile(battletag);
            }
            catch (Exception exception)
            {
                string d = exception.ToString();
                return(careerProfile);
            }
            return(careerProfile);
        }
示例#4
0
 protected void btnLoad_Click(object sender, EventArgs e)
 {
     try
     {
         api = new D3API(HostName.en_GB);
         dynamic careerProfile = api.getCareerProfile(txtbBattletag.Text);
         foreach (Dictionary <string, dynamic> hero in careerProfile.heroes)
         {
             foreach (var pair in hero)
             {
                 if (pair.Key == "id")
                 {
                     dynamic  heroProfile  = api.getHeroProfile(careerProfile.battleTag, pair.Value);
                     Document heroDocument = d3pServices.CreateDiablo3Hero(new Document(2354), heroProfile, User.GetUser(0));
                 }
             }
         }
     }catch (Exception errorEvent)
     {
         string error = errorEvent.ToString();
         lblTestMethods.Text = error;
     }
 }