Пример #1
0
        //--------------------------------------------------------------------------------------------------------------------------
        // 供外部直接调用的方法,实际执行线程是调用线程。
        //--------------------------------------------------------------------------------------------------------------------------
        internal void DSPSaveCreateUser(AccountInfo ai, string nickname, ulong userGuid)
        {
            try {
                TableAccount dataAccount = new TableAccount();
                dataAccount.AccountId = ai.AccountId;
                //dataAccount.IsBanned = ai.IsBanned;
                //dataAccount.UserGuid = ai.UserGuid;
                Msg_LD_Save msg = new Msg_LD_Save();
                msg.MsgId = (int)DataEnum.TableAccount;
                msg.PrimaryKeys.Add(dataAccount.AccountId);
                msg.Data = DbDataSerializer.Encode(dataAccount);
                DispatchAction(DSSaveInternal, msg);

                TableNicknameInfo dataNickname = new TableNicknameInfo();
                dataNickname.Nickname = nickname;
                dataNickname.UserGuid = userGuid;
                Msg_LD_Save msgNickname = new Msg_LD_Save();
                msgNickname.MsgId = (int)DataEnum.TableNicknameInfo;
                msgNickname.PrimaryKeys.Add(dataNickname.Nickname);
                msgNickname.Data = DbDataSerializer.Encode(dataNickname);
                DispatchAction(DSSaveInternal, msgNickname);
            } catch (Exception e) {
                LogSys.Log(LOG_TYPE.ERROR, "DataCache Save ERROR. Msg:DSP_CreateUser, Key:{0}, Error:{1},\nStacktrace:{2}", ai.AccountId, e.Message, e.StackTrace);
            }
        }
Пример #2
0
 public CloudClient(string connectionString)
 {
     // Create clients
     TableAccount   = CloudStorageAccount.Parse(connectionString);
     StorageAccount = Microsoft.Azure.Storage.CloudStorageAccount.Parse(connectionString);
     Table          = TableAccount.CreateCloudTableClient();
     Blob           = StorageAccount.CreateCloudBlobClient();
     Queue          = StorageAccount.CreateCloudQueueClient();
 }
Пример #3
0
 public void FromProto(TableAccount proto)
 {
     m_TableAccount = proto;
     UpdatePrimaryKeys();
     UpdateForeignKeys();
 }
        //
        internal void GMLoadAccount(string gmAccount, string accountId, int nodeHandle)
        {
            Msg_LD_Load msg = new Msg_LD_Load();

            msg.MsgId = (int)DataEnum.TableAccount;
            msg.PrimaryKeys.Add(accountId);
            Msg_LD_SingleLoadRequest reqAccount = new Msg_LD_SingleLoadRequest();

            reqAccount.MsgId    = (int)DataEnum.TableAccount;
            reqAccount.LoadType = Msg_LD_SingleLoadRequest.LoadTypeEnum.LoadSingle;
            reqAccount.Keys.Add(accountId);
            msg.LoadRequests.Add(reqAccount);
            RequestLoad(msg, (ret) => {
                JsonMessage resultMsg = new JsonMessage(LobbyGmMessageDefine.Msg_CL_GmQueryAccount, gmAccount);
                GameFrameworkMessage.Msg_LC_GmQueryAccount protoData = new GameFrameworkMessage.Msg_LC_GmQueryAccount();
                protoData.m_Result       = GameFrameworkMessage.GmResultEnum.Failed;
                protoData.m_QueryAccount = accountId;
                protoData.m_AccountState = GameFrameworkMessage.GmStateEnum.Offline;
                resultMsg.m_ProtoData    = protoData;

                KeyString primaryKey = KeyString.Wrap(ret.PrimaryKeys);
                if (Msg_DL_LoadResult.ErrorNoEnum.Success == ret.ErrorNo)
                {
                    LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "DataCache Load Success: Msg:{0}, Key:{1}", "GmAccount", primaryKey);
                    TableAccount dataAccount = null;
                    foreach (var result in ret.Results)
                    {
                        object _msg;
                        if (DbDataSerializer.Decode(result.Data, DataEnum2Type.Query(result.MsgId), out _msg))
                        {
                            DataEnum msgEnum = (DataEnum)result.MsgId;
                            switch (msgEnum)
                            {
                            case DataEnum.TableAccount:
                                dataAccount = _msg as TableAccount;
                                break;

                            default:
                                LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "Decode account data ERROR. Wrong message id. Account:{0}, WrongId:{1}", result.PrimaryKeys[0], msgEnum);
                                break;
                            }
                        }
                    }
                    protoData.m_Result       = GameFrameworkMessage.GmResultEnum.Success;
                    protoData.m_QueryAccount = dataAccount.AccountId;
                    protoData.m_AccountState = GameFrameworkMessage.GmStateEnum.Online;
                    if (dataAccount.IsBanned)
                    {
                        protoData.m_AccountState = GameFrameworkMessage.GmStateEnum.Banned;
                    }
                }
                else if (Msg_DL_LoadResult.ErrorNoEnum.NotFound == ret.ErrorNo)
                {
                    LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Yellow, "DataCache Load NotFound: Msg:{0}, Key:{1}", "GmAccount", primaryKey);
                }
                else
                {
                    LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "DataCache Load Failed: Msg:{0}, Key:{1}, ERROR:{2}", "GmAccount", primaryKey, ret.ErrorInfo);
                }
                resultMsg.m_ProtoData = protoData;
                JsonGmMessageDispatcher.SendNodeMessage(nodeHandle, resultMsg);
            });
        }