Exemple #1
0
        /// <summary>
        /// 删除
        /// </summary>
        private void dbconn_delete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("   您确定要删除连接细节吗?", "安全提示",
                                System.Windows.Forms.MessageBoxButtons.YesNo,
                                System.Windows.Forms.MessageBoxIcon.Question)
                == System.Windows.Forms.DialogResult.Yes)
            {
                if (getKeyExistsDics(dbconn_comb.Text.Trim()) == null)
                {
                    MessageBox.Show("       请选择一个希望被删除的数据源!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                DB_Map dbconn_delete = new DB_Map(this.dbconn_comb.Text.Trim(), this.dbconn_username.Text.Trim(),
                                                  this.dbconn_password.Text.Trim(), this.dbconn_ipaddr.Text.Trim(), Convert.ToInt32(this.dbconn_port.Text.Trim()), getKeyExistsDics(dbconn_comb.Text.Trim()).property, "否", Publec_Class.UserName);
                byte[]   dbconn_deleteData = new ClassSerializers().SerializeBinary(dbconn_delete).ToArray();
                ClassMsg msg = new ClassMsg();
                msg.sendKind   = SendKind.SendCommand;
                msg.msgCommand = MsgCommand.DBDelete;
                msg.SPort      = this.udpSocket1.LocalPort.ToString();
                msg.SIP        = PubClass.getMacAddr_Local(0);
                msg.Data       = dbconn_deleteData;

                udpSocket1.Send(IPAddress.Parse(PubClass.GetServerIp().Trim()), Convert.ToInt32(PubClass.GetServerPort().Trim()), new ClassSerializers().SerializeBinary(msg).ToArray());
            }
        }
        public MapServer(DB_Map map)
        {
            _port       = Interlocked.Increment(ref _staticPort);
            _map        = map;
            _id         = "########";
            _dialogs    = new DialogsMgr(this);
            _updatables = new List <IUpdatable>();
            _players    = new Dictionary <ushort, MapPlayer>();
            _name       = _map.Name.Normalize(Constants.MaxServerName);
#if DEBUG
            if (!(Debug.Logger is DefaultConsoleLogger))
            {
                Debug.Logger = new DefaultConsoleLogger();
            }
#endif
        }
Exemple #3
0
        /// <summary>
        /// 重命名
        /// </summary>
        private void dbconn_rename_Click(object sender, EventArgs e)
        {
            DB_Map tmp = new DB_Map(this.dbconn_comb.Text.Trim(), this.dbconn_username.Text.Trim(),
                                    this.dbconn_password.Text.Trim(), this.dbconn_ipaddr.Text.Trim(), Convert.ToInt32(this.dbconn_port.Text.Trim()), 0, "否", Publec_Class.UserName);

            create_conn ccn = new create_conn();

            if (ccn.ShowDialog(this) == DialogResult.OK)   //当登窗体的对话框的返回值为OK时
            {
                this.dbconn_comb.Text     = PublicValue.dbname;
                this.dbconn_ipaddr.Text   = tmp.ipaddr;
                this.dbconn_username.Text = tmp.username;
                this.dbconn_password.Text = tmp.password;
                this.dbconn_port.Text     = tmp.port.ToString();
                dbconn_replace_dbname(tmp, PublicValue.dbname);
                init4_views();
            }
        }
Exemple #4
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());
        }
Exemple #5
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());
        }
Exemple #6
0
        public static bool SelectAllMaps(out Dictionary <int, DB_Map> data)
        {
            var locked = false;

            data = new Dictionary <int, DB_Map>();
            if (!IsConnected)
            {
                return(false);
            }
            try
            {
                using (MySqlCommand _cmd = _connection.CreateCommand())
                {
                    _cmd.CommandText = $"SELECT * FROM {tb_03};";
                    Monitor.Enter(_connection, ref locked);
                    using (MySqlDataReader _result = _cmd.ExecuteReader())
                    {
                        int id;
                        if (_result.HasRows)
                        {
                            while (_result.Read())
                            {
                                id       = _result.GetInt32(0);
                                data[id] = new DB_Map(id, _result.GetString(1), _result.GetByte(2));
                            }
                        }
                    }
                }
                return(true);
            }
            catch { return(false); }
            finally { if (locked)
                      {
                          Monitor.Exit(_connection);
                      }
            }
        }
 public static bool Select(int id, out DB_Map entry)
 {
     return(m_maps.TryGetValue(id, out entry));
 }