示例#1
0
        public MySqlConnection GetMySqlConnection()
        {
            string installPath = Assembly.GetExecutingAssembly().Location;
            string fileName = string.Format("{0}\\..\\local.ip", installPath);

            var s = new DBConnectionString();
            s.Address = "127.0.0.1";
            if (File.Exists(fileName))
            {
                using (StreamReader sr = new StreamReader(fileName))
                {
                    string ip = sr.ReadLine();
                    if (ip != null && ip.Length > 0)
                    {
                        s.Address = ip;
                    }
                }
            }
            this.ConnectionString = s.ToString();
            var conn = new MySqlConnection(this.ConnectionString);

            if (conn != null)
            {
                try
                {
                    conn.Open();
                    return conn;
                }
                catch (Exception e)
                {
                    string msg = e.Message;
                }
            }
            return null;
        }
示例#2
0
        internal void CreateDAQDB()
        {
            var s = new DBConnectionString();
            s.Database = "mysql";
            var connectionString = s.ToString();
            using (var connToMySql = new MySqlConnection(connectionString))
            {
                connToMySql.Open();

                MySqlCommand cmd = connToMySql.CreateCommand();
                cmd.CommandText = "CREATE DATABASE if NOT EXISTS scada";
                cmd.ExecuteNonQuery();
                cmd.Dispose();
            }
        }
示例#3
0
        /// <summary>
        /// 
        /// </summary>
        public DBDataProvider()
        {
            this.allDeviceKeys.Add(DeviceKey_Hpic);
            this.allDeviceKeys.Add(DeviceKey_Dwd);
            this.allDeviceKeys.Add(DeviceKey_HvSampler);
            this.allDeviceKeys.Add(DeviceKey_ISampler);
            this.allDeviceKeys.Add(DeviceKey_NaI);
            this.allDeviceKeys.Add(DeviceKey_Shelter);
            this.allDeviceKeys.Add(DeviceKey_Weather);

            this.FetchCount = 26;

            this.dataListeners = new Dictionary<string, DBDataCommonListerner>(30);

            // 192.168.1.24
            string installPath = Assembly.GetExecutingAssembly().Location;
            string fileName = string.Format("{0}\\..\\local.ip", installPath);
            var s = new DBConnectionString();
            s.Address = "127.0.0.1";
            if (File.Exists(fileName))
            {
                using (StreamReader sr = new StreamReader(fileName))
                {
                    string ip = sr.ReadLine();
                    if (ip != null && ip.Length > 0)
                    {
                        s.Address = ip;
                    }
                }
            }

            this.ConnectionString = s.ToString();
            this.conn = new MySqlConnection(this.ConnectionString);

            if (this.conn != null)
            {
                try
                {
                    this.conn.Open();
                    this.cmd = this.conn.CreateCommand();
                }
                catch (Exception e)
                {
                    string msg = e.Message;
                }
            }

            // 192.168.1.24

            this.timelineSource = new List<Dictionary<string, object>>();
        }