Exemple #1
0
        public void UpdateStock(Item[] itemArray, CommandItem commandItem, ScheduleItem scheduleItem)
        {
            var repository = Sitecore.Ecommerce.Context.Entity.Resolve <IProductRepository>();
            var schedule   = new ActiveCommerce.SitecoreX.ScheduledTasks.ExtendedScheduleItem(scheduleItem);
            var file       = schedule.Arguments["file"];


            using (new SecurityDisabler())
            {
                using (new ShopContextSwitcher(schedule.SiteContext, schedule.Database))
                {
                    Sitecore.Diagnostics.Log.Info("Executing import...", this);

                    var stockManager = Sitecore.Ecommerce.Context.Entity.Resolve <IProductStockManager>();
                    var xml          = XElement.Load(Sitecore.IO.FileUtil.MapPath(file));
                    var books        = xml.Descendants("book");
                    foreach (var book in books)
                    {
                        long stock = Int64.Parse(book.Element("stock").Value);
                        stockManager.Update(new ProductStockInfo
                        {
                            ProductCode = book.Attribute("id").Value
                        }, stock);
                    }
                }
            }
        }
Exemple #2
0
        public void ExportOrders(Item[] itemArray, CommandItem commandItem, ScheduleItem scheduleItem)
        {
            Sitecore.Diagnostics.Log.Info("Starting export...", this);
            var schedule = new ActiveCommerce.SitecoreX.ScheduledTasks.ExtendedScheduleItem(scheduleItem);

            using (new ShopContextSwitcher(schedule.SiteContext, schedule.Database))
            {
                var startStatus = schedule.Arguments["startStatus"];
                var endStatus   = schedule.Arguments["endStatus"];
                DoExport(startStatus, endStatus);
            }
        }
Exemple #3
0
        public void ImportProducts(Item[] itemArray, CommandItem commandItem, ScheduleItem scheduleItem)
        {
            Sitecore.Diagnostics.Log.Info("Starting import...", this);

            //be sure to populate these values on your schedule item
            var schedule   = new ActiveCommerce.SitecoreX.ScheduledTasks.ExtendedScheduleItem(scheduleItem);
            var file       = schedule.Arguments["file"];
            var path       = schedule.Arguments["path"];
            var templateId = schedule.Arguments["templateId"];

            using (new SecurityDisabler())
            {
                using (new ShopContextSwitcher(schedule.SiteContext, schedule.Database))
                {
                    Sitecore.Diagnostics.Log.Info("Executing import...", this);
                    DoImport(file, path, templateId);
                }
            }
        }
Exemple #4
0
        public void UpdateOrders(Item[] itemArray, CommandItem commandItem, ScheduleItem scheduleItem)
        {
            Sitecore.Diagnostics.Log.Info("Starting update...", this);
            var schedule = new ActiveCommerce.SitecoreX.ScheduledTasks.ExtendedScheduleItem(scheduleItem);

            using (new SecurityDisabler())
            {
                using (new ShopContextSwitcher(schedule.SiteContext, schedule.Database))
                {
                    //otherwise, if we have a preview cookie in place, we can't get to the orders root item
                    using (new ItemFilteringDisabler())
                    {
                        var startStatus = schedule.Arguments["startStatus"];

                        //to get an appropriately typed OrderStatus, to set on an order
                        var endStatus = Sitecore.Ecommerce.Context.Entity.Resolve <OrderStatus>(schedule.Arguments["endStatus"]);

                        DoUpdate(startStatus, endStatus);
                    }
                }
            }
        }