protected void ExecuteButton_Click(object sender, EventArgs e) { if (PortalEnabled) { DateTime beginTime = DateTime.Now; StringBuilder dataTable = new StringBuilder(); try { IList result = NHibernateHelper.CreateSQLQuery(SqlQuery.Text).List(); dataTable.Append("<div style=\"overflow:auto\"><table border=\"1\">"); foreach (object[] dataRow in result) { int columnCount = dataRow.Length; dataTable.Append("<tr>"); for (int i = 0; i < columnCount; i++) { dataTable.Append("<td>" + dataRow[i].ToString() + "</td>"); } dataTable.Append("</tr>"); } dataTable.Append("</table></div><br />"); } catch { } DateTime endTime = DateTime.Now; phQueryResult.Controls.Add(new LiteralControl(dataTable.ToString())); TimeSpan ts = endTime - beginTime; phQueryResult.Controls.Add(new LiteralControl("Query executed in " + Math.Round(ts.TotalMilliseconds, 0) + "ms")); } }
private void updateGroupBox() { string sql = "select count(*) from xcar_customer where upload_time like ? and upload_ind='Y'"; ISQLQuery isql = NHibernateHelper.CreateSQLQuery(sql); isql.SetString(0, DateTime.Now.ToString("yyyy-MM-dd") + "%"); //int count = (int)isql.UniqueResult(); groupBox1.Text = string.Format("今天已成功上传 {0} 个客户", isql.UniqueResult().ToString()); }
private void cobCity_SelectedIndexChanged(object sender, EventArgs e) { string city = this.cobCity.Text; string sql = "select name from xcar_shop where city=?"; ISQLQuery isql = NHibernateHelper.CreateSQLQuery(sql); isql.SetString(0, city); var ds = isql.List <string>(); this.cobShop.Items.Clear(); foreach (var item in ds) { this.cobShop.Items.Add(item); } this.cobShop.SelectedIndex = 0; }
private void cobProvince_SelectedIndexChanged(object sender, EventArgs e) { string province = this.cobProvince.Text; string sql = "select DISTINCT(city) from xcar_shop where province=?"; ISQLQuery isql = NHibernateHelper.CreateSQLQuery(sql); isql.SetString(0, province); var ds = isql.List <string>(); this.cobCity.Items.Clear(); foreach (var item in ds) { this.cobCity.Items.Add(item); } this.cobCity.SelectedIndex = 0; }
public UploadCustomerForm() { InitializeComponent(); string sql = "select DISTINCT(province) from xcar_shop "; ISQLQuery isql = NHibernateHelper.CreateSQLQuery(sql); var ds = isql.List <string>(); foreach (var item in ds) { this.cobProvince.Items.Add(item); } sql = "select text from xcar_buytime "; isql = NHibernateHelper.CreateSQLQuery(sql); ds = isql.List <string>(); foreach (var item in ds) { this.cobBuytime.Items.Add(item); } sql = "select text from xcar_drivercs "; isql = NHibernateHelper.CreateSQLQuery(sql); ds = isql.List <string>(); foreach (var item in ds) { this.cobDrivercs.Items.Add(item); } this.cobDrivercs.SelectedIndex = 0; this.cobBuytime.SelectedIndex = 0; reflashDgvCustomer(); updateGroupBox(); timer1.Stop(); }
private void BindData() { // get database name SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["AbleCommerce"].ConnectionString); string dbName = con.Database; // build query StringBuilder queryStr = new StringBuilder(); queryStr.Append("DECLARE @SPWHO2 TABLE (SPID VARCHAR(1000), [Status] VARCHAR(1000) NULL, [Login] VARCHAR(1000) NULL"); queryStr.Append(", HostName VARCHAR(1000) NULL, BlkBy VARCHAR(1000) NULL, DBName VARCHAR(1000) NULL, Command VARCHAR(1000) NULL"); queryStr.Append(", CPUTime VARCHAR(1000) NULL, DiskIO VARCHAR(1000) NULL, LastBatch VARCHAR(1000) NULL, ProgramName VARCHAR(1000) NULL"); queryStr.Append(", SPID2 VARCHAR(1000) NULL, Request VARCHAR(1000) NULL) "); queryStr.Append("INSERT INTO @SPWHO2 EXEC sp_who2"); if (ActiveOnly.Checked) { queryStr.Append(" 'Active' "); } queryStr.Append(" SELECT * FROM @SPWHO2 WHERE DBName = :dbName"); var nhQuery = NHibernateHelper.CreateSQLQuery(queryStr.ToString()) .SetString("dbName", dbName); // execute query var results = nhQuery.List(); // parse results IList <RptData> finalData = new List <RptData>(); foreach (object[] resultRow in results) { RptData row = new RptData(); row.Spid = (string)resultRow[0]; row.Status = (string)resultRow[1]; row.Login = (string)resultRow[2]; row.HostName = (string)resultRow[3]; row.BlkBy = (string)resultRow[4]; row.DbName = (string)resultRow[5]; row.Command = (string)resultRow[6]; row.CPUTime = (string)resultRow[7]; row.DiskIO = (string)resultRow[8]; row.LastBatch = (string)resultRow[9]; row.ProgramName = (string)resultRow[10]; row.SPID2 = (string)resultRow[11]; row.Request = (string)resultRow[12]; finalData.Add(row); } ConnectionsGrid.DataSource = finalData; ConnectionsGrid.DataBind(); // summarize data ConnectionsCount.Text = finalData.Count.ToString(); if (Session["LastCount"] != null) { int lastCount = AlwaysConvert.ToInt(Session["LastCount"], 0); int diff = finalData.Count - lastCount; Changed.Text = diff.ToString(); } else { Changed.Text = "n/a"; } Session["LastCount"] = finalData.Count.ToString(); }
protected void Page_Load(object sender, EventArgs e) { IList <CatalogNode> productNodes = new List <CatalogNode>(); int _CategoryId = AbleCommerce.Code.PageHelper.GetCategoryId(); Category _Category = CategoryDataSource.Load(_CategoryId); var user = AbleContext.Current.User; string groups = string.Join(",", (from ug in user.UserGroups select ug.GroupId).ToList <int>().ToArray()); if (_Category != null) { int productId = AbleCommerce.Code.PageHelper.GetProductId(); if (productId > 0) { //load products near the current product short currentOrderBy = 0; String sqlquery = @"SELECT TOP 1 CN.OrderBy FROM ac_CatalogNodes AS CN INNER JOIN ac_Products AS P ON CN.CatalogNodeId = P.ProductId WHERE CN.CategoryId = :categoryId AND CN.CatalogNodeTypeId = :nodeType AND CN.CatalogNodeId = :nodeId AND P.VisibilityId = :visibilityId "; if (!user.IsAdmin) { if (user.UserGroups.Count > 0) { sqlquery += " AND (NOT EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId) OR EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId AND PG.GroupId IN (" + groups + "))) "; } else { sqlquery += " AND (NOT EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId)) "; } } ISQLQuery query = NHibernateHelper.CreateSQLQuery(sqlquery); query.SetParameter("categoryId", _CategoryId); query.SetParameter("nodeType", CatalogNodeType.Product); query.SetParameter("nodeId", productId); query.SetParameter("visibilityId", (byte)CatalogVisibility.Public); currentOrderBy = query.UniqueResult <short>(); int minOrderBy = currentOrderBy - 2 * MaxItems; int maxOrderBy = currentOrderBy + 2 * MaxItems; if (DisplayMode == "RANDOM") { // this query is MS SQL Server specific because it uses NEWID() function. sqlquery = "SELECT TOP " + (MaxItems + 1) + @" CN.* FROM ac_CatalogNodes AS CN INNER JOIN ac_Products AS P ON CN.CatalogNodeId = P.ProductId WHERE CN.CategoryId = :categoryId AND CN.CatalogNodeTypeId = :nodeType AND CN.OrderBy > :minOrderBy AND CN.OrderBy < :maxOrderBy AND P.VisibilityId = :visibilityId "; if (!user.IsAdmin) { if (user.UserGroups.Count > 0) { sqlquery += " AND (NOT EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId) OR EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId AND PG.GroupId IN (" + groups + "))) "; } else { sqlquery += " AND (NOT EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId)) "; } } sqlquery += " ORDER BY NEWID() "; } else { sqlquery = "SELECT TOP " + (MaxItems + 1) + @" CN.* FROM ac_CatalogNodes AS CN INNER JOIN ac_Products AS P ON CN.CatalogNodeId = P.ProductId WHERE CN.CategoryId = :categoryId AND CN.CatalogNodeTypeId = :nodeType AND CN.OrderBy > :minOrderBy AND CN.OrderBy < :maxOrderBy AND P.VisibilityId = :visibilityId "; if (!user.IsAdmin) { if (user.UserGroups.Count > 0) { sqlquery += " AND (NOT EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId) OR EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId AND PG.GroupId IN (" + groups + "))) "; } else { sqlquery += " AND (NOT EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId)) "; } } sqlquery += " ORDER BY ABS (CN.OrderBy - " + currentOrderBy + ") "; } query = NHibernateHelper.CreateSQLQuery(sqlquery); query.SetParameter("categoryId", _CategoryId); query.SetParameter("nodeType", CatalogNodeType.Product); query.SetParameter("minOrderBy", minOrderBy); query.SetParameter("maxOrderBy", maxOrderBy); query.SetParameter("visibilityId", (byte)CatalogVisibility.Public); query.AddEntity(typeof(CatalogNode)); productNodes = query.List <CatalogNode>(); } else { //load products without any product preference String sqlquery = string.Empty; if (DisplayMode == "RANDOM") { //load products randomly. This query is SQL Server specific because of the use of NEWID() function sqlquery = "SELECT TOP " + (MaxItems + 1) + @" CN.* FROM ac_CatalogNodes AS CN INNER JOIN ac_Products AS P ON CN.CatalogNodeId = P.ProductId WHERE CN.CategoryId = :categoryId AND CN.CatalogNodeTypeId = :nodeType AND P.VisibilityId = :visibilityId "; if (!user.IsAdmin) { if (user.UserGroups.Count > 0) { sqlquery += " AND (NOT EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId) OR EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId AND PG.GroupId IN (" + groups + "))) "; } else { sqlquery += " AND (NOT EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId)) "; } } sqlquery += " ORDER BY NEWID() "; } else { //load products sequentially sqlquery = "SELECT TOP " + (MaxItems + 1) + @" CN.* FROM ac_CatalogNodes AS CN INNER JOIN ac_Products AS P ON CN.CatalogNodeId = P.ProductId WHERE CN.CategoryId = :categoryId AND CN.CatalogNodeTypeId = :nodeType AND P.VisibilityId = :visibilityId "; if (!user.IsAdmin) { if (user.UserGroups.Count > 0) { sqlquery += " AND (NOT EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId) OR EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId AND PG.GroupId IN (" + groups + "))) "; } else { sqlquery += " AND (NOT EXISTS(SELECT PG.GroupId FROM ac_ProductGroups AS PG WHERE PG.ProductId = P.ProductId)) "; } } sqlquery += " ORDER BY CN.OrderBy "; } ISQLQuery query = NHibernateHelper.CreateSQLQuery(sqlquery); query.SetParameter("categoryId", _CategoryId); query.SetParameter("nodeType", CatalogNodeType.Product); query.SetParameter("visibilityId", (byte)CatalogVisibility.Public); query.AddEntity(typeof(CatalogNode)); productNodes = query.List <CatalogNode>(); } // remove the current product int productIndex = productNodes.IndexOf(_CategoryId, productId, (byte)CatalogNodeType.Product); if (productIndex >= 0) { productNodes.RemoveAt(productIndex); } else if (productNodes.Count > MaxItems) { //remove the last item productNodes.RemoveAt(productNodes.Count - 1); } //MAKE SURE WE HAVE SOMETHING TO SHOW if (productNodes.Count > 0) { List <Product> showProducts = new List <Product>(); List <int> ids = productNodes.Select(n => n.CatalogNodeId).ToList <int>(); // FETCH THE PRODUCTS INTO ORM OBJECT GRAPH AND DISCARD RESULTS // THIS IS ESSENTIALLY FOR PERFORMANCE BOOST BY MINIMIZING NUMBER OF QUERIES NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .List <Product>(); // LOAD PRODUCTS FROM OBJECT GRAPH ONE BY ONE TO MAINTAIN SORT ORDER foreach (int id in ids) { Product p = ProductDataSource.Load(id); showProducts.Add(p); } // DELAYED QUERIES TO EAGER LOAD RELATED DATA if (ids.Count > 0) { var futureQuery = NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .Fetch(p => p.Specials).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .Fetch(p => p.ProductOptions).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .Fetch(p => p.ProductKitComponents).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .AndRestrictionOn(p => p.Id).IsIn(ids) .Fetch(p => p.ProductTemplates).Eager .Future <Product>(); futureQuery.ToList(); } //BIND THE PRODUCTS ProductList.RepeatColumns = this.Columns; ProductList.DataSource = showProducts; ProductList.DataBind(); } else { //THERE ARE NOT ANY ITEMS TO DISPLAY this.Visible = false; } } }
protected void Page_PreRender(object sender, EventArgs e) { List <string> alertList; DateTime cacheDate; CacheWrapper alertWrapper = Cache.Get("AdminAlerts") as CacheWrapper; if (alertWrapper == null) { alertList = new List <string>(); //Check if installation directory still exists if (System.IO.Directory.Exists(Request.MapPath("~/Install"))) { string alertText = "The 'Install' directory still exists in your store. It should be removed immediately after the Installation is complete."; alertList.Add(alertText); } // CHECK IF EMAIL TEMPLATES ARE CONFIGURED, WITHOUT EMAIL SERVER SETTINGS Store store = AbleContext.Current.Store; if ((store.EmailTemplates.Count > 0)) { if (string.IsNullOrEmpty(store.Settings.SmtpServer)) { string alertText = "You have email templates configured, but you have not provided an SMTP (mail) server. Without a serv" + "er, email notifications cannot be sent. <a href=\'Store/EmailTemplates/Settings.aspx\'>Click here</a> to configure " + "email now."; alertList.Add(alertText); } } //VALIDATE ORDER STATUSES //CHECK FOR A STATUS ATTACHED TO THE ORDER PLACED EVENT OrderStatus status = OrderStatusTriggerDataSource.LoadForStoreEvent(StoreEvent.OrderPlaced); if (status == null) { status = new OrderStatus(); status.Name = "Payment Pending"; status.DisplayName = "Payment Pending"; status.IsActive = false; status.IsValid = true; status.Triggers.Add(new OrderStatusTrigger(StoreEvent.OrderPlaced, status)); status.Save(); alertList.Add("You did not have an order status assigned to the 'Order Placed' event, so one was created for you. <a href=\"Store/OrderStatuses/Default.aspx\">Click here</a> to check the order status configuration for your store."); } //CHECK FOR A STATUS ATTACHED TO THE ORDER CANCELLED EVENT status = OrderStatusTriggerDataSource.LoadForStoreEvent(StoreEvent.OrderCancelled); if (status == null) { status = new OrderStatus(); status.Name = "Cancelled"; status.DisplayName = "Cancelled"; status.IsActive = false; status.IsValid = false; status.Triggers.Add(new OrderStatusTrigger(StoreEvent.OrderCancelled, status)); status.Save(); alertList.Add("You did not have an order status assigned to the 'Order Cancelled' event, so one was created for you. <a href=\"Store/OrderStatuses/Default.aspx\">Click here</a> to check the order status configuration for your store."); } //MAKE SURE AT LEAST ONE PRODUCT EXISTS int productCount = ProductDataSource.CountAll(); if (productCount == 0) { alertList.Add("You have not yet added any products in your store. <a href=\"Catalog/Browse.aspx\">Click here</a> to manage your catalog now."); } //MAKE SURE AT LEAST ONE SHIPPING METHOD EXISTS int shipMethodCount = ShipMethodDataSource.CountAll(); if (shipMethodCount == 0) { alertList.Add("You do not have any shipping methods configured. Your customers will not be able to complete checkout if the order contains any shippable products. <a href=\"Shipping/Methods/Default.aspx\">Click here</a> to manage shipping methods now."); } //CHECK FOR LOW INVENTORY PRODUCTS int lowInventoryProducts = ProductInventoryDataSource.GetLowProductInventoryCount(); if (lowInventoryProducts > 0) { alertList.Add("One or more products are at or below their low inventory warning level. You can view these products <a href=\"Reports/LowInventory.aspx\">here</a>."); } //CHECK FOR PRESENCE OF ERRORS int errorCount = ErrorMessageDataSource.CountAll(); if (errorCount > 0) { string errorAlert = string.Format("There are {0} messages in your <a href=\"Help/ErrorLog.aspx\">error log</a>. You should review these messages and take corrective action if necessary.", errorCount); alertList.Add(errorAlert); } //Check of SSL is not enabled StoreSettingsManager storeSettings = AbleContext.Current.Store.Settings; if (!storeSettings.SSLEnabled) { string alertText = "SSL is not enabled. Your store is currently being accessed over an insecure connection. <a href=\"Store/Security/Default.aspx\">Click Here</a> to change SSL settings."; alertList.Add(alertText); } //MAKE SURE ORDER NUMBER INCREMENT IS VALID if (store.OrderIdIncrement < 1) { string alertText = "The order number increment for your store was " + store.OrderIdIncrement + " (invalid). The increment has been updated to 1. <a href=\"Store/StoreSettings.aspx\">Click Here</a> to review this setting."; alertList.Add(alertText); store.OrderIdIncrement = 1; store.Save(); } //ALERT FOR ORDER NUMBER PROBLEM int maxOrderNumber = StoreDataSource.GetMaxOrderNumber(); int nextOrderNumber = StoreDataSource.GetNextOrderNumber(false); if (maxOrderNumber >= nextOrderNumber) { int newOrderNumber = maxOrderNumber + store.OrderIdIncrement; StoreDataSource.SetNextOrderNumber(newOrderNumber); string alertText = "The next order number of {0} is less than the highest assigned order number of {1}. We have automatically increased your next order number to {2} to prevent errors. <a href=\"Store/StoreSettings.aspx\">Click Here</a> to review this setting."; alertList.Add(string.Format(alertText, nextOrderNumber, maxOrderNumber, newOrderNumber)); } //MAKE SURE A VALID ENCRYPTION KEY IS PRESENT bool encryptionKeyValid; try { encryptionKeyValid = EncryptionKeyManager.IsKeyValid(EncryptionKeyManager.Instance.CurrentKey.KeyData); } catch { encryptionKeyValid = false; } if (!encryptionKeyValid) { //ENCRYPTION KEY IS MISSING OR INVALID, SEE WHETHER WE ARE STORING CARD DATA if (storeSettings.EnableCreditCardStorage) { string alertText = "Your store encryption key is missing or invalid, and you have not disabled storage of card data. You should either <a href=\"Store/Security/EncryptionKey.aspx\">set the encryption key</a> or <a href=\"Store/Security/Default.aspx\">disable credit card storage</a>."; alertList.Add(alertText); } } // ALERT FOR PRODUCT IMAGE LOOKUP BY SKU if (storeSettings.ImageSkuLookupEnabled) { // SEARCH FOR PRODUCTS MISSING SKU AND MISSING IMAGE URLs ICriteria productCriteria = NHibernateHelper.CreateCriteria <Product>() .Add(new Disjunction() .Add(Restrictions.IsNull("Sku")) .Add(Restrictions.Eq("Sku", string.Empty))) .Add(new Disjunction() .Add(Restrictions.IsNull("ImageUrl")) .Add(Restrictions.IsNull("IconUrl")) .Add(Restrictions.IsNull("ThumbnailUrl"))) .Add(Restrictions.Eq("VisibilityId", (byte)CatalogVisibility.Public)); IList <Product> products = ProductDataSource.LoadForCriteria(productCriteria); if (products != null && products.Count > 0) { StringBuilder textBuilder = new StringBuilder(); textBuilder.Append("Following product(s) are missing SKU, and also do not have image paths provided:<br/>"); textBuilder.Append("<ul>"); int counter = 0; // PRODUCT COUNTER, SHOW ONLY FIRST FIVE PRODUCTS foreach (Product product in products) { counter++; textBuilder.Append("<li><a href=\"products/EditProduct.aspx?ProductId=" + product.Id + "\">" + product.Name + "</a>.</li>"); if (counter >= 5) { break; } } textBuilder.Append("<ul>"); alertList.Add(textBuilder.ToString()); } } // LOOK FOR UNREAD NOTES ICriteria orderNoteCriteria = NHibernateHelper.CreateCriteria <OrderNote>() .Add(Restrictions.Eq("IsRead", false)) .Add(Restrictions.Not(Restrictions.Eq("NoteTypeId", (byte)NoteType.SystemPublic))) .Add(Restrictions.Not(Restrictions.Eq("NoteTypeId", (byte)NoteType.SystemPrivate))); int unreadNoteCount = OrderNoteDataSource.CountForCriteria(orderNoteCriteria); if (unreadNoteCount > 0) { string alertText = "There are {0} unread order note(s). <a href=\"Orders/OrderNotesManager.aspx\">review now</a>"; alertList.Add(string.Format(alertText, unreadNoteCount)); } // CHECK ANON USER MAINTENANCE SETTINGS if (store.Settings.AnonymousUserLifespan < 1 || store.Settings.AnonymousAffiliateUserLifespan < 1) { alertList.Add("You have not configured the number of days to save anonymous user records. You should visit the <a href=\"Store/Maintenance.aspx\">Configure > Maintenance</a> menu, view the status of the anonymous user database, and update your anonymous user maintenance settings."); } // ALERT FOR DUPLICATE COUPON CODES IList <Coupon> duplicateCoupons = NHibernateHelper.CreateSQLQuery("SELECT * FROM ac_Coupons WHERE CouponCode IN (SELECT LOWER(CouponCode) FROM ac_Coupons GROUP BY CouponCode HAVING COUNT(*) > 1)").AddEntity(typeof(Coupon)).List <Coupon>(); if (duplicateCoupons.Count > 0) { Dictionary <string, List <Coupon> > codeCounts = new Dictionary <string, List <Coupon> >(); foreach (Coupon coupon in duplicateCoupons) { string normalizedKey = coupon.CouponCode.ToUpperInvariant(); if (!codeCounts.ContainsKey(normalizedKey)) { codeCounts[normalizedKey] = new List <Coupon>(); } codeCounts[normalizedKey].Add(coupon); } StringBuilder alertText = new StringBuilder(); alertText.Append("<p>You have coupons that have duplicate codes. Duplicates should be eliminated as a unique constraint will be applied in a future release:</p>"); foreach (string couponCode in codeCounts.Keys) { alertText.Append("<p><b>" + couponCode + ":</b> "); string delimiter = string.Empty; foreach (Coupon coupon in codeCounts[couponCode]) { alertText.Append(delimiter); alertText.Append("<a href=\"Marketing/Coupons/EditCoupon.aspx?CouponId=" + coupon.Id + "\">" + coupon.Name + "</a>"); delimiter = ", "; } alertText.Append("</p>"); } alertList.Add(alertText.ToString()); } //UPDATE CACHE alertWrapper = new CacheWrapper(alertList); Cache.Remove("AdminAlerts"); Cache.Add("AdminAlerts", alertWrapper, null, DateTime.UtcNow.AddMinutes(15), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } else { alertList = (List <string>)alertWrapper.CacheValue; } cacheDate = alertWrapper.CacheDate; if (alertList.Count == 0) { alertList.Add("no action items available"); } AlertList.DataSource = alertList; AlertList.DataBind(); CachedAt.Text = string.Format("{0:g}", cacheDate); }