コード例 #1
0
        public IActionResult Configure(KachingConfigurationModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            try
            {
                _kachingSettings.POSKaChingActive          = model.POSKaChingActive;
                _kachingSettings.POSKaChingHost            = model.POSKaChingHost;
                _kachingSettings.POSKaChingId              = model.POSKaChingId;
                _kachingSettings.POSKaChingAccountToken    = model.POSKaChingAccountToken;
                _kachingSettings.POSKaChingAPIToken        = model.POSKaChingAPIToken;
                _kachingSettings.POSKaChingImportQueueName = model.POSKaChingImportQueueName;

                _settingService.SaveSetting(_kachingSettings);
            }
            catch (Exception ex)
            {
                Exception inner = ex;
                while (inner.InnerException != null)
                {
                    inner = inner.InnerException;
                }
                _logger.Error("Configure POS Kaching: " + inner.Message, ex);
                model.ErrorMessage += "<br />" + inner.Message;
            }
            return(Configure());
        }
コード例 #2
0
        public IActionResult TestConnection()
        {
            KachingConfigurationModel model = GetBaseModel();

            try
            {
                POSKachingService service = new POSKachingService(_logger, _kachingSettings, _settingService, _pictureService, _productAttributeService);

                if (service.TestConnection())
                {
                    model.KachingAliveValue = "Kaching is alive";
                }
                else
                {
                    model.KachingIsDead = "Kaching is dead";
                }
            }
            catch (Exception ex)
            {
                Exception inner = ex;
                while (inner.InnerException != null)
                {
                    inner = inner.InnerException;
                }
                _logger.Error("Configure POS Kaching: " + inner.Message, ex);
                model.ErrorMessage += "<br />" + inner.Message;
            }

            return(View("~/Plugins/Nop.Plugin.POS.Kaching/Views/Configure.cshtml", model));
        }
コード例 #3
0
        public IActionResult SendAllProducts()
        {
            KachingConfigurationModel model = GetBaseModel();

            if (this._kachingSettings.POSKaChingActive)
            {
                IPagedList <Core.Domain.Catalog.Product> products = _productService.SearchProducts();
                int count = 0;
                foreach (Core.Domain.Catalog.Product product in products)
                {
                    try
                    {
                        POSKachingService service = new POSKachingService(_logger, _kachingSettings, _settingService, _pictureService, _productAttributeService);
                        var json = service.BuildJSONString(product);

                        service.SaveProduct(json);
                        count++;
                    }
                    catch (Exception ex)
                    {
                        Exception inner = ex;
                        while (inner.InnerException != null)
                        {
                            inner = inner.InnerException;
                        }
                        _logger.Error("Configure POS Kaching: " + inner.Message, ex);
                        model.ErrorMessage += "<br />" + inner.Message;
                    }
                }

                if (count > 0)
                {
                    model.ProductsTransferred = "Products transferred: " + count;
                }
            }
            else
            {
                model.ErrorMessage = "Kaching is not active";
            }

            return(View("~/Plugins/Nop.Plugin.POS.Kaching/Views/Configure.cshtml", model));
        }
コード例 #4
0
        public IActionResult Configure()
        {
            KachingConfigurationModel model = null;

            try
            {
                model = GetBaseModel();
            }
            catch (Exception ex)
            {
                Exception inner = ex;
                while (inner.InnerException != null)
                {
                    inner = inner.InnerException;
                }
                _logger.Error("Configure POS Kaching: " + inner.Message, ex);
                model.ErrorMessage += "<br />" + inner.Message;
            }
            return(View("~/Plugins/Nop.Plugin.POS.Kaching/Views/Configure.cshtml", model));
        }