/// <summary> /// Adds the sub table relation. /// </summary> /// <param name="querytable"> /// The querytable. /// </param> /// <param name="relation"> /// The relation. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool AddSubTableRelation(UPConfigQueryTable querytable, string relation) { var table = new UPContainerInfoAreaMetaInfo(querytable); if (relation != null) { table.ParentRelation = relation; } if (this.subTables == null) { this.subTables = new List <UPContainerInfoAreaMetaInfo>(); } this.subTables.Add(table); var count = querytable.NumberOfSubTables; for (var i = 0; i < count; i++) { var subQueryTable = querytable.SubTableAtIndex(i); var subParentRelation = subQueryTable.ParentRelation; if (string.IsNullOrEmpty(subParentRelation)) { subParentRelation = relation; } table.AddSubTableRelation(subQueryTable, subParentRelation); } return(true); }
private void ConfigForStepFromQueryTable(UPRecordCopyStep recordCopyStep, UPConfigQueryTable queryTable) { UPConfigQueryCondition sourceConfigNameCondition = queryTable.PropertyConditions.ValueOrDefault("SourceConfig"); string sourceConfigName = null; if (sourceConfigNameCondition != null && sourceConfigNameCondition.FieldValues.Count > 0) { sourceConfigName = sourceConfigNameCondition.FieldValues[0] as string; } bool skipSearchAndList = false; if (string.IsNullOrEmpty(sourceConfigName)) { sourceConfigName = queryTable.InfoAreaId; skipSearchAndList = true; } if (!skipSearchAndList) { recordCopyStep.SearchAndListConfiguration = this.configStore.SearchAndListByName(sourceConfigName); } if (recordCopyStep.SearchAndListConfiguration == null) { recordCopyStep.FieldControl = this.configStore.FieldControlByNameFromGroup("Edit", sourceConfigName) ?? this.configStore.FieldControlByNameFromGroup("List", sourceConfigName); } else { recordCopyStep.FieldControl = this.configStore.FieldControlByNameFromGroup("List", recordCopyStep.SearchAndListConfiguration.FieldGroupName); } }
/// <summary> /// Starts the with source record identification. /// </summary> /// <param name="sourceRecordIdentification">The source record identification.</param> /// <param name="destRecordIdentification">The dest record identification.</param> /// <param name="_parameters">The parameters.</param> /// <returns></returns> public bool StartWithSourceRecordIdentification(string sourceRecordIdentification, string destRecordIdentification, Dictionary <string, object> _parameters) { if (this.running) { return(false); } this.running = true; this.parameters = _parameters; this.replacedFilter = this.TemplateFilter.FilterByApplyingValueDictionaryDefaults(this.parameters, true); UPCRMRecord destinationRootRecord = new UPCRMRecord(destRecordIdentification); int count = this.replacedFilter.RootTable.NumberOfSubTables; this.recordArray = new List <UPCRMRecord>(); this.stepQueue = new List <UPRecordCopyStep>(); for (int i = 0; i < count; i++) { UPConfigQueryTable currentTable = this.replacedFilter.RootTable.SubTableAtIndex(i); UPRecordCopyStep recordStep = new UPRecordCopyStep(); recordStep.SourceRecordIdentification = sourceRecordIdentification; recordStep.QueryTable = currentTable; recordStep.DestinationRecord = destinationRootRecord; this.ConfigForStepFromQueryTable(recordStep, currentTable); this.stepQueue.Add(recordStep); } this.ExecuteNextStep(); return(true); }
/// <summary> /// Adds the conditions. /// </summary> /// <param name="querytable"> /// The querytable. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool AddConditions(UPConfigQueryTable querytable) { if (querytable.Condition == null) { return(false); } this.AddCondition(querytable.Condition.Condition()); return(true); }
/// <summary> /// Initializes a new instance of the <see cref="UPContainerInfoAreaMetaInfo"/> class. /// </summary> /// <param name="querytable"> /// The querytable. /// </param> public UPContainerInfoAreaMetaInfo(UPConfigQueryTable querytable) { this.InfoAreaId = querytable.InfoAreaId; this._linkId = querytable.LinkId; this.InfoAreaIdWithLink = this.InfoAreaId.InfoAreaIdLinkId(this._linkId); this._fieldIds = null; this.Links = null; this._cdataInitialized = false; this.ParentRelation = querytable.ParentRelation; if (querytable.Condition != null) { this.AddConditions(querytable); } }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigQuerySortField"/> class. /// </summary> /// <param name="fieldIndex"> /// Index of the field. /// </param> /// <param name="queryTable"> /// The query table. /// </param> /// <param name="flags"> /// The flags. /// </param> public UPConfigQuerySortField(int fieldIndex, UPConfigQueryTable queryTable, int flags) : base(fieldIndex, queryTable, flags) { this.Descending = (this.Flags & 1) != 0; }
/// <summary> /// Adds the sub table. /// </summary> /// <param name="querytable"> /// The querytable. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool AddSubTable(UPConfigQueryTable querytable) { return(this.AddSubTableRelation(querytable, null)); }
private void ProcessResult(UPCRMResult result) { UPRecordCopyStep currentStep = this.stepQueue[0]; this.stepQueue.RemoveAt(0); UPConfigQueryTable queryTable = currentStep.QueryTable; int count = result.RowCount; int resultTableCount = result.NumberOfResultTables; UPContainerInfoAreaMetaInfo copyResultInfoArea = null; if (queryTable.InfoAreaId == currentStep.FieldControl.InfoAreaId) { copyResultInfoArea = result.MetaInfo.ResultInfoAreaMetaInfoAtIndex(0); } for (int i = 0; i < count; i++) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i); UPCRMRecord record = new UPCRMRecord(queryTable.InfoAreaId); if (currentStep.DestinationRecord != null) { record.AddLink(new UPCRMLink(currentStep.DestinationRecord, queryTable.LinkId)); } for (int j = 1; j < resultTableCount; j++) { string linkRecordIdentification = row.RecordIdentificationAtIndex(j); if (string.IsNullOrEmpty(linkRecordIdentification) && !result.IsServerResult) { UPContainerInfoAreaMetaInfo resultInfoArea = result.MetaInfo.ResultInfoAreaMetaInfoAtIndex(j); UPCRMLinkReader linkReader = new UPCRMLinkReader(StringExtensions.InfoAreaIdRecordId(currentStep.FieldControl.InfoAreaId, row.RootRecordId), $"{resultInfoArea.InfoAreaId}:{resultInfoArea.LinkId}", null); linkRecordIdentification = linkReader.RequestLinkRecordOffline(); } int linkId = -1; if (linkRecordIdentification?.Length > 8) { if (currentStep.DestinationRecord == null || queryTable.LinkId != linkId || linkRecordIdentification.InfoAreaId() != currentStep.DestinationRecord.InfoAreaId) { record.AddLink(new UPCRMLink(linkRecordIdentification, linkId)); } } } Dictionary <string, object> fieldsWithFunctions = row.ValuesWithFunctions(); UPConfigQueryTable replacedTable = queryTable.QueryTableByApplyingValueDictionary(fieldsWithFunctions); if (copyResultInfoArea != null) { foreach (UPContainerFieldMetaInfo field in copyResultInfoArea.Fields) { string val = row.RawValueAtIndex(field.PositionInResult); if (!string.IsNullOrEmpty(val)) { record.AddValue(new UPCRMFieldValue(val, field.InfoAreaId, field.FieldId)); } } } if (replacedTable != null) { record.ApplyValuesFromTemplateFilter(replacedTable, true); } int numberOfSubTables = queryTable.NumberOfSubTables; if (numberOfSubTables > 0) { for (int k = 0; k < numberOfSubTables; k++) { UPRecordCopyStep subStep = new UPRecordCopyStep(); subStep.QueryTable = queryTable.SubTableAtIndex(k); subStep.SourceRecordIdentification = row.RootRecordIdentification; subStep.DestinationRecord = record; this.ConfigForStepFromQueryTable(subStep, subStep.QueryTable); this.stepQueue.Add(subStep); } } this.recordArray.Add(record); } this.ExecuteNextStep(); }
/// <summary> /// Results the view reference. /// </summary> /// <returns></returns> public ViewReference ResultViewReference() { if (this.DecisionHandler != null && this.Result.RowCount > 0) { UPCRMResultRow resultRow = (UPCRMResultRow)this.Result.ResultRowAtIndex(0); UPConfigQueryTable resultQueryTable = this.DecisionHandler.QueryTableForResultRow(resultRow); if (resultQueryTable != null) { UPConfigQueryCondition propertyCondition = resultQueryTable.PropertyConditions["Action"]; if (!string.IsNullOrEmpty(propertyCondition.FirstValue)) { Menu menu = ConfigurationUnitStore.DefaultStore.MenuByName(propertyCondition.FirstValue); ViewReference returnViewReference = menu.ViewReference.ViewReferenceWith(this.RecordIdentification, resultRow.RootRecordIdentification); if (this.ViewReference.HasBackToPreviousFollowUpAction()) { this.followUpReplaceOrganizer = true; return(returnViewReference.ViewReferenceWithBackToPreviousFollowUpAction()); } return(returnViewReference); } propertyCondition = resultQueryTable.PropertyConditions["ButtonAction"]; if (!string.IsNullOrEmpty(propertyCondition.FirstValue)) { UPConfigButton button = ConfigurationUnitStore.DefaultStore.ButtonByName(propertyCondition.FirstValue); ViewReference returnViewReference = button.ViewReference.ViewReferenceWith(this.RecordIdentification, resultRow.RootRecordIdentification); if (this.ViewReference.HasBackToPreviousFollowUpAction()) { this.followUpReplaceOrganizer = true; return(returnViewReference.ViewReferenceWithBackToPreviousFollowUpAction()); } return(returnViewReference); } propertyCondition = resultQueryTable.PropertyConditions["DefaultAction"]; if (!string.IsNullOrEmpty(propertyCondition.FirstValue)) { Menu menu = ConfigurationUnitStore.DefaultStore.MenuByName(propertyCondition.FirstValue); ViewReference returnViewReference = menu.ViewReference.ViewReferenceWith(this.RecordIdentification, resultRow.RootRecordIdentification); if (this.ViewReference.HasBackToPreviousFollowUpAction()) { this.followUpReplaceOrganizer = true; return(returnViewReference.ViewReferenceWithBackToPreviousFollowUpAction()); } return(returnViewReference); } propertyCondition = resultQueryTable.PropertyConditions["DefaultButtonAction"]; if (!string.IsNullOrEmpty(propertyCondition.FirstValue)) { UPConfigButton button = ConfigurationUnitStore.DefaultStore.ButtonByName(propertyCondition.FirstValue); ViewReference returnViewReference = button.ViewReference.ViewReferenceWith(this.RecordIdentification, resultRow.RootRecordIdentification); if (this.ViewReference.HasBackToPreviousFollowUpAction()) { this.followUpReplaceOrganizer = true; return(returnViewReference.ViewReferenceWithBackToPreviousFollowUpAction()); } return(returnViewReference); } } } if (this.Result.RowCount > 0) { Menu menu = ConfigurationUnitStore.DefaultStore.MenuByName(this.ViewReference.ContextValueForKey("ExistsAction")); if (menu != null) { ViewReference returnViewReference = menu.ViewReference.ViewReferenceWith( ((UPCRMResultRow)this.Result.ResultRowAtIndex(0)).RootRecordIdentification, this.ViewReference.ContextValueForKey("RecordId")); return(this.ViewReference.HasBackToPreviousFollowUpAction() ? returnViewReference.ViewReferenceWithBackToPreviousFollowUpAction() : returnViewReference); } return(null); } else { Menu menu = ConfigurationUnitStore.DefaultStore.MenuByName(this.ViewReference.ContextValueForKey("NotExistsAction")); if (menu != null) { ViewReference returnViewReference = menu.ViewReference.ViewReferenceWith(this.ViewReference.ContextValueForKey("RecordId")); return(this.ViewReference.HasBackToPreviousFollowUpAction() ? returnViewReference.ViewReferenceWithBackToPreviousFollowUpAction() : returnViewReference); } return(null); } }