我有一个页面可以运行一段时间内的销售报告。当我用大约88笔交易运行一个月时,它需要一段时间,但我现在可以忍受它。 问题是,当我尝试运行页面一年或超过3个月时,它需要大约30分钟,然后进入错误页面说" cms.kics.com.au不工作..它没有发送任何数据.. .err_empty_response&#34 ;. ] 首先想到的是,有太多的数据要返回,并且它的时间超出了请求。 我已经增加了web.config中的执行时间以及页面超时但没有运气。
<httpRuntime maxRequestLength="409600" executionTimeout="720" />
Page.Server.ScriptTimeout = 3600;
我也尝试在每次进入转发器时刷新数据但是没有做任何事情。
代码behide计算数据范围的总计工作正常但是当它使用已售出的所有产品填充salesrepeater时,我会超时。
有没有办法解决这个问题? 我想可能是一个在后台运行的存储过程,它计算所有产品和转发器的总数,只输出每个项目。 3个月的销售额可以达到300-400。
请参阅以下代码。
protected void BtnFilter_Click(object sender, EventArgs e)
{
if (StartDate.SelectedDate == null && FinishDate.SelectedDate == null)
return;
startDate = DateTime.Parse(StartDate.SelectedDate.ToString()).Date;
endDate = DateTime.Parse(FinishDate.SelectedDate.ToString()).Date;
DateTime now = DAL.TimeZoneConversion.ConvertDateTime(DateTime.UtcNow, thisShop.Company.TimeZoneLocationID);
CurrentDateTimeLiteral.Text = now.ToString() + " (" + thisShop.Company.TimeZoneLocationID + ")";
DateRangeLiteral.Text = startDate.ToShortDateString() + " - " + endDate.ToShortDateString();
TaxTypeLiteral.Text = thisShop.TaxName;
TaxTypeLiteral2.Text = thisShop.TaxName;
TaxTypeLiteral3.Text = thisShop.TaxName;
TaxTypeLiteral4.Text = thisShop.TaxName;
TaxTypeLiteral5.Text = thisShop.TaxName;
TaxTypeLiteral6.Text = thisShop.TaxName;
TaxTypeLiteral7.Text = thisShop.TaxName;
TaxTypeLiteral8.Text = thisShop.TaxName;
TaxTypeLiteral9.Text = thisShop.TaxName;
IObjectScope scope = ORM.ScopeFactory.GetPerRequestScope(HttpContext.Current);
decimal totalPAmount = 0;
decimal totalPTax = 0;
decimal totalDAmount = 0;
decimal totalDTax = 0;
decimal totalAmount = 0;
decimal totalTax = 0;
var shopOrders = (from shopOrder in scope.Extent<ORM.Shoporder>()
where shopOrder.ShopId == shopId &&
shopOrder.CreateDateTime.Date >= startDate && shopOrder.CreateDateTime.Date <= endDate && shopOrder.IsDeleted == false &&
(shopOrder.IsReceiptSent == true || shopOrder.IsReceiptSkipped == true)
orderby shopOrder.CreateDateTime descending
select shopOrder);
foreach (ORM.Shoporder thisShopOrder in shopOrders.ToList())
{
decimal orderTotal = thisShopOrder.TotalCostIncludingTax; //DAL.DataClasses.ShopOrder.CalculateOrderTotal(thisShopOrder.ShopOrderId);
totalAmount += thisShopOrder.TotalCostIncludingTax;
totalTax += thisShopOrder.TotalTaxCost;
totalPAmount += thisShopOrder.ProductCostIncludingTax;
totalPTax += thisShopOrder.ProductTaxCost;
totalDAmount += thisShopOrder.DeliveryCostIncludingTax;
totalDTax += thisShopOrder.DeliveryTaxCost;
}
TotalLiteral.Text = totalAmount.ToString("C");
TotalTaxLiteral.Text = totalTax.ToString("C");
TotalDLiteral.Text = totalDAmount.ToString("C");
TotalDTaxLiteral.Text = totalDTax.ToString("C");
TotalPLiteral.Text = totalPAmount.ToString("C");
TotalPTaxLiteral.Text = totalPTax.ToString("C");
ReportDiv.Visible = true;
Populate();
}
private void Populate()
{
IObjectScope scope = ORM.ScopeFactory.GetPerRequestScope(HttpContext.Current);
var result = from o in scope.Extent<ORM.Shopproductvariationprice>()
where o.Shopproduct.Shopcategory.ShopId == shopId
orderby o.Name, o.PriceIncludingTax
select o;
SaleRepeater.DataSource = result.ToList();
SaleRepeater.DataBind();
}
protected void SaleRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
IObjectScope scope = ORM.ScopeFactory.GetPerRequestScope(HttpContext.Current);
RepeaterItem item = e.Item;
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
{
ORM.Shopproductvariationprice thisPrice = (ORM.Shopproductvariationprice)item.DataItem;
Literal ProductNameLiteral = (Literal)item.FindControl("ProductNameLiteral");
Literal ProductCountLiteral = (Literal)item.FindControl("ProductCountLiteral");
Literal ProductAmountIncludingTaxLiteral = (Literal)item.FindControl("ProductAmountIncludingTaxLiteral");
Literal ProductAmountExcludingTaxLiteral = (Literal)item.FindControl("ProductAmountExcludingTaxLiteral");
Literal ProductTaxLiteral = (Literal)item.FindControl("ProductTaxLiteral");
int productCount = 0;
decimal productAmount = 0;
decimal productTax = 0;
ProductNameLiteral.Text = thisPrice.Name;
var shopOrders = (from shopOrder in scope.Extent<ORM.Shoporder>()
where shopOrder.ShopId == shopId &&
shopOrder.CreateDateTime.Date >= startDate && shopOrder.CreateDateTime.Date <= endDate && shopOrder.IsDeleted == false &&
(shopOrder.IsReceiptSent == true || shopOrder.IsReceiptSkipped == true)
orderby shopOrder.CreateDateTime descending
select shopOrder);
foreach (ORM.Shoporder thisShopOrder in shopOrders.ToList())
{
foreach (ORM.Shoporderproduct thisShopOrderProduct in DAL.DataClasses.ShopOrder.GetProductsInOrder(thisShopOrder.ShopOrderId))
{
if (thisShopOrderProduct.ShopProductVariationPriceId == thisPrice.ShopProductVariationPriceId)
{
productCount += thisShopOrderProduct.Quantity;
productAmount += (thisShopOrderProduct.Quantity * thisShopOrderProduct.Shopproductvariationprice.PriceIncludingTax);
if (thisShopOrderProduct.Shopproductvariationprice.Shopproduct.IsTaxable)
{
decimal taxRate = 100 + thisShop.TaxPercent;
decimal thisProductPriceExcludingTax = thisShopOrderProduct.Shopproductvariationprice.PriceIncludingTax * 100;
thisProductPriceExcludingTax = thisProductPriceExcludingTax / taxRate;
decimal thisProductTax = thisShopOrderProduct.Shopproductvariationprice.PriceIncludingTax - thisProductPriceExcludingTax;
productTax += (thisShopOrderProduct.Quantity * thisProductTax);
}
}
}
}
ProductCountLiteral.Text = productCount.ToString();
ProductAmountIncludingTaxLiteral.Text = productAmount.ToString("C");
ProductAmountExcludingTaxLiteral.Text = (productAmount - productTax).ToString("C");
ProductTaxLiteral.Text = productTax.ToString("C");
totalProductAmount += productAmount;
totalProductTax += productTax;
totalItemsSold += productCount;
Response.Flush();
}
if (item.ItemType == ListItemType.Footer)
{
Literal TotalCountLiteral = (Literal)item.FindControl("TotalCountLiteral");
Literal TotalAmountIncludingTaxLiteral = (Literal)item.FindControl("TotalAmountIncludingTaxLiteral");
Literal TotalAmountExcludingTaxLiteral = (Literal)item.FindControl("TotalAmountExcludingTaxLiteral");
Literal TotalTaxLiteral = (Literal)item.FindControl("TotalTaxLiteral");
TotalCountLiteral.Text = totalItemsSold.ToString();
TotalAmountIncludingTaxLiteral.Text = totalProductAmount.ToString("C");
TotalAmountExcludingTaxLiteral.Text = (totalProductAmount - totalProductTax).ToString("C");
TotalTaxLiteral.Text = totalProductTax.ToString("C");
}
}
}