Esempio n. 1
0
        private void AsyncCallback(IRestResponse response)
        {
            var doc = ProcessResponse(response);

            if (doc != null)
            {
                Successful?.Invoke(doc);
            }
        }
Esempio n. 2
0
        public void Execute()
        {
            for (var retry = 0; retry <= retries; retry++)
            {
                try
                {
                    action(retry);
                    Successful?.Invoke(this, new RetryArgs(attempt));
                    attempt = 0;
                    return;
                }
                catch (Exception exception)
                {
                    exceptionAction(exception, retry);
                    attempt = retry;
                }

                Failed?.Invoke(this, new RetryArgs(attempt));
            }
        }
Esempio n. 3
0
        private async Task <MTConnectAssets.Document> ProcessResponse(HttpResponseMessage response)
        {
            if (response != null)
            {
                if (!response.IsSuccessStatusCode)
                {
                    ConnectionError?.Invoke(new Exception(response.ReasonPhrase));
                }
                else if (response.Content != null)
                {
                    string xml = await response.Content.ReadAsStringAsync();

                    if (!string.IsNullOrEmpty(xml))
                    {
                        // Process MTConnectAssets Document
                        var doc = MTConnectAssets.Document.Create(xml);
                        if (doc != null)
                        {
                            doc.UserObject = UserObject;
                            doc.Url        = response.RequestMessage.RequestUri.ToString();
                            Successful?.Invoke(doc);
                            return(doc);
                        }
                        else
                        {
                            // Process MTConnectError Document (if MTConnectDevices fails)
                            var errorDoc = MTConnectError.Document.Create(xml);
                            if (errorDoc != null)
                            {
                                errorDoc.UserObject = UserObject;
                                errorDoc.Url        = response.RequestMessage.RequestUri.ToString();
                                Error?.Invoke(errorDoc);
                            }
                        }
                    }
                }
            }

            return(null);
        }
Esempio n. 4
0
 protected void OnSuccessful(TEventArgs arg) => Successful?.Invoke(this, arg);
Esempio n. 5
0
 public void OnSuccess(Java.Lang.Object result)
 {
     Successful?.Invoke(this, new EventArgs());
 }
Esempio n. 6
0
 void OnSuccessful(object sender, TEventArgs e)
 {
     Successful?.Invoke(this, e);
 }