public IActionResult SettingSave() { using (var db = this.GetMongodb()) { try { var setting = db.WebSettings.FirstOrDefault(); if (setting == null) { setting = new WebSetting(); setting.Id = 1; setting.AddDate = DateTime.Now; } setting.ModifyUser = this.LoginId; setting.LastModify = DateTime.Now; FormHelper.FillTo(setting, new DisableField("Id")); db.WebSettings.Save(setting); MyWebConfig.WebSetting = setting; return(this.GetResult(true)); } catch (Exception ex) { return(this.GetResult(ex)); } } }
public ActionResult SetEditedEntity(WebSetting model) { model.AltTime = DateTime.Now; int val = settingService.Update(model, "ConfigKey", "ConfigValue", "Description", "BuildTime", "AltTime"); return(Json(val)); }
public ActionResult OpenApplication(string applicationRadio) { if (applicationRadio == null) { return(RedirectToAction("ModifyWebSettings")); } bool isOpen = false; if (applicationRadio.ToLower() == "open") { isOpen = true; } else if (applicationRadio.ToLower() == "close") { isOpen = false; } WebSetting web = ent.WebSettings.FirstOrDefault(); web.ApplicationOpen = isOpen; ent.SaveChanges(); return(RedirectToAction("ModifyWebSettings")); }
/// <summary> /// 网站启动时即配置七牛Key:用户名+密码(从数据库中取) /// </summary> public static void SetKey() { WebSetting setAccess = settingService.GetDataListBy(s => s.ConfigKey == "QiNiuACCESS_KEY")[0]; WebSetting setSecret = settingService.GetDataListBy(s => s.ConfigKey == "QiNiuSECRET_KEY")[0]; Qiniu.Conf.Config.ACCESS_KEY = setAccess.ConfigValue; Qiniu.Conf.Config.SECRET_KEY = setSecret.ConfigValue; }
public ThreadEntity(System.Web.HttpContext webApp, WebSetting.WebSettingItem webSetting, URLManage.URLItem urlItem, Xy.Tools.Web.UrlAnalyzer currentURL) { _webContext = webApp; _webSetting = webSetting; _urlItem = urlItem; _url = currentURL; _content = new HTMLContainer(_webSetting.Encoding); }
public ActionResult AddSetting(WebSetting model) { model.BuildTime = DateTime.Now; int val = settingService.Add(model); return(Json(val)); }
public ActionResult Login(LoginUser userModel) { //实体验证成功的话 进一步验证 if (ModelState.IsValid) { WebSetting nameSetting = webSetService.GetDataListBy(w => w.ConfigKey == "AdminName").FirstOrDefault(); WebSetting pwdSetting = webSetService.GetDataListBy(w => w.ConfigKey == "AdminSecret").FirstOrDefault(); //校验成功,将用户信息保存到Session中,并将票据写入cookie,跳转至后台首页 //后台中的每个Controller都要继承一个BaseController,BaseController中要先校验用户有没有登录, //之后才能进行Action操作 //该用户校验通过:写完cookie和sesion后跳转到首页 string Md5Pwd = userModel.PassWord; if (nameSetting.ConfigValue == userModel.UserName && pwdSetting.ConfigValue == Common.Security.StrToMD5(userModel.PassWord)) { ////写Session //跳转到首页 //Session.Add("loginuser", userModel); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 2, userModel.UserName, DateTime.Now, DateTime.Now.AddDays(30), true, string.Empty ); HttpCookie cookie = new HttpCookie("ZynBlogTicket"); string ticketString = FormsAuthentication.Encrypt(ticket); cookie.Value = ticketString; cookie.Expires = DateTime.Now.AddDays(30); //cookie的过期时间 this.Response.Cookies.Add(cookie); return(Json(new { Status = 1, CoreData = "/Admin/AdminHome/Index" })); } else { return(Json(new { Status = 0, Message = "用户名或密码错误" })); } } else { return(Json(new { Status = 0, Message = "没通过验证,请核对信息" })); } }
public ActionResult WebSetting(WebSetting model) { var img = FileManage.UploadOneFile(); model.Logo = string.IsNullOrEmpty(img) ? model.Logo : img; GlobeInfo.WebSetting = model; TempData["success"] = "保存成功"; return(RedirectToAction("WebSetting")); }
/// <summary> /// 保存信息 /// </summary> /// <param name="message">需要保存的信息</param> /// <param name="level">1 info 2 warm 3 error 4 fatal</param> public void SaveMessage(int level, string message, Exception ex = null) { Log4Net.LogMessage logmessage = new Log4Net.LogMessage(message); var user = WebSetting.GetUser(); logmessage.UserName = System.Web.HttpContext.Current.Session.SessionID; logmessage.UserID = Guid.Empty; if (user != null) { logmessage.UserID = user.ID; logmessage.UserName = user.Account; } logmessage.WebID = WingsConfigurationReader.Instance.WebID; logmessage.WebName = WingsConfigurationReader.Instance.WebName; switch (level) { case 1: if (IsInfoEnabled) { log.Info(logmessage, ex); } ; break; case 2: if (IsWarnEnabled) { log.Warn(logmessage, ex); } ; break; case 3: if (IsErrorEnabled) { log.Error(logmessage, ex); } ; break; case 4: if (IsFatalEnabled) { log.Fatal(logmessage, ex); } ; break; default: break; } }
/// <summary> /// 5.1 ajax get 获取被修改的model /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult GetEditedEntity(int id) { WebSetting entity = settingService.GetEntity(id); return(Json(new { Id = entity.Id, ConfigKey = entity.ConfigKey, ConfigValue = entity.ConfigValue, Description = entity.Description, BuildTime = entity.BuildTime.ToString() }, JsonRequestBehavior.AllowGet)); }
public ActionResult LoadMenus() { List <Tree> Menus = null; List <Permission> permissions = WebSetting.GetPermission(); if (permissions != null) { var Root = permissions.Where(p => p._parentId == null || p._parentId == Guid.Empty).OrderBy(p => p.Index); if (Root != null) { Menus = GetMenus(Root.ToList(), permissions.Where(p => p.IsMenus == true).ToList()); } } return(Json(Menus)); }
public ActionResult Login(LoginModel model, string returnUrl) { var webid = Wings.Framework.Config.WingsConfigurationReader.Instance.WebID; var adminid = Wings.Framework.Config.WingsConfigurationReader.Instance.WebAdminID; string errormsg = string.Empty; if (ModelState.IsValid) { if (!VerificationCode.TestCode(model.CheckCode)) { errormsg += "验证码不正确。"; //ModelState.AddModelError("", "验证码不正确。"); } else { var account = PluginsManger.Service.Login(model.Account, model.Password, webid); if (account == null || account.Equals(Guid.Empty)) { errormsg += "提供的账户或密码不正确。"; //ModelState.AddModelError("", "提供的账户或密码不正确。"); } else { var PermissionList = PluginsManger.Service.GetPermissionByUserID(account.ID, webid, adminid == account.ID); WebSetting.UserOnline(account, model.RememberMe); WebSetting.SaveUserPermission(PermissionList); } } } bool state = true; // 如果我们进行到这一步时某个地方出错,则重新显示表单 if (!string.IsNullOrWhiteSpace(errormsg)) { state = false; ModelState.AddModelError("", errormsg); } return(View(model)); }
public ActionResult LogOut() { var webid = Wings.Framework.Config.WingsConfigurationReader.Instance.WebID; var userinfo = WebSetting.GetUser(); Result r = new Result(); if (userinfo != null) { try { PluginsManger.Service.LoginOut(userinfo.ID, webid); r.success = true; } catch (Exception ex) { r.message = ex.Message; } } WebSetting.UserOffLine(); return(View()); }
public ActionResult Index(WebSetting model) { var dbSetting = db.WebSettings.FirstOrDefault(); var tempPeriod = db.ValidationPeriods.Where(e => e.PeriodID.Equals(model.PeriodID)).FirstOrDefault(); var period = db.ValidationPeriods.Where(e => e.AcademicYearStart.Equals(tempPeriod.AcademicYearStart) && e.AcademicYearEnd.Equals(tempPeriod.AcademicYearEnd) && e.Term.Equals(model.ValidationPeriod.Term)).FirstOrDefault(); if (period == null) { TempData["MessageType"] = "warning"; TempData["Message"] = "Validation Period is not found"; return(RedirectToAction("Index")); } dbSetting.ValidationPeriod = period; dbSetting.ValidationOpen = model.ValidationOpen; db.SaveChanges(); ViewBag.MessageType = "success"; ViewBag.Message = "Successfully changed website settings"; ViewBag.Periods = db.ValidationPeriods.ToList(); return(View(db.WebSettings.FirstOrDefault())); }
public ActionResult ChangeYear(string newChangedYear) { if (newChangedYear == null) { return(RedirectToAction("ModifyWebSettings")); } DateSetting dSet = new DateSetting() { Year = DateTime.Parse(newChangedYear + "/1/1") }; ent.DateSettings.Add(dSet); ent.SaveChanges(); WebSetting web = ent.WebSettings.FirstOrDefault(); web.DSetId = dSet.DSetId; ent.SaveChanges(); return(RedirectToAction("ModifyWebSettings")); }
public KrPatchServer() { WebSetting setting = new WebSetting(); setting.ServerHeader = ""; setting.WebFolder = Path.Combine(Util.ExecutingDirectory(), "Files/www"); setting.HttpPorts = new List <ushort>() { 80 }; setting.HttpsEnabled = false; setting.HttpsPort = 443; setting.HttpsCertPath = ""; setting.HttpsCertPw = ""; IWebServerCore core = new KestrelWebServer(setting); _webService = new WebService(core); IFileProvider webFileProvider = new PhysicalFileProvider(setting.WebFolder); _webService.AddMiddleware(new StaticFileMiddleware("", webFileProvider)); _webService.AddRoute(new IndexRoute()); }
public int BookingCart(OrderDetail model) { try { if (model != null) { var cart = Session["BookingEntry"] as Order; //var orderTime = DateTime.ParseExact("18/04/2019 11:10:00", "dd/MM/yyyy hh:mm tt", // CultureInfo.InvariantCulture); var orderTime = DateTime.Now; var food = _foodRepository.Find(model.Id); if (cart == null) { cart = new Order { OrderDetails = new List <OrderDetail> { new OrderDetail { FoodId = model.Id, FoodPrice = food.Price, OrderTime = orderTime, FoodName = food.Name, TableId = 9, Quantity = food.Quantity, Subtotal = food.Price * food.Quantity, CreationTime = DateTime.Now, LastUpdate = DateTime.Now } } }; } else { if (!cart.OrderDetails.Any(x => x.TableId == model.Id && x.OrderTime.Value.Date == orderTime.Date && x.OrderTime.Value.Hour == orderTime.Hour)) { cart.OrderDetails.Add(new OrderDetail { FoodId = model.Id, FoodPrice = food.Price, OrderTime = orderTime, FoodName = food.Name, TableId = 9, Quantity = food.Quantity, Subtotal = food.Price * food.Quantity, CreationTime = DateTime.Now, LastUpdate = DateTime.Now }); } else { cart.OrderDetails.Remove(cart.OrderDetails.First(x => x.TableId == model.Id)); } } if (DateTime.Today.AddDays(int.Parse(WebSetting.GetBookingLimit())) < model.OrderTime) { RedirectToAction("Index", "Home"); } ISettingRepository settingRepository = new SettingRepository(); var discount = decimal.Parse(settingRepository.GetSettingByKey(SystemSettingEnum.Discount.ToString()).Value); var tax = decimal.Parse(settingRepository.GetSettingByKey(SystemSettingEnum.Tax.ToString()).Value); var order = new Order { LastUpdate = DateTime.Now, CreationTime = DateTime.Now, Name = Resources.Resources.Content_Booking, // Note = model.Note, DepositPrice = 0, Discount = discount, Tax = tax, OrderDetails = new List <OrderDetail>(), }; if (cart.OrderDetails != null) { for (var i = 0; i < cart.OrderDetails.Count; i++) { cart.OrderDetails.ElementAt(i).Id = i + 1; } } Session["BookingEntry"] = cart; return(cart.OrderDetails.Count); } } catch (Exception e) { throw; } return(1); }
/// <summary> /// 安装初始化服务 /// </summary> /// <param name="password">管理员密码</param> /// <param name="title">网站标题</param> /// <param name="adminTitle">后台管理标题</param> /// <returns></returns> public SetupService Setup(string password, string title, string adminTitle) { if (!_db.Users.Any()) { #region 初始化管理员 var admin = new Administrator() { LoginId = "admin", ByOrder = _db.Users.GetId(), Password = SecurityHelper.GetPassword("liguo1987"), IP = HttpHelper.GetIP(), Name = "超级管理员" }; admin.NumberId = 1000000 + admin.ByOrder; _db.Users.Add(admin); #endregion #region 初始化WebSetting var webSet = new WebSetting() { Id = 1, Title = title, Keyword = title, Description = title, Footer = "<p>2017 Copyright 上海七彩网络科技有限公司 All rights reserved</p>", AdminTitle = adminTitle, AdminSubTitle = adminTitle, AdminBackupPath = $"backup_{CommonHelper.GetRandomStr(8)}", AdminBackupFolders = new List <string>(new string[] { "upFiles", "dbbak" }), LastModify = DateTime.Now, AddDate = DateTime.Now, DataCacheTime = 10, BackupLimit = 10, EmailSetting = new EmailSetting() }; _db.WebSettings.Add(webSet); #endregion #region 初始化菜单 var menu = new Menu() { Id = _db.Menus.GetMaxId(), LastModify = DateTime.Now, ParentId = 0, Type = 1, Name = "系统设置", Icon = "cogs", ByOrder = 1 }; _db.Menus.Add(menu); menu = new Menu() { Id = _db.Menus.GetMaxId(), LastModify = DateTime.Now, ParentId = 1, Type = 1, Name = "用户管理", Icon = "group", Url = "User", ByOrder = 2 }; _db.Menus.Add(menu); menu = new Menu() { Id = _db.Menus.GetMaxId(), LastModify = DateTime.Now, ParentId = 1, Type = 1, Name = "菜单管理", Icon = "list", Url = "Menu", ByOrder = 3 }; _db.Menus.Add(menu); menu = new Menu() { Id = _db.Menus.GetMaxId(), LastModify = DateTime.Now, ParentId = 1, Type = 1, Name = "权限管理", Icon = "lock", Url = "Role", ByOrder = 4 }; _db.Menus.Add(menu); menu = new Menu() { Id = _db.Menus.GetMaxId(), LastModify = DateTime.Now, ParentId = 0, Type = 1, Name = "网站设置", Icon = "home", Url = "", ByOrder = 5 }; _db.Menus.Add(menu); menu = new Menu() { Id = _db.Menus.GetMaxId(), LastModify = DateTime.Now, ParentId = 5, Type = 1, Name = "网站参数", Icon = "cog", Url = "WebSetting", ByOrder = 6 }; _db.Menus.Add(menu); menu = new Menu() { Id = _db.Menus.GetMaxId(), LastModify = DateTime.Now, ParentId = 5, Type = 1, Name = "邮件模版", Icon = "list", Url = "MailTemplate", ByOrder = 7 }; _db.Menus.Add(menu); menu = new Menu() { Id = _db.Menus.GetMaxId(), LastModify = DateTime.Now, ParentId = 5, Type = 1, Name = "网站备份", Icon = "database", Url = "Backup", ByOrder = 8 }; _db.Menus.Add(menu); #endregion #region 初始化权限 var permission = new Permission() { Id = 1, AddDate = DateTime.Now, LastModify = DateTime.Now, Name = "后台管理" }; _db.Permissions.Add(permission); permission = new Permission() { Id = 2, AddDate = DateTime.Now, LastModify = DateTime.Now, Name = "编辑权限" }; _db.Permissions.Add(permission); permission = new Permission() { Id = 3, AddDate = DateTime.Now, LastModify = DateTime.Now, Name = "删除权限" }; _db.Permissions.Add(permission); permission = new Permission() { Id = 4, AddDate = DateTime.Now, LastModify = DateTime.Now, Name = "网站设置" }; _db.Permissions.Add(permission); permission = new Permission() { Id = 5, AddDate = DateTime.Now, LastModify = DateTime.Now, Name = "用户管理" }; _db.Permissions.Add(permission); permission = new Permission() { Id = 6, AddDate = DateTime.Now, LastModify = DateTime.Now, Name = "审核权限" }; _db.Permissions.Add(permission); permission = new Permission() { Id = 7, AddDate = DateTime.Now, LastModify = DateTime.Now, Name = "系统设置" }; _db.Permissions.Add(permission); #endregion #region 初始化角色 var role = new Role() { Id = _db.Roles.GetMaxId(), Name = "管理员", AddDate = DateTime.Now, DefaultMenu = null, LastModify = DateTime.Now, Permissions = new List <long>(new long[] { 1 }), Menus = new List <long>() }; _db.Roles.Add(role); #endregion } return(this); }
public KestrelWebServer(WebSetting setting) { _setting = setting; _cancellationTokenSource = new CancellationTokenSource(); }
public void SendBlogCmtEmail(Comment cmt, string pageSize) { //7.1 获取系统邮件Key Secret IBLL.IWebSettingService wService = OperateHelper.Current.serviceSession.WebSettingService; WebSetting keySeting = wService.GetDataListBy(w => w.ConfigKey == "SystemEmailKey").FirstOrDefault(); WebSetting secretSeting = wService.GetDataListBy(w => w.ConfigKey == "SystemEmailSecret").FirstOrDefault(); string systemEmailName = keySeting.ConfigValue; //系统邮箱 string systemEmailSecret = secretSeting.ConfigValue; //系统邮箱密码 //7.2 获取评论隶属于那一篇博文 string title = articleService.GetEntity(cmt.CmtArtId).Title; //7.3 取到这条评论的最根上的评论Id int rootcmtId = 0; int parentId = 0; Comment parentCmt = commentService.GetDataListBy(c => c.Id == cmt.ParentId).FirstOrDefault(); Comment tempCmt = parentCmt; if (parentCmt != null) { //7.4 父Id parentId = parentCmt.Id; while (tempCmt != null) { tempCmt = commentService.GetDataListBy(c => c.Id == tempCmt.ParentId).FirstOrDefault(); if (tempCmt != null) { parentCmt = tempCmt; } } rootcmtId = parentCmt.Id; } else { rootcmtId = cmt.Id; } //7.5 判断这个rootcmtId位于第几页 int pageindex = 0; int pagesize = Convert.ToInt32(pageSize); //对所有的一级评论按照时间排序即可 List <Comment> cmtList = commentService.GetDataListBy(c => c.CmtArtId == cmt.CmtArtId && c.Status == 1 && c.ParentId == 0, c => c.SubTime); //判断id为rootcmtId在第几页 int position = cmtList.FindIndex(c => c.Id == rootcmtId); //找出这个rootId在所有一级评论中的位置, pageindex = Math.Max(((position + 1) + pagesize - 1) / pagesize, 1); //得到的即是该root评论在第几页的 //7.6 url参数;最终这些参数将发送到前台js进行锚点定位、高亮处理 (对url参数进行加密) string url = "http://127.0.0.1:8081/Archives/Index/" + cmt.CmtArtId + "?Flag=" + Common.Security.Base64UTF8Encode("1") + "&AnchorIndex=" + Common.Security.Base64UTF8Encode(pageindex.ToString()) + "&AnchorSize=" + Common.Security.Base64UTF8Encode(pageSize.ToString()) + "&AnchorCmtRootId=" + Common.Security.Base64UTF8Encode(rootcmtId.ToString()) + "&AnchorCmtParentId=" + Common.Security.Base64UTF8Encode(parentId.ToString()) + "&AnchorCmtId=" + Common.Security.Base64UTF8Encode(cmt.Id.ToString()); Visitor visitor = visitorService.GetEntity(cmt.VisitorId); //7.7 构造邮件主题、内容、发送邮件 if (cmt.ParentId == 0) { string subject = "[您的博客有新评论]Re:" + title; url += "&Vid=" + Common.Security.Base64UTF8Encode("1"); Visitor blogger = visitorService.GetEntity(1); //Id=3的是博主=我 string emailBody = @"#Re: " + title + "<br/>" + "博客新评论:" + "<br/>" + "内容:" + cmt.CmtText + "<hr/>" + "评论者:<a href='#' >" + visitor.VisitorName + "</a>" + "<br/>" + "URL:" + "<a href='" + url + "' title='链接地址'>" + url + "</a>" + "<br/>" + "(系统通知,请勿回复)"; SendMail.SendEMail("smtp.126.com", systemEmailName, systemEmailSecret, blogger.VisitorEmail, subject, emailBody); } else { Comment ParentCmt = commentService.GetEntity(cmt.ParentId); string toEmail = ParentCmt.Visitor.VisitorEmail; string subject = "[您的博客评论有新回复]Re:" + title; url += "&Vid=" + ParentCmt.Visitor.Id; string emailBody = @"#Re: " + title + "<br/>" + "<a href='#'>@ </a>" + ParentCmt.Visitor.VisitorName + "<br/>" + "内容:" + cmt.CmtText + "<hr/>" + "回复者:<a href='#' >" + visitor.VisitorName + "</a>" + "<br/>" + "URL:" + "<a href='" + url + "' title='链接地址'>" + url + "</a>" + "<br/>" + "(系统通知,请勿回复)"; SendMail.SendEMail("smtp.126.com", systemEmailName, systemEmailSecret, toEmail, subject, emailBody); } }
public ActionResult Register(UserModel model) { if (model == null) { return(View()); } var message = new MessageModel { Content = Resources.Resources.Message_Success_Register, Title = Resources.Resources.Content_Success, Type = MessageTypeEnum.SuccessReload.ToString(), ClosePopup = true }; //Parse var entity = new Customer() { Id = model.Id, DateOfBirth = model.DateOfBirth, Username = model.Username, Password = model.Password, Phone = model.Phone, Email = model.Email, FullName = model.FullName, Address = model.Address, Active = true, Deleted = false, LastUpdate = DateTime.Now, }; //Check Password = Password confirm if (model.Password != model.PasswordConfirm) { message = new MessageModel { Content = Resources.Resources.Message_Error_PasswordConfirm, Title = Resources.Resources.Content_Error, Type = MessageTypeEnum.Error.ToString() }; return(Json(message, JsonRequestBehavior.AllowGet)); } //Check username Exist if (!_customerRepository.IsValid(entity)) { message = new MessageModel { Content = Resources.Resources.Message_Error_UserExisted, Title = Resources.Resources.Content_Error, Type = MessageTypeEnum.Error.ToString() }; return(Json(message, JsonRequestBehavior.AllowGet)); } entity.Password = Utils.ToMd5Hash(entity.Password); //Validate if (!Validator.Validate(entity)) { message = new MessageModel { Content = Resources.Resources.Message_Error_Validate, Title = Resources.Resources.Content_Error, Type = MessageTypeEnum.Error.ToString() }; return(Json(message, JsonRequestBehavior.AllowGet)); } //Save if (!_customerRepository.Save(entity)) { message = new MessageModel { Content = Resources.Resources.Message_Error_System, Title = Resources.Resources.Content_Error, Type = MessageTypeEnum.Error.ToString() }; return(Json(message, JsonRequestBehavior.AllowGet)); } SendActivationEmail(entity); Session["User"] = entity; message.Content = string.Format("Registration successful, mail send to your mail id", entity.FullName, WebSetting.GetWebContent().WebLongName); Session["ReturnToUrl"] = "Home/Index"; return(Json(message, JsonRequestBehavior.AllowGet)); }
public void Init(ThreadEntity threadEntity, WebSetting.WebSettingItem webSetting) { _threadEntity = threadEntity; _htmlContainer = new HTMLContainer(_threadEntity.WebSetting.Encoding); _server = _threadEntity.WebContext.Server; _url = threadEntity.URL; _updateLocalCache = false; _response = new PageResponse(_threadEntity, _htmlContainer); _request = new PageRequest(_threadEntity); _pageData = new PageData(); _pageSession = PageSessionCollection.GetInstance().GetSession(_threadEntity); _webSetting = webSetting; }
public void Init(PageAbstract page, WebSetting.WebSettingItem webSetting, HTMLContainer container) { _threadEntity = page._threadEntity; _server = page._server; _updateLocalCache = page._updateLocalCache; _request = page._request; _pageData = page._pageData; _pageSession = page._pageSession; _url = page._url; _webSetting = webSetting; _response = page._response; _response.SetNewContainer(container); _htmlContainer = container; }
public ActionResult SubmitBooking(Order model) { if (DateTime.Today.AddDays(int.Parse(WebSetting.GetBookingLimit())) < model.OrderTime) { RedirectToAction("Index", "Home"); } ISettingRepository settingRepository = new SettingRepository(); var discount = decimal.Parse(settingRepository.GetSettingByKey(SystemSettingEnum.Discount.ToString()).Value); var tax = decimal.Parse(settingRepository.GetSettingByKey(SystemSettingEnum.Tax.ToString()).Value); var order = new Order { LastUpdate = DateTime.Now, CreationTime = DateTime.Now, Name = Resources.Resources.Content_Booking, Note = model.Note, DepositPrice = 0, Discount = discount, Tax = tax, OrderDetails = new List <OrderDetail>(), }; var tableBll = new TableBll(); foreach (var item in model.OrderDetails) { if (tableBll.GetOrderByTableIdAndTime(item.TableId, item.OrderTime.Value) != null) { Session.Remove("BookingEntry"); RedirectToAction("Index", "Home"); } if (!item.FoodId.HasValue) { var food = _foodRepository.Find(item.FoodId.Value); order.OrderDetails.Add(new OrderDetail { TableId = 9, FoodId = item.FoodId, FoodName = food.Name, FoodPrice = food.Price, Quantity = food.Quantity, Subtotal = food.Price * food.Quantity, CreationTime = DateTime.Now, OrderTime = item.OrderTime, LastUpdate = DateTime.Now }); } else { var food = _foodRepository.Find(item.FoodId.Value); if (!item.Quantity.HasValue || !(item.Quantity > 0) || food.Quantity < item.Quantity.Value) { return(RedirectToAction("Error", "Home")); } var sameOrderdetails = order.OrderDetails.FirstOrDefault(x => x.FoodId == food.Id && x.TableId == item.TableId); if (sameOrderdetails == null) { order.OrderDetails.Add(new OrderDetail { TableId = item.TableId, Food = food, FoodId = food.Id, FoodName = food.Name, FoodPrice = food.Price, Quantity = item.Quantity, Subtotal = food.Price * item.Quantity.Value, CreationTime = DateTime.Now, LastUpdate = DateTime.Now }); } else { sameOrderdetails.Quantity++; } order.SubTotal += food.Price * item.Quantity.Value; //Session["ReturnToUrl"] = "Orders/viewbooking"; } } Session["Booking"] = order; return(RedirectToAction("ViewBooking")); }
public static void Update(this WebSetting webSetting, WebSettingForm model) { webSetting.Name = model.Name; webSetting.Value = model.Value; }
public void SendBlogLvmEmail(LeaveMsg lvm) { //7.1 获取系统邮件Key Secret IBLL.IWebSettingService wService = OperateHelper.Current.serviceSession.WebSettingService; WebSetting keySeting = wService.GetDataListBy(w => w.ConfigKey == "SystemEmailKey").FirstOrDefault(); WebSetting secretSeting = wService.GetDataListBy(w => w.ConfigKey == "SystemEmailSecret").FirstOrDefault(); string systemEmailName = keySeting.ConfigValue; //系统邮箱 string systemEmailSecret = secretSeting.ConfigValue; //系统邮箱密码 //7.2 先取到这条留言的最根上的留言Id int rootlvmId = 0; int parentId = 0; LeaveMsg parentLvm = leaveService.GetDataListBy(c => c.Id == lvm.ParentId).FirstOrDefault(); LeaveMsg tempLvm = parentLvm; if (parentLvm != null) { //7.3 父Id parentId = parentLvm.Id; while (tempLvm != null) { tempLvm = leaveService.GetDataListBy(c => c.Id == tempLvm.ParentId).FirstOrDefault(); if (tempLvm != null) { parentLvm = tempLvm; } } rootlvmId = parentLvm.Id; } else { rootlvmId = lvm.Id; } //7.4 url参数;最终这些参数将发送到前台js进行锚点定位、高亮处理 string url = "http://127.0.0.1:8081/LeaveMsg/Index/" + "?Flag=" + Common.Security.Base64UTF8Encode("1") + "&AnchorLvmRootId=" + Common.Security.Base64UTF8Encode(rootlvmId.ToString()) + "&AnchorLvmParentId=" + Common.Security.Base64UTF8Encode(parentId.ToString()) + "&AnchorLvmId=" + Common.Security.Base64UTF8Encode(lvm.Id.ToString());//Ajax加载完数据后定位到锚点 //7.5 构造邮件主题、内容、发送邮件 Visitor visitor = visitorService.GetEntity(lvm.VisitorId); if (lvm.ParentId == 0) { //给博主的留言 string subject = "[您的博客有新留言]Re:留言板"; url += "&Vid=" + Common.Security.Base64UTF8Encode("1"); Visitor blogger = visitorService.GetEntity(1); //Id=3的是博主=我 string emailBody = @"#Re: 留言板" + "<br/>" + "新留言:" + "<br/>" + "内容:" + lvm.LMessage + "<hr/>" + "留言者:<a href='#' >" + visitor.VisitorName + "</a>" + "<br/>" + "URL:" + "<a href='" + url + "' title='链接地址'>" + url + "</a>" + "<br/>" + "(系统通知,请勿回复)"; SendMail.SendEMail("smtp.126.com", systemEmailName, systemEmailSecret, blogger.VisitorEmail, subject, emailBody); } else { //游客给其它留言者的回复 LeaveMsg parentlvm = leaveService.GetEntity(lvm.ParentId); string toEmail = parentlvm.Visitor.VisitorEmail; string subject = "[zynblog留言新回复]Re:"; url += "&Vid=" + parentlvm.Visitor.Id; string emailBody = @"#Re: zynblog留言板" + "<br/>" + "<a href='#'>@ </a>" + parentlvm.Visitor.VisitorName + "<br/>" + "内容:" + lvm.LMessage + "<hr/>" + "回复者:<a href='#' >" + visitor.VisitorName + "</a>" + "<br/>" + "URL:" + "<a href='" + url + "' title='链接地址'>" + url + "</a>" + "<br/>" + "(系统通知,请勿回复)"; SendMail.SendEMail("smtp.126.com", systemEmailName, systemEmailSecret, toEmail, subject, emailBody); } }
public List <Permission> GetAllPermission() { return(WebSetting.GetAllAction()); }
public void SavePermission(List <Permission> permissions, Guid userid) { WebSetting.SaveUserPermission(permissions, userid); }
/// <summary> /// 判断当前用户是否有次访问点的权限 /// </summary> /// <param name="filterContext"></param> public override void OnActionExecuting(ActionExecutingContext filterContext) { //权限拦截是否忽略 bool IsIgnored = false; string message = string.Empty; if (filterContext == null) { throw new ArgumentNullException("filterContext"); } //判断当前用户是否是管理员 var userinfo = WebSetting.GetUser(); if (userinfo != null && userinfo.ID == WingsConfigurationReader.Instance.WebAdminID) { message = "当前用户是超级管理员!"; IsIgnored = true; } //是否登录和允许匿名访问 即无权限控制 if (filterContext.ActionDescriptor.IsDefined(typeof(AnonymousAttribute), false)) { message = "匿名使用页面,无权限控制!"; IsIgnored = true; } if (!filterContext.HttpContext.User.Identity.IsAuthenticated && !IsIgnored) { message = "用户未登录,转跳登录!"; { FormsAuthentication.RedirectToLoginPage(); } } else //用户已经登录 if (!IsIgnored) { if (filterContext.ActionDescriptor.IsDefined(typeof(LoginAllowViewAttribute), false)) { message = "登录即可允许页面!"; IsIgnored = true; } else { //读取缓存 是否包含此控制器和访问 var permissionsobjs = WebSetting.GetPermission(); if (permissionsobjs != null) { List <Permission> permissions = (List <Permission>)permissionsobjs; var path = filterContext.HttpContext.Request.Path.ToLower(); string controller = filterContext.RouteData.Values["controller"].ToString(); string action = filterContext.RouteData.Values["action"].ToString(); var ispost = filterContext.HttpContext.Request.HttpMethod.ToLower() == "post"; if (permissions != null && permissions.Count > 0) { var result = permissions.Find(p => { if (p.Action == null || p.Controller == null) { return(false); } else { return(p.Action.ToLower() == action.ToLower() && p.Controller.ToLower() == controller.ToLower() && p.IsPost == ispost); } } ); IsIgnored = result != null; } } message = IsIgnored ? "权限之内页面!" : "不具有权限页面!"; } } // if (!IsIgnored) { filterContext.Result = new JsonResult() { Data = new { success = false, message = "抱歉 您不具有此页面的访问权限,如有疑问请联系管理员!" }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } object[] Descriptions = filterContext.ActionDescriptor.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false); string OperaName = string.Empty; if (Descriptions != null && Descriptions.Count() > 0) { OperaName = ((System.ComponentModel.DescriptionAttribute)(Descriptions[0])).Description; } string paras = Newtonsoft.Json.JsonConvert.SerializeObject(filterContext.ActionParameters); Log.OperaInstance.SaveMessage(IsIgnored ? 1 : 2, string.Format("权限判断:{0};参数:{1};信息:{2}", OperaName, paras, message)); base.OnActionExecuting(filterContext); }
public WebRouter(WebSetting setting) { _setting = setting; _routes = new Dictionary <string, IWebRoute>(); }