Dino Cookbook

Scott Waldron Updated by Scott Waldron

Deferred Evaluation

We'll be expanding the documentation in this section soon. Please contact us if you have questions.

Dynamic Script Integration Points

We'll be expanding the documentation in this section soon. Please contact us if you have questions.

Function Dictionary

Sometimes you have a set of values, and for a given value you want to run a certain function. Rather than a big if-then-else clause, consider putting anonymous functions into a dictionary:

// String - Func dictionary for values that come from the well record.

var m_wellInitVals = dict[string, object](
'187197' : w => DateTime.Now.Date, // TODAY
'190823' : w => w.WellStatusList.LastOrDefault()?.TotalDepth, // TDEPTH
'190824' : w => w.WellStatusList.LastOrDefault()?.PlugbackDepth, // PBTD
'695979' : w => w.WellStatusList.LastOrDefault()?.Perforations, // PERFS
'700013' : w => w.Route?.RouteName, // ROUTE
'700012' : w => w.Facility?.FacilityName // FACILITY
);

// String - Func dictionary for values that come from the well svc proxy.

var m_proxyInitVals = dict[string, object](
'700017' : p => p?.dgm_updated, // DGM_UPDATE_DATE
'700008' : p => p?.open_perf_status, // PERF_STATUS
'695979' : p => {
var top = p?.open_perf_top;
var bot = p?.open_perf_bottom;
if top and bot {
return string.Format('{0}-{1}', top, bot);
}
}, // PERFS
'707035' : p => p?.open_perf_shots, // PERF_SHOTS
'695977' : p => p?.gl ? 'GL' : 'KB', // REF_DATUM
'697919' : p => p?.gl ? p.gl : p?.kb, // REF_ELEV
'705626' : p => p?.prod_tube_date, // CASING_UPDATE_DATE
'190827' : p => p?.prod_tube_od, // CASING_OD
'193184' : p => p?.prod_tube_wt, // CASING_WEIGHT
'707932' : p => p?.prod_tube_joints, // CASING_JOINTS
'194068' : p => p?.prod_tube_top, // CASING_TOP
'194069' : p => p?.prod_tube_bottom, // CASING_BOTTOM
'702703' : p => p?.tube_tube_date, // TUBING_UPDATE_DATE
'190667' : p => p?.tube_tube_od, // TUBING_OD
'702702' : p => p?.tube_tube_wt, // TUBING_WEIGHT
'194315' : p => p?.tube_tube_grade, // TUBING_GRADE
'695970' : p => p?.tube_tube_joints, // TUBING_JOINTS
'707477' : p => p?.tube_tube_top, // TUBING_TOP
'707478' : p => p?.tube_tube_bottom // TUBING_BOTTOM
);

// Runs when the field is first added to the form.

def initWellSvcField(form, f) {
var well = getWell(form);
var p = getWellSvcProxy(well);
var val = null;
each k, func in m_wellInitVals {
if f.IsField(k) {
val = func(well);
break;

}
}
if null == val or val == '' {
each k, func in m_proxyInitVals {
if f.IsField(k) {
val = func(p);
break;
}
}

}
if null != val {
f.SetValue(val);
}
}

How did we do?

FAQ

Sandbox In-Depth

Contact