public void run()
        {
            while (state)
            {
                updateGUI("Start.");

                this.shopList = new Dictionary<String, Shop>();
                try
                {
                    updateGUI("Getting shop ip list.");

                    SqlConnection connection = new SqlConnection(Properties.Settings.Default.crrhkitop);
                    connection.Open();
                    String shop_sql = @"
                        select store_code, store_ip, store_loginid, store_loginpw
                        from ShopIPAddress where store_active = 'T' order by store_code";
                    SqlCommand command = new SqlCommand(shop_sql, connection);
                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        shopList.Add(reader[0].ToString(), new Shop(reader[1].ToString(), reader[2].ToString(), reader[3].ToString()));
                    }
                    reader.Close();
                    connection.Close();
                }
                catch (SqlException ex)
                {
                    updateGUI(ex.Message);
                    stop();
                }

                ds = new DataSet();
                dt = new DataTable();
                dt.Columns.Add(new DataColumn("Shop", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("Size", Type.GetType("System.String")));

                foreach (KeyValuePair<String, Shop> kvp in shopList)
                {
                    key = kvp.Key;
                    shop = kvp.Value;
                    dr = dt.NewRow();
                    dr["Shop"] = key;

                    updateGUI("Checking " + key);

                    connectionString = "Provider=MSDAORA.1;Data Source=@ip;Persist Security Info=True;User ID=@id;Password=@pw;Unicode=True";
                    connectionString = connectionString.Replace("@ip", shop.ip + "/xe");
                    connectionString = connectionString.Replace("@id", shop.id);
                    connectionString = connectionString.Replace("@pw", shop.pw);

                    try
                    {
                        OleDbConnection con = new OleDbConnection(connectionString);
                        con.Open();
                        OleDbCommand command = new OleDbCommand(sizeSql, con);
                        OleDbDataReader reader = command.ExecuteReader();

                        while (reader.Read())
                            dr["Size"] = reader[0].ToString() + " MB";
                    }
                    catch (OleDbException ex)
                    {
                        updateGUI(key + " " +ex.Message);
                        dr["Size"] = ex.Message;
                    }
                    dt.Rows.Add(dr);
                }
                if (dt.Rows.Count > 0)
                {
                    ds.Tables.Add(dt);
                    using (ShopDBFreeSpaceReport sdbfsr = new ShopDBFreeSpaceReport())
                    {
                        sdbfsr.setDataSet(ds);
                        sdbfsr.ShowDialog();
                    }
                }
                state = false;
            }
        }
示例#2
0
        public void run()
        {
            while (state)
            {
                updateGUI("Start.");

                this.shopList = new Dictionary <String, Shop>();
                try
                {
                    updateGUI("Getting shop ip list.");

                    SqlConnection connection = new SqlConnection(Properties.Settings.Default.crrhkitop);
                    connection.Open();
                    String        shop_sql = @"
                        select store_code, store_ip, store_loginid, store_loginpw
                        from ShopIPAddress where store_active = 'T' order by store_code";
                    SqlCommand    command  = new SqlCommand(shop_sql, connection);
                    SqlDataReader reader   = command.ExecuteReader();

                    while (reader.Read())
                    {
                        shopList.Add(reader[0].ToString(), new Shop(reader[1].ToString(), reader[2].ToString(), reader[3].ToString()));
                    }
                    reader.Close();
                    connection.Close();
                }
                catch (SqlException ex)
                {
                    updateGUI(ex.Message);
                    stop();
                }

                ds = new DataSet();
                dt = new DataTable();
                dt.Columns.Add(new DataColumn("Shop", Type.GetType("System.String")));
                dt.Columns.Add(new DataColumn("Size", Type.GetType("System.String")));

                foreach (KeyValuePair <String, Shop> kvp in shopList)
                {
                    key        = kvp.Key;
                    shop       = kvp.Value;
                    dr         = dt.NewRow();
                    dr["Shop"] = key;

                    updateGUI("Checking " + key);

                    connectionString = "Provider=MSDAORA.1;Data Source=@ip;Persist Security Info=True;User ID=@id;Password=@pw;Unicode=True";
                    connectionString = connectionString.Replace("@ip", shop.ip + "/xe");
                    connectionString = connectionString.Replace("@id", shop.id);
                    connectionString = connectionString.Replace("@pw", shop.pw);

                    try
                    {
                        OleDbConnection con = new OleDbConnection(connectionString);
                        con.Open();
                        OleDbCommand    command = new OleDbCommand(sizeSql, con);
                        OleDbDataReader reader  = command.ExecuteReader();

                        while (reader.Read())
                        {
                            dr["Size"] = reader[0].ToString() + " MB";
                        }
                    }
                    catch (OleDbException ex)
                    {
                        updateGUI(key + " " + ex.Message);
                        dr["Size"] = ex.Message;
                    }
                    dt.Rows.Add(dr);
                }
                if (dt.Rows.Count > 0)
                {
                    ds.Tables.Add(dt);
                    using (ShopDBFreeSpaceReport sdbfsr = new ShopDBFreeSpaceReport())
                    {
                        sdbfsr.setDataSet(ds);
                        sdbfsr.ShowDialog();
                    }
                }
                state = false;
            }
        }