Beispiel #1
0
        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);
        }
Beispiel #2
0
        private void SourceCopyFieldGroupLoaded(UPCRMResultRow resultRow)
        {
            this.Parameters = resultRow.ValuesWithFunctions();
            UPQuestionnaireManager questionnaireManager = null; //ServerSession.CurrentSession.QuestionnaireManager;

            if (this.QuestionnaireLinkName == "RecordLink")
            {
                string questionnaireRecordIdentification = resultRow.RecordIdentificationForLinkInfoAreaIdLinkId(questionnaireManager.QuestionnaireList.InfoAreaId, -1);
                if (questionnaireRecordIdentification.Length == 0 && this.questionnairelinkFieldMetaInfo != null)
                {
                    string questionnaireRecordId = resultRow.RawValueAtIndex(this.questionnairelinkFieldMetaInfo.PositionInResult);
                    if (!string.IsNullOrEmpty(questionnaireRecordId))
                    {
                        questionnaireRecordIdentification = StringExtensions.InfoAreaIdRecordId(questionnaireManager.QuestionnaireList.InfoAreaId, questionnaireRecordId);
                    }
                }

                if (!string.IsNullOrEmpty(questionnaireRecordIdentification))
                {
                    this.Questionnaire = questionnaireManager.LoadQuestionaire(questionnaireRecordIdentification, this);
                }
                else
                {
                    this.TheDelegate.SurveyDidFailWithError(this, new Exception("cannot load questionnaire, recordIdentification empty"));
                    return;
                }
            }
            else
            {
                int catalogCode = Convert.ToInt32(this.Parameters.ValueOrDefault(this.QuestionnaireLinkName));
                if (catalogCode > 0)
                {
                    this.Questionnaire = questionnaireManager.LoadQuestionaire(catalogCode, this);
                }
                else
                {
                    this.TheDelegate.SurveyDidFailWithError(this, new Exception("cannot load questionnaire with code, catalogCode empty"));
                    return;
                }
            }

            if (this.Questionnaire != null)
            {
                this.QuestionnaireLoaded();
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UPQuestionnaire"/> class.
 /// </summary>
 /// <param name="recordIdentification">The record identification.</param>
 /// <param name="manager">The manager.</param>
 public UPQuestionnaire(string recordIdentification, UPQuestionnaireManager manager)
 {
     this.RecordIdentification = recordIdentification;
     this.Manager = manager;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UPQuestionnaire"/> class.
 /// </summary>
 /// <param name="catalogCode">The catalog code.</param>
 /// <param name="manager">The manager.</param>
 public UPQuestionnaire(int catalogCode, UPQuestionnaireManager manager)
 {
     this.CatalogCode = catalogCode;
     this.Manager     = manager;
 }
Beispiel #5
0
        /// <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);
        }