Skip to content

Commit

Permalink
last changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo506 committed Aug 25, 2022
1 parent 8dbacaf commit f3d869a
Show file tree
Hide file tree
Showing 25 changed files with 100 additions and 130 deletions.
4 changes: 2 additions & 2 deletions AuthMicroservice/AuthMicroservice.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
}
},
"AuthServer": {
"Url": "https://185.137.234.190:10001"
"Url": "https://localhost:10001"
},
"AllowedHosts": "*",
"ConnectionStrings": {
"MongoDbConnection": "mongodb://mongodb:27017"
"MongoDbConnection": "mongodb://localhost:27017"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
},
"AuthServer": {
"Url": "https://185.137.234.190:10001"
"Url": "https://localhost:10001"
},

"AllowedHosts": "*",
Expand Down
5 changes: 3 additions & 2 deletions BlazorClient/BlazorClient/Components/AddProductModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class AddProductModel : ComponentBase

public async Task HandleValidSubmitAsync()
{

var t = addProductViewModel;
var token = await localStorageService.GetAsync<SecurityToken>(nameof(SecurityToken));
ChangePortfolioResponse addProductResponse = new();
try
Expand All @@ -32,9 +32,10 @@ public async Task HandleValidSubmitAsync()
headers.Add("Authorization", $"Bearer {token.AccessToken}");
var changePortfolioRequest = new ChangePortfolioRequest()
{
InvestorId = null,
InvestorId = "",
ProductName = addProductViewModel.ProductName,
StartPrice = priceDefineService.DefinePrice(addProductViewModel.StartPrice),
Volume = addProductViewModel.Volume
};

addProductResponse = await Client.AddProductAsync(changePortfolioRequest, headers);
Expand Down
9 changes: 5 additions & 4 deletions BlazorClient/BlazorClient/Components/PostOrderModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ public async Task HandleValidSubmitAsync()
{
var headers = new Metadata();
headers.Add("Authorization", $"Bearer {token.AccessToken}");

var orderDetail = new Order()
{
ProductId = ProductId,
Volume = postOrderViewModel.Volume,
Price = priceDefineService.DefinePrice(postOrderViewModel.Price),
OnlyFullExecution = postOrderViewModel.OnlyFullExecution,
SubmissionTime = Timestamp.FromDateTime(postOrderViewModel.SubmissionTime),
Deadline = Timestamp.FromDateTime(postOrderViewModel.Deadline),
InvestorId = null
SubmissionTime = Timestamp.FromDateTime(postOrderViewModel.SubmissionTime.ToUniversalTime()),
Deadline = Timestamp.FromDateTime(postOrderViewModel.Deadline.ToUniversalTime()),
InvestorId = "",
Type = this.OrderType
};
var postOrderRequest = new CreateOrderRequest() { OrderDetail = orderDetail };

Expand Down
15 changes: 2 additions & 13 deletions BlazorClient/BlazorClient/Pages/Catalog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,11 @@
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/product/123" class="">Apple</a>
</td>
<td>
172.04
</td>
<td>
169.32
</td>
</tr>
@foreach (var product in products)
@foreach (var product in products)
{
<tr>
<td>
<a href="/product/@product.Id"
<a href="/product/@product.Name/@product.Id"
class="">
@product.Name
</a>
Expand Down
2 changes: 1 addition & 1 deletion BlazorClient/BlazorClient/Pages/CatalogModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected override async Task OnInitializedAsync()
{
Id = x.Id,
Name = x.Name,
BestAsk = x.BestAsk,
BestAsk = priceDefineService.DefineNormalPrice(x.BestAsk),
BestBid = x.BestBid
}).ToList();
}
Expand Down
71 changes: 14 additions & 57 deletions BlazorClient/BlazorClient/Pages/Portfolio.razor
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,23 @@
</tr>
</thead>
<tbody>
<tr>
<td>
123
</td>
<td>
123
</td>
<td>
123
</td>
<td>
123
</td>
<td>
123
</td>
</tr>
@if(portfolio.Total != null)
@if(portfolio.Total != null)
{
<tr>
<td>
@portfolio.Total?.Spent?
@($"{portfolio.Total?.Spent:0.00}")
</td>
<td>
@portfolio.Total?.Earned?
@($"{portfolio.Total?.Earned:0.00}")
</td>
<td>
@portfolio.Total?.Estimate?
@($"{portfolio.Total?.Estimate:0.00}")
</td>
<td>
@portfolio.Total?.DeltaAbs?
@($"{portfolio.Total?.DeltaAbs:0.00}")
</td>
<td>
@portfolio.Total?.DeltaRel?
@($"{portfolio.Total?.DeltaRel:0.00}")
</td>
</tr>
}
Expand Down Expand Up @@ -86,66 +69,40 @@
</tr>
</thead>
<tbody>
<tr>
<th>
Apple
</th>
<td>
123
</td>
<td>
123/<span style="color:gray">123</span>
</td>
<td>
123
</td>
<td>
123
</td>
<td>
123
</td>
<td>
123
</td>
<td>
123
</td>
</tr>
@if(portfolio.Products != null)
@if(portfolio.Products != null)
{
@foreach (var product in portfolio.Products)
{
<tr>
<td>
<a href="/product/@product.Id"
<a href="/product/@product.Name/@product.Id"
class="">
@product.Name
</a>
</td>
<td>
@{
var price = product.Price == 0 ? "-" : product.Price.ToString();
var price = product.Price <= 0 ? "-" : product.Price.ToString();
}
@price
</td>
<td>
@product.VolumeActive/<span style="color:gray">@product.VolumeFrozen</span>
</td>
<td>
@product.Spent
@($"{product.Spent:0.00}")
</td>
<td>
@product.Earned
@($"{product.Earned:0.00}")
</td>
<td>
@product.Estimate
@($"{product.Estimate:0.00}")
</td>
<td>
@product.DeltaAbs
@($"{product.DeltaAbs:0.00}")
</td>
<td>
@product.DeltaRel
@($"{product.DeltaRel:0.00}")
</td>
</tr>
}
Expand Down
4 changes: 2 additions & 2 deletions BlazorClient/BlazorClient/Pages/PortfolioModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected override async Task OnInitializedAsync()
var headers = new Metadata();
headers.Add("Authorization", $"Bearer {token.AccessToken}");

getPortfolioResponse = await Client.GetPortfolioAsync(new GetPortfolioRequest());
getPortfolioResponse = await Client.GetPortfolioAsync(new GetPortfolioRequest(), headers);

if (getPortfolioResponse == null || getPortfolioResponse.Error != null)
{
Expand All @@ -43,7 +43,7 @@ protected override async Task OnInitializedAsync()
VolumeFrozen = x.VolumeFrozen,
Spent = x.Spent,
Earned = x.Earned,
Price = x.BestAsk,
Price = priceDefineService.DefineNormalPrice(x.BestAsk),
Estimate = x.Estimate,
DeltaAbs = x.DeltaAbs,
DeltaRel = x.DeltaRel
Expand Down
8 changes: 6 additions & 2 deletions BlazorClient/BlazorClient/Pages/Product.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/product/{Id}"
@page "/product/{Name}/{Id}"
@using Orders
<PostOrderModal @ref="Modal"></PostOrderModal>
<div class="container-fluid">
Expand All @@ -9,7 +9,7 @@
<div class="card card-primary card-outline">
<div class="card-body box-profile">

<h3 class="profile-username text-center">Apple</h3>
<h3 class="profile-username text-center">@Name</h3>

<ul class="list-group list-group-unbordered mb-3">
<li class="list-group-item">
Expand Down Expand Up @@ -113,5 +113,9 @@
@code {
[Parameter]
public string? Id { get; set; }

[Parameter]
public string? Name { get; set; }
public Components.PostOrderModal Modal { get; set; }

}
2 changes: 1 addition & 1 deletion BlazorClient/BlazorClient/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"FacadeBaseURL": "https://185.137.234.190:20001"
"FacadeBaseURL": "https://localhost:20001"
}
8 changes: 6 additions & 2 deletions Facade/Facade/Facade.Web/GrpcServices/Orders/OrderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ public OrderService(IOptionsMonitor<ServiceUrls> optionsMonitor)
_client = new OrdersService.OrdersServiceClient(channel);
}

public override async Task<CreateOrderResponse> CreateOrder(CreateOrderRequest request, ServerCallContext context) =>
await _client.CreateOrderAsync(request);
public override async Task<CreateOrderResponse> CreateOrder(CreateOrderRequest request, ServerCallContext context)
{
var investorId = context.GetHttpContext().User.Claims.FirstOrDefault(x => x.Type == "id")!.Value;
request.OrderDetail.InvestorId = investorId;
return await _client.CreateOrderAsync(request);
}

public override async Task<ProductInfoResponse> GetProductsInfo(ProductInfoRequest request, ServerCallContext context) =>
await _client.GetProductsInfoAsync(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private async Task<OperationResult<ChangePortfolioResponse>> TryAddProduct(Chang
Error = new Error()
{
ErrorMessage = result?.Exception?.Message ?? alternativeText,
StackTrace = result?.Exception?.StackTrace ?? new Exception().StackTrace
StackTrace = result?.Exception?.StackTrace ?? "No stack trace"
}
};
}
Expand Down
12 changes: 6 additions & 6 deletions Facade/Facade/Facade.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@


"AuthServer": {
"Url": "https://185.137.234.190:5001"
"Url": "https://localhost:10001"
},
"AllowedHosts": "*",
"ServiceUrls": {
"AuthService": "https://185.137.234.190:5001/connect/token",
"ProductService": "https://localhost:35001",
"PortfolioService": "https://185.137.234.190:35001",
"BalanceService" : "https://185.137.234.190:30001",
"OrdersService" : "https://185.137.234.190:37001"
"AuthService": "https://localhost:10001/connect/token",
"ProductService": "https://localhost:36001",
"PortfolioService": "https://localhost:35001",
"BalanceService" : "https://localhost:30001",
"OrdersService" : "https://localhost:7044"
}
}
3 changes: 3 additions & 0 deletions Kafka/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ services:
kafka-topics --bootstrap-server broker:29092 --create --if-not-exists --topic Product_Created --replication-factor 1 --partitions 1
kafka-topics --bootstrap-server broker:29092 --create --if-not-exists --topic Orders_Executed --replication-factor 1 --partitions 1
kafka-topics --bootstrap-server broker:29092 --create --if-not-exists --topic Auth_Register --replication-factor 1 --partitions 1
echo -e 'Successfully created topics'
kafka-topics --bootstrap-server broker:29092 --list
"
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,38 @@ public Task StartAsync(CancellationToken cancellationToken)

private async Task ConsumeEvents(CancellationToken token)
{
_consumer.Subscribe(_topic);
try
{
_consumer.Subscribe(_topic);

ConsumeResult<TKey, TValue> result = null;
ConsumeResult<TKey, TValue> result = null;

while (!token.IsCancellationRequested)
{
result = _consumer.Consume(token);
if (result == null)
continue;

Console.WriteLine($"From consumer: message value: {result.Message.Value}");
var processResult = await _handler.ProcessAsync(result.Message);

if (processResult.Ok)
_consumer.Commit(result);
}

while (!token.IsCancellationRequested)
{
result = _consumer.Consume(token);
if (result == null)
continue;
return;

Console.WriteLine($"From consumer: message value: {result.Message.Value}");
await _handler.ProcessAsync(result.Message);
// We do commit before invoke close method (if autocommit is disable)
// because Close() method informs consumer group coordinator about changing
// consumers number so after that rebalancing starts
_consumer.Commit(result);
_consumer.Close();
}
catch(Exception ex)
{
Console.WriteLine($"Error while start kafka: {ex?.Message}");
}

if (result == null)
return;

// We do commit before invoke close method (if autocommit is disable)
// because Close() method informs consumer group coordinator about changing
// consumers number so after that rebalancing starts
_consumer.Commit(result);
_consumer.Close();
}

public void Dispose()
Expand Down
Loading

0 comments on commit f3d869a

Please sign in to comment.