public BaseService() { if (unity == null) { unity = new UnityContext(); } if (dao == null) { using (context = new DataContext()) { dao = unity.GetInstance <T>(context); } } }
protected void Application_Start(object sender, EventArgs e) { //读取系统配置信息 var configService = unity.GetInstance <IConfigService>(); var config = configService.GetConfig("base"); ApplicationConfig.SysFee = config.GetValue("sysfee").TryParseToDecimal(0.03m); Application.Add("name", config.GetValue("name")); Application.Add("site", config.GetValue("site")); Application.Add("slogan", config.GetValue("slogan")); Application.Add("seo_title", config.GetValue("seo_title")); Application.Add("seo_keys", config.GetValue("seo_keys")); Application.Add("seo_desc", config.GetValue("seo_desc")); Application.Add("beian", config.GetValue("beian")); Application.Add("tel", config.GetValue("tel")); Application.Add("fax", config.GetValue("fax")); Application.Add("hot_line", config.GetValue("hot_line")); Application.Add("qqkefu1", config.GetValue("qqkefu1")); Application.Add("qqkefu2", config.GetValue("qqkefu2")); Application.Add("qqkefu3", config.GetValue("qqkefu3")); Application.Add("address", config.GetValue("address")); Application.Add("keywords", config.GetValue("keywords")); Application.Add("description", config.GetValue("description")); Application.Add("copyright", config.GetValue("copyright")); Application.Add("sysfee", ApplicationConfig.SysFee); Application.Add("lowest_get_cash", config.GetValue("lowest_get_cash")); Application.Add("lowest_get_points_cash", config.GetValue("lowest_get_points_cash")); Application.Add("money_points_ratio", config.GetValue("money_points_ratio")); Application.Add("make_good", config.GetValue("make_good")); }
public bool SendOrder(string mobile, string subname, string orderid) { string msg = string.Format("【巨店网】您出售的店铺[{0}]买家已经付款,如有疑问请联系选猫网", subname); var unity = new UnityContext(); var orderService = unity.GetInstance <IOrderService>(); var order = orderService.GetOrder(orderid); #if !DEBUG if (order != null && order.Send_Mail != 1 && order.Mobile.Equals(mobile)) { if (SendText(mobile, msg)) { order.Send_Mail = 1; orderService.Modify(order); return(true); } } #endif #if DEBUG if (SendText(mobile, msg)) { return(true); } #endif return(false); }
public static void SendEmail(string email, string subject, string body) { try { var unity = new UnityContext(); var configService = unity.GetInstance <IConfigService>(); var cfg = configService.GetConfig(1); var smtp = new SmtpClient(); smtp.Host = cfg.GetValue("host"); smtp.Port = cfg.GetValue("port").TryParseToInt32(); smtp.UseDefaultCredentials = false; smtp.EnableSsl = "ssl".Equals(cfg.GetValue("secure")) ? true : false; System.Net.NetworkCredential nc = new System.Net.NetworkCredential(cfg.GetValue("username"), cfg.GetValue("password")); smtp.Credentials = nc.GetCredential(smtp.Host, smtp.Port, "NTLM"); smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.Send(cfg.GetValue("email"), email, subject, body); } catch (Exception ex) { Logger.GetLogger().Error("发送邮件出错\n", ex); } }
public void Refresh() { if (this.IsLogged) { var unity = new UnityContext(); var svr = unity.GetInstance <IUserService>(); Context.Session[KEY_SESSION] = svr.GetUser(this.DisplayName); } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { return; } var unity = new UnityContext(); var svr = unity.GetInstance <IAttributeService>(); attributes = svr.GetList(new Model.Attribute.Query { Status = 1 }); }
protected void Page_Load(object sender, EventArgs e) { var unity = new UnityContext(); var articleService = unity.GetInstance <IArticleService>(); if (Limit == null) { this.DataSource = articleService.GetList(new Model.Article.Query { Cate_Id = CatID, Status = 1 }); this.DataBind(); } else { this.DataSource = articleService.GetList(new Model.Article.Query { Cate_Id = CatID, Status = 1 }, Limit.Value); this.DataBind(); } }
protected override void OnLoad(EventArgs e) { if (Page.IsPostBack) { return; } var unity = new UnityContext(); if (this.LoopType == LoopType.Article) { var svr = unity.GetInstance <IArticleService>(); this.DataSource = svr.GetList(new Model.Article.Query { Cate_Id = CatId, Status = 1 }, Limit); this.DataBind(); } else if (this.LoopType == LoopType.Advertisement) { var svr = unity.GetInstance <IAdService>(); this.DataSource = svr.GetList(new Model.Ad.Query { Position_Id = Position, Status = 1, Ad_Type = AdType, Type = this.Type }, Limit); this.DataBind(); } else if (this.LoopType == LoopType.Link) { var svr = unity.GetInstance <ILinksService>(); //int? isRecommend = null; //if (this.IsHot != null) //{ // isRecommend = this.Recommend.Value ? 1 : 0; //} this.DataSource = svr.GetList(new Model.Links.Query { Recommend = (int?)Recommend, Status = 1 }, Limit); this.DataBind(); } else if (this.LoopType == LoopType.Title) { var svr = unity.GetInstance <ITitleService>(); //int? isHots = null; //if (this.IsHot != null) //{ // isHots = this.IsHot.Value ? 1 : 0; //} //int? isRecommend = null; //if (this.IsHot != null) //{ // isRecommend = this.Recommend.Value ? 1 : 0; //} this.DataSource = svr.GetList(new Model.Title.Query { Recommend = (int?)Recommend, Parent_Id = CatId, Status = 1 }, Limit); this.DataBind(); } else if (this.LoopType == LoopType.Category) { var svr = unity.GetInstance <ICategoryService>(); IList <int> limits = new List <int>(); if (Start != null && Start.HasValue) { limits.Add(Start.Value); } if (Limit != null && Limit.HasValue) { limits.Add(Limit.Value); } int[] newLimit = limits.ToArray <int>(); this.DataSource = svr.GetList(new Model.Category.Query { Parent_Id = CatId, Recommend = (int?)Recommend, Status = 1 }, newLimit); this.DataBind(); } else if (this.LoopType == LoopType.Attribute) { var svr = unity.GetInstance <IAttributeService>(); this.DataSource = svr.GetList(new Model.Attribute.Query { Recommend = (int?)Recommend, Pid = CatId, Status = 1 }, Limit); this.DataBind(); } else if (this.LoopType == LoopType.Question) { var svr = unity.GetInstance <IQuestionService>(); this.DataSource = svr.GetList(new Model.Question.Query { Is_Best = (int?)IsBest, Type_Id = CatId, Status = 1, User_Id = UserId }, Limit); this.DataBind(); } else if (this.LoopType == LoopType.QuestionType) { var svr = unity.GetInstance <IQuestionTypeService>(); this.DataSource = svr.GetList(new Model.QuestionType.Query { }, Limit); this.DataBind(); } else if (this.LoopType == LoopType.Region) { var svr = unity.GetInstance <IRegionService>(); this.DataSource = svr.GetList(new Model.Region.Query { Parent_Id = CatId }); this.DataBind(); } else if (this.LoopType == LoopType.Product) { var svr = unity.GetInstance <IProductService>(); this.DataSource = svr.GetList(new Model.Product.Query { Cat_Id = CatId.TryParseToString(null), Best = (int?)IsBest, Hot = (int?)IsHot, New = IsNew, Status = 1, Sales = 0 }, Limit); this.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { ShopId = Request.QueryString["pid"].TryParseToInt32(0); if (Page.IsPostBack) { return; } var unity = new UnityContext(); var svr = unity.GetInstance <IAttributeService>(); attributes = svr.GetList(new Model.Attribute.Query { Status = 1 }); if ("GET".Equals(Request.RequestType)) { } else if ("POST".Equals(Request.RequestType)) { var productService = unity.GetInstance <IProductService>(); var shop = new ProductFrontend(); shop.Type = Request.Form["type"].TryParseToInt32(); //shop.Status = Request.Form["status"].TryParseToInt32(); shop.Name = Request.Form["spTitle"].TryParseToString(); shop.Brief = Request.Form["spBrief"].TryParseToString(); shop.Url = Request.Form["spUrl"].TryParseToString(); shop.Subname = Request.Form["spAdmin"].TryParseToString(); shop.Start_Time = Request.Form["shopHours"].TryParseToInt32(0); shop.Price = Request.Form["shopsPrice"].TryParseToDecimal(); shop.Category_Id = Request.Form["category_id"].TryParseToInt32(0); shop.Area = Request.Form["area"].TryParseToString(); var attrs = Request.Form.GetValues("attr[]"); var productAttrs = new List <ProductAttr>(); //处理Input=1 foreach (var attr in attrs) { var strAry = attr.Split('_'); if (strAry.Count() != 3) { continue; } var productAttr = new ProductAttr(); productAttr.Attr_Pid = ShopId; productAttr.Attr_Value = strAry[2]; productAttr.Attr_Id = strAry[1].TryParseToInt32(); productAttr.Input = strAry[0].TryParseToInt32(); productAttrs.Add(productAttr); } //处理Input=2,3 foreach (var attr in attributes.Where(d => d.Pid == ShopId).ToList()) { if (attr.Input == 2 || attr.Input == 3) { var attrValues = Request.Form.GetValues(string.Format("input[{0}][{1}][]", attr.Input, attr.Id)); if (attrValues != null) { foreach (var attrVal in attrValues) { var productAttr = new ProductAttr(); productAttr.Attr_Pid = ShopId; productAttr.Attr_Value = attrVal; productAttr.Attr_Id = attr.Id; productAttr.Input = attr.Input; productAttrs.Add(productAttr); } } } } //shop = Request.Form["input"]; // shop. = Request.Form["attr_id"]; shop.Address_Id = Request.Form["address_id"].TryParseToInt32(0); var user = new UserConsignee(); user.User_Id = LoggedUser.Id; user.Consignee = Request.Form["utruename"] ?? ""; user.Mobile = Request.Form["umobile"] ?? ""; user.Phone = Request.Form["utel"] ?? ""; user.Qq = Request.Form["uqq"] ?? ""; user.Address = ""; user.Zip = ""; user.Email = ""; user.Fax = ""; user.Is_Def = 1; user.Region_Values = ""; shop.Content = ""; shop.Filename = ""; shop.Video = ""; shop.Buyer_Protection = ""; shop.Mobile = LoggedUser.Mobile; shop.UserConsignee = user; shop.Attrs = productAttrs; shop.Admin_Id = 1; shop.Guanlian_Id = 1; shop.Seller_Id = LoggedUser.Id; productService.Add(shop); ViewState["Message"] = "发布网店成功"; } }