예제 #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;
            }
        }
예제 #2
0
 public DS_UserInfo GetUserInfo(int userId)
 {
     string SQL_READ_USERINFO = "select * from userInfo where userId=@userId";
     DS_UserInfo ds = new DS_UserInfo();
     SqlParameter[] para = {
         new SqlParameter("@userId", userId)
     };
     m_dao.FillDataSet(ds, "UserInfoTbl", SQL_READ_USERINFO, para);
     return ds;
 }
예제 #3
0
 ///=====================================================================================================
 /// tool
 ///=====================================================================================================
 private ArkCrossEngineMessage.UserBaseData UserInfoBuilder(DS_UserInfo user)
 {
     if (null == user)
     {
         return(null);
     }
     ArkCrossEngineMessage.UserBaseData result = new ArkCrossEngineMessage.UserBaseData();
     result.m_Guid           = (ulong)user.Guid;
     result.m_Account        = user.AccountId;
     result.m_LogicServerId  = 1;
     result.m_Nickname       = user.Nickname;
     result.m_HeroId         = user.HeroId;
     result.m_Level          = user.Level;
     result.m_Vip            = user.Vip;
     result.m_Money          = user.Money;
     result.m_Gold           = user.Gold;
     result.m_LastLogoutTime = user.LastLogoutTime.ToString();
     return(result);
 }
예제 #4
0
 ///=====================================================================================================
 /// 这里定义供其它线程通过QueueAction调用的函数,实际执行线程是GmServerThread。
 ///=====================================================================================================
 internal void GMPQueryUser(ulong userGuid, ulong targetGuid, int handle)
 {
     if (true == m_GmSeverAvailable)
     {
         GMPQueryUser(targetGuid, (GMPLoadUserCB)((ret, data) =>
         {
             JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.GmQueryInfoByGuidOrNickname);
             resultMsg.m_Guid = userGuid;
             ArkCrossEngineMessage.Msg_LC_GmQueryInfoByGuidOrNickname protoData = new ArkCrossEngineMessage.Msg_LC_GmQueryInfoByGuidOrNickname();
             protoData.m_Result = 1;
             if (ret == DSLoadResult.Success)
             {
                 DS_UserInfo dataUser = data.UserBasic;
                 protoData.m_Info = UserInfoBuilder(dataUser);
                 protoData.m_Result = (int)ret;
                 resultMsg.m_ProtoData = protoData;
             }
             JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
         }));
     }
 }
예제 #5
0
        private void LoadUserInfoCallback(string error, DS_UserInfo data, long guid)
        {
            var data_scdr = LobbyServer.Instance.DataProcessScheduler;

            if (null != error)
            {
                Next("End", GetType().Name, error);
            }
            else
            {
                LogSys.Log(LOG_TYPE.INFO, "Load {0} data success: {1}", guid, data.Account);
                UserInfo user = data_scdr.NewUserInfo();
                user.BillingPlayer = billing_player_;
                user.Guid          = (ulong)data.Guid;
                user.Account       = data.Account;
                user.Nickname      = data.Nickname;
                user.Level         = data.Level;
                user.ExpPoints     = data.Exp;
                user.Gold          = data.Gold;
                user.NodeName      = NodeName;
                user.LeftLife      = UserInfo.LifeTimeOfNoHeartbeat;
                data_scdr.DoUserLogin(user);
                ///////////////////////
                //向客户端发送玩家数据
                JsonMessageUserInfo userInfoMsg = new JsonMessageUserInfo();
                userInfoMsg.m_Account = user.Account;
                userInfoMsg.m_Guid    = user.Guid;
                userInfoMsg.m_Nick    = user.Nickname;
                userInfoMsg.m_Level   = user.Level;
                userInfoMsg.m_Sign    = user.Sign;
                JsonMessageDispatcher.SendDcoreMessage(LobbyServer.Instance.SvrAPI, NodeName, userInfoMsg);
                LogSys.Log(LOG_TYPE.DEBUG, "DoAccountLogin,User New! guid:{0},nick:{1},acc:{2},node:{3}", user.Guid, user.Nickname, user.Account, user.NodeName);

                Next("BillingOnline", user);
            }
        }
예제 #6
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     DS_UserInfo ds = new DS_UserInfo();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "userInfoDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
예제 #7
0
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     DS_UserInfo ds = new DS_UserInfo();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
예제 #8
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;
            }
        }