示例#1
0
        private void DataArrival(byte[] Data, System.Net.IPAddress Ip, int Port) //当有数据到达后的处理进程
        {
            try
            {
                //RegisterMsg registermsg = (RegisterMsg)new ClassSerializers().DeSerializeBinary(new MemoryStream(msg.Data));

                ClassMsg msg = new ClassSerializers().DeSerializeBinary((new System.IO.MemoryStream(Data))) as ClassMsg;
                switch (msg.msgCommand)
                {
                case MsgCommand.DBList:
                    //DialogResult = DialogResult.OK;
                    mydics = (MyDictioinary <string, DB_Map>) new ClassSerializers().DeSerializeBinary(new MemoryStream(msg.Data));
                    //渲染数据库资源下拉按钮之前,保存列表字典到全局区
                    //全局变量重构//
                    //PublicValue.mydics = mydics;
                    SuperMessage.mydics = mydics;
                    //数据库列表展开
                    init2_views();
                    dbconn_comb.Items.Clear();
                    foreach (KeyValuePair <string, DB_Map> mydic in mydics.llDictionary)
                    {
                        if (mydic.Value.property == 0 && Publec_Class.UserName != mydic.Value.rguser)
                        {
                            continue;
                        }
                        if (mydic.Value.property == 1 && mydic.Value.ack == "否")
                        {
                            continue;
                        }
                        if (dbconn_comb.Text.Trim().Length > 0)
                        {
                            dbconn_comb.Items.Add(mydic.Key);
                        }
                        else
                        {
                            dbconn_comb.Items.Add(mydic.Key);
                            dbconn_comb.Text     = mydic.Key;
                            dbconn_ipaddr.Text   = mydic.Value.ipaddr;
                            dbconn_username.Text = mydic.Value.username;
                            dbconn_password.Text = mydic.Value.password;
                            dbconn_port.Text     = mydic.Value.port.ToString();
                        }
                        //Console.WriteLine("数据库列表测试:"+ mydic.Key.ToString() + "\t:" + mydic.Value.ToString());
                    }
                    PublicValue.dbname = dbconn_comb.Items[0].ToString();
                    init4_views();
                    break;

                case MsgCommand.DBCount:    //数据库资源为0
                    //没有数据库资源
                    //Console.WriteLine("没有数据库资源列表哦。。");
                    //初始化界面为0应该的样子
                    init_views();
                    break;
                }
            }
            catch { }
        }
示例#2
0
        private void DataArrival(byte[] Data, System.Net.IPAddress Ip, int Port) //当有数据到达后的处理进程
        {
            try
            {
                ClassMsg msg = new ClassSerializers().DeSerializeBinary((new System.IO.MemoryStream(Data))) as ClassMsg;
                switch (msg.msgCommand)
                {
                case MsgCommand.TaskList:
                    //DialogResult = DialogResult.OK;
                    mytasks = (MyDictioinary <string, DB_Task>) new ClassSerializers().DeSerializeBinary(new MemoryStream(msg.Data));
                    //渲染数据
                    SuperMessage.mytasks = mytasks;
                    //数据库任务列表
                    this.splitContainer1.Visible = true;
                    this.treeView1.Nodes.Clear();
                    TreeNode datasync = new TreeNode("数据同步");    //mytask.Value.TaskName

                    foreach (KeyValuePair <string, DB_Task> mytask in mytasks.llDictionary)
                    {
                        //var synctask = datasync.Nodes.Add(mytask.Value.TaskName);
                        //如果还有子任务则:参考:https://blog.csdn.net/laoyezha/article/details/79302679
                        //    pointer = synctask.Nodes.Add("一人之下");
                        datasync.Nodes.Add(mytask.Value.TaskName);
                    }
                    this.treeView1.Nodes.Add(datasync);

                    break;

                case MsgCommand.DBTaskCount:    //数据库资源为0
                    //0任务列表,不做显示
                    //初始化界面为0应该的样子
                    this.splitContainer1.Visible = false;

                    break;

                case MsgCommand.DBList:
                    //DialogResult = DialogResult.OK;
                    mydics = (MyDictioinary <string, DB_Map>) new ClassSerializers().DeSerializeBinary(new MemoryStream(msg.Data));
                    //渲染数据库资源下拉按钮之前,保存列表字典到全局区
                    //全局变量重构//
                    //PublicValue.mydics = mydics;
                    SuperMessage.mydics = mydics;

                    break;

                case MsgCommand.DBCount:    //数据库资源为0

                    break;
                }
            }
            catch { }
        }
示例#3
0
        private void DataArrival(byte[] Data, System.Net.IPAddress Ip, int Port) //当有数据到达后的处理进程
        {
            try
            {
                ClassMsg msg = new ClassSerializers().DeSerializeBinary((new System.IO.MemoryStream(Data))) as ClassMsg;
                switch (msg.msgCommand)
                {
                case MsgCommand.DBList:
                    //DialogResult = DialogResult.OK;
                    mydics = (MyDictioinary <string, DB_Map>) new ClassSerializers().DeSerializeBinary(new MemoryStream(msg.Data));
                    //渲染数据库资源下拉按钮之前,保存列表字典到全局区PublicValue.mydics
                    //全局变量重构//
                    //PublicValue.mydics = mydics;
                    SuperMessage.mydics = mydics;

                    //数据库列表展开
                    dataGridView1_house.AllowUserToAddRows = true;

                    int i     = this.dataGridView1_house.Rows.Count;
                    int j     = this.dataGridView1_house.Rows[0].Cells.Count;
                    int i_tmp = 0;
                    foreach (KeyValuePair <string, DB_Map> mydic in mydics.llDictionary)
                    {
                        //针对不同的数据资源展现不同列表
                        if (SuperMessage.dbtype == 1)
                        {
                            if (SuperMessage.dbtype == 1 && mydic.Value.property == 0)
                            {
                                continue;
                            }
                            if (i_tmp + 1 >= dataGridView1_house.Rows.Count)
                            {
                                this.dataGridView1_house.Rows.Add();
                            }
                            this.dataGridView1_house.Rows[i_tmp].Cells[0].Value = "(公司)" + mydic.Value.name;
                            this.dataGridView1_house.Rows[i_tmp].Cells[1].Value = mydic.Value.username;
                            this.dataGridView1_house.Rows[i_tmp].Cells[2].Value = mydic.Value.password;
                            this.dataGridView1_house.Rows[i_tmp].Cells[3].Value = mydic.Value.ipaddr;
                            this.dataGridView1_house.Rows[i_tmp].Cells[4].Value = mydic.Value.port;
                        }
                        if (SuperMessage.dbtype == 0)
                        {
                            if (mydic.Value.ack != "是" && mydic.Value.property == 1)
                            {
                                continue;
                            }
                            if (mydic.Value.rguser != Publec_Class.UserName && mydic.Value.property == 0)
                            {
                                continue;
                            }
                            if (i_tmp + 1 >= dataGridView1_house.Rows.Count)
                            {
                                this.dataGridView1_house.Rows.Add();
                            }
                            if (mydic.Value.property == 0)
                            {
                                this.dataGridView1_house.Rows[i_tmp].Cells[0].Value = "(私有)" + mydic.Value.name;
                            }
                            else
                            {
                                this.dataGridView1_house.Rows[i_tmp].Cells[0].Value = "(公司)" + mydic.Value.name;
                            }
                            this.dataGridView1_house.Rows[i_tmp].Cells[1].Value = mydic.Value.username;
                            this.dataGridView1_house.Rows[i_tmp].Cells[2].Value = mydic.Value.password;
                            this.dataGridView1_house.Rows[i_tmp].Cells[3].Value = mydic.Value.ipaddr;
                            this.dataGridView1_house.Rows[i_tmp].Cells[4].Value = mydic.Value.port;
                        }

                        i_tmp += 1;
                    }

/*                        for (int k = i_tmp; k <= dataGridView1_house.Rows.Count; k++)
 *                      {
 *                          dataGridView1_house.Rows.Remove(dataGridView1_house.Rows[k]);
 *                      }
 */
                    //dataGridView1_house.AllowUserToAddRows = false;
                    break;

                case MsgCommand.PVSUCCESS:    //数据资源申请后返回、
                    MessageBox.Show("       申请成功已提交-请等待管理员确认!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return;

                    break;

                case MsgCommand.PVFAIL:    //数据资源申请后返回、
                    MessageBox.Show("       操作失败-或者已经申请过-如有疑问请联系管理员!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return;

                    break;

                case MsgCommand.DBCount:    //数据库资源为0
                    break;
                }
            }
            catch { }
        }
示例#4
0
        private void DataArrival(byte[] Data, System.Net.IPAddress Ip, int Port) //当有数据到达后的处理进程
        {
            try
            {
                ClassMsg msg = new ClassSerializers().DeSerializeBinary((new System.IO.MemoryStream(Data))) as ClassMsg;
                switch (msg.msgCommand)
                {
                case MsgCommand.DBList:
                    //DialogResult = DialogResult.OK;
                    mydics = (MyDictioinary <string, DB_Map>) new ClassSerializers().DeSerializeBinary(new MemoryStream(msg.Data));
                    //渲染数据库资源下拉按钮之前,保存列表字典到全局区
                    //全局变量重构//
                    //PublicValue.mydics = mydics;
                    SuperMessage.mydics = mydics;
                    //数据库列表展开
                    dblist_left.Items.Clear();
                    dblist_right.Items.Clear();
                    foreach (KeyValuePair <string, DB_Map> mydic in mydics.llDictionary)
                    {
                        if (Publec_Class.UserName == mydic.Value.rguser)
                        {
                            continue;
                        }
                        //left
                        if (dblist_left.Text.Trim().Length > 0)
                        {
                            dblist_left.Items.Add(mydic.Key);
                        }
                        else
                        {
                            dblist_left.Items.Add(mydic.Key);
                            dblist_left.Text      = mydic.Key;
                            tb_left_ipaddr.Text   = mydic.Value.ipaddr;
                            tb_left_username.Text = mydic.Value.username;
                            tb_left_password.Text = mydic.Value.password;
                            tb_left_port.Text     = mydic.Value.port.ToString();
                        }
                        //right
                        if (dblist_right.Text.Trim().Length > 0)
                        {
                            dblist_right.Items.Add(mydic.Key);
                        }
                        else
                        {
                            dblist_right.Items.Add(mydic.Key);
                            dblist_right.Text      = mydic.Key;
                            tb_right_ipaddr.Text   = mydic.Value.ipaddr;
                            tb_right_username.Text = mydic.Value.username;
                            tb_right_password.Text = mydic.Value.password;
                            tb_right_port.Text     = mydic.Value.port.ToString();
                        }
                        //Console.WriteLine("数据库列表测试:"+ mydic.Key.ToString() + "\t:" + mydic.Value.ToString());
                    }
                    //PublicValue.dbname = dblist_left.Items[0].ToString();

                    break;

                case MsgCommand.DBCount:    //数据库资源为0
                    //没有数据库资源,不做显示
                    //Console.WriteLine("没有数据库资源列表哦。。");
                    //初始化界面为0应该的样子
                    this.tb_left_ipaddr.Text   = "localhost";
                    this.tb_left_username.Text = "root";
                    this.tb_left_password.Text = "";
                    this.tb_left_port.Text     = "3306";
                    //
                    this.tb_right_ipaddr.Text   = "localhost";
                    this.tb_right_username.Text = "root";
                    this.tb_right_password.Text = "";
                    this.tb_right_port.Text     = "3306";

                    break;
                }
            }
            catch { }
        }