/// <summary> /// Requests add as favorite. /// </summary> /// <param name="recordIdentification">The record identification.</param> /// <returns></returns> public bool RequestAddAsFavorite(string recordIdentification) { this.currentRequest = new UPOfflineRecordRequest(); UPCRMRecord record = UPCRMRecord.CreateNew(Constants.FAVORITES_INFOAREAID); if (this.TemplateFilter != null) { record.ApplyValuesFromTemplateFilter(this.TemplateFilter); } record.AddLink(new UPCRMLink(recordIdentification, Constants.FAVORITES_LINKID)); return(this.currentRequest.StartRequest(this.OfflineRequestMode, new List <UPCRMRecord> { record }, this)); }
private bool ApplyTemplateFilterToRecord(UPCRMRecord record) { string templateFilterName = this.FieldControlConfig.ValueForAttribute($"TemplateFilter_{this.TabIndex + 1}"); if (!string.IsNullOrEmpty(templateFilterName)) { var filter = ConfigurationUnitStore.DefaultStore.FilterByName(templateFilterName); if (filter != null) { record.ApplyValuesFromTemplateFilter(filter); return(true); } } return(false); }
/// <summary> /// Approves the specified dummy. /// </summary> /// <param name="dummy">The dummy.</param> public void Approve(object dummy) { if (this.disableSigning) { return; } string recordIdentification = this.buttonViewReference.ContextValueForKey("RecordId"); string filterName = this.buttonViewReference.ContextValueForKey("TemplateFilter"); if (string.IsNullOrEmpty(recordIdentification)) { this.ParentOrganizerModelController.HandleOrganizerActionError( LocalizedString.TextErrorConfiguration, string.Format(LocalizedString.TextErrorParameterEmpty, "RecordId"), true); return; } UPConfigFilter filter = ConfigurationUnitStore.DefaultStore.FilterByName(filterName); if (filter == null) { this.HandlePageErrorDetails(LocalizedString.TextErrorConfiguration, string.Format(LocalizedString.TextErrorFilterMissing, filterName)); return; } filter = filter.FilterByApplyingValueDictionaryDefaults(this.FieldValueDictionary, true); UPCRMRecord record = new UPCRMRecord(recordIdentification); record.ApplyValuesFromTemplateFilter(filter); UPOfflineEditRecordRequest request = new UPOfflineEditRecordRequest(0); this.buttonRequest = request; string requestOptionString = this.buttonViewReference.ContextValueForKey("RequestOption"); UPOfflineRequestMode requestMode = UPOfflineRequest.RequestModeFromString(requestOptionString, UPOfflineRequestMode.OnlineConfirm); if (request.StartRequest(requestMode, new List <UPCRMRecord> { record }, this) == false) { this.buttonRequest = null; } else { this.ShouldWaitForPendingChanges = true; } }
/// <summary> /// CRMs the records for parameters record add root. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="record">The record.</param> /// <param name="addRoot">if set to <c>true</c> [add root].</param> /// <returns></returns> public List <UPCRMRecord> CrmRecordsForParametersRecordAddRoot(Dictionary <string, object> parameters, UPCRMRecord record, bool addRoot) { List <UPCRMRecord> recordArray = new List <UPCRMRecord>(); UPCRMRecord documentRecord = null; if (this.TemplateFilter != null) { UPConfigFilter filter = this.TemplateFilter.FilterByApplyingValueDictionary(parameters); if (filter != null) { documentRecord = UPCRMRecord.CreateNew(filter.InfoAreaId); documentRecord.Mode = "NewOffline"; documentRecord.ApplyValuesFromTemplateFilter(filter); recordArray.Add(documentRecord); } } if (!string.IsNullOrEmpty(this.DocumentLinkInfoAreaId) && documentRecord != null) { UPCRMRecord documentLinkRecord = UPCRMRecord.CreateNew(this.DocumentLinkInfoAreaId); documentLinkRecord.Mode = "NewOffline"; UPConfigFilter filter = this.LinkTemplateFilter?.FilterByApplyingValueDictionary(parameters); if (filter != null) { documentLinkRecord.ApplyValuesFromTemplateFilter(filter); } documentLinkRecord.AddLink(new UPCRMLink(record, this.RecordLinkId)); documentLinkRecord.AddLink(new UPCRMLink(documentRecord, this.DocumentLinkLinkId)); recordArray.Add(documentLinkRecord); } else if (string.IsNullOrEmpty(this.DocumentLinkInfoAreaId)) { documentRecord?.AddLink(new UPCRMLink(record, this.RecordLinkId)); } if (addRoot && recordArray.Count > 0) { recordArray.Add(record); } return(recordArray.Count > 0 ? recordArray : null); }
private void ContinueWithParameters(Dictionary <string, object> parameterDictionary) { this.TemplateFilter = this.TemplateFilter.FilterByApplyingValueDictionaryDefaults(parameterDictionary, true); UPCRMRecord record = new UPCRMRecord(this.RecordIdentification); string linkRecordId = this.ViewReference.ContextValueForKey("LinkRecordId"); if (!string.IsNullOrEmpty(linkRecordId)) { int linkId = Convert.ToInt32(this.ViewReference.ContextValueForKey("LinkId")); if (linkId < 0) { linkId = -1; } record.AddLink(new UPCRMLink(linkRecordId, linkId)); } List <UPCRMRecord> childRecords = record.ApplyValuesFromTemplateFilter(this.TemplateFilter, false); if (childRecords?.Count > 0) { List <UPCRMRecord> linkRecords = null; List <UPCRMRecord> combinedRecords = new List <UPCRMRecord> { record }; foreach (UPCRMRecord childRecord in childRecords) { if (childRecord.Mode == "ParentUpdate") { if (linkRecords == null) { linkRecords = new List <UPCRMRecord> { childRecord }; } else { linkRecords.Add(childRecord); } } else { combinedRecords.Add(childRecord); } } if (linkRecords?.Count == 0) { this.ContinueWithRecords(combinedRecords); } else { this.RecordsToSave = combinedRecords; this.ContinueWithLinkRecords(linkRecords); } } else { this.ContinueWithRecords(new List <UPCRMRecord> { record }); } }
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(); }
private void ContinueUploadReportPdf() { string recordIdentification = this.RecordIdentification; int fieldId = -1; ViewReference documentUploadViewReference = this.DetermineDocumentUploadViewReference(); if (documentUploadViewReference != null) { if (this.parentLinkReader != null) { recordIdentification = this.parentLinkRecordIdentification; this.parentLinkReader = null; } else { recordIdentification = documentUploadViewReference.ContextValueForKey("RecordId"); if (string.IsNullOrEmpty(recordIdentification)) { recordIdentification = this.RecordIdentification; } string parentLinkString = documentUploadViewReference.ContextValueForKey("ParentLink"); if (!string.IsNullOrEmpty(parentLinkString)) { this.parentLinkReader = new UPCRMLinkReader(recordIdentification, parentLinkString, this); if (this.parentLinkReader.Start()) { return; } recordIdentification = this.parentLinkReader.RequestLinkRecordOffline(); } } fieldId = this.DetermineFieldIdDocumentUploadViewReference(fieldId, documentUploadViewReference); } this.reportFileName = this.CalcReportFileName(); this.uploadDocumentRequest = new UPOfflineUploadDocumentRequest(this.pdfData, -1, this.reportFileName, "application/pdf", recordIdentification, fieldId); this.multiRequest = new UPOfflineMultiRequest(this); this.multiRequest.AddRequest(this.uploadDocumentRequest); recordIdentification = this.buttonViewReference.ContextValueForKey("RecordId"); string filterName = this.buttonViewReference.ContextValueForKey("TemplateFilter"); UPConfigFilter filter = ConfigurationUnitStore.DefaultStore.FilterByName(filterName); filter = filter.FilterByApplyingValueDictionaryDefaults(this.FieldValueDictionary, true); if (!string.IsNullOrEmpty(recordIdentification) && filter != null) { UPCRMRecord record = new UPCRMRecord(recordIdentification); List <UPCRMRecord> combinedRecords = new List <UPCRMRecord> { record }; List <UPCRMRecord> childRecords = record.ApplyValuesFromTemplateFilter(filter, false); foreach (UPCRMRecord childRecord in childRecords) { if (childRecord.Mode == "ParentUpdate") { if (this.templateFilterLinkRecords == null) { this.templateFilterLinkRecords = new List <UPCRMRecord> { childRecord }; } else { this.templateFilterLinkRecords.Add(childRecord); } } else { combinedRecords.Add(childRecord); } } if (this.templateFilterLinkRecords.Count > 0) { this.recordsToSave = combinedRecords; this.ContinueWithLinkRecords(this.templateFilterLinkRecords); return; } this.PerformUploadReportPdfWithRecords(combinedRecords); } else { this.PerformUploadReportPdfWithRecords(null); } }
/// <summary> /// Gets the changed records. /// </summary> /// <param name="rootTemplateFilter">The root template filter.</param> /// <param name="baseTemplateFilter">The base template filter.</param> /// <param name="ignoreDefault">if set to <c>true</c> [ignore default].</param> /// <returns></returns> public List <UPCRMRecord> ChangedRecords(UPConfigFilter rootTemplateFilter, UPConfigFilter baseTemplateFilter, bool ignoreDefault) { UPCRMRecord rootRecord; bool changedRoot = false; if (!string.IsNullOrEmpty(this.AnswerRootRecordIdentification)) { rootRecord = new UPCRMRecord(this.AnswerRootRecordIdentification); } else { rootRecord = new UPCRMRecord(this.SurveySearchAndList.InfoAreaId); rootRecord.AddLink(new UPCRMLink(this.RootRecordIdentification)); if (this.Questionnaire.Manager.LinkSurveyToQuestionnaire) { rootRecord.AddLink(new UPCRMLink(this.Questionnaire.RecordIdentification)); } if (this.SurveyTemplateFilter != null) { UPConfigFilter filter = this.SurveyTemplateFilter.FilterByApplyingValueDictionaryDefaults(this.Parameters, true); rootRecord.ApplyValuesFromTemplateFilter(filter); } changedRoot = true; } Dictionary <string, UPCRMRecord> foreignFieldDictionary = new Dictionary <string, UPCRMRecord>(); List <UPCRMRecord> answerRecords = new List <UPCRMRecord>(); foreach (UPQuestionnaireQuestion question in this.Questionnaire.Questions) { UPSurveyAnswer answer = this.surveyAnswers[question.QuestionId]; List <UPCRMRecord> currentAnswerRecords = answer.ChangedRecords(rootRecord, this.Parameters, ignoreDefault); if (currentAnswerRecords.Count > 0) { answerRecords.AddRange(currentAnswerRecords); } if (question.Save) { UPSurveyForeignField foreignField = answer.SurveyForeignField; if (!string.IsNullOrEmpty(foreignField.RecordIdentification) && !string.IsNullOrEmpty(foreignField.Value) && !string.IsNullOrEmpty(answer.Answer) && foreignField.Value != answer.Answer) { UPCRMRecord foreignRecord = foreignFieldDictionary.ValueOrDefault(foreignField.RecordIdentification); if (foreignRecord == null) { foreignRecord = new UPCRMRecord(foreignField.RecordIdentification); foreignFieldDictionary[foreignField.RecordIdentification] = foreignRecord; } UPCRMFieldValue fieldValue = new UPCRMFieldValue(answer.Answer, foreignRecord.InfoAreaId, foreignField.FieldInfo.FieldId, this.Questionnaire.Manager.AutomaticOnlineSaveOfForeignFields); foreignRecord.AddValue(fieldValue); } } } List <UPCRMRecord> changedRecords = new List <UPCRMRecord>(); if (changedRoot) { changedRecords.Add(rootRecord); } if (answerRecords.Count > 0) { changedRecords.AddRange(answerRecords); } if (changedRecords.Count > 0) { UPCRMRecord rootSyncRecord = new UPCRMRecord(rootRecord, "Sync"); changedRecords.Add(rootSyncRecord); } if (foreignFieldDictionary.Count > 0) { changedRecords.AddRange(foreignFieldDictionary.Values); } if (rootTemplateFilter != null) { rootTemplateFilter = rootTemplateFilter.FilterByApplyingValueDictionaryDefaults(this.Parameters, true); if (rootTemplateFilter != null) { UPCRMRecord record = new UPCRMRecord(rootRecord); record.ApplyValuesFromTemplateFilter(rootTemplateFilter); changedRecords.Add(record); } } if (baseTemplateFilter != null) { baseTemplateFilter = baseTemplateFilter.FilterByApplyingValueDictionaryDefaults(this.Parameters, true); if (baseTemplateFilter != null) { UPCRMRecord record = new UPCRMRecord(this.RecordIdentification); record.ApplyValuesFromTemplateFilter(baseTemplateFilter); changedRecords.Add(record); } } return(changedRecords); }