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 mtls & api key creation docid\ hro4lnngi79gn1ww2y ma visual studio 2022 community edition internet connection get the code samples docid\ lccfpr254t0 b8pobosk9 data schema please read the data schema fundamentals docid\ irzm o cyhcgjw5athv1 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 fundamentals docid\ irzm o cyhcgjw5athv1 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 https //\<tenant> app onxecta com/ the portal contains a model quality docid\ jxhsila0ecxifrjb4g l6 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 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 on the nuget window > browse > search for xecta platform dataclient > select latest 2 x version 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 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 // 3 3 1 add a new well to the well header table // create and upsert 2 well headers var wells = new list\<wellinput>(); wells add(new wellinput( sourceid "db id well 001", uwi "00123456789120", name "example producer well 1", lat 0, lon 0, group1 "bakken operations", group2 "route a", group3 "example well pad", fluid wellinput fluidenum oil, type wellinput typeenum producer, lifttype wellinput lifttypeenum naturalflow ) ); wells add(new wellinput( sourceid "db id well 002", uwi "00123456789121", name "example producer well 2", lat 0, lon 0, group1 "bakken operations", group2 "route a", group3 "example well pad", fluid wellinput fluidenum oil, type wellinput typeenum producer, lifttype wellinput lifttypeenum naturalflow ) ); // upsert wells var upsertedwells = await client wellheaderapi() upsertwellsasync(wells); console writeline("added " + wells count + " wells"); foreach (var well in upsertedwells) console writeline(well sourceid + " | " + well name); 3 2 get well headers // 3 3 2 get all wells from well header table try { // get a list of well headers var welllist = await client wellheaderapi() getwellsasync(); console writeline("found " + welllist count + " wells"); foreach (var wellheader in welllist) console writeline(wellheader name); } catch (exception ex) { // most likely an authentication error console writeline(ex tostring()); environment exit(1); } 3 3 delete well header // 3 3 3 delete a well from the well header table try { // delete well header const string wellsourcesystemid = "db id well 002"; await client wellheaderapi() deletewellbysourceasync(wellsourcesystemid); console writeline("deleted well " + wellsourcesystemid); } catch (exception ex) { console writeline(ex tostring()); environment exit(1); } 3 4 delete well headers the snippet below will delete all wells from the database the snippet below will delete all wells from the database do not use this snippet unless you have a real world use case 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 4 2 get wellbores // 4 4 2 get wellbore(s) try { const string sourcewellid = "db id well 001"; //< required well id/primary key from your source database const string sourceboreid = "db id well 001 bore 0"; var boresforwell = await client wellboreapi() getwellborbysourceasync(sourcewellid, sourceboreid); console writeline("found " + boresforwell name + " wellbore for well " + sourcewellid); } catch (exception ex) { // most likely the well source system id did not exist in well header table console writeline(ex tostring()); environment exit(1); } 4 3 delete wellbore 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 // 5 5 1 create wellbore formation info try { const string defaultwellid = "db id well 001"; const string defaultboreid = "db id well 001 bore 0"; //< required bore id/primary key from your source database var formationproperties = new list\<formationinput>(); formationproperties add(new formationinput( sourcewellid defaultwellid, sourcewellboreid defaultboreid, name defaultboreid, allocationfactor 1, compressibilityrock 0 000006, depth 7200, fluidcomingledgor 7200, fluidgravityapi 38, fluidgravitygas 0 78, fluidmolarfracco2 0 002, fluidmolarfrach2s 0 01, fluidmolarfracn2 0 002, fluidsalinitywater 50000, porosity 0 08, pressureformationinitialdatum 5200, primaryfluidtype formationinput primaryfluidtypeenum oil, rsi 800, saturationgasinitial 0 1, saturationoilinitial 0 4, saturationwaterinitial 0 5, temperatureformationdatum 218, thicknessformation 180, volumeacquiferinitial 0 )); // upsert new wellbore formation info await client wellboreformationapi() upsertformationsasync(formationproperties); console writeline("wellbore formation info updated " + defaultboreid); } catch (exception ex) { // most likely the wellbore id did not exist console writeline(ex tostring()); environment exit(1); } 5 2 get wellbore formation // 5 5 2 get wellbore formation info try { const string sourcewellid = "db id well 001"; //< required well id/primary key from your source database const string sourceboreid = "db id well 001 bore 0"; //< required bore id/primary key from your source database var formationproperties = await client wellboreformationapi() getformationsbywellasync(sourcewellid); if (formationproperties count > 0) console writeline("found formation info for " + formationproperties\[0] name); else console writeline("no formation info found for " + sourcewellid); } catch (exception ex) { // most likely the wellbore id did not exist console writeline(ex tostring()); } 5 3 delete wellbore formation // 5 5 3 delete wellbore formation info try { const string sourcewellid = "db id well 001"; //< required well id/primary key from your source database const string sourceboreid = "db id well 001 bore 0"; //< required bore id/primary key from your source database await client wellboreformationapi() deleteformationbysourcewellboreasync(sourcewellid, sourceboreid); console writeline("deleted formation info for " + sourceboreid); } catch (exception ex) { // most likely the wellbore id did not exist console writeline(ex tostring()); environment exit(1); } 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 6 2 get survey // 6 6 2 get a deviation survey try { // get deviation survey const string sourcewellid = "db id well 001"; //< required well id/primary key from your source database const string sourceboreid = "db id well 001 bore 0"; //< required bore id/primary key from your source database var survey = await client deviationsurveyapi() getdeviationsurveybysourcewellboreasync(sourcewellid, sourceboreid); console writeline("found deviation survey for " + sourceboreid + " found " + survey count + " survey points"); } catch (exception ex) { // most likely the wellbore id did not exist console writeline(ex tostring()); environment exit(1); } 6 3 delete survey // 6 6 3 delete a deviation survey try { const string sourcewellid = "db id well 001"; //< required well id/primary key from your source database const string sourceboreid = "db id well 001 bore 0"; //< required bore id/primary key from your source database await client deviationsurveyapi() deletedeviationsurveysbysourcewellboreasync(sourcewellid, sourceboreid); console writeline("survey deleted for " + sourceboreid); } catch (exception ex) { // most likely the wellbore id did not exist // if you delete a wellbore console writeline(ex tostring()); environment exit(1); } 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 // 7 7 1 add casing to the wellbore try { const string sourcewellid = "db id well 001"; //< required well id/primary key from your source database const string sourceboreid = "db id well 001 bore 0"; //< required bore id/primary key from your source database var wellborecasing = new list\<casinginput>(); for (var i = 0; i < 10; i++) { wellborecasing add(new casinginput( sourcewellid sourcewellid, //< required sourcewellboreid sourceboreid, //< required sourceid "db id well 001 bore 0 cas " + i, //< required must be unique topmd i, //< required bottommd i + 1, //< required od 5, // //< requiredouter diameter of the casing id 3, // //< requiredinner diameter of the casing roughness i, //< required friction use 0 if not available rundate datetime today //installation date ) ); } // upsert casing console writeline("upserting the wellbore casing for " \+ sourceboreid + " this may take a few seconds "); await client wellborecasingapi() upsertcasingasync(wellborecasing); console writeline("casing created for " + sourceboreid); } catch (exception ex) { // most likely the wellbore id did not exist console writeline(ex tostring()); environment exit(1); } 7 2 get casing // 7 7 2 get casing for the wellbore try { // get casing const string sourcewellid = "db id well 001"; //< required well id/primary key from your source database const string sourceboreid = "db id well 001 bore 0"; //< required bore id/primary key from your source database var wellborecasing = await client wellborecasingapi() getcasingbysourcewellboreasync(sourcewellid, sourceboreid); console writeline("found casing for " + sourceboreid + " found " + wellborecasing count + " records"); } catch (exception ex) { // most likely the wellbore id did not exist console writeline(ex tostring()); environment exit(1); } 7 3 delete casing 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 // 8 8 1 add tubing to the wellbore try { const string sourcewellid = "db id well 001"; //< required well id/primary key from your source database const string sourceboreid = "db id well 001 bore 0"; //< required bore id/primary key from your source database var wellboretubing = new list\<tubinginput>(); for (var i = 0; i < 10; i++) { wellboretubing add(new tubinginput( sourcewellid sourcewellid, //< required sourcewellboreid sourceboreid, //< required sourceid "db id well 001 bore 0 tub " + i, //< required must be unique for each object topmd i, //< required bottommd i + 1, //< required od 4, // //< required outer diameter of the tubing id 2, // //< required inner diameter of the tubing roughness i, //< required friction use 0 if not available rundate datetime today //installation date ) ); } // upsert tubing console writeline("upserting the wellbore tubing for " \+ sourceboreid + " this may take a few seconds "); await client wellboretubingapi() upserttubingasync(wellboretubing); console writeline("tubing created for " + sourceboreid); } catch (exception ex) { // most likely the wellbore id did not exist console writeline(ex tostring()); environment exit(1); } 8 2 get tubing 8 3 delete tubing 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) 9 2 upsert production records (multiple records) 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 9 4 delete production record (single record) 9 5 delete production history (multiple records) 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