private string GetLink(string content, int generalId) { if (this.m_InsideStaticlabel == null) { this.m_InsideStaticlabel = new InsideStaticLabel(); } if (generalId == 0) { return(content); } return(("<a href='" + this.m_InsideStaticlabel.GetInfoPath(generalId.ToString()) + "'target='_blank' title='立刻购买' >") + content + "</a>"); }
protected void RptShoppingCart_ItemDataBound(object sender, RepeaterItemEventArgs e) { ShopConfig shopConfig = SiteConfig.ShopConfig; if ((e.Item.ItemType != ListItemType.Item) && (e.Item.ItemType != ListItemType.AlternatingItem)) { goto Label_07BA; } int productNum = 0; string str = ""; string str2 = ""; decimal subTotal = 0M; ((CheckBox)e.Item.FindControl("ChkProductId")).Checked = true; ShoppingCartInfo dataItem = e.Item.DataItem as ShoppingCartInfo; if (dataItem == null) { goto Label_07BA; } productNum = dataItem.Quantity; ((TextBox)e.Item.FindControl("TxtProductAmount")).Text = productNum.ToString(); bool haveWholesalePurview = false; if (PEContext.Current.User.PurviewInfo != null) { haveWholesalePurview = PEContext.Current.User.PurviewInfo.Enablepm; } str2 = ShoppingCart.GetSaleType(dataItem.ProductInfomation, productNum, haveWholesalePurview); str = ShoppingCart.GetProductType(dataItem.ProductInfomation, productNum, haveWholesalePurview); AbstractItemInfo info2 = new ConcreteProductInfo(productNum, dataItem.Property, dataItem.ProductInfomation, PEContext.Current.User.UserInfo, false, false, haveWholesalePurview); info2.GetItemInfo(); subTotal = info2.SubTotal; this.total += subTotal; if (!string.IsNullOrEmpty(dataItem.Property)) { ((Literal)e.Item.FindControl("LitProperty")).Text = "(" + info2.Property + ")"; } ProductInfo productById = Product.GetProductById(dataItem.ProductId); if (productById.Minimum > 0) { ((Literal)e.Item.FindControl("LblMark")).Text = "(<font color=\"red\">最低购买量" + productById.Minimum.ToString() + "</font>)"; } InsideStaticLabel label = new InsideStaticLabel(); string str3 = "<a href='"; str3 = (str3 + label.GetInfoPath(info2.ProductId.ToString())) + "' Target='_blank'>" + info2.ProductName + "</a>"; ((Literal)e.Item.FindControl("LitProductName")).Text = str3; ((Literal)e.Item.FindControl("LitProductUnit")).Text = info2.Unit; ((Literal)e.Item.FindControl("LitTruePrice")).Text = info2.Price.ToString("0.00"); ((Literal)e.Item.FindControl("LitSubTotal")).Text = subTotal.ToString("0.00"); ExtendedImage image = (ExtendedImage)e.Item.FindControl("extendedImage"); ExtendedImage image2 = (ExtendedImage)e.Item.FindControl("extendedPresentImage"); Control control = e.Item.FindControl("ProductImage"); Control control2 = e.Item.FindControl("presentImage"); if (!shopConfig.IsGwcShowProducdtThumb) { image.Visible = false; control.Visible = false; control2.Visible = false; } else { if (!string.IsNullOrEmpty(dataItem.ProductInfomation.ProductThumb)) { image.Src = dataItem.ProductInfomation.ProductThumb; } else { image.Src = SiteConfig.SiteInfo.VirtualPath + "Images/nopic.gif"; } image.ImageHeight = shopConfig.GwcThumbsHeight; image.ImageWidth = shopConfig.GwcThumbsWidth; if (dataItem.ProductInfomation.PresentId > 0) { PresentInfo presentById = Present.GetPresentById(dataItem.ProductInfomation.PresentId); if (!string.IsNullOrEmpty(presentById.PresentThumb)) { image2.Src = presentById.PresentThumb; } else { image2.Src = SiteConfig.SiteInfo.VirtualPath + "Images/nopic.gif"; } image2.ImageHeight = shopConfig.GwcThumbsHeight; image2.ImageWidth = shopConfig.GwcThumbsWidth; } } if (!shopConfig.IsShowGwcProductType) { e.Item.FindControl("tdProductType").Visible = false; } else { ((Literal)e.Item.FindControl("LitProductType")).Text = str; } if (!shopConfig.IsShowGwcSaleType) { e.Item.FindControl("tdSaleType").Visible = false; } else { ((Literal)e.Item.FindControl("LitSaleType")).Text = str2; } if (!shopConfig.IsShowGwcMarkPrice) { e.Item.FindControl("tdMarkPrice").Visible = false; } else { ((Literal)e.Item.FindControl("LitPriceMarket")).Text = info2.PriceMarket.ToString("0.00"); } if (((dataItem.ProductInfomation.SalePromotionType <= 0) || (productNum < dataItem.ProductInfomation.MinNumber)) || dataItem.IsPresent) { goto Label_07BA; } e.Item.FindControl("PresentInfomation").Visible = true; string str4 = ""; string str5 = ""; string str6 = ""; int productId = 0; AbstractItemInfo info5 = new ConcreteSalePromotionType(productNum, dataItem.ProductInfomation, false, null); info5.GetItemInfo(); switch (dataItem.ProductInfomation.SalePromotionType) { case 1: case 3: str5 = "<font color=red>(赠品)</font>"; str4 = "赠送礼品"; str6 = "赠送"; productId = info5.Id; goto Label_05B2; case 2: case 4: if (info5.Price <= 0M) { str5 = "<font color=red>(赠送赠品)</font>"; str6 = "赠送"; break; } str5 = "<font color=red>(换购赠品)</font>"; str6 = "换购"; break; default: goto Label_05B2; } str4 = "促销礼品"; productId = info5.Id; Label_05B2: ((HiddenField)e.Item.FindControl("HdnPresentId")).Value = productId.ToString(); ((Literal)e.Item.FindControl("LitPresentName")).Text = info5.ProductName + str5; ((Literal)e.Item.FindControl("LitPresentUnit")).Text = info5.Unit; ((Literal)e.Item.FindControl("LitPresentNum")).Text = info5.Amount.ToString(); ((Literal)e.Item.FindControl("LitPresentTruePrice")).Text = info5.Price.ToString("0.00"); ((Literal)e.Item.FindControl("LitPresentSubtotal")).Text = info5.SubTotal.ToString("0.00"); if (this.PresentExist(this.cartId, productId)) { ((CheckBox)e.Item.FindControl("ChkPresentId")).Checked = true; this.total += info5.SubTotal; } if (!shopConfig.IsShowGwcProductType) { e.Item.FindControl("tdPresentType").Visible = false; } else { ((Literal)e.Item.FindControl("LitPresentType")).Text = str4; } if (!shopConfig.IsShowGwcSaleType) { e.Item.FindControl("tdPresentSaleType").Visible = false; } else { ((Literal)e.Item.FindControl("LitPresentSaleType")).Text = str6; } if (!shopConfig.IsShowGwcMarkPrice) { e.Item.FindControl("tdPresentMarkPrice").Visible = false; } else { ((Literal)e.Item.FindControl("LitPresentPriceMarket")).Text = info5.PriceMarket.ToString("0.00"); } Label_07BA: if (e.Item.ItemType == ListItemType.Header) { Control control9 = e.Item.FindControl("ProductImageTitle"); Control control10 = e.Item.FindControl("tdProductTypeTitle"); Control control11 = e.Item.FindControl("tdSaleTypeTitle"); Control control12 = e.Item.FindControl("tdMarkPriceTitle"); if (!shopConfig.IsGwcShowProducdtThumb) { control9.Visible = false; } if (!shopConfig.IsShowGwcProductType) { control10.Visible = false; } if (!shopConfig.IsShowGwcSaleType) { control11.Visible = false; } if (!shopConfig.IsShowGwcMarkPrice) { control12.Visible = false; } } if (e.Item.ItemType == ListItemType.Footer) { Control control13 = e.Item.FindControl("footerTdThemeImage"); Control control14 = e.Item.FindControl("footerTdProductType"); Control control15 = e.Item.FindControl("footerTdSaleType"); Control control16 = e.Item.FindControl("footerTdMarkPrice"); if (!shopConfig.IsGwcShowProducdtThumb) { control13.Visible = false; } if (!shopConfig.IsShowGwcProductType) { control14.Visible = false; } if (!shopConfig.IsShowGwcSaleType) { control15.Visible = false; } if (!shopConfig.IsShowGwcMarkPrice) { control16.Visible = false; } } }
protected void RptShoppingCart_ItemDataBound(object sender, RepeaterItemEventArgs e) { ShopConfig shopConfig = SiteConfig.ShopConfig; bool isPaymentShowProducdtThumb = true; int paymentThumbsWidth = 0; int paymentThumbsHeight = 0; bool isShowPaymentProductType = true; bool isShowPaymentSaleType = true; bool isShowPaymentMarkPrice = true; if (this.IsPreview == 0) { isPaymentShowProducdtThumb = shopConfig.IsPaymentShowProducdtThumb; isShowPaymentProductType = shopConfig.IsShowPaymentProductType; isShowPaymentSaleType = shopConfig.IsShowPaymentSaleType; isShowPaymentMarkPrice = shopConfig.IsShowPaymentMarkPrice; paymentThumbsWidth = shopConfig.PaymentThumbsWidth; paymentThumbsHeight = shopConfig.PaymentThumbsHeight; } else if (this.IsPreview == 1) { isPaymentShowProducdtThumb = shopConfig.IsPreviewShowProducdtThumb; isShowPaymentProductType = shopConfig.IsShowPreviewProductType; isShowPaymentSaleType = shopConfig.IsShowPreviewSaleType; isShowPaymentMarkPrice = shopConfig.IsShowPreviewMarkPrice; paymentThumbsWidth = shopConfig.PreviewThumbsWidth; paymentThumbsHeight = shopConfig.PreviewThumbsHeight; } if ((e.Item.ItemType != ListItemType.Item) && (e.Item.ItemType != ListItemType.AlternatingItem)) { if (e.Item.ItemType == ListItemType.Footer) { PresentProjectInfo presentProInfo = new PresentProjectInfo(true); if (this.m_IsPreview != 3) { presentProInfo = PresentProject.GetPresentProjectByTotalMoney(this.total); this.presentExpInfomation = this.ShowPresentExp(presentProInfo).ToString(); } if (this.m_IsPreview == 1) { int presentId = DataConverter.CLng(this.PresentId); PlaceHolder holder = (PlaceHolder)e.Item.FindControl("PlhPresentInfo"); holder.Visible = false; if (((presentId > 0) && !presentProInfo.IsNull) && (presentProInfo.PresentContent.Contains("1") && (presentId > 0))) { holder.Visible = true; AbstractItemInfo info7 = new ConcretePresentProject(presentId, presentProInfo); info7.GetItemInfo(); Label label2 = (Label)e.Item.FindControl("LblProductName"); Label label3 = (Label)e.Item.FindControl("LblUnit"); Label label4 = (Label)e.Item.FindControl("LblPresentPriceMarket"); Label label5 = (Label)e.Item.FindControl("LblPresentPrice"); Label label6 = (Label)e.Item.FindControl("LblPresentPrice1"); label2.Text = info7.ProductName; label3.Text = info7.Unit; label4.Text = info7.PriceMarket.ToString("0.00"); label5.Text = info7.Price.ToString("0.00"); label6.Text = info7.Price.ToString("0.00"); this.weight += info7.TotalWeight; this.total += info7.Price; } ((PlaceHolder)e.Item.FindControl("PlhMoneyInfo")).Visible = true; Label label7 = (Label)e.Item.FindControl("LblDeliverCharge"); Label label8 = (Label)e.Item.FindControl("LblTaxRate"); Label label9 = (Label)e.Item.FindControl("LblIncludeTax"); Label label10 = (Label)e.Item.FindControl("LblCoupon"); Label label11 = (Label)e.Item.FindControl("LblTotalMoney"); Label label12 = (Label)e.Item.FindControl("LblTrueTotalMoney"); PackageInfo packageByGoodsWeight = Package.GetPackageByGoodsWeight(this.weight); if (!packageByGoodsWeight.IsNull) { this.weight += packageByGoodsWeight.PackageWeight; } decimal num7 = DeliverCharge.GetDeliverCharge(this.m_DeliverType, this.weight, this.m_ZipCode, this.total, this.m_NeedInvoice); DeliverTypeInfo deliverTypeById = EasyOne.Shop.DeliverType.GetDeliverTypeById(this.m_DeliverType); label7.Text = num7.ToString("0.00"); label8.Text = deliverTypeById.TaxRate.ToString(); if ((deliverTypeById.IncludeTax == TaxRateType.IncludeTaxNoInvoiceFavourable) || (deliverTypeById.IncludeTax == TaxRateType.IncludeTaxNoInvoiceNoFavourable)) { label9.Text = "是"; } else { label9.Text = "否"; } decimal num8 = this.total + num7; if (this.m_CouponMoney > 0M) { label10.Visible = true; decimal num9 = this.total - this.m_CouponMoney; if (num9 < 0M) { num9 = 0M; } num8 = num9 + num7; label10.Text = "使用优惠券,面值为:" + this.m_CouponMoney.ToString("0.00") + "元,商品实际价格为:" + num9.ToString("0.00") + "元 <br>"; label11.Text = num9.ToString("0.00") + "+" + num7.ToString("0.00") + "=" + num8.ToString("0.00") + "元"; label12.Text = num8.ToString("0.00"); } else { label10.Visible = false; label11.Text = this.total.ToString("0.00") + "+" + num7.ToString("0.00") + "=" + num8.ToString("0.00") + "元"; label12.Text = num8.ToString("0.00"); } this.ViewState["TrueTotalMoney"] = num8; } else { ((PlaceHolder)e.Item.FindControl("PlhMoneyInfo")).Visible = false; } ExtendedImage image3 = (ExtendedImage)e.Item.FindControl("presentImage"); Control control9 = e.Item.FindControl("footerPresentImage"); Control control10 = e.Item.FindControl("footerTdThemeImage"); Control control11 = e.Item.FindControl("footerTdProductType"); Control control12 = e.Item.FindControl("footerTdSaleType"); Control control13 = e.Item.FindControl("footerTdMarkPrice"); Control control14 = e.Item.FindControl("footerTdThemeImage"); Control control15 = e.Item.FindControl("footerTdMoneyInfoSaleType"); Control control16 = e.Item.FindControl("footerTdMoneyInfoMarkPrice"); Control control17 = e.Item.FindControl("footerPresentType"); Control control18 = e.Item.FindControl("footerPresentSaleType"); Control control19 = e.Item.FindControl("footerPresentMarkPrice"); if (!isPaymentShowProducdtThumb) { control10.Visible = false; control9.Visible = false; } else { PresentInfo presentById = Present.GetPresentById(DataConverter.CLng(this.PresentId)); if (!string.IsNullOrEmpty(presentById.PresentThumb)) { image3.Src = presentById.PresentThumb; } else { image3.Src = SiteConfig.SiteInfo.VirtualPath + "Images/nopic.gif"; } image3.Width = paymentThumbsWidth; image3.Height = paymentThumbsHeight; } if (!isShowPaymentProductType) { control11.Visible = false; control14.Visible = false; control17.Visible = false; } if (!isShowPaymentSaleType) { control12.Visible = false; control15.Visible = false; control18.Visible = false; } if (!isShowPaymentMarkPrice) { control13.Visible = false; control16.Visible = false; control19.Visible = false; return; } } else if (e.Item.ItemType == ListItemType.Header) { Control control20 = e.Item.FindControl("ProductImageTitle"); Control control21 = e.Item.FindControl("tdProductTypeTitle"); Control control22 = e.Item.FindControl("tdSaleTypeTitle"); Control control23 = e.Item.FindControl("tdMarkPriceTitle"); if (!isPaymentShowProducdtThumb) { control20.Visible = false; } if (!isShowPaymentProductType) { control21.Visible = false; } if (!isShowPaymentSaleType) { control22.Visible = false; } if (!isShowPaymentMarkPrice) { control23.Visible = false; } } return; } int productNum = 0; string str = ""; string str2 = ""; decimal subTotal = 0M; ShoppingCartInfo dataItem = (ShoppingCartInfo)e.Item.DataItem; if (dataItem == null) { return; } productNum = dataItem.Quantity; bool haveWholesalePurview = Convert.ToBoolean(this.ViewState["HaveWholesalePurview"]); str2 = ShoppingCart.GetSaleType(dataItem.ProductInfomation, productNum, haveWholesalePurview); str = ShoppingCart.GetProductType(dataItem.ProductInfomation, productNum, haveWholesalePurview); AbstractItemInfo info2 = new ConcreteProductInfo(productNum, dataItem.Property, dataItem.ProductInfomation, this.m_UserInfo, false, false, haveWholesalePurview); info2.GetItemInfo(); subTotal = info2.SubTotal; this.total += subTotal; this.totalExp += dataItem.ProductInfomation.PresentExp * productNum; this.totalMoney += dataItem.ProductInfomation.PresentMoney * productNum; this.totalPoint += dataItem.ProductInfomation.PresentPoint * productNum; this.weight += info2.TotalWeight; if (!string.IsNullOrEmpty(dataItem.Property)) { ((Literal)e.Item.FindControl("LitProperty")).Text = "(" + info2.Property + ")"; } InsideStaticLabel label = new InsideStaticLabel(); string str3 = "<a href='"; str3 = (str3 + label.GetInfoPath(info2.ProductId.ToString())) + "' Target='_blank'>" + info2.ProductName + "</a>"; ((Literal)e.Item.FindControl("LitProductName")).Text = str3; ((Literal)e.Item.FindControl("LitProductUnit")).Text = info2.Unit; ((Literal)e.Item.FindControl("LitTruePrice")).Text = info2.Price.ToString("0.00"); ((Literal)e.Item.FindControl("LitSubTotal")).Text = subTotal.ToString("0.00"); ExtendedImage image = (ExtendedImage)e.Item.FindControl("extendedImage"); ExtendedImage image2 = (ExtendedImage)e.Item.FindControl("extendedPresentImage"); Control control = e.Item.FindControl("ProductImage"); Control control2 = e.Item.FindControl("presentImage"); if (!isPaymentShowProducdtThumb) { image.Visible = false; control.Visible = false; control2.Visible = false; } else { if (!string.IsNullOrEmpty(dataItem.ProductInfomation.ProductThumb)) { image.Src = dataItem.ProductInfomation.ProductThumb; } else { image.Src = SiteConfig.SiteInfo.VirtualPath + "Images/nopic.gif"; } image.ImageHeight = paymentThumbsHeight; image.ImageWidth = paymentThumbsWidth; if (dataItem.ProductInfomation.PresentId > 0) { PresentInfo info3 = Present.GetPresentById(dataItem.ProductInfomation.PresentId); if (!string.IsNullOrEmpty(info3.PresentThumb)) { image2.Src = info3.PresentThumb; } else { image2.Src = SiteConfig.SiteInfo.VirtualPath + "Images/nopic.gif"; } image2.ImageHeight = paymentThumbsHeight; image2.ImageWidth = paymentThumbsWidth; } } if (!isShowPaymentProductType) { e.Item.FindControl("tdProductType").Visible = false; } else { ((Literal)e.Item.FindControl("LitProductType")).Text = str; } if (!isShowPaymentSaleType) { e.Item.FindControl("tdSaleType").Visible = false; } else { ((Literal)e.Item.FindControl("LitSaleType")).Text = str2; } if (!isShowPaymentMarkPrice) { e.Item.FindControl("tdMarkPrice").Visible = false; } else { ((Literal)e.Item.FindControl("LitPriceMarket")).Text = info2.PriceMarket.ToString("0.00"); } int num5 = Order.CountBuyNum(PEContext.Current.User.UserName, dataItem.ProductId); ProductInfo productById = Product.GetProductById(dataItem.ProductId); if ((productById.LimitNum > 0) && ((dataItem.Quantity + num5) > productById.LimitNum)) { BaseUserControl.WriteErrMsg(string.Concat(new object[] { "您订购了", num5, productById.Unit, productById.ProductName, ",曾经购买了", num5, productById.Unit, ",而此商品每人限购数量为", productById.LimitNum, productById.Unit, ",请重新调整您的购物车!" }), "ShoppingCart.aspx"); } if ((dataItem.ProductInfomation.SalePromotionType <= 0) || (productNum < dataItem.ProductInfomation.MinNumber)) { return; } e.Item.FindControl("PresentInfomation").Visible = true; string str4 = ""; string str5 = ""; string str6 = ""; AbstractItemInfo info5 = new ConcreteSalePromotionType(productNum, dataItem.ProductInfomation, false, null); info5.GetItemInfo(); switch (dataItem.ProductInfomation.SalePromotionType) { case 1: case 3: str5 = "<font color=red>(赠品)</font>"; str4 = "赠送礼品"; str6 = "赠送"; goto Label_06A1; case 2: case 4: if (info5.Price <= 0M) { str5 = "<font color=red>(赠送赠品)</font>"; str6 = "赠送"; break; } str5 = "<font color=red>(换购赠品)</font>"; str6 = "换购"; break; default: goto Label_06A1; } str4 = "促销礼品"; Label_06A1: if (this.PresentExist(this.m_CartId, info5.Id)) { ((HiddenField)e.Item.FindControl("HdnPresentId")).Value = info5.Id.ToString(); ExtendedLiteral literal = (ExtendedLiteral)e.Item.FindControl("LitPresentName"); literal.Text = info5.ProductName; literal.EndTag = str5; ((Literal)e.Item.FindControl("LitPresentUnit")).Text = info5.Unit; ((Literal)e.Item.FindControl("LitPresentNum")).Text = info5.Amount.ToString(); ((Literal)e.Item.FindControl("LitPresentTruePrice")).Text = info5.Price.ToString("0.00"); ((Literal)e.Item.FindControl("LitPresentSubtotal")).Text = info5.SubTotal.ToString("0.00"); this.total += info5.SubTotal; this.weight += info5.TotalWeight; } if (!isShowPaymentProductType) { e.Item.FindControl("tdPresentType").Visible = false; } else { ((Literal)e.Item.FindControl("LitPresentType")).Text = str4; } if (!isShowPaymentSaleType) { e.Item.FindControl("tdPresentSaleType").Visible = false; } else { ((Literal)e.Item.FindControl("LitPresentSaleType")).Text = str6; } if (!isShowPaymentMarkPrice) { e.Item.FindControl("tdPresentMarkPrice").Visible = false; } else { ((Literal)e.Item.FindControl("LitPresentPriceOriginal")).Text = info5.PriceMarket.ToString("0.00"); } }
public static string CreateCode(int dbId, string tableName, string templateFile) { var sw = new Stopwatch(); sw.Start(); var config = ConfigHelper.GetConfig <AppConfig>(); var con = FormDbService.GetConnectionString(dbId); var template = BuildManager.CreateTemplate(templateFile); #region 表实体 var className = tableName.Contains("_") ? tableName.Substring(tableName.LastIndexOf("_", StringComparison.Ordinal) + 1) : tableName; var classChineseName = SqlserverHelper.GetTableNote(con, tableName); var tableInfo = new TableInfo { TableNote = classChineseName, ClassName = className, TableName = tableName }; #endregion #region 字段 var fieldList = SqlserverHelper.GetFieldInfoList(con, tableName); var list = new List <FieldInfo>(); var except = config.ExceptFields ?? ""; var excepts = except.Replace(",", ",").ToLower().Trim().Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); foreach (var fieldInfo in fieldList) { if (!excepts.Contains(fieldInfo.Name.ToLower())) { list.Add(fieldInfo); } if (fieldInfo.IsPrimaryKey) { tableInfo.PrimaryKey = fieldInfo.Name; } } #endregion #region 加载模板内置对象 Dictionary <string, PresentBase> tempData = new Dictionary <string, PresentBase>(); if (tempData.Count <= 0) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { //反射调用展现层类库 if (assembly.FullName.Contains("RC.Software.Presentation")) { Type[] classes = assembly.GetTypes(); foreach (Type type in classes) { if (IsInherit(type, typeof(PresentBase))) { string name = type.Name.ToLower(); var instance = Activator.CreateInstance(type) as PresentBase; tempData.Add(name, instance); } } } } } foreach (var pair in tempData) { template.Context.TempData[pair.Key] = pair.Value; } #endregion template.Context.CurrentPath = templateFile; template.Context.TempData["datetime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); template.Context.TempData["conn"] = con; template.Context.TempData["table"] = tableInfo; template.Context.TempData["fields"] = list; template.Context.TempData["author"] = config.Author ?? ""; template.Context.TempData["namespace"] = config.NameSpace ?? ""; #region 内置标签方法 (动态加载) object insideStaticLabel = null; try { const string insideClassName = "RC.Software.Presentation.InsideStaticLabel"; string fileName = Path.Combine(Thread.GetDomain().BaseDirectory, @"InsideStaticLabel.cs"); if (File.Exists(fileName)) { var sourceFile = new FileInfo(fileName); CodeDomProvider provider = new CSharpCodeProvider(); var cp = new CompilerParameters(); cp.ReferencedAssemblies.Add("System.dll"); //添加命名空间引用 cp.ReferencedAssemblies.Add("RC.Software.Presentation.dll"); //添加命名空间引用 cp.ReferencedAssemblies.Add("RC.Software.Framework.dll"); cp.GenerateExecutable = false; // 生成类库 cp.GenerateInMemory = true; // 保存到内存 cp.TreatWarningsAsErrors = false; // 不将编译警告作为错误 // 编译 CompilerResults results = provider.CompileAssemblyFromFile(cp, sourceFile.FullName); if (results.Errors.Count < 1) { Assembly asm = results.CompiledAssembly; // 加载 insideStaticLabel = asm.CreateInstance(insideClassName); //获取编译后的类型 } else { string msg = null; for (int index = 0; index < results.Errors.Count; index++) { CompilerError error = results.Errors[index]; msg += "【错误" + (index + 1) + "】" + Environment.NewLine; msg += "[文件] " + error.FileName + Environment.NewLine; msg += "[位置] 行" + error.Line + ",列" + error.Column + Environment.NewLine; msg += "[信息] " + error.ErrorText + Environment.NewLine; msg += Environment.NewLine; } MessageBox.Show(msg, "内置方法类编译错误"); } } } catch { //如果用户文件写的有问题,用系统内置的标签方法 if (insideStaticLabel == null) { insideStaticLabel = new InsideStaticLabel(); } } if (insideStaticLabel == null) { insideStaticLabel = new InsideStaticLabel(); } template.Context.TempData["rc"] = insideStaticLabel; #endregion var html = template.Render(); return(html); }