/// <summary>
        /// Questionnaires the loaded error.
        /// </summary>
        /// <param name="questionnaire">The questionnaire.</param>
        /// <param name="error">The error.</param>
        public void QuestionnaireLoadedError(UPQuestionnaire questionnaire, Exception error)
        {
            if (error == null)
            {
                this.AddQuestionnaireToCache(questionnaire);
            }

            this.pendingQuestionnaires.Remove(questionnaire);
        }
        /// <summary>
        /// Adds the questionnaire to cache.
        /// </summary>
        /// <param name="questionnaire">The questionnaire.</param>
        public void AddQuestionnaireToCache(UPQuestionnaire questionnaire)
        {
            if (questionnaire.CatalogCode > 0)
            {
                this.cacheByCode[questionnaire.CatalogCode] = questionnaire;
            }

            if (!string.IsNullOrEmpty(questionnaire.RecordIdentification))
            {
                this.cacheByRecordIdentification[questionnaire.RecordIdentification] = questionnaire;
            }
        }
        /// <summary>
        /// Loads the questionaire.
        /// </summary>
        /// <param name="recordIdentification">The record identification.</param>
        /// <param name="theDelegate">The delegate.</param>
        /// <returns></returns>
        public UPQuestionnaire LoadQuestionaire(string recordIdentification, IQuestionnaireDelegate theDelegate)
        {
            UPQuestionnaire quest = this.cacheByRecordIdentification.ValueOrDefault(recordIdentification);

            if (quest != null || theDelegate == null)
            {
                return(quest);
            }

            quest = new UPQuestionnaire(recordIdentification, this);
            this.pendingQuestionnaires.Add(quest);
            quest.Load(theDelegate);
            return(null);
        }
        /// <summary>
        /// Loads the questionaire.
        /// </summary>
        /// <param name="code">The code.</param>
        /// <param name="theDelegate">The delegate.</param>
        /// <returns></returns>
        public UPQuestionnaire LoadQuestionaire(int code, IQuestionnaireDelegate theDelegate)
        {
            UPQuestionnaire quest = this.cacheByCode.ValueOrDefault(code);

            if (quest != null || theDelegate == null)
            {
                return(quest);
            }

            quest = new UPQuestionnaire(code, this);
            this.pendingQuestionnaires.Add(quest);
            quest.Load(theDelegate);
            return(null);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UPQuestionnaireQuestionGroup"/> class.
 /// </summary>
 /// <param name="questionnaire">The questionnaire.</param>
 public UPQuestionnaireQuestionGroup(UPQuestionnaire questionnaire)
 {
     this.questions     = new List <UPQuestionnaireQuestion>();
     this.Questionnaire = questionnaire;
     this.Label         = LocalizedString.TextProcessSurvey;
 }
Esempio n. 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPQuestionnaireQuestion"/> class.
        /// </summary>
        /// <param name="recordIdentification">The record identification.</param>
        /// <param name="data">The data.</param>
        /// <param name="questionnaire">The questionnaire.</param>
        public UPQuestionnaireQuestion(string recordIdentification, Dictionary <string, object> data, UPQuestionnaire questionnaire)
        {
            this.Label           = data.ValueOrDefault(Constants.QuestionnaireLabel) as string;
            this.QuestionId      = data.ValueOrDefault(Constants.QuestionnaireQuestionNumber) as string;
            this.QuestionSortKey = Convert.ToInt32(this.QuestionId).ToString("D8");
            this.InfoAreaId      = data.ValueOrDefault(Constants.QuestionnaireInfoAreaId) as string;
            this.NextQuestionId  = data.ValueOrDefault(Constants.QuestionnaireFollowUpNumber) as string;
            int nextQuestionIntId = Convert.ToInt32(this.NextQuestionId);

            if (nextQuestionIntId > 0)
            {
                int questionIntId = Convert.ToInt32(this.QuestionId);
                if (nextQuestionIntId <= questionIntId)
                {
                    this.NextQuestionId = string.Empty;
                }
            }

            this.Mandatory      = data.ValueOrDefault(Constants.QuestionnaireMandatory) as string == "true";
            this.Read           = data.ValueOrDefault(Constants.QuestionnaireRead) as string == "true";
            this.Save           = data.ValueOrDefault(Constants.QuestionnaireSave) as string == "true";
            this.multiple       = data.ValueOrDefault(Constants.QuestionnaireMultiple) as string == "true";
            this.AdditionalInfo = data.ValueOrDefault(Constants.QuestionnaireAdditionalInfo) as string;
            this.StartsNewGroup = data.ValueOrDefault(Constants.QuestionnaireNewSection) as string == "true";
            this.DefaultAnswer  = data.ValueOrDefault(Constants.QuestionnaireDefault) as string;
            this.Hide           = data.ValueOrDefault(Constants.QuestionnaireHide) as string == "true";

            string fieldIdString = data.ValueOrDefault(Constants.QuestionnaireFieldId) as string;

            if (!string.IsNullOrEmpty(fieldIdString))
            {
                this.FieldId = Convert.ToInt32(fieldIdString);
                if (this.FieldId >= 0)
                {
                    ICRMDataStore dataStore = UPCRMDataStore.DefaultStore;
                    this.Field     = new UPCRMField(this.FieldId, this.InfoAreaId);
                    this.FieldInfo = dataStore.FieldInfoForField(this.Field);
                }
                else
                {
                    this.FieldId = -1;
                }
            }
            else
            {
                this.FieldId = -1;
            }

            this.RecordIdentification = recordIdentification;
            this.Questionnaire        = questionnaire;
        }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UPQuestionnaireQuestion"/> class.
 /// </summary>
 /// <param name="row">The row.</param>
 /// <param name="questionnaire">The questionnaire.</param>
 public UPQuestionnaireQuestion(UPCRMResultRow row, UPQuestionnaire questionnaire)
     : this(row.RootRecordIdentification, row.ValuesWithFunctions(), questionnaire)
 {
 }
Esempio n. 8
0
 /// <summary>
 /// Questionnaire the did finish with result.
 /// </summary>
 /// <param name="questionnaire">The questionnaire.</param>
 /// <param name="result">The result.</param>
 public void QuestionnaireDidFinishWithResult(UPQuestionnaire questionnaire, object result)
 {
     this.Questionnaire = questionnaire;
     this.QuestionnaireLoaded();
 }
Esempio n. 9
0
 /// <summary>
 /// Questionnaire the did fail with error.
 /// </summary>
 /// <param name="questionnaire">The questionnaire.</param>
 /// <param name="error">The error.</param>
 public void QuestionnaireDidFailWithError(UPQuestionnaire questionnaire, Exception error)
 {
     this.TheDelegate.SurveyDidFailWithError(this, error);
 }