示例#1
0
        public frmMain()
        {
            Thread splashthread = new Thread(new ThreadStart(clsStatus.ShowScreen));

            splashthread.IsBackground = true;
            splashthread.Start();
            InitializeComponent();

            xmlData = new clsXMLData();
            xmlData.connect();
            settings = xmlData.ReadSettings();

            clsStatus.UdpateStatusText(DateTime.Now.ToString());
            clsStatus.UdpateStatusText("\r\nTimer : " + settings.timer + " Minute(s)\r\n");
            Relicate();
            try
            {
                System.Timers.Timer replicationTimer = new System.Timers.Timer();
                replicationTimer.Interval = Convert.ToInt32(settings.timer) * 60 * 1000;
                replicationTimer.Elapsed += new System.Timers.ElapsedEventHandler(MyTimer_Elapsed);
                replicationTimer.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public xmlSettings ReadSettings()
        {
            xmlSettings settings = new xmlSettings();

            if (!File.Exists(xmlSettingsFile))
            {
                settings.success      = false;
                settings.errorMessage = "File not found (" + xmlSettingsFile + ")";
                return(settings);
            }
            string        xmlElement = "";
            XmlTextReader reader     = new XmlTextReader(xmlSettingsFile);

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    xmlElement = reader.Name;
                    //MessageBox.Show(objXmlTextReader.Name);
                    break;

                case XmlNodeType.Text:
                    switch (xmlElement)
                    {
                    case "SERVER":
                        settings.serverName = reader.Value;
                        branchName          = settings.serverName;
                        break;

                    case "DATABASE":
                        settings.dbName = reader.Value;
                        break;

                    case "PORT":
                        settings.dbPort = reader.Value;
                        break;

                    case "USER":
                        settings.userName = reader.Value;
                        break;

                    case "PWD":
                        settings.password = reader.Value;
                        break;

                    case "TIMER":
                        settings.timer = reader.Value;
                        break;
                    }
                    break;
                }
            }
            reader.Close();
            settings.success      = true;
            settings.errorMessage = "";
            return(settings);
        }
示例#3
0
 private void btnError_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(clsReplicate.pendingquery, "Pending Query", MessageBoxButtons.RetryCancel, MessageBoxIcon.None) == DialogResult.Retry)
     {
         xmlsettings = clsxml.ReadSettings();
         dbconnect   = new clsDBConnect(xmlsettings);
         dbconnect.Requeue(dbconnect.LogDBConne, ref errorMessage);
         dbconnect.LogDBConne.Close();
         dbconnect.LogDBConne.Dispose();
     }
     else
     {
         xmlsettings = clsxml.ReadSettings();
         dbconnect   = new clsDBConnect(xmlsettings);
         dbconnect.UpdateSkip(dbconnect.LogDBConne, ref errorMessage);
         dbconnect.LogDBConne.Close();
         dbconnect.LogDBConne.Dispose();
     }
 }
        public DataTable GridFillSql()
        {
            clsXMLData clsXmlData = new clsXMLData();

            settings = clsXmlData.ReadSettings();

            dbinfo.ServerName = settings.serverName;
            dbinfo.DBName     = settings.dbName;
            dbinfo.DBPort     = settings.dbPort;
            dbinfo.DBUser     = settings.userName;
            dbinfo.DBPWD      = settings.password;


            DataTable dt = new DataTable();

            cnn  = new MySqlConnection(connectionString);
            conn = new MySqlConnection(connectionString1);
            try
            {
                cnn.Open();
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("SELECT LASTCONNECTION,COUNT(ID),(SELECT COUNT(ID) FROM REPLICATIONLOG WHERE COMMANDSTATUS = 'SUCCESS') APPLIEDQUERY , (SELECT COUNT(ID) FROM REPLICATIONLOG WHERE UPDATESTATUS = 'SUCCESS') VERIFIEDQUERY FROM replicationinfo JOIN replicationlog ON replicationlog.DBCODE = replicationinfo.CODE ", conn);
                cmd.CommandType = CommandType.Text;
                MySqlDataAdapter sqlda = new MySqlDataAdapter(cmd);
                sqlda.Fill(dt);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can't open connection" + ex.ToString());
            }
            finally
            {
                cnn.Close();
                conn.Close();
            }
            return(dt);
        }
示例#5
0
 public clsReplicate(xmlSettings xmlsettings)
 {
     settings         = xmlsettings;
     mainDBConnection = initReplicate();
 }
示例#6
0
 public clsDBConnect(xmlSettings xmlsettings)
 {
     settings          = xmlsettings;
     mainDBConnections = btnConnect();
 }