ProvisionFromXmlDocumentAsync() public method

public ProvisionFromXmlDocumentAsync ( [ provisioningXmlDocument ) : IAsyncOperation
provisioningXmlDocument [
return IAsyncOperation
        /// <summary>
        /// This is the click handler for the 'ProvisionMnoButton' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ProvisionMno_Click(object sender, RoutedEventArgs e)
        {
            if (provXmlText.Text == "")
            {
                rootPage.NotifyUser("Provisioning XML cannot be empty", NotifyType.ErrorMessage);
                return;
            }

            string provisioningXML = provXmlText.Text;

            try
            {
                // Get the network account ID.
                IReadOnlyList <string> networkAccIds = Windows.Networking.NetworkOperators.MobileBroadbandAccount.AvailableNetworkAccountIds;

                if (networkAccIds.Count == 0)
                {
                    rootPage.NotifyUser("No network account ID found", NotifyType.ErrorMessage);
                    return;
                }

                ProvisionMnoButton.IsEnabled = false;

                // For the sake of simplicity, assume we want to use the first account.
                // Refer to the MobileBroadbandAccount API's how to select a specific account ID.
                string networkAccountId = networkAccIds[0];

                // Create provisioning agent for specified network account ID
                Windows.Networking.NetworkOperators.ProvisioningAgent provisioningAgent =
                    Windows.Networking.NetworkOperators.ProvisioningAgent.CreateFromNetworkAccountId(networkAccountId);

                // Provision using XML
                ProvisionFromXmlDocumentResults result = await provisioningAgent.ProvisionFromXmlDocumentAsync(provisioningXML);

                if (result.AllElementsProvisioned)
                {
                    // Provisioning is done successfully
                    rootPage.NotifyUser("Device was successfully configured", NotifyType.StatusMessage);
                }
                else
                {
                    // Error has occured during provisioning
                    // And hence displaying result XML containing
                    // errors
                    rootPage.NotifyUser(util.ParseResultXML(result.ProvisionResultsXml), NotifyType.StatusMessage);
                }
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser("Unexpected exception occured: " + ex.ToString(), NotifyType.ErrorMessage);
            }

            ProvisionMnoButton.IsEnabled = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is the click handler for the 'Provision' button to provision the embedded XML file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ProvisionButton_Click(object sender, RoutedEventArgs args)
        {
            ProvisionButton.IsEnabled = false;

            try
            {
                // Open the installation folder
                var installLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;

                // Access the provisioning file
                var provisioningFile = await installLocation.GetFileAsync("ProvisioningData.xml");

                // Load with XML parser
                var xmlDocument = await XmlDocument.LoadFromFileAsync(provisioningFile);

                // Get raw XML
                var provisioningXml = xmlDocument.GetXml();

                // Create ProvisiongAgent Object
                var provisioningAgent = new ProvisioningAgent();

                // Create ProvisionFromXmlDocumentResults Object
                var result = await provisioningAgent.ProvisionFromXmlDocumentAsync(provisioningXml);

                if (result.AllElementsProvisioned)
                {
                    rootPage.NotifyUser("Provisioning was successful", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Provisioning result: " + result.ProvisionResultsXml, NotifyType.StatusMessage);
                }
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser(ex.ToString(), NotifyType.ErrorMessage);
            }

            ProvisionButton.IsEnabled = true;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This is the click handler for the 'ProvisionOtherOperatorButton' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ProvisionOtherOperator_Click(object sender, RoutedEventArgs e)
        {
            if (provXmlText.Text == "")
            {
                rootPage.NotifyUser("Provisioning XML cannot be empty", NotifyType.ErrorMessage);
                return;
            }

            string provisioningXML = provXmlText.Text;

            ProvisionOtherOperatorButton.IsEnabled = false;

            try
            {
                // Create provisioning agent
                Windows.Networking.NetworkOperators.ProvisioningAgent provisioningAgent = new Windows.Networking.NetworkOperators.ProvisioningAgent();

                // Provision using XML
                ProvisionFromXmlDocumentResults result = await provisioningAgent.ProvisionFromXmlDocumentAsync(provisioningXML);

                if (result.AllElementsProvisioned)
                {
                    // Provisioning is done successfully
                    rootPage.NotifyUser("Device was successfully configured", NotifyType.StatusMessage);
                }
                else
                {
                    // Error has occured during provisioning
                    // And hence displaying result XML containing
                    // errors
                    rootPage.NotifyUser(util.ParseResultXML(result.ProvisionResultsXml), NotifyType.StatusMessage);
                }
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser("Unexpected exception occured: " + ex.ToString(), NotifyType.ErrorMessage);
            }

            ProvisionOtherOperatorButton.IsEnabled = true;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This is the click handler for the 'ProvisionOtherOperatorButton' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ProvisionOtherOperator_Click(object sender, RoutedEventArgs e)
        {
            if (provXmlText.Text == "")
            {
                rootPage.NotifyUser("Provisioning XML cannot be empty", NotifyType.ErrorMessage);
                return;
            }

            string provisioningXML = provXmlText.Text;
            ProvisionOtherOperatorButton.IsEnabled = false;

            try
            {
                // Create provisioning agent
                Windows.Networking.NetworkOperators.ProvisioningAgent provisioningAgent = new Windows.Networking.NetworkOperators.ProvisioningAgent();

                // Provision using XML
                ProvisionFromXmlDocumentResults result = await provisioningAgent.ProvisionFromXmlDocumentAsync(provisioningXML);

                if (result.AllElementsProvisioned)
                {
                    // Provisioning is done successfully
                    rootPage.NotifyUser("Device was successfully configured", NotifyType.StatusMessage);
                }
                else
                {
                    // Error has occured during provisioning
                    // And hence displaying result XML containing
                    // errors
                    rootPage.NotifyUser(util.ParseResultXML(result.ProvisionResultsXml), NotifyType.StatusMessage);
                }
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser("Unexpected exception occured: " + ex.ToString(), NotifyType.ErrorMessage);
            }

            ProvisionOtherOperatorButton.IsEnabled = true;
        }