コード例 #1
0
 // TODO: Refactor to own component
 private async ValueTask <Module> GetModuleAsync(ModuleIdentifier module, CancellationToken cancellation)
 {
     using (var scope = _serviceProvider.CreateScope())
     {
         var storageEngine = scope.ServiceProvider.GetRequiredService <IEntityStorageEngine>();
         return(await storageEngine.GetByIdAsync <Module>(module.ToString(), cancellation));
     }
 }
コード例 #2
0
        public static Guid?get_report_id(ModuleIdentifier moduleIdentifier, string reportName)
        {
            string name = (moduleIdentifier.ToString() + "_" + reportName).ToLower();
            Guid?  id   = null;

            if (ReportIDs.Any(u => u.Key.ToLower() == name))
            {
                id = ReportIDs.Where(u => u.Key.ToLower() == name).First().Value;
            }
            return(id);
        }
コード例 #3
0
        public ConfigCatalog LoadCatalogForModule(ModuleIdentifier module)
        {
            var dir     = optionsMonitor.CurrentValue.Source;
            var catalog = new ConfigCatalog()
            {
                ModuleInfo = new ModuleInfo()
                {
                    Identifier = module
                }
            };

            var basename = Path.Combine(dir, module.ToString());

            if (File.Exists(basename + ".json"))
            {
                logger.LogTrace($"load catalog file [{basename}.json]");
                string content = File.ReadAllText(basename + ".json");
                catalog = JsonConvert.DeserializeObject <ConfigCatalog>(content);
            }
            if (Directory.Exists(basename))
            {
                logger.LogTrace($"load catalog dir [{basename}]");
                var sections = new List <ConfigCatalog.Section>();
                foreach (var file in Directory.GetFiles(basename))
                {
                    logger.LogTrace($"-> loading {file}");
                    if (Path.GetExtension(file).ToLower() != ".json")
                    {
                        break;
                    }
                    string content = File.ReadAllText(file);
                    if (Path.GetFileNameWithoutExtension(file) == "moduleinfo")
                    {
                        catalog.ModuleInfo = JsonConvert.DeserializeObject <ModuleInfo>(content);
                    }
                    else
                    {
                        var section = JsonConvert.DeserializeObject <ConfigCatalog.Section>(content);
                        sections.Add(section);
                    }
                }
                catalog.Sections = sections.ToArray();
            }

            return(catalog);
        }
コード例 #4
0
        public static bool succeed(int value, ModuleIdentifier moduleIdentifier, ref string message)
        {
            _fill();

            if (value > 0)
            {
                message = _ErrorMessages["Succeed"];
                return(true);
            }
            else if (value == 0)
            {
                message = _ErrorMessages["Failed"];
                return(false);
            }
            else
            {
                string str = moduleIdentifier.ToString() + (-value).ToString();
                message = _ErrorMessages[str];
                return(false);
            }
        }
コード例 #5
0
 private static string GetFullyQualifiedName(string name, ModuleIdentifier moduleIdentifier = ModuleIdentifier.RPT)
 {
     return("[dbo]." + "[" + moduleIdentifier.ToString() + "_" + name + "]"); //'[dbo].' is database owner and 'RPT_' is module qualifier
 }