/// <summary>
        /// Initializes a new instance of the <see cref="RecognizeContentOperation"/> class.
        /// </summary>
        /// <param name="operationId">The ID of this operation.</param>
        /// <param name="client">The client used to check for completion.</param>
        public RecognizeContentOperation(string operationId, FormRecognizerClient client)
        {
            // TODO: Add argument validation here.

            Id             = operationId;
            _serviceClient = client.ServiceClient;
        }
예제 #2
0
        internal TrainingOperation(string location, ServiceRestClient allOperations)
        {
            _serviceClient = allOperations;

            // TODO: validate this
            // https://github.com/Azure/azure-sdk-for-net/issues/10385
            Id = location.Split('/').Last();
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RecognizeReceiptsOperation"/> class.
        /// </summary>
        /// <param name="serviceClient">The client for communicating with the Form Recognizer Azure Cognitive Service through its REST API.</param>
        /// <param name="operationLocation">The address of the long-running operation. It can be obtained from the response headers upon starting the operation.</param>
        internal RecognizeReceiptsOperation(ServiceRestClient serviceClient, string operationLocation)
        {
            _serviceClient = serviceClient;

            // TODO: Add validation here
            // https://github.com/Azure/azure-sdk-for-net/issues/10385
            Id = operationLocation.Split('/').Last();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RecognizeReceiptsOperation"/> class.
        /// </summary>
        /// <param name="operationId">The ID of this operation.</param>
        /// <param name="client">The client used to check for completion.</param>
        public RecognizeReceiptsOperation(string operationId, FormRecognizerClient client)
        {
            // TODO: Add argument validation here.

            Id             = operationId;
            _serviceClient = client.ServiceClient;
            _diagnostics   = client.Diagnostics;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RecognizeContentOperation"/> class.
        /// </summary>
        /// <param name="serviceClient">The client for communicating with the Form Recognizer Azure Cognitive Service through its REST API.</param>
        /// <param name="diagnostics">The client diagnostics for exception creation in case of failure.</param>
        /// <param name="operationLocation">The address of the long-running operation. It can be obtained from the response headers upon starting the operation.</param>
        internal RecognizeContentOperation(ServiceRestClient serviceClient, ClientDiagnostics diagnostics, string operationLocation)
        {
            _serviceClient = serviceClient;
            _diagnostics   = diagnostics;

            // TODO: Add validation here
            // https://github.com/Azure/azure-sdk-for-net/issues/10385
            Id = operationLocation.Split('/').Last();
        }
예제 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormTrainingClient"/> class.
        /// </summary>
        /// <param name="endpoint">The endpoint to use for connecting to the Form Recognizer Azure Cognitive Service.</param>
        /// <param name="credential">A credential used to authenticate to an Azure Service.</param>
        /// <param name="options">A set of options to apply when configuring the client.</param>
        /// <remarks>
        /// The <paramref name="endpoint"/> URI <c>string</c> can be found in the Azure Portal.
        /// </remarks>
        /// <seealso href="https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md#authenticate-a-form-recognizer-client"/>
        public FormTrainingClient(Uri endpoint, TokenCredential credential, FormRecognizerClientOptions options)
        {
            Argument.AssertNotNull(endpoint, nameof(endpoint));
            Argument.AssertNotNull(credential, nameof(credential));
            Argument.AssertNotNull(options, nameof(options));

            Diagnostics = new ClientDiagnostics(options);
            var pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, Constants.DefaultCognitiveScope));

            ServiceClient = new ServiceRestClient(Diagnostics, pipeline, endpoint.AbsoluteUri);
        }
예제 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormTrainingClient"/> class.
        /// </summary>
        /// <param name="endpoint">The endpoint to use for connecting to the Form Recognizer Azure Cognitive Service.</param>
        /// <param name="credential">A credential used to authenticate to an Azure Service.</param>
        /// <param name="options">A set of options to apply when configuring the client.</param>
        /// <remarks>
        /// Both the <paramref name="endpoint"/> URI <c>string</c> and the <paramref name="credential"/> <c>string</c> key
        /// can be found in the Azure Portal.
        /// </remarks>
        /// <seealso href="https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md#authenticate-a-form-recognizer-client"/>
        public FormTrainingClient(Uri endpoint, AzureKeyCredential credential, FormRecognizerClientOptions options)
        {
            Argument.AssertNotNull(endpoint, nameof(endpoint));
            Argument.AssertNotNull(credential, nameof(credential));
            Argument.AssertNotNull(options, nameof(options));

            Diagnostics = new ClientDiagnostics(options);
            HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new AzureKeyCredentialPolicy(credential, Constants.AuthorizationHeader));

            ServiceClient = new ServiceRestClient(Diagnostics, pipeline, endpoint.AbsoluteUri);
        }
예제 #8
0
        public static IRestResponse SaveAppointment(Appointment ap)
        {
            IRestResponse response = null;

            try
            {
                response = ServiceRestClient.ExecuteReturnPostRequest(ap, "appointments");
                if (response.Content != null)
                {
                    return(response);
                }
            }
            catch (Exception e)
            { }
            return(response);
        }
예제 #9
0
        private (ServiceRestClient ServiceClient, ContainerRestClient ContainerClient) BuildRestClients(Uri serviceUri)
        {
            ServiceRestClient serviceRestClient = new ServiceRestClient(
                clientDiagnostics: _clientDiagnostics,
                pipeline: _pipeline,
                url: serviceUri.AbsoluteUri,
                version: _version.ToVersionString());

            ContainerRestClient containerRestClient = new ContainerRestClient(
                clientDiagnostics: _clientDiagnostics,
                pipeline: _pipeline,
                url: serviceUri.AbsoluteUri,
                version: _version.ToVersionString());

            return(serviceRestClient, containerRestClient);
        }
예제 #10
0
        public static IRestResponse GetLoyaltyPoints()
        {
            IRestResponse response = null;

            try
            {
                var credential = DependencyService.Get <ICredentialRetriever>().GetCredential();
                response = ServiceRestClient.ExecuteGetRequest("loyaltycard/?partner_id=" + UmbrellaApi.PARTNER_ID);
                if (response.Content != null)
                {
                    return(response);
                }
            }
            catch (Exception e)
            {}
            return(response);
        }
예제 #11
0
 public static string GetTotalEarnings()
 {
     try
     {
         var credential = DependencyService.Get <ICredentialRetriever>().GetCredential();
         var rest       = ServiceRestClient.ExecuteGetRequest("earnings/?email=" + credential.User.Email);
         var obj        = JObject.Parse(rest.Content);
         var result     = (string)obj["acount_balance"];
         if (result != null)
         {
             return(result);
         }
     }
     catch (Exception e)
     {}
     return("0");
 }
예제 #12
0
        public async Task <int> GetRewardLevel(string email)
        {
            var rest = await ServiceRestClient.ExecuteGetTaskAsync("reward_level/?email=" + email).ConfigureAwait(false);

            System.Diagnostics.Debug.WriteLine("resultrest" + rest);
            var obj = JObject.Parse(rest.Content);

            System.Diagnostics.Debug.WriteLine("objreward" + obj);
            var result = (string)obj["reward_level"];

            System.Diagnostics.Debug.WriteLine("Resultreward" + result);
            if (result != null)
            {
                return(int.Parse(result));
            }
            return(1);
        }
예제 #13
0
        /// <summary>
        /// </summary>
        /// <param name="operations"></param>
        /// <param name="diagnostics"></param>
        /// <param name="operationLocation"></param>
        internal RecognizeCustomFormsOperation(ServiceRestClient operations, ClientDiagnostics diagnostics, string operationLocation)
        {
            _serviceClient = operations;
            _diagnostics   = diagnostics;

            // TODO: Use regex to parse ids.
            // https://github.com/Azure/azure-sdk-for-net/issues/11505

            // TODO: Add validation here (should we store _resuldId and _modelId as GUIDs?)
            // https://github.com/Azure/azure-sdk-for-net/issues/10385

            string[] substrs = operationLocation.Split('/');

            _resultId = substrs[substrs.Length - 1];
            _modelId  = substrs[substrs.Length - 3];

            Id = string.Join("/", substrs, substrs.Length - 3, 3);
        }
예제 #14
0
        public List <Message> GetMessages()
        {
            var list = new List <Message>();

            try
            {
                var     credential = DependencyService.Get <ICredentialRetriever>().GetCredential();
                var     rest = ServiceRestClient.ExecuteGetRequest("messages/?email=" + credential.User.Email);
                var     obj = JObject.Parse(rest.Content);
                dynamic msg = Newtonsoft.Json.JsonConvert.DeserializeObject(obj.ToString());
                var     stud = msg.replies;
                var     Subject = (string)obj["subject"];
                string  Sender = "", Email = "";
                foreach (var rep in stud)
                {
                    string str = rep.from_email;
                    if (str != null)
                    {
                        string   tr         = str.Trim().Replace("<", ",").Replace(">", "").Replace("\"", "");
                        string[] separators = { "," };
                        string[] words      = tr.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                        Sender = words[0];
                        Email  = words[1];
                    }
                    list.Add(new Message
                    {
                        Image         = ImageSource.FromUri(new Uri("http://www.mens-hairstyle.com/wp-content/uploads/2016/06/Good-Men-Haircuts.jpg")),
                        Sender        = Sender,
                        Email         = Email,
                        Subject       = msg.subject,
                        Body          = rep["body_text"],
                        Type          = MessageType.UmbrellaMessages,
                        IsUnread      = true,
                        HasAttachment = false,
                        Received      = DateTime.Now
                    });
                }
            }
            catch (Exception e)
            {
            }
            return(list);
        }
        private (ServiceRestClient, ContainerRestClient) BuildRestClients()
        {
            BlobUriBuilder uriBuilder = new BlobUriBuilder(_uri);

            uriBuilder.BlobContainerName = null;
            uriBuilder.BlobName          = null;

            ServiceRestClient serviceRestClient = new ServiceRestClient(
                clientDiagnostics: _clientDiagnostics,
                pipeline: _pipeline,
                url: uriBuilder.ToUri().ToString(),
                version: _version.ToVersionString());

            ContainerRestClient containerRestClient = new ContainerRestClient(
                clientDiagnostics: _clientDiagnostics,
                pipeline: _pipeline,
                url: uriBuilder.ToUri().ToString(),
                version: _version.ToVersionString());

            return(serviceRestClient, containerRestClient);
        }
예제 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BlobBatchClient"/>
        /// class for the same account as the <see cref="BlobServiceClient"/>.
        /// The new <see cref="BlobBatchClient"/> uses the same request policy
        /// pipeline as the <see cref="BlobServiceClient"/>.
        /// </summary>
        /// <param name="client">The <see cref="BlobServiceClient"/>.</param>
        public BlobBatchClient(BlobServiceClient client)
        {
            _uri      = client.Uri;
            _pipeline = BlobServiceClientInternals.GetHttpPipeline(client);
            BlobClientOptions options = BlobServiceClientInternals.GetClientOptions(client);

            _version           = options.Version;
            _clientDiagnostics = new StorageClientDiagnostics(options);

            // Construct a dummy pipeline for processing batch sub-operations
            // if we don't have one cached on the service
            _batchOperationPipeline = CreateBatchPipeline(
                _pipeline,
                BlobServiceClientInternals.GetAuthenticationPolicy(client),
                _version);

            (ServiceRestClient serviceRestClient, ContainerRestClient containerRestClient) = BuildRestClients(_uri);
            _serviceRestClient   = serviceRestClient;
            _containerRestClient = containerRestClient;

            _isContainerScoped = false;
        }
예제 #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RecognizeCustomFormsOperation"/> class.
        /// </summary>
        /// <param name="operationId">The ID of this operation.</param>
        /// <param name="client">The client used to check for completion.</param>
        public RecognizeCustomFormsOperation(string operationId, FormRecognizerClient client)
        {
            _serviceClient = client.ServiceClient;
            _diagnostics   = client.Diagnostics;

            // TODO: Use regex to parse ids.
            // https://github.com/Azure/azure-sdk-for-net/issues/11505

            // TODO: Add validation here (should we store _resuldId and _modelId as GUIDs?)
            // https://github.com/Azure/azure-sdk-for-net/issues/10385

            string[] substrs = operationId.Split('/');

            if (substrs.Length < 3)
            {
                throw new ArgumentException($"Invalid {operationId}. It should be formatted as: '{{modelId}}/analyzeresults/{{resultId}}'.", operationId);
            }

            _resultId = substrs.Last();
            _modelId  = substrs.First();

            Id = operationId;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CopyModelOperation"/> class.
        /// </summary>
        /// <param name="serviceClient">The client for communicating with the Form Recognizer Azure Cognitive Service through its REST API.</param>
        /// <param name="diagnostics">Provides tools for exception creation in case of failure.</param>
        /// <param name="operationLocation">The address of the long-running operation. It can be obtained from the response headers upon starting the operation.</param>
        /// <param name="targetModelId">Model id in the target Form Recognizer Resource.</param>
        internal CopyModelOperation(ServiceRestClient serviceClient, ClientDiagnostics diagnostics, string operationLocation, string targetModelId)
        {
            _serviceClient = serviceClient;
            _diagnostics   = diagnostics;
            _targetModelId = targetModelId;

            // TODO: Use regex to parse ids.
            // https://github.com/Azure/azure-sdk-for-net/issues/11505

            // TODO: Add validation here (should we store _resuldId and _modelId as GUIDs?)
            // https://github.com/Azure/azure-sdk-for-net/issues/10385

            string[] substrs = operationLocation.Split('/');

            if (substrs.Length < 3)
            {
                throw new ArgumentException($"Invalid {operationLocation}. It should be formatted as: '{{modelId}}/analyzeresults/{{resultId}}'.", operationLocation);
            }

            _resultId = substrs[substrs.Length - 1];
            _modelId  = substrs[substrs.Length - 3];

            Id = string.Join("/", substrs, substrs.Length - 3, 3);
        }
예제 #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CopyModelOperation"/> class.
        /// </summary>
        /// <param name="operationId">The ID of this operation.</param>
        /// <param name="targetModelId">Model ID in the target Form Recognizer resource.</param>
        /// <param name="client">The client used to check for completion.</param>
        public CopyModelOperation(string operationId, string targetModelId, FormTrainingClient client)
        {
            _serviceClient = client.ServiceClient;
            _diagnostics   = client.Diagnostics;
            _targetModelId = targetModelId;

            // TODO: Use regex to parse ids.
            // https://github.com/Azure/azure-sdk-for-net/issues/11505

            // TODO: Add validation here (should we store _resuldId and _modelId as GUIDs?)
            // https://github.com/Azure/azure-sdk-for-net/issues/10385

            string[] substrs = operationId.Split('/');

            if (substrs.Length < 3)
            {
                throw new ArgumentException($"Invalid '{nameof(operationId)}'. It should be formatted as: '{{modelId}}/copyresults/{{resultId}}'.", nameof(operationId));
            }

            _resultId = substrs.Last();
            _modelId  = substrs.First();

            Id = operationId;
        }
예제 #20
0
 internal ServiceClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string syncToken = null, string apiVersion = "1.0")
 {
     RestClient         = new ServiceRestClient(clientDiagnostics, pipeline, endpoint, syncToken, apiVersion);
     _clientDiagnostics = clientDiagnostics;
     _pipeline          = pipeline;
 }
예제 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TrainingOperation"/> class.
 /// </summary>
 /// <param name="operationId">The ID of this operation.</param>
 /// <param name="client">The client used to check for completion.</param>
 public TrainingOperation(string operationId, FormTrainingClient client)
 {
     Id             = operationId;
     _serviceClient = client.ServiceClient;
 }