public string ResolveApplicationKey(string keyName) { var currentEncryptionKey = ApplicationKeys?.SingleOrDefault(a => a.Key == keyName); if (currentEncryptionKey == null) { throw new Exception($"Could not retrieve the requested application key [{keyName}]"); } return(currentEncryptionKey.Value.Value); }
/// <summary> /// 创建主页实体 /// </summary> /// <returns></returns> public static ApplicationKeys Instance() { if (_instance == null) { lock (lockObject) { if (_instance == null) { _instance = new ApplicationKeys(); } } } return(_instance); }
/// <summary> /// 创建主页实体 /// </summary> /// <returns></returns> public static ApplicationKeys Instance() { if (_instance == null) { lock (lockObject) { if (_instance == null) { _instance = new ApplicationKeys(); } } } return _instance; }
public IActionResult Login([Bind("UserName", "Password")] Account account) { Encription encription = new Encription(); bool existed = _context.Account.Any(x => x.UserName.TrimEnd().ToLower().Equals(account.UserName.TrimEnd().ToLower()) && x.Password.Equals(account.Password)); if (existed) { Account selectedAccount = _context.Account.Where(x => x.UserName.TrimEnd().ToLower().Equals(account.UserName.TrimEnd().ToLower()) && x.Password.Equals(account.Password)).FirstOrDefault(); int? AccountTypeId = selectedAccount.AccountTypeId; ApplicationKeys appKeys = new ApplicationKeys(); string UserNameEncription = encription.Encrypt(appKeys.Key_UserName, selectedAccount.UserName); string PasswordEncription = encription.Encrypt(appKeys.Key_Password, selectedAccount.Password); //HttpContext.Session.SetString("x", UserNameEncription); //HttpContext.Session.SetString("y", PasswordEncription); _session.SetString("x", UserNameEncription); _session.SetString("y", PasswordEncription); if (AccountTypeId == AccountType_Doctor) { ViewData["Layout"] = "_DoctorLayout"; //ViewData["ContactLayout"] = "~/Views/Shared/_DoctorLayout.cshtml"; return(RedirectToAction("DoctorDefault", "Home", new { id = UserNameEncription, y = PasswordEncription })); } else if (AccountTypeId == AccountType_Admin) { ViewData["Layout"] = "_AdminLayout"; //ViewData["ContactLayout"] = "~/Views/Shared/_AdminLayout.cshtml"; return(RedirectToAction("AdminDefault", "Home", new { id = UserNameEncription, y = PasswordEncription })); } else if (AccountTypeId == AccountType_Patient) { ViewData["Layout"] = "_PatientLayout"; //ViewData["ContactLayout"] = "~/Views/Shared/_PatientLayout.cshtml"; return(RedirectToAction("PatientDefault", "Home", new { id = UserNameEncription, y = PasswordEncription })); } else { return(RedirectToAction("Login")); } } else { return(RedirectToAction("Login")); } }
/// <summary> /// 文章管理 /// </summary> /// <param name="auditStatus">审批状态</param> /// <param name="categoryId">文章类别id</param> /// <param name="subjectKeywords">标题关键字</param> /// <param name="isEssential">是否加精</param> /// <param name="userId">作者id</param> /// <param name="pageSize">分页大小</param> /// <param name="pageIndex">页码</param> public ActionResult ManageBlogs(AuditStatus?auditStatus = null, long?categoryId = null, string subjectKeywords = null, bool?isEssential = null, string userId = null, string tenantTypeId = null, int pageSize = 20, int pageIndex = 1) { long?blogUserId = null; if (!string.IsNullOrEmpty(userId)) { userId = userId.Trim(','); if (!string.IsNullOrEmpty(userId)) { blogUserId = long.Parse(userId); } } //获取类别 IEnumerable <Category> categorys = categoryService.GetOwnerCategories(0, TenantTypeIds.Instance().BlogThread()); SelectList categoryList = new SelectList(categorys.Select(n => new { text = n.CategoryName, value = n.CategoryId }), "value", "text", categoryId); ViewData["categoryList"] = categoryList; //组装是否加精 List <SelectListItem> selectListIsEssential = new List <SelectListItem> { new SelectListItem { Text = "是", Value = true.ToString() }, new SelectListItem { Text = "否", Value = false.ToString() } }; ViewData["isEssential"] = new SelectList(selectListIsEssential, "Value", "Text", isEssential); ViewData["userId"] = blogUserId; //获取租户类型 IEnumerable <TenantType> tenantTypes = tenantTypeService.Gets(ApplicationKeys.Instance().Blog()); SelectList tenants = null; tenants = new SelectList(tenantTypes.Select(n => new { text = n.Name, value = n.TenantTypeId }), "value", "text", tenantTypeId); ViewData["tenants"] = tenants; ViewData["tenantscount"] = tenantTypes.Count(); PagingDataSet <BlogThread> blogs = blogService.GetsForAdmin(null, auditStatus, categoryId, isEssential, blogUserId, subjectKeywords, pageSize, pageIndex); pageResourceManager.InsertTitlePart("文章管理"); return(View(blogs)); }
/// <summary> /// Grava os nossos valores para a aplicação, mas exclui DB /// </summary> /// <param name="keyName"></param> /// <param name="value"></param> public void WriteKey(ApplicationKeys keyName, string value) { if (!Directory.Exists("Settings")) { Directory.CreateDirectory("Settings"); } XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; XmlWriter writer = XmlWriter.Create("Settings\\" + keyName.Name + ".xml"); writer.WriteStartDocument(); writer.WriteStartElement("Settings"); writer.WriteAttributeString("Name", keyName.Name); writer.WriteElementString(keyName.Name, value); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); }
/// <summary> /// 微博数 /// </summary> public static string ThreadCount(this OwnerDataKeys ownerDataKeys) { return(ApplicationKeys.Instance().Microblog() + "-ThreadCount"); }
/// <summary> /// 关注的帖吧数 /// </summary> public static string FollowSectionCount(this OwnerDataKeys ownerDataKeys) { return(ApplicationKeys.Instance().Bar() + "-FollowSectionCount"); }
/// <summary> /// 回帖总数 /// </summary> public static string PostCount(this OwnerDataKeys ownerDataKeys) { return(ApplicationKeys.Instance().Bar() + "-PostCount"); }
/// <summary> /// 贴吧 /// </summary> public static string Blog(this ApplicationKeys applicationKeys) { return("Blog"); }
/// <summary> /// 贴吧 /// </summary> public static string Bar(this ApplicationKeys applicationKeys) { return("Bar"); }
/// <summary> /// 微博 /// </summary> public static string Microblog(this ApplicationKeys applicationKeys) { return("Microblog"); }