/// <inheritdoc /> public ICommenceEditRowSet GetEditRowSetByID(string pRowID, CmcOptionFlags flags = CmcOptionFlags.Default) { ICommenceEditRowSet ers = null; try { ers = new CommenceEditRowSet(_cur, pRowID, _rcwReleasePublisher, flags); } catch (COMException e) { throw new CommenceCOMException("Unable to get a EditRowSet object from Commence", e); } return(ers); }
// violates S in SOLID private bool ProcessRows(ICommenceEditRowSet ers, int rowCount) { bool retval = false; for (int row = 0; row < rowCount; row++) // process Commence rows { var changeResults = new List <FieldModification>(); var rowId = ers.GetRowID(row, CmcOptionFlags.UseThids); // let CmcLibNet do magic. string[] rowValues = string.IsNullOrEmpty(colDelimiter) ? ers.GetRow(row).Cast <string>().ToArray() : ers.GetRow(row, colDelimiter).Cast <string>().ToArray(); // the keys correspond to columns in the cursor for (int column = 0; column < rules.Keys.Count; column++) // process fields in row { var oldValue = rowValues[column]; // rules.Values.ElementAt(c) contains the dictionary of rules for character replacement. var newValue = ReplaceControlCharacters(oldValue, rules.Values.ElementAt(column)); if (!oldValue.Equals(newValue)) // TODO can we make this faster? { var result = ers.ModifyRow(row, column, newValue, CmcOptionFlags.Default); // ModifyRow will truncate strings. //if (result != 0) //{ // throw new CommenceCOMException($"Commence method EditRowSet.ModifyRow() failed on row {row}, column {column}."); //} retval = true; // add new result to temporary changeset changeResults.Add(new FieldModification( CategoryName = this.CategoryName, // notice we pass rowValues[0] as the itemname // that is because the Name field is always the first field to be returned from Commence, // and it is also always present in our test. // it is therefore a little brittle. rowValues[0], // itemname rules.Keys.ElementAt(column), // fieldname oldValue, newValue, result));; } } // add edits made to the row to change log if (changeResults.Any()) { changeLog.ModifiedRows.Add(rowId, changeResults); } } return(retval); }