Esempio n. 1
0
        private void button_login_click_Click(object sender, EventArgs e)
        {
            //输入参数处理
            if ((text_login_passwd.Text.Trim()).Length == 0)
            {
                MessageBox.Show("       用户密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return;
            }
            if (text_login_passwd.Text.Length < 6)
            {
                MessageBox.Show("       密码太短!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return;
            }

            //传送参数到后台校验
            RegisterMsg registermsg = new RegisterMsg();

            registermsg.UserName = text_login_name.Text.Trim();
            registermsg.PassWord = text_login_passwd.Text.Trim();
            byte[]   registerData = new ClassSerializers().SerializeBinary(registermsg).ToArray();
            ClassMsg msg          = new ClassMsg();

            msg.sendKind   = SendKind.SendCommand;
            msg.msgCommand = MsgCommand.Logining;
            msg.SPort      = this.udpSocket1.LocalPort.ToString();
            msg.SIP        = PubClass.getMacAddr_Local(0);
            msg.Data       = registerData;
            udpSocket1.Send(IPAddress.Parse(Publec_Class.ServerIP), Convert.ToInt32(Publec_Class.ServerPort), new ClassSerializers().SerializeBinary(msg).ToArray());
            Publec_Class.UserName = text_login_name.Text;
        }
Esempio n. 2
0
        private void getprivileges_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("       当前选择了:"+ dataGridView1_house.Rows[dataGridView1_house.CurrentRow.Index].Cells[0].Value , "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return;
            if (dataGridView1_house.Rows[dataGridView1_house.CurrentRow.Index].Cells[0].Value == null)
            {
                MessageBox.Show("       不能选择空行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
            }
            PrivigesMsg pvMsg = new PrivigesMsg();

            pvMsg.UserName = Publec_Class.UserName;
            pvMsg.cover    = dataGridView1_house.Rows[dataGridView1_house.CurrentRow.Index].Cells[0].Value.ToString().Replace("(公司)", "");
            Publec_Class pc = new Publec_Class();

            byte[]   pvMsgData = new ClassSerializers().SerializeBinary(pvMsg).ToArray();
            ClassMsg msg       = new ClassMsg();

            msg.sendKind   = SendKind.SendCommand;
            msg.msgCommand = MsgCommand.DBPRIV;
            msg.SIP        = pc.getMacAddr_Local(0);
            msg.SPort      = this.udpSocket1.LocalPort.ToString();
            msg.Data       = pvMsgData;
            //打开socket,后台通信
            udpSocket1.Active = true;

            udpSocket1.Send(IPAddress.Parse(Publec_Class.ServerIP), Convert.ToInt32(Publec_Class.ServerPort), new ClassSerializers().SerializeBinary(msg).ToArray());
        }
Esempio n. 3
0
        /// <summary>
        /// 保存
        /// </summary>
        private void dbconn_save_Click(object sender, EventArgs e)
        {
            Int32  pro_tmp    = 1;
            DB_Map db_pro_tmp = null;

            //全局变量重构//
            //if (PublicValue.mydics.llDictionary.Count > 0)
            if (SuperMessage.mydics.llDictionary.Count > 0)
            {
                if (PublicValue.old_dbname != null)
                {
                    db_pro_tmp             = getKeyExistsDics(PublicValue.old_dbname);
                    PublicValue.old_dbname = "";
                }
                else
                {
                    db_pro_tmp = getKeyExistsDics(dbconn_comb.Text.Trim());
                }
                if (db_pro_tmp == null)
                {
                    pro_tmp = 0;
                }
                else
                {
                    pro_tmp = 0;
                    //bug  ing
                    //MessageBox.Show("       名字冲突,请重新填写一个连接名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //return;
                }
            }
            DB_Map dbconn_save = new DB_Map(dbconn_comb.Text.Trim(), dbconn_username.Text.Trim(), dbconn_password.Text.Trim(),
                                            dbconn_ipaddr.Text.Trim(), Convert.ToInt32(dbconn_port.Text.Trim()), pro_tmp, "否", Publec_Class.UserName);

            byte[]   dbconn_saveData = new ClassSerializers().SerializeBinary(dbconn_save).ToArray();
            ClassMsg msg             = new ClassMsg();

            msg.sendKind   = SendKind.SendCommand;
            msg.msgCommand = MsgCommand.DBSave;
            msg.SPort      = this.udpSocket1.LocalPort.ToString();
            msg.SIP        = PubClass.getMacAddr_Local(0);
            msg.Data       = dbconn_saveData;

            udpSocket1.Send(IPAddress.Parse(PubClass.GetServerIp().Trim()), Convert.ToInt32(PubClass.GetServerPort().Trim()), new ClassSerializers().SerializeBinary(msg).ToArray());
        }
Esempio n. 4
0
        //处理socket接收的数据(且反序列化解码)
        private void DataArrival(byte[] Data, IPAddress Ip, int Port) //当有数据到达后的主要逻辑处理函数(的进程)
        {
            try
            {
                ClassMsg msg = new ClassSerializers().DeSerializeBinary((new System.IO.MemoryStream(Data))) as ClassMsg;

                switch (msg.msgCommand)
                {
                case MsgCommand.Registered:    //注册成功
                    DialogResult = DialogResult.OK;
                    WritePrivateProfileString("MyDTS", "UID", serID, PubClass.Get_windows() + "\\Server.ini");
                    WritePrivateProfileString("MyDTS", "Port", PubClass.GetServerPort().Trim(), PubClass.Get_windows() + "\\Server.ini");
                    WritePrivateProfileString("MyDTS", "Name", text_regist_name.Text.Trim(), PubClass.Get_windows() + "\\Server.ini");
                    WritePrivateProfileString("MyDTS-Client", "C-UID", PubClass.getMacAddr_Local(0).Trim(), PubClass.Get_windows() + "\\Server.ini");
                    WritePrivateProfileString("MyDTS-Client", "C-Port", this.udpSocket1.LocalPort.ToString(), PubClass.Get_windows() + "\\Server.ini");
                    WritePrivateProfileString("MyDTS-Client", "C-MacAddr", PubClass.getMacAddr_Local(1).Trim(), PubClass.Get_windows() + "\\Server.ini");

                    break;
                }
            }
            catch { }
        }
Esempio n. 5
0
        private void DBH_init_dblist()
        {
            Publec_Class pc  = new Publec_Class();
            ClassMsg     msg = new ClassMsg();

            msg.sendKind   = SendKind.SendCommand;
            msg.msgCommand = MsgCommand.DBList;
            msg.SIP        = pc.getMacAddr_Local(0);
            msg.SPort      = this.udpSocket1.LocalPort.ToString();
            msg.Suser      = Publec_Class.UserName;
            //打开socket,后台通信
            udpSocket1.Active = true;

            udpSocket1.Send(IPAddress.Parse(Publec_Class.ServerIP), Convert.ToInt32(Publec_Class.ServerPort), new ClassSerializers().SerializeBinary(msg).ToArray());
        }
Esempio n. 6
0
        private void init_dblist()
        {
            Publec_Class pc          = new Publec_Class();
            RegisterMsg  registermsg = new RegisterMsg();

            registermsg.name = this.dbconn_comb.Text.Trim();
            byte[]   registerData = new ClassSerializers().SerializeBinary(registermsg).ToArray();
            ClassMsg msg          = new ClassMsg();

            msg.sendKind   = SendKind.SendCommand;
            msg.msgCommand = MsgCommand.DBList;
            msg.SIP        = pc.getMacAddr_Local(0);
            msg.SPort      = this.udpSocket1.LocalPort.ToString();
            msg.Data       = registerData;
            msg.Suser      = Publec_Class.UserName;
            //打开socket,后台通信
            udpSocket1.Active = true;

            udpSocket1.Send(IPAddress.Parse(Publec_Class.ServerIP), Convert.ToInt32(Publec_Class.ServerPort), new ClassSerializers().SerializeBinary(msg).ToArray());
        }
Esempio n. 7
0
        private void dbconn_replace_dbname(DB_Map tmp, string dbname)
        {
            Publec_Class pc        = new Publec_Class();
            DB_Map       renamemsg = new DB_Map(dbname, tmp.username, tmp.password, tmp.ipaddr, tmp.port, tmp.property, "否", Publec_Class.UserName);

            byte[]   renamemsgData = new ClassSerializers().SerializeBinary(renamemsg).ToArray();
            ClassMsg msg           = new ClassMsg();

            msg.sendKind   = SendKind.SendCommand;
            msg.msgCommand = MsgCommand.DBRename;
            msg.oldname    = tmp.name;
            msg.SIP        = pc.getMacAddr_Local(0);
            msg.SPort      = this.udpSocket1.LocalPort.ToString();
            msg.Data       = renamemsgData;

            //打开socket,后台通信
            if (!udpSocket1.Active)
            {
                udpSocket1.Active = true;
            }

            udpSocket1.Send(IPAddress.Parse(Publec_Class.ServerIP), Convert.ToInt32(Publec_Class.ServerPort), new ClassSerializers().SerializeBinary(msg).ToArray());
        }
Esempio n. 8
0
        private void start_task()
        {
            //判断任务列表是否重复
            foreach (KeyValuePair <string, DB_Task> mytask in SuperMessage.mytasks.llDictionary)
            {
                if (mytask.Value.TaskName == this.tb_taskname.Text.Trim())
                {
                    MessageBox.Show("       " + this.tb_taskname.Text.Trim() + " 任务名称重复,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            Publec_Class pc  = new Publec_Class();
            ClassMsg     msg = new ClassMsg();

            msg.sendKind   = SendKind.SendCommand;
            msg.msgCommand = MsgCommand.DBPStart;
            msg.SIP        = pc.getMacAddr_Local(0);
            msg.SPort      = this.udpSocket1.LocalPort.ToString();
            //        public DB_Task(string TaskName, string SIp, int SPort, string SUser, string TIp, int TPort,string TUser, int TaskProcess)
            DB_Task task = new DB_Task(
                this.tb_taskname.Text.Trim(),
                this.tb_left_ipaddr.Text.Trim(),
                Convert.ToInt32(this.tb_left_port.Text.Trim()),
                this.tb_left_username.Text.Trim(),
                this.tb_right_ipaddr.Text.Trim(),
                Convert.ToInt32(this.tb_right_port.Text.Trim()),
                this.tb_right_username.Text.Trim(),
                Convert.ToInt32((int)MsgCommand.DBPStart));

            byte[] taskData = new ClassSerializers().SerializeBinary(task).ToArray();
            msg.Data = taskData;
            //打开socket,后台通信
            if (!udpSocket1.Active)
            {
                udpSocket1.Active = true;
            }
            udpSocket1.Send(IPAddress.Parse(Publec_Class.ServerIP), Convert.ToInt32(Publec_Class.ServerPort), new ClassSerializers().SerializeBinary(msg).ToArray());
            //SuperMessage.mytasks.Add(this.tb_taskname.Text.Trim(), task);
            string list_tables = tableFunction();

            if (list_tables == "")
            {
                MessageBox.Show("       数据源没有表需要同步!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Hide();
            if (sync_type == "all")
            {
                WinExec(System.Environment.CurrentDirectory + "\\" + "slave.exe" +
                        " --my_addr " + task.SIp + ":" + task.SPort +
                        " --my_user " + task.SUser +
                        " --my_password " + this.tb_left_password.Text.Trim() +
                        " --my_database " + this.dbname_left.Text.Trim() +
                        " --my_taddr " + task.TIp + ":" + task.TPort +
                        " --my_tuser " + task.TUser +
                        " --my_tpassword " + this.tb_right_password.Text.Trim() +
                        " --my_tdatabase " + this.dbname_right.Text.Trim() + " " +
                        list_tables
                        , 0);

                /*
                 * string ProcessName = "explorer";//这里换成你需要删除的进程名称
                 * Process[] MyProcess1 = Process.
                 * GetProcessesByName(ProcessName);
                 * Process MyProcess = new Process();
                 * //设定程序名
                 * MyProcess.StartInfo.FileName = "cmd.exe";
                 * //关闭Shell的使用
                 * MyProcess.StartInfo.UseShellExecute = false;
                 * //重定向标准输入
                 * MyProcess.StartInfo.RedirectStandardInput = true;
                 * //重定向标准输出
                 * MyProcess.StartInfo.RedirectStandardOutput = true;
                 * //重定向错误输出
                 * MyProcess.StartInfo.RedirectStandardError = true;
                 * //设置不显示窗口
                 * MyProcess.StartInfo.CreateNoWindow = true;
                 * //执行强制结束命令
                 * MyProcess.Start();
                 * MyProcess.StandardInput.WriteLine("ntsd -c q -p "
                 + (MyProcess1[0].Id).ToString());//直接结束进程ID
                 + MyProcess.StandardInput.WriteLine("Exit");
                 + 第二种,通过强大的进程类进行标准关闭。
                 + string ProcessName = "explorer";//换成想要结束的进程名字
                 + Process[] MyProcess = Process.
                 + GetProcessesByName(ProcessName);
                 + MyProcess[0].Kill();
                 */
            }
            if (sync_type == "once")
            {
            }
            if (sync_type == "sql")
            {
                if (!Sql_tableFunction())
                {
                    MessageBox.Show("       同步失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            DialogResult = DialogResult.OK;
        }