private bool db_info_set_target() { if (this.tb_right_ipaddr.Text.Trim() == "" || this.tb_right_username.Text.Trim() == "" || this.tb_right_password.Text.Trim() == "" || this.tb_right_port.Text.Trim() == "") { //MessageBox.Show(" 目标数据库连接信息错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return(false); } if (!Publec_Class.IsNumberic(this.tb_right_port.Text.Trim())) { MessageBox.Show("端口只能为正整数!"); return(false); } // 数据源信息 this.dbtarget.DbHost = this.tb_right_ipaddr.Text.Trim(); this.dbtarget.DbUser = this.tb_right_username.Text.Trim(); this.dbtarget.DbPassword = this.tb_right_password.Text.Trim(); this.dbtarget.DbPort = Convert.ToInt32(this.tb_right_port.Text.Trim()); //this.dbtarget.Dbname = this.dbname_right.Text.Trim(); // // 目标数据库信息 url_target_mysql.DbHost = this.dbtarget.DbHost; url_target_mysql.DbUser = this.dbtarget.DbUser; url_target_mysql.DbPassword = this.dbtarget.DbPassword; url_target_mysql.DbPort = this.dbtarget.DbPort; //url_target_mysql.Dbname = this.dbtarget.Dbname; return(true); }
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()); }
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()); }
private void button_regist_click_Click(object sender, EventArgs e) { if (text_regist_password.Text.Length < 6) { MessageBox.Show(" 密码太短!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (!Publec_Class.IsMail(text_regist_mail.Text.Trim())) { MessageBox.Show(" 邮箱不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (!Publec_Class.IsPhone(text_regist_phone.Text.Trim())) { MessageBox.Show(" 电话号不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if ((text_regist_password.Text.Trim()).Length == 0) { MessageBox.Show(" 用户密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { if (text_regist_password.Text.Trim() == text_regist_ack_password.Text.Trim()) //当密码输入相同 { RegisterMsg registermsg = new RegisterMsg(); registermsg.UserName = text_regist_name.Text; registermsg.PassWord = text_regist_password.Text; registermsg.phone = text_regist_phone.Text.Trim(); registermsg.mail = text_regist_mail.Text.Trim(); registermsg.MacAddr = PubClass.getMacAddr_Local(1).Trim(); byte[] registerData = new ClassSerializers().SerializeBinary(registermsg).ToArray(); ClassMsg msg = new ClassMsg(); msg.sendKind = SendKind.SendCommand; msg.msgCommand = MsgCommand.Registering; msg.SPort = this.udpSocket1.LocalPort.ToString(); msg.SIP = PubClass.getMacAddr_Local(0); msg.Data = registerData; msg.Suser = text_regist_name.Text; serID = PubClass.GetServerIp().Trim(); udpSocket1.Send(IPAddress.Parse(serID), Convert.ToInt32(PubClass.GetServerPort().Trim()), new ClassSerializers().SerializeBinary(msg).ToArray()); } else { text_regist_password.Text = ""; text_regist_ack_password.Text = ""; MessageBox.Show(" 输入的密码不匹配,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } }
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()); }
private void DataArrival(byte[] Data, IPAddress Ip, int Port) //当有数据到达后的处理进程 { Publec_Class Pub_class = new Publec_Class(); try { ClassMsg msg = new ClassSerializers().DeSerializeBinary((new System.IO.MemoryStream(Data))) as ClassMsg; switch (msg.msgCommand) { case MsgCommand.Logined: //登录成功 Publec_Class.UserID = msg.SID; Publec_Class.Fraction = msg.Fraction; Publec_Class.UserSex = msg.Sex; Publec_Class.ClientIP = Pub_class.MyHostIP(); //获取当前计算机的IP地址 DialogResult = DialogResult.OK; udpSocket1.Active = false; this.Close(); break; } } catch { } }
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()); }
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; }