Exemple #1
0
        private void HandleLoadGMPUser(uint msgId, string key, MyAction <DSLoadResult, string, IMessage> cb)
        {
            string   error    = null;
            IMessage data     = null;
            Type     dataType = MessageMapping.Query(msgId);

            try {
                uint             userTypeId      = MessageMapping.Query(typeof(DS_UserInfo));
                GMP_User.Builder dataUserBuilder = GMP_User.CreateBuilder();
                DbThreadManager.Instance.LoadActionQueue.QueueAction(() => {
                    DS_UserInfo dataUserBasic = DataLoadImpl.LoadSingleRow(typeof(DS_UserInfo), key) as DS_UserInfo;
                    if (dataUserBasic != null)
                    {
                        dataUserBuilder.SetUserGuid(dataUserBasic.Guid);
                        dataUserBuilder.SetUserBasic(dataUserBasic);
                    }
                    else
                    {
                        error = string.Format("GMServer Load from Database MISS: key:({0}), data({1})", key, dataType.Name);
                        cb(DSLoadResult.NotFound, error, null);
                        LogSys.Log(LOG_TYPE.INFO, error);
                        return;
                    }
                    data = dataUserBuilder.Build();
                    cb(DSLoadResult.Success, null, data);
                    LogSys.Log(LOG_TYPE.DEBUG, "GMServer Load from Database: key:({0}), data({1})", key, dataType.Name);
                });
            } catch (Exception e) {
                error = e.Message;
                cb(DSLoadResult.PostError, error, data);
                LogSys.Log(LOG_TYPE.ERROR, "GMServer Load from Database ERROR: key:{0}, data:{1}, error:{2},stacktrace:{3}",
                           key, dataType.Name, error, e.StackTrace);
                return;
            }
        }
Exemple #2
0
        ///==============================================================================================
        /// 只能在本线程调用的方法。
        ///==============================================================================================
        private void HandleLoadGMPAccount(uint msgId, string key, MyAction <DSLoadResult, string, IMessage> cb)
        {
            string   error    = null;
            IMessage data     = null;
            Type     dataType = MessageMapping.Query(msgId);

            try {
                DbThreadManager.Instance.LoadActionQueue.QueueAction(() => {
                    GMP_Account.Builder dataAccountBuilder = GMP_Account.CreateBuilder();
                    DS_Account dataAccountBasic            = DataLoadImpl.LoadSingleRow(typeof(DS_Account), key) as DS_Account;
                    if (dataAccountBasic != null)
                    {
                        dataAccountBuilder.SetAccount(dataAccountBasic.Account);
                        dataAccountBuilder.SetAccountBasic(dataAccountBasic);
                    }
                    else
                    {
                        error = string.Format("GMServer Load from Database MISS: key:({0}), data({1})", key, dataType.Name);
                        cb(DSLoadResult.NotFound, error, null);
                        LogSys.Log(LOG_TYPE.INFO, error);
                        return;
                    }
                    List <DS_UserInfo> dataUserList = new List <DS_UserInfo>();
                    if (dataAccountBasic.UserGuid1 > 0)
                    {
                        DS_UserInfo dataUser = DataLoadImpl.LoadSingleRow(typeof(DS_UserInfo), dataAccountBasic.UserGuid1.ToString()) as DS_UserInfo;
                        if (dataUser != null)
                        {
                            dataUserList.Add(dataUser);
                        }
                    }
                    if (dataAccountBasic.UserGuid2 > 0)
                    {
                        DS_UserInfo dataUser = DataLoadImpl.LoadSingleRow(typeof(DS_UserInfo), dataAccountBasic.UserGuid2.ToString()) as DS_UserInfo;
                        if (dataUser != null)
                        {
                            dataUserList.Add(dataUser);
                        }
                    }
                    if (dataAccountBasic.UserGuid3 > 0)
                    {
                        DS_UserInfo dataUser = DataLoadImpl.LoadSingleRow(typeof(DS_UserInfo), dataAccountBasic.UserGuid3.ToString()) as DS_UserInfo;
                        if (dataUser != null)
                        {
                            dataUserList.Add(dataUser);
                        }
                    }
                    foreach (var dataUser in dataUserList)
                    {
                        dataAccountBuilder.UserListList.Add(dataUser as DS_UserInfo);
                    }
                    data = dataAccountBuilder.Build();
                    cb(DSLoadResult.Success, null, data);
                    LogSys.Log(LOG_TYPE.DEBUG, "GMServer Load from Database: key:({0}), data({1})", key, dataType.Name);
                });
            } catch (Exception e) {
                error = e.Message;
                cb(DSLoadResult.PostError, error, data);
                LogSys.Log(LOG_TYPE.ERROR, "GMServer Load from Database ERROR: key:({0}), data({1}), error({2})", key, dataType.Name, error);
                return;
            }
        }