Example #1
0
        public static async Task <MiddlewareResponse> GetStateInvoiceMiddlewareAsync(AuthenticationProvider authenticationProvider, Guid id)
        {
            try
            {
                // Create the HTTP client to perform the request

                using (HttpClient client = new HttpClient())
                {
                    await authenticationProvider.SetAccessTokenAsync(client);

                    MiddlewareResponse res = await MiddlewareController.GetInvoiceProcessAsync(client, id);

                    if (res.state.Equals("Succeeded", StringComparison.OrdinalIgnoreCase))
                    {
                        res.details = await MiddlewareController.GetInvoiceOutputProcessAsync(client, id);
                    }

                    return(res);
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
Example #2
0
        public static async Task <List <MiddlewareResponse> > CreateBulkInvoiceMiddlewareAsync(AuthenticationProvider authenticationProvider, List <OrderResource> orders)
        {
            try
            {
                List <MiddlewareResponse> result = new List <MiddlewareResponse>();

                // Create the HTTP client to perform the request

                using (HttpClient client = new HttpClient())
                {
                    await authenticationProvider.SetAccessTokenAsync(client);

                    foreach (var order in orders)
                    {
                        InvoiceProcessResource resource = Mappers.ToInvoiceProcess(order);

                        string res = await MiddlewareController.InsertInvoiceToIEAsync(client, resource);

                        MiddlewareResponse r = JsonSerializer.Deserialize <MiddlewareResponse>(res);

                        result.Add(r);
                    }
                }

                return(result);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
Example #3
0
        public static async Task <string> CreateInvoiceMiddlewareAsync(AuthenticationProvider authenticationProvider, OrderResource order)
        {
            try
            {
                // Converter objeto order para invoice
                InvoiceProcessResource resource = Mappers.ToInvoiceProcess(order);

                // Inserir invoice do IE

                return(await MiddlewareController.InsertInvoiceToIEAsync(authenticationProvider, resource).ConfigureAwait(false));
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
        private static async Task HandleExceptionAsync(HttpContext context, Exception exception)
        {
            MiddlewareController controller = new MiddlewareController();
            var    code = HttpStatusCode.BadRequest;
            string body = string.Empty;

            if (context.Response.HasStarted || context.Response.StatusCode >= 400 || context.Response.StatusCode <= 599 ||
                context.Response.ContentLength.HasValue || !string.IsNullOrEmpty(context.Response.ContentType))
            {
                body = UnitT.ReturnError(context.Request.Path.Value.ToLower(), context.Response.StatusCode.ToString(), exception);
                context.Items[SettingHelper.Re_ponse] = body;
                //Eric fix 20170928
                context.Response.ContentType = "application/json";
                context.Response.StatusCode  = (int)code;
                await controller.EnterInsertAsync(context, exception);

                await context.Response.WriteAsync(body);
            }
        }
 public FindingStatus()
 {
     InitializeComponent();
     start.Text      = thietlapHeSo.startdatetime;
     end.Text        = thietlapHeSo.enddatetime;
     colorgroup.Text = thietlapHeSo.n.ToString();
     totalcolor      = MiddlewareController.estimateTime(middle.getExcelCol(), thietlapHeSo.n);
     number1         = (decimal)totalcolor;
     totalcolor_old  = totalcolor;
     if (thietlapHeSo.limit.ToString() == "")
     {
         limitvalue.Text = "0";
     }
     else
     {
         limitvalue.Text = thietlapHeSo.limit.ToString();
     }
     timer1.Tick    += new EventHandler(timer1_Tick);
     timer1.Interval = 1000; // in miliseconds
     timer1.Start();
 }
Example #6
0
 public ValuesController(IHostingEnvironment env)
 {
     _myLog = new MiddlewareController();
     _env   = env;
 }
Example #7
0
 public ValuesController()
 {
     _myLog = new MiddlewareController();
 }