protected void btnProcessAll_Click(object sender, EventArgs e) { var output = new StringBuilder(); var recurringOrderMgr = new RecurringOrderMgr(); using (var connection = new SqlConnection(DB.GetDBConn())) using (var command = connection.CreateCommand()) { command.CommandText = "Select distinct(OriginalRecurringOrderNumber) from ShoppingCart where RecurringSubscriptionID='' and CartType = @cartType and NextRecurringShipDate < dateadd(d,1,getDate())"; command.Parameters.AddWithValue("@cartType", (int)CartTypeEnum.RecurringCart); connection.Open(); using (var reader = command.ExecuteReader()) while (reader.Read()) { output.AppendFormat( AppLogic.GetString("admin.recurring.ProcessingNextOccurrence"), reader.FieldInt("OriginalRecurringOrderNumber")); output.Append(recurringOrderMgr.ProcessRecurringOrder(reader.FieldInt("OriginalRecurringOrderNumber"))); output.Append("...<br/>"); } } AlertMessage.PushAlertMessage( output.ToString(), AspDotNetStorefrontControls.AlertMessage.AlertType.Info); }
protected void btnProcess_Click(Object sender, EventArgs e) { if (OriginalRecurringOrderNumber != 0) { RecurringOrderMgr orderMgr = new RecurringOrderMgr(); string message = orderMgr.ProcessRecurringOrder(OriginalRecurringOrderNumber); AlertMessage.PushAlertMessage(message, (message == AppLogic.ro_OK) ? AspDotNetStorefrontControls.AlertMessage.AlertType.Success : AspDotNetStorefrontControls.AlertMessage.AlertType.Error); } }
private void RenderMarkup() { StringBuilder output = new StringBuilder(); if (CommonLogic.QueryStringBool("ProcessAll")) { using (SqlConnection conn = DB.dbConn()) { conn.Open(); using (IDataReader rsp = DB.GetRS("Select distinct(OriginalRecurringOrderNumber) from ShoppingCart where RecurringSubscriptionID='' and CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + " and NextRecurringShipDate<" + DB.SQuote(Localization.ToDBShortDateString(System.DateTime.Now.AddDays(1))), conn)) { RecurringOrderMgr rmgr = new RecurringOrderMgr(EntityHelpers, GetParser); while (rsp.Read()) { output.Append(String.Format(AppLogic.GetString("admin.recurring.ProcessingNextOccurrence", SkinID, LocaleSetting), DB.RSFieldInt(rsp, "OriginalRecurringOrderNumber").ToString())); output.Append(rmgr.ProcessRecurringOrder(DB.RSFieldInt(rsp, "OriginalRecurringOrderNumber"))); output.Append("...<br/>"); } } } } int OriginalRecurringOrderNumber = CommonLogic.QueryStringUSInt("OriginalRecurringOrderNumber"); int ProcessCustomerID = CommonLogic.QueryStringUSInt("ProcessCustomerID"); if (ProcessCustomerID != 0 && OriginalRecurringOrderNumber != 0) { output.Append(String.Format(AppLogic.GetString("admin.recurring.ProcessingNextOccurrence", SkinID, LocaleSetting), OriginalRecurringOrderNumber.ToString())); RecurringOrderMgr rmgr = new RecurringOrderMgr(EntityHelpers, GetParser); output.Append(rmgr.ProcessRecurringOrder(OriginalRecurringOrderNumber)); output.Append("...<br/>"); } output.Append("<br/><ul>"); bool PendingOnly = (!CommonLogic.QueryStringCanBeDangerousContent("Show").Equals("ALL", StringComparison.InvariantCultureIgnoreCase)); if (PendingOnly) { if (DB.GetSqlN("Select count(*) as N from ShoppingCart with (NOLOCK) where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + " and NextRecurringShipDate<" + DB.SQuote(Localization.ToDBDateTimeString(System.DateTime.Now.AddDays(1)))) > 0) { output.Append("<li><b><a href=\"" + AppLogic.AdminLinkUrl("recurring.aspx") + "?processall=true\">" + AppLogic.GetString("admin.recurring.ProcessChargesAll", SkinID, LocaleSetting) + "</a></b> " + AppLogic.GetString("admin.recurring.ProcessChargesSingle", SkinID, LocaleSetting) + "</li>"); } else { output.Append("<li><b>" + AppLogic.GetString("admin.recurring.NoRecurringShipmentsDueToday", SkinID, LocaleSetting) + "</b></li>"); } } else { if (DB.GetSqlN("Select count(*) as N from ShoppingCart with (NOLOCK) where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString()) == 0) { output.Append("<li><b>" + AppLogic.GetString("admin.recurring.NoActiveRecurringOrdersFound", SkinID, LocaleSetting) + "</b></li>"); } } if (AppLogic.AppConfigBool("Recurring.UseGatewayInternalBilling")) { output.Append("<li><b>" + AppLogic.GetString("admin.recurring.NoteAutobillGatewayOrders", SkinID, LocaleSetting) + "</b></li>"); } output.Append("</ul>"); using (SqlConnection conn2 = DB.dbConn()) { conn2.Open(); using (IDataReader rsr = DB.GetRS("Select distinct OriginalRecurringOrderNumber, CustomerID from ShoppingCart with (NOLOCK) where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + CommonLogic.IIF(PendingOnly, " and NextRecurringShipDate<" + DB.SQuote(Localization.ToDBShortDateString(System.DateTime.Now.AddDays(1))), "") + " order by OriginalRecurringOrderNumber desc", conn2)) { while (rsr.Read()) { output.Append(AppLogic.GetRecurringCart(EntityHelpers, GetParser, new Customer(DB.RSFieldInt(rsr, "CustomerID")), DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"), SkinID, false)); } } } ltContent.Text = output.ToString(); }