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); }
private void FillTimesVrianteWithoutTypeFromResultRowTimeTypePrefix(UPCRMResultRow resultRow, string timeType, string prefix) { var valuesWithFunctions = resultRow.ValuesWithFunctions(); DateTime fromDate; DateTime toDate; UPMDateTimeEditField fromTime; UPMDateTimeEditField toTime; UPMContactTime contactTime; var from = $"{prefix}FROM"; var to = $"{prefix}TO"; var afternoonFrom = $"{prefix}AFTERNOONFROM"; var afternoonTo = $"{prefix}AFTERNOONTO"; int weekDay = ((string)valuesWithFunctions.ValueOrDefault("DAYOFWEEK")).ToInt(); if (weekDay < 7) { weekDay++; } else { weekDay = 1; } if (valuesWithFunctions.ValueOrDefault(to) != null && ((string)valuesWithFunctions.ValueOrDefault(to)).ToInt() > 0) { fromDate = (valuesWithFunctions.ValueOrDefault(from) as string).TimeFromCrmValue(); toDate = (valuesWithFunctions.ValueOrDefault(to) as string).TimeFromCrmValue(); fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime")) { Type = DateTimeType.Time, DateValue = fromDate }; toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime")) { Type = DateTimeType.Time, DateValue = toDate }; contactTime = new UPMContactTime(weekDay, timeType, fromTime, toTime) { RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0) }; this.contactTimesGroup.AddChild(contactTime); } else { contactTime = new UPMContactTime(weekDay, timeType, null, null); this.contactTimesGroup.AddChild(contactTime); } if (valuesWithFunctions.ValueOrDefault(afternoonTo) != null && ((string)valuesWithFunctions.ValueOrDefault(afternoonTo)).ToInt() > 0) { fromDate = (valuesWithFunctions.ValueOrDefault(afternoonFrom) as string).TimeFromCrmValue(); toDate = (valuesWithFunctions.ValueOrDefault(afternoonTo) as string).TimeFromCrmValue(); fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime")) { Type = DateTimeType.Time, DateValue = fromDate }; toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime")) { Type = DateTimeType.Time, DateValue = toDate }; contactTime = new UPMContactTime(weekDay, timeType, fromTime, toTime) { RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0) }; this.contactTimesGroup.AddChild(contactTime); } else { contactTime = new UPMContactTime(weekDay, timeType, null, null) { RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0) }; this.contactTimesGroup.AddChild(contactTime); } }
private void FillTimesVrianteWithTypeFromResultRowTimeType(UPCRMResultRow resultRow, string timeType) { if (string.IsNullOrEmpty(this.contactTimesGroup.TimeTypeTitleForTimeType(timeType))) { return; } var valuesWithFunctions = resultRow.ValuesWithFunctions(); DateTime fromDate; DateTime toDate; UPMDateTimeEditField fromTime; UPMDateTimeEditField toTime; UPMContactTime contactTime; string from = "FROM"; string to = "TO"; string afternoonFrom = "AFTERNOONFROM"; string afternoonTo = "AFTERNOONTO"; int weekDay = ((string)valuesWithFunctions.ValueOrDefault("DAYOFWEEK")).ToInt(); if (weekDay < 7) { weekDay++; } else { weekDay = 1; } if ((valuesWithFunctions.ValueOrDefault(from) != null && ((string)valuesWithFunctions.ValueOrDefault(from)).ToInt() > 0) || (valuesWithFunctions.ValueOrDefault(to) != null && ((string)valuesWithFunctions.ValueOrDefault(to)).ToInt() > 0)) { fromDate = ((string)valuesWithFunctions.ValueOrDefault(from)).TimeFromCrmValue(); toDate = ((string)valuesWithFunctions.ValueOrDefault(to)).TimeFromCrmValue(); fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime")) { Type = DateTimeType.Time, DateValue = fromDate }; toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime")) { Type = DateTimeType.Time, DateValue = toDate }; contactTime = new UPMContactTime(weekDay, timeType, fromTime, toTime) { RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0) }; this.contactTimesGroup.AddChild(contactTime); } if ((valuesWithFunctions.ValueOrDefault(afternoonFrom) != null && ((string)valuesWithFunctions.ValueOrDefault(afternoonFrom)).ToInt() > 0) || (valuesWithFunctions.ValueOrDefault(afternoonTo) != null && ((string)valuesWithFunctions.ValueOrDefault(afternoonTo)).ToInt() > 0)) { fromDate = ((string)valuesWithFunctions.ValueOrDefault(afternoonFrom)).TimeFromCrmValue(); toDate = ((string)valuesWithFunctions.ValueOrDefault(afternoonTo)).TimeFromCrmValue(); fromTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("fromTime")) { Type = DateTimeType.Time, DateValue = fromDate }; toTime = new UPMDateTimeEditField(StringIdentifier.IdentifierWithStringId("toTime")) { Type = DateTimeType.Time, DateValue = toDate }; contactTime = new UPMContactTime(weekDay, timeType, fromTime, toTime) { RecordIdentification = resultRow.RecordIdentificationAtFieldIndex(0) }; this.contactTimesGroup.AddChild(contactTime); } }
private void ForeignFieldsLoaded(UPCRMResultRow row) { if (row != null) { foreach (UPSurveyForeignField foreignField in this.ForeignFields.Values) { if (foreignField.PositionInResult < 0) { continue; } foreignField.SetValueRecordIdentification(row.RawValueAtIndex(foreignField.PositionInResult), row.RecordIdentificationAtFieldIndex(foreignField.PositionInResult)); } } this.loadStep = 2; this.crmQuery = new UPContainerMetaInfo(this.SurveySearchAndList, this.Parameters); this.crmQuery.SetLinkRecordIdentification(this.RootRecordIdentification); this.crmQuery.Find(this.DestinationRequestOption, this); }