예제 #1
0
    protected void uxGenerateButton_Click(object sender, EventArgs e)
    {
        uxMessage.Clear();

        uxExportFilter.GetSearchFilterObj(e);

        int             howMayItems;
        int             count   = DataAccessContext.ProductRepository.GetAllProductCount();
        Culture         culture = DataAccessContext.CultureRepository.GetOne(uxLanguageDrop.SelectedValue.ToString());
        string          storeID = uxStoreDrop.SelectedValue.ToString();
        IList <Product> list    = DataAccessContext.ProductRepository.SearchProduct(
            culture, "", uxSortByDrop.SelectedValue.ToString(), uxExportFilter.SearchFilterObj,
            0, count, out howMayItems, storeID, DataAccessContext.Configurations.GetValue("RootCategory", DataAccessContext.StoreRepository.GetOne(storeID)));

        if (list.Count > 0)
        {
            ProductExporter exporter  = new ProductExporter();
            MemoryStream    memStream = exporter.ExportToStream(list, culture, storeID);
            Exception       ex;
            WebUtilities.CreateExportFile(System.Web.HttpContext.Current.ApplicationInstance, memStream, "ExportProduct.csv", out ex);
            if (ex != null)
            {
                uxMessage.DisplayError(Resources.ExportDataMessage.Error + ex.GetType().ToString());
            }
        }
        else
        {
            uxMessage.DisplayError(Resources.ExportDataMessage.CannotFindData);
        }
    }
예제 #2
0
        /// <summary>
        /// returns serialized xml string
        /// </summary>
        /// <param name="data"></param>
        /// <param name="exportType"></param>
        /// <returns></returns>
        private string GetSerializedData(ref string data, ExportType exportType, ICollection <IntegrationSetting> integrationSettings)
        {
            string xml = string.Empty;

            switch (exportType)
            {
            case ExportType.Product:
                var productRoot     = JsonConvert.DeserializeObject <ProductRoot>(data);
                var productExporter = new ProductExporter(productRoot, integrationSettings);
                xml = productExporter.ExportData();
                break;

            case ExportType.Category:
                var categoryRoot     = JsonConvert.DeserializeObject <List <Category> >(data);
                var categoryExporter = new CategoryExporter(categoryRoot);
                xml = categoryExporter.ExportData();
                break;
            }

            return(xml);
        }