Esempio n. 1
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!";
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        currentNode = new DynamicNode(Node.getCurrentNodeId());
        heroPageUrl = "/profile/heroes/hero.aspx";

        if (!Page.IsPostBack && !string.IsNullOrEmpty(Request.QueryString["id"]))
        {
            profile = new DynamicNode(Convert.ToInt32(Request.QueryString["id"]));

            //check if profile has heroes else show the download heroes panel
            if (!profile.Descendants(x => x.NodeTypeAlias == Hero.documentTypeAlias).IsNull())
            {
                rViewHeroes.DataSource = profile.Descendants(Hero.documentTypeAlias);
                rViewHeroes.DataBind();
            }
            else
            {
            }
        }
    }
Esempio n. 3
0
        /// <summary>
        /// Render the top Root Nodes.
        /// - Calendar -> The Root of all Calendars
        /// - Locations -> The Root of all Locations
        /// </summary>
        /// <param name="tree">The current tree</param>
        private void PopulateRootNodes(ref XmlTree tree)
        {
            XmlTreeNode xNode = CreateNode("Global Settings", -1);

            tree.Add(xNode);

            var rootNode      = new DynamicNode(-1);
            var homepageNodes = rootNode.Descendants(Constants.HomepageAlias);

            foreach (var node in homepageNodes)
            {
                xNode = CreateNode(node.Name, node.Id);
                tree.Add(xNode);
            }
        }
Esempio n. 4
0
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            var globalSettingsNode = CreateTreeNode("-1", "-2", queryStrings, "Global Settings");

            nodes.Add(globalSettingsNode);

            var rootNode      = new DynamicNode(-1);
            var homepageNodes = rootNode.Descendants(Constants.HomepageAlias);

            foreach (var node in homepageNodes)
            {
                nodes.Add(CreateTreeNode(node.Id.ToString(), "-2", queryStrings, node.Name));
            }

            return(nodes);
        }
        public static bool HasDescendantsOfType(this DynamicNode node, string documentType, out DynamicNodeList descendants)
        {
            var nodes = node.Descendants(documentType);

            descendants = new DynamicNodeList();

            if (nodes == null)
            {
                return(false);
            }
            else if (nodes.Count() == 0)
            {
                return(false);
            }
            else
            {
                descendants = nodes;
                return(true);
            }
        }