Developer Docs
API Quick Start Tutorials

C# Tutorial

Author(s): Dhilip Marimuthu and Ian Brown, September 2022

Developer Prerequisites:

  • mTLS Certificate, Client ID and Client Secret Keys (tutorial)
  • Visual Studio 2022 Community Edition
  • Internet connection

Get the complete source code

Data Schema:

Please read the Data Schema Fundamentals document before using the API. Database CRUD operations are performed via the API and therefore it is important to think of each HTTP REST operation (POST/GET/DELETE) as a SQL transaction (UPSERT/SELECT/DELETE).

WellView® and OpenWells® Source Systems:

The API uses original source system IDs as key fields. For WellView and OpenWells data schema documentation provides guidance as to which table/view and which column/value to use as the source system ID. Guidance is provided for the Well Header, Wellbore and all other Wellbore related data sets

WellView is a registered trademark of Peloton Computer Enterprises Ltd. OpenWells is a registered trademark of Halliburton Landmark.

Visualizing Data: Data inserted or modified using this tutorial can be visualized using the web portal application(s) at https://<tenant>.app.onxecta.com. The portal contains a Model Quality tool where you can see what data is in the system, the validity of the data and when the data was last modified.

1 Project Setup

1.1 Project Creation

Create New Project

Open Visual Studio 2022 Community Edition and Create a new C# Console Application

Provide a name for the project e.g., ConsoleApp1

Choose .NET framework version NET 6.0 or higher

Document image

Document image


1.2 Xecta.Platform.Data.Client

On the project Dependencies tree -> Right Click -> Manage NuGet Packages... Follow the stemps below to find and install the Xecta.Platform.Data.Client from NuGet package manager

Document image


On the NuGet Window -> Browse -> Search for Xecta.Platform.DataClient -> Select latest 2.X version.

Document image


2. Connect to API

To connect to the API, you will need:

  • Your PEM File
  • Your KEY File
  • Client ID
  • Client Secret

Open the program.cs - Delete the default Visual Studio "Hello World" code and replace it with the code snippet below

C#


3. Well Header Data

The code snippets in section 2 build on the code snippets used in section 2. The snippets assume you have successfully built and ran the code in Section 2. To read more about Well Headers and to see all of the properties.

3.1 UPSERT Well Headers

Put this code directly below the below the Section 2 code snippet

C#


3.2 GET Well Headers

C#


3.3 DELETE Well Header

C#


3.4 DELETE Well Headers

The snippet below will delete all wells from the database Do not use this snippet unless you have a real-world use case

C#


4. Wellbore

The code snippets below use source Ids from the wells created by the code snippets in Section 3. The snippets assume you have successfully built and ran the code in Section 3. To read more about a Wellbore and to see all of the properties.

A well must exist in the well header table before a wellbore can be added for that well. A well must have at least one wellbore

4.1 UPSERT Wellbore

C#


4.2 GET Wellbores

C#


4.3 DELETE Wellbore

C#


5. Wellbore Formation

A wellbore must exist before the formation data for that wellbore can be created

Wellbore Formation Terminology

Wellbore formation represents the rock properties and the fluid properties within the reservoir (formation) where the wellbore is producing the fluids from.

5.1 UPSERT Wellbore Formation

C#


5.2 GET Wellbore Formation

C#


5.3 DELETE Wellbore Formation

C#


6. Wellbore Deviation Surveys

A wellbore must exist before survey data points can be created for that wellbore. To read more about a Deviation Survey and to see all of the properties.

6.1 UPSERT Survey

C#


6.2 GET Survey

C#


6.3 DELETE Survey

C#


7 Wellbore Casing

A wellbore must exist before the casing information can be created for that wellbore. To read more about a casing and to see all of the properties.

7.1 UPSERT Casing

C#


7.2 GET Casing

C#


7.3 DELETE Casing

C#


8. Wellbore Tubing

A wellbore must exist before the tubing information can be created for that wellbore. To read more about tubing and to see all of the properties.

8.1. UPSERT Tubing

C#


8.2 GET Tubing

C#


8.3 DELETE Tubing

C#


9 Daily Production Records

To read more about daily production records and to see all of the properties.

The daily production is related to the well. Not the wellbore. The well UWI property from the well header is used as the primary key for daily production records

See Section 3 for well header API details

9.1 UPSERT Production Record (single record)

C#


9.2 UPSERT Production Records (multiple records)

C#


9.3 GET Production History

Get Latest Production:



To get the most recent production record you have to get the history and then use the latest record. At the time of writing there is not an end point for Get Latest record.

C#


9.4 DELETE Production Record (single record)

C#


9.5 DELETE Production History (multiple records)

C#


10. Import Data from Excel

The snippet below can run standalone without the other snippets above. The code reads a standard excel template and pushes the data from the excel template to the server. An example MS Excel template file called Excel-Import-Template.xlsx can be found in the Code Samples section.

C#