コード例 #1
0
ファイル: FormSetting.cs プロジェクト: gangjian/work
        int _update_period; // 更新周期(分)

        #endregion Fields

        #region Constructors

        public FormSetting( ServerInfo db_server, ServerInfo relay_server, int sarea_num,
                            int update_period, E_DB_CONNECT_MODE connect_mode)
        {
            InitializeComponent();
            string host = db_server.Host_name;
            string[] arr = host.Split('.');
            if (4 == arr.Length)
            {
                tbxIP1.Text = arr[0];
                tbxIP2.Text = arr[1];
                tbxIP3.Text = arr[2];
                tbxIP4.Text = arr[3];
            }
            tbxPortNum1.Text = db_server.Port_num.ToString();
            tbxDBName.Text = db_server.Db_name;
            tbxUsrName.Text = db_server.User_id;
            tbxPassword.Text = db_server.Pass_word;

            host = relay_server.Host_name;
            arr = host.Split('.');
            if (4 == arr.Length)
            {
                tbxIP5.Text = arr[0];
                tbxIP6.Text = arr[1];
                tbxIP7.Text = arr[2];
                tbxIP8.Text = arr[3];
            }
            tbxPortNum2.Text = relay_server.Port_num.ToString();

            tbxServiceAreaNum.Text = sarea_num.ToString();
            Service_area_num = sarea_num;
            tbxUpdatePeriod.Text = update_period.ToString();
            Update_period = update_period;

            Db_server = db_server;
            Relay_server = relay_server;

            Db_connect_mode = connect_mode;
            if (E_DB_CONNECT_MODE.DIRECT == Db_connect_mode)
            {
                checkBox1.Checked = true;
            }
            else
            {
                checkBox2.Checked = true;
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: gangjian/work
        void LoadIniFile()
        {
            Db_server = new ServerInfo("", 0, "", "", "");
            Db_server.Host_name = IniFile.IniReadValue("DB_SERVER_INFO", "HOST");
            string readStr = IniFile.IniReadValue("DB_SERVER_INFO", "PORT");
            int value;
            if (int.TryParse(readStr, out value))
            {
                Db_server.Port_num = value;
            }
            Db_server.Db_name = IniFile.IniReadValue("DB_SERVER_INFO", "DB_NAME");
            Db_server.User_id = IniFile.IniReadValue("DB_SERVER_INFO", "USR_NAME");
            Db_server.Pass_word = IniFile.IniReadValue("DB_SERVER_INFO", "PASSWORD");

            Relay_server = new ServerInfo("", 0, "", "", "");
            Relay_server.Host_name = IniFile.IniReadValue("RELAY_SERVER_INFO", "HOST");
            readStr = IniFile.IniReadValue("RELAY_SERVER_INFO", "PORT");
            if (int.TryParse(readStr, out value))
            {
                Relay_server.Port_num = value;
            }

            readStr = IniFile.IniReadValue("SERVICE_AREA_INFO", "SERVICE_AREA_NUM");
            if (int.TryParse(readStr, out value))
            {
                Service_area_num = value;
            }
            Service_area_name = IniFile.IniReadValue("SERVICE_AREA_INFO", "SERVICE_AREA_NAME");
            readStr = IniFile.IniReadValue("SETTING", "UPDATE_PERIOD");
            if (int.TryParse(readStr, out value))
            {
                Update_period = value;
            }

            readStr = IniFile.IniReadValue("DB_CONNECT_INFO", "CONNECT_MODE");
            if (readStr == E_DB_CONNECT_MODE.DIRECT.ToString())
            {
                Db_connect_mode = E_DB_CONNECT_MODE.DIRECT;
            }
            else
            {
                Db_connect_mode = E_DB_CONNECT_MODE.RELAY;
            }

            string listView1ColNames = IniFile.IniReadValue("LISTVIEW_COLUMN", "LISTVIEW_1_COLUMN_NAME");
            string listView1ColWidths = IniFile.IniReadValue("LISTVIEW_COLUMN", "LISTVIEW_1_COLUMN_WIDTH");
            AddListViewColumns(listView1, listView1ColNames, listView1ColWidths);

            string listView2ColNames = IniFile.IniReadValue("LISTVIEW_COLUMN", "LISTVIEW_2_COLUMN_NAME");
            string listView2ColWidths = IniFile.IniReadValue("LISTVIEW_COLUMN", "LISTVIEW_2_COLUMN_WIDTH");
            AddListViewColumns(listView2, listView2ColNames, listView2ColWidths);

            string listView3ColNames = IniFile.IniReadValue("LISTVIEW_COLUMN", "LISTVIEW_3_COLUMN_NAME");
            string listView3ColWidths = IniFile.IniReadValue("LISTVIEW_COLUMN", "LISTVIEW_3_COLUMN_WIDTH");
            AddListViewColumns(listView3, listView3ColNames, listView3ColWidths);

            string listView4ColNames = IniFile.IniReadValue("LISTVIEW_COLUMN", "LISTVIEW_4_COLUMN_NAME");
            string listView4ColWidths = IniFile.IniReadValue("LISTVIEW_COLUMN", "LISTVIEW_4_COLUMN_WIDTH");
            AddListViewColumns(listView4, listView4ColNames, listView4ColWidths);

            string listView5ColNames = IniFile.IniReadValue("LISTVIEW_COLUMN", "LISTVIEW_5_COLUMN_NAME");
            string listView5ColWidths = IniFile.IniReadValue("LISTVIEW_COLUMN", "LISTVIEW_5_COLUMN_WIDTH");
            AddListViewColumns(listView5, listView5ColNames, listView5ColWidths);

            Db_table_list = new List<string>();
            string table_name = IniFile.IniReadValue("DB_TABLE_NAME", "DB_TABLE_1"); Db_table_list.Add(table_name);
            table_name = IniFile.IniReadValue("DB_TABLE_NAME", "DB_TABLE_2"); Db_table_list.Add(table_name);
            table_name = IniFile.IniReadValue("DB_TABLE_NAME", "DB_TABLE_3"); Db_table_list.Add(table_name);
            table_name = IniFile.IniReadValue("DB_TABLE_NAME", "DB_TABLE_4"); Db_table_list.Add(table_name);
            table_name = IniFile.IniReadValue("DB_TABLE_NAME", "DB_TABLE_5"); Db_table_list.Add(table_name);

            string autoStartStr = IniFile.IniReadValue("SETTING", "AUTO_START");
            if ("true" == autoStartStr.ToLower())
            {
                cbxAutoStart.Checked = true;
            }
            else
            {
                cbxAutoStart.Checked = false;
            }

            string logOutputEnableStr = IniFile.IniReadValue("LOG_OUTPUT", "ENABLE");
            bool logOutputEnable = false;
            if (bool.TryParse(logOutputEnableStr, out logOutputEnable))
            {
                LogOutput.Enabled = logOutputEnable;
            }
        }