private void loadProducts()
{
CatalogManager catalogManager = CatalogManager.GetManager();
List<Product> products = catalogManager.GetProducts().Where(u => u.Status == ContentLifecycleStatus.Live).ToList();
DataTable output = new DataTable("ASA");
output.Columns.Add("ProductTitle");
output.Columns.Add("DisplayPrice");
output.Columns.Add("ThumbURL");
output.Columns.Add("ProductBarcode");
foreach (Product product in products)
{
// Current Page URL
string product_info = product.Title + "," + product.DisplayPriceFormatted + "," + product.AutoGenerateUniqueUrl;
string barcode_url = "";
BarCodeBuilder bb = new BarCodeBuilder();
bb.CodeText = product_info;
bb.SymbologyType = (Symbology)Enum.Parse(typeof(Symbology), mySymbology);
if (Height <= 0)
Height = 100;
if (Width <= 0)
Width = 100;
bb.ImageWidth = Width;
bb.ImageHeight = Height;
if (AutoHeight)
bb.AutoSize = true;
bb.CodeLocation = CodeLocation.None;
// Check for license and apply if exists
string licenseFile = Server.MapPath("~/App_Data/Aspose.Total.lic");
if (File.Exists(licenseFile))
{
License license = new License();
license.SetLicense(licenseFile);
}
using (MD5 md5Hash = MD5.Create())
{
string hashData = product_info + mySymbology + myWidth.ToString() + myHeight.ToString() + myAutoHeight.ToString();
string filename_hash = GetMd5Hash(md5Hash, hashData);
string fileName = filename_hash + ".png";
if (!File.Exists(Server.MapPath("~/Aspose_Data/" + fileName)))
{
bb.Save(Server.MapPath(@"~/Aspose_Data/" + fileName), BarCodeImageFormat.Png);
}
barcode_url = "~/Aspose_Data/" + fileName;
}
DataRow dr;
dr = output.NewRow();
dr["ProductTitle"] = product.Title;
dr["DisplayPrice"] = product.DisplayPriceFormatted;
dr["ThumbURL"] = product.ThumbnailUrl;
dr["ProductBarcode"] = barcode_url;
output.Rows.Add(dr);
}
SitefinityProductsGridView.DataSource = output;
SitefinityProductsGridView.DataBind();
}