示例#1
0
        /// <summary>
        /// get the survey form data
        /// </summary>
        /// <param name="surveyId"></param>
        /// <param name="responseId"></param>
        /// <param name="pageNumber"></param>
        /// <param name="surveyAnswerDTO"></param>
        /// <returns></returns>
        public MvcDynamicForms.Form GetSurveyFormData(string surveyId, int pageNumber, Epi.Web.Common.DTO.SurveyAnswerDTO surveyAnswerDTO, bool isMobileDevice = false, string callerThereby = "", bool IsAndroid = false, bool GetSourceTables = true)
        {
            SourceTablesResponse Response = new SourceTablesResponse();
            SourceTablesRequest  Request  = new SourceTablesRequest();

            if (GetSourceTables)
            {
                Request.SurveyId = surveyId;
                Response         = _iSurveyInfoRepository.GetSourceTables(Request);//Pain Point
            }
            Epi.Web.Common.DTO.SurveyInfoDTO surveyInfoDTO = SurveyHelper.GetSurveyInfoDTO(_surveyInfoRequest, _iSurveyInfoRepository, surveyId);
            MvcDynamicForms.Form             form          = null;
            form = Epi.Web.MVC.Utility.FormProvider.GetForm(surveyInfoDTO, pageNumber, surveyAnswerDTO, isMobileDevice, IsAndroid, Response.List);

            return(form);
        }
示例#2
0
        /// <summary>
        /// Maps SurveyInfo DTO to SurveyInfo Model.
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>


        public static SurveyInfoModel ToSurveyInfoModel(this Epi.Web.Common.DTO.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,
                XML = SurveyInfoDTO.XML,
                IsSuccess = SurveyInfoDTO.IsSuccess,
                SurveyType = SurveyInfoDTO.SurveyType,
                ClosingDate = SurveyInfoDTO.ClosingDate,
                UserPublishKey = SurveyInfoDTO.UserPublishKey,
                IsDraftMode = SurveyInfoDTO.IsDraftMode,
                StartDate = SurveyInfoDTO.StartDate,
                IsSqlProject = SurveyInfoDTO.IsSqlProject
                , OrganizationKey = SurveyInfoDTO.OrganizationKey
                , PublishedOrgName = SurveyInfoDTO.PublishedOrgName
            });
        }
示例#3
0
        public MvcDynamicForms.Form GetSurveyFormData(
            string surveyId,
            int pageNumber,
            Epi.Web.Common.DTO.SurveyAnswerDTO surveyAnswerDTO,
            bool IsMobileDevice,
            List <SurveyAnswerDTO> _SurveyAnswerDTOList = null,
            List <Epi.Web.Common.DTO.FormsHierarchyDTO> FormsHierarchyDTOList = null, bool IsAndroid = false, bool GetSourceTables = true)
        {
            List <SurveyInfoDTO> List = new List <SurveyInfoDTO>();


            //Get the SurveyInfoDTO
            Epi.Web.Common.DTO.SurveyInfoDTO surveyInfoDTO;
            if (FormsHierarchyDTOList == null || FormsHierarchyDTOList.Count() == 0)
            {
                surveyInfoDTO = SurveyHelper.GetSurveyInfoDTO(_surveyInfoRequest, _iSurveyInfoRepository, surveyId);//Pain Point 5s
                if (_SurveyAnswerDTOList != null)
                {
                    foreach (var item in _SurveyAnswerDTOList)
                    {
                        Epi.Web.Common.Message.SurveyInfoRequest request = new SurveyInfoRequest();
                        request.Criteria.SurveyIdList.Add(item.SurveyId);
                        Epi.Web.Common.DTO.SurveyInfoDTO _SurveyInfoDTO = SurveyHelper.GetSurveyInfoDTO(request, _iSurveyInfoRepository, item.SurveyId);
                        List.Add(_SurveyInfoDTO);
                    }
                }
            }

            else
            {
                //  var SurveyInfoDTO = FormsHierarchyDTOList.First(x => x.FormId == surveyAnswerDTO.SurveyId);

                var SurveyInfoDTO = FormsHierarchyDTOList.First(x => x.FormId == surveyId);
                surveyInfoDTO = SurveyInfoDTO.SurveyInfo;



                _SurveyAnswerDTOList = new List <SurveyAnswerDTO>();
                _SurveyAnswerDTOList.Add(surveyAnswerDTO);
                var DTOList = FormsHierarchyDTOList.Where(x => x.ResponseIds.Count() > 0);
                foreach (var item in DTOList)
                {
                    //if (item.ResponseIds.Count() > 0)
                    //{
                    var DTO = item.ResponseIds.FirstOrDefault(z => z.ResponseId == surveyAnswerDTO.RelateParentId);
                    if (DTO != null && !_SurveyAnswerDTOList.Contains(DTO))
                    {
                        _SurveyAnswerDTOList.Add(DTO);
                    }

                    //}
                }

                foreach (var item in _SurveyAnswerDTOList)
                {
                    var _SurveyInfoDTO = FormsHierarchyDTOList.FirstOrDefault(x => x.FormId == item.SurveyId);
                    List.Add(_SurveyInfoDTO.SurveyInfo);
                }
            }
            MvcDynamicForms.Form form     = null;
            SourceTablesResponse Response = new SourceTablesResponse();
            SourceTablesRequest  Request  = new Common.Message.SourceTablesRequest();

            if (GetSourceTables)
            {
                //if (IsMobileDevice)
                //{
                if (FormsHierarchyDTOList != null && FormsHierarchyDTOList.Count() > 0)
                {
                    Request.SurveyId = FormsHierarchyDTOList[0].FormId.ToString();
                }
                else
                {
                    if (string.IsNullOrEmpty(surveyAnswerDTO.ParentRecordId))
                    {
                        Request.SurveyId = surveyId;
                    }
                    else
                    {
                        Request.SurveyId = surveyAnswerDTO.ParentRecordId;
                    }
                }
                Response = _iSurveyInfoRepository.GetSourceTables(Request);//Pain Point
                //}
                //else
                //{
                //    Request.SurveyId = FormsHierarchyDTOList[0].FormId.ToString();
                //    Response = _iSurveyInfoRepository.GetSourceTables(Request);//Pain Point

                //}
            }
            //if (IsMobileDevice)
            //{
            //    Epi.Web.MVC.Utility.MobileFormProvider.SurveyInfoList = List;
            //    Epi.Web.MVC.Utility.MobileFormProvider.SurveyAnswerList = _SurveyAnswerDTOList;
            //    form = Epi.Web.MVC.Utility.MobileFormProvider.GetForm(surveyInfoDTO, pageNumber, surveyAnswerDTO, IsAndroid, Response.List);
            //}
            //else
            //{
            Epi.Web.MVC.Utility.FormProvider.SurveyInfoList   = List;
            Epi.Web.MVC.Utility.FormProvider.SurveyAnswerList = _SurveyAnswerDTOList;
            form = Epi.Web.MVC.Utility.FormProvider.GetForm(surveyInfoDTO, pageNumber, surveyAnswerDTO, IsMobileDevice, IsAndroid, Response.List);
            //}
            return(form);
        }