コード例 #1
0
        public static void perform(string url = "/activities/memberships")
        {
            String  successRecords = "";
            dynamic memberships    = DownStream.syncMemberships(url);

            foreach (var membership in memberships)
            {
                try
                {
                    var response = ActionPerform.perform(membership, membership.action);
                    if (response)
                    {
                        successRecords += membership.log_id + ",";
                    }
                    else
                    {
                        Console.WriteLine("Unable to create membership");
                    }
                }
                catch (MySqlException e)
                {
                    if (e.Number == 1062)
                    {
                        successRecords += membership.log_id + ",";
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex.Message.ToString());
                }
            }
            UpStream.webAcknowledgement(successRecords);
        }
コード例 #2
0
ファイル: CustomerService.cs プロジェクト: nazrulcse/epose
        public static void perform(string url = "activities/customers")
        {
            String  successRecords = "";
            dynamic customers      = DownStream.syncCustomer(url);

            foreach (var customer in customers)
            {
                try
                {
                    var response = ActionPerform.perform(customer, customer.action);
                    if (response)
                    {
                        successRecords += customer.log_id + "";
                    }
                    else
                    {
                        Console.WriteLine("Unable to create department");
                    }
                }
                catch (MySqlException e)
                {
                    if (e.Number == 1062)
                    {
                        successRecords += customer.log_id + "";
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex.Message.ToString());
                }
            }
            UpStream.webAcknowledgement(successRecords);
        }
コード例 #3
0
        public static void perform(string url = "activities/employees")
        {
            String  successRecords = "";
            dynamic employees      = DownStream.syncEmployee(url);

            foreach (var employee in employees)
            {
                try
                {
                    var response = ActionPerform.perform(employee, employee.action);
                    if (response)
                    {
                        successRecords += employee.log_id + ",";
                    }
                    else
                    {
                        Console.WriteLine("Unable to create employee");
                    }
                }
                catch (MySqlException e)
                {
                    if (e.Number == 1062)
                    {
                        successRecords += employee.log_id + ",";
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex.Message.ToString());
                }
            }
            UpStream.webAcknowledgement(successRecords);
        }
コード例 #4
0
ファイル: Invoice_Frame.cs プロジェクト: nazrulcse/epose
 public void createInvoice()
 {
     try
     {
         UpStream.perform();
         this.inv = new InvoiceModel();
         var ms = (DateTime.Now - DateTime.MinValue).TotalMilliseconds * 10;
         inv.id            = ms.ToString();
         inv.number        = "IN" + ms.ToString();
         inv.date          = DateTime.Now.ToString("yyyy-MM-dd");
         inv.department_id = DepartmentSettings.DepartmentId;
         inv.till_id       = DepartmentSettings.TillId;
         inv.barcode       = inv.number;
         dynamic invoice = inv.create(inv);
         if (invoice != null)
         {
             ActivityLogModel.track("invoice", "create", this.inv.id);
             invoiceNumber.Text = "" + invoice.number;
         }
         else
         {
             invoiceNumber.Text = "Unable to create Invoice";
         }
     }
     catch (Exception ex)
     {
         invoiceNumber.Text = "Error: " + ex.Message.ToString();
     }
 }
コード例 #5
0
ファイル: UpStreamApi.cs プロジェクト: jangocheng/Kong.Net-1
 /// <summary>
 ///  Update Upstream Associated to a Specific Target
 /// </summary>
 /// <param name="target">{target host:port or id}</param>
 /// <param name="upstream"></param>
 /// <returns></returns>
 public async Task <UpStream> Update(string target, UpStream upstream)
 {
     throw new NotImplementedException();
     //var path = string.Format("{0}/{1}/upstream", RESTfulPath.TARGETS, target);
     //var result = await RequestAPI<UpStream>(RequestMethod.Patch, path, upstream);
     //return result;
 }
コード例 #6
0
ファイル: UpStreamApi.cs プロジェクト: jangocheng/Kong.Net-1
        /// <summary>
        /// Update Upstream
        /// </summary>
        /// <param name="upstream"></param>
        /// <returns></returns>
        public async Task <UpStream> Update(UpStream upstream)
        {
            var path   = string.Format("{0}/{1}", RESTfulPath.UPSTREAMS, upstream.Name);
            var result = await RequestAPI <UpStream>(RequestMethod.Patch, path, upstream);

            return(result);
        }
コード例 #7
0
ファイル: UpStreamApi.cs プロジェクト: jangocheng/Kong.Net-1
        /// <summary>
        /// Update Or Create Upstream
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public async Task <UpStream> UpdateOrCreate(UpStream options)
        {
            var path   = string.Format("{0}/{1}", RESTfulPath.UPSTREAMS, options.Name);
            var result = await RequestAPI <UpStream>(RequestMethod.Put, path, options);

            return(result);
        }
コード例 #8
0
        public async Task UpdateOrCreateByTarget()
        {
            UpStream upstream = Create();

            upstream = await client.UpStream.UpdateOrCreate("172.16.10.227:80", upstream);

            Assert.NotNull(upstream);
        }
コード例 #9
0
        public async Task UpdateOrCreate()
        {
            UpStream upstream = Create();

            upstream = await client.UpStream.UpdateOrCreate(upstream);

            Assert.NotNull(upstream);
        }
コード例 #10
0
        public async Task UpdateTarget()
        {
            UpStream upstream = Create();

            upstream = await client.UpStream.Update(TestCases.TARGET, upstream);

            Assert.NotNull(upstream);
        }
コード例 #11
0
ファイル: UpStreamApi.cs プロジェクト: zx972243884/Kong.Net
        /// <summary>
        ///  Update Upstream Associated to a Specific Target
        /// </summary>
        /// <param name="target">{target host:port or id}</param>
        /// <param name="upstream"></param>
        /// <returns></returns>
#pragma warning disable CS1998 // 此异步方法缺少 "await" 运算符,将以同步方式运行。请考虑使用 "await" 运算符等待非阻止的 API 调用,或者使用 "await Task.Run(...)" 在后台线程上执行占用大量 CPU 的工作。
        public async Task <UpStream> Update(string target, UpStream upstream)
#pragma warning restore CS1998 // 此异步方法缺少 "await" 运算符,将以同步方式运行。请考虑使用 "await" 运算符等待非阻止的 API 调用,或者使用 "await Task.Run(...)" 在后台线程上执行占用大量 CPU 的工作。
        {
            throw new NotImplementedException();
            //var path = string.Format("{0}/{1}/upstream", RESTfulPath.TARGETS, target);
            //var result = await RequestAPI<UpStream>(RequestMethod.Patch, path, upstream);
            //return result;
        }
コード例 #12
0
        public async Task Update()
        {
            UpStream upstream = Create();

            upstream.Id = TestCases.UPSTREAM_ID;
            upstream    = await client.UpStream.Update(upstream);

            Assert.NotNull(upstream);
        }
コード例 #13
0
        public async Task Add()
        {
            UpStream upstream = Create();

            upstream.Name = "Test-" + upstream.Id.Value.ToString("N");
            upstream      = await client.UpStream.Add(upstream);

            Assert.NotNull(upstream);
        }
コード例 #14
0
ファイル: ProductService.cs プロジェクト: nazrulcse/epose
        public static void perform(string url = "activities/products")
        {
            String  successRecords = "";
            dynamic products       = DownStream.syncProduct(url);

            Console.WriteLine("" + products);
            foreach (var product in products)
            {
                try
                {
                    var response = ActionPerform.perform(product, product.action);
                    if (response)
                    {
                        successRecords += product.log_id + ",";
                    }
                    else
                    {
                        Console.WriteLine("Unable to create department");
                    }
                }
                catch (MySqlException e)
                {
                    if (e.Number == 1062)
                    {
                        successRecords += product.log_id + ",";
                    }
                    else
                    {
                        MessageDialog.ShowAlert("Error: " + e.Message.ToString());
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex.Message.ToString());
                }
            }
            UpStream.webAcknowledgement(successRecords);
        }
コード例 #15
0
        /// <summary>
        /// Adds Kong Client to the Kong Gateway UpStreams And HealthChecks Registration
        /// </summary>
        /// <param name="app"></param>
        /// <param name="client"></param>
        /// <param name="upStream"></param>
        /// <param name="target"></param>
        /// <param name="onExecuter">The parameter allow you custom healthchecks response</param>
        /// <returns></returns>
        public static IApplicationBuilder UseKong(this IApplicationBuilder app, KongClient client, UpStream upStream, TargetInfo target, Action <HttpContext> onExecuter)
        {
            if (upStream == null)
            {
                throw new ArgumentNullException(nameof(upStream));
            }
            if (target == null || string.IsNullOrEmpty(target.Target))
            {
                throw new ArgumentNullException(nameof(target));
            }

            upStream.Id         = Guid.NewGuid();
            upStream.Created_at = DateTime.Now;
            upStream            = client.UpStream.UpdateOrCreate(upStream).GetAwaiter().GetResult();
            target.Id           = Guid.NewGuid();
            target.Created_at   = DateTime.Now;
            target.UpStream     = new TargetInfo.UpStreamId {
                Id = upStream.Id.Value
            };
            target = client.Target.Add(target).GetAwaiter().GetResult();

            app.UseKongHealthChecks(upStream, onExecuter);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("{0} UpStream registration completed!", upStream.Name);
            Console.WriteLine("The target is {0}", target.Target);
            Console.ForegroundColor = ConsoleColor.Gray;

            return(app);
        }
コード例 #16
0
 /// <summary>
 /// Adds Kong Client to the Kong Gateway UpStreams And HealthChecks Registration
 /// </summary>
 /// <param name="app"></param>
 /// <param name="client"></param>
 /// <param name="upStream"></param>
 /// <param name="target"></param>
 /// <returns></returns>
 public static IApplicationBuilder UseKong(this IApplicationBuilder app, KongClient client, UpStream upStream, TargetInfo target)
 {
     return(app.UseKong(client, upStream, target, null));
 }
コード例 #17
0
ファイル: UpStreamApi.cs プロジェクト: jangocheng/Kong.Net-1
        /// <summary>
        /// Add Upstream
        /// </summary>
        /// <param name="upstream"></param>
        /// <returns></returns>
        public async Task <UpStream> Add(UpStream upstream)
        {
            var result = await RequestAPI <UpStream>(RequestMethod.Post, RESTfulPath.UPSTREAMS, upstream);

            return(result);
        }
コード例 #18
0
ファイル: Invoice_Frame.cs プロジェクト: nazrulcse/epose
 public void paymentCompleted()
 {
     updateInvoice();
     UpStream.perform();
 }
コード例 #19
0
        private static IApplicationBuilder UseKongHealthChecks(this IApplicationBuilder app, UpStream upStream, Action <HttpContext> onExecuter)
        {
            app.Map(upStream.HealthChecks.Active.Http_path, s =>
            {
                s.Run(async context =>
                {
                    if (onExecuter != null)
                    {
                        onExecuter(context);
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Blue;
                        Console.WriteLine("Healthchecks at: {0}", DateTime.Now);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        await context.Response.WriteAsync("ok");
                    }
                });
            });

            return(app);
        }