/// <summary>
 /// Maps SurveyMetaData entity to SurveyInfoBO business object.
 /// </summary>
 /// <param name="entity">A SurveyMetaData entity to be transformed.</param>
 /// <returns>A SurveyInfoBO business object.</returns>
 public static SurveyInfoBO ToBusinessObject(SurveyInfoDTO pDTO)
 {
     return(new SurveyInfoBO
     {
         SurveyId = pDTO.SurveyId,
         SurveyName = pDTO.SurveyName,
         SurveyNumber = pDTO.SurveyNumber,
         XML = pDTO.XML,
         IntroductionText = pDTO.IntroductionText,
         ExitText = pDTO.ExitText,
         OrganizationName = pDTO.OrganizationName,
         DepartmentName = pDTO.DepartmentName,
         ClosingDate = pDTO.ClosingDate,
         UserPublishKey = pDTO.UserPublishKey,
         SurveyType = pDTO.SurveyType,
         OrganizationKey = pDTO.OrganizationKey,
         IsDraftMode = pDTO.IsDraftMode,
         StartDate = pDTO.StartDate,
         OwnerId = pDTO.OwnerId,
         DBConnectionString = pDTO.DBConnectionString,
         IsSqlProject = pDTO.IsSqlProject,
         ViewId = pDTO.ViewId,
         IsShareable = pDTO.IsShareable,
         DataAccessRuleId = pDTO.DataAccessRuleId,
         RelateViewIds = pDTO.RelateViewIds,
         ViewIdNames = pDTO.ViewIdNames
     });
 }
示例#2
0
 public static SurveyInfoBO ToSurveyInfoBO(this SurveyInfoDTO surveyInfoDTO)
 {
     return(new SurveyInfoBO
     {
         SurveyId = surveyInfoDTO.SurveyId,
         SurveyName = surveyInfoDTO.SurveyName,
         SurveyNumber = surveyInfoDTO.SurveyNumber,
         IntroductionText = surveyInfoDTO.IntroductionText,
         ExitText = surveyInfoDTO.ExitText,
         OrganizationName = surveyInfoDTO.OrganizationName,
         DepartmentName = surveyInfoDTO.DepartmentName,
         ClosingDate = surveyInfoDTO.ClosingDate,
         UserPublishKey = surveyInfoDTO.UserPublishKey,
         SurveyType = surveyInfoDTO.SurveyType,
         OrganizationKey = surveyInfoDTO.OrganizationKey,
         IsDraftMode = surveyInfoDTO.IsDraftMode,
         StartDate = surveyInfoDTO.StartDate,
         OwnerId = surveyInfoDTO.OwnerId,
         DBConnectionString = surveyInfoDTO.DBConnectionString,
         IsSqlProject = surveyInfoDTO.IsSqlProject,
         ViewId = surveyInfoDTO.ViewId,
         IsShareable = surveyInfoDTO.IsShareable,
         DataAccessRuleId = surveyInfoDTO.DataAccessRuleId,
     });
 }
示例#3
0
        public MvcDynamicForms.Form GetSurveyFormData(string surveyId, int pageNumber, SurveyAnswerDTO surveyAnswerDTO)
        {
            SurveyInfoModel surveyInfoModel = GetSurveyInfoModel(surveyId);
            SurveyInfoDTO   surveyInfoDTO   = Epi.Web.MVC.Models.Mapper.ToSurveyInfoDTO(surveyInfoModel);

            MvcDynamicForms.Form form = Epi.Web.MVC.Utility.FormProvider.GetForm(surveyInfoDTO, 1, null);
            return(form);
        }
示例#4
0
        public void TestSurveyInfoBODTO()
        {
            SurveyInfoBO  objsurveyinfobo  = new SurveyInfoBO();
            SurveyInfoDTO objsurveyInfoDTO = new SurveyInfoDTO();

            int numberOfPublicPropertiesofSurveyInfoBO  = objsurveyinfobo.GetType().GetProperties().Count();
            int numberOfPublicPropertiesofSurveyInfoDTO = objsurveyInfoDTO.GetType().GetProperties().Count();

            Assert.AreEqual(numberOfPublicPropertiesofSurveyInfoBO, SurveyInfoBOPropertyCount, "SurveyInfoBO properties has been changed");
            Assert.AreEqual(numberOfPublicPropertiesofSurveyInfoDTO, SurveyInfoDTOPropertyCount, "SurveyInfoDTO properties has been changed");
        }
示例#5
0
 /// <summary>
 /// Returns a SurveyInfoDTO object
 /// </summary>
 /// <param name="surveyInfoRequest"></param>
 /// <param name="surveyInfoService"></param>
 /// <param name="surveyId"></param>
 /// <returns></returns>
 public static SurveyInfoDTO GetSurveyInfoDTO(SurveyInfoRequest surveyInfoRequest,
                                              ISurveyInfoService surveyInfoService,
                                              string surveyId)
 {
     surveyInfoRequest.Criteria.SurveyIdList.Add(surveyId);
     try
     {
         SurveyInfoDTO result = surveyInfoService.GetSurveyInfoByFormId(surveyId).ToSurveyInfoDTO();
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#6
0
        public List <SurveyInfoDTO> ListOfSurveyResponse()
        {
            SurveyResponseRepository srep = new SurveyResponseRepository();

            SurveyInfoDTO sr = new SurveyInfoDTO();

            sr.SurveyId     = "1";
            sr.SurveyNumber = "11";
            sr.SurveyName   = "Abc Survey";
            sr.XML          = "";
            sr.IsSuccess    = true;
            sr.ClosingDate  = DateTime.Parse("2011-12-05");
            srep.AddSurveyResponse(sr);

            sr              = new SurveyInfoDTO();
            sr.SurveyId     = "2";
            sr.SurveyNumber = "22";
            sr.SurveyName   = "Bbc Survey";
            sr.XML          = "";
            sr.IsSuccess    = true;
            sr.ClosingDate  = DateTime.Parse("2011-12-06");
            srep.AddSurveyResponse(sr);

            sr              = new SurveyInfoDTO();
            sr.SurveyId     = "3";
            sr.SurveyNumber = "33";
            sr.SurveyName   = "Cbc Survey";
            sr.XML          = "";
            sr.IsSuccess    = true;
            sr.ClosingDate  = DateTime.Parse("2011-12-03");
            srep.AddSurveyResponse(sr);

            sr              = new SurveyInfoDTO();
            sr.SurveyId     = "4";
            sr.SurveyNumber = "44";
            sr.SurveyName   = "Dbc Survey";
            sr.XML          = "";
            sr.IsSuccess    = true;
            sr.ClosingDate  = DateTime.Parse("2011-12-08");
            srep.AddSurveyResponse(sr);

            return(srep.ShowSurveyResponseList());
        }
示例#7
0
 public static SurveyInfoModel ToFormInfoModel(this SurveyInfoDTO SurveyInfoDTO)
 {
     return(new SurveyInfoModel
     {
         SurveyId = SurveyInfoDTO.SurveyId,
         SurveyNumber = SurveyInfoDTO.SurveyNumber,
         SurveyName = SurveyInfoDTO.SurveyName,
         OrganizationName = SurveyInfoDTO.OrganizationName,
         DepartmentName = SurveyInfoDTO.DepartmentName,
         IntroductionText = SurveyInfoDTO.IntroductionText,
         ExitText = SurveyInfoDTO.ExitText,
         IsSuccess = SurveyInfoDTO.IsSuccess,
         SurveyType = SurveyInfoDTO.SurveyType,
         ClosingDate = SurveyInfoDTO.ClosingDate,
         UserPublishKey = SurveyInfoDTO.UserPublishKey,
         IsDraftMode = SurveyInfoDTO.IsDraftMode,
         StartDate = SurveyInfoDTO.StartDate,
         IsSqlProject = SurveyInfoDTO.IsSqlProject,
         FormOwnerId = SurveyInfoDTO.OwnerId,
     });
 }
示例#8
0
 /// <summary>
 /// Maps SurveyMetaData entity to SurveyInfoBO business object.
 /// </summary>
 /// <param name="entity">A SurveyMetaData entity to be transformed.</param>
 /// <returns>A SurveyInfoBO business object.</returns>
 public static SurveyInfoBO ToBusinessObject(SurveyInfoDTO pDTO)
 {
     return(new SurveyInfoBO
     {
         SurveyId = pDTO.SurveyId,
         SurveyName = pDTO.SurveyName,
         SurveyNumber = pDTO.SurveyNumber,
         XML = pDTO.XML,
         IntroductionText = pDTO.IntroductionText,
         ExitText = pDTO.ExitText,
         OrganizationName = pDTO.OrganizationName,
         DepartmentName = pDTO.DepartmentName,
         ClosingDate = pDTO.ClosingDate,
         UserPublishKey = pDTO.UserPublishKey,
         SurveyType = pDTO.SurveyType,
         OrganizationKey = pDTO.OrganizationKey,
         IsDraftMode = pDTO.IsDraftMode,
         StartDate = pDTO.StartDate,
         DBConnectionString = pDTO.DBConnectionString,
         IsSqlProject = pDTO.IsSqlProject,
         OrganizationId = pDTO.OrganizationId,
         ParentId = pDTO.ParentId
     });
 }
示例#9
0
        /// <summary>
        /// get the survey form data
        /// </summary>
        /// <param name="surveyId"></param>
        /// <param name="pageNumber"></param>
        /// <param name="surveyAnswerDTO"></param>
        /// <param name="isMobileDevice"></param>
        /// <param name="surveyAnswerDTOList"></param>
        /// <param name="formsHierarchyDTOList"></param>
        /// <param name="isAndroid"></param>
        /// <returns></returns>
        public MvcDynamicForms.Form GetSurveyFormData(
            string surveyId,
            int pageNumber,
            SurveyAnswerDTO surveyAnswerDTO,
            bool isMobileDevice,
            List <SurveyAnswerDTO> surveyAnswerDTOList     = null,
            List <FormsHierarchyDTO> formsHierarchyDTOList = null,
            bool isAndroid = false)
        {
            List <SurveyInfoDTO> surveyInfoDTOList = new List <SurveyInfoDTO>();

            //Get the SurveyInfoDTO
            SurveyInfoDTO surveyInfoDTO;

            if (formsHierarchyDTOList == null)
            {
                surveyInfoDTO = SurveyHelper.GetSurveyInfoDTO(_surveyInfoRequest, _surveyInfoService, surveyId);

                if (surveyAnswerDTOList != null)
                {
                    foreach (var item in surveyAnswerDTOList)
                    {
                        Epi.Cloud.Common.Message.SurveyInfoRequest request = new SurveyInfoRequest();
                        request.Criteria.SurveyIdList.Add(item.SurveyId);
                        SurveyInfoDTO surveyInfoDTO2 = SurveyHelper.GetSurveyInfoDTO(request, _surveyInfoService, item.SurveyId);
                        surveyInfoDTOList.Add(surveyInfoDTO2);
                    }
                }
            }
            else
            {
                var SurveyInfoDTO = formsHierarchyDTOList.First(x => x.FormId == (surveyAnswerDTO != null ? surveyAnswerDTO.SurveyId : surveyId));
                surveyInfoDTO = SurveyInfoDTO.SurveyInfo;

                surveyAnswerDTOList = new List <SurveyAnswerDTO>();
                surveyAnswerDTOList.Add(surveyAnswerDTO);

                foreach (var item in formsHierarchyDTOList)
                {
                    if (item.ResponseIds.Count() > 0)
                    {
                        var DTO = item.ResponseIds.FirstOrDefault(z => z.ResponseId == surveyAnswerDTO.ParentResponseId);
                        if (DTO != null && !surveyAnswerDTOList.Contains(DTO))
                        {
                            surveyAnswerDTOList.Add(DTO);
                        }
                    }
                }

                foreach (var item in surveyAnswerDTOList)
                {
                    if (item != null)
                    {
                        var formsHierarchyDTO = formsHierarchyDTOList.FirstOrDefault(x => x.FormId == item.SurveyId);
                        surveyInfoDTOList.Add(formsHierarchyDTO.SurveyInfo);
                    }
                }
            }

            var formProvider = isMobileDevice ? new MobileFormProvider(surveyId) : new FormProvider(surveyId);

            MvcDynamicForms.Form form = formProvider.GetForm(surveyInfoDTO, pageNumber, surveyAnswerDTO, surveyAnswerDTOList, surveyInfoDTOList, isAndroid);

            return(form);
        }
示例#10
0
        public virtual Form GetForm(SurveyInfoDTO surveyInfo, int pageNumber, SurveyAnswerDTO surveyAnswer, List <SurveyAnswerDTO> surveyAnswerList, List <SurveyInfoDTO> surveyInfoList, bool isAndroid)
        {
            // Save last values for subsequent calls from ValidateAll in SurveyController
            SurveyAnswerList = surveyAnswerList;
            SurveyInfoList   = surveyInfoList;

            var surveyId = CurrentFormId = surveyInfo.SurveyId;

            FormDigest currentFormDigest = GetFormDigest(surveyId);
            PageDigest currentPageDigest = GetPageDigestByPageNumber(surveyId, pageNumber);

            var pageId = currentPageDigest.PageId;

            string             formId             = currentFormDigest.FormId;
            string             formName           = currentFormDigest.FormName;
            FormResponseDetail formResponseDetail = surveyAnswer.ResponseDetail != null
                ? surveyAnswer.ResponseDetail
                : new FormResponseDetail {
                FormId = formId, FormName = formName
            };

            PageResponseDetail pageResponseDetail = formResponseDetail.GetPageResponseDetailByPageId(pageId);

            var form = new Form();

            form.PageId    = pageId.ToString();
            form.IsAndroid = isAndroid;

            form.ResponseId = surveyAnswer.ResponseId;
            form.FormName   = surveyAnswer.FormName;
            form.FormId     = surveyAnswer.FormId;

            form.ParentResponseId = surveyAnswer.ParentResponseId;
            form.ParentFormName   = surveyAnswer.ParentFormName;
            form.ParentFormId     = surveyAnswer.ParentFormId;

            form.RootResponseId = surveyAnswer.RootResponseId;
            form.RootFormName   = surveyAnswer.RootFormName;
            form.RootFormId     = surveyAnswer.RootFormId;

            form.SurveyInfo = surveyInfo;

            //Watermark
            if (form.SurveyInfo.IsDraftMode)
            {
                form.IsDraftModeStyleClass = "draft";
            }

            form.CurrentPage = pageNumber;

            form.NumberOfPages = currentFormDigest.NumberOfPages;

            double _Width, _Height;

            var orientationIsPortrait = currentFormDigest.Orientation == "Portrait";

            _Height = orientationIsPortrait ? currentFormDigest.Height : currentFormDigest.Width;
            _Width  = orientationIsPortrait ? currentFormDigest.Width : currentFormDigest.Height;

            //Add checkcode to Form
            string checkcode = currentFormDigest.CheckCode;

            StringBuilder javaScript          = new StringBuilder();
            StringBuilder VariableDefinitions = new StringBuilder();
            string        defineFormat        = "cce_Context.define(\"{0}\", \"{1}\", \"{2}\", \"{3}\");";
            string        defineNumberFormat  = "cce_Context.define(\"{0}\", \"{1}\", \"{2}\", new Number({3}));";

            if (surveyAnswerList != null && surveyAnswerList.Count > 0)
            {
                form.FormCheckCodeObj = form.GetRelateCheckCodeObj(GetRelateFormObj(surveyAnswerList, surveyInfoList), checkcode);
            }
            else
            {
                form.FormCheckCodeObj = form.GetCheckCodeObj(surveyInfo.GetFieldDigests(surveyId), formResponseDetail, checkcode);
            }

            form.HiddenFieldsList      = formResponseDetail.HiddenFieldsList;
            form.HighlightedFieldsList = formResponseDetail.HighlightedFieldsList;
            form.DisabledFieldsList    = formResponseDetail.DisabledFieldsList;
            form.RequiredFieldsList    = formResponseDetail.RequiredFieldsList;

            form.FormCheckCodeObj.GetVariableJavaScript(VariableDefinitions);
            form.FormCheckCodeObj.GetSubroutineJavaScript(VariableDefinitions);
            string pageName = currentPageDigest.PageName;

            //Generate page level Java script (Before)
            javaScript.Append(GetPageLevelJS(pageNumber, form, pageName, "Before"));
            //Generate page level Java script (After)
            javaScript.Append(GetPageLevelJS(pageNumber, form, pageName, "After"));

            SetProviderSpecificProperties(form, _Height, _Width);

            var responseQA = pageResponseDetail != null ? pageResponseDetail.ResponseQA : new Dictionary <string, string>();

            //if (responseQA.Count == 0)
            //{
            //    var pageFieldAttributes = GetPageFieldAttributesByPageId(surveyId, pageId);
            //    responseQA = new Dictionary<string, string>();

            //    foreach (var fieldAttributes in pageFieldAttributes.Values)
            //    {
            //        if (fieldAttributes.Value != null)
            //        {
            //            responseQA.Add(fieldAttributes.FieldName.ToLower(), fieldAttributes.Value);
            //        }
            //    }
            //}

            AddFormFields(surveyInfo, pageId, responseQA, form, _Width, _Height, checkcode, javaScript);

            form.FormJavaScript = VariableDefinitions.ToString() + "\n" + javaScript.ToString();

            return(form);
        }
示例#11
0
 public virtual Form GetForm(SurveyInfoDTO surveyInfo, int pageNumber, SurveyAnswerDTO surveyAnswer, bool isAndroid = false)
 {
     return(GetForm(surveyInfo, pageNumber, surveyAnswer, SurveyAnswerList, SurveyInfoList, isAndroid));
 }
示例#12
0
        protected virtual void AddFormFields(SurveyInfoDTO surveyInfo, int pageId, Dictionary <string, string> responseQA, Form form, double _Width, double _Height, string checkcode, StringBuilder javaScript)
        {
            var formId = surveyInfo.SurveyId;
            IEnumerable <FieldAttributes> currentPageFieldAttributes = surveyInfo.GetPageFieldAttributesByPageId(formId, pageId).Values;

            foreach (var fieldAttributes in currentPageFieldAttributes)
            {
                string fieldValue = null;

                fieldValue = (responseQA.TryGetValue(fieldAttributes.FieldName.ToLower(), out fieldValue) ? fieldValue : string.Empty);

                javaScript.Append(GetFormJavaScript(checkcode, form, fieldAttributes.FieldName));
                fieldAttributes.IsHighlighted = GetControlState(fieldAttributes.FieldName, form.HighlightedFieldsList);
                switch (fieldAttributes.FieldType)
                {
                case FieldTypes.Text:       // textbox
                    form.AddFields(GetTextBox(fieldAttributes, _Width, _Height, fieldValue));
                    break;

                case FieldTypes.Label:      //Label/Title
                    form.AddFields(GetLabel(fieldAttributes, _Width, _Height));
                    break;

                case FieldTypes.UppercaseText:
                    break;

                case FieldTypes.Multiline:      //MultiLineTextBox
                    form.AddFields(GetTextArea(fieldAttributes, _Width, _Height, fieldValue));
                    break;

                case FieldTypes.Number:     //NumericTextBox

                    form.AddFields(GetNumericTextBox(fieldAttributes, _Width, _Height, fieldValue));
                    break;

                case FieldTypes.Date:       //DatePicker
                    form.AddFields(GetDatePicker(fieldAttributes, _Width, _Height, fieldValue));
                    break;

                case FieldTypes.Time:     //TimePicker
                    form.AddFields(GetTimePicker(fieldAttributes, _Width, _Height, fieldValue));
                    break;

                case FieldTypes.DateTime:
                    break;

                case FieldTypes.Checkbox:     //CheckBox
                    var checkbox = GetCheckBox(fieldAttributes, _Width, _Height, fieldValue);
                    form.AddFields(checkbox);
                    break;

                case FieldTypes.YesNo:      //DropDown Yes/No
                    if (fieldValue == "1" || fieldValue == "true")
                    {
                        fieldValue = "Yes";
                    }
                    else if (fieldValue == "0" || fieldValue == "false")
                    {
                        fieldValue = "No";
                    }

                    var dropdownSelectedValueYN = GetDropDown(fieldAttributes, _Width, _Height, fieldValue, "Yes&#;No", 11);
                    form.AddFields(dropdownSelectedValueYN);
                    break;

                case FieldTypes.Option:     //RadioList
                    AddRadioButtonGroupBox(form, fieldAttributes, _Width, _Height);
                    var selectedRadioListValue = fieldValue;
                    var radioListValues        = fieldAttributes.List;
                    form.AddFields(GetRadioList(fieldAttributes, _Width, _Height, selectedRadioListValue));

                    break;

                case FieldTypes.LegalValues:        //DropDown LegalValues
                    var dropDownLegalValues = string.Join("&#;", fieldAttributes.SourceTableValues);
                    var selectedLegalValue  = fieldValue;
                    form.AddFields(GetDropDown(fieldAttributes, _Width, _Height, selectedLegalValue, dropDownLegalValues, (int)FieldTypes.LegalValues));
                    break;

                case FieldTypes.Codes:      //DropDown Codes
                    var dropDownCodesValues        = string.Join("&#;", fieldAttributes.SourceTableValues);
                    var selectedCodesValue         = fieldValue;
                    var dropDownSelectedCodesValue = GetDropDown(fieldAttributes, _Width, _Height, selectedCodesValue, dropDownCodesValues, (int)FieldTypes.Codes, fieldAttributes.RelateCondition);
                    form.AddFields(dropDownSelectedCodesValue);
                    break;

                case FieldTypes.CommentLegal:       //DropDown CommentLegal
                    var dropDownCommentLegalValues        = string.Join("&#;", fieldAttributes.SourceTableValues);
                    var selectedCommentLegalValue         = fieldValue;
                    var dropDownSelectedCommentLegalValue = GetDropDown(fieldAttributes, _Width, _Height, selectedCommentLegalValue, dropDownCommentLegalValues, 19);
                    form.AddFields(dropDownSelectedCommentLegalValue);
                    break;

                case FieldTypes.Relate:     //RelateButton
                    form.AddFields(GetRelateButton(fieldAttributes, _Width, _Height));
                    break;

                case FieldTypes.Group:      //GroupBox
                    form.AddFields(GetGroupBox(fieldAttributes, _Width, _Height, fieldValue));
                    break;
                }
            }
        }
示例#13
0
 internal static FormInfoModel ToFormInfoModel(SurveyInfoDTO surveyInfo)
 {
     throw new NotImplementedException();
 }
示例#14
0
 public void Update(SurveyInfoDTO t)
 {
     throw new NotImplementedException();
 }
示例#15
0
 public void Insert(SurveyInfoDTO t)
 {
     throw new NotImplementedException();
 }
示例#16
0
        public static Form GetForm(SurveyInfoDTO surveyInfo, int pageNumber, SurveyAnswerDTO surveyAnswer, bool isMobile = false, bool IsAndroid = false, List <SourceTableDTO> SourceTableList = null)

        {
            Form form = null;

            string surveyId     = surveyInfo.SurveyId;
            string isMobileText = isMobile ? "true" : "false";

            string cacheKey = surveyId +
                              ",page:" + pageNumber.ToString() +
                              ",mobile:" + isMobileText;

            bool enableFormCaching = false;

            if (enableFormCaching)
            {
                form = CacheUtility.Get(cacheKey) as Form;
            }

            if (form == null)
            {
                form           = new Form();
                form.IsAndroid = IsAndroid;
                if (isMobile)
                {
                    form.IsMobile         = isMobile;
                    form.FormWrapperClass = "MvcDynamicMobileForm";
                }

                form.SurveyInfo = surveyInfo;

                if (form.SurveyInfo.IsDraftMode)
                {
                    form.IsDraftModeStyleClass = "draft";
                }
                form.StatusId = surveyAnswer.Status;
                string xml = form.SurveyInfo.XML;
                form.CurrentPage = pageNumber;

                if (string.IsNullOrEmpty(xml))
                {
                    form.NumberOfPages = 1;
                }
                else
                {
                    form.NumberOfPages = GetNumberOfPages(XDocument.Parse(xml));
                }

                if (string.IsNullOrEmpty(xml) == false)
                {
                    form.XDocMetadata = XDocument.Parse(xml);

                    form.FieldsTypeIDs = from _FieldTypeID in form.XDocMetadata.Descendants("Field") select _FieldTypeID;

                    double width, height;
                    width       = GetWidth(form.XDocMetadata);
                    height      = GetHeight(form.XDocMetadata);
                    form.PageId = GetPageId(form.XDocMetadata, pageNumber);
                    form.Width  = width;
                    form.Height = height;

                    XElement      ViewElement         = form.XDocMetadata.XPathSelectElement("Template/Project/View");
                    string        checkcode           = ViewElement.Attribute("CheckCode").Value.ToString();
                    StringBuilder JavaScript          = new StringBuilder();
                    StringBuilder VariableDefinitions = new StringBuilder();

                    XDocument xdocResponse = XDocument.Parse(surveyAnswer.XML);

                    form.RequiredFieldsList    = xdocResponse.Root.Attribute("RequiredFieldsList").Value;
                    form.HiddenFieldsList      = xdocResponse.Root.Attribute("HiddenFieldsList").Value;
                    form.HighlightedFieldsList = xdocResponse.Root.Attribute("HighlightedFieldsList").Value;
                    form.DisabledFieldsList    = xdocResponse.Root.Attribute("DisabledFieldsList").Value;
                    if (SurveyAnswerList != null)
                    {
                        form.FormCheckCodeObj = form.GetRelateCheckCodeObj(GetRelateFormObj(), checkcode);
                    }
                    else
                    {
                        form.FormCheckCodeObj = form.GetCheckCodeObj(form.XDocMetadata, xdocResponse, checkcode);
                    }
                    form.FormCheckCodeObj.GetVariableJavaScript(VariableDefinitions);
                    form.FormCheckCodeObj.GetSubroutineJavaScript(VariableDefinitions);

                    form.SourceTableList = SourceTableList;

                    string pageName = GetPageName(form.XDocMetadata, pageNumber);

                    JavaScript.Append(GetPageLevelJS(pageNumber, form, pageName, "Before"));
                    JavaScript.Append(GetPageLevelJS(pageNumber, form, pageName, "After"));

                    foreach (var fieldElement in form.FieldsTypeIDs)
                    {
                        string formJavaScript = GetFormJavaScript(checkcode, form, fieldElement.Attribute("Name").Value);
                        JavaScript.Append(formJavaScript);
                    }
                    ///JavaScript POC start

                    if (checkcode.Contains("Script-Start") && checkcode.Contains("Script-End"))
                    {
                        var startTag   = "Script-Start";
                        int startIndex = checkcode.IndexOf(startTag) + startTag.Length;
                        int endIndex   = checkcode.IndexOf("Script-End", startIndex);
                        var Script     = checkcode.Substring(startIndex, endIndex - startIndex);
                        JavaScript.Append(Script);
                    }

                    ///JavaScript POC End

                    AddFormFields(pageNumber, form, surveyAnswer, SourceTableList, isMobile);
                    form.FormJavaScript = VariableDefinitions.ToString() + "\n" + JavaScript.ToString();
                }

                if (enableFormCaching)
                {
                    CacheUtility.Insert(cacheKey, form, surveyId);
                }
            }
            else
            {
                form.Fields.Clear();
                AddFormFields(pageNumber, form, surveyAnswer);
            }

            form.ResponseId = surveyAnswer.ResponseId;

            form.IsSaved = false;

            if (surveyAnswer.XML.Contains("ResponseDetail"))
            {
                SetStates(form, surveyAnswer);
            }

            return(form);
        }
示例#17
0
 public void AddSurveyResponse(SurveyInfoDTO sResponse)
 {
     _surveyResponseList.Add(sResponse);
 }
 public static FormsHierarchyDTO MergeIntoFormsHierarchyDTO(this FormDigest formDigest, FormsHierarchyDTO formsHierarchyDTO, SurveyInfoDTO surveyInfoDTO = null)
 {
     formsHierarchyDTO.FormId     = formDigest.FormId;
     formsHierarchyDTO.ViewId     = formDigest.ViewId;
     formsHierarchyDTO.RootFormId = formDigest.RootFormId;
     formsHierarchyDTO.IsRoot     = formDigest.IsRootForm;
     if (surveyInfoDTO != null)
     {
         formsHierarchyDTO.SurveyInfo = surveyInfoDTO;
     }
     return(formsHierarchyDTO);
 }
        public static List <FormsHierarchyDTO> ToFormsHierarchyDTOList(this FormDigest[] formDigests, SurveyInfoDTO surveyInfoDTO)
        {
            List <FormsHierarchyDTO> formsHierarchyDTOs = formDigests.Select(d => d.ToFormsHierarchyDTO(surveyInfoDTO)).ToList();

            return(formsHierarchyDTOs);
        }
        public static FormsHierarchyDTO ToFormsHierarchyDTO(this FormDigest formDigest, SurveyInfoDTO surveyInfoDTO)
        {
            var formsHierarchyDTO = new FormsHierarchyDTO {
                SurveyInfo = surveyInfoDTO, IsSqlProject = true
            };

            return(formDigest.MergeIntoFormsHierarchyDTO(formsHierarchyDTO));
        }