private void AddWellData(ModelRecord record, FieldParser parser) { using (var conn = new SQLiteConnection(ConnectionString, true)) { conn.Open(); using (var txn = conn.BeginTransaction()) { using (var cmd = new SQLiteCommand(conn)) { cmd.Transaction = txn; foreach (var wi in parser.AllWellInfo) { if (wi.FileNumber.Trim() == string.Empty) { continue; } cmd.CommandText = "INSERT INTO [Wells] VALUES (NULL, $modelID, $wellName, $fileNumber)"; cmd.Parameters.AddWithValue("$modelID", record.ID); cmd.Parameters.AddWithValue("$wellName", wi.WellName); cmd.Parameters.AddWithValue("$fileNumber", wi.FileNumber.Trim()); cmd.ExecuteNonQuery(); int wellID = GetLastInsertRowId(conn); AddPlanVersionData(conn, txn, record, wi, wellID); } } txn.Commit(); } } }
public void UpdateModel(ModelInfo info, FieldParser parser) { var existingModelRecord = GetModelByPath(info.ModelPath); if (existingModelRecord != null) { ClearModelData(existingModelRecord.ID); } UpdateModelTable(info); var newModelRecord = GetModelByPath(info.ModelPath); AddWellData(newModelRecord, parser); SetLastUpdatedTime(); }