Ejemplo n.º 1
0
        private bool DB_CreateMail(CSCommon.Data.MailData mail)
        {
            string condition = "MailId = " + mail.MailId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.InsertData(condition, mail, true);
            return(mDBConnect._ExecuteInsert(dbOp));
        }
Ejemplo n.º 2
0
        private void DB_RoleEnteInitMessages(UserRole role)//只有登录的时候调用
        {
            string condition = "OwnerId=" + role.RoleData.RoleId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, new CSCommon.Data.Message(), "");
            System.Data.DataTable     tab  = mDBConnect._ExecuteSelect(dbOp, "Message");
            if (tab != null)
            {
                foreach (System.Data.DataRow r in tab.Rows)
                {
                    CSCommon.Data.Message msg = new CSCommon.Data.Message();
                    if (false == ServerFrame.DB.DBConnect.FillObject(msg, r))
                    {
                        continue;
                    }
                    DB_DelMessage(msg);
                    //发送消息
                    RPC.PackageWriter pkg = new RPC.PackageWriter();
                    H_RPCRoot.smInstance.HGet_PlanesServer(pkg).RPC_SendPlayerMsg(pkg, role.RoleData.RoleId, msg);
                    pkg.DoCommand(role.PlanesConnect, RPC.CommandTargetType.DefaultType);
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("角色获取信息数据库执行失败:" + dbOp.SqlCode);
            }
        }
Ejemplo n.º 3
0
        private void DB_SaveGiftData(UserRole role)
        {
            string condition = "OtherId = " + role.RoleData.RoleId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.ReplaceData(condition, role.GiftData, true);
            mDBConnect._ExecuteInsert(dbOp);
        }
Ejemplo n.º 4
0
        public bool DB_CreateGird(CSCommon.Data.ConsignGridData data)
        {
            string condition = "GirdId = " + data.GirdId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.InsertData(condition, data, true);
            return(mDBConnect._ExecuteInsert(dbOp));
        }
Ejemplo n.º 5
0
        private bool DB_DelMail(ulong mailId)
        {
            string condition = "MailId = " + mailId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.DelData(condition, new CSCommon.Data.MailData());
            return(mDBConnect._ExecuteDelete(dbOp));
        }
Ejemplo n.º 6
0
        private void DB_SaveSocials(UserRole role)
        {
            var items = role.SocialManager.SaveSocialList();

            foreach (var i in items)
            {
                CSCommon.Data.SocialData outItem = null;
                foreach (var j in role.Socials)
                {
                    if (j.OtherId == i.OtherId)
                    {
                        outItem = j;
                        break;
                    }
                }
                if (outItem != null)
                {
                    string condition = "OtherId = " + i.OtherId;
                    ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.UpdateData(condition, i, outItem);
                    mDBConnect._ExecuteUpdate(dbOp);
                }
                else
                {
                    string condition = "OtherId = " + i.OtherId;
                    ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.ReplaceData(condition, i, true);
                    mDBConnect._ExecuteInsert(dbOp);
                }
            }
            role.Socials = items;
        }
Ejemplo n.º 7
0
        private void DB_InitSocial(UserRole role)
        {
            string condition = "OwnerId=" + role.RoleData.RoleId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, new CSCommon.Data.SocialData(), "");
            System.Data.DataTable     tab  = mDBConnect._ExecuteSelect(dbOp, "SocialData");
            if (tab != null)
            {
                List <CSCommon.Data.SocialData> items = new List <CSCommon.Data.SocialData>();

                foreach (System.Data.DataRow r in tab.Rows)
                {
                    CSCommon.Data.SocialData itemData = new CSCommon.Data.SocialData();
                    if (false == ServerFrame.DB.DBConnect.FillObject(itemData, r))
                    {
                        continue;
                    }
                    items.Add(itemData);
                }
                role.Socials.Clear();
                role.Socials.AddRange(items);
                role.SocialManager.InitSocialList(role);
                items.Clear();
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("角色获取关系数据库执行失败:" + dbOp.SqlCode);
            }
        }
Ejemplo n.º 8
0
        public void Init(PlanesData[] planedatas)
        {
            foreach (var p in planedatas)
            {
                string condition = "PlaneId=" + p.PlanesId;
                ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, new CityData(), "");
                System.Data.DataTable     tab  = UserRoleManager.Instance.DBConnect._ExecuteSelect(dbOp, "CityData");
                if (tab != null)
                {
                    List <CityData> citys = new List <CityData>();
                    foreach (System.Data.DataRow r in tab.Rows)
                    {
                        CSCommon.Data.CityData city = new CSCommon.Data.CityData();
                        if (false == ServerFrame.DB.DBConnect.FillObject(city, r))
                        {
                            continue;
                        }
                        citys.Add(city);
                    }

                    var world = new World();
                    world.Init(p.PlanesId, citys);
                    mWorlds[p.PlanesId] = world;
                }
                else
                {
                    Log.Log.Mail.Print("WorldManager init PlanesData failed :{0}", condition);
                }
            }
        }
Ejemplo n.º 9
0
        private bool DB_DelMails(ulong roleId)
        {
            string condition = "OwnerId=" + roleId + " and StrItems = " + "\'" + "\'" + " and StrCurrencies = " + "\'" + "\'";

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.DelData(condition, new CSCommon.Data.MailData());
            return(mDBConnect._ExecuteDelete(dbOp));
        }
Ejemplo n.º 10
0
        private bool DB_CreateMessage(CSCommon.Data.Message message)
        {
            string condition = "MessageId = " + message.MessageId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.InsertData(condition, message, true);
            return(mDBConnect._ExecuteInsert(dbOp));
        }
Ejemplo n.º 11
0
        private void DB_DelMessage(CSCommon.Data.Message message)
        {
            string condition = "MessageId =" + message.MessageId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.DestroyData(condition, message);
            mDBConnect._ExecuteDestroy(dbOp);
            return;
        }
Ejemplo n.º 12
0
        private void DB_UpdateMail(CSCommon.Data.MailData mail)
        {
            string condition = "MailId = " + mail.MailId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.ReplaceData(condition, mail, true);
            mDBConnect._ExecuteInsert(dbOp);
            return;
        }
Ejemplo n.º 13
0
        public void DB_DelGird(CSCommon.Data.ConsignGridData data)
        {
            string condition = "GirdId =" + data.GirdId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.DestroyData(condition, data);
            mDBConnect._ExecuteDestroy(dbOp);
            return;
        }
Ejemplo n.º 14
0
        private bool DB_CreatGuildCom(CSCommon.Data.GuildCom Guild)
        {
            // 产生insert语句
            string condition = "GuildId = " + Guild.GuildId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.InsertData(condition, Guild, true);
            return(mDBConnect._ExecuteInsert(dbOp));
        }
Ejemplo n.º 15
0
        public void DB_DelGuildCom(CSCommon.Data.GuildCom Guild)
        {
            //产生Destroy语句
            string condition = "GuildId =" + Guild.GuildId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.DestroyData(condition, Guild);
            mDBConnect._ExecuteDestroy(dbOp);
            return;
        }
Ejemplo n.º 16
0
        private CSCommon.Data.MailData DB_GetMail(ulong mailId)
        {
            string condition = "MailId = " + mailId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, new CSCommon.Data.MailData(), "");
            System.Data.DataTable     tab  = mDBConnect._ExecuteSelect(dbOp, "MailData");
            if (tab == null || tab.Rows.Count != 1)
            {
                return(null);
            }
            CSCommon.Data.MailData mail = new CSCommon.Data.MailData();
            if (false == ServerFrame.DB.DBConnect.FillObject(mail, tab.Rows[0]))
            {
                return(null);
            }
            return(mail);
        }
Ejemplo n.º 17
0
//         public void CreatePlanesData(byte level,string name,byte state)
//         {
//             CSCommon.Data.PlanesData pd = new CSCommon.Data.PlanesData();
//             pd.PlanesId = ServerFrame.Util.GenerateObjID(ServerFrame.GameObjectType.Server);
//             pd.PlanesName = name;
//             pd.CreateTime = System.DateTime.Now;
//             pd.ActiveState = state;
//
//             mPlanes.Add(pd.PlanesId, pd);
//
//             string condition = "PlanesName=\'" + name + "\'";
//             ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.ReplaceData(condition, pd, true);
//             mDataServer.DBLoaderConnect._ExecuteInsert(dbOp);
//         }

        CSCommon.Data.PlanesData LoadPlanesFromDB(string planesName)
        {
            string condition = "ActiveState>0 && PlanesName = \'" + planesName + "\'";

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, new CSCommon.Data.PlanesData(), "");
            System.Data.DataTable     tab  = mDataServer.DBLoaderConnect._ExecuteSelect(dbOp, "CSCommon.Data.PlanesData");
            if (tab == null || tab.Rows.Count != 1)
            {
                return(null);
            }

            CSCommon.Data.PlanesData pd = new CSCommon.Data.PlanesData();
            if (false == ServerFrame.DB.DBConnect.FillObject(pd, tab.Rows[0]))
            {
                return(pd);
            }
            return(null);
        }
Ejemplo n.º 18
0
        private void DB_InitGiftData(UserRole role)
        {
            string condition = "OwnerId=" + role.RoleData.RoleId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, new CSCommon.Data.GiftData(), "");
            System.Data.DataTable     tab  = mDBConnect._ExecuteSelect(dbOp, "GiftData");
            if (tab != null && tab.Rows.Count == 1)
            {
                CSCommon.Data.GiftData gd = new CSCommon.Data.GiftData();
                if (ServerFrame.DB.DBConnect.FillObject(gd, tab.Rows[0]))
                {
                    role.GiftData = gd;
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("角色获取礼物数据库执行失败:" + dbOp.SqlCode);
            }
        }
Ejemplo n.º 19
0
 //加载数据库中的相关静态配置信息
 public static void LoadDbConfig(ServerFrame.DB.DBConnect dbConnect)
 {
     ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData("", new CSCommon.Data.CPlanesConfig(), "");
     System.Data.DataTable     tab  = dbConnect._ExecuteSelect(dbOp, "planesconfig");
     if (tab != null)
     {
         foreach (System.Data.DataRow r in tab.Rows)
         {
             CSCommon.Data.CPlanesConfig lPlanesConfig = new CSCommon.Data.CPlanesConfig();
             if (false == ServerFrame.DB.DBConnect.FillObject(lPlanesConfig, r))
             {
                 continue;
             }
             m_PlanesConfig[lPlanesConfig.PlanesServerId] = lPlanesConfig;
         }
     }
     else
     {
         System.Diagnostics.Debug.WriteLine("加载位面管理地图信息失败:" + dbOp.SqlCode);
     }
 }
Ejemplo n.º 20
0
        public CSCommon.Data.ConsignGridData GetGird(ulong id)
        {
            CSCommon.Data.ConsignGridData gird = new CSCommon.Data.ConsignGridData();
            string condition = "GirdId =" + id;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, gird, "");
            System.Data.DataTable     tab  = mDBConnect._ExecuteSelect(dbOp, "ConsignGirdData");
            if (tab != null && tab.Rows.Count == 1)
            {
                if (false == ServerFrame.DB.DBConnect.FillObject(gird, tab.Rows[0]))
                {
                    return(null);
                }
                return(gird);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("GetGird failed:{0}" + id);
                return(null);
            }
        }
Ejemplo n.º 21
0
 void Tick()
 {
     if (mLogQueue.Count > 0)
     {
         ServerFrame.DB.DBLogData atom = null;
         lock (this)
         {
             atom = mLogQueue.Dequeue();
         }
         try
         {
             string condition = "LogId = " + ServerFrame.DB.DBConnect.Guid2SqlString(atom.LogId);
             ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.ReplaceData(condition, atom, false);
             mDBConnect._ExecuteInsert(dbOp);
         }
         catch (System.Exception ex)
         {
             Log.Log.Common.Print(ex.ToString());
             Log.Log.Common.Print(ex.StackTrace.ToString());
         }
     }
 }
Ejemplo n.º 22
0
        public PlanesMgr(IDataServer server)
        {
            mDataServer = server;
            //加载所有活跃位面
            string condition = "ActiveState>0";

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, new CSCommon.Data.PlanesData(), "");
            System.Data.DataTable     tab  = mDataServer.DBLoaderConnect._ExecuteSelect(dbOp, "CSCommon.Data.PlanesData");
            if (tab == null)
            {
                return;
            }

            foreach (System.Data.DataRow r in tab.Rows)
            {
                CSCommon.Data.PlanesData pd = new CSCommon.Data.PlanesData();
                if (false == ServerFrame.DB.DBConnect.FillObject(pd, r))
                {
                    continue;
                }
                mPlanes.Add(pd.PlanesId, pd);
            }
        }
Ejemplo n.º 23
0
        public RankData DB_LoadRankData(UserRole role)
        {
            RankData rd = new RankData();

            rd.RoleId      = role.RoleData.RoleId;
            rd.PlanesId    = role.RoleData.PlanesId;
            rd.RoleName    = role.RoleData.Name;
            rd.Level       = role.RoleData.Level;
            rd.Fighting    = 0;
            rd.Exploit     = 0;
            rd.ExploitRank = 0;

            string condition = "RoleId=" + rd.RoleId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.InsertData(condition, rd, false);
            if (false == mDBConnect._ExecuteInsert(dbOp))
            {
                Log.Log.Common.Print("create RankData failed");
                return(null);
            }

            return(rd);
        }
Ejemplo n.º 24
0
        private List <CSCommon.Data.MailData> DB_GetMails(string condition)
        {
            List <CSCommon.Data.MailData> mails = new List <CSCommon.Data.MailData>();

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, new CSCommon.Data.MailData(), "");
            System.Data.DataTable     tab  = mDBConnect._ExecuteSelect(dbOp, "MailData");
            if (tab != null)
            {
                foreach (System.Data.DataRow r in tab.Rows)
                {
                    CSCommon.Data.MailData mail = new CSCommon.Data.MailData();
                    if (false == ServerFrame.DB.DBConnect.FillObject(mail, r))
                    {
                        continue;
                    }
                    mails.Add(mail);
                }
            }
            else
            {
                Log.Log.Mail.Print("RPC_GetRoleMails failed :{0}", condition);
            }
            return(mails);
        }
Ejemplo n.º 25
0
        public void DB_InitAllGuildMember(GuildInstance guild)
        {
            ServerFrame.DB.DBOperator dbOp = new ServerFrame.DB.DBOperator();
            dbOp.SqlCode = "select RoleId from RoleCom where GuildId=\'" + guild.GuildData.GuildId + "\'";
            var tab = UserRoleManager.Instance.DBConnect._ExecuteSelect(dbOp, "RoleCom");

            if (tab == null || tab.Rows.Count < 1)
            {
                return;
            }

            for (int i = 0; i < tab.Rows.Count; i++)
            {
                ulong roleId = (ulong)tab.Rows[i]["RoleId"];
                if (roleId != 0)
                {
                    var role = UserRoleManager.Instance.GetRole(roleId);
                    if (role != null)
                    {
                        guild.Members.Add(roleId, role);
                    }
                }
            }
        }
Ejemplo n.º 26
0
//         private void DB_CreatStranger(CSCommon.Data.StrangerInfo stranger)
//         {
//             // 产生insert语句
//             string condition = "EnemyerId = " + stranger.StrangerId;
//             ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.InsertData(condition, stranger, true);
//             mDBConnect._ExecuteInsert(dbOp);
//             return;
//         }
//
//         private void DB_SaveStranger(CSCommon.Data.StrangerInfo stranger)
//         {
//             var condition = "EnemyerId=\'" + (stranger.StrangerId);
//             var dbOp = ServerFrame.DB.DBConnect.UpdateData(condition, stranger, null);
//             mDBConnect._ExecuteUpdate(dbOp);
//             return;
//         }
//
//         private void DB_DelStranger(CSCommon.Data.StrangerInfo stranger)
//         {
//             //产生Destroy语句
//             string condition = "EnemyerId =" + stranger.StrangerId;
//             ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.DestroyData(condition, stranger);
//             mDBConnect._ExecuteDestroy(dbOp);
//             return;
//         }

        #endregion

        #region 创建加载角色

        public UserRole TryCreatePlaye(CSCommon.Data.RoleDetail pd)
        {
            UserRole role = new UserRole();

            role.RoleData.RoleId     = pd.RoleId;
            role.RoleData.Name       = pd.RoleName;
            role.RoleData.Sex        = pd.Sex;
            role.RoleData.Level      = pd.RoleLevel;  //change
            role.RoleData.Camp       = pd.Camp;       //change
            role.RoleData.Profession = pd.Profession; //change
            role.RoleData.PlanesId   = pd.PlanesId;   //change
            role.RoleData.MapName    = pd.MapName;

            string condition = "RoleId=" + pd.RoleId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.InsertData(condition, role.RoleData, false);
            if (false == mDBConnect._ExecuteInsert(dbOp))
            {
                Log.Log.Common.Print("create rolecom failed");
                return(null);
            }

            mRoles.Add(pd.RoleId, role);

            RankData rd = new RankData();

            rd.RoleId      = pd.RoleId;
            rd.PlanesId    = pd.PlanesId;
            rd.RoleName    = pd.RoleName;
            rd.Level       = pd.RoleLevel;
            rd.Fighting    = 0;
            rd.Exploit     = 0;
            rd.ExploitRank = 0;
            UPdateRankData(rd);
            return(role);
        }