Example #1
0
    private void QueryIdFacebookCallback(AzureResponse <List <pandafruitfarm> > response)
    {
        long score = Convert.ToInt64(ObscuredPrefs.GetString("score"));
        var  list  = response.ResponseData;

        if (list.Count > 0)
        {
            foreach (var item in list)
            {
                _selectedItem = item;
                if (item.Score < score)
                {
                    _selectedItem.Score      = score;
                    _selectedItem.IdFacebook = GetDataFacebook.IDFacebook;
                    _selectedItem.Level      = "Level" + ObscuredPrefs.GetInt("level");
                    _selectedItem.Username   = GetDataFacebook.UserFacebook;
                    azure.Update <pandafruitfarm>(_selectedItem);
                }
            }
        }
        else
        {
            _selectedItem.Score      = score;
            _selectedItem.IdFacebook = GetDataFacebook.IDFacebook;
            _selectedItem.Level      = "Level" + ObscuredPrefs.GetInt("level");
            _selectedItem.Username   = GetDataFacebook.UserFacebook;
            azure.Insert <pandafruitfarm>(_selectedItem);
        }
    }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AzureResponseException"/> class
        /// using a <see cref="AzureResponse"/> instance.
        /// </summary>
        /// <param name="response"><see cref="AzureResponse"/> instance containing the response.</param>
        /// <param name="errorMessage">Message describing the error.</param>
        public AzureResponseException(AzureResponse response, string errorMessage) : this(errorMessage)
        {
            Response = response;

            // Build a new fault object
            Fault = AzureResponseHelper.BuildFaultMessage(ErrorMessage, response);
        }
Example #3
0
        /// <summary>
        /// Sends a REST request to the given API, optionally using OAuth.
        /// </summary>
        /// <param name="method"><see cref="HttpMethod"/> instance indicating the HTTP method to use.</param>
        /// <param name="destinationUri"><see cref="Uri"/> instance with the Uri to use.</param>
        /// <param name="headers">Optional <see cref="IDictionary{string, string}"/> instance with any headers to set.</param>
        /// <param name="bodyContent">Optional body content to send.</param>
        /// <param name="bodyContentType">Optional content type of the body.</param>
        /// <param name="cancellationToken">Optional sync <see cref="CancellationToken"/> instance.</param>
        /// <returns><see cref="AzureResponse"/> instance.</returns>
        public virtual async Task <AzureResponse> SendAsync(HttpMethod method, Uri destinationUri, IDictionary <string, string> headers = null, string bodyContent = null, string bodyContentType = DefaultContentType, CancellationToken cancellationToken = default)
        {
            HttpClient          httpClient = new HttpClient();
            HttpResponseMessage httpResponse;
            AzureResponse       azureResponse;

            try
            {
                // Initialize if not initialized
                if (!_initialized)
                {
                    Initialize();
                }

                // Create the request message
                HttpRequestMessage requestMessage = new HttpRequestMessage(method, destinationUri);

                // Set headers
                if (headers != null && headers.Count > 0)
                {
                    foreach (var item in headers)
                    {
                        if (requestMessage.Headers.Contains(item.Key))
                        {
                            requestMessage.Headers.Remove(item.Key);
                        }
                        requestMessage.Headers.Add(item.Key, item.Value);
                    }
                }

                // Set body content
                if (bodyContent != null)
                {
                    //TODO: allow different encodings?
                    requestMessage.Content = new StringContent(bodyContent, Encoding.UTF8, bodyContentType);
                }

                //Check if we need to authenticate
                if (_requestDetails.OAuthEnabled(AuthenticationEndpoint))
                {
                    // Authenticate the request
                    _client.Credentials.ProcessHttpRequestAsync(requestMessage, cancellationToken).GetAwaiter().GetResult();
                }

                // Make the call and get a response
                httpResponse = await httpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);

                // Create a new AzureResponse
                azureResponse = new AzureResponse(httpResponse);
            }
            catch (Exception ex)
            {
                // Exception occurred
                throw new AzureResponseException($"An error occurred making a REST call: {ex.Message}", ex);
            }

            return(azureResponse);
        }
Example #4
0
    private void QueryCallback(AzureResponse <List <moregame> > obj)
    {
        var list = obj.ResponseData;

        for (int i = 0; i < list.Count; i++)
        {
            _moregame.Add(list[i]);
        }
    }
Example #5
0
	void OnServiceLoggedIn (AzureResponse<MobileServiceUser> response)
	{
		// If the login attempt was successful, save the user object. Otherwise, log the error
		if (response.Status == AzureResponseStatus.Success) {
			NetworkingManager.Instance.Service.User = response.ResponseData;
		} else {
			Debug.Log ("Error:" + response.StatusCode);
		}
	}
Example #6
0
 private void LoginAsyncCallback(AzureResponse <MobileServiceUser> obj)
 {
     if (obj.Status == AzureResponseStatus.Success)
     {
         azure.User = obj.ResponseData;
     }
     else
     {
         Debug.Log("Error:" + obj.StatusCode);
     }
 }
Example #7
0
        /// <summary>
        /// Gets a <see cref="JObject"/> instance containing the RoutingProperties for the given ScenarioName from APIM.
        /// </summary>
        /// <param name="scenarioName">Name of the scenario to get the RoutingProperties for.</param>
        /// <returns><see cref="Task{JObject}"/> instance containing the RoutingProperties.</returns>
        public async Task <JObject> GetRoutingPropertiesAsync(string scenarioName)
        {
            Argument.AssertNotNullOrEmpty(scenarioName, nameof(scenarioName));

            // Make a call to APIM to get RoutingSlip
            HttpClient    httpClient = new HttpClient();
            Uri           apimUri    = new Uri($"{AuthenticationScope}aimroutingstore/routingproperties/{scenarioName}?clearCache={_requestDetails.ClearCache}");
            AzureResponse response   = await GetFromAPIM(apimUri, "RoutingProperties");

            return(response.BodyContentAsJson as JObject);
        }
Example #8
0
        /// <summary>
        /// Gets the content of a given Schema in the ArtifactStore from APIM.
        /// </summary>
        /// <param name="schemaName">Name of the scenario to get the content for.</param>
        /// <returns>Schema content as a string.</returns>
        public async Task <string> GetSchemaContentByNameAsync(string schemaName)
        {
            Argument.AssertNotNullOrEmpty(schemaName, nameof(schemaName));

            // Make a call to APIM to get Schema Content
            HttpClient    httpClient = new HttpClient();
            Uri           apimUri    = new Uri($"{AuthenticationScope}aimconfigurationmanager/schemacontentbyname/{schemaName}?clearCache={_requestDetails.ClearCache}");
            AzureResponse response   = await GetFromAPIM(apimUri, "SchemaContent", false);

            return(response.BodyContent);
        }
    public void ReadHandler(AzureResponse <List <Leaderboard> > response)
    {
        var list = response.ResponseData;

        Debug.Log("Items ==================");
        foreach (var item in list)
        {
            Debug.Log(Convert.ToString(item.Score) + "," + item.Username + "," + item.Id);
            _leaderboardItems.Add(item);
        }
        Debug.Log("==================");
    }
Example #10
0
    public void ReadHandler(AzureResponse <List <ToDoItem> > response)
    {
        var list = response.ResponseData;

        Debug.Log("Items ==================");
        foreach (var item in list)
        {
            Debug.Log(item.Text + "," + item.Id);
            _toDoItems.Add(item);
        }
        Debug.Log("==================");
    }
Example #11
0
    public void ReadHandler(AzureResponse <List <pandafruitfarm> > response)
    {
        var list = response.ResponseData;

        Debug.Log("Items ==================");
        foreach (var item in list)
        {
            Debug.Log(item.Username);
            //getDataFacebook.GetAvatar(item.IdFacebook, 1);
            _leaderboardItems.Add(item);
        }
        Debug.Log("==================");
    }
Example #12
0
        public void ReadHandler(AzureResponse<List<LeaderBoard>> response)
        {

            Debug.WriteLine("readhandler");
            var list = response.ResponseData;

            Debug.WriteLine("Items ==================");
            foreach (var item in list)
            {
                Debug.WriteLine(item.ToString());
                //_leaders.Add(item);
            }
            Debug.WriteLine("==================");
        }
Example #13
0
        /// <summary>
        /// Builds a new <see cref="JObject"/> instance representing a fault.
        /// </summary>
        /// <param name="message">Error message for this fault.</param>
        /// <returns><see cref="AzureResponse"/> instance returned by Azure, which may or may not contain a fault object.</returns>
        public static JObject BuildFaultMessage(string message, AzureResponse response)
        {
            Argument.AssertNotNullOrEmpty(message, nameof(message));
            Argument.AssertNotNull(response, nameof(response));

            // Check if the response already contains a fault
            if (response.IsFault)
            {
                // Return the BodyContent as a JSON fault object
                return(response.BodyContentAsJson as JObject);
            }

            // Build a new Fault object from the response
            return(BuildFaultMessage($"{message}: {response.BodyContent}", ((int)response.StatusCode).ToString(), response.Reason, response.RequestUri.ToString()));
        }
Example #14
0
    private void QueryListLevelCallback(AzureResponse <List <pandafruitfarm> > response)
    {
        var list = response.ResponseData;

        for (int i = 0; i < list.Count; i++)
        {
            lstId.Add(list[i].IdFacebook);
            if (list[i].Username.Length > 10)
            {
                list[i].Username = "******" + list[i].Username.Substring(list[i].Username.Length - 10);
            }
            getDataFacebook.lstName[i].text  = list[i].Username;
            getDataFacebook.lstScore[i].text = list[i].Score.ToString();
        }
        StartCoroutine(getDataFacebook.getAvatarFriend(lstId));
    }
Example #15
0
        /// <summary>
        /// Creates a new <see cref="ContentResult"/> instance from the supplied message.
        /// </summary>
        /// <param name="message">Message to use in the result.</param>
        /// <param name="response"><see cref="AzureResponse"/> instance to use.</param>
        /// <param name="logPrefix">Logging prefix to use.</param>
        /// <param name="log"><see cref="ILogger"/> instance to use.</param>
        /// <returns><see cref="ContentResult"/> instance.</returns>
        public static ContentResult CreateFaultObjectResult(string message, AzureResponse response, string logPrefix, ILogger log)
        {
            Argument.AssertNotNullOrEmpty(message, nameof(message));
            Argument.AssertNotNull(response, nameof(response));
            Argument.AssertNotNullOrEmpty(logPrefix, nameof(logPrefix));
            Argument.AssertNotNull(log, nameof(log));

            string errorMessage = $"{message}: {response}";

            log.LogError($"{logPrefix}{errorMessage}");

            return(new ContentResult()
            {
                Content = BuildFaultMessage(message, response).ToString(),
                ContentType = "application/json",
                StatusCode = 500
            });
        }
Example #16
0
        /// <summary>
        /// Gets a <see cref="Uri"/> instance containing a CallbackUrl for the given Consumption LogicApp from APIM.
        /// </summary>
        /// <param name="resourceGroupName">Name of the ResourceGroup the Consumption LogicApp is in.</param>
        /// <param name="logicAppName">Name of the Consumption LogicApp.</param>
        /// <returns><see cref="Task{Uri}"/> instance containing a CallbackUrl.</returns>
        public async Task <Uri> GetConsumptionLogicAppCallbackUrlAsync(string resourceGroupName, string logicAppName)
        {
            Argument.AssertNotNullOrEmpty(ApimInstanceName, nameof(ApimInstanceName));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(logicAppName, nameof(logicAppName));

            // Make a call to APIM to get LogicApp CallbackUrl
            Uri           apimUri  = new Uri($"{AuthenticationScope}aimroutingmanager/logicappcallbackurl/{resourceGroupName}/{logicAppName}?clearCache={_requestDetails.ClearCache}");
            AzureResponse response = await GetFromAPIM(apimUri, "Consumption LogicApp CallbackUrl");

            // Get and return the CallbackUrl as a Uri instance
            string logicAppUrl = ((JObject)response.BodyContentAsJson)?["logicAppUrl"]?.ToString();

            if (string.IsNullOrWhiteSpace(logicAppUrl))
            {
                // No Url
                throw new AzureResponseException(response, $"No valid Url in the JSON returned from APIM trying to get a Consumption LogicApp CallbackUrl");
            }

            return(new Uri(logicAppUrl));
        }
    public void ReadHandler(AzureResponse<List<Leaderboard>> response)
    {
        var list = response.ResponseData;

        Debug.Log("Items ==================");
        foreach (var item in list)
        {
            Debug.Log( Convert.ToString(item.Score) + "," + item.Username + "," + item.Id);
            _leaderboardItems.Add(item);
        }
        Debug.Log("==================");
    }
Example #18
0
    public void ReadHandlerSchool(AzureResponse<List<School>> response)
    {
        returned = false;
        var list = response.ResponseData;

        Debug.Log("Items ==================");
        foreach (var item in list)
        {
            Debug.Log(item.Name + "," + item.Id);
            _schools.Add(item);

        }
        Debug.Log("==================");
        returned = true;
    }
 private void UploadScoreCallback(AzureResponse<Score> response)
 {
 }
Example #20
0
        public async Task <PowerBIToken> GetToken()
        {
            try
            {
                string pBiUser     = ConfigurationManager.AppSettings["Username"];
                string pBiPwd      = ConfigurationManager.AppSettings["Password"];
                string pBiClientId = ConfigurationManager.AppSettings["ClientId"];
                string pBiSecret   = ConfigurationManager.AppSettings["ClientSecret"];

                if (string.IsNullOrEmpty(pBiUser) || string.IsNullOrEmpty(pBiPwd) || string.IsNullOrEmpty(pBiClientId) || string.IsNullOrEmpty(pBiSecret))
                {
                    return(new PowerBIToken()
                    {
                        AccessToken = null,
                        RefreshToken = null,
                        StatusCode = HttpStatusCode.BadRequest.ToString(),
                        Message = "Authentication Credentials missing"
                    });
                }
                string tokenEndpointUri = "https://login.microsoftonline.com/common/oauth2/token";

                var content = new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair <string, string>("grant_type", "password"),
                    new KeyValuePair <string, string>("username", pBiUser),
                    new KeyValuePair <string, string>("password", pBiPwd),
                    new KeyValuePair <string, string>("client_id", pBiClientId),
                    new KeyValuePair <string, string>("client_secret", pBiSecret),
                    new KeyValuePair <string, string>("resource", "https://analysis.windows.net/powerbi/api")
                });
                AzureResponse  tokenRes = new AzureResponse();
                HttpStatusCode statusCode;
                string         message;
                using (var client = new HttpClient())
                {
                    HttpResponseMessage res = client.PostAsync(tokenEndpointUri, content).Result;
                    statusCode = res.StatusCode;
                    message    = res.IsSuccessStatusCode == true ? "Success" : "failure";
                    string json = await res.Content.ReadAsStringAsync();

                    tokenRes = JsonConvert.DeserializeObject <AzureResponse>(json);
                }
                PowerBIToken token = new PowerBIToken()
                {
                    AccessToken  = tokenRes.access_token,
                    RefreshToken = tokenRes.refresh_token,
                    StatusCode   = statusCode.ToString(),
                    Message      = message
                };

                return(token);
            }
            catch (Exception ex)
            {
                return(new PowerBIToken()
                {
                    AccessToken = null,
                    RefreshToken = null,
                    StatusCode = HttpStatusCode.InternalServerError.ToString(),
                    Message = ex.Message
                });
            }
        }
Example #21
0
 /// <summary>
 /// Builds a new <see cref="JObject"/> instance representing a fault.
 /// </summary>
 /// <returns><see cref="AzureResponse"/> instance returned by Azure, which may or may not contain a fault object.</returns>
 public static JObject BuildFaultMessage(AzureResponse response)
 {
     return(BuildFaultMessage(null, response));
 }
 public void CreateHandler(AzureResponse<Leaderboard> response)
 {
     Debug.Log("CreateHandler response: " + response.ResponseData.ToString());
     createComplete = true;
 }
Example #23
0
    public void ReadHandlerLeader(AzureResponse<List<LeaderBoard>> response)
    {
        returned = false;
        var list = response.ResponseData;

        Debug.Log("Items ==================");
        foreach (var item in list)
        {
            Debug.Log(item.Game + "," + item.Id+ "," +item.PlayerName+ "," +item.Score);
            _leaderBoardItems.Add(item);

        }
        Debug.Log("==================");

        returned = true;
    }
 private void MyCallback(AzureResponse <MobileServiceUser> obj)
 {
 }
Example #25
0
    public void ReadHandler(AzureResponse<List<ToDoItem>> response)
    {
        var list = response.ResponseData;

        Debug.Log("Items ==================");
        foreach (var item in list)
        {
            Debug.Log(item.Text + "," + item.Id);
            _toDoItems.Add(item);
        }
        Debug.Log("==================");
    }
Example #26
0
        /// <summary>
        /// Looks at the response from the called route, and works out what to return back to the last caller.
        /// For example, if the route returned an ACK message, we return this.
        /// If the route returns a Fault, we create a new NACK message and return this.
        /// </summary>
        /// <param name="requestDetails"><see cref="RequestDetails"/> containing information about the original request.</param>
        /// <param name="routeResponse"><see cref="AzureResponse"/> instance returned from the call to the current route.</param>
        /// <param name="routeType">Type of route (used in logging).</param>
        /// <param name="routeName">Name of route (used in logging).</param>
        /// <param name="logPrefix">Log prefix.</param>
        /// <param name="log"><see cref="ILogger"/> instance used for logging.</param>
        /// <returns><see cref="IActionResult"/> instance with the result.</returns>
        public static IActionResult GenerateRouteResponse(RequestDetails requestDetails, AzureResponse routeResponse, string routeType, string routeName, string logPrefix, ILogger log)
        {
            Argument.AssertNotNull(requestDetails, nameof(requestDetails));
            Argument.AssertNotNull(routeResponse, nameof(routeResponse));
            Argument.AssertNotNullOrEmpty(routeType, nameof(routeType));
            Argument.AssertNotNullOrEmpty(routeName, nameof(routeName));
            Argument.AssertNotNullOrEmpty(logPrefix, nameof(logPrefix));
            Argument.AssertNotNull(log, nameof(log));

            // Check if we have a 200 response
            if (routeResponse.StatusCode == HttpStatusCode.OK)
            {
                // We should have an ACK envelope
                if (routeResponse.BodyEnvelopeType == EnvelopeType.Ack)
                {
                    // Return the ACK with a 200 code
                    log.LogDebug($"{logPrefix}Finished calling the next route {routeType} and received an ACK - returning result");
                    return(new OkObjectResult(routeResponse.BodyContentAsJson));
                }
                else if (routeResponse.BodyEnvelopeType == EnvelopeType.Nack)
                {
                    // Return the NACK with a 200 code
                    log.LogDebug($"{logPrefix}Finished calling the next route {routeType} and received a NACK - returning result");
                    return(new OkObjectResult(routeResponse.BodyContentAsJson));
                }
                else
                {
                    // Invalid envelope type
                    return(CreateFaultObjectResult(requestDetails, $"{routeType} {routeName} returned an HTTP 200 but didn't return an ACK or NACK envelope - instead the envelope type is {routeResponse.BodyEnvelopeType}", logPrefix, log));
                }
            }

            // We have something other than a 200 response
            // Check if we have a Fault
            if (routeResponse.IsFault)
            {
                return(CreateFaultObjectResult($"{routeType} {routeName} returned a Fault", routeResponse, logPrefix, log));
            }

            // Check we have returned content
            if (routeResponse.BodyContentLength == 0)
            {
                return(CreateFaultObjectResult(requestDetails, $"No response content was returned after calling {routeType} {routeName}", logPrefix, log));
            }

            // Check that we have a JSON response from the route
            if (routeResponse.BodyContentAsJson == null || !(routeResponse.BodyContentAsJson is JObject))
            {
                return(CreateFaultObjectResult($"Unable to parse the response from the {routeType} {routeName} as a JSON Object", routeResponse, logPrefix, log));
            }

            // We have content but it's not JSON - wrap the content in a Fault
            return(CreateFaultObjectResult($"{routeType} {routeName} did not succeed and returned a non-JSON response", routeResponse, logPrefix, log));
        }
Example #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AzureResponseException"/> class
 /// using a <see cref="AzureResponse"/> instance.
 /// </summary>
 /// <param name="response"><see cref="AzureResponse"/> instance containing the response.</param>
 public AzureResponseException(AzureResponse response) : this(response, "An error occurred during an Http Request")
 {
 }
        /// <summary>
        /// Check Prerequisites for Vault Upgrade.
        /// </summary>
        /// <param name='resourceUpgradeInput'>
        /// Required. Input required for the resource to be upgraded.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// The response model for the Azure operations.
        /// </returns>
        public async Task <AzureResponse> CheckPrerequisitesForRecoveryServicesVaultUpgradeAsync(ResourceUpgradeInput resourceUpgradeInput, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken)
        {
            // Validate
            if (resourceUpgradeInput == null)
            {
                throw new ArgumentNullException("resourceUpgradeInput");
            }
            if (resourceUpgradeInput.NewResourcePath == null)
            {
                throw new ArgumentNullException("resourceUpgradeInput.NewResourcePath");
            }

            // Tracing
            bool   shouldTrace  = TracingAdapter.IsEnabled;
            string invocationId = null;

            if (shouldTrace)
            {
                invocationId = TracingAdapter.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("resourceUpgradeInput", resourceUpgradeInput);
                tracingParameters.Add("customRequestHeaders", customRequestHeaders);
                TracingAdapter.Enter(invocationId, this, "CheckPrerequisitesForRecoveryServicesVaultUpgradeAsync", tracingParameters);
            }

            // Construct URL
            string url = "";

            url = url + "/";
            if (this.Client.Credentials.SubscriptionId != null)
            {
                url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId);
            }
            url = url + "/cloudservices/";
            url = url + Uri.EscapeDataString(this.Client.CloudServiceName);
            url = url + "/resources/";
            url = url + Uri.EscapeDataString(this.Client.ResourceNamespace);
            url = url + "/~/";
            url = url + Uri.EscapeDataString(this.Client.ResourceType);
            url = url + "/";
            url = url + Uri.EscapeDataString(this.Client.ResourceName);
            url = url + "/checkPrereqsForUpgrade";
            string baseUrl = this.Client.BaseUri.AbsoluteUri;

            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;

            try
            {
                httpRequest            = new HttpRequestMessage();
                httpRequest.Method     = HttpMethod.Post;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers
                httpRequest.Headers.Add("Accept", "application/xml");
                httpRequest.Headers.Add("Agent-Authentication", customRequestHeaders.AgentAuthenticationHeader);
                httpRequest.Headers.Add("x-ms-client-request-id", customRequestHeaders.ClientRequestId);
                httpRequest.Headers.Add("x-ms-version", "2013-03-01");

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Serialize Request
                string    requestContent = null;
                XDocument requestDoc     = new XDocument();

                XElement resourceUpgradeInputElement = new XElement(XName.Get("ResourceUpgradeInput", "http://schemas.microsoft.com/windowsazure"));
                requestDoc.Add(resourceUpgradeInputElement);

                XElement newResourcePathElement = new XElement(XName.Get("NewResourcePath", "http://schemas.microsoft.com/windowsazure"));
                newResourcePathElement.Value = resourceUpgradeInput.NewResourcePath;
                resourceUpgradeInputElement.Add(newResourcePathElement);

                requestContent      = requestDoc.ToString();
                httpRequest.Content = new StringContent(requestContent, Encoding.UTF8);
                httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/xml");

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        TracingAdapter.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                    if (shouldTrace)
                    {
                        TracingAdapter.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
                        if (shouldTrace)
                        {
                            TracingAdapter.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    AzureResponse result = null;
                    // Deserialize Response
                    if (statusCode == HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                        result = new AzureResponse();
                        XDocument responseDoc = XDocument.Parse(responseContent);
                    }
                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("x-ms-request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        TracingAdapter.Exit(invocationId, result);
                    }
                    return(result);
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }
 private void OnError(AzureResponse<object> azureResponse)
 {
 }
 private void MyCallback(AzureResponse<MobileServiceUser> obj)
 {
 }
 public void DeleteHandler(AzureResponse<object> response)
 {
     Debug.Log("DeleteHandler response: " + response.ResponseData.ToString());
     deleteComplete = true;
 }
Example #32
0
 private void LoginAsyncCallback(AzureResponse<MobileServiceUser> obj)
 {
     if (obj.Status == AzureResponseStatus.Success)
     {
         azure.User = obj.ResponseData;
     }
     else
     {
         Debug.Log("Error:" + obj.StatusCode);
     }
 }
 public void ReadHandler(AzureResponse<List<Leaderboard>> response)
 {
     listToShow = response.ResponseData;
     Debug.Log("ReadHandler response: ==================");
     foreach (Leaderboard item in listToShow)
     {
         Debug.Log(Convert.ToString(item.Score) + ", " + item.Username + ", " + item.Id);
     }
     Debug.Log("==================");
     readComplete = true;
 }
 private void OnError(AzureResponse <object> azureResponse)
 {
 }
Example #35
0
    public void ReadHandler(AzureResponse<List<PlayerProfile>> response)
    {
        returned = false;
        var list = response.ResponseData;

        Debug.Log("Items ==================");
        foreach (var item in list)
        {
            Debug.Log(item.Name + "," + item.Id);
            _playprofiles.Add(item);

        }
        Debug.Log("==================");
        returned = true;
    }