Ejemplo n.º 1
0
 public C21DocumentService(DbConnectionSettings dbConnectionSettings, List <string> procOutput)
 {
     _dbConnectionSettings          = dbConnectionSettings;
     DataConnection.DefaultSettings = new DbSettings(_dbConnectionSettings.ConnStr());
     DataConnection.SetConnectionString("Db", _dbConnectionSettings.ConnStr());
     _procOutput = procOutput;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SchemaReader"/> class.
        /// </summary>
        /// <param name="dbSettings">The <see cref="DbConnectionSettings"/> for connecting to the database to read
        /// the schema of.</param>
        public SchemaReader(DbConnectionSettings dbSettings)
        {
            var conn = OpenConnection(dbSettings);

            _tableSchemas = ExecuteQuery(conn, dbSettings);
            CloseConnection(conn);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates the prompt for editing the <see cref="DbConnectionSettings"/> file.
        /// </summary>
        /// <param name="s">The <see cref="DbConnectionSettings"/>.</param>
        /// <param name="msg">The message to display.</param>
        /// <returns>True if to retry the connection; false to abort.</returns>
        static bool PromptEditDbSettingsFile(DbConnectionSettings s, string msg)
        {
            if (!s.OpenFileForEdit())
            {
                return(false);
            }

            const string instructions =
                "Please edit the database settings with the appropriate values. Press Retry when done editing, or Cancel to abort.";

            if (msg == null)
            {
                msg = instructions;
            }
            else
            {
                msg += Environment.NewLine + Environment.NewLine + instructions;
            }

            if (MessageBox.Show(msg, "Edit database settings", MessageBoxButtons.RetryCancel) == DialogResult.Cancel)
            {
                return(false);
            }

            s.Reload();

            return(true);
        }
Ejemplo n.º 4
0
        static IEnumerable <TableSchema> ExecuteQuery(MySqlConnection conn, DbConnectionSettings dbSettings)
        {
            var tableColumns = new Dictionary <string, List <ColumnSchema> >();

            using (var cmd = conn.CreateCommand())
            {
                cmd.CommandText = GetQueryString(dbSettings);
                using (var r = cmd.ExecuteReader())
                {
                    while (r.Read())
                    {
                        var column = new ColumnSchema(r);

                        List <ColumnSchema> columnList;
                        if (!tableColumns.TryGetValue(column.TableName, out columnList))
                        {
                            columnList = new List <ColumnSchema>();
                            tableColumns.Add(column.TableName, columnList);
                        }

                        columnList.Add(column);
                    }
                }
            }

            var ret = tableColumns.Select(x => new TableSchema(x.Key, x.Value));

            // ToArray() required to serialize, otherwise it is a LINQ statement
            return(ret.ToArray());
        }
Ejemplo n.º 5
0
        internal static async Task <int> SetCTIDFP(DbConnectionSettings settings)
        {
            // We subtract 10 from the cutoff year here so that we can calculate the 10 year deltas
            using SqlConnection conn = new SqlConnection(settings.CONNECTION_STRING);
            try
            {
                conn.Open();

                using SqlCommand sqlCommand = new SqlCommand(
                          //$@"UPDATE
                          //        {BaseContext.DatabaseToUse}.{BaseContext.Schema}.{BaseContext.TableName}
                          // SET CTIDFP = CT.GEOID2, Has_New_Location = 0
                          // FROM
                          //     {BaseContext.DatabaseToUse}.{BaseContext.Schema}.{BaseContext.TableName} A
                          // JOIN
                          //     BoundaryGEO.BOUNDARYGEO.TIGER15_GEO_TRACT ct
                          // ON
                          //     geography::STGeomFromText('POINT('+convert(varchar(20),A.X)+' '+convert(varchar(20),A.Y)+')',4326).STIntersects(ct.shape)=1
                          //       WHERE
                          //            Has_New_Location = 1"
                          ""
                          , conn)
                      {
                          CommandTimeout = COMMAND_TIMEOUT
                      };
                return(await sqlCommand.ExecuteNonQueryAsync());
            }
            finally
            {
                conn.Close();
            }
        }
Ejemplo n.º 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers().AddNewtonsoftJson(options =>
                                                        options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                                                        );

            if (_env.IsDevelopment() || _env.IsProduction())
            {
                Console.WriteLine("Configuring for " + _env.EnvironmentName + ".");
                IConfiguration       conf       = Configuration.GetSection("DbConnectionSettings");
                DbConnectionSettings dbSettings = conf.Get <DbConnectionSettings>();

                Console.WriteLine(dbSettings.ConnectionString);

                services.AddDbContext <MyDbContext>(options =>
                {
                    options.UseMySql(
                        dbSettings.ConnectionString,
                        x => x.MigrationsAssembly("Backend").EnableRetryOnFailure(
                            dbSettings.RetryCount, new TimeSpan(0, 0, 0, dbSettings.RetryWaitInSeconds), new List <int>())
                        ).UseLazyLoadingProxies();
                });
            }
            else if (_env.EnvironmentName.ToLower().Equals("test"))
            {
                Console.WriteLine("Configuring for test.");
                int    retryCount = Configuration.GetValue <int>("DATABSE_RETRY");
                int    retryWait  = Configuration.GetValue <int>("DATABASE_RETRY_WAIT");
                string dbURL      = Configuration.GetValue <string>("DATABASE_URL");
                DbConnectionSettings dbSettings = new DbConnectionSettings(dbURL, retryCount, retryWait);

                Console.WriteLine(dbSettings.ConnectionString);

                services.AddDbContext <MyDbContext>(options =>
                {
                    options.UseNpgsql(
                        dbSettings.ConnectionString,
                        x => x.MigrationsAssembly("Backend").EnableRetryOnFailure(
                            dbSettings.RetryCount, new TimeSpan(0, 0, 0, dbSettings.RetryWaitInSeconds), new List <string>())
                        ).UseLazyLoadingProxies();
                });
            }
            else
            {
                Console.WriteLine("Not dev or test.");
            }

            services.Configure <RabbitMqConfiguration>(GetRabbitConfig);
            services.Configure <ServiceSettings>(GetServiceSettings);
            services.AddSingleton <IRabbitMqConnection, RabbitMqConnection>();
            services.AddSingleton <IRabbitMqTenderingService, RabbitMqTenderingService>();
            services.AddScoped <ITenderRepository, MySqlTenderRepository>();
            services.AddScoped <ITenderService, TenderService>();
            services.AddScoped <ITenderMessageRepository, MySqlTenderMessageRepository>();
            services.AddScoped <ITenderMessageService, TenderMessageService>();
        }
Ejemplo n.º 7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            if (_env.IsDevelopment())
            {
                Console.WriteLine("Configuring for dev.");
                IConfiguration       conf       = Configuration.GetSection("DbConnectionSettings");
                DbConnectionSettings dbSettings = conf.Get <DbConnectionSettings>();

                Console.WriteLine(dbSettings.ConnectionString);

                services.AddDbContext <MyDbContext>(options =>
                {
                    options.UseMySql(
                        dbSettings.ConnectionString,
                        x => x.MigrationsAssembly("Backend").EnableRetryOnFailure(
                            dbSettings.RetryCount, new TimeSpan(0, 0, 0, dbSettings.RetryWaitInSeconds), new List <int>())
                        ).UseLazyLoadingProxies();
                });
            }
            else if (_env.EnvironmentName.ToLower().Equals("test"))
            {
                Console.WriteLine("Configuring for test.");
                int    retryCount = Configuration.GetValue <int>("DATABASE_RETRY");
                int    retryWait  = Configuration.GetValue <int>("DATABASE_RETRY_WAIT");
                string dbURL      = Configuration.GetValue <string>("DATABASE_URL") ?? "postgres://*****:*****@dummy:5432/dummy";
                DbConnectionSettings dbSettings = new DbConnectionSettings(dbURL, retryCount, retryWait);

                Console.WriteLine(dbSettings.ConnectionString);

                services.AddDbContext <MyDbContext>(options =>
                {
                    options.UseNpgsql(
                        dbSettings.ConnectionString,
                        x => x.MigrationsAssembly("Backend").EnableRetryOnFailure(
                            dbSettings.RetryCount, new TimeSpan(0, 0, 0, dbSettings.RetryWaitInSeconds), new List <string>())
                        ).UseLazyLoadingProxies();
                });
            }
            else
            {
                Console.WriteLine("Not dev or test.");
            }

            services.AddScoped <IFeedbackService, FeedbackService.Service.FeedbackService>();
            services.AddScoped <IFeedbackRepository, FeedbackRepository>();
            services.AddScoped <ICommentatorRepository, CommentatorRepository>();

            services.AddScoped <IDoctorSurveyReportGeneratorRepository, DoctorSurveyReportGeneratorRepository>();
            services.AddScoped <IMedicalStaffSurveyResponseGeneratorRepository, MedicalStaffSurveyResponseGeneratorRepository>();
            services.AddScoped <IHospitalSurveyReportGeneratorRepository, HospitalSurveyReportGeneratorRepository>();
            services.AddScoped <ISurveyResponderRepository, SurveyResponderRepository>();
            services.AddScoped <ISurveyReportService, SurveyReportService>();
            services.AddScoped <ISurveyResponseService, SurveyResponseService>();

            services.AddControllers();
        }
Ejemplo n.º 8
0
        public async void C21ContractorServiceCreateViewTest()
        {
            DbConnectionSettings dbConnectionSettings = new DbConnectionSettings("192.168.21.20", "sa", "#sa2015!", "fkf_test_db");
            C21ContractorService contractorService    = new C21ContractorService(dbConnectionSettings);

            var output = await contractorService.CreateContractorView();

            Console.WriteLine($"C21ContractorServiceCreateViewTest - status : {output}");
            Assert.True(output.Length > 0);
        }
Ejemplo n.º 9
0
        public async void C21ContractorServiceProceedContractorTest()
        {
            DbConnectionSettings dbConnectionSettings = new DbConnectionSettings("192.168.21.20", "sa", "#sa2015!", "fkf_test_db");
            C21ContractorService contractorService    = new C21ContractorService(dbConnectionSettings);

            var output = await contractorService.ProceedContractorsAsync();

            Console.WriteLine($"C21ContractorServiceProceedContractorTest - output records : {output.Count}");
            Assert.True(output.Count > 0);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Builds the connections string based on DbConnectionSettings.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <returns></returns>
 public static string Build(DbConnectionSettings settings)
 {
     return(new SqlConnectionStringBuilder
     {
         DataSource = settings.ServerName,
         InitialCatalog = settings.DataBaseName,
         UserID = settings.UserName,
         Password = settings.UserPassword
     }.ConnectionString);
 }
Ejemplo n.º 11
0
        public async void C21GetNextDocumentIdTest()
        {
            DbConnectionSettings dbConnectionSettings = new DbConnectionSettings("192.168.21.20", "sa", "#sa2015!", "fkf_test_db");
            C21DocumentService   documentService      = new C21DocumentService(dbConnectionSettings, null);

            var output = await documentService.GetNextDocumentId(10);

            Console.WriteLine($"C21GetNextDocumentIdTest - Next ID: {output}");
            Assert.True(output > 0);
        }
Ejemplo n.º 12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            if (_env.IsDevelopment() || _env.IsProduction())
            {
                Console.WriteLine("Configuring for " + _env.EnvironmentName + ".");
                IConfiguration       conf       = Configuration.GetSection("DbConnectionSettings");
                DbConnectionSettings dbSettings = conf.Get <DbConnectionSettings>();

                Console.WriteLine(dbSettings.ConnectionString);

                services.AddDbContext <MyDbContext>(options =>
                {
                    options.UseMySql(
                        dbSettings.ConnectionString,
                        x => x.MigrationsAssembly("Backend").EnableRetryOnFailure(
                            dbSettings.RetryCount, new TimeSpan(0, 0, 0, dbSettings.RetryWaitInSeconds), new List <int>())
                        ).UseLazyLoadingProxies();
                });
            }
            else if (_env.EnvironmentName.ToLower().Equals("test"))
            {
                Console.WriteLine("Configuring for test.");
                int    retryCount = Configuration.GetValue <int>("DATABSE_RETRY");
                int    retryWait  = Configuration.GetValue <int>("DATABASE_RETRY_WAIT");
                string dbURL      = Configuration.GetValue <string>("DATABASE_URL");
                DbConnectionSettings dbSettings = new DbConnectionSettings(dbURL, retryCount, retryWait);

                Console.WriteLine(dbSettings.ConnectionString);

                services.AddDbContext <MyDbContext>(options =>
                {
                    options.UseNpgsql(
                        dbSettings.ConnectionString,
                        x => x.MigrationsAssembly("Backend").EnableRetryOnFailure(
                            dbSettings.RetryCount, new TimeSpan(0, 0, 0, dbSettings.RetryWaitInSeconds), new List <string>())
                        ).UseLazyLoadingProxies();
                });
            }
            else
            {
                Console.WriteLine("Not dev or test.");
            }

            services.Configure <ServiceSettings>(GetServiceSettings);
            services.AddScoped <IConfirmedDrugRepository, MySqlConfirmedDrugRepository>();
            services.AddScoped <IUnconfirmedDrugRepository, MySqlUnconfirmedDrugRepository>();
            services.AddScoped <IDrugInRoomRepository, MySqlDrugInRoomRepository>();
            services.AddScoped <IDrugService, DrugService>();
            services.AddScoped <IDrugConsumptionRepository, MySqlDrugConsumptionRepository>();
            services.AddScoped <IDrugConsumptionService, DrugConsumptionService>();
        }
Ejemplo n.º 13
0
        public async void C21GetYearsTest()
        {
            DbConnectionSettings dbConnectionSettings = new DbConnectionSettings("192.168.21.20", "sa", "#sa2015!", "fkf_test_db");
            C21DocumentService   documentService      = new C21DocumentService(dbConnectionSettings, null);

            var output = await documentService.GetYearId(new DateTime(2020, 5, 20));

            Console.WriteLine($"C21GetYearsTest - Year id: {output.rokId}");
            Assert.True(output != null);
            var outputNull = await documentService.GetYearId(new DateTime(2099, 5, 20));

            Assert.True(outputNull == null);
        }
Ejemplo n.º 14
0
        public async void C21GetVatRegisterDefsTest()
        {
            DbConnectionSettings dbConnectionSettings = new DbConnectionSettings("192.168.21.20", "sa", "#sa2015!", "fkf_test_db");
            C21DocumentService   documentService      = new C21DocumentService(dbConnectionSettings, null);

            var output = await documentService.GetVatRegistersDefs(1);

            Console.WriteLine($"C21GetVatRegisterDefsTest - Vat register name: {output.rNazwa}");
            Assert.True(output != null);
            var outputNull = await documentService.GetVatRegistersDefs(9999);

            Assert.True(outputNull == null);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Opens the connection.
        /// </summary>
        /// <param name="dbSettings">The db settings.</param>
        /// <returns>The <see cref="MySqlConnection"/>.</returns>
        static MySqlConnection OpenConnection(DbConnectionSettings dbSettings)
        {
            var s = new MySqlConnectionStringBuilder
            {
                UserID = dbSettings.User, Password = dbSettings.Pass, Server = dbSettings.Host, Database = "information_schema"
            };

            var connStr = s.ToString();
            var conn    = new MySqlConnection(connStr);

            conn.Open();

            return(conn);
        }
Ejemplo n.º 16
0
        public async void C21ContractorServiceGetFvpContractorTest()
        {
            DbConnectionSettings dbConnectionSettings = new DbConnectionSettings("192.168.21.20", "sa", "#sa2015!", "fkf_test_db");
            C21ContractorService contractorService    = new C21ContractorService(dbConnectionSettings);

            var memBefore      = GC.GetTotalMemory(false);
            var fvpContractors = await contractorService.GetC21FvpContractorsAsync(true).ConfigureAwait(false);

            var memDiff = ((GC.GetTotalMemory(false) - memBefore) / 1024) / 1024;

            Console.WriteLine($"C21ContractorServiceGetFvpContractorTest - contractors read : {fvpContractors.Count}");
            Console.WriteLine($"C21ContractorServiceGetFvpContractorTest - size in MB : {memDiff}");
            Assert.True(fvpContractors.Count > 0);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Saves the schema to file.
        /// </summary>
        /// <param name="path">The file path to save to. If null, the default path will be used.</param>
        public static void Save(string path = null)
        {
            if (string.IsNullOrEmpty(path))
            {
                path = Paths.Root + MySqlHelper.DbSchemaFile;
            }

            // Load the database settings
            var dbSettings = new DbConnectionSettings(Paths.Root + MySqlHelper.DbSettingsFile, true);

            // Get the schema
            var schema = new SchemaReader(dbSettings);

            // Save
            schema.Save(path);
        }
Ejemplo n.º 18
0
        public async Task <IActionResult> GetFkDuplicatedDocuments(int sourceId, int year, int month)
        {
            var target = await _context.Targets.FirstOrDefaultAsync(t => t.Sources.Select(s => s.SourceId).Contains(sourceId));

            var docSettings = await _context.TargetDocumentsSettings.FirstOrDefaultAsync(t => t.SourceId == sourceId);

            DbConnectionSettings dbConnectionSettings = new DbConnectionSettings(target.DatabaseAddress, target.DatabaseUsername, target.DatabasePassword, target.DatabaseName);
            C21DocumentService   c21DocumentService   = new C21DocumentService(dbConnectionSettings, null);
            var fkfDocuments = (await c21DocumentService.GetFKDocuments(year, month, docSettings.DocumentShortcut));

            _context.Database.SetCommandTimeout(0);
            var systemDocuments = await _context.Documents.Where(d => d.SourceId == sourceId && d.DocumentDate.Month == month).ToListAsync();

            var duplicates = fkfDocuments.GroupBy(d => new { d.tresc }).Select(d => new
            {
                d.Key.tresc,
                cnt = d.Count()
            }).ToList();

            duplicates = duplicates.Where(d => d.cnt > 1).ToList();
            var duplicatedDocs = systemDocuments.Where(d => duplicates.Select(d => d.tresc).Contains(d.DocumentNumber)).ToList();
            var sourcesIds     = await _context.Sources.Select(s => s.SourceId).ToListAsync();

            if (sourceId > 0)
            {
                sourcesIds = new List <int> {
                    sourceId
                }
            }
            ;
            var contractors = await _context.Contractors.ToListAsync();

            var sources = await _context.Sources.ToListAsync();

            var documents = (
                from d in duplicatedDocs
                from c in contractors
                from s in sources
                where d.ContractorId == c.ContractorId && d.SourceId == s.SourceId &&
                sourcesIds.Contains((int)d.SourceId) && d.DocumentDate.Month == month &&
                d.DocumentDate.Year == year
                orderby d.DocumentDate
                select new DocumentView(d, s, c)).ToList();

            return(Ok(new { data = documents }));
        }
Ejemplo n.º 19
0
        public async void C21ContractorServiceAddContractorTest()
        {
            DbConnectionSettings dbConnectionSettings = new DbConnectionSettings("192.168.21.20", "sa", "#sa2015!", "fkf_test_db");
            //test
            C21ContractorService contractorService = new C21ContractorService(dbConnectionSettings);
            var erpContractors = await contractorService.GetC21FvpContractorsAsync(true);

            int?erpContractorId = null;

            if (erpContractors != null)
            {
                var erpContractor = erpContractors.FirstOrDefault(v => v.VatId == "6912503886TEST");
                if (erpContractor != null)
                {
                    erpContractorId = erpContractor.Id;
                }
            }

            C21Contractor contractor = new C21Contractor
            {
                id         = erpContractorId,
                skrot      = "FVP-TestKh",
                nazwa      = $"FVP - Kontrahent testowy {string.Format("{0:HH:mm:ss}", DateTime.Now)}",
                ulica      = "ul. Okrzei",
                numerDomu  = "13",
                kod        = "59-220",
                nip        = "6912503886TEST",
                Kraj       = "PL",
                aktywny    = true,
                statusUE   = 0,
                externalId = null,
                limit      = false,
                limitKwota = 0.0,
                negoc      = 0
            };

            await contractorService.AddContractorsAsync(new List <C21Contractor> {
                contractor
            });

            var contractorReaded = await contractorService.GetC21ContractorsAsync();

            Console.WriteLine($"C21ContractorServiceAddContractorTest - contractor read : {contractorReaded.FirstOrDefault().nazwa}");
            Assert.True(contractorReaded.Count > 0);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Makes a MySql connection string using the given settings.
        /// </summary>
        /// <returns>The MySql connection string.</returns>
        public static string GetMySqlConnectionString(this DbConnectionSettings settings)
        {
            var sb = new MySqlConnectionStringBuilder
            {
                Database              = settings.Database,
                UserID                = settings.User,
                Password              = settings.Pass,
                Server                = settings.Host,
                Port                  = settings.Port,
                IgnorePrepare         = true,
                Pooling               = true,
                UseCompression        = false,
                UsePerformanceMonitor = false,
                UseUsageAdvisor       = false
            };

            return(sb.ToString());
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Initializes the <see cref="EventCounterManager"/> class.
        /// </summary>
        static EventCounterManager()
        {
            // Create a dedicated dbController for the EventCounters since they are all executed in non-blocking mode,
            // none of the queries touch the normal game tables, and none of the queries do not rely on order of execution
            var dbConnSettings = new DbConnectionSettings();
            var dbController   = new ServerDbController(dbConnSettings.GetMySqlConnectionString());

            // Create the query objects
            var pool = dbController.ConnectionPool;

            var userECQuery = EventCounterHelper.CreateQuery <CharacterID, UserEventCounterType>(pool,
                                                                                                 EventCountersUserTable.TableName, "user_id", "user_event_counter_id");

            var guildECQuery = EventCounterHelper.CreateQuery <GuildID, GuildEventCounterType>(pool,
                                                                                               EventCountersGuildTable.TableName, "guild_id", "guild_event_counter_id");

            var shopECQuery = EventCounterHelper.CreateQuery <ShopID, ShopEventCounterType>(pool, EventCountersShopTable.TableName,
                                                                                            "shop_id", "shop_event_counter_id");

            var mapECQuery = EventCounterHelper.CreateQuery <MapID, MapEventCounterType>(pool, EventCountersMapTable.TableName,
                                                                                         "map_id", "map_event_counter_id");

            var questECQuery = EventCounterHelper.CreateQuery <QuestID, QuestEventCounterType>(pool,
                                                                                               EventCountersQuestTable.TableName, "quest_id", "quest_event_counter_id");

            var itemTemplateECQuery = EventCounterHelper.CreateQuery <ItemTemplateID, ItemTemplateEventCounterType>(pool,
                                                                                                                    EventCountersItemTemplateTable.TableName, "item_template_id", "item_template_event_counter_id");

            var npcECQuery = EventCounterHelper.CreateQuery <CharacterTemplateID, NPCEventCounterType>(pool,
                                                                                                       EventCountersNpcTable.TableName, "npc_template_id", "npc_event_counter_id");

            // Create the event counters
            _userEventCounter         = new EventCounter <CharacterID, UserEventCounterType>(userECQuery);
            _guildEventCounter        = new EventCounter <GuildID, GuildEventCounterType>(guildECQuery);
            _shopEventCounter         = new EventCounter <ShopID, ShopEventCounterType>(shopECQuery);
            _mapEventCounter          = new EventCounter <MapID, MapEventCounterType>(mapECQuery);
            _questEventCounter        = new EventCounter <QuestID, QuestEventCounterType>(questECQuery);
            _itemTemplateEventCounter = new EventCounter <ItemTemplateID, ItemTemplateEventCounterType>(itemTemplateECQuery);
            _npcEventCounter          = new EventCounter <CharacterTemplateID, NPCEventCounterType>(npcECQuery);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Creates a new DbController instance if one does not already exist. Do not use this to just acquire a DbController instance when one may already exist -
        /// use DbControllerBase.GetInstance() instead.
        /// </summary>
        /// <returns></returns>
        public static ServerDbController CreateDbController()
        {
            ServerDbController db = null;

            // See if the instance already exists
            try
            {
                db = DbControllerBase.GetInstance() as ServerDbController;
            }
            catch (MemberAccessException)
            {
            }

            if (db == null)
            {
                var settings = new DbConnectionSettings();
                db = (ServerDbController)settings.CreateDbControllerPromptEditWhenInvalid(x => new ServerDbController(x.GetMySqlConnectionString()),
                                                                                          x => PromptEditDbSettingsFile(settings, x));
            }

            return(db);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GlobalState"/> class.
        /// </summary>
        GlobalState()
        {
            ThreadAsserts.IsMainThread();

            // Load all sorts of stuff
            _contentManager = NetGore.Content.ContentManager.Create();

            var dbConnSettings = new DbConnectionSettings();

            _dbController =
                dbConnSettings.CreateDbControllerPromptEditWhenInvalid(x => new ServerDbController(x.GetMySqlConnectionString()),
                                                                       x => dbConnSettings.PromptEditFileMessageBox(x));

            _defaultRenderFont = ContentManager.LoadFont("Font/Arial", 16, ContentLevel.Global);

            Character.NameFont = DefaultRenderFont;

            GrhInfo.Load(ContentPaths.Dev, ContentManager);
            AutomaticGrhDataSizeUpdater.Instance.UpdateSizes();

            _mapGrhWalls = new MapGrhWalls(ContentPaths.Dev, x => new WallEntity(x));

            // Load the child classes
            _mapState = new MapState(this);

            // Grab the audio manager instances, which will ensure that they are property initialized
            // before something that can't pass it an ContentManager tries to get an instance
            AudioManager.GetInstance(ContentManager);

            // Set the custom UITypeEditors
            CustomUITypeEditors.AddEditors(DbController);

            // Set up the timer
            _timer = new Timer {
                Interval = 1000 / 60
            };
            _timer.Tick += _timer_Tick;
        }
Ejemplo n.º 24
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(options =>
            {
                options.AddPolicy("localhost",
                                  builder =>
                {
                    builder.WithOrigins("https://localhost:4200", "http://localhost:4200");
                    builder.AllowAnyMethod();
                    builder.AllowAnyHeader();
                });
            });

            services.AddControllers();

            IConfigurationSection  jwtSection             = Configuration.GetSection("JwtBearerTokenSettings");
            JwtBearerTokenSettings jwtBearerTokenSettings = jwtSection.Get <JwtBearerTokenSettings>();

            services.AddSingleton <ITokenService, TokenService>(sp => new TokenService(jwtSection.Get <JwtBearerTokenSettings>().SecretKey));

            IConfigurationSection dbSection            = Configuration.GetSection("DbConnectionSettings");
            DbConnectionSettings  dbConnectionSettings = dbSection.Get <DbConnectionSettings>();
            string connectionString = dbSection.Get <DbConnectionSettings>().SqlServerConnectionString;

            services.AddSingleton <DbProviderFactory>(sp => SqlClientFactory.Instance);
            services.AddSingleton(sp => new ConnectionInfo(connectionString));
            services.AddSingleton <Connection>();

            services.AddSingleton <AuthService>();
            services.AddSingleton <UserService>();
            services.AddSingleton <RoleService>();
            services.AddSingleton <GameService>();
            services.AddSingleton <RuleService>();
            services.AddSingleton <TimeControlService>();
            services.AddSingleton <StatisticService>();
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SchemaReader"/> class.
 /// </summary>
 /// <param name="dbSettings">The <see cref="DbConnectionSettings"/> for connecting to the database to read
 /// the schema of.</param>
 public SchemaReader(DbConnectionSettings dbSettings)
 {
     var conn = OpenConnection(dbSettings);
     _tableSchemas = ExecuteQuery(conn, dbSettings);
     CloseConnection(conn);
 }
Ejemplo n.º 26
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            if (_env.IsDevelopment())
            {
                Console.WriteLine("Configuring for dev.");
                IConfiguration       conf       = Configuration.GetSection("DbConnectionSettings");
                DbConnectionSettings dbSettings = conf.Get <DbConnectionSettings>();

                Console.WriteLine(dbSettings.ConnectionString);

                services.AddDbContext <EventSourcingDbContext>(options =>
                {
                    options.UseMySql(dbSettings.ConnectionString,
                                     x => x.EnableRetryOnFailure(
                                         dbSettings.RetryCount, new TimeSpan(0, 0, 0, dbSettings.RetryWaitInSeconds), new List <int>())
                                     ).UseLazyLoadingProxies();
                });
            }
            else if (_env.EnvironmentName.ToLower().Equals("test"))
            {
                Console.WriteLine("Configuring for test.");
                int    retryCount = Configuration.GetValue <int>("DATABASE_RETRY");
                int    retryWait  = Configuration.GetValue <int>("DATABASE_RETRY_WAIT");
                string dbURL      = Configuration.GetValue <string>("DATABASE_URL") ?? "postgres://*****:*****@dummy:5432/dummy";
                DbConnectionSettings dbSettings = new DbConnectionSettings(dbURL, retryCount, retryWait);

                Console.WriteLine(dbSettings.ConnectionString);

                services.AddDbContext <EventSourcingDbContext>(options =>
                {
                    options.UseNpgsql(
                        dbSettings.ConnectionString + ";SSL Mode=Prefer;Trust Server Certificate=true",
                        x => x.EnableRetryOnFailure(
                            dbSettings.RetryCount, new TimeSpan(0, 0, 0, dbSettings.RetryWaitInSeconds), new List <string>())
                        ).UseLazyLoadingProxies();
                });
            }
            else
            {
                Console.WriteLine("Not dev or test.");
            }


            services.AddControllers().AddNewtonsoftJson(s =>
            {
                s.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            });

            services.AddScoped <IDomainEventRepository <PatientStepSchedulingEvent>, DomainEventRepository <PatientStepSchedulingEvent> >();
            services.AddScoped <IEventStorePatientStepSchedulingService, EventStorePatientStepSchedulingService>();

            services.AddScoped <IDomainEventRepository <PatientStartSchedulingEvent>, DomainEventRepository <PatientStartSchedulingEvent> >();
            services.AddScoped <IEventStorePatientStartSchedulingService, EventStorePatientStartSchedulingService>();

            services.AddScoped <IDomainEventRepository <PatientEndSchedulingEvent>, DomainEventRepository <PatientEndSchedulingEvent> >();
            services.AddScoped <IEventStorePatientEndSchedulingService, EventStorePatientEndSchedulingService>();

            services.AddScoped <IRoomSelectionService, RoomSelectionService>();
            services.AddScoped <IDomainEventRepository <RoomSelectionEvent>, DomainEventRepository <RoomSelectionEvent> >();

            services.AddScoped <IBuildingSelectionService, BuildingSelectionService>();
            services.AddScoped <IDomainEventRepository <BuildingSelectionEvent>, DomainEventRepository <BuildingSelectionEvent> >();

            services.AddScoped <IFloorChangeService, FloorChangeService>();
            services.AddScoped <IDomainEventRepository <FloorChangeEvent>, DomainEventRepository <FloorChangeEvent> >();
        }
Ejemplo n.º 27
0
        private static async Task <TaskStatus> ParseDataAsync(string fileName, Action <double> updateProgress, DbConnectionSettings settings)
        {
            try
            {
                if (File.Exists(fileName))
                {
                    using (var stream = new StreamReader(fileName))
                    {
                        var ctx = new Context(settings);

                        await ctx.SaveChangesAsync();

                        updateProgress(4);
                        ctx.Dispose();
                    }
                    return(TaskStatus.RanToCompletion);
                }
                else
                {
                    Console.WriteLine($"File Not Found: {fileName}");
                    return(TaskStatus.Canceled);
                }
            }
            catch (Exception e)
            {
#if DEBUG
                Console.WriteLine(e.ToString());
#endif
                return(TaskStatus.Faulted);
            }
        }
Ejemplo n.º 28
0
        static IEnumerable<TableSchema> ExecuteQuery(MySqlConnection conn, DbConnectionSettings dbSettings)
        {
            var tableColumns = new Dictionary<string, List<ColumnSchema>>();

            using (var cmd = conn.CreateCommand())
            {
                cmd.CommandText = GetQueryString(dbSettings);
                using (var r = cmd.ExecuteReader())
                {
                    while (r.Read())
                    {
                        var column = new ColumnSchema(r);

                        List<ColumnSchema> columnList;
                        if (!tableColumns.TryGetValue(column.TableName, out columnList))
                        {
                            columnList = new List<ColumnSchema>();
                            tableColumns.Add(column.TableName, columnList);
                        }

                        columnList.Add(column);
                    }
                }
            }

            var ret = tableColumns.Select(x => new TableSchema(x.Key, x.Value));

            // ToArray() required to serialize, otherwise it is a LINQ statement
            return ret.ToArray();
        }
Ejemplo n.º 29
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            if (_env.IsDevelopment())
            {
                Console.WriteLine("Configuring for dev.");
                IConfiguration       conf       = Configuration.GetSection("DbConnectionSettings");
                DbConnectionSettings dbSettings = conf.Get <DbConnectionSettings>();

                Console.WriteLine(dbSettings.ConnectionString);

                services.AddDbContext <MyDbContext>(options =>
                {
                    options.UseMySql(
                        dbSettings.ConnectionString,
                        x => x.MigrationsAssembly("Backend").EnableRetryOnFailure(
                            dbSettings.RetryCount, new TimeSpan(0, 0, 0, dbSettings.RetryWaitInSeconds), new List <int>())
                        ).UseLazyLoadingProxies();
                });
            }
            else if (_env.EnvironmentName.ToLower().Equals("test"))
            {
                Console.WriteLine("Configuring for test.");
                int    retryCount = Configuration.GetValue <int>("DATABASE_RETRY");
                int    retryWait  = Configuration.GetValue <int>("DATABASE_RETRY_WAIT");
                string dbURL      = Configuration.GetValue <string>("DATABASE_URL") ?? "postgres://*****:*****@dummy:5432/dummy";
                DbConnectionSettings dbSettings = new DbConnectionSettings(dbURL, retryCount, retryWait);

                Console.WriteLine(dbSettings.ConnectionString);

                services.AddDbContext <MyDbContext>(options =>
                {
                    options.UseNpgsql(
                        dbSettings.ConnectionString,
                        x => x.MigrationsAssembly("Backend").EnableRetryOnFailure(
                            dbSettings.RetryCount, new TimeSpan(0, 0, 0, dbSettings.RetryWaitInSeconds), new List <string>())
                        ).UseLazyLoadingProxies();
                });
            }
            else
            {
                Console.WriteLine("Not dev or test.");
            }

            services.AddScoped <IClock, Clock>();

            services.AddScoped <IExaminationService, ExaminationService>();
            services.AddScoped <IAvailableExaminationService, AvailableExaminationService>();

            services.AddScoped <IExaminationRepository, ExaminationRepository>();
            services.AddScoped <IRoomRepository, RoomRepository>();
            services.AddScoped <IDoctorRepository, DoctorRepository>();
            services.AddScoped <IPatientRepository, PatientRepository>();

            services.AddScoped <Backend.Service.RoomAndEquipment.IRoomService, Backend.Service.RoomAndEquipment.RoomService>();
            services.AddScoped <Backend.Repository.RoomRepository.IRoomRepository,
                                Backend.Repository.RoomRepository.MySqlRoomRepository.MySqlRoomRepository>();
            services.AddScoped <Backend.Repository.RenovationPeriodRepository.IRenovationPeriodRepository,
                                Backend.Repository.RenovationPeriodRepository.MySqlRenovationPeriodRepository.MySqlRenovationPeriodRepository>();
            services.AddScoped <Backend.Repository.EquipmentInRoomsRepository.IEquipmentInRoomsRepository,
                                Backend.Repository.EquipmentInRoomsRepository.MySqlEquipmentInRoomsRepository.MySqlEquipmentInRoomsRepository>();
            services.AddScoped <Backend.Repository.IEquipmentRepository,
                                Backend.Repository.MySqlEquipmentRepository>();

            services.AddControllers();
        }
Ejemplo n.º 30
0
 public C21ContractorService(DbConnectionSettings dbConnectionSettings)
 {
     _dbConnectionSettings          = dbConnectionSettings;
     DataConnection.DefaultSettings = new DbSettings(_dbConnectionSettings.ConnStr());
     DataConnection.SetConnectionString("Db", _dbConnectionSettings.ConnStr());
 }
Ejemplo n.º 31
0
        /// <summary>
        /// Opens the connection.
        /// </summary>
        /// <param name="dbSettings">The db settings.</param>
        /// <returns>The <see cref="MySqlConnection"/>.</returns>
        static MySqlConnection OpenConnection(DbConnectionSettings dbSettings)
        {
            var s = new MySqlConnectionStringBuilder
            { UserID = dbSettings.User, Password = dbSettings.Pass, Server = dbSettings.Host, Database = "information_schema" };

            var connStr = s.ToString();
            var conn = new MySqlConnection(connStr);
            conn.Open();

            return conn;
        }
Ejemplo n.º 32
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.Configure <ServiceSettings>(GetServiceSettings);

            if (_env.IsDevelopment())
            {
                Console.WriteLine("Configuring for dev.");
                IConfiguration       conf       = Configuration.GetSection("DbConnectionSettings");
                DbConnectionSettings dbSettings = conf.Get <DbConnectionSettings>();

                Console.WriteLine(dbSettings.ConnectionString);

                services.AddDbContext <MyDbContext>(options =>
                {
                    options.UseMySql(
                        dbSettings.ConnectionString,
                        x => x.MigrationsAssembly("Backend").EnableRetryOnFailure(
                            dbSettings.RetryCount, new TimeSpan(0, 0, 0, dbSettings.RetryWaitInSeconds), new List <int>())
                        ).UseLazyLoadingProxies();
                });
            }
            else if (_env.EnvironmentName.ToLower().Equals("test"))
            {
                Console.WriteLine("Configuring for test.");
                int    retryCount = Configuration.GetValue <int>("DATABASE_RETRY");
                int    retryWait  = Configuration.GetValue <int>("DATABASE_RETRY_WAIT");
                string dbURL      = Configuration.GetValue <string>("DATABASE_URL");
                DbConnectionSettings dbSettings = new DbConnectionSettings(dbURL, retryCount, retryWait);

                Console.WriteLine(dbSettings.ConnectionString);

                services.AddDbContext <MyDbContext>(options =>
                {
                    options.UseNpgsql(
                        dbSettings.ConnectionString,
                        x => x.MigrationsAssembly("Backend").EnableRetryOnFailure(
                            dbSettings.RetryCount, new TimeSpan(0, 0, 0, dbSettings.RetryWaitInSeconds), new List <string>())
                        ).UseLazyLoadingProxies();
                });
            }
            else
            {
                Console.WriteLine("Not dev or test.");
            }

            services.AddScoped <IRoomService, RoomService>();
            services.AddScoped <IRoomRepository, MySqlRoomRepository>();
            services.AddScoped <IRenovationPeriodRepository, MySqlRenovationPeriodRepository>();
            services.AddScoped <IEquipmentTypeService, EquipmentTypeService>();

            services.AddScoped <IEquipmentTypeRepository, MySqlEquipmentTypeRepository>();
            services.AddScoped <IEquipmentInExaminationRepository, MySqlEquipmentInExaminationRepository>();

            services.AddScoped <IEquipmentInRoomsService, EquipmentInRoomsService>();

            services.AddScoped <IEquipmentInRoomsRepository, MySqlEquipmentInRoomsRepository>();

            services.AddScoped <IEquipmentService, EquipmentService>();

            services.AddScoped <IEquipmentRepository, MySqlEquipmentRepository>();

            services.AddScoped <IDrugInRoomService, DrugInRoomService>();

            services.AddScoped <IDrugInRoomRepository, MySqlDrugInRoomRepository>();

            services.AddScoped <IDrugService, DrugService>();

            services.AddScoped <IConfirmedDrugRepository, MySqlConfirmedDrugRepository>();

            services.AddScoped <IUnconfirmedDrugRepository, MySqlUnconfirmedDrugRepository>();

            services.AddScoped <IDrugTypeService, DrugTypeService>();
            services.AddScoped <IEquipmentInExaminationService, EquipmentInExaminationService>();
            services.AddScoped <IDrugTypeRepository, MySqlDrugTypeRepository>();

            services.AddScoped <ISpecialtyRepository, MySqlSpecialtyRepository>();
            services.AddScoped <ISpecialtyService, SpecialtyService>();

            services.AddScoped <IDoctorRepository, MySqlDoctorRepository>();
            services.AddScoped <IDoctorService, DoctorService>();

            services.AddScoped <IDoctorSpecialtyRepository, MySqlDoctorSpecialtyRepository>();
            services.AddScoped <IDoctorSpecialtyService, DoctorSpecialtyService>();

            services.AddScoped <IActivePatientRepository, MySqlActivePatientRepository>();
            services.AddScoped <IPatientService, PatientService>();

            services.AddScoped <IActivePatientCardRepository, MySqlActivePatientCardRepository>();
            services.AddScoped <IPatientCardService, PatientCardService>();

            services.AddScoped <IExaminationService, ExaminationService>();
            services.AddScoped <IExaminationRepository, MySqlExaminationRepository>();


            services.AddScoped <IFreeAppointmentSearchService, FreeAppointmentSearchService>();
            services.AddScoped <IScheduleAppointmenService, ScheduleAppointmentService>();
            services.AddScoped <IDoctorRepository, MySqlDoctorRepository>();
            services.AddScoped <IActivePatientRepository, MySqlActivePatientRepository>();
            services.AddScoped <IActivePatientCardRepository, MySqlActivePatientCardRepository>();
            services.AddScoped <IRenovationPeriodRepository, MySqlRenovationPeriodRepository>();
            services.AddScoped <IEquipmentTransferRepository, MySqlEquipmentTransferRepostory>();
            services.AddScoped <IEquipmentTransferService, EquipmentTransferService>();
            services.AddScoped <IEquipmentInExaminationRepository, MySqlEquipmentInExaminationRepository>();
            services.AddScoped <IEquipmentInExaminationService, EquipmentInExaminationService>();
            services.AddScoped <IRenovationRepository, MySqlRenovationRepository>();
            services.AddScoped <IRenovationService, RenovationService>();
        }
Ejemplo n.º 33
0
 static string GetQueryString(DbConnectionSettings dbSettings)
 {
     return string.Format(_queryStr, GetColumnsString(), dbSettings.Database, _columnsAlias);
 }
Ejemplo n.º 34
0
        static void Main()
        {
            Console.WriteLine("This program will generate the code files to match the database." +
                              " As a result, many code files will be altered. Are you sure you wish to continue?");
            Console.WriteLine("Press Y to continue, or any other key to abort.");

            if (Console.ReadKey().Key != ConsoleKey.Y)
            {
                return;
            }

            Console.WriteLine();

            // Force the NetGore.Features.Server assembly to load up so we can properly find the IDbClassGeneratorSettingsProvider
            // implementations in NetGore.Features.Server. To do this, we just create a random instance of an object in
            // NetGore.Features.Server.
#pragma warning disable 168
            var x = new DbClassGeneratorSettings();
#pragma warning restore 168

            DbConnectionSettings dbSettings = new DbConnectionSettings(string.Format("{0}..{1}..{1}DemoGame.Server{1}DbSettings.dat",
                                                                                     AppDomain.CurrentDomain.BaseDirectory, Path.DirectorySeparatorChar), false);

            using (var generator = new MySqlClassGenerator(dbSettings.Host, dbSettings.User, dbSettings.Pass, dbSettings.Database, dbSettings.Port))
            {
                var baseStatColumns = GetStatColumnCollectionItems(generator.Formatter, StatCollectionType.Base);
                var reqStatColumns  = GetStatColumnCollectionItems(generator.Formatter, StatCollectionType.Requirement);

                // Custom usings
                generator.AddUsing("NetGore.Db");
                generator.AddUsing("DemoGame.DbObjs");

                // Custom column collections
                var baseStatTables = new string[] { "character", "character_template", "item", "item_template" };
                var reqStatTables  = new string[] { "item", "item_template" };

                generator.AddColumnCollection("Stat", typeof(StatType), typeof(int), typeof(short), baseStatTables, baseStatColumns);
                generator.AddColumnCollection("ReqStat", typeof(StatType), typeof(int), typeof(short), reqStatTables, reqStatColumns);

                // Custom external types
                generator.AddCustomType(typeof(AccountID), "account", "id");
                generator.AddCustomType(typeof(UserPermissions), "account", "permissions");

                generator.AddCustomType(typeof(AllianceID), "alliance", "id");

                generator.AddCustomType(typeof(CharacterID), "character", "id");
                generator.AddCustomType(typeof(CharacterTemplateID), "character", "template_id");


                generator.AddCustomType(typeof(EquipmentSlot), "character_equipped", "slot");

                generator.AddCustomType(typeof(InventorySlot), "character_inventory", "slot");

                generator.AddCustomType(typeof(ActiveStatusEffectID), "character_status_effect", "id");
                generator.AddCustomType(typeof(StatusEffectType), "character_status_effect", "status_effect_id");

                generator.AddCustomType(typeof(CharacterTemplateID), "character_template", "id");

                generator.AddCustomType(typeof(ItemChance), "character_template_equipped", "chance");

                generator.AddCustomType(typeof(ItemChance), "character_template_inventory", "chance");

                generator.AddCustomType(typeof(ItemID), "item", "id");
                generator.AddCustomType(typeof(GrhIndex), "item", "graphic");
                generator.AddCustomType(typeof(ItemType), "item", "type");

                generator.AddCustomType(typeof(ItemTemplateID), "item_template", "id");
                generator.AddCustomType(typeof(GrhIndex), "item_template", "graphic");
                generator.AddCustomType(typeof(ItemType), "item_template", "type");

                generator.AddCustomType(typeof(MapID), "map", "id");

                generator.AddCustomType(typeof(MapSpawnValuesID), "map_spawn", "id");
                generator.AddCustomType(typeof(Direction), "map_spawn", "direction_id");

                // Mass-added custom types
                generator.AddCustomType(typeof(AllianceID), "*", "alliance_id", "attackable_id", "hostile_id");
                generator.AddCustomType(typeof(CharacterID), "*", "character_id", "target_character_id", "user_id", "npc_id");
                generator.AddCustomType(typeof(CharacterTemplateID), "*", "character_template_id", "user_template_id", "npc_template_id");
                generator.AddCustomType(typeof(AccountID), "*", "account_id");
                generator.AddCustomType(typeof(MapID), "*", "map_id", "respawn_map_id", "load_map_id");
                generator.AddCustomType(typeof(ItemID), "*", "item_id");
                generator.AddCustomType(typeof(ItemTemplateID), "*", "item_template_id");
                generator.AddCustomType(typeof(BodyID), "*", "body_id");
                generator.AddCustomType(typeof(SPValueType), "*", "hp", "mp");
                generator.AddCustomType(typeof(AIID), "*", "ai_id");
                generator.AddCustomType(typeof(WeaponType), "*", "weapon_type");
                generator.AddCustomType(typeof(NPCChatDialogID), "*", "chat_dialog");
                generator.AddCustomType(typeof(ShopID), "*", "shop_id");
                generator.AddCustomType(typeof(ActionDisplayID), "*", "action_display_id");
                generator.AddCustomType(typeof(SkillType), "*", "skill_id");

                generator.AddCustomType(typeof(UserEventCounterType), "*", "user_event_counter_type");
                generator.AddCustomType(typeof(ShopEventCounterType), "*", "shop_event_counter_type");
                generator.AddCustomType(typeof(QuestEventCounterType), "*", "quest_event_counter_type");
                generator.AddCustomType(typeof(MapEventCounterType), "*", "map_event_counter_type");
                generator.AddCustomType(typeof(ItemTemplateEventCounterType), "*", "item_template_event_counter_type");
                generator.AddCustomType(typeof(GuildEventCounterType), "*", "guild_event_counter_type");
                generator.AddCustomType(typeof(NPCEventCounterType), "*", "npc_event_counter_type");

                // Renaming
                var formatter = generator.Formatter;
                formatter.AddAlias("alliance_id", "AllianceID");
                formatter.AddAlias("account_id", "AccountID");
                formatter.AddAlias("attackable_id", "AttackableID");
                formatter.AddAlias("hostile_id", "HostileID");
                formatter.AddAlias("character_id", "CharacterID");
                formatter.AddAlias("character_template_id", "CharacterTemplateID");
                formatter.AddAlias("npc_template_id", "NPCTemplateID");
                formatter.AddAlias("user_template_id", "UserTemplateID");
                formatter.AddAlias("item_template_id", "ItemTemplateID");
                formatter.AddAlias("item_id", "ItemID");
                formatter.AddAlias("map_id", "MapID");
                formatter.AddAlias("load_map_id", "LoadMapID");
                formatter.AddAlias("load_x", "LoadX");
                formatter.AddAlias("load_y", "LoadY");
                formatter.AddAlias("body_id", "BodyID");
                formatter.AddAlias("respawn_map_id", "RespawnMapID");
                formatter.AddAlias("respawn_x", "RespawnX");
                formatter.AddAlias("respawn_y", "RespawnY");
                formatter.AddAlias("give_exp", "GiveExp");
                formatter.AddAlias("give_cash", "GiveCash");
                formatter.AddAlias("status_effect_id", "StatusEffect");
                formatter.AddAlias("ai_id", "AIID");
                formatter.AddAlias("event_id", "EventID");
                formatter.AddAlias("target_character_id", "TargetCharacterID");
                formatter.AddAlias("action_display_id", "ActionDisplayID");
                formatter.AddAlias("skill_id", "SkillID");
                formatter.AddAlias("npc_id", "NPCID");
                formatter.AddAlias("user_id", "UserID");
                formatter.AddAlias("npc_event_counter_id", "NPCEventCounterID");

                formatter.AddAlias("Name");
                formatter.AddAlias("ID");
                formatter.AddAlias("AI");
                formatter.AddAlias("StatPoints");
                formatter.AddAlias("HP");
                formatter.AddAlias("MP");
                formatter.AddAlias("HP");
                formatter.AddAlias("MaxHP");
                formatter.AddAlias("MaxMP");
                formatter.AddAlias("MinHit");
                formatter.AddAlias("MaxHit");

                // Custom settings defined elsewhere
                generator.AddCustomSettings();

                // Generate
                var codeItems = generator.Generate(_tempNamespaceName, _tempNamespaceName);
                foreach (var item in codeItems)
                {
                    SaveCodeFile(item);
                }
            }

            Console.WriteLine("Done");
        }