Example #1
0
        /// <summary>
        /// Initially used via a response callback for commands which expect a async response
        /// </summary>
        /// <param name="webResponse">the HttpWebResponse that will be sent back to the user from the request</param>
        protected virtual void ResponseCallback(HttpWebResponse webResponse)
        {
            //Track and throw up the X-ms request id (x-ms-request-id)
            MsftAsyncResponseId = webResponse.GetResponseHeader("x-ms-request-id");
            ElastaLogger.MessageLogger.Trace("Hosted Service Response Id: {0}", MsftAsyncResponseId);
            for (;;)
            {
                var asyncCommand = new GetAsyncStatusCommand
                {
                    HttpVerb       = HttpVerbGet,
                    SubscriptionId = SubscriptionId,
                    OperationId    = MsftAsyncResponseId,
                    ServiceType    = "operations",
                    Certificate    = Certificate
                };
                asyncCommand.Execute();
                Thread.Sleep(1000);
                OperationStatus status = asyncCommand.GetOperationStatus();
                switch (status)
                {
                case OperationStatus.InProgress:
                    break;

                case OperationStatus.Failed:
                    ElastaLogger.MessageLogger.Error("Hosted Service Response Id: {0}", MsftAsyncResponseId);
                    SitAndWait.Set();
                    return;

                case OperationStatus.Succeeded:
                    ElastaLogger.MessageLogger.Trace("Hosted Service Response Id: {0}", MsftAsyncResponseId);
                    SitAndWait.Set();
                    return;
                }
            }
        }
 /// <summary>
 /// Initially used via a response callback for commands which expect a async response 
 /// </summary>
 /// <param name="webResponse">the HttpWebResponse that will be sent back to the user from the request</param>
 protected virtual void ResponseCallback(HttpWebResponse webResponse)
 {
     //Track and throw up the X-ms request id (x-ms-request-id)
     MsftAsyncResponseId = webResponse.GetResponseHeader("x-ms-request-id");
     ElastaLogger.MessageLogger.Trace("Hosted Service Response Id: {0}", MsftAsyncResponseId);
     for (;;)
     {
         var asyncCommand = new GetAsyncStatusCommand
                                {
                                    HttpVerb = HttpVerbGet,
                                    SubscriptionId = SubscriptionId,
                                    OperationId = MsftAsyncResponseId,
                                    ServiceType = "operations",
                                    Certificate = Certificate
                                };
         asyncCommand.Execute();
         Thread.Sleep(1000);
         OperationStatus status = asyncCommand.GetOperationStatus();
         switch (status)
         {
             case OperationStatus.InProgress:
                 break;
             case OperationStatus.Failed:
                 ElastaLogger.MessageLogger.Error("Hosted Service Response Id: {0}", MsftAsyncResponseId);
                 SitAndWait.Set();
                 return;
             case OperationStatus.Succeeded:
                 ElastaLogger.MessageLogger.Trace("Hosted Service Response Id: {0}", MsftAsyncResponseId);
                 SitAndWait.Set();
                 return;
         }
     }
 }