Exemplo n.º 1
0
        protected void DoExport(object objConfiguration)
        {
            try
            {
                var conf = objConfiguration as ExportConfiguration;

                HccRequestContext.Current = conf.HccRequestContext;
                DnnGlobal.SetPortalSettings(conf.DnnPortalSettings);
                Factory.HttpContext = conf.HttpContext;
                CultureSwitch.SetCulture(HccApp.CurrentStore, conf.DnnPortalSettings);

                var products = HccApp.CatalogServices.Products.FindByCriteria(conf.Criteria, 1, int.MaxValue,
                                                                              ref RowCount, false);

                var export   = new CatalogExport(HccApp);
                var fileName = string.Format("Hotcakes_Products_{0}_{1:yyyyMMddhhMMss}.xlsx", HccApp.CurrentCustomerId,
                                             DateTime.UtcNow);
                var filePath = DiskStorage.GetStoreDataPhysicalPath(HccApp.CurrentStore.Id, "Exports/" + fileName);
                export.ExportToExcel(products, filePath);

                var pageLink    = DiskStorage.GetHccAdminUrl(HccApp, "catalog/default.aspx", false);
                var mailMessage = new MailMessage(conf.DnnPortalSettings.Email, HccApp.CurrentCustomer.Email);
                mailMessage.IsBodyHtml = true;
                mailMessage.Body       = Localization.GetFormattedString("ExportProductsMailBody", pageLink);
                mailMessage.Subject    = Localization.GetString("ExportProductsMailSubject");
                MailServices.SendMail(mailMessage, HccApp.CurrentStore);
            }
            catch (Exception ex)
            {
                EventLog.LogEvent(ex);
            }
        }
        /// <summary>
        ///     Creates and configures hotcakes store from config file.
        /// </summary>
        /// <exception cref="CreateStoreException">Could not create store</exception>
        private void InstallApplication()
        {
            var intallFolderPath = "~/DesktopModules/Hotcakes/Core/Install/";
            var configPath       = HttpContext.Current.Server.MapPath(intallFolderPath + "Hotcakes.install.config");

            if (File.Exists(configPath))
            {
                // hardcoded for now since we create only one store now
                var portalId       = 0;
                var portalSettings = new PortalSettings(portalId);
                DnnGlobal.SetPortalSettings(portalSettings);

                var productsFile = HttpContext.Current.Server.MapPath(intallFolderPath + "Products.xlsx");

                var hccApp = HotcakesApplication.Current;

                var store = hccApp.AccountServices.CreateAndSetupStore();
                if (store == null)
                {
                    throw new CreateStoreException("Could not create store");
                }

                var config = GetStoreConfig(configPath);

                store.StoreName = config.StoreName;
                foreach (var settingConfig in config.Settings)
                {
                    store.Settings.AddOrUpdateLocalSetting(new StoreSetting
                    {
                        SettingName  = settingConfig.Name,
                        SettingValue = settingConfig.Value
                    });
                }

                hccApp.CurrentStore = store;
                hccApp.UpdateCurrentStore();

                hccApp.AccountServices.Stores.SetLastOrderNumber(store.Id, config.LastOrderNumber);

                var systemColumnsFilePath =
                    "~/DesktopModules/Hotcakes/Core/Admin/Parts/ContentBlocks/SystemColumnsData.xml";
                hccApp.ContentServices.Columns.CreateFromTemplateFile(systemColumnsFilePath);

                hccApp.OrderServices.EnsureDefaultZones(store.Id);

                var urlSettings = hccApp.CurrentStore.Settings.Urls;
                PageUtils.EnsureTabsExist(urlSettings);
                hccApp.UpdateCurrentStore();

                var catImport = new CatalogImport(hccApp)
                {
                    ImagesImportPath = intallFolderPath + "Images/"
                };
                catImport.ImportFromExcel(productsFile, (p, l) => { });

                Directory.Delete(HttpContext.Current.Server.MapPath(intallFolderPath), true);

                DnnGlobal.SetPortalSettings(null);
            }
        }
Exemplo n.º 3
0
        public void Affiliate_CanAddAffiliateWithExistedUser()
        {
            using (ShimsContext.Create())
            {
                InitShims();
                var users      = new List <UserInfo>();
                var dnnUserCtl = GetStubIUserController(users);
                DnnGlobal.SetTestableInstance(GetStubIDnnGlobal());
                DnnUserController.SetTestableInstance(dnnUserCtl);
                users.Add(dnnUserCtl.BuildUserInfo(
                              "user1", "User", "First", "email@test",
                              "12345", DnnGlobal.Instance.GetPortalId()));

                var hccApp = CreateHccAppInMemory();
                var target = hccApp.ContactServices.Affiliates;

                var expected = new Affiliate
                {
                    AffiliateId = "001",
                    UserId      = users[0].UserID,
                    TaxId       = "123",
                    Username    = "******"
                };

                var status = CreateUserStatus.None;
                var res    = target.Create(expected, ref status);
                var actual = target.FindAllPaged(1, 1).First();

                Assert.AreEqual(1, target.CountOfAll());
                Assert.AreEqual(expected.TaxId, actual.TaxId);
                Assert.AreEqual(expected.Username, actual.Username);
                Assert.AreEqual(1, users.Count);
            }
        }
Exemplo n.º 4
0
        public void TestInOrder()
        {
            using (ShimsContext.Create())
            {
                DnnGlobal.SetTestableInstance(GetStubIDnnGlobal());
                DnnUserController.SetTestableInstance(GetStubIUserController(new List <UserInfo>()));

                CreateDefaultStore();
                StoreUrls();
                EnsureStore();
            }
        }
        protected void DoImport(object objConfiguration)
        {
            var conf = objConfiguration as ImportConfiguration;

            HccRequestContext.Current = conf.HccRequestContext;
            DnnGlobal.SetPortalSettings(conf.DnnPortalSettings);
            Factory.HttpContext = conf.HttpContext;
            CultureSwitch.SetCulture(HccApp.CurrentStore, conf.DnnPortalSettings);

            var manager = new SessionManager(conf.Session);

            manager.AdminProductImportLog      = null;
            manager.AdminProductImportProgress = 0;

            var catImport = new CatalogImport(HccApp);

            catImport.UpdateExistingProducts = chkImportOverride.Checked;

            // added import path so version 2.xx knows where import images are stored
            catImport.ImagesImportPath = string.Format("~/Portals/{0}/Hotcakes/Data/import/", conf.DnnPortalSettings.PortalId);

            catImport.ImportFromExcel(TempFilePath, (p, l) =>
            {
                lock (manager.AdminProductImportLog)
                {
                    manager.AdminProductImportProgress = Math.Round(p * 100);

                    if (!string.IsNullOrEmpty(l))
                    {
                        var log = manager.AdminProductImportLog;
                        log.Add(l);
                        manager.AdminProductImportLog = log;
                    }
                }
            });
        }
Exemplo n.º 6
0
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //

        #endregion

        public void InitBasicStubs()
        {
            DnnGlobal.SetTestableInstance(GetStubIDnnGlobal());
            DnnUserController.SetTestableInstance(GetStubIUserController(new List <UserInfo>()));
        }