public async void CheckWooStatus()
        {
            Waiting = true;
            StateHasChanged();
            WooAPISettings _WooAPISettings = new WooAPISettings(WooSettingsModel);
            //{
            //    ConsumerKey = WooSettingsModel.ConsumerKey,
            //    ConsumerSecret = WooSettingsModel.ConsumerSecret,
            //    QueryURL = WooSettingsModel.QueryURL,
            //    IsSecureURL = WooSettingsModel.IsSecureURL,
            //    JSONAPIPostFix = WooSettingsModel.JSONAPIPostFix,
            //    RootAPIPostFix = WooSettingsModel.RootAPIPostFix
            //};

            WooProduct _WooProducts = new WooProduct(_WooAPISettings, Logger);

            //int _count = await Task.Run(() => _WooProducts.GetProductCount());    //CheckProductLink())
            //WooStatus = ((_count > 0) ? $"Success - product count: {_count}" : "Failed");

            bool _success = await Task.Run(() => _WooProducts.CheckProductLink());   // GetProductCount());    //

            WooStatus = (_success ? $"Success" : "Failed");

            Waiting = false;
            StateHasChanged();
            ShowModalStatus.UpdateModalMessage($"Woo API call status: {Environment.NewLine}{Environment.NewLine}  {WooStatus}");
            ShowModalStatus.ShowModal();
        }
Ejemplo n.º 2
0
        public virtual async Task <bool> WooIsActiveAsync(ApplicationState currentApplicatioonState)
        {
            if (!currentApplicatioonState.HaveCheckState)
            {
                try
                {
                    WooAPISettings _wooAPISettings = await GetWooAPISettingsAsync();

                    if (_wooAPISettings == null)
                    {
                        currentApplicatioonState.SetWooIsActive(false);
                    }
                    else
                    {
                        WooProductCategory _wooProductCategory = new WooProductCategory(_wooAPISettings, _Logger);
                        if (_wooProductCategory == null)
                        {
                            currentApplicatioonState.SetWooIsActive(false);
                        }
                        else
                        {
                            currentApplicatioonState.SetWooIsActive(await _wooProductCategory.CheckProductCategoryLinkAsync());
                        }
                    }
                }
                catch (Exception ex)
                {
                    _Logger.LogError($"Error running async tasks: {ex.Message}");
                    throw;
                }
            }

            return(currentApplicatioonState.WooIsActive);
        }
Ejemplo n.º 3
0
        public WooProduct(WooAPISettings wooAPISettings, ILoggerManager logger)
        {
            _Woo = new WooBase(wooAPISettings, logger);

            //_WooAPISettings = wooAPISettings;
            // this._Logger = logger;
        }
        /// <summary>
        /// All the attribute import stuff. Could we have generalised this?
        /// </summary>
        #region AttrbiuteStuff

        // Retrieve data from Woo
        public async Task <List <ProductAttribute> > GetWooAttributeData()
        {
            WooAPISettings _WooAPISettings = new WooAPISettings(AppWooSettings);

            IWooProductAttribute    _WooProductAttribute = new WooProductAttribute(_WooAPISettings, _Logger);
            List <ProductAttribute> wooProductAttributes = await _WooProductAttribute.GetAllProductAttributes();

            return(wooProductAttributes);
        }
Ejemplo n.º 5
0
        private async Task <IWooProductCategory> GetIWooProductCategory()
        {
            //IAppRepository<WooSettings> _WooPrefs = _appUnitOfWork.Repository<WooSettings>();

            //WooSettings _wooSettings = await _WooPrefs.FindFirstAsync();
            //if (_wooSettings == null)
            //    return null;
            //WooAPISettings _wooAPISettings = new WooAPISettings(_wooSettings);
            WooAPISettings _wooAPISettings = await GetWooAPISettingsAsync();

            return(new WooProductCategory(_wooAPISettings, _Logger));
        }
Ejemplo n.º 6
0
        public WooBase(WooAPISettings wooAPISettings, ILoggerManager logger)
        {
            //while (wooAPISettings.QueryURL.EndsWith("/"))
            //    wooAPISettings.QueryURL.Remove(wooAPISettings.QueryURL.Length - 1);

            _WooAPISettings = wooAPISettings;
            //_RestAPI = new RestAPI(wooAPISettings.FullSourceURL + "/wp-json/wc/v3/",
            //    wooAPISettings.ConsumerKey,
            //    wooAPISettings.ConsumerSecret, !wooAPISettings.IsSecureURL);

            this._Logger = logger;
        }
        /// <summary>
        /// All the category import stuff. Could we have generalised this?
        /// </summary>

        /* Objective:
         *
         *  We create a list of item categories. From that list we need to create a list of primary categories. These are used in the items mapping. Only those that are imported can be used
         *  Mapping:
         *
         *  The Table WooCategoryMaps stores the category information.
         *
         *  Field	                                UsedFor
         *  WooCategoryID [int]	                    To store the CategoryID  that Woo returns
         *  WooCategoryName [string (size:2-255)]	To store Categories.name that Woo returns
         *  WooCategorySlug [string (size:2-255)]	To store Categories.slug that Woo returns
         *  WooCategoryParentID	                    Can be null if not will point to a WooCategoryID
         *  ItemCategoryLookupID	                        This links to the Category in the system. Allows us to transfer the data.
         *
         *  Item categories Should be linked to tracking so items in similar categories are tracked similarly.
         */
        // Retrieve data from Woo
        public async Task <List <ProductCategory> > GetWooCategoryData()
        {
            WooAPISettings _wooAPISettings = new WooAPISettings(AppWooSettings);


            IWooProductCategory _WooProductCategory = new WooProductCategory(_wooAPISettings, _Logger);

            //List<ProductCategory> wooProductCategories = await _WooProductCategory.GetAllProductCategories();
            return(await _WooProductCategory.GetAllProductCategoriesAsync());

            //return wooProductCategories;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// All the attribute term import stuff. Attributes Terms in Woo are Attributed Varieties to us. Could we have generalised this for each item import with an object?
        /// </summary>
        #region AttrbiuteStuff

        // Retrieve data from Woo
        async Task <List <Product> > GetAllWooProducts(bool OnlyItemsInStock)
        {
            WooAPISettings _wooAPISettings = new WooAPISettings(AppWooSettings);

            WooProduct     _wooProduct = new WooProduct(_wooAPISettings, _Logger);
            List <Product> wooProducts = OnlyItemsInStock ?
                                         await _wooProduct.GetAllProductsInStock() :
                                         await _wooProduct.GetAllProducts();


            // unique check not needed
            //  var _wooProducts = wooProducts.GroupBy(wp => wp.id).Select(wp => wp.FirstOrDefault()); // wooProducts that are distinct;
            //  wooProducts = _wooProducts.ToList();
            return(wooProducts);
        }
        /// <summary>
        /// All the attribute term import stuff. Attributes Terms in Woo are Attributed Varieties to us. Could we have generalised this for each item import with an object?
        /// </summary>
        #region AttrbiuteStuff

        // Retrieve data from Woo
        async Task <List <ProductAttributeTerm> > GetWooAttributeTermData(ProductAttribute currProductAttribute)
        {
            WooAPISettings _wooAPISettings = new WooAPISettings(AppWooSettings);
            //
            //    ConsumerKey = WooSettingsModel.ConsumerKey,
            //    ConsumerSecret = WooSettingsModel.ConsumerSecret,
            //    QueryURL = WooSettingsModel.QueryURL,
            //    IsSecureURL = WooSettingsModel.IsSecureURL,
            //    JSONAPIPostFix = WooSettingsModel.JSONAPIPostFix,
            //    RootAPIPostFix = WooSettingsModel.RootAPIPostFix
            //};

            IWooProductAttributeTerm    _WooProductAttributeTerm = new WooProductAttributeTerm(_wooAPISettings, _Logger);
            List <ProductAttributeTerm> wooProductAttributeTerms = await _WooProductAttributeTerm.GetAttributeTermsByAtttribute(currProductAttribute);

            return(wooProductAttributeTerms);
        }
Ejemplo n.º 10
0
 public WooProductAttribute(WooAPISettings wooAPISettings, ILoggerManager logger)
 {
     _Woo = new WooBase(wooAPISettings, logger);
 }
        private async Task <IWooProduct> GetIWooProduct()
        {
            WooAPISettings _wooAPISettings = await GetWooAPISettingsAsync();

            return(new WooProduct(_wooAPISettings, _Logger));
        }
        private async Task <IWooProductAttributeTerm> GetIWooProductAttributeTerm()
        {
            WooAPISettings _wooAPISettings = await GetWooAPISettingsAsync();

            return(new WooProductAttributeTerm(_wooAPISettings, _Logger));
        }