コード例 #1
0
        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);
        }
コード例 #2
0
 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);
 }
コード例 #3
0
        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
                }
            }
        }
コード例 #4
0
        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();
            }
        }
コード例 #5
0
 public void DeleteModule(int ModuleId)
 {
     Models.Module Module = db.Module.Find(ModuleId);
     Permissions.DeletePermissions(Module.SiteId, "Module", ModuleId);
     db.Module.Remove(Module);
     db.SaveChanges();
 }
コード例 #6
0
 public Models.Module AddModule(Models.Module Module)
 {
     db.Module.Add(Module);
     db.SaveChanges();
     Permissions.UpdatePermissions(Module.SiteId, "Module", Module.ModuleId, Module.Permissions);
     return(Module);
 }
コード例 #7
0
        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);
        }
コード例 #8
0
 public Models.Module Put(int id, [FromBody] Models.Module Module)
 {
     if (ModelState.IsValid)
     {
         Module = Modules.UpdateModule(Module);
     }
     return(Module);
 }
コード例 #9
0
 public Models.Module Post([FromBody] Models.Module Module)
 {
     if (ModelState.IsValid)
     {
         Module = Modules.AddModule(Module);
     }
     return(Module);
 }
コード例 #10
0
 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);
 }
コード例 #11
0
 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);
 }
コード例 #12
0
 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);
 }
コード例 #13
0
 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"))));
 }
コード例 #15
0
        public RedirectToActionResult Delete(Models.Module mod)
        {
            if (ModelState.IsValid)
            {
                repository.DeleteModule(mod.Mod_Code, mod.Mod_Sys_Code);
            }

            // ModelState.Clear();
            return(RedirectToAction(nameof(Index)));
        }
コード例 #16
0
 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);
 }
コード例 #17
0
 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"
     }));
 }
コード例 #18
0
ファイル: LoadExceltoDB.cs プロジェクト: chrisateen/CSResults
        //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();
        }
コード例 #19
0
 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))));
 }
コード例 #20
0
        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));
        }
コード例 #21
0
        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);
        }
コード例 #22
0
 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);
 }
コード例 #23
0
 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);
 }
コード例 #24
0
        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);
        }
コード例 #25
0
 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);
     }
 }
コード例 #26
0
        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);
        }
コード例 #27
0
        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);
        }
コード例 #28
0
        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();
            }
        }
コード例 #29
0
ファイル: CMOD.cs プロジェクト: H-Mohamed/GESTION-ISTA-MVC
 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);
     }
 }
コード例 #30
0
        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();
            }
        }