The project includes a Blazor WebAssembly front-end application and a gRPC back-end service. The front-end application allows users to select wells and retrieve detailed information, and also supports manual input of well IDs.
- .NET 6.0 or higher
- Visual Studio 2022 or Visual Studio Code
- gRPC tools
-
Clone the project repository to your local machine:
cd p7api
-
Install the required .NET packages:
dotnet restore
GrpcGreeter
: gRPC server project providing structure and well-related data services.p7api
: API gateway project that calls gRPC services and provides RESTful APIs.BlazorFrontend
: Blazor WebAssembly front-end project for user interaction and data display.
Ensure that the Protobuf files are correctly configured in the project's .csproj
file:
<ItemGroup>
<Protobuf Include="Protos\wells.proto" GrpcServices="Both" />
<Protobuf Include="Protos\structure.proto" GrpcServices="Both" />
</ItemGroup>
Configure the gRPC server in the GrpcGreeter
project's Program.cs
file:
builder.Services.AddGrpc();
Configure the gRPC client and CORS in the p7api
project's Program.cs
file:
builder.Services.AddGrpcClient<StructureService.StructureServiceClient>(options =>
{
options.Address = new Uri("https://localhost:7004");
});
builder.Services.AddGrpcClient<WellService.WellServiceClient>(options =>
{
options.Address = new Uri("https://localhost:7004");
});
Ensure the front-end Blazor WebAssembly project is correctly configured.
Before starting the project, you need to obtain a user token by logging in to https://tj06.evt.slb.com/msd
using your browser. Copy the token and paste it into the Program.cs
file of the GrpcGreeter
project:
builder.Services.AddHttpClient("WellFetchApiClient", client =>
{
client.BaseAddress = new Uri("https://tj06.evt.slb.com/msd/");
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "//paste your token here");
});
- Open the
GrpcGreeter
project in your IDE. - Ensure the token is correctly pasted in
Program.cs
. - Run the project:
dotnet run
- Open the
p7api
project in your IDE. - Run the project:
dotnet run
- Open the
BlazorFronted
project in your IDE. - Run the project:
dotnet run
Sure! Here is an English version of the README.md document for mapping.json
:
The mapping.json
file defines rules for mapping fields from external data sources to internal data models. It contains multiple mapping rules, each defining how to map fields from external data sources to properties in internal data models. The file currently includes two main sections: well_definition
and well_details
.
Each mapping rule consists of the following fields:
MSD_source
: A list that defines data sources. Each data source includes the following two subfields:model
: Specifies the model name of the data source. For example,well
indicates that the data comes from theWellDetail
class.key
: Specifies the property path of the data source. For example,metadata.src
indicates that the data comes from thesrc
sub-property of themetadata
property in theWellDetail
class.
default_value
: The default value to use if the mapped value is not found.method
: Specifies the mapping method. The following methods are supported:"Direct Mapping"
: Direct mapping, using the value from the data source."Increase from 1"
: A field that increments from 1.- others ...
nullable
: Indicates whether the field can be null. Iffalse
, the field cannot be null.description
: Describes the meaning of the field. If the description contains"Fixed fields"
, thevalue
of the field is used directly.value
: The default or example value of the field.need_review
: Indicates whether the field needs manual review.
Below is a partial example of the mapping.json
file:
{
"well_definition": {
"1": {
"MSD_source": null,
"default_value": null,
"method": null,
"nullable": false,
"description": "Fixed fields",
"value": "H7",
"need_review": false
},
"2": {
"MSD_source": null,
"default_value": null,
"method": null,
"nullable": false,
"description": "Fixed fields",
"value": "1",
"need_review": false
}
// Other fields omitted
},
"well_details": {
"1": {
"MSD_source": null,
"default_value": null,
"method": null,
"nullable": false,
"description": "Fixed fields",
"value": "H7",
"need_review": false
},
"2": {
"MSD_source": null,
"default_value": null,
"method": null,
"nullable": false,
"description": "Fixed fields",
"value": "1",
"need_review": false
}
// Other fields omitted
}
}
well_definition
: Defines mapping rules for fields related to well objects(GrpcGreeterClient.Wells.Well).well_details
: Defines mapping rules for fields related to well details .
The latest rule library is in the formated_map.json file, but it is not complete and needs further proofreading and supplementation
When the rule library is updated, corresponding updates need to be made in the code project file \p7api\mapping.json