// private void ReportMyState(double transAmount, double balanceAfter, IActorRef toWhom = null) // { // if (toWhom == null) // toWhom = Context.Parent; // use the parent if we're not passed one. // // toWhom.Tell( // new RegisterMyAccountBalanceChange( // _accountState.AccountNumber, // transAmount, // balanceAfter) // ); // } private void ProcessBilling(BillingAssessment command) { if (_accountState?.AccountNumber == null) { _log.Error($"[ProcessBilling]: Actor {Self.Path.Name} is passing an empty account number."); throw new Exception($"[ProcessBilling]: Actor {Self.Path.Name} is passing an empty account number."); } try { var c = command; var billedAmount = c.LineItems.Aggregate(0.0, (accumulator, next) => accumulator + next.Item.Amount); // var parameters = c.LineItems.Aggregate("", // (working, next) => working + ";" + next.Item.Name + "=" + next.Item.Amount); var model = new FetchAccountBusinessRules( client: Self.Path.Parent.Parent.Name, portfolioName: Self.Path.Parent.Name, accountState: (AccountState)_accountState.Clone(), command: command, totalBilledAmount: billedAmount, accountRef: Self ); command.AccountBusinessMapperRouter.Tell(model); //_log.Info($"[ProcessBilling]: {response}"); } catch (Exception e) { _log.Error($"[ProcessBilling]: {Self.Path.Name} {e.Message} {e.StackTrace}"); throw; } }
public FetchAccountBusinessRules(double totalBilledAmount, string client, string portfolioName, AccountState accountState, BillingAssessment command, IActorRef accountRef) { TotalBilledAmount = totalBilledAmount; Client = client; PortfolioName = portfolioName; AccountState = accountState; Command = command; AccountRef = accountRef; }
public async Task <string> AccountPayment(string actorName, [FromBody] SimulateAssessmentModel Assessment) { var system = ActorSystemRefs .ActorSystem .ActorSelection($"akka://demo-system/user/demo-supervisor/{actorName}").ResolveOne(TimeSpan.FromSeconds(10)); if (system.Exception != null) { return($"{actorName} is not running at the moment"); } ImmutableList <InvoiceLineItem> items = ImmutableList.Create <InvoiceLineItem>(Assessment.LineItems.ToArray()); var domanCommand = new BillingAssessment(actorName, items); var response = await system.Result.Ask <ThisIsMyStatus>(domanCommand, TimeSpan.FromSeconds(10)); return(response.Message); }
private void AssessAllAccounts(AssessWholePortfolio cmd) { Monitor(); _stopWatch = Stopwatch.StartNew(); _stopWatch.Start(); Console.WriteLine( $"Billing Items: {cmd.Items.Aggregate("", (acc, next) => acc + " " + next.Item.Name + " " + next.Item.Amount)}"); try { foreach (var account in _porfolioState.SupervizedAccounts.Values.ToList()) { var bill = new BillingAssessment( account.AccountNumber , cmd.Items , AccountBusinessRulesHandlerRouter , AccountBusinessRulesMapperRouter ); account.AccountActorRef.Tell(bill); //_log.Info($"[AssessAllAccounts]: Just told account {account.AccountNumber} to run assessment."); } Sender.Tell(new TellMeYourPortfolioStatus( $"Your request was sent to all {_porfolioState.SupervizedAccounts.Count.ToString()} accounts", null)); } catch (Exception e) { _log.Error($"[AssessAllAccounts]: {e.Message} {e.StackTrace}"); throw; } _stopWatch.Stop(); ReportStopwatchInfo("AssessAllAccounts", _stopWatch.ElapsedMilliseconds); }
private void ProcessBilling(BillingAssessment command) { ApplyBusinessRules(command); Sender.Tell(new ThisIsMyStatus($"Your billing request has been submited to occount {_accountState.AccountNumber}. The new account state is: {_accountState}")); }