private void lnkExport_Click(object sender, EventArgs e) { var criteria = ucSimpleProductFilter.LoadProductCriteria(); criteria.DisplayInactiveProducts = true; var productsCount = HccApp.CatalogServices.Products.FindCountByCriteria(criteria); if (productsCount < 250) { var products = HccApp.CatalogServices.Products.FindByCriteria(criteria, 1, int.MaxValue, ref RowCount, false); var export = new CatalogExport(HccApp); export.ExportToExcel(products, "Hotcakes_Products.xlsx", Response); } else { var asyncTask = Task.Factory.StartNew( DoExport, new ExportConfiguration { HccRequestContext = HccRequestContext.Current, HttpContext = Context, DnnPortalSettings = PortalSettings.Current, Criteria = criteria }); ucMessageBox.ShowInformation(Localization.GetString("ExportInProgress")); } }
private Export CreateExport(ComposablePartDefinition partDefinition, ExportDefinition exportDefinition, ImportDefinition importDefinition) { CreationPolicy importPolicy = importDefinition.GetRequiredCreationPolicy(); return(CatalogExport.CreateExport(this, partDefinition, exportDefinition, importPolicy)); }
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); } }
private Export CreateExport(ComposablePartDefinition partDefinition, ExportDefinition exportDefinition, bool isExportFactory, CreationPolicy importPolicy) { if (isExportFactory) { return(new PartCreatorExport(this, partDefinition, exportDefinition)); } else { return(CatalogExport.CreateExport(this, partDefinition, exportDefinition, importPolicy)); } }
/// <summary> /// Returns all exports that match the conditions of the specified import. /// </summary> /// <param name="definition">The <see cref="ImportDefinition"/> that defines the conditions of the /// <see cref="Export"/> to get.</param> /// <returns></returns> /// <result> /// An <see cref="IEnumerable{T}"/> of <see cref="Export"/> objects that match /// the conditions defined by <see cref="ImportDefinition"/>, if found; otherwise, an /// empty <see cref="IEnumerable{T}"/>. /// </result> /// <remarks> /// <note type="inheritinfo"> /// The implementers should not treat the cardinality-related mismatches as errors, and are not /// expected to throw exceptions in those cases. /// For instance, if the import requests exactly one export and the provider has no matching exports or more than one, /// it should return an empty <see cref="IEnumerable{T}"/> of <see cref="Export"/>. /// </note> /// </remarks> protected override IEnumerable <Export> GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition) { this.ThrowIfDisposed(); this.EnsureRunning(); // Use the version of the catalog appropriate to this atomicComposition ComposablePartCatalog currentCatalog = atomicComposition.GetValueAllowNull(this._catalog); #if SILVERLIGHT IPartCreatorImportDefinition partCreatorDefinition = definition as IPartCreatorImportDefinition; bool isPartCreator = false; if (partCreatorDefinition != null) { definition = partCreatorDefinition.ProductImportDefinition; isPartCreator = true; } #endif CreationPolicy importPolicy = definition.GetRequiredCreationPolicy(); List <Export> exports = new List <Export>(); foreach (var partDefinitionAndExportDefinition in currentCatalog.GetExports(definition)) { if (!IsRejected(partDefinitionAndExportDefinition.Item1, atomicComposition)) { #if SILVERLIGHT if (isPartCreator) { exports.Add(new PartCreatorExport(this, partDefinitionAndExportDefinition.Item1, partDefinitionAndExportDefinition.Item2)); } else #endif { exports.Add(CatalogExport.CreateExport(this, partDefinitionAndExportDefinition.Item1, partDefinitionAndExportDefinition.Item2, importPolicy)); } } } return(exports); }