Retrieving Well Test Records

Any external system can retrieve well test records using the CygNet.API.WellTest.

The CygNet.API.WellTest has two helper functions that can be used to retrieve well test records:

Example

The following C# code example demonstrates the use of these helper functions. Customize this example for your own system.

Copy
GetAllWellTest and GetWellTestsForWell Functions
public void GetWellTests()
{
    // First, we need to load the well test configuration into the WellTest object.
    // A well-test configuration is a text-based XML string that can be loaded from
    // either a local file path, a BSS file path, or a CygNet Point.  It is envisioned
    // that the point-based storage method will be the method of choice.
     
    // Create a WellTest object.  This object is located in CygNet.API.WellTest
    WellTest wellTest = new WellTest();
     
    // Example:  To load a configuration from a local path
    // string localPath = @"X:\CygNet\Source\ToolkitAPIs\CygNet.API.WellTest\CygNet.API.WellTest.UnitTest\WellTestConfigSample.xml";
    // bool localPathLoad = wellTest.Load(localPath, Helpers.FileSource.Local);
     
    // Example:  To load a configuration from a BSS path
    // string bssPath = @"C4PROD.BSS\WELLTEST\WellTestConfigSample.xml";
    // bool bssPathLoad = wellTest.Load(bssPath, Helpers.FileSource.BSS);
     
    // To load a configuration from a point path
    string pointPath = @"C4PROD.UIS:WELLTEST_CONFIG_V3";
    bool pointPathLoad = wellTest.Load(pointPath, Helpers.FileSource.Point);
     
    // There are a couple of helper functions to get well tests.
    // The first is to get all the well tests for a specified date range from all wells defined in the well test configuration.
    if (pointPathLoad)
    {
        // Specify the date range
        DateTime endDateTime = DateTime.Now;
        DateTime startDateTime = endDateTime.AddDays(-2);
         
        // Create a container to store the well test
        // The first dictionary key value pair:
        // key:  The facility tag of the well (i.e. Site.Service::FacilityID)
        // value: List of well tests
        // The second dictionary key value pair in the well test list:
        // key: type of value (i.e. OIL, WATER, GAS, DURATION, DATETIME, or STATUS)
        // value: the value for the type
        //
        // *** Note, this structure could change if we incorporate units into the well test record. ***
        Dictionary<string, List<Dictionary<string, string>>> allWellTests = new Dictionary<string, List<Dictionary<string, string>>>();
         
        // Issue the method to get all well tests
        if (wellTest.GetAllWellTests(startDateTime, endDateTime, out allWellTests, out string error))
        {
            // Iterate each well
            foreach (KeyValuePair<string, List<Dictionary<string, string>>> facilityWellTestContainer in allWellTests)
            {
                // Get the facility tag string
                string facilityTagString = facilityWellTestContainer.Key;
             
                // Iterate each well test for the facility
                foreach (Dictionary<string, string> wellTestRecord in facilityWellTestContainer.Value)
                {
                    // Process the well test record
                 
                    // Get the OIL value
                    string Oil = string.Empty;
                    if (wellTestRecord.ContainsKey("OIL"))
                    {
                        Oil = wellTestRecord["OIL"];
                    }
                     
                    // Get the WATER value
                    string Water = string.Empty;
                    if (wellTestRecord.ContainsKey("WATER"))
                    {
                        Water = wellTestRecord["WATER"];
                    }
                     
                    // Get the GAS value
                    string Gas = string.Empty;
                    if (wellTestRecord.ContainsKey("GAS"))
                    {
                        Gas = wellTestRecord["GAS"];
                    }
                     
                    // Get the DURATION value
                    string Duration = string.Empty;
                    if (wellTestRecord.ContainsKey("DURATION"))
                    {
                        Duration = wellTestRecord["DURATION"];
                    }
                     
                    // Get the STATUS value
                    string Status = string.Empty;
                    if (wellTestRecord.ContainsKey("STATUS"))
                    {
                        Status = wellTestRecord["STATUS"];
                    }
             
                    // Get the DATETIME value
                    string DateTime = string.Empty;
                    if (wellTestRecord.ContainsKey("DATETIME"))
                    {
                        DateTime = wellTestRecord["DATETIME"];
                    }
                }
            }
        }
        else
        {
            // The method was not successful, look at the error string for details
        }
    }
         
    // The second helper function is to retrieve the well tests for a specific well
    if (pointPathLoad)
    {
        // Specify the date range
        DateTime endDateTime = DateTime.Now;
        DateTime startDateTime = endDateTime.AddDays(-7);
         
        // Specify well facility tag string
        string facilityTagString = "C4PROD.UIS::AMANDA_WL";
         
        // Create a container to store the well test
        // This is a list of dictionary key value pairs for each well test
        // The dictionary key value pair in the well test list:
        // key:  type of value (i.e. OIL, WATER, GAS, DURATION, DATETIME, or STATUS)
        // value:  the value for the type
        //
        // *** Note, this structure could change if we incorporate units into the well test record. ***
        List<Dictionary<string, string>> wellTests = new List<Dictionary<string, string>>();
         
        // Issue the method to get all well tests for specified well
        if (wellTest.GetWellTestsForWell(facilityTagString, startDateTime, endDateTime, out wellTests, out string error))
        {
            // Iterate each well test for the facility
            foreach (Dictionary<string, string> wellTestRecord in wellTests)
            {
                // Process the well test record
             
                // Get the OIL value
                string Oil = string.Empty;
                if (wellTestRecord.ContainsKey("OIL"))
                {
                    Oil = wellTestRecord["OIL"];
                }
             
                // Get the WATER value
                string Water = string.Empty;
                if (wellTestRecord.ContainsKey("WATER"))
                {
                    Water = wellTestRecord["WATER"];
                }
                 
                // Get the GAS value
                string Gas = string.Empty;
                if (wellTestRecord.ContainsKey("GAS"))
                {
                    Gas = wellTestRecord["GAS"];
                }
                 
                // Get the DURATION value
                string Duration = string.Empty;
                if (wellTestRecord.ContainsKey("DURATION"))
                {
                    Duration = wellTestRecord["DURATION"];
                }
                 
                // Get the STATUS value
                string Status = string.Empty;
                if (wellTestRecord.ContainsKey("STATUS"))
                {
                    Status = wellTestRecord["STATUS"];
                }
                 
                // Get the DATETIME value
                string DateTime = string.Empty;
                if (wellTestRecord.ContainsKey("DATETIME"))
                {
                    DateTime = wellTestRecord["DATETIME"];
                }
            }
        }
        else
        {
            // The method was not successful, look at the error string for details
        }
    }
}

Back to top