当前位置: 首页>>代码示例>>C#>>正文


C# DBConnector.Connect方法代码示例

本文整理汇总了C#中DBConnector.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# DBConnector.Connect方法的具体用法?C# DBConnector.Connect怎么用?C# DBConnector.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBConnector的用法示例。


在下文中一共展示了DBConnector.Connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        /// <summary>
        /// starts the initialization of the global objects
        /// </summary>
        public static void Init()
        {
            try
            {
                if(!m_initDone)
                {
                    Program.SplashScreen = new SplashScreenForm();
                    Program.SplashScreen.Show();

                    Program.SplashScreen.InfoAdd("initializing logger...");
                    Program.Logger = new SingleThreadLogger(ThreadLoggerType.Form);
                    Program.Logger.Log("Initialising...\n");
                    Program.SplashScreen.InfoAppendLast("<OK>");

                    Program.SplashScreen.InfoAdd("starting sql server...");

                    // load settings from file
                    IniFile = new STA.Settings.INIFile(GetDataPath("ED-IBE.ini"), false, true);

                    // starT database process (if not running)
                    DBProcess.DBProcessParams newProcessParams  = new DBProcess.DBProcessParams() { };
                    newProcessParams.Commandline                = IniFile.GetValue("DB_Server",        "Commandline",      @"bin\mysqld.exe");
                    newProcessParams.Commandargs                = IniFile.GetValue("DB_Server",        "CommandArgs",      @"--defaults-file=Elite.ini --console");
                    newProcessParams.Workingdirectory           = IniFile.GetValue("DB_Server",        "WorkingDirectory", @"..\..\..\RNDatabase\Database");
                    newProcessParams.Port                       = IniFile.GetValue<Int16>("DB_Server", "Port",             "3306");
                    newProcessParams.DBStartTimeout             = IniFile.GetValue<Int16>("DB_Server", "DBStartTimeout",   "60");

                    EliteDBProcess                              = new DBProcess(newProcessParams);

                    if (EliteDBProcess.WasRunning)
                        Program.SplashScreen.InfoAppendLast("already running...<OK>");
                    else
                        Program.SplashScreen.InfoAppendLast("<OK>");

                    // connecT to the database
                    Program.SplashScreen.InfoAdd("connect to sql server...");

                    DBConnector.ConnectionParams newConnectionParams = new DBConnector.ConnectionParams() { };

                    newConnectionParams.Name                    = IniFile.GetValue("DB_Connection",          "Name",           "master");
                    newConnectionParams.Server                  = IniFile.GetValue("DB_Connection",          "Server",         "localhost");
                    newConnectionParams.Database                = IniFile.GetValue("DB_Connection",          "Database",       "Elite_DB");
                    newConnectionParams.User                    = IniFile.GetValue("DB_Connection",          "User",           "RN_User");
                    newConnectionParams.Pass                    = IniFile.GetValue("DB_Connection",          "Pass",           "Elite");
                    newConnectionParams.ConnectTimeout          = IniFile.GetValue<Int16>("DB_Connection",   "ConnectTimeout", "60");
                    newConnectionParams.StayAlive               = IniFile.GetValue<Boolean>("DB_Connection", "StayAlive",      "false");
                    newConnectionParams.TimeOut                 = IniFile.GetValue<Int16>("DB_Connection",   "TimeOut",        "60");

                    DBCon                                       = new DBConnector(newConnectionParams);

                    DBCon.Connect();

                    Program.SplashScreen.InfoAppendLast("<OK>");

                    /* **************** database is running ********************** */

                    Program.SplashScreen.InfoAdd("preparing global objects...");

                    // prepare colors-object
                    Colors                                      = new GUIColors();

                    // preprare main data object
                    Data                                        = new IBE.SQL.EliteDBIO();
                    Data.PrepareBaseTables();

                    // create global paths-object
                    //Paths                                       = new ProgramPaths();

                    // prepare settings
                    Settings                                    = new Settings();
                    Settings.BaseData                           = Data.BaseData;

                    // prepare commanders log
                    CommandersLog                               = new CommandersLog();
                    CommandersLog.BaseData                      = Data.BaseData;

                    // prepare price analysis
                    PriceAnalysis                               = new PriceAnalysis(new DBConnector(DBCon.ConfigData, true));
                    PriceAnalysis.BaseData                      = Data.BaseData;

                    // starting the external data interface
                    ExternalData                                = new ExternalDataInterface();

                    // initializing the object for the actual condition
                    actualCondition                             = new Condition();

                    // initializing the LogfileScanner
                    LogfileScanner                              = new EDLogfileScanner();

                    // forwards a potentially new system or station information to database
                    Program.LogfileScanner.LocationInfo += LogfileScanner_LocationInfo;
                    Program.ExternalData.LocationInfo   += ExternalData_LocationInfo;

                    // register the LogfileScanner in the CommandersLog for the ExternalDataEvent-event
                    CommandersLog.registerLogFileScanner(LogfileScanner);
                    CommandersLog.registerExternalTool(ExternalData);

//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:ED-IBE,代码行数:101,代码来源:Program.cs

示例2: PrepareBaseTables

//        private Dictionary<DataTable, MySql.Data.MySqlClient.MySqlDataAdapter>     m_BaseData_UpdateObjects = new Dictionary<DataTable, MySql.Data.MySqlClient.MySqlDataAdapter>();
        



        /// <summary>
        /// loads the data from the basetables into memory. For correct initialization it is
        /// necessary to call this fuction with a unset tableName
        /// 
        /// </summary>
        /// <param name="m_BaseData"></param>
        internal void PrepareBaseTables(String TableName = "", Boolean saveChanged = false)
        {
            PerformanceTimer Runtime;
            //MySql.Data.MySqlClient.MySqlDataAdapter dataAdapter;
            DBConnector currentDBCon;

            try
            {
                Runtime = new PerformanceTimer();

                if(String.IsNullOrEmpty(TableName))
                { 
                    if(m_BaseData == null)
                    {
                        m_BaseData              = new dsEliteDB();
                        m_BaseData_Connector    = new Dictionary<DataTable, DBConnector>();
                    }

                    foreach (String BaseTable in BaseTables_Systems)
                    {
                        if (!m_BaseData_Connector.TryGetValue(m_BaseData.Tables[BaseTable], out currentDBCon))
                        {
                            // each basetable gets it's own DBConnector, because 
                            // the contained DataReaders will be hold open for possible 
                            // changes (MySQL doesn't support MARS "Multiple Active result Sets")

                            currentDBCon = new DBConnector(Program.DBCon.ConfigData);
                            m_BaseData_Connector.Add(m_BaseData.Tables[BaseTable], currentDBCon);

                            currentDBCon.Connect();
                        }

                        Runtime.startMeasuring();
                        m_BaseData.Tables[BaseTable].Clear();

                        if (!Program.SplashScreen.IsDisposed)
                            Program.SplashScreen.InfoAdd("...loading basetable '" + BaseTable + "'...");                            

                        // preload all tables with base data
                        currentDBCon.TableRead(String.Format("select * from {0}", BaseTable), BaseTable, m_BaseData);
                        
                        if (!Program.SplashScreen.IsDisposed)
                            Program.SplashScreen.InfoAppendLast("<OK>");                            

                        Runtime.PrintAndReset("loading full table '" + BaseTable + "':");
                    }
                }
                else if(BaseTables_Systems.Contains(TableName))
                {
                    currentDBCon = m_BaseData_Connector[m_BaseData.Tables[TableName]];

                    if(saveChanged)
                    {
                        // save all containing changes
                        Runtime.PrintAndReset("saving changes in table '" + TableName + "':");
                        currentDBCon.TableUpdate(TableName, m_BaseData);
                    }
                    else
                    {
                        Runtime.startMeasuring();

                        m_BaseData.Tables[TableName].Clear();

                        // reload selected table
                        currentDBCon.TableRead("", TableName, m_BaseData);

                        Runtime.PrintAndReset("re-loading full table '" + TableName + "':");
                    }
                }
                else
                {
                    throw new Exception(string.Format("Attempt to load an unknown basetable : <{0}>", TableName));
                }

            }
            catch (Exception ex)
            {
                throw new Exception("Error while preparing base tables", ex);
            }
        }
开发者ID:Duke-Jones,项目名称:ED-IBE,代码行数:91,代码来源:EliteDBIO.cs

示例3: Init

        /// <summary>
        /// starts the initialization of the global objects
        /// </summary>
        public static void Init()
        {

            try
            {
                if(!m_initDone)
                { 
                    Program.SplashScreen = new SplashScreenForm();
                    Program.SplashScreen.Show();

                    Program.SplashScreen.Logger = MainLog;

                    Program.SplashScreen.InfoAdd("initializing logger...");
                    Program.MainLog.Log("Initialising...\n");
                    Program.SplashScreen.InfoAppendLast("<OK>");

                    Program.SplashScreen.InfoAdd("starting sql server...");

                    // load settings from file
                    IniFile = new STA.Settings.INIFile(GetDataPath("ED-IBE.ini"), false, true);


                    // prepare architecture-dependend files
                    PrepareDepFiles();

                    // start database process (if not running)
                    DBProcess.DBProcessParams newProcessParams  = new DBProcess.DBProcessParams() { };
                    newProcessParams.Commandline                = IniFile.GetValue("DB_Server",         "Commandline",      @"bin\mysqld.exe");    
                    newProcessParams.Commandargs                = IniFile.GetValue("DB_Server",         "CommandArgs",      @"--defaults-file=Elite.ini --console");
                    newProcessParams.Workingdirectory           = IniFile.GetValue("DB_Server",         "WorkingDirectory", @"..\..\..\RNDatabase\Database");
                    newProcessParams.Port                       = IniFile.GetValue<UInt16>("DB_Server", "Port",             "3306");
                    newProcessParams.DBStartTimeout             = IniFile.GetValue<Int16>("DB_Server",  "DBStartTimeout",   "60");

                    Program.SplashScreen.InfoAppendLast("on port " + newProcessParams.Port + "...");

                    EliteDBProcess                              = new DBProcess(newProcessParams);

                    if (EliteDBProcess.WasRunning)
                        Program.SplashScreen.InfoAppendLast("already running...<OK>"); 
                    else
                        Program.SplashScreen.InfoAppendLast("<OK>");
                        


                    // connecT to the database
                    Program.SplashScreen.InfoAdd("connect to sql server...");

                    DBConnector.ConnectionParams newConnectionParams = new DBConnector.ConnectionParams() { };

                    newConnectionParams.Name                    = IniFile.GetValue("DB_Connection",          "Name",           "master");   
                    newConnectionParams.Server                  = IniFile.GetValue("DB_Connection",          "Server",         "localhost");
                    newConnectionParams.Port                    = IniFile.GetValue<UInt16>("DB_Server",      "Port",           "3306");
                    newConnectionParams.Database                = IniFile.GetValue("DB_Connection",          "Database",       "Elite_DB"); 
                    newConnectionParams.User                    = IniFile.GetValue("DB_Connection",          "User",           "RN_User");  
                    newConnectionParams.Pass                    = IniFile.GetValue("DB_Connection",          "Pass",           "Elite");    
                    newConnectionParams.ConnectTimeout          = IniFile.GetValue<Int16>("DB_Connection",   "ConnectTimeout", "60");   
                    newConnectionParams.StayAlive               = IniFile.GetValue<Boolean>("DB_Connection", "StayAlive",      "false");    
                    newConnectionParams.TimeOut                 = IniFile.GetValue<Int16>("DB_Connection",   "TimeOut",        "10000");

                    DBCon                                       = new DBConnector(newConnectionParams);

                    DBCon.Connect();

                    Program.SplashScreen.InfoAppendLast("<OK>");

                    /* **************** database is running ********************** */
                    
                    /* perform updates */
                    Updater.DBUpdate();

                    Program.SplashScreen.InfoAdd("preparing global objects...");

                    // prepare colors-object
                    Colors                                      = new GUIColors();

                    // preprare main data object
                    Data                                        = new IBE.SQL.EliteDBIO();
                    Data.PrepareBaseTables();

                    // create global paths-object
                    //Paths                                       = new ProgramPaths();

                    // prepare settings
//                    Settings                                    = new Settings();
//                    Settings.BaseData                           = Data.BaseData;

                    // prepare commanders log 
                    CommandersLog                               = new CommandersLog();
                    CommandersLog.BaseData                      = Data.BaseData;

                    // prepare price analysis 
                    PriceAnalysis                               = new PriceAnalysis(new DBConnector(DBCon.ConfigData, true));
                    PriceAnalysis.BaseData                      = Data.BaseData;

                    //// starting the external data interface
                    //ExternalData                                = new ExternalDataInterface();

//.........这里部分代码省略.........
开发者ID:Duke-Jones,项目名称:ED-IBE,代码行数:101,代码来源:Program.cs


注:本文中的DBConnector.Connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。