public SaltedHash GetAccountPassword(AccountId accountId) { using (var db = new THCard()) { Account dbAccount = db.Accounts.Find(accountId); AssertFound(dbAccount); return MapToHashedPassword(dbAccount); } }
/// <summary> /// Create a new Gera Account. /// </summary> /// <param name="AccountId">The AccountId.</param> /// <param name="Metadata">Optional metadata.</param> public Account(AccountId AccountId, IDictionary<String, Object> Metadata = null) { Id = AccountId; _Repositories = new Dictionary<RepositoryId, IRepository>(); _Metadata = new Dictionary<String, Object>(StringComparer.OrdinalIgnoreCase);; if (Metadata != null) AddMetadata(Metadata); }
public static ActivityCreationData Create(AccountId accountId, IEnumerable<ActivityId> ancestorIds, String name, Object value) { return new ActivityCreationData() { AccountId = accountId, AncestorIds = ancestorIds ?? Enumerable.Empty<ActivityId>(), Name = name, Value = value, }; }
public AccountManagement.User GetUser(AccountId accountId) { Contract.Requires(accountId != null && !accountId.IsNew); using (var db = new THCard()) { Account dbAccount = db.Accounts.Find(accountId.ToGuid()); if (dbAccount == null) { throw new InvalidOperationException("Account not found."); } return MapToUser(dbAccount.User); } }
public AccountManagement.Account GetAccount(AccountId accountId) { using (var db = new THCard()) { Account dbAccount = FindAccountById(db, accountId.ToGuid()); if (dbAccount != null) { return MapAccount(dbAccount); } else { return null; } } }
/// <summary> /// Create a new account using the given AccountId. /// </summary> /// <param name="AccountId">A valid AccountId.</param> public HTTPResponseHeader CreateNewAccount(String AccountId) { #region Not a valid AccountId if (!IsValidAccountId(AccountId)) { return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.BadRequest, CacheControl = "no-cache", }; } #endregion var _NewAccountId = new AccountId(AccountId); if (!GeraServer.HasAccount(_NewAccountId)) { var _Account = GeraServer.CreateAccount(AccountId: _NewAccountId); var _RequestHeader = IHTTPConnection.RequestHeader; var _Content = Encoding.UTF8.GetBytes(HTMLBuilder("Account Created!", _StringBuilder => _StringBuilder.AppendLine("<a href=\"/Account/" + _Account.Id.ToString() + "\">" + _Account.Id.ToString() + "</a><br />"). AppendLine("<br /><a href=\"/\">back</a><br />") )); return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.OK, CacheControl = "no-cache", ContentLength = (UInt64) _Content.Length, ContentType = HTTPContentType.HTML_UTF8, Content = _Content }; } #region ...or conflict! else { return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.Conflict, CacheControl = "no-cache", }; } #endregion }
public int IncrementFailedLoginAttemptCount(AccountId accountId) { using (var db = new THCard()) { using (var transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.RepeatableRead })) { FailedLoginAttempt dbFailedLoginAttempt = FindFailedLoginAttempt(db, accountId.ToGuid()); if (dbFailedLoginAttempt == null) { db.FailedLoginAttempts.Add(new FailedLoginAttempt {AccountId = accountId.ToGuid(), FailedLoginAttemptCount = 0}); db.SaveChanges(); transaction.Complete(); return 1; } else { ++dbFailedLoginAttempt.FailedLoginAttemptCount; db.SaveChanges(); transaction.Complete(); return dbFailedLoginAttempt.FailedLoginAttemptCount; } } } }
public HTTPResponseHeader ListRepositories(String AccountId) { IAccount _Account; var _AccountId = new AccountId(AccountId); if (GeraServer.TryGetAccount(_AccountId, out _Account)) { var _Content = Encoding.UTF8.GetBytes(HTMLBuilder("List Repositories...", _StringBuilder => { _StringBuilder.AppendLine("<table>"). AppendLine("<tr><td>AccountId:</td><td>" + AccountId.ToString() + "</td></tr>"); var _RepositoryArray = _Account.RepositoryIds.ToArray(); var _RepositoryCount = _RepositoryArray.Length; if (_RepositoryCount > 0) _StringBuilder.AppendLine("<tr><td rowspan=" + GeraServer.NumberOfAccounts + ">Repositories</td><td><a href=\"/Account/" + AccountId.ToString() + "/" + _RepositoryArray[0] + "\">" + _RepositoryArray[0] + "</a></td></tr>"); if (_RepositoryCount > 1) for(var _Repo = 1; _Repo<_RepositoryCount; _Repo++) _StringBuilder.AppendLine("<tr><td><a href=\"/Account/" + AccountId + "/" + _RepositoryArray[_Repo] + "\">" + _RepositoryArray[_Repo] + "</a></td></tr>"); } )); return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.OK, CacheControl = "no-cache", ContentLength = (UInt64) _Content.Length, ContentType = HTTPContentType.HTML_UTF8, Content = _Content }; } #region ...invalid AccountId! else { return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.NotFound, CacheControl = "no-cache", ContentLength = 0, }; } #endregion }
/// <summary> /// Get information on the given account. /// </summary> /// <param name=__AccountId>A valid AccountId.</param> /// <example> /// $ curl -X GET -H "Accept: application/json" http://127.0.0.1:8182/Account/ABC /// { /// "AccountId": "ABC", /// "Repositories": [] /// } /// </example> public HTTPResponseHeader GetAccountInformation(String AccountId) { #region Not a valid AccountId if (!IsValidAccountId(AccountId)) return Error400_BadRequest(); #endregion IAccount _Account; var _AccountId = new AccountId(AccountId); if (GeraServer.TryGetAccount(_AccountId, out _Account)) { var _Content = new JObject( new JProperty(__AccountId, AccountId), new JProperty("Repositories", new JArray( from _RepositoryId in _Account.RepositoryIds select _RepositoryId.ToString())) ).ToString().ToUTF8Bytes(); return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.OK, CacheControl = "no-cache", ContentType = HTTPContentType.JSON_UTF8, Content = _Content }; } #region ...invalid AccountId! else return Error404_NotFound(); #endregion }
/// <summary> /// Create a new account using the given AccountId. /// </summary> /// <param name=__AccountId>A valid AccountId.</param> /// <example> /// $ curl -X PUT -H "Accept: application/json" http://127.0.0.1:8182/Account/ABC /// ~ HTTP/1.1 201 Created /// ~ Location: http://127.0.0.1:8182/Account/ABC /// { /// "AccountId": "ABC" /// } /// /// $ curl -X PUT -H "Content-Type: application/json" -H "Accept: application/json" -d "{"metadata" :{\"name\":\"Alice\", \"age\":18, \"password\":\"secure\"}" http://127.0.0.1:8182/Account/ABC /// ~ HTTP/1.1 201 Created /// ~ Location: http://127.0.0.1:8182/Account/ABC /// { /// "AccountId": "ABC", /// "Metadata": { /// "name": "Alice", /// "age": 18, /// "password": "******" /// } /// } /// </example> public HTTPResponseHeader CreateNewAccount(String AccountId) { #region Not a valid AccountId if (!IsValidAccountId(AccountId)) return Error400_BadRequest(); #endregion var _NewAccountId = new AccountId(AccountId); if (!GeraServer.HasAccount(_NewAccountId)) { IAccount _Account = null; Byte[] _Content = null; // ADD HTTP-HEADERFIELD CONTENT-LENGTH! // ADD HTTP-HEADERFIELD CONTENT-TYPE! if (IHTTPConnection.RequestBody.Length > 0) { _Account = GeraServer.CreateAccount(AccountId: _NewAccountId, Metadata: ParseMetadata()); _Content = new JObject( new JProperty(__AccountId, _Account.Id.ToString()), new JProperty(__Metadata, new JObject(from _Metadatum in _Account.Metadata select new JProperty(_Metadatum.Key, _Metadatum.Value))) ).ToString().ToUTF8Bytes(); } else { _Account = GeraServer.CreateAccount(AccountId: _NewAccountId); _Content = new JObject( new JProperty(__AccountId, _Account.Id.ToString()) ).ToString().ToUTF8Bytes(); } return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.Created, Location = "http://" + IHTTPConnection.RequestHeader.Host + "/Account/" + _Account.Id.ToString(), CacheControl = "no-cache", ContentType = HTTPContentType.JSON_UTF8, Content = _Content }; } #region ...or conflict! else return Error409_Conflict(); #endregion }
public void Returns_False_On_NotEqual( AccountId sut, AccountId other) { Assert.True(!sut.Equals(other)); }
public Account(AccountId identity) : base(identity) { transactions = new List<Transaction>(); }
public ChangeAccountEmail(AccountId id, string oldEmail, string newEmail) { NewEmail = newEmail; OldEmail = oldEmail; Id = id; }
public void Returns_True(AccountId sut) { Assert.True(sut.Equals(sut)); }
public async Task Handle( DateTimeOffset date, UserId user, BrokerId brokerId, AccountId payAccountId, AccountId feeAccountId, AssetId assetId, decimal price, decimal fee, int count) { if (count <= 0) { throw new InvalidCountException(); } var state = _stateManager.ReadState(date, user); var broker = state.Brokers.FirstOrDefault(b => b.Id == brokerId); if (broker == null) { throw new InvalidBrokerException(); } if (string.IsNullOrWhiteSpace(assetId)) { throw new InvalidAssetException(); } var asset = broker.Inventory.FirstOrDefault(a => a.Id == assetId); if (asset == null) { throw new AssetNotFoundException(); } var remainingCount = asset.Count - count; if (remainingCount < 0) { throw new InvalidCountException(); } var payAccount = broker.Accounts.FirstOrDefault(a => a.Id == payAccountId); if (payAccount == null) { throw new InvalidAccountException(); } var feeAccount = broker.Accounts.FirstOrDefault(a => a.Id == feeAccountId); if (feeAccount == null) { throw new InvalidAccountException(); } switch (price) { case < 0: throw new InvalidPriceException(); case 0: break; default: await _addIncome.Handle( date, user, brokerId, payAccountId, price, IncomeCategory.SellAsset, assetId); break; } switch (fee) { case < 0: throw new InvalidPriceException(); case 0: break; default: await _addExpense.Handle( date, user, brokerId, feeAccountId, fee, ExpenseCategory.SellAssetFee, assetId); break; } await _stateManager.AddCommand(new ReduceAssetCommand(date, user, brokerId, assetId, count)); }
public GetPositionsResponse GetOpenPositions(AccountId accountId) => Execute <GetPositionsResponse>(new GetOpenPositionsEndpoint() { AccountId = accountId });
private static BankAccount NewAccount(Money monies) { var bankAccount = BankAccount.Factory.OpenNewAccount(AccountId.NewId(), GetNow()); return(bankAccount.Deposit(monies, GetNow())); }
public Task <Option <Account> > GetAsync(AccountId accountId) { return(Task.FromResult(accountsByKey.ContainsKey(accountId) ? Option.Some(accountsByKey[accountId]) : Option.None <Account>())); }
public void Add(AccountId accountId) => _accountIds.Add(accountId);
/// <summary> /// Initializes a new instance of the <see cref="ResourceAccount" /> class. /// </summary> /// <param name="environment">A string containing the identity provider for this account.</param> /// <param name="identifier">The unique identifier for the account.</param> /// <param name="objectId">A string representation for a GUID which is the ID of the user owning the account in the tenant.</param> /// <param name="tenantId">A string representation for a GUID, which is the ID of the tenant where the account resides.</param> /// <param name="username">A string containing the displayable value in UserPrincipalName (UPN) format.</param> public ResourceAccount(string environment, string identifier, string objectId, string tenantId, string username) { Environment = environment; HomeAccountId = new AccountId(identifier, objectId, tenantId); Username = username; }
protected override void Execute() { List <KeyValuePair <StorageAccountSearchFilterParameter, string> > filters = new List <KeyValuePair <StorageAccountSearchFilterParameter, string> >(); switch (ParameterSetName) { case GetSingleAccountParamSet: filters.Add(new KeyValuePair <StorageAccountSearchFilterParameter, string>(StorageAccountSearchFilterParameter.VersionedAccountName, AccountId.ToString(CultureInfo.InvariantCulture))); break; case ListAccountsParamSet: if (TenantSubscriptionId != null) { filters.Add(new KeyValuePair <StorageAccountSearchFilterParameter, string>(StorageAccountSearchFilterParameter.TenantSubscriptionId, TenantSubscriptionId)); } if (PartialAccountName != null) { filters.Add(new KeyValuePair <StorageAccountSearchFilterParameter, string>(StorageAccountSearchFilterParameter.PartialAccountName, PartialAccountName)); } if (StorageAccountStatus.HasValue == true) { filters.Add(new KeyValuePair <StorageAccountSearchFilterParameter, string>(StorageAccountSearchFilterParameter.StorageAccountStatus, StorageAccountStatus.Value.ToString(CultureInfo.InvariantCulture))); } break; } string filter = Tools.GenerateStorageAccountsSearchFilter(filters); var response = Client.StorageAccounts.List(ResourceGroupName, FarmName, filter, !Detail.IsPresent); if (response.StatusCode == System.Net.HttpStatusCode.OK) { List <StorageAccountResponse> adminViewList = new List <StorageAccountResponse>(); foreach (StorageAccountModel model in response.StorageAccounts) { adminViewList.Add(new StorageAccountResponse(model, FarmName)); } WriteObject(adminViewList, true); } else { WriteObject(response, true); } }
/// <summary>Initialises a new instance of the <see cref="AddAccountCommand" /> class.</summary> /// <param name="id">Account id</param> /// <param name="name">Account name</param> /// <param name="budget">Budget the account belongs to</param> public AddAccountCommand(AccountId id, string name, BudgetId budget) { this.Id = id; this.Name = name; this.Budget = budget; }
public GetPositionResponse GetInstrumentPosition(AccountId accountId, InstrumentName instrument) => Execute <GetPositionResponse>(new GetInstrumentPositionEndpoint() { AccountId = accountId, Instrument = instrument });
public override string ToString() { return("Account ID: " + AccountId.ToString() + "\nUser Name: " + UserName); }
public Account(AccountId id, CurrencyCode currency, string displayName) { Id = id; Currency = currency; DisplayName = displayName; }
public IAsyncResult BeginSessionArchiveQuery(DateTime?timeStart, DateTime?timeEnd, string searchText, AccountId userId, uint max, string afterId, string beforeId, int firstMessageIndex, AsyncCallback callback) { AssertSessionNotDeleted(); if (TextState != ConnectionState.Connected) { throw new InvalidOperationException($"{GetType().Name}: {nameof(TextState)} must equal ChannelState.Connected"); } if (afterId != null && beforeId != null) { throw new ArgumentException($"{GetType().Name}: Parameters {nameof(afterId)} and {nameof(beforeId)} cannot be used at the same time"); } if (max > 50) { throw new ArgumentException($"{GetType().Name}: {nameof(max)} cannot be greater than 50"); } var ar = new AsyncNoResult(callback); var request = new vx_req_session_archive_query_t { session_handle = _sessionHandle, max = max, after_id = afterId, before_id = beforeId, first_message_index = firstMessageIndex, search_text = searchText }; if (timeStart != null && timeStart != DateTime.MinValue) { request.time_start = (timeStart?.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")); } if (timeEnd != null && timeEnd != DateTime.MaxValue) { request.time_end = (timeEnd?.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")); } if (!AccountId.IsNullOrEmpty(userId)) { request.participant_uri = userId.ToString(); } VxClient.Instance.BeginIssueRequest(request, result => { vx_resp_session_archive_query_t response; try { response = VxClient.Instance.EndIssueRequest(result); _sessionArchiveResult = new ArchiveQueryResult(response.query_id); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SessionArchiveResult))); ar.SetComplete(); } catch (Exception e) { VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}"); ar.SetComplete(e); if (VivoxDebug.Instance.throwInternalExcepetions) { throw; } return; } }); return(ar); }
public MsalAccount(string objectId, string tenantId) { HomeAccountId = new AccountId($"{objectId}.{tenantId}", objectId, tenantId); }
public void Returns_False_On_Type(AccountId sut) { var value = sut.ToString(); Assert.True(!sut.Equals(value)); }
public static void Configure(this StateManager manager) { manager.Bind <CreateBrokerCommand, CreateBrokerModel>( cmd => new(cmd.Date, cmd.User, cmd.Id, cmd.DisplayName), m => new(m.Date, new(m.User), new(m.Id), m.DisplayName), (state, m) => { state.Brokers.Add(new( new(m.Id), m.DisplayName, new List <Account>(), new List <Asset>())); } ); manager.Bind <CreateAccountCommand, CreateAccountModel>( cmd => new (cmd.Date, cmd.User, cmd.Broker, cmd.Id, cmd.Currency, cmd.DisplayName), m => new (m.Date, new(m.User), new(m.Broker), new(m.Id), new(m.Currency), m.DisplayName), (state, m) => { var brokerId = new BrokerId(m.Broker); var broker = state.Brokers.First(b => b.Id == brokerId); broker.Accounts.Add(new( new(m.Id), new(m.Currency), m.DisplayName)); } ); manager.Bind <AddIncomeCommand, AddIncomeModel>( cmd => { var asset = (cmd.Asset != null) ? (string)cmd.Asset : null; return(new( cmd.Date, cmd.User, cmd.Broker, cmd.Account, cmd.Id, cmd.Amount, cmd.Category, asset)); }, m => { var asset = (m.Asset != null) ? new AssetId(m.Asset) : null; return(new( m.Date, new(m.User), new(m.Broker), new(m.Account), new(m.Id), m.Amount, new(m.Category), asset)); }, (state, m) => { var brokerId = new BrokerId(m.Broker); var broker = state.Brokers.First(b => b.Id == brokerId); var accountId = new AccountId(m.Account); var account = broker.Accounts.First(a => a.Id == accountId); account.Balance += m.Amount; } ); manager.Bind <AddExpenseCommand, AddExpenseModel>( cmd => { var asset = (cmd.Asset != null) ? (string)cmd.Asset : null; return(new(cmd.Date, cmd.User, cmd.Broker, cmd.Account, cmd.Id, cmd.Amount, cmd.Category, asset)); }, m => { var asset = (m.Asset != null) ? new AssetId(m.Asset) : null; return(new(m.Date, new(m.User), new(m.Broker), new(m.Account), new(m.Id), m.Amount, new(m.Category), asset)); }, (state, m) => { var brokerId = new BrokerId(m.Broker); var broker = state.Brokers.First(b => b.Id == brokerId); var accountId = new AccountId(m.Account); var account = broker.Accounts.First(a => a.Id == accountId); account.Balance -= m.Amount; } ); manager.Bind <AddAssetCommand, AddAssetModel>( cmd => new(cmd.Date, cmd.User, cmd.Broker, cmd.Asset, cmd.Isin, cmd.Currency, cmd.RawName, cmd.Count), m => new(m.Date, new(m.User), new(m.Broker), new(m.Id), new(m.Isin), new(m.Currency), m.RawName, m.Count), (state, m) => { var brokerId = new BrokerId(m.Broker); var broker = state.Brokers.First(b => b.Id == brokerId); broker.Inventory.Add(new( new(m.Asset), new(m.Isin), new(m.Currency), m.RawName, m.Count)); } ); manager.Bind <ReduceAssetCommand, ReduceAssetModel>( cmd => new(cmd.Date, cmd.User, cmd.Broker, cmd.Asset, cmd.Count), m => new(m.Date, new(m.User), new(m.Broker), new(m.Id), m.Count), (state, m) => { var brokerId = new BrokerId(m.Broker); var broker = state.Brokers.First(b => b.Id == brokerId); var asset = broker.Inventory.First(a => a.Id == m.Asset); asset.Count -= m.Count; } ); manager.Bind <IncreaseAssetCommand, IncreaseAssetModel>( cmd => new(cmd.Date, cmd.User, cmd.Broker, cmd.Id, cmd.Count), m => new(m.Date, new(m.User), new(m.Broker), new(m.Id), m.Count), (state, m) => { var brokerId = new BrokerId(m.Broker); var broker = state.Brokers.First(b => b.Id == brokerId); var asset = broker.Inventory.First(a => a.Id == m.Id); asset.Count += m.Count; } ); }
public void Returns_False_On_Null(AccountId sut) { Assert.True(!sut.Equals(null)); }
public Account GetAccountFromId(AccountId accountId) { return(_store.GetAccountFromId(accountId)); }
/// <summary> /// Delete an account using the given AccountId. /// </summary> /// <param name=__AccountId>A valid AccountId.</param> /// <example> /// $ curl -X DELETE -H "Accept: application/json" http://127.0.0.1:8182/Account/ABC /// </example> public HTTPResponseHeader DeleteAccount(String AccountId) { #region Not a valid AccountId if (!IsValidAccountId(AccountId)) return Error400_BadRequest(); #endregion var _AccountId = new AccountId(AccountId); if (GeraServer.HasAccount(_AccountId)) { if (GeraServer.DeleteAccount(_AccountId)) { return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.OK, CacheControl = "no-cache", }; } else return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.InternalServerError, CacheControl = "no-cache" }; } #region ...or not found! else return Error404_NotFound(); #endregion }
public void Throw_ArgumentNullException_On_Null_AccountHolder(AccountId id) { Assert.Throws <ArgumentNullException>(() => { new Account(id, null); }); }
public HTTPResponseHeader ListRepositories(String AccountId) { IAccount _Account; var _AccountId = new AccountId(AccountId); if (GeraServer.TryGetAccount(_AccountId, out _Account)) return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.OK, CacheControl = "no-cache", ContentType = HTTPContentType.JSON_UTF8, Content = new JArray(from _RepositoryId in _Account.RepositoryIds select _RepositoryId.ToString()).ToString().ToUTF8Bytes() }; #region ...invalid AccountId! else return Error404_NotFound(); #endregion }
private static MatchInfo GetMatchInfoInternal() { var matchInfo = new MatchInfo(); var gameState = Mirror.Root?["GameState"]["s_instance"]; var netCacheValues = GetService("NetCache")?["m_netCache"]?["valueSlots"]; if (gameState != null) { var playerIds = gameState["m_playerMap"]["keySlots"]; var players = gameState["m_playerMap"]["valueSlots"]; for (var i = 0; i < playerIds.Length; i++) { if (players[i]?.Class.Name != "Player") { continue; } var medalInfo = players[i]["m_medalInfo"]; var sMedalInfo = medalInfo?["m_currMedalInfo"]; var wMedalInfo = medalInfo?["m_currWildMedalInfo"]; var name = players[i]["m_name"]; var sRank = sMedalInfo != null?GetRankValue(sMedalInfo) : 0; var sLegendRank = sMedalInfo?["legendIndex"] ?? 0; var wRank = wMedalInfo != null?GetRankValue(wMedalInfo) : 0; var wLegendRank = wMedalInfo?["legendIndex"] ?? 0; var cardBack = players[i]["m_cardBackId"]; var id = playerIds[i]; var side = (Side)players[i]["m_side"]; var account = players[i]["m_gameAccountId"]; var accountId = new AccountId { Hi = account?["m_hi"] ?? 0, Lo = account?["m_lo"] ?? 0 }; var battleTag = GetBattleTag(accountId); if (side == Side.FRIENDLY) { dynamic netCacheMedalInfo = null; if (netCacheValues != null) { foreach (var netCache in netCacheValues) { if (netCache?.Class.Name != "NetCacheMedalInfo") { continue; } netCacheMedalInfo = netCache; break; } } var sStars = netCacheMedalInfo?["<Standard>k__BackingField"]["<Stars>k__BackingField"]; var wStars = netCacheMedalInfo?["<Wild>k__BackingField"]["<Stars>k__BackingField"]; matchInfo.LocalPlayer = new MatchInfo.Player(id, name, sRank, sLegendRank, sStars, wRank, wLegendRank, wStars, cardBack, accountId, battleTag); } else if (side == Side.OPPOSING) { matchInfo.OpposingPlayer = new MatchInfo.Player(id, name, sRank, sLegendRank, 0, wRank, wLegendRank, 0, cardBack, accountId, battleTag); } } } if (matchInfo.LocalPlayer == null || matchInfo.OpposingPlayer == null) { return(null); } var gameMgr = GetService("GameMgr"); if (gameMgr != null) { matchInfo.MissionId = gameMgr["m_missionId"]; matchInfo.GameType = gameMgr["m_gameType"]; matchInfo.FormatType = gameMgr["m_formatType"]; var brawlGameTypes = new[] { 16, 17, 18 }; if (brawlGameTypes.Contains(matchInfo.GameType)) { var mission = GetCurrentBrawlMission(); matchInfo.BrawlSeasonId = mission?["<tavernBrawlSpec>k__BackingField"]?["<GameContentSeason>k__BackingField"]?["<SeasonId>k__BackingField"]; } } if (netCacheValues != null) { foreach (var netCache in netCacheValues) { if (netCache?.Class.Name != "NetCacheRewardProgress") { continue; } matchInfo.RankedSeasonId = netCache["<Season>k__BackingField"]; break; } } return(matchInfo); }
/// <summary> /// Delete an account using the given AccountId. /// </summary> /// <param name="AccountId">A valid AccountId.</param> public HTTPResponseHeader DeleteAccount(String AccountId) { #region Not a valid AccountId if (!IsValidAccountId(AccountId)) { return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.BadRequest, CacheControl = "no-cache", }; } #endregion var _AccountId = new AccountId(AccountId); if (GeraServer.HasAccount(_AccountId)) { if (GeraServer.DeleteAccount(_AccountId)) { var _Content = Encoding.UTF8.GetBytes(HTMLBuilder("Account deleted!", _StringBuilder => _StringBuilder.AppendLine("<br /><a href=\"/\">back</a><br />") )); return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.OK, CacheControl = "no-cache", ContentLength = (UInt64) _Content.Length, ContentType = HTTPContentType.HTML_UTF8, Content = _Content }; } else return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.InternalServerError, CacheControl = "no-cache" }; } #region ...or not found! else { return new HTTPResponseBuilder() { HTTPStatusCode = HTTPStatusCode.NotFound, CacheControl = "no-cache", }; } #endregion }
protected override void ConfirmedPrimeElected(BlockElectionDistillate blockElectionDistillate, FinalElectionResultDistillate finalElectionResultDistillate) { base.ConfirmedPrimeElected(blockElectionDistillate, finalElectionResultDistillate); NeuraliumBlockElectionDistillate neuraliumBlockElectionDistillate = (NeuraliumBlockElectionDistillate)blockElectionDistillate; NeuraliumFinalElectionResultDistillate neuraliumFinalElectionContext = (NeuraliumFinalElectionResultDistillate)finalElectionResultDistillate; this.centralCoordinator.PostSystemEvent(NeuraliumSystemEventGenerator.NeuraliumMiningPrimeElected(blockElectionDistillate.currentBlockId, neuraliumFinalElectionContext.BountyShare, neuraliumFinalElectionContext.TransactionTips, AccountId.FromString(neuraliumFinalElectionContext.DelegateAccountId))); Log.Information($"We were officially announced as a prime elected in Block {blockElectionDistillate.currentBlockId} for the election that was announced in block {blockElectionDistillate.currentBlockId - neuraliumFinalElectionContext.BlockOffset}"); }
public override int GetHashCode() { return(AccountId.GetHashCode() ^ MeterReadingValue.GetHashCode()); }
public GetPricingResponse GetPricing(AccountId accountId, ICollection <InstrumentName> instruments, bool?includeHomeConversions = null, DateTime?since = null, bool?includeUnitsAvailable = null) => GetPricing(accountId, instruments, since, includeHomeConversions, includeUnitsAvailable);
public Account(Portfolio portfolio, AccountId accountId) : base(portfolio, accountId) { transactions = new List<Transaction>(); }
public List <Withdraw> GetWithdrawByAccountId(AccountId accountId) { throw new NotImplementedException(); }
public async Task Execute() { var bus = Bus.Factory.CreateUsingRabbitMq(sbc => { sbc.Host(new Uri(_rabbitHost), host => { host.Username(_rabbitUsername); host.Password(_rabbitPassword); }); sbc.ReceiveEndpoint(_rabbitEndpoint + "_account", ep => { ep.Consumer(() => new AccountMessageConsumer()); /* * ep.Bind("core_transaction_created", s => * { * s.RoutingKey = "user2user_source_asd"; * s.ExchangeType = "direct"; * }); * * */ }); sbc.ReceiveEndpoint(_rabbitEndpoint + "_transaction", ep => { ep.Consumer(() => new TransactionMessageConsumer()); ep.Bind("core_transaction_created", s => { s.RoutingKey = "user2user_source"; s.ExchangeType = "direct"; }); ep.Bind("core_transaction_created", s => { s.RoutingKey = "user2user_destination"; s.ExchangeType = "direct"; }); }); }); await bus.StartAsync(); // This is important! var accId = new AccountId(Models.UniqId.New()); var create = new CreateAccount( accId, CurrencyFactory.New("MXN"), false ); var convId = Guid.NewGuid(); Console.WriteLine($"Publish create account with {accId.Value.Value} with convId = {convId} "); //await bus.Publish(CreateAccountCommand.From(create), context => context.ConversationId = convId); //await bus.Publish(new Message { Text = "Hi", MyInt = new Message2 {Text2 = "sometined2", SomeInt = 123} }); // Console.WriteLine("Press any key to exit"); // await Task.Run(() => Console.ReadKey()); // await bus.StopAsync(); }
public void False_With_Valid_Request(AccountId sut) { var compared = new AccountId(int.Parse(sut.ToString()) + 1); Assert.True(sut != compared); }
public void Throw_ArgumentNullException_On_Null_Balance( AccountId id, AccountHolder holder) { Assert.Throws <ArgumentNullException>(() => { new Account(id, holder, null); }); }
private void ProcessHiredFriends(ServerAccount serverAccount, Action <List <object> > returnFunc, List <object> responseData, ICollection <long> hiredFriendIds) { if (hiredFriendIds.Count > 0) { Dictionary <AccountId, FacebookFriendInfo> friendAccounts = new Dictionary <AccountId, FacebookFriendInfo>(); List <FacebookFriendInfo> friendsWithoutAccounts = new List <FacebookFriendInfo>(); foreach (long facebookId in hiredFriendIds) { if (facebookId == serverAccount.FacebookAccountId) { friendAccounts.Add(serverAccount.AccountId, null); continue; } HandleFriendCase ( serverAccount, facebookId, delegate(FacebookFriendInfo ffi) { friendAccounts.Add(ffi.AccountId, ffi); }, delegate(FacebookFriendInfo ffi) { friendsWithoutAccounts.Add(ffi); }, delegate() { friendsWithoutAccounts.Add(new FacebookFriendInfo(new AccountId(0u), facebookId, "Unfriended", "", "")); } ); } AvatarManagerServiceAPI.GetAvatarForUsers(friendAccounts.Keys, delegate(XmlDocument friendAccountsAvatars) { AvatarManagerServiceAPI.GetSystemAvatars(delegate(XmlDocument npcAvatarsXml) { // Get the Avatars for the friends with Hangout Avatars foreach (XmlNode friendAvatarNode in friendAccountsAvatars.SelectNodes("Avatars/Avatar")) { // This is a little weird... the dictionary doesn't actually contain the new object, but that object // will index properly into the dictionary for what we want. If we didn't do this weirdness we'd have // to make a new data structure or search linearly AccountId accountId = new AccountId(uint.Parse(friendAvatarNode.SelectSingleNode("@AccountId").InnerText)); FacebookFriendInfo facebookFriend; if (!friendAccounts.TryGetValue(accountId, out facebookFriend)) { StateServerAssert.Assert ( new Exception ( "Facebook friend ID provided by the client (" + accountId + ") was not found in Account ID (" + serverAccount.AccountId + ")'s friend list while trying to process hired friends" ) ); return; } XmlElement friendAvatarElement = (XmlElement)friendAvatarNode; ReplaceItemIdsWithDna(friendAvatarElement); AddFacebookData(friendAvatarNode, facebookFriend); responseData.Add(friendAvatarNode.OuterXml); } // Get the avatars for the friends without Hangout Avatars XmlNodeList npcAvatarNodes = npcAvatarsXml.SelectNodes("/Avatars/Avatar"); foreach (FacebookFriendInfo facebookFriend in friendsWithoutAccounts) { XmlNode npcAvatarNode = npcAvatarNodes[mRand.Next(0, npcAvatarNodes.Count)]; // Local avatar is already expanded to assets XmlElement npcElement = (XmlElement)npcAvatarNode; ReplaceItemIdsWithDna(npcElement); AddFacebookData(npcAvatarNode, facebookFriend); responseData.Add(npcAvatarNode.OuterXml); } returnFunc(responseData); }); }); } else { returnFunc(responseData); } }
/// <inheritdoc/> public void Register(AccountId accountId) { this.Accounts ??= new AccountCollection(); this.Accounts.Add(accountId); }
protected Account(Portfolio portfolio, AccountId identity) : base(portfolio, identity) { }