Ejemplo n.º 1
0
        private bool check_cms_in_vms(int vms_index)
        {
            for (int i = 0; i < 6; i++)
            {
                string _name     = "gdm." + inc._vms[vms_index]._id.ToString() + "." + (i + 1).ToString() + ".txt";
                string _path     = "gdm" + inc._vms[vms_index]._id.ToString();
                string _workdir  = fn_global.get_workdir(_path);
                string file_name = _workdir + "\\" + _name;

                if (fn_global.fn_file_exist(_path, _name))
                {
                    if (fn_global.fn_get_file(_path, _name, _name))
                    {
                        MyFile f = new MyFile();

                        f.FileName = file_name;
                        for (int j = 1; j < 4; j++)
                        {
                            string name = "cp" + j.ToString() + "_cms_id";
                            string temp = "";
                            temp = f.search_file_line(name);

                            if (temp == CMS_id.ToString())
                            {
                                return(true);
                            }
                        }
                        f.close();
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        private void save_report(string name)
        {
            MyFile mf = new MyFile(name);

            mf.addstr_to_file(tabControl_management.TabPages[tabControl_management.SelectedIndex].Text);
            mf.addstr_to_file("Report time: " + get_report_date());
            mf.addstr_to_file("Time: " + DateTime.Now.ToString("dd ") + inc.Month_Display[DateTime.Now.Month] + DateTime.Now.ToString(" yyyy"));
            string str           = "";
            string _datagridname = get_report_dataviewname();

            for (int i = 0; i < ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns.Count; i++)
            {
                if (((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns[i].Visible)
                {
                    str += ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns[i].HeaderText + ",";
                }
            }
            mf.addstr_to_file(str);
            for (int i = 0; i < ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Rows.Count; i++)
            {
                str = "";
                for (int j = 0; j < ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns.Count; j++)
                {
                    if (((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns[j].Visible)
                    {
                        str += Tools.get_value(((DataGridView)this.Controls.Find(_datagridname, true)[0]).Rows[i].Cells[j].Value) + ",";
                    }
                }
                mf.addstr_to_file(str);
                Application.DoEvents();
            }
            mf.close();
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string _week = "";
            int    index = fn_global.fn_cms_name2index(textBox8.Text);

            if (index >= 0)
            {
                if (comboBox1.SelectedIndex != 6)
                {
                    _week = "." + (comboBox1.SelectedIndex + 1).ToString();
                }
                string _name = "cms." + inc.Carpark[index].id + _week + ".txt";
                //string file_name = fn_global.get_workdir("") + "\\cms" + inc.Carpark[index].id + "\\" + _name;

                string file_name = fn_global.get_workdir("\\cms" + inc.Carpark[index].id) + "\\" + _name;

                MyFile ftimezone = new MyFile();
                try
                {
                    ftimezone.FileName = file_name;

                    //string[] valueofzone = new string[16];

                    for (int i = 0; i < dataGridView3.Rows.Count; i++)
                    {
                        string _vms_name = Tools.get_value(dataGridView3.Rows[i].Cells[0].Value);
                        int    _index    = fn_global.fn_vms_name2index(_vms_name);
                        string name_head = "gdm" + inc._vms[_index]._id.ToString() + "_";
                        for (int j = 1; j <= 16; j++)
                        {
                            string name          = name_head + "zone" + j.ToString();
                            string _offset_value = name + "=" + Tools.get_value(dataGridView3.Rows[i].Cells[j].Value);
                            //Thread.Sleep(20);
                            ftimezone.write_to_file(_offset_value);
                        }
                    }
                    ftimezone.write_to_file("file_type=cms");
                    ftimezone.close();


                    if (fn_global.fn_put_file("cms" + inc.Carpark[index].id, _name))
                    {
                        MessageBox.Show("Update CMS Timezone Successaful");
                    }
                    else
                    {
                        MessageBox.Show("Update CMS Timezone Failed");
                    }
                }
                catch (Exception e1)
                {
                    MessageBox.Show(e1.Message);
                    ftimezone.close();
                }

                //ftimezone = null;
                //ftimezone = new MyFile("temp");
            }
        }
Ejemplo n.º 4
0
        private void add_timezone_data()
        {
            string _week = "";

            //dataGridView3.Rows.Clear();
            if (comboBox1.SelectedIndex != 6)
            {
                _week = "." + (comboBox1.SelectedIndex + 1).ToString();
            }
            string _path = "cms" + CMS_id.ToString();
            string _name = "cms." + CMS_id.ToString() + _week + ".txt";

            for (int r = 0; r < dataGridView3.Rows.Count; r++)
            {
                for (int j = 1; j <= 16; j++)
                {
                    dataGridView3.Rows[r].Cells[j].Value = "";
                }
                dataGridView3.EndEdit();
            }

            if (!fn_global.fn_get_file(_path, _name, _name))
            {
                return;
            }

            MyFile ftimeoffset = new MyFile();

            try
            {
                string _workdir = fn_global.get_workdir(_path);
                ftimeoffset.FileName = _workdir + "\\" + _name;

                for (int r = 0; r < dataGridView3.Rows.Count; r++)
                {
                    int i = fn_global.fn_vms_name2index(dataGridView3.Rows[r].Cells[0].Value.ToString());
                    if (i >= 0)
                    {
                        string name_head = "gdm" + inc._vms[i]._id.ToString() + "_";
                        for (int j = 1; j <= 16; j++)
                        {
                            string name = name_head + "zone" + j.ToString();
                            dataGridView3.Rows[r].Cells[j].Value = ftimeoffset.search_file_line(name);
                        }
                        dataGridView3.EndEdit();
                    }
                }

                ftimeoffset.close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                ftimeoffset.close();
                //ftimeoffset = new MyFile("temp");
            }
        }
Ejemplo n.º 5
0
        private void button15_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog sfdSaveOnlineText = new SaveFileDialog();
                sfdSaveOnlineText.Filter           = "CSV files (*.csv)|*.csv";
                sfdSaveOnlineText.FilterIndex      = 0;
                sfdSaveOnlineText.RestoreDirectory = true;
                sfdSaveOnlineText.CreatePrompt     = true;
                sfdSaveOnlineText.Title            = "Save File To";

                if (sfdSaveOnlineText.ShowDialog() == DialogResult.OK)
                {
                    string name = sfdSaveOnlineText.FileName;

                    MyFile mf = new MyFile(name);
                    mf.addstr_to_file(tabControl_management.TabPages[tabControl_management.SelectedIndex].Text);
                    mf.addstr_to_file("Report time: " + get_report_date());
                    mf.addstr_to_file("Time: " + DateTime.Now.ToString("dd ") + inc.Month_Display[DateTime.Now.Month] + DateTime.Now.ToString(" yyyy"));
                    string str           = "";
                    string _datagridname = get_report_dataviewname();

                    mf.addstr_to_file("\r\n");
                    str           = "";
                    _datagridname = dataGridView6.Name;
                    for (int i = 0; i < ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns.Count; i++)
                    {
                        if (((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns[i].Visible)
                        {
                            str += ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns[i].HeaderText + ",";
                        }
                    }
                    mf.addstr_to_file(str);
                    for (int i = 0; i < ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Rows.Count; i++)
                    {
                        str = "";
                        for (int j = 0; j < ((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns.Count; j++)
                        {
                            if (((DataGridView)this.Controls.Find(_datagridname, true)[0]).Columns[j].Visible)
                            {
                                str += Tools.get_value(((DataGridView)this.Controls.Find(_datagridname, true)[0]).Rows[i].Cells[j].Value) + ",";
                            }
                        }
                        mf.addstr_to_file(str);
                        Application.DoEvents();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Save File Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
            }
        }
Ejemplo n.º 6
0
        private void udpate_cms_lots()
        {
            try
            {
                string file_name = "alarmstatus.txt";
                string _workdir  = fn_global.get_workdir("");

                if (!fn_global.fn_get_file("", file_name, file_name))
                {
                    return;
                }

                string str = "";
                if (System.Configuration.ConfigurationSettings.AppSettings["UseRemoteDisk"] == "1")
                {
                    File.Copy((_workdir + "\\" + file_name), "C:\\alarmstatus.txt", true);
                    MyFile mf = new MyFile("C:\\alarmstatus.txt");
                    str = mf.read_file_all();
                    mf.close();
                }
                else
                {
                    MyFile mf = new MyFile(_workdir + "\\" + file_name);
                    str = mf.read_file_all();
                    mf.close();
                }
                string[] list_str = str.Split('\n');

                for (int i = 0; i < inc.Carpark.Length; i++)
                {
                    string s_key = "lots_cms" + inc.Carpark[i].id;

                    string _temp = fn_global.fn_txt_getvalue(list_str, s_key);
                    try { inc.Carpark[i].lots = int.Parse(_temp); }
                    catch { }

                    s_key = "lotslimit_cms" + inc.Carpark[i].id;
                    _temp = fn_global.fn_txt_getvalue(list_str, s_key);
                    try { inc.Carpark[i].limit = int.Parse(_temp); }
                    catch { }
                }
            }
            catch { }
        }
Ejemplo n.º 7
0
        private void button7_Click(object sender, EventArgs e)
        {
            set_enable_printbuttons(false);
            dataGridView5.Rows.Clear();

            if (comboBox2.SelectedIndex >= 0)
            {
                string _path     = "cms" + inc.Carpark[comboBox2.SelectedIndex].id.ToString();
                string _name     = dateTimePicker9.Value.ToString("yyyyMMdd") + ".trans";
                string _cms_name = cms_id2name(inc.Carpark[comboBox2.SelectedIndex].id);
                string _data     = "";

                dataGridView5.Rows.Clear();

                if (fn_global.fn_get_file(_path, _name, _name))
                {
                    MyFile f1 = new MyFile(fn_global.get_workdir(_path) + "\\" + _name);
                    int    i  = 0;

                    while ((_data = f1.read_file_line()) != null)
                    {
                        string[] s_data = _data.Split('|');
                        dataGridView5.Rows.Add();

                        dataGridView5.Rows[i].Cells["time"].Value      = s_data[1];
                        dataGridView5.Rows[i].Cells["user"].Value      = _cms_name;
                        dataGridView5.Rows[i].Cells["occupancy"].Value = (int)(double.Parse(s_data[4]) / 10) + "%";
                        dataGridView5.Rows[i].Cells["lots"].Value      = s_data[2];
                        dataGridView5.Rows[i].Cells["limit"].Value     = s_data[3];
                        i++;

                        label29.Text = "Total: " + i.ToString();
                        Application.DoEvents();
                    }
                    f1.close();
                }
            }
            set_enable_printbuttons(true);
        }
Ejemplo n.º 8
0
        private void set_value(int index)
        {
            string _path     = "cms" + inc.Carpark[index].id.ToString();
            string _name     = dateTimePicker13.Value.ToString("yyyyMMdd") + ".trans";
            string _cms_name = inc.Carpark[index].name;
            string _data     = "";

            if (fn_global.fn_get_file(_path, _name, _name))
            {
                MyFile f1 = new MyFile(fn_global.get_workdir(_path) + "\\" + _name);
                int    i  = 0;
                while ((_data = f1.read_file_line()) != null)
                {
                    string[] s_data = _data.Split('|');

                    DateTime line_time     = Tools.str_to_datetime(s_data[1], "yyyy-MM-dd HH:mm:ss");
                    DateTime cur_line_time = get_time(dataGridView8.Rows.Count - 1);

                    int mmm = line_time.Hour * 12 + line_time.Minute / 5;

                    if (radioButton1.Checked)
                    {
                        dataGridView8.Rows[mmm].Cells[index.ToString()].Value = s_data[2];
                    }
                    else
                    {
                        //dataGridView5.Rows[i].Cells["occupancy"].Value = (int)(double.Parse(s_data[4]) / 10) + "%";
                        dataGridView8.Rows[mmm].Cells[index.ToString()].Value = (int)(double.Parse(s_data[4]) / 10) + "%";
                    }

                    i++;
                    Application.DoEvents();
                }
                f1.close();
            }
        }
Ejemplo n.º 9
0
        private void Form_Dimming_Load(object sender, EventArgs e)
        {
            groupBox1.Text = inc._vms[fn_global.fn_vms_id2index(VMSid)].name + " Dimming Configuation";
            comboBox1.Items.AddRange(inc.Dimming_mode);
            if ((fn_type == 0) || (fn_type == 1))
            {
                button1.Visible = false;

                string _workdir = fn_global.get_workdir("gdm" + VMSid.ToString());
                string f_name   = "";
                if (fn_type == 1)
                {
                    f_name = _workdir + "\\dimupdate.txt";
                }
                else
                {
                    f_name = _workdir + "\\dimget.txt";
                }

                MyFile f1 = new MyFile(f_name);

                label20.Text = Tools.get_str_value(f1.read_file_line());
                string _temp0 = f1.read_file_line();
                string _temp  = Tools.get_str_value(_temp0);
                if (_temp == "Disconnect")
                {
                    comboBox1.Visible = false;
                    for (int i = 1; i < 9; i++)
                    {
                        ((TextBox)this.Controls.Find("textBox" + i, true)[0]).Visible = false;
                    }

                    for (int i = 2; i <= 19; i++)
                    {
                        ((Label)this.Controls.Find("label" + i, true)[0]).Visible = false;
                    }
                    textBox9.Visible = false;
                    label1.Text      = _temp0;
                }
                else
                {
                    comboBox1.Enabled = false;
                    for (int i = 1; i <= 9; i++)
                    {
                        ((TextBox)this.Controls.Find("textBox" + i, true)[0]).ReadOnly = true;
                    }
                    if (fn_type == 1)
                    {
                        comboBox1.Text = _temp;
                        for (int i = 1; i < 9; i++)
                        {
                            ((TextBox)this.Controls.Find("textBox" + i, true)[0]).Text = Tools.get_str_value(f1.read_file_line());
                        }
                        textBox9.Text = Tools.get_str_value(f1.read_file_line());
                    }
                    else
                    {
                        ((TextBox)this.Controls.Find("textBox" + 1, true)[0]).Text = _temp;
                        for (int i = 2; i < 9; i++)
                        {
                            ((TextBox)this.Controls.Find("textBox" + i, true)[0]).Text = Tools.get_str_value(f1.read_file_line());
                        }
                        comboBox1.Text = Tools.get_str_value(f1.read_file_line());
                        textBox9.Text  = Tools.get_str_value(f1.read_file_line());
                    }
                }
                f1.close();
            }
            else
            {
                button1.Visible = true;

                string _workdir = fn_global.get_workdir("gdm" + VMSid.ToString());
                string f_name   = "";

                f_name = _workdir + "\\dimming.txt";

                MyFile f1 = new MyFile(f_name);

                comboBox1.Text = Tools.get_str_value(f1.read_file_line());
                for (int i = 1; i < 9; i++)
                {
                    ((TextBox)this.Controls.Find("textBox" + i, true)[0]).Text
                        = Tools.get_str_value(f1.read_file_line());
                }
                textBox9.Text = Tools.get_str_value(f1.read_file_line());

                f1.close();
            }
        }
Ejemplo n.º 10
0
        private void Form_Config_CMS_Load(object sender, EventArgs e)
        {
            textBox8.Text = inc.Carpark[fn_global.fn_cms_id2index(CMS_id)].name;
            comboBox1.Items.AddRange(inc.WeekDays);
            comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;

            if (!fn_global.fn_get_file("setting", "cms_timezone.txt", "cms_timezone.txt"))
            {
                return;
            }

            string _workdir    = fn_global.get_workdir("setting");
            MyFile ftimezone   = new MyFile(_workdir + "\\cms_timezone.txt");
            string _temp       = "";
            int    j           = 0;
            int    _len        = 1;
            string time_string = "";

            dataGridView3.Columns.Add("VMS", "VMS");
            while ((_temp = ftimezone.read_file_line()) != null)
            {
                //int _index = 32;
                try
                {
                    bool _addj = false;
                    if (j >= 10)
                    {
                        _len = 2;
                    }

                    string _day = _temp.Substring(6, _len);
                    int    i    = int.Parse(_day);

                    if (_temp.IndexOf("start") > 0)
                    {
                        time_string = Tools.get_str_value(_temp) + "-";
                        //_addj = true;
                    }
                    else if (_temp.IndexOf("end") > 0)
                    {
                        time_string += Tools.get_str_value(_temp);
                        _addj        = true;
                    }
                    if (_addj)
                    {
                        dataGridView3.Columns.Add(time_string, time_string);
                        time_string = "";
                        j++;
                    }
                }
                catch { }
            }
            ftimezone.close();
            //ftimezone = new MyFile("temp");

            dataGridView3.Columns["VMS"].ReadOnly = true;
            dataGridView3.Columns["VMS"].Width    = 180;

            for (int i = 0; i < inc._vms.Length; i++)
            {
                if (!check_cms_in_vms(i))
                {
                    continue;
                }

                dataGridView3.Rows.Add();
                dataGridView3.Rows[dataGridView3.Rows.Count - 1].Cells["VMS"].Value = inc._vms[i].name;
            }

            //comboBox1.SelectedIndex = 0;
        }