public static DigitalGood Load(Int32 digitalGoodId, bool useCache) { if (digitalGoodId == 0) { return(null); } DigitalGood digitalGood = null; string key = "DigitalGood_" + digitalGoodId.ToString(); if (useCache) { digitalGood = ContextCache.GetObject(key) as DigitalGood; if (digitalGood != null) { return(digitalGood); } } digitalGood = new DigitalGood(); if (digitalGood.Load(digitalGoodId)) { if (useCache) { ContextCache.SetObject(key, digitalGood); } return(digitalGood); } return(null); }
protected void OkButton_Click(object sender, EventArgs e) { // Looping through all the rows in the GridView foreach (GridViewRow row in SearchResultsGrid.Rows) { CheckBox checkbox = (CheckBox)row.FindControl("SelectCheckbox"); if ((checkbox != null) && (checkbox.Checked)) { // Retreive the DigitalGood int digitalGoodId = Convert.ToInt32(SearchResultsGrid.DataKeys[row.RowIndex].Value); DigitalGood dg = DigitalGoodDataSource.Load(digitalGoodId); // ( Bug 8262 ) CREATE A NEW ORDER ITEM FOR EACH DIGITAL GOOD OrderItem oi = new OrderItem(); oi.OrderId = _OrderId; oi.CustomFields["DigitalGoodIndicator"] = "1"; oi.Name = dg.Name; oi.OrderItemType = OrderItemType.Product; oi.Price = 0; oi.Quantity = 1; oi.Shippable = Shippable.No; oi.IsHidden = true; oi.Save(); OrderItemDigitalGood orderItemDigitalGood = new OrderItemDigitalGood(); orderItemDigitalGood.OrderItemId = oi.Id; orderItemDigitalGood.DigitalGoodId = digitalGoodId; orderItemDigitalGood.Name = dg.Name; orderItemDigitalGood.Save(); orderItemDigitalGood.Save(); } } Response.Redirect(string.Format("ViewDigitalGoods.aspx?OrderNumber={0}", _Order.OrderNumber)); }
protected string GetDownloadUrl(object dataItem) { if (!this.Order.OrderStatus.IsValid) { return("#"); } OrderItemDigitalGood oidg = (OrderItemDigitalGood)dataItem; DigitalGood dg = oidg.DigitalGood; if ((oidg.DownloadStatus == DownloadStatus.Valid) && (dg != null)) { string downloadUrl = this.Page.ResolveUrl(NavigationHelper.GetMobileStoreUrl("~/Members/Download.ashx?id=" + oidg.Id.ToString())); if ((dg.LicenseAgreementMode & LicenseAgreementMode.OnDownload) == LicenseAgreementMode.OnDownload) { if (dg.LicenseAgreement != null) { string acceptUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(downloadUrl)); string declineUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("javascript:window.close()")); string agreeUrl = this.Page.ResolveUrl(NavigationHelper.GetMobileStoreUrl("~/ViewLicenseAgreement.aspx")) + "?id=" + dg.LicenseAgreement.Id + "&AcceptUrl=" + acceptUrl + "&DeclineUrl=" + declineUrl; return(agreeUrl + "\" onclick=\"" + AbleCommerce.Code.PageHelper.GetPopUpScript(agreeUrl, "license", 640, 480, "resizable=1,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no") + ";return false"); } } return(downloadUrl); } return(string.Empty); }
/// <summary> /// Acquires a serial key for this digital good /// </summary> public void AcquireSerialKey() { if (IsSerialKeyAcquired()) { return; } if (!HasSerialKeyProvider()) { return; } ISerialKeyProvider provider = DigitalGood.GetSerialKeyProviderInstance(); AcquireSerialKeyResponse response = provider.AcquireSerialKey(this); if (response.Successful) { this.SerialKeyData = response.SerialKey; //initiate fulfillment email EmailTemplate template = EmailTemplateDataSource.Load(DigitalGood.FulfillmentEmailId); if (template != null) { SendEmail(template); } } else { //serial key could not be acquired. Logger.Error(string.Format("Serial Key could not be acquired for {0} using Serial Key Provider {1}. Provider Error Message '{2}'", DigitalGood.Name, provider.Name, response.ErrorMessage)); } }
protected void AttachButton_Click(object sender, EventArgs e) { string attach = Request.Form["attach"]; if (!string.IsNullOrEmpty(attach)) { string[] ids = attach.Replace(" ", "").Split(",".ToCharArray()); foreach (string strId in ids) { int dgid = AlwaysConvert.ToInt(strId); DigitalGood dg = DigitalGoodDataSource.Load(dgid); if (dg != null) { int index = _Product.DigitalGoods.IndexOf(dg.Id); if (index < 0) { ProductDigitalGood pdg = new ProductDigitalGood(); pdg.Product = _Product; pdg.OptionList = _OptionList; pdg.DigitalGood = dg; _Product.DigitalGoods.Add(pdg); } } } _Product.DigitalGoods.Save(); } Response.Redirect(CancelButton.NavigateUrl); }
protected void Page_Load(object sender, EventArgs e) { _DigitalGoodId = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]); _DigitalGood = DigitalGoodDataSource.Load(_DigitalGoodId); if (_DigitalGood == null) { Response.Redirect("Default.aspx"); } Caption.Text = string.Format(Caption.Text, _DigitalGood.Name); //GET ALL ORDER ITEMS ASSOCIATED WITH DIGITAL GOOD IList <OrderItemDigitalGood> oidgs = OrderItemDigitalGoodDataSource.LoadForDigitalGood(_DigitalGoodId); //BUILD DISTINCT LIST OF ORDERS List <Order> orders = new List <Order>(); foreach (OrderItemDigitalGood oidg in oidgs) { Order order = oidg.OrderItem.Order; if (orders.IndexOf(order) < 0) { orders.Add(order); } } //BIND TO GRID OrderGrid.DataSource = orders; OrderGrid.DataBind(); }
private static void HandleOrderItemDigitalGood(HttpContext context, HttpResponse Response, int orderItemDigitalGoodId) { OrderItemDigitalGood oidg = OrderItemDigitalGoodDataSource.Load(orderItemDigitalGoodId); // VERIFY DIGITAL GOOD IS VALID if (oidg != null) { // VERIFY REQUESTING USER PLACED THE ORDER OrderItem orderItem = oidg.OrderItem; if (orderItem != null) { Order order = orderItem.Order; if (order != null) { if (AbleContext.Current.UserId == order.User.Id) { // VERIFY THE DOWNLOAD IS VALID if (oidg.DownloadStatus == DownloadStatus.Valid) { DigitalGood digitalGood = oidg.DigitalGood; if (digitalGood != null) { // RECORD THE DOWNLOAD Uri referrer = context.Request.UrlReferrer; string referrerUrl = (referrer != null) ? referrer.ToString() : string.Empty; oidg.RecordDownload(context.Request.UserHostAddress, context.Request.UserAgent, referrerUrl); DownloadHelper.SendFileDataToClient(context, digitalGood); } else { Response.Write("The requested file could not be located."); } } else { Response.Write("This download is expired or invalid."); } } else { Response.Write("You are not authorized to download the requested file."); } } else { Response.Write("The order could not be loaded."); } } else { Response.Write("The order item could not be loaded."); } } else { Response.Write("The requested item does not exist."); } }
/// <summary> /// Returns the serial key to the the serial key pool of the provider /// </summary> public void ReturnSerialKey() { if (IsSerialKeyAcquired() && HasSerialKeyProvider()) { ISerialKeyProvider provider = DigitalGood.GetSerialKeyProviderInstance(); provider.ReturnSerialKey(this.SerialKeyData, this); this.SerialKeyData = null; } }
public static bool Delete(Int32 digitalGoodId) { DigitalGood digitalGood = new DigitalGood(); if (digitalGood.Load(digitalGoodId)) { return(digitalGood.Delete()); } return(false); }
protected void Page_Load(object sender, EventArgs e) { int digitalGoodId = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]); _DigitalGood = DigitalGoodDataSource.Load(digitalGoodId); if (_DigitalGood == null) { Response.Redirect("~/Admin/DigitalGoods/DigitalGoods.aspx"); } _SerialKeyProviderId = Misc.GetClassId(typeof(DefaultSerialKeyProvider)); Caption.Text = string.Format(Caption.Text, _DigitalGood.Name); }
protected void SearchResultsGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Download") { int digitalGoodId = AlwaysConvert.ToInt(e.CommandArgument); DigitalGood dg = DigitalGoodDataSource.Load(digitalGoodId); if (dg != null) { AbleCommerce.Code.PageHelper.SendFileDataToClient(dg); } } }
protected bool DGFileExists(object dataItem) { DigitalGood dg = dataItem as DigitalGood; if (dg != null) { return(System.IO.File.Exists(dg.AbsoluteFilePath)); } else { return(false); } }
protected int GetProductCount(object dataItem) { DigitalGood m = (DigitalGood)dataItem; if (_ProductCounts.ContainsKey(m.Id)) { return(_ProductCounts[m.Id]); } int count = ProductDigitalGoodDataSource.CountForDigitalGood(m.Id); _ProductCounts[m.Id] = count; return(count); }
protected void Page_InIt(object sender, EventArgs e) { _DigitalGoodId = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]); _DigitalGood = DigitalGoodDataSource.Load(_DigitalGoodId); if (_DigitalGood == null) { Response.Redirect("Default.aspx"); } Caption.Text = string.Format(Caption.Text, _DigitalGood.Name); FindAssignProducts1.AssignmentValue = _DigitalGoodId; FindAssignProducts1.OnAssignProduct += new AssignProductEventHandler(FindAssignProducts1_AssignProduct); FindAssignProducts1.OnLinkCheck += new AssignProductEventHandler(FindAssignProducts1_LinkCheck); FindAssignProducts1.OnCancel += new EventHandler(FindAssignProducts1_CancelButton); }
protected void Page_Init(object sender, System.EventArgs e) { _DigitalGoodId = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]); _DigitalGood = DigitalGoodDataSource.Load(_DigitalGoodId); if (_DigitalGood == null) { Response.Redirect("Default.aspx"); } Caption.Text = string.Format(Caption.Text, _DigitalGood.Name); InstructionText.Text = string.Format(InstructionText.Text, _DigitalGood.Name); ProductsGrid.DataSource = _DigitalGood.ProductDigitalGoods; ProductsGrid.DataBind(); //GET ALL ORDER ITEMS ASSOCIATED WITH DIGITAL GOOD IList <OrderItemDigitalGood> oidgs = OrderItemDigitalGoodDataSource.LoadForDigitalGood(_DigitalGoodId); //BUILD DISTINCT LIST OF ORDERS List <CommerceBuilder.Orders.Order> orders = new List <CommerceBuilder.Orders.Order>(); foreach (OrderItemDigitalGood oidg in oidgs) { CommerceBuilder.Orders.Order order = oidg.OrderItem.Order; if (orders.IndexOf(order) < 0) { orders.Add(order); } } //BIND TO GRID OrderGrid.DataSource = orders; OrderGrid.DataBind(); if (!String.IsNullOrEmpty(_DigitalGood.FileName)) { ICriteria criteria = NHibernateHelper.CreateCriteria <DigitalGood>(); criteria.Add(Restrictions.Eq("FileName", StringHelper.SafeSqlString(_DigitalGood.FileName))); IList <DigitalGood> dgc = DigitalGoodDataSource.LoadForCriteria(criteria); if (dgc != null && dgc.Count > 1) { DeleteAllowedPanel.Visible = false; DeletePreventedPanel.Visible = true; NoDeleteFileText.Text = string.Format(NoDeleteFileText.Text, _DigitalGood.FileName); } else { DeleteAllowedPanel.Visible = true; DeletePreventedPanel.Visible = false; DeleteFile.Text = string.Format(DeleteFile.Text, _DigitalGood.FileName); } } }
protected string GetReadMeUrl(object dataItem) { DigitalGood dg = (DigitalGood)dataItem; string encodedUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("javascript:window.close()")); string readmeUrl = this.Page.ResolveUrl("~/ViewReadme.aspx") + "?ReadmeId={0}&ReturnUrl=" + encodedUrl; string readmeClickScript = AbleCommerce.Code.PageHelper.GetPopUpScript(readmeUrl, "readme", 640, 480, "resizable=1,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no") + ";"; if (dg.Readme != null) { readmeClickScript = string.Format(readmeClickScript, dg.ReadmeId); return(readmeClickScript); } return(string.Empty); }
protected void DigitalGoodsGrid_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item) { OrderItemDigitalGood oidg = (OrderItemDigitalGood)e.Item.DataItem; if (oidg != null) { DigitalGood dg = oidg.DigitalGood; if (dg != null) { if ((dg.LicenseAgreement != null) || (dg.Readme != null)) { PlaceHolder phAssets = (PlaceHolder)e.Item.FindControl("phAssets"); if (phAssets != null) { phAssets.Visible = true; string encodedUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("javascript:window.close()")); string agreeUrl = this.Page.ResolveUrl(NavigationHelper.GetMobileStoreUrl("~/ViewLicenseAgreement.aspx") + "?id={0}&ReturnUrl=" + encodedUrl); string agreeClickScript = AbleCommerce.Code.PageHelper.GetPopUpScript(agreeUrl, "license", 640, 480, "resizable=1,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no") + ";return false"; string readmeUrl = this.Page.ResolveUrl(NavigationHelper.GetMobileStoreUrl("~/ViewReadme.aspx")) + "?ReadmeId={0}&ReturnUrl=" + encodedUrl; string readmeClickScript = AbleCommerce.Code.PageHelper.GetPopUpScript(readmeUrl, "readme", 640, 480, "resizable=1,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no") + ";return false"; if (dg.Readme != null) { readmeClickScript = string.Format(readmeClickScript, dg.ReadmeId); HtmlControl ReadMeItem = (HtmlControl)phAssets.FindControl("ReadMeItem"); HtmlControl ReadMeLink = (HtmlControl)ReadMeItem.FindControl("ReadMeLink"); ReadMeItem.Visible = true; ReadMeLink.Attributes["onclick"] = readmeClickScript; } if (dg.LicenseAgreement != null) { agreeClickScript = string.Format(agreeClickScript, dg.LicenseAgreementId); HtmlControl AgreementItem = (HtmlControl)phAssets.FindControl("AgreementItem"); HtmlControl AgreementLink = (HtmlControl)AgreementItem.FindControl("AgreementLink"); AgreementItem.Visible = true; AgreementLink.Attributes["href"] = string.Format(agreeUrl, dg.LicenseAgreementId); AgreementLink.Attributes["onclick"] = agreeClickScript; } } } } } } }
public void ProcessRequest(HttpContext context) { context.Server.ScriptTimeout = 14400; HttpResponse Response = context.Response; // LOAD REQUESTED ORDER ITEM DIGITAL GOOD if (!string.IsNullOrEmpty(context.Request.QueryString["id"])) { int orderItemDigitalGoodId = AlwaysConvert.ToInt(context.Request.QueryString["id"]); HandleOrderItemDigitalGood(context, Response, orderItemDigitalGoodId); } // HANDLE DIGITAL GOOD DOWNLOAD REQUEST else if (!string.IsNullOrEmpty(context.Request.QueryString["dgid"])) { int digitalGoodId = AlwaysConvert.ToInt(context.Request.QueryString["dgid"]); DigitalGood digitalGood = DigitalGoodDataSource.Load(digitalGoodId); // VERIFY DIGITAL GOOD IS VALID if (digitalGood != null) { bool hasAccess = false; foreach (DigitalGoodGroup dgg in digitalGood.DigitalGoodGroups) { if (AbleContext.Current.User.IsInGroup(dgg.GroupId)) { hasAccess = true; break; } } if (hasAccess) { DownloadHelper.SendFileDataToClient(context, digitalGood); } else { Response.Write("You are not authorized to download the requested file."); } } else { Response.Write("The requested file could not be located."); } } }
protected string GetFileSize(object dataItem) { decimal tempSize = 0; DigitalGood digitalGood = (DigitalGood)dataItem; if (digitalGood.FileSize < 1024) { return(digitalGood.FileSize.ToString() + " bytes"); } tempSize = digitalGood.FileSize / 1024; if (tempSize < 1024) { return(string.Format("{0:0.#}kb", tempSize)); } tempSize = tempSize / 1024; return(string.Format("{0:F1}mb", tempSize)); }
public static DigitalGoodCollection LoadForStore(int maximumRows, int startRowIndex, string sortExpression) { int storeId = Token.Instance.StoreId; //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT"); if (maximumRows > 0) { selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString()); } selectQuery.Append(" " + DigitalGood.GetColumnNames(string.Empty)); selectQuery.Append(" FROM ac_DigitalGoods"); selectQuery.Append(" WHERE StoreId = @storeId"); if (!string.IsNullOrEmpty(sortExpression)) { selectQuery.Append(" ORDER BY " + sortExpression); } Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, storeId); //EXECUTE THE COMMAND DigitalGoodCollection results = new DigitalGoodCollection(); int thisIndex = 0; int rowCount = 0; using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows))) { if (thisIndex >= startRowIndex) { DigitalGood digitalGood = new DigitalGood(); DigitalGood.LoadDataReader(digitalGood, dr); results.Add(digitalGood); rowCount++; } thisIndex++; } dr.Close(); } return(results); }
protected void Page_Load(object sender, EventArgs e) { _CategoryId = AbleCommerce.Code.PageHelper.GetCategoryId(); _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]); _DigitalGoodId = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]); _DigitalGood = DigitalGoodDataSource.Load(_DigitalGoodId); _SerialKeyProviderId = Misc.GetClassId(typeof(DefaultSerialKeyProvider)); if (_DigitalGood == null) { if (_ProductId > 0) { Response.Redirect("~/Admin/Products/EditProduct.aspx?CategoryId=" + _CategoryId.ToString() + "&ProductId=" + _ProductId.ToString() + "&DigitalGoodId=" + _DigitalGoodId.ToString()); } else { Response.Redirect("~/Admin/DigitalGoods/EditDigitalGood.aspx?DigitalGoodId=" + _DigitalGoodId.ToString()); } } _SerialKeyId = AlwaysConvert.ToInt(Request.QueryString["SerialKeyId"]); _SerialKey = SerialKeyDataSource.Load(_SerialKeyId); if (_SerialKey == null) { if (_ProductId > 0) { Response.Redirect("~/Admin/Products/EditProduct.aspx?CategoryId=" + _CategoryId.ToString() + "&ProductId=" + _ProductId.ToString() + "&DigitalGoodId=" + _DigitalGoodId.ToString()); } else { Response.Redirect("~/Admin/DigitalGoods/EditDigitalGood.aspx?DigitalGoodId=" + _DigitalGoodId.ToString()); } } Caption.Text = string.Format(Caption.Text, _DigitalGood.Name); if (!Page.IsPostBack) { InitializeForm(); } }
protected void DigitalGoodGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Copy") { int dgid = AlwaysConvert.ToInt(e.CommandArgument); DigitalGood digitalGood = DigitalGoodDataSource.Load(dgid); DigitalGood copy = digitalGood.Copy(); if (copy != null) { String newName = "Copy of " + copy.Name; if (newName.Length > 100) { newName = newName.Substring(0, 97) + "..."; } copy.Name = newName; copy.Save(); } DigitalGoodGrid.DataBind(); } }
/// <summary> /// Gets all assets for a product regardless of variant. /// </summary> /// <param name="page">Page context</param> /// <param name="product">Product to get assets for</param> /// <param name="returnUrl">URL to use for the return location when pages visited.</param> /// <returns></returns> public static List <AbleCommerce.Code.ProductAssetWrapper> GetAssets(Page page, Product product, string returnUrl) { // BUILD LIST OF ASSETS List <string> assetTracker = new List <string>(); string encodedReturnUrl; if (!string.IsNullOrEmpty(returnUrl)) { encodedReturnUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(returnUrl)); } else { encodedReturnUrl = string.Empty; } List <AbleCommerce.Code.ProductAssetWrapper> assetList = new List <AbleCommerce.Code.ProductAssetWrapper>(); string agreeUrl = page.ResolveUrl("~/ViewLicenseAgreement.aspx") + "?id={0}&ReturnUrl=" + encodedReturnUrl; string agreePopup = agreeUrl + "\" onclick=\"" + AbleCommerce.Code.PageHelper.GetPopUpScript(agreeUrl, "license", 640, 480, "resizable=1,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no") + ";return false"; string readmeUrl = page.ResolveUrl("~/ViewReadme.aspx") + "?ReadmeId={0}&ReturnUrl=" + encodedReturnUrl; string readmePopup = readmeUrl + "\" onclick=\"" + AbleCommerce.Code.PageHelper.GetPopUpScript(readmeUrl, "readme", 640, 480, "resizable=1,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no") + ";return false"; foreach (ProductDigitalGood pdg in product.DigitalGoods) { DigitalGood digitalGood = pdg.DigitalGood; Readme readme = digitalGood.Readme; if (readme != null && assetTracker.IndexOf("R" + readme.Id.ToString()) < 0) { assetList.Add(new AbleCommerce.Code.ProductAssetWrapper(string.Format(readmePopup, readme.Id), readme.DisplayName)); assetTracker.Add("R" + readme.Id.ToString()); } LicenseAgreement agreement = digitalGood.LicenseAgreement; if (agreement != null && assetTracker.IndexOf("L" + agreement.Id.ToString()) < 0) { assetList.Add(new AbleCommerce.Code.ProductAssetWrapper(string.Format(agreePopup, agreement.Id), agreement.DisplayName)); assetTracker.Add("L" + agreement.Id.ToString()); } } return(assetList); }
public static void SendFileDataToClient(DigitalGood digitalGood) { if (digitalGood == null) { throw new ArgumentNullException("digitalGood"); } //STREAM TO BOWSER HttpResponse Response = HttpContext.Current.Response; int chunkSize = 10000; FileInfo fi = new FileInfo(digitalGood.AbsoluteFilePath); if (fi.Exists) { using (FileStream fs = fi.OpenRead()) { Response.Clear(); Response.ContentType = "application/octet-stream"; if (fs.Length > 0) { Response.AddHeader("Content-Length", fs.Length.ToString()); } Response.AddHeader("Content-Disposition", "attachment; filename=" + digitalGood.FileName); long dataToRead = fs.Length; while ((dataToRead > 0) && (Response.IsClientConnected)) { byte[] buffer = new byte[chunkSize]; int bytesRead = fs.Read(buffer, 0, chunkSize); Response.OutputStream.Write(buffer, 0, bytesRead); Response.Flush(); dataToRead -= bytesRead; } fs.Close(); } } Response.Close(); }
public static SaveResult Insert(DigitalGood digitalGood) { return(digitalGood.Save()); }
public static SaveResult Update(DigitalGood digitalGood) { return(digitalGood.Save()); }
public static bool Delete(DigitalGood digitalGood) { return(digitalGood.Delete()); }
public static List <AbleCommerce.Code.ProductAssetWrapper> GetAssets(Page page, Product product, string optionList, string kitList, string returnUrl) { // BUILD LIST OF ASSETS List <string> assetTracker = new List <string>(); string encodedReturnUrl; if (!string.IsNullOrEmpty(returnUrl)) { encodedReturnUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(returnUrl)); } else { encodedReturnUrl = string.Empty; } List <AbleCommerce.Code.ProductAssetWrapper> assetList = new List <AbleCommerce.Code.ProductAssetWrapper>(); string agreeUrl = page.ResolveUrl("~/ViewLicenseAgreement.aspx") + "?id={0}&ReturnUrl=" + encodedReturnUrl; string agreePopup = agreeUrl + "\" onclick=\"" + AbleCommerce.Code.PageHelper.GetPopUpScript(agreeUrl, "license", 640, 480, "resizable=1,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no") + ";return false"; string readmeUrl = page.ResolveUrl("~/ViewReadme.aspx") + "?ReadmeId={0}&ReturnUrl=" + encodedReturnUrl; string readmePopup = readmeUrl + "\" onclick=\"" + AbleCommerce.Code.PageHelper.GetPopUpScript(readmeUrl, "readme", 640, 480, "resizable=1,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no") + ";return false"; List <ProductAndOptionList> products = new List <ProductAndOptionList>(); products.Add(new ProductAndOptionList(product, optionList)); // IF IT IS A KIT LOOK FOR CHILD PRODUCTS AS WELL if (!String.IsNullOrEmpty(kitList)) { if (product.IsKit) { bool kitIsBundled = !product.Kit.ItemizeDisplay; int[] kitProductIds = AlwaysConvert.ToIntArray(kitList); if (kitProductIds != null && kitProductIds.Length > 0) { foreach (int kitProductId in kitProductIds) { KitProduct kitProduct = KitProductDataSource.Load(kitProductId); if ((kitProduct != null) && (kitProduct.KitComponent.InputType == KitInputType.IncludedHidden || kitIsBundled)) { products.Add(new ProductAndOptionList(kitProduct.Product, kitProduct.OptionList)); } } } } } foreach (ProductAndOptionList pol in products) { foreach (ProductDigitalGood pdg in pol.Product.DigitalGoods) { if ((string.IsNullOrEmpty(pdg.OptionList)) || (pol.OptionList == pdg.OptionList)) { DigitalGood digitalGood = pdg.DigitalGood; Readme readme = digitalGood.Readme; if (readme != null && assetTracker.IndexOf("R" + readme.Id.ToString()) < 0) { assetList.Add(new AbleCommerce.Code.ProductAssetWrapper(string.Format(readmePopup, readme.Id), readme.DisplayName)); assetTracker.Add("R" + readme.Id.ToString()); } LicenseAgreement agreement = digitalGood.LicenseAgreement; if (agreement != null && assetTracker.IndexOf("L" + agreement.Id.ToString()) < 0) { assetList.Add(new AbleCommerce.Code.ProductAssetWrapper(string.Format(agreePopup, agreement.Id), agreement.DisplayName)); assetTracker.Add("L" + agreement.Id.ToString()); } } } } return(assetList); }
protected bool DGFileExists(object dataItem) { DigitalGood dg = (DigitalGood)dataItem; return(File.Exists(dg.AbsoluteFilePath)); }
/// <summary> /// Initializes the configuration provider. /// </summary> /// <param name="digitalGood">The digital good</param> /// <param name="configurationData">The configuration data</param> public virtual void Initialize(DigitalGood digitalGood, Dictionary <string, string> configurationData) { this.DigitalGood_ = digitalGood; }