/// <summary> /// Creates the list of data list item view model to bind to. /// </summary> /// <param name="errorString">The error string.</param> /// <returns></returns> public void CreateListsOfIDataListItemModelToBindTo(out string errorString) { errorString = string.Empty; IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); if (!string.IsNullOrEmpty(Resource.DataList)) { ErrorResultTO errors = new ErrorResultTO(); try { IBinaryDataList binarnyDl = CreateBinaryDataListFromXmlData(Resource.DataList, out errors); if (!errors.HasErrors()) { ConvertBinaryDataListToListOfIDataListItemModels(binarnyDl, out errorString); } else { string errorMessage = errors.FetchErrors().Aggregate(string.Empty, (current, error) => current + error); throw new Exception(errorMessage); } if (binarnyDl != null) { compiler.ForceDeleteDataListByID(binarnyDl.UID); } } catch (Exception) { errors.AddError("Invalid variable list. Please insure that your variable list has valid entries"); } } else { RecsetCollection.Clear(); AddRecordSet(); ScalarCollection.Clear(); } BaseCollection = new OptomizedObservableCollection <DataListHeaderItemModel>(); DataListHeaderItemModel varNode = DataListItemModelFactory.CreateDataListHeaderItem("Variable"); if (ScalarCollection.Count == 0) { var dataListItemModel = DataListItemModelFactory.CreateDataListModel(string.Empty); ScalarCollection.Add(dataListItemModel); } varNode.Children = ScalarCollection; BaseCollection.Add(varNode); //AddRecordsetNamesIfMissing(); DataListHeaderItemModel recordsetsNode = DataListItemModelFactory.CreateDataListHeaderItem("Recordset"); if (RecsetCollection.Count == 0) { AddRecordSet(); } recordsetsNode.Children = RecsetCollection; BaseCollection.Add(recordsetsNode); }
/// <summary> /// Creates the list of data list item view model to bind to. /// </summary> /// <param name="errorString">The error string.</param> /// <returns></returns> public void CreateListsOfIDataListItemModelToBindTo(out string errorString) { errorString = string.Empty; if (!string.IsNullOrEmpty(Resource.DataList)) { ErrorResultTO errors = new ErrorResultTO(); try { if (!string.IsNullOrEmpty(Resource.DataList)) { ConvertDataListStringToCollections(Resource.DataList); } } catch (Exception) { errors.AddError(ErrorResource.InvalidVariableList); } } else { RecsetCollection.Clear(); ScalarCollection.Clear(); ComplexObjectCollection.Clear(); _recordsetHandler.AddRecordSet(); } BaseCollection = new OptomizedObservableCollection <DataListHeaderItemModel>(); DataListHeaderItemModel variableNode = DataListItemModelFactory.CreateDataListHeaderItem("Variable"); if (ScalarCollection.Count == 0) { IScalarItemModel dataListItemModel = DataListItemModelFactory.CreateScalarItemModel(string.Empty); dataListItemModel.IsComplexObject = false; dataListItemModel.AllowNotes = false; ScalarCollection.Add(dataListItemModel); } BaseCollection.Add(variableNode); DataListHeaderItemModel recordsetsNode = DataListItemModelFactory.CreateDataListHeaderItem("Recordset"); if (RecsetCollection.Count == 0) { _recordsetHandler.AddRecordSet(); } BaseCollection.Add(recordsetsNode); DataListHeaderItemModel complexObjectNode = DataListItemModelFactory.CreateDataListHeaderItem("Object"); BaseCollection.Add(complexObjectNode); AddBlankRow(null); BaseCollection[0].Children = ScalarCollection; BaseCollection[1].Children = RecsetCollection; BaseCollection[2].Children = ComplexObjectCollection; WriteToResourceModel(); }
/// <summary> /// Sorts the scalars. /// </summary> private void SortScalars() { IList <IDataListItemModel> newScalarCollection = ScalarCollection.OrderBy(c => c.DisplayName).Where(c => !c.IsBlank).ToList(); ScalarCollection.Clear(); foreach (IDataListItemModel item in newScalarCollection) { ScalarCollection.Add(item); } ScalarCollection.Add(DataListItemModelFactory.CreateDataListModel(string.Empty)); }
private void AddRowToScalars() { IList <IDataListItemModel> blankList = ScalarCollection.Where(c => c.IsBlank).ToList(); if (blankList.Count == 0) { IDataListItemModel scalar = DataListItemModelFactory.CreateDataListModel(string.Empty); ScalarCollection.Add(scalar); Validator.Add(scalar); } }
void AddRowToScalars() { List <IDataListItemModel> blankList = ScalarCollection.Where(c => c.IsBlank).ToList(); if (blankList.Count != 0) { return; } IDataListItemModel scalar = DataListItemModelFactory.CreateDataListModel(string.Empty); ScalarCollection.Add(scalar); }
/// <summary> /// Creates the list of data list item view model to bind to. /// </summary> /// <param name="_resource">The resource model.</param> /// <param name="errorString">The error string.</param> /// <returns></returns> private void CreateListsOfIDataListItemModelToBindTo(out string errorString) { ErrorResultTO errors = new ErrorResultTO(); errorString = string.Empty; if (!string.IsNullOrEmpty(_resource.DataList)) { IBinaryDataList binarnyDL = CreateBinaryDataListFromXmlData(_resource.DataList, out errors); if (!errors.HasErrors()) { ConvertBinaryDataListToListOfIDataListItemModels(binarnyDL, out errorString); } else { string errorMessage = string.Empty; foreach (string error in errors.FetchErrors()) { errorMessage += error; } throw new Exception(errorMessage); } _compiler.ForceDeleteDataListByID(binarnyDL.UID); } else { RecsetCollection = new OptomizedObservableCollection <IDataListItemModel>(); AddRecordSet(); ScalarCollection = new OptomizedObservableCollection <IDataListItemModel>(); ScalarCollection.Add(DataListItemModelFactory.CreateDataListModel(string.Empty)); } BaseCollection = new OptomizedObservableCollection <DataListHeaderItemModel>(); DataListHeaderItemModel VarNode = DataListItemModelFactory.CreateDataListHeaderItem("Variables"); if (ScalarCollection.Count == 0) { ScalarCollection.Add(DataListItemModelFactory.CreateDataListModel(string.Empty)); } VarNode.Children = ScalarCollection; BaseCollection.Add(VarNode); DataListHeaderItemModel RecordsetsNode = DataListItemModelFactory.CreateDataListHeaderItem("Recordsets"); if (RecsetCollection.Count == 0) { AddRecordSet(); } RecordsetsNode.Children = RecsetCollection; BaseCollection.Add(RecordsetsNode); }
/// <summary> /// Sorts the scalars. /// </summary> private void SortScalars(bool ascending) { IList <IDataListItemModel> newScalarCollection; if (ascending) { newScalarCollection = ScalarCollection.OrderBy(c => c.DisplayName) .Where(c => !c.IsBlank).ToList(); } else { newScalarCollection = ScalarCollection.OrderByDescending(c => c.DisplayName) .Where(c => !c.IsBlank).ToList(); } ScalarCollection.Clear(); foreach (var item in newScalarCollection) { ScalarCollection.Add(item); } ScalarCollection.Add(DataListItemModelFactory.CreateDataListModel(string.Empty)); }
/// <summary> /// Converts a binary data list to list a data list item view models. /// </summary> /// <param name="dataListToConvert">The data list to convert.</param> /// <param name="errorString">The error string.</param> /// <returns></returns> private void ConvertBinaryDataListToListOfIDataListItemModels(IBinaryDataList dataListToConvert, out string errorString) { errorString = string.Empty; RecsetCollection.Clear(); ScalarCollection.Clear(); IList <IBinaryDataListEntry> listOfEntries = dataListToConvert.FetchAllEntries(); foreach (var entry in listOfEntries) { if (entry.IsRecordset) { var recset = DataListItemModelFactory.CreateDataListModel(entry.Namespace, entry.Description, entry.ColumnIODirection); recset.IsEditable = entry.IsEditable; foreach (var col in entry.Columns) { var child = DataListItemModelFactory.CreateDataListModel(col.ColumnName, col.ColumnDescription, col.ColumnIODirection); child.Parent = recset; child.IsEditable = col.IsEditable; recset.Children.Add(child); } RecsetCollection.Add(recset); } else { var scalar = DataListItemModelFactory.CreateDataListModel(entry.Namespace, entry.Description, entry.ColumnIODirection); scalar.IsEditable = entry.IsEditable; ScalarCollection.Add(scalar); } } }