Example #1
0
        private void SendEmailNotification(PublishModel model, HttpPostedFileBase newfile2)
        {
            string strPassCode = Epi.Web.MVC.Utility.SurveyHelper.GetPassCode();
            var    SurveyInfo  = this._isurveyFacade.GetSurveyInfoModel(model.EmailSurveyKey);
            Guid   ResponseID  = Guid.NewGuid();

            Epi.Web.Common.DTO.SurveyAnswerDTO SurveyAnswer = _isurveyFacade.CreateSurveyAnswer(SurveyInfo.SurveyId, ResponseID.ToString());



            _isurveyFacade.UpdatePassCode(ResponseID.ToString(), strPassCode);
        }
Example #2
0
 public static SurveyAnswerModel ToSurveyAnswerModel(this Epi.Web.Common.DTO.SurveyAnswerDTO SurveyAnswerDTO)
 {
     return(new SurveyAnswerModel
     {
         ResponseId = SurveyAnswerDTO.ResponseId,
         SurveyId = SurveyAnswerDTO.SurveyId,
         DateUpdated = SurveyAnswerDTO.DateUpdated,
         DateCompleted = SurveyAnswerDTO.DateCompleted,
         Status = SurveyAnswerDTO.Status,
         XML = SurveyAnswerDTO.XML
     });
 }
        private void SendEmailNotification(PublishModel model, HttpPostedFileBase newfile2)
        {
            string strPassCode = Epi.Web.MVC.Utility.SurveyHelper.GetPassCode();
            var    SurveyInfo  = this._isurveyFacade.GetSurveyInfoModel(model.EmailSurveyKey);
            Guid   ResponseID  = Guid.NewGuid();

            Epi.Web.Common.DTO.SurveyAnswerDTO SurveyAnswer = _isurveyFacade.CreateSurveyAnswer(SurveyInfo.SurveyId, ResponseID.ToString());

            // Epi.Web.Common.Message.UserAuthenticationResponse AuthenticationResponse = _isurveyFacade.GetAuthenticationResponse(ResponseID.ToString());


            //  if (string.IsNullOrEmpty(AuthenticationResponse.PassCode))
            // {

            _isurveyFacade.UpdatePassCode(ResponseID.ToString(), strPassCode);
            // }
        }
Example #4
0
        public string GetSurveyResponseJson(Epi.Web.Common.DTO.SurveyAnswerDTO surveyAnswer, List <FormsHierarchyDTO> FormsHierarchyDTOList, SurveyControlsResponse List)
        {
            if (!string.IsNullOrEmpty(surveyAnswer.XML))
            {
                ResponseDetail Responsedetail = new ResponseDetail();

                var ChildFormsHierarchy = FormsHierarchyDTOList.Where(x => x.IsRoot == false);
                Dictionary <string, object> ResponseQA     = new Dictionary <string, object>();
                Dictionary <string, object> RootResponseQA = new Dictionary <string, object>();


                XDocument xdoc          = XDocument.Parse(surveyAnswer.XML);
                int       NumberOfPages = GetNumberOfPags(surveyAnswer.XML);

                Responsedetail.ResponseId = surveyAnswer.ResponseId;
                Responsedetail.FormId     = surveyAnswer.SurveyId;
                if (FormsHierarchyDTOList.Count() > 0)
                {
                    Responsedetail.OKey = FormsHierarchyDTOList[0].SurveyInfo.OrganizationKey.ToString().Substring(0, 8);
                }
                for (int i = 1; NumberOfPages + 1 > i; i++)
                {
                    try
                    {
                        var _FieldsTypeIDs = from _FieldTypeID in
                                             xdoc.Descendants("Page")

                                             where _FieldTypeID.Attribute("PageNumber").Value == (i).ToString()
                                             select _FieldTypeID;

                        var _PageFieldsTypeIDs = from _FieldTypeID1 in
                                                 _FieldsTypeIDs.Descendants("ResponseDetail")

                                                 select _FieldTypeID1;
                        foreach (var item in _PageFieldsTypeIDs)
                        {
                            if (!string.IsNullOrEmpty(item.Value))
                            {
                                try
                                {
                                    string ControlId        = item.Attribute("QuestionName").Value;
                                    bool   IsCheckBox       = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType == "CheckBox");
                                    bool   ISNumericTextBox = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType == "NumericTextBox");

                                    if (ISNumericTextBox && !string.IsNullOrEmpty(item.Value))
                                    {
                                        string uiSep = ".";
                                        if (item.Value.Contains(uiSep))
                                        {
                                            RootResponseQA.Add(item.Attribute("QuestionName").Value, Convert.ToDecimal(item.Value));
                                        }
                                        else
                                        {
                                            RootResponseQA.Add(item.Attribute("QuestionName").Value, Convert.ToInt64(item.Value));
                                        }
                                    }
                                    else if (IsCheckBox)
                                    {
                                        bool Ischecked = false;
                                        if (item.Value == "Yes")
                                        {
                                            RootResponseQA.Add(item.Attribute("QuestionName").Value, !Ischecked);
                                        }
                                        else
                                        {
                                            RootResponseQA.Add(item.Attribute("QuestionName").Value, Ischecked);
                                        }
                                    }
                                    else
                                    {
                                        RootResponseQA.Add(item.Attribute("QuestionName").Value, item.Value);
                                    }
                                }
                                catch (System.Exception ex)
                                {
                                }
                            }
                            else
                            {
                                RootResponseQA.Add(item.Attribute("QuestionName").Value, "");
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                    }
                }
                Responsedetail.ResponseQA = RootResponseQA;

                foreach (var child in ChildFormsHierarchy)
                {
                    List <SurveyAnswerDTO> childResponses = child.ResponseIds;
                    foreach (var childresponse in childResponses)
                    {
                        ResponseDetail childresponseDetail = new ResponseDetail();
                        childresponseDetail.FormId           = childresponse.SurveyId;
                        childresponseDetail.ResponseId       = childresponse.ResponseId;
                        childresponseDetail.ParentResponseId = childresponse.RelateParentId;
                        childresponseDetail.ParentFormId     = childresponse.ParentRecordId;
                        ResponseQA = new Dictionary <string, object>();
                        ResponseQA.Add("FKEY", childresponse.RelateParentId);
                        ResponseQA.Add("ResponseId", childresponse.ResponseId);

                        XDocument xdochild           = XDocument.Parse(childresponse.XML);
                        int       NumberOfPagesChild = GetNumberOfPags(childresponse.XML);
                        for (int i = 1; NumberOfPagesChild + 1 > i; i++)
                        {
                            var _FieldsTypeIDs = from _FieldTypeID in
                                                 xdochild.Descendants("Page")

                                                 where _FieldTypeID.Attribute("PageNumber").Value == (i).ToString()
                                                 select _FieldTypeID;

                            var _PageFieldsTypeIDs = from _FieldTypeID1 in
                                                     _FieldsTypeIDs.Descendants("ResponseDetail")

                                                     select _FieldTypeID1;

                            foreach (var item in _PageFieldsTypeIDs)
                            {
                                try
                                {
                                    string ControlId        = item.Attribute("QuestionName").Value;
                                    bool   IsCheckBox       = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType == "CheckBox");
                                    bool   ISNumericTextBox = (bool)List.SurveyControlList.Any(x => x.ControlId == ControlId && x.ControlType == "NumericTextBox");
                                    if (ISNumericTextBox && item.Value != null)
                                    {
                                        string uiSep = CultureInfo.CurrentUICulture.NumberFormat.NumberDecimalSeparator;
                                        if (item.Value.Contains(uiSep))
                                        {
                                            ResponseQA.Add(item.Attribute("QuestionName").Value, Convert.ToDecimal(item.Value));
                                        }
                                        else
                                        {
                                            ResponseQA.Add(item.Attribute("QuestionName").Value, Convert.ToInt32(item.Value));
                                        }
                                    }
                                    else if (IsCheckBox)
                                    {
                                        bool Ischecked = false;
                                        if (item.Value == "Yes")
                                        {
                                            ResponseQA.Add(item.Attribute("QuestionName").Value, !Ischecked);
                                        }
                                        else
                                        {
                                            ResponseQA.Add(item.Attribute("QuestionName").Value, Ischecked);
                                        }
                                    }
                                    else
                                    {
                                        ResponseQA.Add(item.Attribute("QuestionName").Value, item.Value);
                                    }
                                    ResponseQA.Add(item.Attribute("QuestionName").Value, item.Value);
                                }
                                catch (System.Exception ex)
                                {
                                }
                            }
                        }

                        childresponseDetail.ResponseQA = ResponseQA;
                        Responsedetail.ChildResponseDetailList.Add(childresponseDetail);
                    }
                }

                var json = JsonConvert.SerializeObject(Responsedetail);

                return(json);
            }
            else
            {
                return("");
            }
        }
        public ActionResult Index(string surveyId, SurveyAnswerModel surveyAnswerModel)
        {
            try
            {
                bool isMobileDevice = this.Request.Browser.IsMobileDevice;

                if (isMobileDevice == false)
                {
                    isMobileDevice = Epi.Web.MVC.Utility.SurveyHelper.IsMobileDevice(this.Request.UserAgent.ToString());
                }
                if (!string.IsNullOrEmpty(this.Request.Form["is_print_action"]) && this.Request.Form["is_print_action"].ToString().Equals("true", StringComparison.OrdinalIgnoreCase))
                {
                    string       ResponseId   = this.Request.Form["ResponseId"];
                    ActionResult actionResult = RedirectToAction("Index", "Print", new { responseId = ResponseId, FromFinal = true });
                    return(actionResult);
                }
                //FormsAuthentication.SignOut();
                FormsAuthentication.SetAuthCookie("BeginSurvey", false);
                Guid responseId = Guid.NewGuid();
                Epi.Web.Common.DTO.SurveyAnswerDTO SurveyAnswer = _isurveyFacade.CreateSurveyAnswer(surveyId, responseId.ToString());

                // Pass Code Logic  start
                Epi.Web.Common.Message.UserAuthenticationResponse AuthenticationResponse = _isurveyFacade.GetAuthenticationResponse(responseId.ToString());

                string strPassCode = Epi.Web.MVC.Utility.SurveyHelper.GetPassCode();
                if (string.IsNullOrEmpty(AuthenticationResponse.PassCode))
                {
                    _isurveyFacade.UpdatePassCode(responseId.ToString(), TempData["PassCode"].ToString());
                }


                SurveyInfoModel      surveyInfoModel = GetSurveyInfo(SurveyAnswer.SurveyId);
                XDocument            xdoc            = XDocument.Parse(surveyInfoModel.XML);
                MvcDynamicForms.Form form            = _isurveyFacade.GetSurveyFormData(SurveyAnswer.SurveyId, 1, SurveyAnswer, isMobileDevice);

                var _FieldsTypeIDs = from _FieldTypeID in
                                     xdoc.Descendants("Field")
                                     select _FieldTypeID;

                foreach (var _FieldTypeID in _FieldsTypeIDs)
                {
                    bool   isRequired;
                    string attributeValue = _FieldTypeID.Attribute("IsRequired").Value;

                    if (bool.TryParse(attributeValue, out isRequired))
                    {
                        if (isRequired)
                        {
                            if (!form.RequiredFieldsList.Contains(_FieldTypeID.Attribute("Name").Value))
                            {
                                if (form.RequiredFieldsList != "")
                                {
                                    form.RequiredFieldsList = form.RequiredFieldsList + "," + _FieldTypeID.Attribute("Name").Value.ToLower();
                                }
                                else
                                {
                                    form.RequiredFieldsList = _FieldTypeID.Attribute("Name").Value.ToLower();
                                }
                            }
                        }
                    }
                }
                SurveyAnswer.XML = CreateResponseDocument(xdoc, SurveyAnswer.XML);
                _isurveyFacade.UpdateSurveyResponse(surveyInfoModel, SurveyAnswer.ResponseId, form, SurveyAnswer, false, false, 1);

                return(RedirectToRoute(new { Controller = "Survey", Action = "Index", responseId = responseId, PageNumber = 1 }));
            }
            catch (Exception ex)
            {
                Epi.Web.Utility.ExceptionMessage.SendLogMessage(ex, this.HttpContext);
                return(View(Epi.Web.MVC.Constants.Constant.EXCEPTION_PAGE));
            }
        }
Example #6
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);
        }
Example #7
0
        public string GetSurveyResponseJson(Epi.Web.Common.DTO.SurveyAnswerDTO surveyAnswerDTO, List <FormsHierarchyDTO> FormsHierarchyDTOList, SurveyControlsResponse List)
        {
            SurveyResponseJson Implementation = new SurveyResponseJson();

            return(Implementation.GetSurveyResponseJson(surveyAnswerDTO, FormsHierarchyDTOList, List));
        }
Example #8
0
        //public SurveyAnswerDTO CreateSurveyAnswer(string surveyId, string responseId, int UserId, bool IsChild = false, string RelateResponseId = "", bool IsEditMode = false , int CurrentOrgId = -1)
        //{

        //    return SurveyHelper.CreateSurveyResponse(surveyId, responseId, _surveyAnswerRequest, _surveyAnswerDTO, _surveyResponseXML, _iSurveyAnswerRepository, UserId, IsChild, RelateResponseId, IsEditMode, CurrentOrgId);
        //}
        public void UpdateSurveyResponse(SurveyInfoModel surveyInfoModel, string responseId, MvcDynamicForms.Form form, Epi.Web.Common.DTO.SurveyAnswerDTO surveyAnswerDTO, bool IsSubmited, bool IsSaved, int PageNumber, int UserId)
        {
            // 1 Get the record for the current survey response
            // 2 update the current survey response and save the response

            //// 1 Get the record for the current survey response
            SurveyAnswerResponse surveyAnswerResponse = new SurveyAnswerResponse();//GetSurveyAnswerResponse(responseId, surveyInfoModel.SurveyId.ToString());

            surveyAnswerResponse.SurveyResponseList.Add(surveyAnswerDTO);
            ///2 Update the current survey response and save it

            SurveyHelper.UpdateSurveyResponse(surveyInfoModel, form, _surveyAnswerRequest, _surveyResponseXML, _iSurveyAnswerRepository, surveyAnswerResponse, responseId, surveyAnswerDTO, IsSubmited, IsSaved, PageNumber, UserId);
        }
Example #9
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);
        }