private void LoadGroups() { this.Groups = new List <UPCharacteristicsGroup>(); this.groupDict = new Dictionary <string, UPCharacteristicsGroup>(); IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; if (this.GroupSearchAndListControl != null) { this.GroupFieldControl = configStore.FieldControlByNameFromGroup("List", this.GroupSearchAndListControl.FieldGroupName); UPConfigFilter filter = null; if (!string.IsNullOrEmpty(this.GroupSearchAndListControl.FilterName)) { filter = configStore.FilterByName(this.GroupSearchAndListControl.FilterName); if (filter != null && this.sourceFieldDictionary != null) { filter = filter.FilterByApplyingReplacements(new UPConditionValueReplacement(this.sourceFieldDictionary)); } } UPConfigFieldControlField groupField = this.GroupFieldControl.FieldWithFunction(Constants.FieldGroupString); if (this.GroupFieldControl != null && groupField != null) { this.crmQuery = new UPContainerMetaInfo(this.GroupFieldControl); if (filter != null) { this.crmQuery.ApplyFilter(filter); } this.currentQueryType = 0; this.crmQuery.Find(this.SourceRequestOption, this); } } else { bool showAdditionalFields = !configStore.ConfigValueIsSet("Characteristics.HideAdditionalFields"); bool showExpanded = !configStore.ConfigValueIsSet("Characteristics.CollapseGroups"); UPCatalog catalog = UPCRMDataStore.DefaultStore.CatalogForCrmField(this.DestinationGroupField.Field); foreach (string key in catalog.SortedValues) { UPCharacteristicsGroup group = new UPCharacteristicsGroup(catalog.TextValueForKey(key), key, false, this, showExpanded); if (showAdditionalFields) { group.ShowAdditionalFields = true; } this.groupDict[key] = group; this.Groups.Add(group); } this.LoadItems(); } }
private void HandleItemResult(UPCRMResult result) { int count = result.RowCount; UPConfigFieldControlField groupField = this.ItemFieldControl.FieldWithFunction(Constants.FieldGroupString); UPConfigFieldControlField itemField = this.ItemFieldControl.FieldWithFunction(Constants.FieldItemString); UPConfigFieldControlField destinationShowAdditionalFieldsField = this.ItemFieldControl.FieldWithFunction(Constants.FieldShowAdditionalFieldsString); List <UPCharacteristicsGroup> groupsWithAllItems = new List <UPCharacteristicsGroup>(); for (int i = 0; i < count; i++) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i); string groupKey = row.RawValueAtIndex(groupField.TabIndependentFieldIndex); UPCharacteristicsGroup group = this.groupDict.ValueOrDefault(groupKey); if (group != null) { string itemKey = row.RawValueAtIndex(itemField.TabIndependentFieldIndex); bool showAdditionalFields = false; if (destinationShowAdditionalFieldsField != null) { showAdditionalFields = row.RawValueAtIndex(destinationShowAdditionalFieldsField.TabIndependentFieldIndex).ToBoolWithDefaultValue(false); } if (itemKey == "0") { group.ShowAdditionalFields = showAdditionalFields; if (!groupsWithAllItems.Contains(group)) { groupsWithAllItems.Add(group); } } else { group.AddItem(new UPCharacteristicsItem(row.ValueAtIndex(itemField.TabIndependentFieldIndex), itemKey, group, showAdditionalFields ? this.AdditionalFields : null)); } } } this.HandleGroupsWithAllItems(groupsWithAllItems); }
/// <summary> /// Initializes a new instance of the <see cref="UPCharacteristicsItem"/> class. /// </summary> /// <param name="label">The label.</param> /// <param name="catalogValue">The catalog value.</param> /// <param name="group">The group.</param> /// <param name="additionalFields">The additional fields.</param> public UPCharacteristicsItem(string label, string catalogValue, UPCharacteristicsGroup group, List <UPConfigFieldControlField> additionalFields) { this.Label = label; this.CatalogValue = catalogValue; this.AdditionalFields = additionalFields; int count = this.AdditionalFields?.Count ?? 0; if (count > 0) { this.values = new List <string>(additionalFields.Count); for (int i = 0; i < count; i++) { this.values.Add(string.Empty); } } this.Group = group; this.Deleted = false; this.Changed = false; this.Created = false; this.ShowAdditionalFields = this.AdditionalFields?.Count > 0; }
private void HandleGroupResult(UPCRMResult result) { int count = result.RowCount; UPConfigFieldControlField groupField = this.GroupFieldControl.FieldWithFunction(Constants.FieldGroupString); UPConfigFieldControlField singleField = this.GroupFieldControl.FieldWithFunction(Constants.FieldSingleString); UPConfigFieldControlField showGroupExpandedField = this.GroupFieldControl.FieldWithFunction(Constants.FieldShowGroupExpandedString); for (int i = 0; i < count; i++) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i); string key = row.RawValueAtIndex(groupField.TabIndependentFieldIndex); if (!this.groupDict.ContainsKey(key)) { bool singleSelection = false; if (singleField != null) { string singleFieldValue = row.RawValueAtIndex(singleField.TabIndependentFieldIndex); if (singleFieldValue == "true") { singleSelection = true; } } bool showGroupExpanded = true; if (showGroupExpandedField != null) { showGroupExpanded = row.RawValueAtIndex(showGroupExpandedField.TabIndependentFieldIndex).ToBoolWithDefaultValue(true); } UPCharacteristicsGroup group = new UPCharacteristicsGroup(row.ValueAtIndex(groupField.TabIndependentFieldIndex), key, singleSelection, this, showGroupExpanded); this.groupDict[key] = group; this.Groups.Add(group); } } this.LoadItems(); }
private void HandleDestinationResult(UPCRMResult result) { int count = result.RowCount; bool expandOnData = ConfigurationUnitStore.DefaultStore.ConfigValue("Characteristics.CollapseGroups") == "empty"; for (int i = 0; i < count; i++) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i); string groupKey = row.RawValueAtIndex(this.DestinationGroupField.TabIndependentFieldIndex); UPCharacteristicsGroup group = this.groupDict.ValueOrDefault(groupKey); if (group != null) { if (expandOnData) { group.ShowExpanded = true; } string itemKey = row.RawValueAtIndex(this.DestinationItemField.TabIndependentFieldIndex); UPCharacteristicsItem item = group.ItemDictionary.ValueOrDefault(itemKey); UPCRMRecord conflictRecord = null; if (this.conflictOfflineRequest != null) { foreach (UPCRMRecord currentConflictRecord in this.conflictOfflineRequest.Records) { if (currentConflictRecord.RecordIdentification == row.RecordIdentificationAtFieldIndex(0)) { conflictRecord = currentConflictRecord; break; } } } if (conflictRecord == null) { item?.SetFromResultRow(row); } else if (conflictRecord.Deleted) { item?.SetFromRecord(conflictRecord); } else { item?.SetFromResultRow(row); foreach (UPCRMFieldValue fieldValue in conflictRecord.FieldValues) { int position = this.PositionForCrmFieldId(fieldValue.FieldId); if (position >= 0) { item.SetValueForAdditionalFieldPosition(fieldValue.Value, position); } } } } } if (this.conflictOfflineRequest != null) { foreach (UPCRMRecord conflictRecord in this.conflictOfflineRequest.Records) { if (conflictRecord.IsNew) { string groupKey = conflictRecord.StringFieldValueForFieldIndex(this.DestinationGroupField.TabIndependentFieldIndex); UPCharacteristicsGroup group = this.groupDict.ValueOrDefault(groupKey); if (group != null) { string itemKey = conflictRecord.StringFieldValueForFieldIndex(this.DestinationItemField.TabIndependentFieldIndex); UPCharacteristicsItem item = group.ItemDictionary[itemKey]; item.SetFromRecord(conflictRecord); } } } } if (!this.EditMode) { this.RemoveEmptyItems(); } this.TheDelegate.CharacteristicsDidFinishWithResult(this, this); }