Ejemplo n.º 1
0
        private static void ThreadStart()
        {
            int maxIteration = 1;
            int count        = 1;

            while (count <= maxIteration)
            {
                using (Domain.ApplicationContext context = new Domain.ApplicationContext())
                {
                    Good good = context.Goods.FirstOrDefault(g => !g.IsBusy && !String.IsNullOrEmpty(g.ProductDetailUrl));
                    good.IsBusy = true;
                    context.SaveChanges();

                    try
                    {
                        Service.Web.Methods.PopulateGoodBrowser(context, good);
                    }
                    //catch (Exception ex) { }
                    finally
                    {
                        good.IsBusy = false;
                        context.SaveChanges();
                    }
                }
                count++;
            }
        }
Ejemplo n.º 2
0
        private async void timer3_Tick(object sender, EventArgs e)
        {
            if (countTimer3Iteration != 0)
            {
                labelControl6.Text = "В работе:" + countTimer3Iteration;
            }
            if (countTimer3Iteration > 10)
            {
                return;
            }

            using (Domain.ApplicationContext context = new Domain.ApplicationContext())
            {
                //SystemSetting systemSetting = context.SystemSettings.FirstOrDefault();

                Good good = context.Goods.OrderBy(g => g.Manufacturer.Id).FirstOrDefault(g => !g.IsBusy && !g.IsWebDownloaded);
                try
                {
                    if (good != null)
                    {
                        countTimer3Iteration++;

                        good.IsBusy = true;
                        context.SaveChanges();

                        //if (systemSetting == null)
                        //{
                        //    context.SystemSettings.Add(new SystemSetting { ApiScrapperCountRequests = 1 });
                        //}
                        //else
                        //{
                        //    systemSetting.ApiScrapperCountRequests++;
                        //}
                        await Service.Api.Methods.GetFromWebAsync(context, good);
                    }
                }
                finally
                {
                    countTimer3Iteration--;
                    good.IsBusy = false;
                    await context.SaveChangesAsync();
                }
            }
        }