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); }
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."); } }
protected bool ShowSerialKeyLink(object dataItem) { OrderItemDigitalGood oidg = (OrderItemDigitalGood)dataItem; if (!string.IsNullOrEmpty(oidg.SerialKeyData) && oidg.SerialKeyData.Length > 100) { return(true); } return(false); }
protected string GetDownloadUrl(object dataItem) { OrderItemDigitalGood oidg = (OrderItemDigitalGood)dataItem; if (oidg.DownloadStatus == DownloadStatus.Valid) { return(Page.ResolveUrl("~/Members/Download.ashx?id=" + oidg.Id.ToString())); } return(string.Empty); }
protected string GetPopUpScript(object dataItem) { OrderItemDigitalGood oidg = (OrderItemDigitalGood)dataItem; string url = string.Format("~/Members/MySerialKey.aspx?OrderItemDigitalGoodId={0}", oidg.Id); url = this.ResolveUrl(url); string clientScript = string.Format("window.open('{0}'); return false;", url); clientScript = "javascript:" + clientScript; return(clientScript); }
protected string GetPopUpScript(object dataItem) { OrderItemDigitalGood oidg = (OrderItemDigitalGood)dataItem; string url = NavigationHelper.GetMobileStoreUrl(string.Format("~/Members/MySerialKey.aspx?OrderItemDigitalGoodId={0}", oidg.Id)); url = this.ResolveUrl(url); //string clientScript = AbleCommerce.Code.PageHelper.GetPopUpScript(url, "Serial Key", 20, 20); string clientScript = string.Format("window.open('{0}'); return false;", url); clientScript = "javascript:" + clientScript; return(clientScript); }
protected string GetMaxDownloads(OrderItemDigitalGood oidg) { if (oidg.DigitalGood == null) { return(string.Empty); } if (oidg.DigitalGood.MaxDownloads == 0) { return("(no max)"); } return(string.Format("(max {0})", oidg.DigitalGood.MaxDownloads)); }
protected bool SerialKeyEnabled(object dataItem) { OrderItemDigitalGood oidg = (OrderItemDigitalGood)dataItem; if (oidg != null && oidg.DigitalGood != null) { return(oidg.DigitalGood.EnableSerialKeys); } else { return(false); } }
protected bool ShowSerialKey(object dataItem) { OrderItemDigitalGood oidg = (OrderItemDigitalGood)dataItem; if (oidg.DownloadStatus == DownloadStatus.Valid) { if (string.IsNullOrEmpty(oidg.SerialKeyData) || oidg.SerialKeyData.Length <= 100) { return(true); } } return(false); }
protected string GetMaxDownloads(object dataItem) { OrderItemDigitalGood oidg = (OrderItemDigitalGood)dataItem; if (oidg.DigitalGood == null) { return(string.Empty); } if (oidg.DigitalGood.MaxDownloads == 0) { return("n/a"); } int remDownloads = AlwaysConvert.ToInt(oidg.DigitalGood.MaxDownloads) - oidg.RelevantDownloads; return(remDownloads.ToString()); }
public bool ShowMediakey(Object dataItem) { OrderItemDigitalGood oidg = (OrderItemDigitalGood)dataItem; if (oidg.DigitalGood == null) { return(false); } bool showMediaKey = (oidg.DownloadStatus == DownloadStatus.Valid || oidg.DownloadStatus == DownloadStatus.Expired); if (showMediaKey) { showMediaKey = !String.IsNullOrEmpty(oidg.DigitalGood.MediaKey); } return(showMediaKey); }
protected void Page_Init(object sender, EventArgs e) { _OrderItemDigitalGoodId = AlwaysConvert.ToInt(Request.QueryString["OrderItemDigitalGoodId"]); _OrderItemDigitalGood = OrderItemDigitalGoodDataSource.Load(_OrderItemDigitalGoodId); if (_OrderItemDigitalGood == null) { Response.Redirect("MyAccount.aspx"); } if ((_OrderItemDigitalGood.OrderItem.Order.UserId != AbleContext.Current.UserId) && (!AbleContext.Current.User.IsInRole(Role.OrderAdminRoles))) { Response.Redirect(AbleCommerce.Code.NavigationHelper.GetStoreUrl(this.Page, "Members/MyAccount.aspx")); } //UPDATE CAPTION Caption.Text = String.Format(Caption.Text, _OrderItemDigitalGood.DigitalGood.Name); SerialKeyData.Text = _OrderItemDigitalGood.SerialKeyData; }
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; } } } } } } }
protected void SaveKeyButton_Click(object sender, EventArgs e) { OrderItemDigitalGood oidg = OrderItemDigitalGoodDataSource.Load(AlwaysConvert.ToInt(this.OidgId.Value)); if (oidg != null) { // WE NEED TO UPDATE THE CURRENT LOADED LIST TO AVOID DISPLAY ISSUES int i = _Order.Items.IndexOf(oidg.OrderItem.Id); int j = _Order.Items[i].DigitalGoods.IndexOf(oidg.Id); OrderItemDigitalGood tempOidg = _Order.Items[i].DigitalGoods[j]; tempOidg.SetSerialKey(SerialKeyData.Text, true); tempOidg.Save(); OidgId.Value = String.Empty; BindDigitalGoodsGrid(); EditKeyPopup.Hide(); } }
protected void DigitalGoodsGrid_RowCommand(object sender, GridViewCommandEventArgs e) { int orderItemDigitalGoodId = AlwaysConvert.ToInt(e.CommandArgument); OrderItemDigitalGood oidg = FindDigitalGood(orderItemDigitalGoodId); ISerialKeyProvider asd = oidg.DigitalGood.GetSerialKeyProviderInstance(); if (oidg != null) { switch (e.CommandName) { case "Activate": oidg.Activate(); oidg.Save(); break; case "Deactivate": oidg.Deactivate(); oidg.Save(); break; case "GetKey": if (oidg.DigitalGood.GetSerialKeyProviderInstance() != null) { oidg.AcquireSerialKey(); oidg.Save(); } break; case "SetKey": this.SerialKeyData.Text = String.Empty; this.SaveKeyButton.Visible = true; this.DeleteKeyButton.Visible = false; this.OidgId.Value = oidg.Id.ToString(); this.EditKeyPopup.Show(); break; //case "ReturnKey": // if (oidg.DigitalGood.GetSerialKeyProviderInstance() != null) // { // oidg.ReturnSerialKey(); // oidg.Save(); // } // else // { // oidg.SerialKeyData = null; // oidg.Save(); // } // break; case "ViewKey": this.SerialKeyData.Text = oidg.SerialKeyData; this.SaveKeyButton.Visible = false; this.DeleteKeyButton.Visible = true; this.OidgId.Value = oidg.Id.ToString(); this.EditKeyPopup.Show(); break; case "Delete": // GET THE ORDERITEM THAT CONTAINS THE DIGITAL GOOD OrderItem oi = FindOrderItem(oidg.OrderItemId); if (oi != null) { // DETERMINE IF THE ORDERITEM IS A PLACEHOLDER FOR DIGITAL GOOD if (oi.CustomFields.TryGetValue("DigitalGoodIndicator") == "1") { // THE ORDERITEM IS A PLACEHOLDER, REMOVE THE ITEM (AND DIGITAL GOOD) int oiIndex = _Order.Items.IndexOf(oi.Id); if (oiIndex > -1) { _Order.Items.DeleteAt(oiIndex); } } else { // NOT A PLACEHOLDER, DELETE THE DIGITAL GOOD ONLY int dgIndex = oi.DigitalGoods.IndexOf(oidg.Id); if (dgIndex > -1) { oi.DigitalGoods.DeleteAt(dgIndex); } } } break; } BindDigitalGoodsGrid(); } }
protected bool GetVisible(object dataItem) { OrderItemDigitalGood oidg = (OrderItemDigitalGood)dataItem; return(oidg.DownloadStatus == DownloadStatus.Valid); }
protected bool HasSerialKey(OrderItemDigitalGood oidg) { return(oidg.IsSerialKeyAcquired()); }
protected bool ProviderIsNull(OrderItemDigitalGood oidg) { return(oidg.DigitalGood == null || oidg.DigitalGood.GetSerialKeyProviderInstance() == null); }
protected bool ShowSetKey(object dataItem) { OrderItemDigitalGood oidg = (OrderItemDigitalGood)dataItem; return(SerialKeyEnabled(dataItem) && !HasSerialKey(oidg) && (ProviderIsNull(oidg) || oidg.DigitalGood.SerialKeys.Count == 0)); }
/// <summary> /// Acquires a new serial key from provider /// </summary> /// <param name="oidg">OrderItemDigitalGood for which to acquire the key</param> /// <returns>Serial key acquisition response</returns> public virtual AcquireSerialKeyResponse AcquireSerialKey(OrderItemDigitalGood oidg) { return(AcquireSerialKey()); }
/// <summary> /// Returns a serial key back to the provider store /// </summary> /// <param name="keyData">The key to return</param> /// <param name="oidg">OrderItemDigitalGood the returned key is associated to</param> public virtual void ReturnSerialKey(string keyData, OrderItemDigitalGood oidg) { ReturnSerialKey(keyData); }