示例#1
0
文件: Check.cs 项目: x360ce/x360ce
        public static void CreateDefaultSchema()
        {
            var db   = new Data.SecurityEntities();
            var item = db.SchemaVersions.FirstOrDefault(x => x.Feature == "common");

            if (item == null)
            {
                item         = new Data.SchemaVersion();
                item.Feature = "common";
                item.CompatibleSchemaVersion = "1";
                item.IsCurrentVersion        = true;
                db.SchemaVersions.AddObject(item);
                db.SaveChanges();
            }
            item = db.SchemaVersions.FirstOrDefault(x => x.Feature == "membership");
            if (item == null)
            {
                item         = new Data.SchemaVersion();
                item.Feature = "membership";
                item.CompatibleSchemaVersion = "1";
                item.IsCurrentVersion        = true;
                db.SchemaVersions.AddObject(item);
                db.SaveChanges();
            }
            item = db.SchemaVersions.FirstOrDefault(x => x.Feature == "role manager");
            if (item == null)
            {
                item         = new Data.SchemaVersion();
                item.Feature = "role manager";
                item.CompatibleSchemaVersion = "1";
                item.IsCurrentVersion        = true;
                db.SchemaVersions.AddObject(item);
                db.SaveChanges();
            }
        }
示例#2
0
		public static void CreateDefaultSchema()
		{
			var db = new Data.SecurityEntities();
			var item = db.SchemaVersions.FirstOrDefault(x => x.Feature == "common");
			if (item == null)
			{
				item = new Data.SchemaVersion();
				item.Feature = "common";
				item.CompatibleSchemaVersion = "1";
				item.IsCurrentVersion = true;
				db.SchemaVersions.AddObject(item);
				db.SaveChanges();
			}
			item = db.SchemaVersions.FirstOrDefault(x => x.Feature == "membership");
			if (item == null)
			{
				item = new Data.SchemaVersion();
				item.Feature = "membership";
				item.CompatibleSchemaVersion = "1";
				item.IsCurrentVersion = true;
				db.SchemaVersions.AddObject(item);
				db.SaveChanges();
			}
			item = db.SchemaVersions.FirstOrDefault(x => x.Feature == "role manager");
			if (item == null)
			{
				item = new Data.SchemaVersion();
				item.Feature = "role manager";
				item.CompatibleSchemaVersion = "1";
				item.IsCurrentVersion = true;
				db.SchemaVersions.AddObject(item);
				db.SaveChanges();
			}
		}
示例#3
0
		public static void UpdateRole(string roleName, string description)
		{
			var db = new Data.SecurityEntities();
			var role = db.Roles.FirstOrDefault(x => x.Application.ApplicationName == System.Web.Security.Roles.ApplicationName && x.RoleName == roleName);
			if (role != null) role.Description = description;
			db.SaveChanges();
		}
示例#4
0
 public static Role GetRole(string roleName, SecurityEntities db)
 {
     var query = from row in db.Roles
                 where row.LoweredRoleName == roleName.ToLower() &&
                     row.Application.ApplicationName == System.Web.Security.Roles.ApplicationName
                 select row;
     return query.FirstOrDefault();
 }
示例#5
0
文件: Role.cs 项目: cagrawal21/x360ce
		public static Role GetRole(Guid roleId, SecurityEntities db)
		{
			var query = from row in db.Roles
						where row.RoleId == roleId &&
							row.Application.ApplicationName == System.Web.Security.Roles.ApplicationName
						select row;
			return query.FirstOrDefault();
		}
示例#6
0
        public static Role GetRole(Guid roleId, SecurityEntities db)
        {
            var query = from row in db.Roles
                        where row.RoleId == roleId &&
                        row.Application.ApplicationName == System.Web.Security.Roles.ApplicationName
                        select row;

            return(query.FirstOrDefault());
        }
示例#7
0
        public static Role GetRole(string roleName, SecurityEntities db)
        {
            var query = from row in db.Roles
                        where row.LoweredRoleName == roleName.ToLower() &&
                        row.Application.ApplicationName == System.Web.Security.Roles.ApplicationName
                        select row;

            return(query.FirstOrDefault());
        }
示例#8
0
文件: Check.cs 项目: x360ce/x360ce
        public static void UpdateRole(string roleName, string description)
        {
            var db   = new Data.SecurityEntities();
            var role = db.Roles.FirstOrDefault(x => x.Application.ApplicationName == System.Web.Security.Roles.ApplicationName && x.RoleName == roleName);

            if (role != null)
            {
                role.Description = description;
            }
            db.SaveChanges();
        }
示例#9
0
		public void CreateRole(string roleName, string description, Guid roleId)
		{
			var db = new SecurityEntities();
			var role = new Role();
			role.ApplicationId = ApplicationId;
			role.RoleName = roleName;
			role.RoleId = roleId;
			role.Description = description;
			role.LoweredRoleName = roleName.ToLower();
			db.Roles.AddObject(role);
			db.SaveChanges();
		}
示例#10
0
        public void CreateRole(string roleName, string description, Guid roleId)
        {
            var db   = new SecurityEntities();
            var role = new Role();

            role.ApplicationId   = ApplicationId;
            role.RoleName        = roleName;
            role.RoleId          = roleId;
            role.Description     = description;
            role.LoweredRoleName = roleName.ToLower();
            db.Roles.AddObject(role);
            db.SaveChanges();
        }
示例#11
0
        public static void SendPasswordResetKey(User user, string subject, string body)
        {
            var db       = new SecurityEntities();
            var userId   = user.UserId;
            var m        = db.Memberships.FirstOrDefault(x => x.UserId == userId);
            var resetKey = m.GetPasswordResetToken();
            var resetUrl = JocysCom.ClassLibrary.Security.Helper.GetUrl(resetKey);
            var u        = System.Web.HttpContext.Current.Request.Url;

            subject = subject.Replace("{Host}", u.Host);
            body    = JocysCom.ClassLibrary.Text.Helper.Replace(body, user, false);
            body    = body.Replace("{Host}", u.Host).Replace("{ResetKey}", resetUrl);
            JocysCom.ClassLibrary.Runtime.LogHelper.Current.SendMail(m.Email, subject, body, true);
        }
示例#12
0
 public static void SendPasswordResetKey(User user, string subject, string body)
 {
     var db = new SecurityEntities();
     var userId = user.UserId;
     var m = db.Memberships.FirstOrDefault(x => x.UserId == userId);
     var resetKey = m.GetPasswordResetToken();
     var resetUrl = JocysCom.ClassLibrary.Security.Helper.GetUrl(PasswordResetKey, resetKey);
     var u = System.Web.HttpContext.Current.Request.Url;
     subject = subject.Replace("{Host}", u.Host);
     body = JocysCom.ClassLibrary.Text.Helper.Replace(body, user, false);
     body = body.Replace("{Host}", u.Host).Replace("{ResetKey}", resetUrl);
     var helper = JocysCom.ClassLibrary.Runtime.LogHelper.Current;
     helper.SendMailFrom(helper.Smtp.SmtpFrom, m.Email, "", "", subject, body, true);
 }
示例#13
0
        public static void SendPasswordResetKey(User user, string subject, string body)
        {
            var db       = new SecurityEntities();
            var userId   = user.UserId;
            var m        = db.Memberships.FirstOrDefault(x => x.UserId == userId);
            var resetKey = m.GetPasswordResetToken();
            var resetUrl = JocysCom.ClassLibrary.Security.Helper.GetUrl(resetKey);
            var u        = System.Web.HttpContext.Current.Request.Url;

            subject = subject.Replace("{Host}", u.Host);
            body    = JocysCom.ClassLibrary.Text.Helper.Replace(body, user, false);
            body    = body.Replace("{Host}", u.Host).Replace("{ResetKey}", resetUrl);
            // utilities.Current.SendMail(user.email_to, "", "", subject, body, Nothing)
            //Engine.Mail.Current.Send(user.Membership.Email, user.FullName, subject, body, JocysCom.ClassLibrary.Mail.MailTextType.Plain);
        }
示例#14
0
 public static void CreateDefaultApplication()
 {
     var db = new Data.SecurityEntities();
     var app = db.Applications.FirstOrDefault(x => x.LoweredApplicationName == "/");
     if (app == null)
     {
         app = new Data.Application();
         app.ApplicationName = "/";
         app.LoweredApplicationName = "/";
         app.ApplicationId = new Guid("5985BB89-8015-42E3-9FE1-D7F9FD914EEC");
         app.Description = "Default Application";
         db.Applications.AddObject(app);
         db.SaveChanges();
     }
 }
示例#15
0
文件: Check.cs 项目: x360ce/x360ce
        public static void CreateDefaultApplication()
        {
            var db  = new Data.SecurityEntities();
            var app = db.Applications.FirstOrDefault(x => x.LoweredApplicationName == "/");

            if (app == null)
            {
                app = new Data.Application();
                app.ApplicationName        = "/";
                app.LoweredApplicationName = "/";
                app.ApplicationId          = new Guid("5985BB89-8015-42E3-9FE1-D7F9FD914EEC");
                app.Description            = "Default Application";
                db.Applications.AddObject(app);
                db.SaveChanges();
            }
        }