public Alias AddAlias(Alias Alias)
 {
     db.Alias.Add(Alias);
     db.SaveChanges();
     _cache.Remove("aliases");
     return(Alias);
 }
Example #2
0
 public Job AddJob(Job job)
 {
     _db.Job.Add(job);
     _db.SaveChanges();
     _cache.Remove("jobs");
     return(job);
 }
 public Tenant AddTenant(Tenant Tenant)
 {
     db.Tenant.Add(Tenant);
     db.SaveChanges();
     _cache.Remove("tenants");
     return(Tenant);
 }
Example #4
0
 public void UpdateModuleDefinition(ModuleDefinition moduleDefinition)
 {
     _db.Entry(moduleDefinition).State = EntityState.Modified;
     _db.SaveChanges();
     _permissions.UpdatePermissions(moduleDefinition.SiteId, EntityNames.ModuleDefinition, moduleDefinition.ModuleDefinitionId, moduleDefinition.Permissions);
     _cache.Remove("moduledefinitions:" + moduleDefinition.SiteId.ToString());
 }
        public void DeleteModuleDefinition(int moduleDefinitionId, int siteId)
        {
            ModuleDefinition moduleDefinition = _db.ModuleDefinition.Find(moduleDefinitionId);

            _permissions.DeletePermissions(siteId, EntityNames.ModuleDefinition, moduleDefinitionId);
            _db.ModuleDefinition.Remove(moduleDefinition);
            _db.SaveChanges();
        }
Example #6
0
        public void DeleteModuleDefinition(int ModuleDefinitionId, int SiteId)
        {
            ModuleDefinition ModuleDefinition = _db.ModuleDefinition.Find(ModuleDefinitionId);

            _permissions.DeletePermissions(SiteId, "ModuleDefinition", ModuleDefinitionId);
            _db.ModuleDefinition.Remove(ModuleDefinition);
            _db.SaveChanges();
            _cache.Remove("moduledefinitions");
        }
Example #7
0
 public void AddTenant(Tenant tenant)
 {
     try
     {
         db.Tenant.Add(tenant);
         db.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
 public void AddAlias(Alias alias)
 {
     try
     {
         db.Alias.Add(alias);
         db.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
Example #9
0
 public Alias AddAlias(Alias Alias)
 {
     try
     {
         db.Alias.Add(Alias);
         db.SaveChanges();
         return(Alias);
     }
     catch
     {
         throw;
     }
 }
Example #10
0
 public Tenant AddTenant(Tenant Tenant)
 {
     try
     {
         db.Tenant.Add(Tenant);
         db.SaveChanges();
         return(Tenant);
     }
     catch
     {
         throw;
     }
 }
        private List <ModuleDefinition> LoadModuleDefinitions(int SiteId)
        {
            List <ModuleDefinition> ModuleDefinitions;

            ModuleDefinitions = _cache.GetOrCreate("moduledefinitions", entry =>
            {
                entry.SlidingExpiration = TimeSpan.FromMinutes(30);
                return(LoadModuleDefinitionsFromAssemblies());
            });

            // sync module definitions with database
            List <ModuleDefinition> moduledefs = db.ModuleDefinition.ToList();

            foreach (ModuleDefinition moduledefinition in ModuleDefinitions)
            {
                IEnumerable <Permission> permissions = Permissions.GetPermissions(SiteId, "ModuleDefinition").ToList();
                ModuleDefinition         moduledef   = moduledefs.Where(item => item.ModuleDefinitionName == moduledefinition.ModuleDefinitionName).FirstOrDefault();
                if (moduledef == null)
                {
                    moduledef = new ModuleDefinition {
                        ModuleDefinitionName = moduledefinition.ModuleDefinitionName
                    };
                    db.ModuleDefinition.Add(moduledef);
                    db.SaveChanges();
                    if (moduledefinition.Permissions != "")
                    {
                        Permissions.UpdatePermissions(SiteId, "ModuleDefinition", moduledef.ModuleDefinitionId, moduledefinition.Permissions);
                    }
                }
                else
                {
                    moduledefs.Remove(moduledef); // remove module definition from list
                }
                moduledefinition.ModuleDefinitionId = moduledef.ModuleDefinitionId;
                moduledefinition.SiteId             = SiteId;
                moduledefinition.Permissions        = Permissions.EncodePermissions(moduledefinition.ModuleDefinitionId, permissions);
                moduledefinition.CreatedBy          = moduledef.CreatedBy;
                moduledefinition.CreatedOn          = moduledef.CreatedOn;
                moduledefinition.ModifiedBy         = moduledef.ModifiedBy;
                moduledefinition.ModifiedOn         = moduledef.ModifiedOn;
            }

            // any remaining module definitions are orphans
            foreach (ModuleDefinition moduledefinition in moduledefs)
            {
                db.ModuleDefinition.Remove(moduledefinition); // delete
            }

            return(ModuleDefinitions);
        }
Example #12
0
 public Setting AddSetting(Setting setting)
 {
     if (IsMaster(setting.EntityName))
     {
         _master.Setting.Add(setting);
         _master.SaveChanges();
     }
     else
     {
         _tenant.Setting.Add(setting);
         _tenant.SaveChanges();
     }
     return(setting);
 }
Example #13
0
        private List <ModuleDefinition> LoadModuleDefinitions(int SiteId)
        {
            List <ModuleDefinition> ModuleDefinitions = new List <ModuleDefinition>();

            // iterate through Oqtane module assemblies
            Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies()
                                    .Where(item => item.FullName.StartsWith("Oqtane.") || item.FullName.Contains(".Module.")).ToArray();
            foreach (Assembly assembly in assemblies)
            {
                ModuleDefinitions = LoadModuleDefinitionsFromAssembly(ModuleDefinitions, assembly);
            }

            // sync module definitions with database
            List <ModuleDefinition> moduledefs = db.ModuleDefinition.ToList();

            foreach (ModuleDefinition moduledefinition in ModuleDefinitions)
            {
                IEnumerable <Permission> permissions = Permissions.GetPermissions(SiteId, "ModuleDefinition").ToList();
                ModuleDefinition         moduledef   = moduledefs.Where(item => item.ModuleDefinitionName == moduledefinition.ModuleDefinitionName).FirstOrDefault();
                if (moduledef == null)
                {
                    moduledef = new ModuleDefinition {
                        ModuleDefinitionName = moduledefinition.ModuleDefinitionName
                    };
                    db.ModuleDefinition.Add(moduledef);
                    db.SaveChanges();
                }
                else
                {
                    moduledefs.Remove(moduledef); // remove module definition from list
                }
                moduledefinition.ModuleDefinitionId = moduledef.ModuleDefinitionId;
                moduledefinition.SiteId             = SiteId;
                moduledefinition.Permissions        = Permissions.EncodePermissions(moduledefinition.ModuleDefinitionId, permissions);
                moduledefinition.CreatedBy          = moduledef.CreatedBy;
                moduledefinition.CreatedOn          = moduledef.CreatedOn;
                moduledefinition.ModifiedBy         = moduledef.ModifiedBy;
                moduledefinition.ModifiedOn         = moduledef.ModifiedOn;
            }

            // any remaining module definitions are orphans
            foreach (ModuleDefinition moduledefinition in moduledefs)
            {
                db.ModuleDefinition.Remove(moduledefinition); // delete
            }

            return(ModuleDefinitions);
        }
Example #14
0
 public Job AddJob(Job Job)
 {
     db.Job.Add(Job);
     db.SaveChanges();
     return(Job);
 }
 public ScheduleLog AddScheduleLog(ScheduleLog ScheduleLog)
 {
     db.ScheduleLog.Add(ScheduleLog);
     db.SaveChanges();
     return(ScheduleLog);
 }
 public Schedule AddSchedule(Schedule Schedule)
 {
     db.Schedule.Add(Schedule);
     db.SaveChanges();
     return(Schedule);
 }
Example #17
0
 public JobLog AddJobLog(JobLog jobLog)
 {
     _db.JobLog.Add(jobLog);
     _db.SaveChanges();
     return(jobLog);
 }
 public Tenant AddTenant(Tenant Tenant)
 {
     db.Tenant.Add(Tenant);
     db.SaveChanges();
     return(Tenant);
 }
Example #19
0
 public JobLog AddJobLog(JobLog JobLog)
 {
     db.JobLog.Add(JobLog);
     db.SaveChanges();
     return(JobLog);
 }
 public void UpdateModuleDefinition(ModuleDefinition moduleDefinition)
 {
     _db.Entry(moduleDefinition).State = EntityState.Modified;
     _db.SaveChanges();
     _permissions.UpdatePermissions(moduleDefinition.SiteId, EntityNames.ModuleDefinition, moduleDefinition.ModuleDefinitionId, moduleDefinition.Permissions);
 }
 public Alias AddAlias(Alias Alias)
 {
     db.Alias.Add(Alias);
     db.SaveChanges();
     return(Alias);
 }