private void TrySourceCopyFieldGroupOfflineWithRecordLink() { if (!UPCRMDataStore.DefaultStore.RecordExistsOffline(this.RecordIdentification)) { this.TheDelegate.SurveyDidFailWithError(this, new Exception("SourceCopyFields could not be loaded")); return; } this.crmQuery = this.SourceCopyFieldGroup != null ? new UPContainerMetaInfo(this.SourceCopyFieldGroup) : new UPContainerMetaInfo(new List <UPCRMField>(), this.RecordIdentification.InfoAreaId()); UPQuestionnaireManager questionnaireManager = ServerSession.CurrentSession.QuestionnaireManager; UPCRMLinkField questionnairelinkField = new UPCRMLinkField(questionnaireManager.QuestionnaireList.InfoAreaId, -1, this.RecordIdentification.InfoAreaId()); List <UPContainerFieldMetaInfo> fieldMetaInfos = this.crmQuery.AddCrmFields(new List <UPCRMField> { questionnairelinkField }); if (fieldMetaInfos.Count > 0) { this.questionnairelinkFieldMetaInfo = fieldMetaInfos[0]; } this.crmQuery.SetLinkRecordIdentification(this.RecordIdentification); this.loadStep = 1; this.crmQuery.Find(UPRequestOption.Offline, this); }
/// <summary> /// Loads this instance. /// </summary> /// <returns></returns> public bool Load() { bool isRecordLink = false; if (string.IsNullOrEmpty(this.QuestionnaireLinkName)) { this.QuestionnaireLinkName = "RecordLink"; } this.loadStep = 1; this.crmQuery = this.SourceCopyFieldGroup != null ? new UPContainerMetaInfo(this.SourceCopyFieldGroup) : new UPContainerMetaInfo(new List <UPCRMField>(), this.RecordIdentification.InfoAreaId()); if (this.QuestionnaireLinkName == "RecordLink") { isRecordLink = true; UPQuestionnaireManager questionnaireManager = null; //ServerSession.CurrentSession.QuestionnaireManager; if (this.SourceRequestOption == UPRequestOption.Offline || ((this.SourceRequestOption == UPRequestOption.FastestAvailable || this.SourceRequestOption == UPRequestOption.Default) && UPCRMDataStore.DefaultStore.RecordExistsOffline(this.RecordIdentification))) { UPCRMLinkField questionnairelinkField = new UPCRMLinkField(questionnaireManager.QuestionnaireList.InfoAreaId, -1, this.RecordIdentification.InfoAreaId()); List <UPContainerFieldMetaInfo> fieldMetaInfos = this.crmQuery.AddCrmFields(new List <UPCRMField> { questionnairelinkField }); if (fieldMetaInfos.Count > 0) { this.questionnairelinkFieldMetaInfo = fieldMetaInfos[0]; } } else { UPCRMField questionnairelinkField = new UPCRMField(0, questionnaireManager?.QuestionnaireList.InfoAreaId, -1); UPContainerInfoAreaMetaInfo subInfoAreaMetaInfo = this.crmQuery.RootInfoAreaMetaInfo.SubTableForInfoAreaIdLinkId(questionnaireManager?.QuestionnaireList.InfoAreaId, -1); if (subInfoAreaMetaInfo == null) { this.crmQuery.RootInfoAreaMetaInfo.AddTable(new UPContainerInfoAreaMetaInfo(questionnaireManager?.QuestionnaireList.InfoAreaId, -1)); } this.crmQuery.AddCrmFields(new List <UPCRMField> { questionnairelinkField }); } } this.crmQuery.SetLinkRecordIdentification(this.RecordIdentification); if (isRecordLink && this.SourceRequestOption == UPRequestOption.BestAvailable) { this.loadStep = 11; if (this.crmQuery.Find(UPRequestOption.Online, this) == null) { this.TrySourceCopyFieldGroupOfflineWithRecordLink(); } } else { this.crmQuery.Find(this.SourceRequestOption, this); } return(true); }