Esempio n. 1
0
        private void InsertProduct(ProductSync result)
        {
            if (result == null || result.ServerId == 0)
            {
                return;
            }

            if (App.LocalDb.Table <Product>().FirstOrDefault(ip => ip.ServerId == result.ServerId) is Product product)
            {
                //PropertyExtension.UpdateProperties(result, product, ExcludedUpdateProperties);
                product.UpdateFromSync(result);

                product.UserId = CurrentUser.Id;

                App.LocalDb.Update(product);
                totalRowUpdated++;
            }
            else
            {
                App.LocalDb.InsertOrReplace(new Product(result)
                {
                    UserId = CurrentUser.Id
                });
                totalRowInserted++;
            }
        }
Esempio n. 2
0
        public async Task AddProduct()
        {
            (var user, var listId) = await GetUserWithList();

            var newProduct = await ProductSync.AddNewProduct("0000000000000", "!!!TESTPRODUCT!!!");

            IsTrue(newProduct.Success);
        }
Esempio n. 3
0
        public async Task GetProductsByName()
        {
            (var user, var listId) = await GetUserWithList();

            var productsPage1 = await ProductSync.GetProducts("!!!TESTPRODUCT!!!", 1);

            IsTrue(productsPage1.Count > 0);

            var productsPage2 = await ProductSync.GetProducts("!!!TESTPRODUCT!!!", 2);

            AreNotEqual(productsPage1, productsPage2);
        }
Esempio n. 4
0
        public async Task GetProductByGtin()
        {
            (var user, var listId) = await GetUserWithList();

            var product = await ProductSync.GetProduct("0000000000000");

            IsNotNull(product);
            IsTrue(product.Success);

            AreEqual(product.Gtin, "0000000000000");
            AreEqual(product.Quantity, 123);
            AreEqual(product.Unit, "T");
            AreEqual(product.Name, "!!!TESTPRODUCT!!!");
        }
Esempio n. 5
0
        public async Task GetProductByGtin()
        {
            (var user, var listId) = await GetUserWithList();

            var product = await ProductSync.GetProduct("4018077669897");

            IsNotNull(product);
            IsTrue(product.Success);

            AreEqual(product.Gtin, "4018077669897");
            AreEqual(product.Quantity, 175);
            AreEqual(product.Unit, "g");
            AreEqual(product.Name, "Crunchips Western Style 175g");
        }
        public void OfflineSelected()
        {
            this.IsBusy   = true;
            this.BusyText = "正在下架选中的产品...";
            this.NotifyOfPropertyChange(() => this.IsBusy);
            this.NotifyOfPropertyChange(() => this.BusyText);
            var g = this.Products.Where(p => p.IsChecked).GroupBy(p => p.Account);

            Task.Factory.StartNew(() => {
                foreach (var gg in g)
                {
                    ProductSync.OfflineProducts(gg.Key, gg.Select(p => p.ProductID.ToString()).ToList());
                }

                this.Query();
            });
        }
        public ProductQueryViewModel()
        {
            this.Status   = Enum.GetValues(typeof(ProductStatus)).Cast <ProductStatus>().ToList();
            this.Accounts = AccountHelper.LoadAccounts().Select(a => a.User).ToList();
            this.Accounts.Insert(0, "");

            this.IsBusy   = true;
            this.BusyText = "正在加载产品分组...";
            this.NotifyOfPropertyChange(() => this.IsBusy);
            this.NotifyOfPropertyChange(() => this.BusyText);

            Task.Factory.StartNew(async() => {
                this.Groups = await ProductSync.QueryGroups();

                this.IsBusy = false;
                this.NotifyOfPropertyChange(() => this.IsBusy);
            });
        }
        private async Task Query(int?expiryDays)
        {
            this.IsBusy   = true;
            this.BusyText = "正在查询,请稍候...";
            this.NotifyOfPropertyChange(() => this.IsBusy);
            this.NotifyOfPropertyChange(() => this.BusyText);

            await Task.Factory.StartNew(async() => {
                var datas     = await ProductSync.Query(this.Subject, this.SelectedStatus, this.SelectedAccount, this.SelectedGroup, expiryDays);
                this.Products = new BindableCollection <CheckableSuccinctProduct>(
                    datas
                    .Select(p => new CheckableSuccinctProduct(p)));

                this.NotifyOfPropertyChange(() => this.Products);

                this.IsBusy = false;
                this.NotifyOfPropertyChange(() => this.IsBusy);
            });
        }
        public void ExtendExpiryDate()
        {
            this.IsBusy   = true;
            this.BusyText = "正在处理...";
            this.NotifyOfPropertyChange(() => this.IsBusy);
            this.NotifyOfPropertyChange(() => this.BusyText);
            var g     = this.Products.Where(p => p.IsChecked);
            var total = g.Count();

            Task.Factory.StartNew(() => {
                int i = 1;
                foreach (var gg in g)
                {
                    this.BusyText = string.Format("正在处理...{0} / {1}", i++, total);
                    this.NotifyOfPropertyChange(() => this.BusyText);
                    ProductSync.ExtendExpiryDate(gg.Account, gg.ProductID.ToString());
                }

                this.WillExpiry();
            });
        }
Esempio n. 10
0
        static async Task Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Please Enter at least 2 Folders");
            }
            var folderMain    = args[0];
            var updateFolders = new List <string>();

            for (var i = 1; i < args.Length; i++)
            {
                updateFolders.Add(args[i]);
            }

            //folderMain = @"";
            //updateFolders.Add(@"");
            //updateFolders.Add(@"");

            Console.WriteLine($"Using {folderMain} to Update {string.Join(',', updateFolders)}");
            Console.WriteLine("Press Y to Continue");
            var accept = Console.ReadKey();

            if (accept.Key == ConsoleKey.Y)
            {
                var mainApi = await ApiSync.Get(folderMain);

                var mainProduct = await ProductSync.GetProducts(folderMain);

                var mainRelease = await ApiReleaseSync.GetApiReleases(folderMain);

                var mainVersion = await ApiVersionSetSync.Get(folderMain);

                var mainTag = await TagSync.GetTags(folderMain);

                foreach (var f in updateFolders)
                {
                    Console.WriteLine($"Upating {f}");
                    Console.WriteLine("");

                    Console.WriteLine("Syncing Api");
                    var apiF1 = await ApiSync.Get(f);

                    await ApiSync.CompareAndSync(f, apiF1, folderMain, mainApi);

                    Console.WriteLine("Syncing Policy");
                    await PolicySync.CompareAndSyncAsync(f, folderMain);

                    Console.WriteLine("Syncing Products");
                    var productF1 = await ProductSync.GetProducts(f);

                    //await ApimUtils.CheckRefsAsync(mainProduct.Values.First(), folderMain);
                    await ProductSync.CompareAndSyncProducts(f, productF1, mainProduct);

                    Console.WriteLine("Syncing Api Releases");
                    var releaseF1 = await ApiReleaseSync.GetApiReleases(f);

                    await ApiReleaseSync.CompareAndSync(f, releaseF1, mainRelease);

                    Console.WriteLine("Syncing Api Versions");
                    var versionF1 = await ApiVersionSetSync.Get(f);

                    await ApiVersionSetSync.CompareAndSync(f, versionF1, mainVersion);

                    Console.WriteLine("Syncing Tags");
                    var TaqF1 = await TagSync.GetTags(f);

                    await TagSync.CompareAndSync(f, TaqF1, mainTag);
                }
            }
            else
            {
                Console.WriteLine("Sync Aborted");
            }
        }