private void LoadHeader(string json) { List <ReferenceTable> dataTypeRefs = _references.Where(x => x.DataType == "WellBore").ToList(); foreach (ReferenceTable reference in dataTypeRefs) { json = CheckHeaderForeignKeys(json, reference); } DataAccessDef dataType = _dataDef.First(x => x.DataType == "WellBore"); string tmpUwi = Common.FixAposInStrings(_uwi); string select = dataType.Select; string query = $" where UWI = '{tmpUwi}'"; DataTable dt = _dbConn.GetDataTable(select, query); if (dt.Rows.Count == 0) { json = Common.SetJsonDataObjectDate(json, "ROW_CREATED_DATE"); json = Common.SetJsonDataObjectDate(json, "ROW_CHANGED_DATE"); JObject jo = JObject.Parse(json); foreach (JProperty property in jo.Properties()) { string strValue = property.Value.ToString(); if (string.IsNullOrEmpty(strValue)) { property.Value = null; } } json = jo.ToString(); _dbConn.InsertDataObject(json, "WellBore"); } }
private void InsertMissingObjectToDatabase(PredictionResult result) { string jsonDataObject = result.DataObject; JObject dataObject = JObject.Parse(jsonDataObject); dataObject["ROW_CHANGED_BY"] = Environment.UserName; dataObject["ROW_CREATED_BY"] = Environment.UserName; jsonDataObject = dataObject.ToString(); jsonDataObject = Helpers.Common.SetJsonDataObjectDate(jsonDataObject, "ROW_CHANGED_DATE"); jsonDataObject = Helpers.Common.SetJsonDataObjectDate(jsonDataObject, "ROW_CREATED_DATE"); string dataType = result.DataType; try { _dbConn.InsertDataObject(jsonDataObject, dataType); } catch (Exception ex) { throw; } }