Esempio n. 1
0
        public ActionResult Index(string responseId, string ReturnUrl)
        {
            string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            ViewBag.Version = version;

            //get the responseId
            responseId = GetResponseId(ReturnUrl);
            if (!string.IsNullOrEmpty(responseId))
            {
                //get the surveyId
                string SurveyId = _isurveyFacade.GetSurveyAnswerResponse(responseId).SurveyResponseList[0].SurveyId;
                //put surveyId in viewbag so can be retrieved in Login/Index.cshtml
                ViewBag.SurveyId = SurveyId;
            }
            if (string.IsNullOrEmpty(GetPassCode(ReturnUrl)))
            {
                return(View("Index"));
            }
            else
            {
                Epi.Web.Common.Message.UserAuthenticationResponse result = _isurveyFacade.ValidateUser(responseId, GetPassCode(ReturnUrl));

                if (result.UserIsValid)
                {
                    FormsAuthentication.SetAuthCookie(GetPassCode(ReturnUrl), false);

                    ReturnUrl = GetRedirectUrl(ReturnUrl);

                    return(Redirect(ReturnUrl));
                }
                else
                {
                    return(View());
                }
            }
        }
Esempio n. 2
0
        public ActionResult Index(PassCodeModel Model, string responseId, string ReturnUrl)
        {
            //parse and get the responseId
            responseId = GetResponseId(ReturnUrl);

            Common.DTO.SurveyAnswerDTO R = _isurveyFacade.GetSurveyAnswerResponse(responseId).SurveyResponseList[0];
            Session["RootFormId"]     = R.SurveyId.ToString();
            Session["RootResponseId"] = responseId;
            // Get Last Page visited else send to page 1 - Begin

            XDocument Xdoc       = XDocument.Parse(R.XML);
            int       PageNumber = 0;

            if (Xdoc.Root.Attribute("LastPageVisited") != null)
            {
                if (!int.TryParse(Xdoc.Root.Attribute("LastPageVisited").Value, out PageNumber))
                {
                    PageNumber = 1;
                }
            }
            else
            {
                PageNumber = 1;
            }

            //if (ReturnUrl.EndsWith("/"))
            //{
            //    ReturnUrl = ReturnUrl + PageNumber.ToString();
            //}
            //else
            //{
            //    ReturnUrl = ReturnUrl + "/" + PageNumber.ToString();
            //}


            // Get Last Page visited else send to page 1 - End



            //get the surveyId
            string SurveyId = R.SurveyId;

            //put surveyId in viewbag so can be retrieved in Login/Index.cshtml
            ViewBag.SurveyId = SurveyId;


            Epi.Web.Common.Message.UserAuthenticationResponse result = _isurveyFacade.ValidateUser(responseId, Model.PassCode);

            if (result.UserIsValid)
            {
                FormsAuthentication.SetAuthCookie(Model.PassCode, false);
                // return RedirectToRoute(new { Controller = "Survey", Action = "Index", responseid = responseId });


                return(Redirect(ReturnUrl));
            }
            else
            {
                ModelState.AddModelError("", "Pass code is incorrect.");
                return(View());
            }
        }
Esempio n. 3
0
        public ActionResult Index(Epi.Web.MVC.Models.SurveyInfoModel surveyModel)
        {
            try
            {
                bool IsMobileDevice = this.Request.Browser.IsMobileDevice;

                if (IsMobileDevice == false)
                {
                    IsMobileDevice = Epi.Web.MVC.Utility.SurveyHelper.IsMobileDevice(this.Request.UserAgent.ToString());
                }

                FormsAuthentication.SetAuthCookie("BeginSurvey", false);



                Session["RootResponseId"] = surveyModel.ResponseId;
                string ResponseID = surveyModel.ResponseId; //string.Empty;
                //object tempDataValue;

                //if (TempData.TryGetValue(Epi.Web.MVC.Constants.Constant.RESPONSE_ID, out tempDataValue))
                //{
                //    ResponseID = (string)tempDataValue;
                //}
                //else
                //{

                //}

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

                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());
                    _isurveyFacade.UpdatePassCode(ResponseID.ToString(), surveyModel.PassCode);
                }


                Epi.Web.Common.Message.SurveyAnswerResponse SurveyAnswerResponse = _isurveyFacade.GetSurveyAnswerResponse(ResponseID);
                SurveyAnswer = SurveyAnswerResponse.SurveyResponseList[0];
                SurveyInfoModel surveyInfoModel = GetSurveyInfo(SurveyAnswer.SurveyId);

                // set the survey answer to be production or test
                SurveyAnswer.IsDraftMode = surveyInfoModel.IsDraftMode;
                XDocument xdoc = XDocument.Parse(surveyInfoModel.XML);

                // MvcDynamicForms.Form form = _isurveyFacade.GetSurveyFormData(SurveyAnswer.SurveyId, 1, SurveyAnswer, IsMobileDevice, "homeController");
                MvcDynamicForms.Form form = _isurveyFacade.GetSurveyFormData(SurveyAnswer.SurveyId, 1, SurveyAnswer, IsMobileDevice, null);

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

                TempData["Width"] = form.Width + 100;

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

                XElement ViewElement = xdoc.XPathSelectElement("Template/Project/View");
                string   checkcode   = ViewElement.Attribute("CheckCode").Value.ToString();

                form.FormCheckCodeObj = form.GetCheckCodeObj(xdoc, xdocResponse, checkcode);

                ///////////////////////////// Execute - Record Before - start//////////////////////
                Dictionary <string, string> ContextDetailList = new Dictionary <string, string>();
                EnterRule FunctionObject_B = (EnterRule)form.FormCheckCodeObj.GetCommand("level=record&event=before&identifier=");
                if (FunctionObject_B != null && !FunctionObject_B.IsNull())
                {
                    try
                    {
                        SurveyAnswer.XML = CreateResponseDocument(xdoc, SurveyAnswer.XML);

                        form.RequiredFieldsList = this.RequiredList;
                        FunctionObject_B.Context.HiddenFieldList      = form.HiddenFieldsList;
                        FunctionObject_B.Context.HighlightedFieldList = form.HighlightedFieldsList;
                        FunctionObject_B.Context.DisabledFieldList    = form.DisabledFieldsList;
                        FunctionObject_B.Context.RequiredFieldList    = form.RequiredFieldsList;

                        FunctionObject_B.Execute();

                        // field list
                        form.HiddenFieldsList      = FunctionObject_B.Context.HiddenFieldList;
                        form.HighlightedFieldsList = FunctionObject_B.Context.HighlightedFieldList;
                        form.DisabledFieldsList    = FunctionObject_B.Context.DisabledFieldList;
                        form.RequiredFieldsList    = FunctionObject_B.Context.RequiredFieldList;


                        ContextDetailList = Epi.Web.MVC.Utility.SurveyHelper.GetContextDetailList(FunctionObject_B);
                        form = Epi.Web.MVC.Utility.SurveyHelper.UpdateControlsValuesFromContext(form, ContextDetailList);
                        SurveyAnswer.RecordBeforeFlag = true;
                        _isurveyFacade.UpdateSurveyResponse(surveyInfoModel, ResponseID.ToString(), form, SurveyAnswer, false, false, 0);
                    }
                    catch (Exception ex)
                    {
                        // do nothing so that processing
                        // can continue
                    }
                }
                else
                {
                    SurveyAnswer.XML        = CreateResponseDocument(xdoc, SurveyAnswer.XML);
                    form.RequiredFieldsList = RequiredList;
                    _isurveyFacade.UpdateSurveyResponse(surveyInfoModel, SurveyAnswer.ResponseId, form, SurveyAnswer, false, false, 0);
                }

                SurveyAnswer = _isurveyFacade.GetSurveyAnswerResponse(SurveyAnswer.ResponseId).SurveyResponseList[0];

                ///////////////////////////// Execute - Record Before - End//////////////////////
                //string page;
                // return RedirectToAction(Epi.Web.Models.Constants.Constant.INDEX, Epi.Web.Models.Constants.Constant.SURVEY_CONTROLLER, new {id="page" });
                return(RedirectToAction(Epi.Web.MVC.Constants.Constant.INDEX, Epi.Web.MVC.Constants.Constant.SURVEY_CONTROLLER, new { responseid = ResponseID, PageNumber = 1 }));
            }
            catch (Exception ex)
            {
                Epi.Web.Utility.ExceptionMessage.SendLogMessage(ex, this.HttpContext);
                return(View(Epi.Web.MVC.Constants.Constant.EXCEPTION_PAGE));
            }
        }
Esempio n. 4
0
        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();
                                }
                            }
                        }
                    }
                }

                _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));
            }
        }