public IEnumerable <Models.Module> Get(string siteid) { List <ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(int.Parse(siteid)).ToList(); List <Models.Module> modules = new List <Models.Module>(); foreach (PageModule pagemodule in _pageModules.GetPageModules(int.Parse(siteid))) { if (_userPermissions.IsAuthorized(User, "View", pagemodule.Module.Permissions)) { Models.Module module = new Models.Module(); module.SiteId = pagemodule.Module.SiteId; module.ModuleDefinitionName = pagemodule.Module.ModuleDefinitionName; module.Permissions = pagemodule.Module.Permissions; module.CreatedBy = pagemodule.Module.CreatedBy; module.CreatedOn = pagemodule.Module.CreatedOn; module.ModifiedBy = pagemodule.Module.ModifiedBy; module.ModifiedOn = pagemodule.Module.ModifiedOn; module.IsDeleted = pagemodule.IsDeleted; module.PageModuleId = pagemodule.PageModuleId; module.ModuleId = pagemodule.ModuleId; module.PageId = pagemodule.PageId; module.Title = pagemodule.Title; module.Pane = pagemodule.Pane; module.Order = pagemodule.Order; module.ContainerType = pagemodule.ContainerType; module.ModuleDefinition = moduledefinitions.Find(item => item.ModuleDefinitionName == module.ModuleDefinitionName); modules.Add(module); } } return(modules); }
public Models.Module UpdateModule(Models.Module Module) { db.Entry(Module).State = EntityState.Modified; db.SaveChanges(); Permissions.UpdatePermissions(Module.SiteId, "Module", Module.ModuleId, Module.Permissions); return(Module); }
public void PerformDataProcessing() { List <AssetModule> modules = _dbcontext.AssetModules.ToListAsync().Result; foreach (AssetModule module in modules) { Models.Module tempModule = _dbcontext.Modules.Where(M => M.moduleID == module.moduleID).FirstOrDefault(); if (tempModule == null) { continue; } if (tempModule.typeID.Equals("CSV File")) { StreamReader csv = File.OpenText(Directory.GetCurrentDirectory() + tempModule.detail1); StreamReader schema = File.OpenText(Directory.GetCurrentDirectory() + tempModule.detail2); LoadCSV(module, csv, schema); } else { //Normal Data API Connection formation and data fetch } } }
public void Post([FromBody] ModuleDefinition moduleDefinition, string moduleid) { if (ModelState.IsValid) { string templatePath = Path.Combine(Directory.GetParent(_environment.ContentRootPath).FullName, "Oqtane.Client\\Modules\\Admin\\ModuleCreator\\Templates\\" + moduleDefinition.Template + "\\"); string rootPath; if (moduleDefinition.Template == "internal") { rootPath = Directory.GetParent(_environment.ContentRootPath).FullName + "\\"; moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Modules, Oqtane.Client"; moduleDefinition.ServerAssemblyName = "Oqtane.Server"; } else { rootPath = Directory.GetParent(_environment.ContentRootPath).Parent.FullName + "\\" + moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Module\\"; moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Modules, " + moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Module.Client"; moduleDefinition.ServerAssemblyName = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Module.Server"; } ProcessTemplatesRecursively(new DirectoryInfo(templatePath), rootPath, templatePath, moduleDefinition); _logger.Log(LogLevel.Information, this, LogFunction.Create, "Module Definition Created {ModuleDefinition}", moduleDefinition); Models.Module module = _modules.GetModule(int.Parse(moduleid)); module.ModuleDefinitionName = moduleDefinition.ModuleDefinitionName; _modules.UpdateModule(module); _installationManager.RestartApplication(); } }
public void DeleteModule(int ModuleId) { Models.Module Module = db.Module.Find(ModuleId); Permissions.DeletePermissions(Module.SiteId, "Module", ModuleId); db.Module.Remove(Module); db.SaveChanges(); }
public Models.Module AddModule(Models.Module Module) { db.Module.Add(Module); db.SaveChanges(); Permissions.UpdatePermissions(Module.SiteId, "Module", Module.ModuleId, Module.Permissions); return(Module); }
public IEnumerable <Models.Module> Get(string siteid) { List <Models.Module> modulelist = new List <Models.Module>(); foreach (PageModule pagemodule in PageModules.GetPageModules(int.Parse(siteid))) { Models.Module module = new Models.Module(); module.SiteId = pagemodule.Module.SiteId; module.ModuleDefinitionName = pagemodule.Module.ModuleDefinitionName; module.Permissions = pagemodule.Module.Permissions; module.CreatedBy = pagemodule.Module.CreatedBy; module.CreatedOn = pagemodule.Module.CreatedOn; module.ModifiedBy = pagemodule.Module.ModifiedBy; module.ModifiedOn = pagemodule.Module.ModifiedOn; module.IsDeleted = pagemodule.IsDeleted; module.PageModuleId = pagemodule.PageModuleId; module.ModuleId = pagemodule.ModuleId; module.PageId = pagemodule.PageId; module.Title = pagemodule.Title; module.Pane = pagemodule.Pane; module.Order = pagemodule.Order; module.ContainerType = pagemodule.ContainerType; modulelist.Add(module); } return(modulelist); }
public Models.Module Put(int id, [FromBody] Models.Module Module) { if (ModelState.IsValid) { Module = Modules.UpdateModule(Module); } return(Module); }
public Models.Module Post([FromBody] Models.Module Module) { if (ModelState.IsValid) { Module = Modules.AddModule(Module); } return(Module); }
public Models.Module Post([FromBody] Models.Module Module) { if (ModelState.IsValid && UserPermissions.IsAuthorized(User, "Edit", Module.Permissions)) { Module = Modules.AddModule(Module); logger.Log(LogLevel.Information, this, LogFunction.Create, "Module Added {Module}", Module); } return(Module); }
public Models.Module Post([FromBody] Models.Module Module) { if (ModelState.IsValid) { Module = Modules.AddModule(Module); logger.Log(LogLevel.Information, this, LogFunction.Create, "Module Added {Module}", Module); } return(Module); }
public Models.Module Put(int id, [FromBody] Models.Module Module) { if (ModelState.IsValid && UserPermissions.IsAuthorized(User, "Module", Module.ModuleId, "Edit")) { Module = Modules.UpdateModule(Module); logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Updated {Module}", Module); } return(Module); }
public Models.Module Put(int id, [FromBody] Models.Module Module) { if (ModelState.IsValid) { Module = Modules.UpdateModule(Module); logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Updated {Module}", Module); } return(Module); }
public IActionResult SelectModule(Models.Module mod) { ModelState.Clear(); ViewBag.Mod_Code = mod.Mod_Code; return(View(nameof(Index), sys_reg_repository.SystemRegistrations.FirstOrDefault( r => r.Syr_Cst_Code == GetKeyField("Syr_Cst_Code") && r.Syr_Sys_Code == GetKeyField("Syr_Sys_Code") && r.Syr_Ver_Code == GetKeyField("Syr_Ver_Code")))); }
public RedirectToActionResult Delete(Models.Module mod) { if (ModelState.IsValid) { repository.DeleteModule(mod.Mod_Code, mod.Mod_Sys_Code); } // ModelState.Clear(); return(RedirectToAction(nameof(Index))); }
public Models.Module GetModule(int ModuleId) { Models.Module module = db.Module.Find(ModuleId); if (module != null) { List <Permission> permissions = Permissions.GetPermissions("Module", module.ModuleId).ToList(); module.Permissions = Permissions.EncodePermissions(module.ModuleId, permissions); } return(module); }
public IActionResult SelectModule(Models.Module mod) { return(RedirectToAction(nameof(SystemRegistrationForm), new { cst_code = GetKeyField("Syr_Cst_Code"), sys_code = GetKeyField("Syr_Sys_Code"), ver_code = GetKeyField("Syr_Ver_Code"), mod_code = mod.Mod_Code, cur_tab = "Enhancement" })); }
//Saves the module data to the database using the module object public static void saveModule(DataRow row, CSResults.DAL.ModuleContext context) { Models.Module md = new Models.Module() { moduleID = row["Module Code"].ToString(), moduleName = row["Module Name"].ToString() }; //Adds the module name and code if it does not exist in the databse context.Module.AddOrUpdate(x => x.moduleID, md); context.SaveChanges(); }
public IActionResult SelectModule(Models.Module mod) { HttpContext.Session.TryGetValue("Cst_Code", out var Cst_Code); HttpContext.Session.TryGetValue("Sys_Code", out var Sys_Code); HttpContext.Session.TryGetValue("Ver_Code", out var Ver_Code); ModelState.Clear(); ViewBag.Mod_Code = mod.Mod_Code; return(View(nameof(Index), sys_reg_repository.SystemRegistrations.FirstOrDefault( r => r.Syr_Cst_Code == Encoding.ASCII.GetString(Cst_Code, 0, Cst_Code.Length) && r.Syr_Sys_Code == Encoding.ASCII.GetString(Sys_Code, 0, Sys_Code.Length) && r.Syr_Ver_Code == Encoding.ASCII.GetString(Ver_Code, 0, Ver_Code.Length)))); }
public IHttpActionResult AddModuleToCourse(CourseAPIDto dto) { var module = new Models.Module() { CourseId = dto.CourseId, Name = dto.Name, StartDate = dto.StartDate, EndDate = dto.EndDate }; _context.Modules.Add(module); _context.SaveChanges(); return(Ok(module)); }
public string Export(int moduleid) { string content = ""; if (UserPermissions.IsAuthorized(User, "Module", moduleid, "View")) { try { Models.Module module = Modules.GetModule(moduleid); if (module != null) { List <ModuleDefinition> moduledefinitions = ModuleDefinitions.GetModuleDefinitions(module.SiteId).ToList(); ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == module.ModuleDefinitionName).FirstOrDefault(); if (moduledefinition != null) { ModuleContent modulecontent = new ModuleContent(); modulecontent.ModuleDefinitionName = moduledefinition.ModuleDefinitionName; modulecontent.Version = moduledefinition.Version; modulecontent.Content = ""; if (moduledefinition.ServerAssemblyName != "") { Assembly assembly = AppDomain.CurrentDomain.GetAssemblies() .Where(item => item.FullName.StartsWith(moduledefinition.ServerAssemblyName)).FirstOrDefault(); if (assembly != null) { Type moduletype = assembly.GetTypes() .Where(item => item.Namespace != null) .Where(item => item.Namespace.StartsWith(moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(",")))) .Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault(); if (moduletype != null) { var moduleobject = ActivatorUtilities.CreateInstance(ServiceProvider, moduletype); modulecontent.Content = ((IPortable)moduleobject).ExportModule(module); } } } content = JsonSerializer.Serialize(modulecontent); logger.Log(LogLevel.Information, this, LogFunction.Read, "Module Content Exported {ModuleId}", moduleid); } } } catch { // error occurred during export } } return(content); }
public Models.Module Put(int id, [FromBody] Models.Module Module) { if (ModelState.IsValid && UserPermissions.IsAuthorized(User, "Module", Module.ModuleId, "Edit")) { Module = Modules.UpdateModule(Module); logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Updated {Module}", Module); } else { logger.Log(LogLevel.Error, this, LogFunction.Update, "User Not Authorized To Update Module {Module}", Module); HttpContext.Response.StatusCode = 401; Module = null; } return(Module); }
public Models.Module Post([FromBody] Models.Module Module) { if (ModelState.IsValid && _userPermissions.IsAuthorized(User, "Page", Module.PageId, "Edit")) { Module = _modules.AddModule(Module); _logger.Log(LogLevel.Information, this, LogFunction.Create, "Module Added {Module}", Module); } else { _logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Module {Module}", Module); HttpContext.Response.StatusCode = 401; Module = null; } return(Module); }
public bool Import(int moduleid, [FromBody] string Content) { bool success = false; if (ModelState.IsValid && UserPermissions.IsAuthorized(User, "Module", moduleid, "Edit")) { try { Models.Module module = Modules.GetModule(moduleid); if (module != null) { List <ModuleDefinition> moduledefinitions = ModuleDefinitions.GetModuleDefinitions(module.SiteId).ToList(); ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == module.ModuleDefinitionName).FirstOrDefault(); if (moduledefinition != null) { ModuleContent modulecontent = JsonSerializer.Deserialize <ModuleContent>(Content); if (modulecontent.ModuleDefinitionName == moduledefinition.ModuleDefinitionName) { if (moduledefinition.ServerAssemblyName != "") { Assembly assembly = AppDomain.CurrentDomain.GetAssemblies() .Where(item => item.FullName.StartsWith(moduledefinition.ServerAssemblyName)).FirstOrDefault(); if (assembly != null) { Type moduletype = assembly.GetTypes() .Where(item => item.Namespace != null) .Where(item => item.Namespace.StartsWith(moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(",")))) .Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault(); if (moduletype != null) { var moduleobject = ActivatorUtilities.CreateInstance(ServiceProvider, moduletype); ((IPortable)moduleobject).ImportModule(module, modulecontent.Content, modulecontent.Version); success = true; logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Content Imported {ModuleId}", moduleid); } } } } } } } catch { // error occurred during import } } return(success); }
public Models.Module Get(int id) { Models.Module module = _modules.GetModule(id); if (_userPermissions.IsAuthorized(User, "View", module.Permissions)) { List <ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(module.SiteId).ToList(); module.ModuleDefinition = moduledefinitions.Find(item => item.ModuleDefinitionName == module.ModuleDefinitionName); return(module); } else { _logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Access Module {Module}", module); HttpContext.Response.StatusCode = 401; return(null); } }
public string ExportModule(int ModuleId) { string content = ""; try { Models.Module module = GetModule(ModuleId); if (module != null) { List <ModuleDefinition> moduledefinitions = _moduleDefinitions.GetModuleDefinitions(module.SiteId).ToList(); ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == module.ModuleDefinitionName).FirstOrDefault(); if (moduledefinition != null) { ModuleContent modulecontent = new ModuleContent(); modulecontent.ModuleDefinitionName = moduledefinition.ModuleDefinitionName; modulecontent.Version = moduledefinition.Version; modulecontent.Content = ""; if (moduledefinition.ServerAssemblyName != "") { Assembly assembly = AppDomain.CurrentDomain.GetAssemblies() .Where(item => item.FullName.StartsWith(moduledefinition.ServerAssemblyName)).FirstOrDefault(); if (assembly != null) { Type moduletype = assembly.GetTypes() .Where(item => item.Namespace != null) .Where(item => item.Namespace.StartsWith(moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(",")))) .Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault(); if (moduletype != null) { var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype); modulecontent.Content = ((IPortable)moduleobject).ExportModule(module); } } } content = JsonSerializer.Serialize(modulecontent); } } } catch { // error occurred during export } return(content); }
public bool ImportModule(int ModuleId, string Content) { bool success = false; try { Models.Module module = GetModule(ModuleId); if (module != null) { List <ModuleDefinition> moduledefinitions = ModuleDefinitions.GetModuleDefinitions(module.SiteId).ToList(); ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionName == module.ModuleDefinitionName).FirstOrDefault(); if (moduledefinition != null) { ModuleContent modulecontent = JsonSerializer.Deserialize <ModuleContent>(Content); if (modulecontent.ModuleDefinitionName == moduledefinition.ModuleDefinitionName) { if (moduledefinition.ServerAssemblyName != "") { Assembly assembly = AppDomain.CurrentDomain.GetAssemblies() .Where(item => item.FullName.StartsWith(moduledefinition.ServerAssemblyName)).FirstOrDefault(); if (assembly != null) { Type moduletype = assembly.GetTypes() .Where(item => item.Namespace != null) .Where(item => item.Namespace.StartsWith(moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(",")))) .Where(item => item.GetInterfaces().Contains(typeof(IPortable))).FirstOrDefault(); if (moduletype != null) { var moduleobject = ActivatorUtilities.CreateInstance(ServiceProvider, moduletype); ((IPortable)moduleobject).ImportModule(module, modulecontent.Content, modulecontent.Version); success = true; } } } } } } } catch { // error occurred during import } return(success); }
public void Post([FromBody] ModuleDefinition moduleDefinition, string moduleid) { if (ModelState.IsValid) { string rootPath; DirectoryInfo rootFolder = Directory.GetParent(_environment.ContentRootPath); string templatePath = Utilities.PathCombine(_environment.WebRootPath, "Modules", "Templates", moduleDefinition.Template, Path.DirectorySeparatorChar.ToString()); if (moduleDefinition.Template == "internal") { rootPath = Utilities.PathCombine(rootFolder.FullName, Path.DirectorySeparatorChar.ToString()); moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + ", Oqtane.Client"; moduleDefinition.ServerManagerType = moduleDefinition.Owner + "." + moduleDefinition.Name + ".Manager." + moduleDefinition.Name + "Manager, Oqtane.Server"; } else { rootPath = Utilities.PathCombine(rootFolder.Parent.FullName, moduleDefinition.Owner + "." + moduleDefinition.Name, Path.DirectorySeparatorChar.ToString()); moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + ", " + moduleDefinition.Owner + "." + moduleDefinition.Name + ".Client.Oqtane"; moduleDefinition.ServerManagerType = moduleDefinition.Owner + "." + moduleDefinition.Name + ".Manager." + moduleDefinition.Name + "Manager, " + moduleDefinition.Owner + "." + moduleDefinition.Name + ".Server.Oqtane"; } ProcessTemplatesRecursively(new DirectoryInfo(templatePath), rootPath, rootFolder.Name, templatePath, moduleDefinition); _logger.Log(LogLevel.Information, this, LogFunction.Create, "Module Definition Created {ModuleDefinition}", moduleDefinition); Models.Module module = _modules.GetModule(int.Parse(moduleid)); module.ModuleDefinitionName = moduleDefinition.ModuleDefinitionName; _modules.UpdateModule(module); if (moduleDefinition.Template == "internal") { // add embedded resources to project List <string> resources = new List <string>(); resources.Add(Utilities.PathCombine("Modules", moduleDefinition.Owner + "." + moduleDefinition.Name, "Scripts", moduleDefinition.Owner + "." + moduleDefinition.Name + ".1.0.0.sql")); resources.Add(Utilities.PathCombine("Modules", moduleDefinition.Owner + "." + moduleDefinition.Name, "Scripts", moduleDefinition.Owner + "." + moduleDefinition.Name + ".Uninstall.sql")); EmbedResourceFiles(Utilities.PathCombine(rootPath, "Oqtane.Server", "Oqtane.Server.csproj"), resources); } _installationManager.RestartApplication(); } }
public static Models.Module Rechercher(string CODEModule) { Models.Module e = new Models.Module(); try { DataTable t = Controlers.DB.PROC_DS_Params("unmodule", new SqlParameter[] { new SqlParameter("@codem", int.Parse(CODEModule)) }).Tables[0]; if (t.Rows.Count != 0) { //instancier l'Etudiant trouvé e = new Models.Module(int.Parse(t.Rows[0][0].ToString()), t.Rows[0][0].ToString(), int.Parse(t.Rows[0][0].ToString()), DateTime.Parse(t.Rows[0][0].ToString()), DateTime.Parse(t.Rows[0][0].ToString())); } return(e); } catch { return(e); } }
public async Task UpdateModuleHeartbeat(Models.Module module) { using (DataContext = new SimplySecureDataContext()) { var dbModule = await DataContext.Modules.Where (m => m.Id == module.Id).SingleOrDefaultAsync(); if (dbModule == null) { DataContext.Modules.Add(module); await DataContext.SaveChangesAsync(); return; } dbModule.LastHeartbeat = DateTime.UtcNow; dbModule.State = module.State; DataContext.Modules.Update(dbModule); await DataContext.SaveChangesAsync(); } }