Пример #1
0
        public ViewTemplateViewModel(ViewTemplates viewTemplates)
        {
            _viewsTemplatesSource = viewTemplates;

            this.LoadData( );
            this.LoadAvailableTools( );
        }
Пример #2
0
        public ActionResult Index()
        {
            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name");
            //var tempp = new ViewTemplates();
            Template second = new Template();
            //User user = db.Users.Where(m => m.Login == HttpContext.User.Identity.Name).FirstOrDefault();
            ViewTemplates viewtemp = new ViewTemplates();

            var templs = db.Templates
                         .OrderByDescending(t => t.Name);
            //  templs.ToList();
            IEnumerable <Template> temp = templs as IEnumerable <Template>;

            viewtemp.Templates = temp;
            viewtemp.Template  = second;// упорядочиваем по имени шаблона заявки
            return(View(viewtemp));

            //return View();
        }
Пример #3
0
        public override string Generate(Table table, GeneratorOptions options)
        {
            //throw new NotImplementedException();

            var template = new ViewTemplates();

            template.Session = new Dictionary <string, object>();

            var fk = table.ForeignKeys.ToForegnTableColumns();

            template.Session.Add("foregnkeys", fk);

            template.Session.Add("table", table);
            template.Session.Add("tableName", table.TableName);
            template.Session.Add("tableNameToLower", table.TableName.ToLower());
            template.Session.Add("tableNameToPascal", table.TableName.ToPascalCase());
            template.Session.Add("options", options);
            template.Session.Add("columns", table.InsertableColumns);
            template.Initialize();

            return(template.TransformText());
        }
Пример #4
0
        public static int Main(string[] args)
        {
            using var webhost = CreateHostBuilder(args).Build();

            using var scope = webhost.Services.CreateScope();
            var config = scope.ServiceProvider.GetRequiredService <IConfiguration>();

            var instance = config[ConfigurationKey.InstanceName] ?? "n/a";

            var webHostEnvironment = scope.ServiceProvider
                                     .GetRequiredService <IWebHostEnvironment>();

            Log.Logger = LogConfig.Build(config).CreateLogger();
            Log.Information("GRA v{Version} instance {Instance} environment {Environment} in {WebRootPath} with content root {ContentRoot}",
                            new Version().GetVersion(),
                            instance,
                            config[EnvAspNetCoreEnv] ?? "Production",
                            webHostEnvironment.WebRootPath,
                            config[ConfigurationKey.InternalContentPath]);

            if (!string.IsNullOrEmpty(config[EnvRunningInContainer]))
            {
                Log.Information("Containerized: commit {ContainerCommit} created on {ContainerDate} image {ContainerImageVersion}",
                                config["org.opencontainers.image.revision"] ?? "unknown",
                                config["org.opencontainers.image.created"] ?? "unknown",
                                config["org.opencontainers.image.version"] ?? "unknown");
            }

            ViewTemplates.CopyToShared(config[ConfigurationKey.InternalContentPath], Log.Logger);

            switch (config[ConfigurationKey.DistributedCache]?.ToLower(Culture.DefaultCulture))
            {
            case "redis":
                Log.Information("Cache: Redis config {RedisConfig} discriminator {RedisDiscriminator}",
                                config[ConfigurationKey.RuntimeCacheRedisConfiguration],
                                config[ConfigurationKey.RuntimeCacheRedisInstance]);
                break;

            case "sqlserver":
                Log.Information("Cache: SQL Server in table {SQLCacheTable}",
                                config[ConfigurationKey.RuntimeCacheSqlConfiguration]);
                break;

            default:
                Log.Information("Cache: in-memory");
                break;
            }
            try
            {
                Task.Run(() => new WebStartup(scope).InitalizeAsync()).Wait();
            }
            catch (StackExchange.Redis.RedisConnectionException ex)
            {
                Log.Fatal("Redis is configured for {RedisConfig} but failed: {ErrorMessage}",
                          config[ConfigurationKey.RuntimeCacheRedisConfiguration],
                          ex.Message);
                throw;
            }

            // output the version and revision
            try
            {
                webhost.Run();
                return(0);
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception ex)
            {
                Log.Warning("GRA v{Version} {Instance} exited unexpectedly: {Message}",
                            new Version().GetVersion(),
                            instance,
                            ex.Message);
                return(1);
            }
#pragma warning restore CA1031 // Do not catch general exception types
            finally
            {
                Log.Warning("GRA v{Version} {Instance} shutting down.",
                            new Version().GetVersion(),
                            instance);
                Log.CloseAndFlush();
            }
        }
Пример #5
0
        public static int Main(string[] args)
        {
            using var webhost = CreateHostBuilder(args).Build();

            using var scope = webhost.Services.CreateScope();
            var config = scope.ServiceProvider.GetRequiredService <IConfiguration>();

            var instance = config[ConfigurationKey.InstanceName] ?? "n/a";

            var webHostEnvironment = scope.ServiceProvider
                                     .GetRequiredService <IWebHostEnvironment>();

            Log.Logger = LogConfig.Build(config).CreateLogger();
            Log.Information("GRA v{Version} instance {Instance} environment {Environment} in {WebRootPath} with content root {ContentRoot}",
                            Version.GetVersion(),
                            instance,
                            config[EnvAspNetCoreEnv] ?? "Production",
                            webHostEnvironment.WebRootPath,
                            config[ConfigurationKey.InternalContentPath]);

            if (!string.IsNullOrEmpty(config[EnvRunningInContainer]))
            {
                Log.Information("Containerized: commit {ContainerCommit} created on {ContainerDate} image {ContainerImageVersion}",
                                config["org.opencontainers.image.revision"] ?? "unknown",
                                config["org.opencontainers.image.created"] ?? "unknown",
                                config["org.opencontainers.image.version"] ?? "unknown");
            }

            ViewTemplates.CopyToShared(config[ConfigurationKey.InternalContentPath], Log.Logger);

            switch (config[ConfigurationKey.DistributedCache]?.ToLower(Culture.DefaultCulture))
            {
            case "redis":
                Log.Information("Cache: Redis config {RedisConfig} discriminator {RedisDiscriminator}",
                                config[ConfigurationKey.RuntimeCacheRedisConfiguration],
                                config[ConfigurationKey.RuntimeCacheRedisInstance]);
                break;

            case "sqlserver":
                Log.Information("Cache: SQL Server in table {SQLCacheTable}",
                                config[ConfigurationKey.RuntimeCacheSqlConfiguration]);
                break;

            default:
                Log.Information("Cache: in-memory");
                break;
            }
            try
            {
                Task.Run(() => new WebStartup(scope).InitalizeAsync()).Wait();
            }
            catch (StackExchange.Redis.RedisConnectionException ex)
            {
                Log.Fatal("Redis is configured for {RedisConfig} but failed: {ErrorMessage}",
                          config[ConfigurationKey.RuntimeCacheRedisConfiguration],
                          ex.Message);
                throw;
            }

            if (!string.IsNullOrEmpty(config[ConfigurationKey.WorkerThreads]) ||
                !string.IsNullOrEmpty(config[ConfigurationKey.CompletionPortThreads]))
            {
                ThreadPool.GetMinThreads(out int minThreads, out int minCompletionPortThreads);
                var setThreads = minThreads;
                var setCompletionPortThreads = minCompletionPortThreads;
                if (!string.IsNullOrEmpty(config[ConfigurationKey.WorkerThreads]))
                {
                    if (int.TryParse(config[ConfigurationKey.WorkerThreads], out int threads))
                    {
                        if (threads > minThreads)
                        {
                            setThreads = threads;
                        }
                        else
                        {
                            Log.Error("Configured {SettingName} to value {Value} would place it below the minimum {Minimum}",
                                      ConfigurationKey.WorkerThreads,
                                      config[ConfigurationKey.WorkerThreads],
                                      minThreads);
                        }
                    }
                    else
                    {
                        Log.Error("Unable to parse configuration {SettingName} value: {Value}",
                                  ConfigurationKey.WorkerThreads,
                                  config[ConfigurationKey.WorkerThreads]);
                    }
                }

                if (!string.IsNullOrEmpty(config[ConfigurationKey.CompletionPortThreads]))
                {
                    if (int.TryParse(config[ConfigurationKey.CompletionPortThreads], out int threads))
                    {
                        if (threads > minCompletionPortThreads)
                        {
                            setCompletionPortThreads = threads;
                        }
                        else
                        {
                            Log.Error("Configured {SettingName} to value {Value} would place it below the minimum {Minimum}",
                                      ConfigurationKey.CompletionPortThreads,
                                      config[ConfigurationKey.CompletionPortThreads],
                                      minCompletionPortThreads);
                        }
                    }
                    else
                    {
                        Log.Error("Unable to parse configuration {SettingName} value: {Value}",
                                  ConfigurationKey.CompletionPortThreads,
                                  config[ConfigurationKey.CompletionPortThreads]);
                    }
                }

                if (minThreads != setThreads ||
                    minCompletionPortThreads != setCompletionPortThreads)
                {
                    if (ThreadPool.SetMinThreads(setThreads, setCompletionPortThreads))
                    {
                        Log.Information("Set minimum thread counts to {SetThreads} threads, {SetCompletionPortThreads} completion port threads",
                                        setThreads,
                                        setCompletionPortThreads);
                    }
                    else
                    {
                        Log.Error("Unable to set minimum thread counts to {SetThreads} threads, {SetCompletionPortThreads} completion port threads",
                                  setThreads,
                                  setCompletionPortThreads);
                    }
                }
            }

            // output the version and revision
            try
            {
                webhost.Run();
                return(0);
            }
            catch (Exception ex)
            {
                Log.Warning("GRA v{Version} {Instance} exited unexpectedly: {Message}",
                            Version.GetVersion(),
                            instance,
                            ex.Message);
                Environment.ExitCode = 1;
                throw;
            }
            finally
            {
                Log.Warning("GRA v{Version} {Instance} shutting down.",
                            Version.GetVersion(),
                            instance);
                Log.CloseAndFlush();
            }
        }