public void BlankRecordSetData(string colName) { IIndexIterator ii = _internalObj.Keys; if (colName != null) { Dev2Column cc = Columns.FirstOrDefault(c => c.ColumnName == colName); if (cc != null) { while (ii.HasMore()) { int next = ii.FetchNextIndex(); // now blank all values at this location IBinaryDataListItem itm = Dev2BinaryDataListFactory.CreateBinaryItem(string.Empty, Namespace, cc.ColumnName, next); string error; TryPutRecordItemAtIndex(itm, next, out error); } } else { ClearAll(ii); } } else { ClearAll(ii); } }
public void Sort(string field, bool desc, out string error) { // INFO : http://stackoverflow.com/questions/925471/c-sharp-help-sorting-a-list-of-objects-in-c-sharp error = string.Empty; Dev2Column col = Columns.FirstOrDefault(c => c.ColumnName == field); IDictionary <int, IList <IBinaryDataListItem> > toSort = _internalObj.FetchSortData(); IDictionary <int, IList <IBinaryDataListItem> > sortedData = null; if (col != null) { int colIdx = Columns.IndexOf(col); // Port of per DLS approach -- Technical debt // Int try { sortedData = GenericSort(toSort, colIdx, desc, GetIntSortValue); } catch (Exception) { try { sortedData = GenericSort(toSort, colIdx, desc, GetFloatSortValue); } catch (Exception) { // DateTime try { sortedData = GenericSort(toSort, colIdx, desc, GetDateTimeSortValue); } catch (Exception) { // String try { sortedData = GenericSort(toSort, colIdx, desc, GetStringSortValue); } catch (Exception ex) { // Very naughty thing have happened.... error = "Invalid format for sorting on field [ " + field + " ] "; Dev2Logger.Log.Error(ex); } } } } // apply the update ;) _internalObj.ApplySortAction(sortedData); } }
/// <summary> /// Tries the fetch indexed recordset upsert payload. /// </summary> /// <param name="idx">The idx.</param> /// <param name="error">The error.</param> /// <returns></returns> IBinaryDataListItem InternalFetchIndexedRecordsetUpsertPayload(int idx, out string error) { // in this case there is a single row, with a single column's data to extract Dev2Column col = Columns.FirstOrDefault(); error = string.Empty; if (col != null) { IBinaryDataListItem result = TryFetchRecordsetColumnAtIndex(col.ColumnName, idx, out error); return(result); } return(null); }
public void TryAppendRecordItem(IBinaryDataListItem item, out string error) { error = "Is not recordset"; if (IsRecordset) { Dev2Column colToFind = Columns.FirstOrDefault(c => c.ColumnName == item.FieldName); if (colToFind != null) { _internalObj.Keys.RemoveGap(FetchAppendRecordsetIndex()); _internalObj[FetchAppendRecordsetIndex()] = new List <IBinaryDataListItem> { item }; error = string.Empty; _internalObj.IsEmtpy = false; } else { error = "Mapping error: Column not found " + item.FieldName; } } }
public bool TryCreateRecordsetValue(string value, string fieldName, string theNameSpace, int idx, out string error) { IBinaryDataListEntry tmp; bool result = false; string key = theNameSpace; if (_templateDict.TryGetValue(key, out tmp)) { if (tmp.IsRecordset) { IList <Dev2Column> columns = tmp.Columns; Dev2Column found = columns.FirstOrDefault(column => String.Equals(column.ColumnName, fieldName, StringComparison.Ordinal)); if (found != null) { tmp.TryPutRecordItemAtIndex(new BinaryDataListItem(value, theNameSpace, fieldName, idx), idx, out error); _templateDict[key] = tmp; // update dic result = true; error = string.Empty; } else { error = "Cannot locate field [ " + fieldName + " ] on recordset [ " + theNameSpace + " ] "; } } else { error = "Cannot add recordset to scalar"; } } else { error = "Could not locate recordset template for [ " + value + " ]"; } return(result); }