示例#1
0
        public DBCommandResult AddNewPlayer(Player p)
        {
            DBCommandResult res = new DBCommandResult();

            try
            {
                var players = db.GetCollection<Player>("Players");

                p._id = players.Count(new BsonDocument());

                players.InsertOne(p, new InsertOneOptions { BypassDocumentValidation = false });

                p.IsLoaded = p.IsSaved = true;

                res.Tag = p;
                res.ResultCode = 0;
                res.ResultMsg = "Ok";
            }
            catch (Exception ex)
            {
                res.ResultCode = -2;
                res.ResultMsg = String.Format("{0} ----> {1}", ex.Message, (ex.InnerException != null) ? ex.InnerException.Message : "");
            }
            return res;
        }
示例#2
0
        public DBCommandResult AddNewPlayer(string userName, string password, string email, Player p)
        {
            DBCommandResult res = new DBCommandResult ();

            MySqlCommand com = new MySqlCommand ("ADM_AddPlayer", _dg.Connection);
            com.CommandType = CommandType.StoredProcedure;
            MySqlParameter spUsername = new MySqlParameter("pUserName", userName);
            MySqlParameter spEmail = new MySqlParameter("pEmail", email);
            MySqlParameter spPassword = new MySqlParameter("pPassword", password);
            MySqlParameter spLeaderName = new MySqlParameter("pLeaderName", p.LeaderName);
            MySqlParameter spRace = new MySqlParameter("pRace", p.Race);
            MySqlParameter spMotto = new MySqlParameter("pMotto", p.Motto);
            MySqlParameter spColor = new MySqlParameter("pColor", p.Color);
            com.Parameters.AddRange(new MySqlParameter[] {spUsername, spEmail, spPassword, spLeaderName, spRace, spMotto, spColor});

            try
            {
                DataSet ds = _dg.GetDataSet(com);
                DataRow dr = ds.Tables[0].Rows[0];
                p.OBID = Convert.ToInt32(dr["OBID"]);
                p.LeaderName = Convert.ToString(dr["LeaderName"]);
                p.Race = Convert.ToString(dr["Race"]);
                p.Motto = Convert.ToString(dr["Motto"]);
                p.Color = Convert.ToString(dr["Color"]);

                res = SaveAttributes(p);
            }
            catch (Exception ex) {
                res.ResultCode = -2;
                res.ResultMsg = String.Format ("{0} ----> {1}", ex.Message, (ex.InnerException != null) ? ex.InnerException.Message : "");
            }
            return res;
        }
示例#3
0
        public void Register()
        {
            InitDefaultParameters ();
            DBCommandResult res = _mdh.AddNewPlayer (this.Player);

            if (res.ResultCode == 0) {
                this.Player = (Player)res.Tag;
                this.Player.IsLoaded = this.Player.IsSaved = true;
            } else {
                throw new Exception (res.ResultMsg);
            }
        }
示例#4
0
        public void AuthUser(string userName, string password)
        {
            DBCommandResult res = _mdh.AuthPlayer (userName, password);

            if (res.ResultCode == 0) {
                this.Player = (Player)res.Tag;

                if (this.Player.Attributes.Count == 0)
                    InitDefaultParameters ();
                //ELSE add missing attributes, if any exists.
            } else {
                throw new Exception (res.ResultMsg);
            }
        }
示例#5
0
        public DBCommandResult AuthPlayer(string userName, string password)
        {
            DBCommandResult res = new DBCommandResult ();

            MySqlCommand com = new MySqlCommand ("GM_AuthPlayer", _dg.Connection);
            com.CommandType = CommandType.StoredProcedure;
            MySqlParameter spUsername = new MySqlParameter("pUserName", userName);
            MySqlParameter spPassword = new MySqlParameter("pPassword", password);

            com.Parameters.AddRange(new MySqlParameter[] {spUsername, spPassword});

            try
            {
                DataSet ds = _dg.GetDataSet(com);
                DataRow dr = ds.Tables[0].Rows[0];
                Player p = new Player();
                p.OBID = Convert.ToInt32(dr["OBID"]);
                p.LeaderName = Convert.ToString(dr["LeaderName"]);
                p.Race = Convert.ToString(dr["Race"]);
                p.Motto = Convert.ToString(dr["Motto"]);
                p.Color = Convert.ToString(dr["Color"]);

                p.Attributes = new List<OAttribute>();
                //p.Attributes.ParentObject = p;
                //p.Attributes.Load(LoadAttributes(ds.Tables[1]));

                res.Tag = p;
                res.ResultCode = 0;
                res.ResultMsg = "Ok";
            }
            catch (Exception ex) {
                res.ResultCode = -2;
                res.ResultMsg = String.Format ("{0} ----> {1}", ex.Message, (ex.InnerException != null) ? ex.InnerException.Message : "");
            }
            return res;
        }
示例#6
0
        public OnlinePlayer RegisterNewPlayer(Player p)
        {
            pHelper = new PlayerHelper();

            pHelper.Player = p;
            pHelper.Register();

            return pHelper.Player;
        }
示例#7
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit (e);

            if (Session ["Universe"] != null) {
                this.ActiveUniverse = (Universe)Session ["Universe"];
                this._gid = this.ActiveUniverse.Galaxies [0]._id;
            }

            if (Session ["Player"] != null) {
                this.ActivePlayer = (Player)Session ["Player"];
            }
            if (Request ["gid"] != null && long.TryParse (Request ["gid"], out _gid)) {
            }

            Channel = BackServiceHelper.ConnectToBackService();
            log = new Log.Logger("HOO.WebClient", this.GetType());
        }