コード例 #1
0
 private void savetoolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         _dbconn.SQLClose();
         SQLConnObj sqlCObj = _dbconn.Connection(tbdbserver.Text, tbdbdatabase.Text, tbdbuser.Text, tbdbpassword.Text);
         if (!sqlCObj.isConnect)
         {
             //this.WriteLog("Save Database config...");
             _dbconn.SQLOpen();
             //this.EnableComponents(true);
             //this.WriteIni();
             _snackboxx.SetNewDBConnection(ref _dbconn);
         }
         if (_dbconn.GetState == ConnectionState.Closed)
         {
             //tssInfoONE.Text = "Database is corrupt...";
             //this.WriteInfo("Save Database Config ... Database is corrupt...");
             //this.EnableComponents(false);
         }
     }
     catch (Exception exp)
     {
         //this.WriteLog(exp.Message);
     }
 }
コード例 #2
0
 private void Connect()
 {
     try
     {
         _dbconn.SQLClose();
         SQLConnObj sqlCObj = _dbconn.Connection(tbdbserver.Text, tbdbdatabase.Text, tbdbuser.Text, tbdbpassword.Text);
         if (!sqlCObj.isConnect)
         {
             //this.WriteLog("Save Database config...");
             _dbconn.SQLOpen();
             //this.EnableComponents(true);
             //this.WriteIni();
         }
         if (_dbconn.GetState == ConnectionState.Closed)
         {
             //tssInfoONE.Text = "Database is corrupt...";
             //this.WriteInfo("Save Database Config ... Database is corrupt...");
             //this.EnableComponents(false);
         }
     }
     catch (Exception exp)
     {
         //this.WriteLog(exp.Message);
     }
 }
コード例 #3
0
        private void btndbcheck_Click(object sender, EventArgs e)
        {
            SQLConnObj sqlCObj = _dbconn.TestConnection(tbdbserver.Text, tbdbdatabase.Text, tbdbuser.Text, tbdbpassword.Text);

            if (sqlCObj.isConnect)
            {
                //this.WriteLog("Check DataBase... ready");
                labconnstat.Text = "Database is ready...";
                //this.EnableComponents(true);
            }
            else
            {
                labconnstat.Text = "Database is corrupt...";
                //this.WriteLog("Check Database... " + sqlCObj.exp.Message);
            }
        }
コード例 #4
0
        private void CheckConnection()
        {
            XmlDocument xmldoc = new XmlDocument();
            string      file   = Server.MapPath(@"\settings.xml");
            FileInfo    fi     = new FileInfo(file);

            if (fi.Exists)
            {
                string dbserver   = null;
                string dbdatabase = null;
                string dbuser     = null;
                string dbpassword = null;
                xmldoc.Load(file);
                XmlElement root = xmldoc.DocumentElement;
                foreach (XmlNode node in root.ChildNodes)
                {
                    if (node.Name.Equals("server"))
                    {
                        dbserver = node.InnerText;
                    }
                    if (node.Name.Equals("database"))
                    {
                        dbdatabase = node.InnerText;
                    }
                    if (node.Name.Equals("user"))
                    {
                        dbuser = node.InnerText;
                    }
                    if (node.Name.Equals("passw"))
                    {
                        dbpassword = node.InnerText;
                    }
                }
                if (!string.IsNullOrEmpty(dbserver) && !string.IsNullOrEmpty(dbdatabase) && !string.IsNullOrEmpty(dbuser) && !string.IsNullOrEmpty(dbpassword))
                {
                    SQLConnObj sqlobj = _dbconn.Connection(dbserver, dbdatabase, dbuser, dbpassword);
                    if (!sqlobj.isConnect)
                    {
                        labinfo.Text     = "No Database connected...";
                        btnlogon.Enabled = false;
                    }
                }
            }
        }
コード例 #5
0
ファイル: Worker.cs プロジェクト: daniel-kuon/Snackboxx
 public void Start()
 {
     this.Startparameter();
     LogFile.WriteLog("Start Snackboxx Service...", _installpath);
     if (!_readini.ConfigFileExists())
     {
         LogFile.WriteLog("Ini File not exists...", _installpath);
         DirectoryInfo di = new DirectoryInfo(_inipath.Substring(0, _inipath.LastIndexOf("\\")));
         if (!di.Exists)
         {
             di.Create();
         }
         _writeini.Write(_inipath, _iniObj);
     }
     else
     {
         this.ReadIni();
         _ready = true;
         _scannercode.Start();
         try
         {
             SQLConnObj sqlObj = _dbconn.Connection(_iniObj.Server, _iniObj.Database, _iniObj.User, _iniObj.Password);
             if (!sqlObj.isConnect)
             {
                 _ready = false;
                 LogFile.WriteLog("SQL Exception... " + sqlObj.exp.Message);
             }
             else
             {
                 LogFile.WriteLog("Database connected...");
                 _threadrun = true;
                 Thread runner = new Thread(new ThreadStart(Runner));
                 runner.Start();
             }
         }
         catch (Exception exp)
         {
             LogFile.WriteLog("Exception... " + exp.Message);
         }
     }
 }