Ejemplo n.º 1
0
 public static void Open(string conStr, DBMS DBManagementSystem)
 {
     if (sess == null)
     {
         sess = new Session(conStr, DBManagementSystem);
         return;
     }
     sess.Close();
     sess = new Session(conStr, DBManagementSystem);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Saves the specified player in the specified database.
        /// </summary>
        /// <param name="Player">The player.</param>
        /// <param name="DBMS">The DBMS.</param>
        internal void Save(Player Player, DBMS DBMS = Constants.Database)
        {
            switch (DBMS)
            {
            case DBMS.MySQL:
            {
                using (GBS_MySQL Database = new GBS_MySQL())
                {
                    var Data = Database.Players.Find(Player.HighID, Player.LowID);

                    if (Data != null)
                    {
                        Data.HighID = Player.HighID;
                        Data.LowID  = Player.LowID;
                        Data.Data   = JsonConvert.SerializeObject(Player, this.Settings);
                    }
                    else
                    {
                        Logging.Error(this.GetType(), "The database returned a null value when we tried to get a player.");
                    }

                    Database.SaveChangesAsync();
                }

                break;
            }

            case DBMS.Redis:
            {
                Redis.Players.StringSetAsync(Player.ToString(), JsonConvert.SerializeObject(Player, this.Settings), TimeSpan.FromMinutes(30));
                break;
            }

            case DBMS.Both:
            {
                this.Save(Player, DBMS.MySQL);
                this.Save(Player, DBMS.Redis);
                break;
            }

            case DBMS.File:
            {
                File.WriteAllText(Directory.GetCurrentDirectory() + "\\Saves\\Players\\" + Player + ".json", JsonConvert.SerializeObject(Player, this.Settings));
                break;
            }

            case DBMS.Mongo:
            {
                Mongo.Players.UpdateOneAsync(T => T.HighID == Player.HighID && T.LowID == Player.LowID, Builders <Core.Database.Models.Mongo.Players> .Update.Set(T => T.Player, BsonDocument.Parse(JsonConvert.SerializeObject(Player, this.Settings))));

                break;
            }
            }
        }
Ejemplo n.º 3
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     if (DBMS.login(txtNombreUsuario.Text.Trim(), txtPass.Text))
     {
         Response.Redirect("Principal.aspx");
     }
     else
     {
         this.Page.Response.Write("<script language='JavaScript'>window.alert('Usuario o contraseña incorrecta');</script>");
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Saves the specified player.
        /// </summary>
        internal void SaveHome(Home Home, DBMS Database = Constants.Database)
        {
            switch (Database)
            {
            case DBMS.Mongo:
            {
                Mongo.Players.UpdateOneAsync(Save => Save.HighID == Home.HighID && Save.LowID == Home.LowID, Builders <Core.Database.Models.Mongo.Players> .Update.Set(Save => Save.Player, BsonDocument.Parse(JsonConvert.SerializeObject(Home, this.Settings))));

                break;
            }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a clan with the specified identifier in the specified database.
        /// </summary>
        /// <param name="Clan">The clan.</param>
        /// <param name="DBMS">The DBMS.</param>
        /// <param name="Store">if set to <c>true</c> [store].</param>
        internal Clan New(Clan Clan, DBMS DBMS = Constants.Database, bool Store = true)
        {
            if (Clan.LowID == 0)
            {
                Clan.LowID = Interlocked.Increment(ref this.Seed);
            }

            switch (DBMS)
            {
            case DBMS.MySQL:
            {
                using (GBS_MySQL Database = new GBS_MySQL())
                {
                    Database.Clans.Add(new Core.Database.Models.Clans
                        {
                            HighID = Clan.HighID,
                            LowID  = Clan.LowID,
                            Data   = JsonConvert.SerializeObject(Clan, this.Settings)
                        });

                    Database.SaveChangesAsync();
                }

                if (Store)
                {
                    this.Add(Clan);
                }

                break;
            }

            case DBMS.Redis:
            {
                Redis.Clans.StringSetAsync(Clan.ToString(), JsonConvert.SerializeObject(Clan, this.Settings), TimeSpan.FromMinutes(15));

                if (Store)
                {
                    this.Add(Clan);
                }

                break;
            }

            case DBMS.Both:
            {
                this.New(Clan, DBMS.Redis, Store);
                this.New(Clan, DBMS.MySQL, Store);
                break;
            }
            }

            return(Clan);
        }
Ejemplo n.º 6
0
        public static DatabaseHelper GetDatabaseHelper(DBMS dbmsType, WrappedConnection connection)
        {
            Check.NotNull(connection, nameof(connection));

            _dbmsMap.TryGetValue(dbmsType, out Func <WrappedConnection, DatabaseHelper>?dbHelperCreationDelegate);
            if (dbHelperCreationDelegate is null)
            {
                throw new EvolveException(string.Format(UnknownDBMS, dbmsType));
            }

            return(dbHelperCreationDelegate(connection));
        }
Ejemplo n.º 7
0
        public static DBMSAbstractFactory GetFactoryByDBMS(DBMS name)
        {
            switch (name)
            {
            case DBMS.MySQL:
                return(new MySQLFactory());

            case DBMS.Postgres:
                return(new PostgresFactory());
            }
            return(null);
        }
Ejemplo n.º 8
0
        ///############################################################
        /// <summary>
        /// Populates the global variables holding the <c>Cn.Web</c> settings.
        /// </summary>
        /// <remarks>
        /// NOTE: This function relies on the default table names for the system settings ("cnInternationalization", "cnRendererConfiguration", "cnHolidayCalculations", and "cnPicklists"). If you have chosen to rename your system configuration tables, you will need to utilize this function's sibling implementation.
        /// <para/>NOTE: This function assumes that the Default Internationalization table name is "cnInternationalization".
        /// </remarks>
        /// <param name="oDBMS"><c>DBMS</c> instance representing an active connection to the related data source.</param>
        /// <param name="bInternationalizationDefaultData">Boolean value representing if the Default Internationalization global variable is to be updated.</param>
        /// <param name="bInternationalization">Boolean value representing if the <paramref>sSystemName</paramref>'s Internationalization global variable is to be updated.</param>
        /// <param name="bPicklists">Boolean value representing if the persistent Picklists's (named after the <paramref>sSystemName</paramref>) global variable is to be updated.</param>
        /// <param name="bMetaData">Boolean value representing if the <paramref>sSystemName</paramref>'s DataSource MetaData global variable is to be updated.</param>
        /// <param name="eDataSource">Enumeration representing the source the <paramref>oDataSourceMetaData</paramref> was generated from.</param>
        /// <param name="sDataSourceContainerName">String representing the name of the data source's container.</param>
        /// <exception cref="Cn.CnException">Thrown when the passed <paramref>eDataSource</paramref> is unsupported or unreconized.</exception>
        ///############################################################
        /// <LastUpdated>May 28, 2007</LastUpdated>
        public static void GetData(DBMS oDBMS, bool bInternationalizationDefaultData, bool bInternationalization, bool bPicklists, bool bMetaData, enumDataSource eDataSource, string sDataSourceContainerName)
        {
            string sInternationalizationDefaultDataTableName = "";
            string sInternationalizationTableName            = "";
            string sMetaDataTableName  = "";
            string sPicklistsTableName = "";

            //#### Setup the local s*TableName variables to the default names based on the passed information (skipping any set to false)
            if (bInternationalizationDefaultData)
            {
                sInternationalizationDefaultDataTableName = "cnInternationalization";
            }
            if (bInternationalization)
            {
                sInternationalizationTableName = "cnInternationalization";
            }
            if (bPicklists)
            {
                sPicklistsTableName = "cnPicklists";
            }
            if (bMetaData)
            {
                //#### Determine the eDataSource, setting sMetaDataTableName accordingly
                switch (eDataSource)
                {
                case enumDataSource.cnSQLServer: {
                    sMetaDataTableName = sDataSourceContainerName + ".INFORMATION_SCHEMA.COLUMNS";
                    break;
                }

                case enumDataSource.cnOracle: {
                    sMetaDataTableName = "all_tab_columns";
                    break;
                }

                //#### Else the passed eDataSource is unsupported or unreconized, so raise the error (based on the passed sSystemName)
                default: {
                    Internationalization.RaiseDefaultError(g_cClassName + "", Internationalization.enumInternationalizationValues.cnDeveloperMessages_General_UnknownValue, "eDataSource", Data.Tools.MakeString(eDataSource, ""));
                    break;
                }
                }
            }

            //#### Pass the call off to our sibling implementation to do the actual work
            GetData(oDBMS,
                    sInternationalizationDefaultDataTableName,
                    sInternationalizationTableName,
                    sPicklistsTableName,
                    sMetaDataTableName,
                    eDataSource
                    );
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Deletes the specified player in the specified database.
        /// </summary>
        /// <param name="HighID">The high identifier.</param>
        /// <param name="LowID">The low identifier.</param>
        /// <param name="DBMS">The DBMS.</param>
        internal void Delete(int HighID, int LowID, DBMS DBMS = Constants.Database)
        {
            switch (DBMS)
            {
            case DBMS.MySQL:
            {
                using (GBS_MySQL Database = new GBS_MySQL())
                {
                    Core.Database.Models.MySQL.Players Data = Database.Players.Find(HighID, LowID);

                    if (Data != null)
                    {
                        Database.Players.Remove(Data);
                    }
                    else
                    {
                        Logging.Error(this.GetType(), "Data was null when deleting a player in the MySQL Database.");
                    }

                    Database.SaveChangesAsync();
                }

                break;
            }

            case DBMS.Redis:
            {
                Redis.Players.KeyDeleteAsync(HighID + "-" + LowID);
                break;
            }

            case DBMS.Both:
            {
                this.Delete(HighID, LowID, DBMS.MySQL);
                this.Delete(HighID, LowID, DBMS.Redis);
                break;
            }

            case DBMS.File:
            {
                File.Delete(Directory.GetCurrentDirectory() + "\\Saves\\Players\\" + HighID + "-" + LowID + ".json");
                break;
            }

            case DBMS.Mongo:
            {
                Mongo.Players.DeleteOneAsync(T => T.HighID == HighID && T.LowID == LowID);

                break;
            }
            }
        }
Ejemplo n.º 10
0
 private void DeleteEntity(int DBMSId)
 {
     if (MessageBox.Show("¿Esta seguro de eliminar el DBMS?", "Advertencia",
                         MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
     {
         return;
     }
     this.DBMS           = this.srvDBMS.GetById(DBMSId);
     this.DBMS.Activated = false;
     this.DBMS.Deleted   = true;
     this.srvDBMS.SaveOrUpdate(this.DBMS);
     this.Search();
 }
Ejemplo n.º 11
0
        public override DBMS GetSearchResult()
        {
            DBMS         DBMS      = null;
            UltraGridRow activeRow = this.grdSchSearch.ActiveRow;

            if (activeRow != null)
            {
                int DBMSId = Convert.ToInt32(activeRow.Cells[0].Value);
                DBMS = this.srvDBMS.GetById(DBMSId);
            }

            return(DBMS);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Gets the alliance using the specified identifier in the specified database.
        /// </summary>
        internal static Alliance Get(int highId, int lowId, DBMS database = Settings.Database, bool store = true)
        {
            long id = (long)highId << 32 | (uint)lowId;

            if (!Alliances.Pool.TryGetValue(id, out Alliance alliance))
            {
                switch (database)
                {
                case DBMS.Mongo:
                {
                    AllianceDb save = Mongo.Alliances.Find(db => db.HighID == highId && db.LowID == lowId).SingleOrDefault();

                    if (save != null)
                    {
                        alliance = Alliances.Load(save.Profile.ToJson());

                        if (alliance == null)
                        {
                            Debugger.Error($"Unable to load alliance with the ID {highId}-{lowId}.");
                        }
                    }

                    break;
                }

                case DBMS.File:
                {
                    FileInfo file = new FileInfo($"{Directory.GetCurrentDirectory()}/Saves/Alliances/{highId}-{lowId}.json");

                    if (file.Exists)
                    {
                        string json = file.ReadAllText();

                        if (!json.IsNullOrEmptyOrWhitespace())
                        {
                            alliance = JsonConvert.DeserializeObject <Alliance>(json, AllianceDb.JsonSettings);
                        }
                        else
                        {
                            Debugger.Error($"The data returned wasn't null but empty, at Get({highId}, {lowId}, File, {store}).");
                        }
                    }

                    break;
                }
                }
            }

            return(alliance);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Switch Source and Destination
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bttnSwitch_Click(object sender, EventArgs e)
        {
            // get sources
            string source = this.txtSource.Text;
            DBMS   dbms   = (DBMS)this.cboSource.SelectedItem;

            // set source
            this.txtSource.Text         = this.txtDestination.Text;
            this.cboSource.SelectedItem = this.cboDestintaion.SelectedItem;

            // set dest
            this.txtDestination.Text         = source;
            this.cboDestintaion.SelectedItem = dbms;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Gets the player using the specified identifier in the specified database.
        /// </summary>
        internal static LogicClientAvatar Get(LogicLong id, DBMS database = Settings.Database)
        {
            if (!Avatars.Pool.TryGetValue(id, out LogicClientAvatar avatar))
            {
                switch (database)
                {
                case DBMS.Mongo:
                {
                    AvatarDb save = Mongo.Avatars.Find(db => db.HighID == id.High && db.LowID == id.Low).SingleOrDefault();

                    if (save != null)
                    {
                        avatar = Avatars.Load(save.Profile.ToJson());

                        if (avatar == null)
                        {
                            Debugger.Error($"Unable to load account with the ID {id}, recreating...");
                            avatar = Avatars.Create(null, id);
                        }
                    }

                    break;
                }

                case DBMS.File:
                {
                    FileInfo file = new FileInfo($"{Directory.GetCurrentDirectory()}/Saves/Players/{id}.json");

                    if (file.Exists)
                    {
                        string json = file.ReadAllText();

                        if (!json.IsNullOrEmptyOrWhitespace())
                        {
                            avatar = JsonConvert.DeserializeObject <LogicClientAvatar>(json, AvatarDb.JsonSettings);
                        }
                        else
                        {
                            Debugger.Error($"The data returned was null/empty/whitespace at Get({id}, {database}).");
                        }
                    }

                    break;
                }
                }
            }

            return(avatar);
        }
Ejemplo n.º 15
0
        /// <summary>
        ///     Gets the process framework factory used to create an instance to the process framework.
        /// </summary>
        /// <param name="dbms">The DBMS that corresponds to the type of database.</param>
        /// <returns>
        ///     Returns a <see cref="IPxApplicationFactory" /> that is used to create a connection.
        /// </returns>
        /// <exception cref="NotSupportedException">The database is not supported.</exception>
        public static IPxApplicationFactory GetFactory(DBMS dbms)
        {
            switch (dbms)
            {
            case DBMS.Access:
                return(new LocalPxApplicationFactory());

            case DBMS.Oracle:
            case DBMS.SqlServer:
                return(new RemotePxApplicationFactory());

            default:
                throw new NotSupportedException("The database is not supported.");
            }
        }
Ejemplo n.º 16
0
        internal void Save(Level Player, DBMS DBMS = Constants.Database)
        {
            while (true)
            {
                switch (DBMS)
                {
                case DBMS.MySQL:
                {
                    if (Constants.IsMono)
                    {
                        Mysql_Backup.Save(Player);
                    }
                    else
                    {
                        using (MysqlEntities Database = new MysqlEntities())
                        {
                            var Data = Database.Player.Find(Player.Avatar.UserId);

                            if (Data != null)
                            {
                                Data.Data = JsonConvert.SerializeObject(Player.Avatar, this.Settings) + "#:#:#:#" +
                                            Player.SaveToJSON();
                                Database.SaveChanges();
                            }
                        }
                    }

                    break;
                }

                case DBMS.Redis:
                {
                    Redis.Players.StringSet(Player.Avatar.UserId.ToString(),
                                            JsonConvert.SerializeObject(Player.Avatar, this.Settings) + "#:#:#:#" + Player.SaveToJSON(),
                                            TimeSpan.FromHours(4));
                    break;
                }

                case DBMS.Both:
                {
                    this.Save(Player, DBMS.MySQL);
                    DBMS = DBMS.Redis;
                    continue;
                }
                }
                break;
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Saves the specified DBMS.
        /// </summary>
        internal static void Save(DBMS database = Settings.Database, bool connected = false)
        {
            Avatars.ForEach(avatar =>
            {
                try
                {
                    avatar.Save(database);
                }
                catch (Exception exception)
                {
                    Debugger.Error($"{exception.GetType().Name} : did not succeed in saving player [{avatar}].");
                }
            }, connected);

            Debugger.Info($"Saved {Avatars.Count} avatars.");
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Load Destination from XML based on current selection
        /// </summary>
        public void RefreshDestination()
        {
            DBMS dbms = (DBMS)this.cboDestintaion.SelectedItem;

            // load dbms template values from xml
            CopyObject template = CopyObject.GetTemplate(dbms);

            if (template != null && this.CurrentObj != null)
            {
                // load destination values
                this.CurrentObj.PostCopySql = template.PostCopySql;
                this.CurrentObj.PreCopySql  = template.PreCopySql;
                this.CurrentObj.DeleteSql   = template.DeleteSql;
                this.CurrentObj.CountSql    = template.CountSql;
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Saves this instance.
        /// </summary>
        internal static void Save(DBMS database = Settings.Database)
        {
            Alliances.ForEach(alliance =>
            {
                try
                {
                    Alliances.Save(alliance, database);
                }
                catch (Exception)
                {
                    Debugger.Debug($"Did not succeed in saving alliance [{alliance}].");
                }
            });

            Debugger.Info($"Saved {Alliances.Count} alliances.");
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Load Source from XML for current selection
        /// </summary>
        public void RefreshSource()
        {
            DBMS dbms = (DBMS)this.cboSource.SelectedItem;

            // load dbms tenplate values from xml
            CopyObject template = CopyObject.GetTemplate(dbms);

            if (template != null && this.CurrentObj != null)
            {
                // load source values
                this.CurrentObj.SelectSql    = template.SelectSql;
                this.CurrentObj.ListSql      = template.ListSql;
                this.CurrentObj.SchemaFormat = template.SchemaFormat;
                this.CurrentObj.TableFormat  = template.TableFormat;
            }
        }
Ejemplo n.º 21
0
        //void Destination_OnRowsCopied(object sender, RowsCopiedEventArgs e)
        //{
        //	if (OnRowsCopied != null) { OnRowsCopied(this, e); }
        //}


        public static IDbData GetDb(string connectionString, CopyObject obj, DBMS dmbs)
        {
            switch (dmbs)
            {
            case DBMS.Oracle:
                return(new OracleData(connectionString, obj));

            case DBMS.MySql:
                return(new MySqlData(connectionString, obj));

            default:
                return(new SqlData(connectionString, obj));
            }

            //this.Db = db;
        }
Ejemplo n.º 22
0
        private static void ConfigureForMySql(
            this IServiceCollection services,
            string connectionString,
            DBMS dbms)
        {
            if (connectionString is null)
            {
                throw new ArgumentNullException("Please specify a valid connection string for MySql to use.");
            }

            services.AddScoped <IBaseSqlExecutorOptions>(provider =>
                                                         new BaseSqlExecutorOptions()
            {
                Connection = new MySqlConnection(connectionString),
                Dbms       = dbms
            });
        }
Ejemplo n.º 23
0
        private static void ConfigureForSqLite(
            this IServiceCollection services,
            string connectionString,
            DBMS dbms)
        {
            if (connectionString is null)
            {
                connectionString = "Data Source=app.db";
            }

            services.AddScoped <IBaseSqlExecutorOptions>(provider =>
                                                         new BaseSqlExecutorOptions()
            {
                Connection = new SqliteConnection(connectionString),
                Dbms       = dbms
            });
        }
Ejemplo n.º 24
0
        internal async Task <Home> LoadHomeAsync(int HighID, int LowID, DBMS Database = Constants.Database, bool Store = true)
        {
            long ID = (long)HighID << 32 | (uint)LowID;

            if (!this.Homes.TryGetValue(ID, out Home Home))
            {
                switch (Database)
                {
                case DBMS.Mongo:
                {
                    Core.Database.Models.Mongo.Players Save = await Mongo.Players.Find(T => T.HighID == HighID && T.LowID == LowID).SingleOrDefaultAsync();

                    if (Save != null)
                    {
                        Home = this.LoadHomeFromSave(Save.Home.ToJson());

                        if (Store)
                        {
                            this.Add(Home);
                        }

                        if (!this.Players.TryGetValue(ID, out Player Player))
                        {
                            Player = this.LoadPlayerFromSave(Save.Player.ToJson());

                            if (Store)
                            {
                                this.Add(Player);
                            }
                        }

                        if (Home == null)
                        {
                            Logging.Error(this.GetType(), "Unable to load home id:" + HighID + "-" + LowID + ".");
                            return(null);
                        }
                    }

                    break;
                }
                }
            }

            return(Home);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Saves the specified player in the specified database.
        /// </summary>
        /// <param name="Player">The player.</param>
        /// <param name="DBMS">The DBMS.</param>
        internal void Save(Player Player, DBMS DBMS = Constants.Database)
        {
            return;

            switch (DBMS)
            {
            case DBMS.MySQL:
            {
                using (GRS_MySQL Database = new GRS_MySQL())
                {
                    Core.Database.Models.Players Data = Database.Players.Find(Player.HighID, Player.LowID);

                    if (Data != null)
                    {
                        Data.HighID = Player.HighID;
                        Data.LowID  = Player.LowID;
                        Data.Data   = JsonConvert.SerializeObject(Player, this.Settings);
                    }

                    Database.SaveChangesAsync();
                }

                break;
            }

            case DBMS.Redis:
            {
                Redis.Players.StringSetAsync(Player.ToString(), JsonConvert.SerializeObject(Player, this.Settings), TimeSpan.FromMinutes(30));
                break;
            }

            case DBMS.Both:
            {
                this.Save(Player, DBMS.MySQL);
                this.Save(Player, DBMS.Redis);
                break;
            }

            case DBMS.File:
            {
                File.WriteAllText(Directory.GetCurrentDirectory() + "\\Saves\\Players\\" + Player + ".json", JsonConvert.SerializeObject(Player, this.Settings));
                break;
            }
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Deletes the specified player in the specified database.
        /// </summary>
        internal static async void Delete(int high, int low, DBMS database = Settings.Database)
        {
            switch (database)
            {
            case DBMS.Mongo:
            {
                await AvatarDb.Delete(high, low);

                break;
            }

            case DBMS.File:
            {
                new FileInfo($"{Directory.GetCurrentDirectory()}/Saves/Players/{high}-{low}.json").DeleteIfExists();
                break;
            }
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Deletes the specified player in the specified database.
        /// </summary>
        internal static async void Delete(LogicClientAvatar avatar, DBMS database = Settings.Database)
        {
            switch (database)
            {
            case DBMS.Mongo:
            {
                await AvatarDb.Delete(avatar.HighID, avatar.LowID);

                break;
            }

            case DBMS.File:
            {
                new FileInfo($"{Directory.GetCurrentDirectory()}/Saves/Players/{avatar}.json").DeleteIfExists();
                break;
            }
            }
        }
Ejemplo n.º 28
0
        public void IFeatureClass_GetSchemaName_IsValid()
        {
            var testClass  = base.GetLineFeatureClass();
            var schemaName = testClass.GetSchemaName();

            DBMS dbms = base.Workspace.GetDBMS();

            switch (dbms)
            {
            case DBMS.Access:
            case DBMS.File:
                Assert.IsNull(schemaName);
                break;

            default:
                Assert.IsNotNull(schemaName);
                break;
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Saves the specified DBMS.
        /// </summary>
        /// <param name="DBMS">The DBMS.</param>
        internal void Save(DBMS DBMS = Constants.Database)
        {
            Clan[] Clans = this.Values.ToArray();

            Parallel.ForEach(Clans, Clan =>
            {
                try
                {
                    this.Save(Clan, DBMS);
                }
                catch (Exception Exception)
                {
                    SResources.Logger.Error(Exception, "Did not successed to save the clan " + Clan + " at shutdown.");
                }
            });

            Logging.Info(this.GetType(), "Saved " + Clans.Length + " clans.");
            Console.WriteLine("Saved " + Clans.Length + " clans.");
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Saves the specified clan in the specified database.
        /// </summary>
        /// <param name="Clan">The clan.</param>
        /// <param name="DBMS">The DBMS.</param>
        internal void Save(Alliance Clan, DBMS DBMS = Constants.Database)
        {
            switch (DBMS)
            {
            case DBMS.MySQL:
            {
                using (GBS_MySQL Database = new GBS_MySQL())
                {
                    Core.Database.Models.MySQL.Clans Data = Database.Clans.Find(Clan.HighID, Clan.LowID);

                    if (Data != null)
                    {
                        Data.Data = JsonConvert.SerializeObject(Clan, this.Settings);
                    }

                    Database.SaveChangesAsync();
                }

                break;
            }

            case DBMS.Redis:
            {
                Redis.Clans.StringSetAsync(Clan.ToString(), JsonConvert.SerializeObject(Clan, this.Settings), TimeSpan.FromMinutes(15));

                break;
            }

            case DBMS.Both:
            {
                this.Save(Clan, DBMS.MySQL);
                this.Save(Clan, DBMS.Redis);
                break;
            }

            case DBMS.Mongo:
            {
                Mongo.Clans.UpdateOneAsync(T => T.HighID == Clan.HighID && T.LowID == Clan.LowID, Builders <Core.Database.Models.Mongo.Clans> .Update.Set(T => T.Data, BsonDocument.Parse(JsonConvert.SerializeObject(Clan, this.Settings))));

                break;
            }
            }
        }
Ejemplo n.º 31
0
 public override string PrepareSql(DBMS convertTo)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Ejemplo n.º 32
0
 public DBManagerFactory(DBMS dbms)
 {
     this._dbms = dbms;
 }
Ejemplo n.º 33
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     DBMS ds = new DBMS();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Phương thức khởi tạo GenerateDDL
 /// </summary>
 /// <param name="mdp">Meta data physical</param>
 /// <param name="nameDBMS">Loại Database Manage System</param>
 /// <param name="dbName">Tên Database</param>
 public GenerateDDL(MetaDataPhysical mdp, DBMS nameDBMS, string dbName)
 {
     this.mdp = mdp;
     this.nameDBMS = nameDBMS;
     this.dbName = dbName;
 }
Ejemplo n.º 35
0
        public static string CreateDbConectionString(DBMS driver)
        {
            driverConnection = driver;

            StringBuilder sb = new StringBuilder("Server = ");
            sb.Append(server);
            sb.Append("; port = ");
            sb.Append(port);
            sb.Append("; User Id = ");
            sb.Append(user);
            sb.Append("; Password = "******"; Database = ");
            sb.Append(database);
            sb.Append(";");

            return sb.ToString();
        }
Ejemplo n.º 36
0
        /// <summary>
        /// Get connection string of App.config 
        /// </summary>
        /// <returns>database connection string</returns>
        public static string GetDbConectionString(DBMS driver)
        {
            driverConnection = driver;

            switch (driver)
            {
                case DBMS.PostgreSQL:
                    return ConfigurationManager.AppSettings["PostgreSQL"];
                case DBMS.OleDB:
                    return ConfigurationManager.AppSettings["OleDB"];
                case DBMS.MSSQLServer:
                    return ConfigurationManager.AppSettings["MSSQLServer"];
                default:
                    return null;
            }
        }