Example #1
0
        private UserOrgModel GetUserInfoList(int OrgId = -1)
        {
            int          UserId       = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());
            UserOrgModel UserOrgModel = new UserOrgModel();

            try
            {
                OrganizationRequest Request = new OrganizationRequest();
                Request.UserId   = UserId;
                Request.UserRole = Convert.ToInt16(Session["UserHighestRole"].ToString());
                OrganizationResponse     Organizations = _isurveyFacade.GetAdminOrganizations(Request);
                List <OrganizationModel> OrgListModel  = Mapper.ToOrganizationModelList(Organizations.OrganizationList);
                UserOrgModel.OrgList = OrgListModel;
                if (OrgId != -1)
                {
                    Request.Organization.OrganizationId = OrgId;
                    ViewBag.SelectedOrg = OrgId;
                }
                else
                {
                    Request.Organization.OrganizationId = Organizations.OrganizationList[0].OrganizationId;
                    ViewBag.SelectedOrg = Organizations.OrganizationList[0].OrganizationId;
                }
                OrganizationResponse OrganizationUsers = _isurveyFacade.GetOrganizationUsers(Request);
                List <UserModel>     UserModel         = Mapper.ToUserModelList(OrganizationUsers.OrganizationUsersList);

                UserOrgModel.UserList = UserModel;
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            return(UserOrgModel);
        }
        public ActionResult Index(string surveyid, int orgid = -1)
        {
            int UserId = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());
            int OrgnizationId;

            Session["EditForm"] = null;

            Guid UserId1 = new Guid();

            try
            {
                string SurveyMode = "";
                //SurveyInfoModel surveyInfoModel = GetSurveyInfo(surveyid);
                //  List<FormInfoModel> listOfformInfoModel = GetFormsInfoList(UserId1);

                FormModel FormModel;

                GetFormModel(surveyid, UserId, UserId1, out OrgnizationId, out FormModel);

                if (orgid == -1)
                {
                    Session["SelectedOrgId"] = OrgnizationId;
                }
                else
                {
                    Session["SelectedOrgId"] = orgid;
                }
                System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"(\r\n|\r|\n)+");



                bool IsMobileDevice = false;
                IsMobileDevice = this.Request.Browser.IsMobileDevice;
                if (IsMobileDevice) // Because mobile doesn't need RootFormId until button click.
                {
                    Session["RootFormId"]     = null;
                    Session["PageNumber"]     = null;
                    Session["SortOrder"]      = null;
                    Session["SortField"]      = null;
                    Session["SearchCriteria"] = null;
                    Session["SearchModel"]    = null;
                }
                Omniture OmnitureObj = Epi.Web.MVC.Utility.OmnitureHelper.GetSettings(SurveyMode, IsMobileDevice);

                ViewBag.Omniture = OmnitureObj;

                string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                ViewBag.Version = version;

                return(View(Epi.Web.MVC.Constants.Constant.INDEX_PAGE, FormModel));
            }
            catch (Exception ex)
            {
                Epi.Web.Utility.ExceptionMessage.SendLogMessage(ex, this.HttpContext);
                ExceptionModel ExModel = new ExceptionModel();
                ExModel.ExceptionDetail = ex.StackTrace;
                ExModel.Message         = ex.Message;
                return(View(Epi.Web.MVC.Constants.Constant.EXCEPTION_PAGE, ExModel));
            }
        }
        public ActionResult Notify(String ResponseId)
        {
            int UserId = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());

            //Get current user info
            int CurrentOrgId = int.Parse(Session["SelectedOrgId"].ToString());
            var UserInfo     = _isurveyFacade.GetUserInfo(UserId);

            //Get Organization admin info
            Epi.Web.Enter.Common.DTO.SurveyAnswerDTO surveyAnswerDTO = GetSurveyAnswer(ResponseId, Session["RootFormId"].ToString());
            SurveyInfoModel surveyInfoModel = GetSurveyInfo(surveyAnswerDTO.SurveyId);

            var OwnerInfo = _isurveyFacade.GetUserInfo(surveyAnswerDTO.FormOwnerId);;


            Epi.Web.Enter.Common.Email.Email EmilObj = new Enter.Common.Email.Email();
            //ResponseId;

            EmilObj.Subject = "Record locked notification.";
            EmilObj.Body    = " A user was unable to edit/delete a Epi Info™ Cloud Data Capture recored. \n \n Please login to Epi Info™ Cloud Data Capture system to Unlock this record.\n \n Below are the needed info to unlock the record.\n \n Response id: " + ResponseId + "\n\n User email: " + UserInfo.User.EmailAddress + "\n\n";
            EmilObj.From    = ConfigurationManager.AppSettings["EMAIL_FROM"];
            EmilObj.To      = new List <string>();
            EmilObj.To.Add(OwnerInfo.User.EmailAddress);

            var success = Epi.Web.Enter.Common.Email.EmailHandler.SendMessage(EmilObj);


            return(Json(1));
        }
Example #4
0
        public ActionResult OrgList()
        {
            string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            ViewBag.Version = version;
            int UserId                  = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());
            int UserHighestRole         = int.Parse(Session["UserHighestRole"].ToString());
            OrganizationRequest Request = new OrganizationRequest();

            Request.UserId   = UserId;
            Request.UserRole = UserHighestRole;
            OrganizationResponse Organizations = _isurveyFacade.GetUserOrganizations(Request);

            List <OrganizationModel> Model        = Mapper.ToOrganizationModelList(Organizations.OrganizationList);
            OrgListModel             OrgListModel = new OrgListModel();

            OrgListModel.OrganizationList = Model;

            if (UserHighestRole == 3)
            {
                return(View("OrgList", OrgListModel));
            }
            else
            {
                return(RedirectToAction("UserList", "AdminUser"));
            }
        }
        public ActionResult SaveSettings(string formid)
        {
            int CurrentOrgId = int.Parse(Session["SelectedOrgId"].ToString());
            List <FormsHierarchyDTO> FormList       = GetFormsHierarchy(formid);
            FormSettingRequest       FormSettingReq = new Enter.Common.Message.FormSettingRequest();
            int UserId = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());

            foreach (var Form in FormList)
            {
                FormSettingReq.GetXml          = true;
                FormSettingReq.FormInfo.FormId = new Guid(formid).ToString();
                FormSettingReq.FormInfo.UserId = UserId;
                FormSettingDTO FormSetting = new FormSettingDTO();
                FormSetting.FormId                 = Form.FormId;
                FormSetting.ColumnNameList         = GetDictionary(this.Request.Form["SelectedColumns_" + Form.FormId]);
                FormSetting.AssignedUserList       = GetDictionary(this.Request.Form["SelectedUser"]);
                FormSetting.SelectedOrgList        = GetDictionary(this.Request.Form["SelectedOrg"]);
                FormSetting.IsShareable            = GetBoolValue(this.Request.Form["IsShareable"]);
                FormSetting.SelectedDataAccessRule = int.Parse(this.Request.Form["DataAccessRuleId"]);

                if (!string.IsNullOrEmpty(this.Request.Form["SoftDeleteForm"]) && this.Request.Form["SoftDeleteForm"].ToUpper() == "ON")
                {
                    FormSetting.IsDisabled = true;
                }
                if (!string.IsNullOrEmpty(this.Request.Form["RemoveTestData"]) && this.Request.Form["RemoveTestData"].ToUpper() == "ON")
                {
                    FormSetting.DeleteDraftData = true;
                }
                FormSettingReq.FormSetting.Add(FormSetting);
                FormSettingReq.FormInfo.IsDraftMode = GetBoolValue(this.Request.Form["Mode"]);
                FormSettingReq.CurrentOrgId         = CurrentOrgId;
            }
            FormSettingResponse FormSettingResponse = _isurveyFacade.SaveSettings(FormSettingReq);



            bool IsMobileDevice = this.Request.Browser.IsMobileDevice;

            var model = new FormResponseInfoModel();


            model = GetFormResponseInfoModel(formid, 1, "", "", CurrentOrgId);

            if (IsMobileDevice == false)
            {
                if (!string.IsNullOrEmpty(this.Request.Form["SoftDeleteForm"]) && this.Request.Form["SoftDeleteForm"].ToUpper() == "ON")
                {
                    return(Json(null));
                }
                else
                {
                    return(PartialView("ListResponses", model));
                }
            }
            else
            {
                return(View("ListResponses", model));
            }
        }
Example #6
0
        public ActionResult UserInfo(UserModel UserModel)
        {
            UserOrgModel UserOrgModel = new UserOrgModel();
            UserResponse Response     = new UserResponse();
            UserRequest  Request      = new UserRequest();
            int          UserId       = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());

            try
            {
                if (ModelState.IsValid)
                {
                    if (UserModel.IsEditMode)
                    {
                        Request.Action = "UpDate";

                        Request.User = Mapper.ToUserDTO(UserModel);

                        Request.CurrentOrg = int.Parse(Session["CurrentOrgId"].ToString());

                        Request.CurrentUser  = UserId;
                        Response             = _isurveyFacade.SetUserInfo(Request);
                        UserOrgModel         = GetUserInfoList(Request.CurrentOrg);
                        UserOrgModel.Message = "User information for " + UserModel.FirstName + " " + UserModel.LastName + " has been updated. ";
                    }
                    else
                    {
                        Request.Action = "";
                        Request.User   = Mapper.ToUserDTO(UserModel);

                        Request.CurrentOrg = int.Parse(Session["CurrentOrgId"].ToString());


                        Request.CurrentUser = UserId;
                        Response            = _isurveyFacade.SetUserInfo(Request);

                        if (Response.Message.ToUpper() == "EXISTS")
                        {
                            ModelState.AddModelError("Email", "Error occurred. User already exists for this organization.");
                            return(View("UserInfo", UserModel));
                        }

                        UserOrgModel         = GetUserInfoList(Request.CurrentOrg);
                        UserOrgModel.Message = "User " + UserModel.FirstName + " " + UserModel.LastName + " has been added. ";
                    }
                }
                else
                {
                    return(View("UserInfo", UserModel));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            UserOrgModel.UserHighestRole = int.Parse(Session["UserHighestRole"].ToString());
            return(View("UserList", UserOrgModel));
        }
        public ActionResult CheckForConcurrency(String ResponseId)
        {
            int UserId = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());

            Epi.Web.Enter.Common.DTO.SurveyAnswerDTO surveyAnswerDTO = GetSurveyAnswer(ResponseId, Session["RootFormId"].ToString());
            surveyAnswerDTO.LoggedInUserId = UserId;
            Session["EditForm"]            = ResponseId;
            //Session[""]
            return(Json(surveyAnswerDTO));
        }
        //  [HttpPost]

        //    public ActionResult Edit(string ResId)
        //    {
        ////    Epi.Web.Enter.Common.DTO.SurveyAnswerDTO surveyAnswerDTO = GetSurveyAnswer(ResId);

        //    return RedirectToAction(Epi.Web.MVC.Constants.Constant.INDEX, Epi.Web.MVC.Constants.Constant.SURVEY_CONTROLLER, new { responseid = ResId, PageNumber = 1 });
        //    }
        private Epi.Web.Enter.Common.DTO.SurveyAnswerDTO GetSurveyAnswer(string responseId, string FormId)
        {
            Epi.Web.Enter.Common.DTO.SurveyAnswerDTO result = null;
            int UserId = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());
            //responseId = TempData[Epi.Web.MVC.Constants.Constant.RESPONSE_ID].ToString();
            var SurveyAnswerResponse = _isurveyFacade.GetSurveyAnswerResponse(responseId, FormId, UserId);

            result             = SurveyAnswerResponse.SurveyResponseList[0];
            result.FormOwnerId = SurveyAnswerResponse.FormInfo.OwnerId;
            return(result);
        }
        public List <FormInfoModel> GetFormsInfoList(Guid UserId, int OrgID)
        {
            FormsInfoRequest formReq = new FormsInfoRequest();

            formReq.Criteria.UserId       = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());//Hard coded user for now.
            formReq.Criteria.CurrentOrgId = OrgID;
            // formReq.Criteria.UserId = UserId;
            //define filter criteria here.
            //define sorting criteria here.

            List <FormInfoModel> listOfFormsInfoModel = _isurveyFacade.GetFormsInfoModelList(formReq);



            // return listOfFormsInfoModel.Where(x=>x.OrganizationId== OrgID).ToList();
            return(listOfFormsInfoModel);
        }
        public ActionResult Delete(string ResponseId)
        {
            SurveyAnswerRequest SARequest = new SurveyAnswerRequest();

            SARequest.SurveyAnswerList.Add(new SurveyAnswerDTO()
            {
                ResponseId = ResponseId
            });
            string Id = Session["UserId"].ToString();

            SARequest.Criteria.UserId       = SurveyHelper.GetDecryptUserId(Id);
            SARequest.Criteria.IsSqlProject = (bool)Session["IsSqlProject"];
            SARequest.Criteria.SurveyId     = Session["RootFormId"].ToString();
            SurveyAnswerResponse SAResponse = _isurveyFacade.DeleteResponse(SARequest);

            return(Json(string.Empty));
        }
 public ActionResult Unlock(String ResponseId, bool RecoverLastRecordVersion)
 {
     try
     {
         int UserId = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());
         SurveyAnswerRequest SurveyAnswerRequest = new SurveyAnswerRequest();
         SurveyAnswerRequest.SurveyAnswerList.Add(new SurveyAnswerDTO()
         {
             ResponseId = ResponseId
         });
         SurveyAnswerRequest.Criteria.StatusId = 2;
         SurveyAnswerRequest.Criteria.SurveyAnswerIdList.Add(ResponseId);
         SurveyAnswerRequest.Criteria.UserId = UserId;
         Session["RecoverLastRecordVersion"] = RecoverLastRecordVersion;
         _isurveyFacade.UpdateResponseStatus(SurveyAnswerRequest);
     }
     catch (Exception ex)
     {
         return(Json("Erorr"));
     }
     return(Json("Success"));
 }
        private string GetChildRecordId(SurveyAnswerDTO surveyAnswerDTO)
        {
            SurveyAnswerRequest  SurveyAnswerRequest  = new SurveyAnswerRequest();
            SurveyAnswerResponse SurveyAnswerResponse = new SurveyAnswerResponse();
            string ChildId = Guid.NewGuid().ToString();

            surveyAnswerDTO.ParentRecordId = surveyAnswerDTO.ResponseId;
            surveyAnswerDTO.ResponseId     = ChildId;
            surveyAnswerDTO.Status         = 1;
            SurveyAnswerRequest.SurveyAnswerList.Add(surveyAnswerDTO);
            string result;

            //responseId = TempData[Epi.Web.MVC.Constants.Constant.RESPONSE_ID].ToString();
            string Id = Session["UserId"].ToString();

            SurveyAnswerRequest.Criteria.UserId = SurveyHelper.GetDecryptUserId(Id);//_UserId;
            SurveyAnswerRequest.RequestId       = ChildId;
            SurveyAnswerRequest.Action          = "CreateMulti";
            SurveyAnswerResponse = _isurveyFacade.SetChildRecord(SurveyAnswerRequest);
            result = SurveyAnswerResponse.SurveyResponseList[0].ResponseId.ToString();
            return(result);
        }
        public ActionResult Index(string surveyid, string AddNewFormId, string EditForm)
        {
            int  UserId       = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());
            int  CuurentOrgId = int.Parse(Session["SelectedOrgId"].ToString());
            Guid ResponseID   = Guid.NewGuid();

            Session["FormValuesHasChanged"] = "";

            TempData[Epi.Web.MVC.Constants.Constant.RESPONSE_ID] = Session["RootResponseId"] = ResponseID.ToString();


            if (string.IsNullOrEmpty(EditForm) && Session["EditForm"] != null)
            {
                EditForm = Session["EditForm"].ToString();
            }

            if (!string.IsNullOrEmpty(EditForm) && string.IsNullOrEmpty(AddNewFormId))
            {
                Session["RootResponseId"] = EditForm.ToLower();

                Session["IsEditMode"] = true;
                Epi.Web.Enter.Common.DTO.SurveyAnswerDTO surveyAnswerDTO = GetSurveyAnswer(EditForm, Session["RootFormId"].ToString());


                Session["RequestedViewId"] = surveyAnswerDTO.ViewId;
                if (Session["RecoverLastRecordVersion"] != null)
                {
                    surveyAnswerDTO.RecoverLastRecordVersion = bool.Parse(Session["RecoverLastRecordVersion"].ToString());
                }
                string ChildRecordId = GetChildRecordId(surveyAnswerDTO);
                Session["RecoverLastRecordVersion"] = false;
                return(RedirectToAction(Epi.Web.MVC.Constants.Constant.INDEX, Epi.Web.MVC.Constants.Constant.SURVEY_CONTROLLER, new { responseid = ChildRecordId, PageNumber = 1, Edit = "Edit" }));
            }
            else
            {
                Session["IsEditMode"] = false;
            }
            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["RootFormId"] = AddNewFormId;
            //create the responseid
            Epi.Web.Enter.Common.DTO.SurveyAnswerDTO SurveyAnswer = _isurveyFacade.CreateSurveyAnswer(AddNewFormId, ResponseID.ToString(), UserId, false, "", false, CuurentOrgId);
            MvcDynamicForms.Form form = _isurveyFacade.GetSurveyFormData(SurveyAnswer.SurveyId, 1, SurveyAnswer, IsMobileDevice, null, null, false, false);
            TempData["Width"] = form.Width + 100;
            SurveyInfoModel surveyInfoModel = Mapper.ToFormInfoModel(form.SurveyInfo);

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

            ///////////////////////////// Execute - Record Before - start//////////////////////
            Dictionary <string, string> ContextDetailList = new Dictionary <string, string>();
            EnterRule         FunctionObject_B            = (EnterRule)form.FormCheckCodeObj.GetCommand("level=record&event=before&identifier=");
            SurveyResponseXML SurveyResponseXML           = new SurveyResponseXML(PageFields, RequiredList);

            if (FunctionObject_B != null && !FunctionObject_B.IsNull())
            {
                try
                {
                    SurveyAnswer.XML        = SurveyResponseXML.CreateResponseDocument(xdoc, SurveyAnswer.XML);
                    Session["RequiredList"] = SurveyResponseXML._RequiredList;
                    //SurveyAnswer.XML = Epi.Web.MVC.Utility.SurveyHelper.CreateResponseDocument(xdoc, SurveyAnswer.XML, RequiredList);
                    this.RequiredList       = SurveyResponseXML._RequiredList;
                    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);

                    _isurveyFacade.UpdateSurveyResponse(surveyInfoModel, ResponseID.ToString(), form, SurveyAnswer, false, false, 0, SurveyHelper.GetDecryptUserId(Session["UserId"].ToString()));
                }
                catch (Exception ex)
                {
                    // do nothing so that processing
                    // can continue
                }
            }
            else
            {
                SurveyAnswer.XML        = SurveyResponseXML.CreateResponseDocument(xdoc, SurveyAnswer.XML);//, RequiredList);
                this.RequiredList       = SurveyResponseXML._RequiredList;
                Session["RequiredList"] = SurveyResponseXML._RequiredList;
                form.RequiredFieldsList = RequiredList;
                _isurveyFacade.UpdateSurveyResponse(surveyInfoModel, SurveyAnswer.ResponseId, form, SurveyAnswer, false, false, 0, SurveyHelper.GetDecryptUserId(Session["UserId"].ToString()));
            }


            return(RedirectToAction(Epi.Web.MVC.Constants.Constant.INDEX, Epi.Web.MVC.Constants.Constant.SURVEY_CONTROLLER, new { responseid = ResponseID, PageNumber = 1, surveyid = surveyInfoModel.SurveyId }));
        }
        public FormResponseInfoModel GetFormResponseInfoModel(string SurveyId, int PageNumber, string sort = "", string sortfield = "", int orgid = -1)
        {
            int UserId = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());
            FormResponseInfoModel FormResponseInfoModel = new FormResponseInfoModel();

            FormResponseInfoModel.SearchModel = new SearchBoxModel();
            SurveyResponseXML SurveyResponseXML = new SurveyResponseXML();

            if (!string.IsNullOrEmpty(SurveyId))
            {
                SurveyAnswerRequest FormResponseReq = new SurveyAnswerRequest();
                FormSettingRequest  FormSettingReq  = new Enter.Common.Message.FormSettingRequest();

                //Populating the request

                FormSettingReq.FormInfo.FormId = SurveyId;
                FormSettingReq.FormInfo.UserId = UserId;
                //Getting Column Name  List
                FormSettingReq.CurrentOrgId = orgid;
                FormSettingReq.FormInfoOnly = true;
                FormSettingResponse FormSettingResponse = _isurveyFacade.GetFormSettings(FormSettingReq);   //Pain Point
                Columns = FormSettingResponse.FormSetting.ColumnNameList.ToList();
                Columns.Sort(Compare);

                // Setting  Column Name  List
                FormResponseInfoModel.Columns = Columns;

                FormResponseInfoModel.FormInfoModel.IsShared    = FormSettingResponse.FormInfo.IsShared;
                FormResponseInfoModel.FormInfoModel.IsShareable = FormSettingResponse.FormInfo.IsShareable;
                // Set User Role
                //if (FormResponseInfoModel.FormInfoModel.IsShared)
                //{

                //    SetUserRole(UserId, orgid);
                //}
                //else
                //{
                //SetUserRole(UserId, FormSettingResponse.FormInfo.OrganizationId);
                //}
                SetUserRole(UserId, orgid);

                FormResponseReq.Criteria.SurveyId           = SurveyId.ToString();
                FormResponseReq.Criteria.PageNumber         = PageNumber;
                FormResponseReq.Criteria.UserId             = UserId;
                FormResponseReq.Criteria.IsSqlProject       = FormSettingResponse.FormInfo.IsSQLProject;
                FormResponseReq.Criteria.IsShareable        = FormSettingResponse.FormInfo.IsShareable;
                FormResponseReq.Criteria.UserOrganizationId = orgid;
                Session["IsSqlProject"] = FormSettingResponse.FormInfo.IsSQLProject;
                Session["IsOwner"]      = FormSettingResponse.FormInfo.IsOwner;
                //if (Session["SearchCriteria"] != null)
                //{
                //    FormResponseInfoModel.SearchModel = (SearchBoxModel)Session["SearchCriteria"];
                //}
                // Following code retain search starts
                if (Session["SearchCriteria"] != null &&
                    !string.IsNullOrEmpty(Session["SearchCriteria"].ToString()) &&
                    (Request.QueryString["col1"] == null || Request.QueryString["col1"] == "undefined"))
                {
                    FormResponseReq.Criteria.SearchCriteria = Session["SearchCriteria"].ToString();
                    FormResponseInfoModel.SearchModel       = (SearchBoxModel)Session["SearchModel"];
                }
                else
                {
                    FormResponseReq.Criteria.SearchCriteria = CreateSearchCriteria(Request.QueryString, FormResponseInfoModel.SearchModel, FormResponseInfoModel);
                    Session["SearchModel"]    = FormResponseInfoModel.SearchModel;
                    Session["SearchCriteria"] = FormResponseReq.Criteria.SearchCriteria;
                }
                // Following code retain search ends
                PopulateDropDownlists(FormResponseInfoModel, FormSettingResponse.FormSetting.FormControlNameList.ToList());

                if (sort.Length > 0)
                {
                    FormResponseReq.Criteria.SortOrder = sort;
                }
                if (sortfield.Length > 0)
                {
                    FormResponseReq.Criteria.Sortfield = sortfield;
                }


                SurveyAnswerResponse FormResponseList = _isurveyFacade.GetFormResponseList(FormResponseReq);//Pain Point


                //var ResponseTableList ; //= FormSettingResponse.FormSetting.DataRows;
                //Setting Resposes List
                List <ResponseModel> ResponseList = new List <ResponseModel>();
                foreach (var item in FormResponseList.SurveyResponseList)
                {
                    if (item.SqlData != null)
                    {
                        ResponseList.Add(ConvertRowToModel(item, Columns));
                    }
                    else
                    {
                        ResponseList.Add(SurveyResponseXML.ConvertXMLToModel(item, Columns));
                    }
                }


                //foreach (var item in FormResponseList.SurveyResponseList)
                //{
                //    ResponseList.Add(SurveyResponseXML.ConvertXMLToModel(item, Columns));
                //}

                FormResponseInfoModel.ResponsesList = ResponseList;
                //Setting Form Info
                FormResponseInfoModel.FormInfoModel = Mapper.ToFormInfoModel(FormResponseList.FormInfo);
                //Setting Additional Data

                FormResponseInfoModel.NumberOfPages     = FormResponseList.NumberOfPages;
                FormResponseInfoModel.PageSize          = ReadPageSize();
                FormResponseInfoModel.NumberOfResponses = FormResponseList.NumberOfResponses;
                FormResponseInfoModel.sortfield         = sortfield;
                FormResponseInfoModel.sortOrder         = sort;
                FormResponseInfoModel.CurrentPage       = PageNumber;
            }
            return(FormResponseInfoModel);
        }
        public ActionResult GetSettings(string formid)//List<FormInfoModel> ModelList, string formid)
        {
            FormSettingRequest FormSettingReq = new Enter.Common.Message.FormSettingRequest();
            List <KeyValuePair <int, string> > TempColumns = new List <KeyValuePair <int, string> >();
            //Get All forms
            List <FormsHierarchyDTO> FormsHierarchy = GetFormsHierarchy(formid);
            // List<FormSettingResponse> FormSettingResponseList = new List<FormSettingResponse>();
            List <SettingsInfoModel> ModelList = new List <SettingsInfoModel>();

            foreach (var Item in FormsHierarchy)
            {
                FormSettingReq.GetXml          = true;
                FormSettingReq.FormInfo.FormId = new Guid(Item.FormId).ToString();
                FormSettingReq.FormInfo.UserId = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());
                FormSettingReq.CurrentOrgId    = int.Parse(Session["SelectedOrgId"].ToString());
                //Getting Column Name  List

                FormSettingResponse FormSettingResponse = _isurveyFacade.GetFormSettings(FormSettingReq);
                //  FormSettingResponseList.Add(FormSettingResponse);



                // FormSettingResponse FormSettingResponse = _isurveyFacade.GetFormSettings(FormSettingReq);
                Columns     = FormSettingResponse.FormSetting.ColumnNameList.ToList();
                TempColumns = Columns;
                Columns.Sort(Compare);


                Dictionary <int, string> dictionary = Columns.ToDictionary(pair => pair.Key, pair => pair.Value);
                SettingsInfoModel        Model      = new SettingsInfoModel();
                Model.SelectedControlNameList = dictionary;

                Columns = FormSettingResponse.FormSetting.FormControlNameList.ToList();
                // Get Additional Metadata columns
                if (!FormSettingResponse.FormInfo.IsSQLProject)
                {
                    var MetaDataColumns = Epi.Web.MVC.Constants.Constant.MetaDaTaColumnNames();
                    Dictionary <int, string> Columndictionary = TempColumns.ToDictionary(pair => pair.Key, pair => pair.Value);

                    foreach (var item in MetaDataColumns)
                    {
                        if (!Columndictionary.ContainsValue(item))
                        {
                            Columns.Add(new KeyValuePair <int, string>(Columns.Count() + 1, item));
                        }
                    }

                    Columns.Sort(Compare);
                }

                Dictionary <int, string> dictionary1 = Columns.ToDictionary(pair => pair.Key, pair => pair.Value);

                Model.FormControlNameList = dictionary1;



                Columns = FormSettingResponse.FormSetting.AssignedUserList.ToList();
                if (Columns.Exists(col => col.Value == Session["UserEmailAddress"].ToString()))
                {
                    Columns.Remove(Columns.First(u => u.Value == Session["UserEmailAddress"].ToString()));
                }

                //Columns.Sort(Compare);

                Dictionary <int, string> dictionary2 = Columns.ToDictionary(pair => pair.Key, pair => pair.Value);

                Model.AssignedUserList = dictionary2;



                Columns = FormSettingResponse.FormSetting.UserList.ToList();

                if (Columns.Exists(col => col.Value == Session["UserEmailAddress"].ToString()))
                {
                    Columns.Remove(Columns.First(u => u.Value == Session["UserEmailAddress"].ToString()));
                }
                //Columns.Sort(Compare);

                Dictionary <int, string> dictionary3 = Columns.ToDictionary(pair => pair.Key, pair => pair.Value);

                Model.UserList = dictionary3;

                Columns = FormSettingResponse.FormSetting.AvailableOrgList.ToList();
                Dictionary <int, string> dictionary4 = Columns.ToDictionary(pair => pair.Key, pair => pair.Value);
                Model.AvailableOrgList = dictionary4;

                Columns = FormSettingResponse.FormSetting.SelectedOrgList.ToList();
                Dictionary <int, string> dictionary5 = Columns.ToDictionary(pair => pair.Key, pair => pair.Value);
                Model.SelectedOrgList = dictionary5;

                Model.IsShareable            = FormSettingResponse.FormInfo.IsShareable;
                Model.IsDraftMode            = FormSettingResponse.FormInfo.IsDraftMode;
                Model.FormOwnerFirstName     = FormSettingResponse.FormInfo.OwnerFName;
                Model.FormOwnerLastName      = FormSettingResponse.FormInfo.OwnerLName;
                Model.FormName               = FormSettingResponse.FormInfo.FormName;
                Model.FormId                 = Item.FormId;
                Model.DataAccessRuleIds      = FormSettingResponse.FormSetting.DataAccessRuleIds;
                Model.SelectedDataAccessRule = FormSettingResponse.FormSetting.SelectedDataAccessRule;
                Model.HasDraftModeData       = FormSettingResponse.FormInfo.HasDraftModeData;
                var DataAccessRuleDescription = "";
                foreach (var item in FormSettingResponse.FormSetting.DataAccessRuleDescription)
                {
                    DataAccessRuleDescription = DataAccessRuleDescription + item.Key.ToString() + " : " + item.Value + "\n";
                }

                Model.DataAccessRuleDescription = DataAccessRuleDescription;
                ModelList.Add(Model);
            }
            return(PartialView("Settings", ModelList));
        }
Example #16
0
        public ActionResult OrgInfo(OrgAdminInfoModel OrgAdminInfoModel)
        {
            int    UserId          = SurveyHelper.GetDecryptUserId(Session["UserId"].ToString());
            int    UserHighestRole = int.Parse(Session["UserHighestRole"].ToString());
            string url             = "";

            if (this.Request.UrlReferrer == null)
            {
                url = this.Request.Url.ToString();
            }
            else
            {
                url = this.Request.UrlReferrer.ToString();
            }
            //Edit Organization
            if (OrgAdminInfoModel.IsEditMode)
            {
                ModelState.Remove("AdminFirstName");
                ModelState.Remove("AdminLastName");
                ModelState.Remove("ConfirmAdminEmail");
                ModelState.Remove("AdminEmail");



                OrganizationRequest Request = new OrganizationRequest();


                UserDTO AdminInfo = new UserDTO();

                AdminInfo.FirstName           = "";
                AdminInfo.LastName            = "";
                AdminInfo.EmailAddress        = "";
                AdminInfo.Role                = 0;
                AdminInfo.PhoneNumber         = "";
                Request.OrganizationAdminInfo = AdminInfo;


                Request.Organization.Organization = OrgAdminInfoModel.OrgName;
                Request.Organization.IsEnabled    = OrgAdminInfoModel.IsOrgEnabled;

                Request.Organization.OrganizationKey = GetOrgKey(url);
                Request.UserId   = UserId;
                Request.UserRole = UserHighestRole;
                Request.Action   = "UpDate";
                try
                {
                    OrganizationResponse     Result        = _isurveyFacade.SetOrganization(Request);
                    OrganizationResponse     Organizations = _isurveyFacade.GetUserOrganizations(Request);
                    List <OrganizationModel> Model         = Mapper.ToOrganizationModelList(Organizations.OrganizationList);
                    OrgListModel             OrgListModel  = new OrgListModel();
                    OrgListModel.OrganizationList = Model;
                    OrgListModel.Message          = "Organization " + OrgAdminInfoModel.OrgName + " has been updated.";
                    if (Result.Message.ToUpper() != "EXISTS" && Result.Message.ToUpper() != "ERROR")
                    {
                        OrgListModel.Message = "Organization " + OrgAdminInfoModel.OrgName + " has been updated.";
                        return(View("OrgList", OrgListModel));
                    }
                    else if (Result.Message.ToUpper() == "ERROR")
                    {
                        OrgAdminInfoModel OrgInfo = new OrgAdminInfoModel();
                        Request.Organization.OrganizationKey = GetOrgKey(url);;

                        Organizations      = _isurveyFacade.GetOrganizationInfo(Request);
                        OrgInfo            = Mapper.ToOrgAdminInfoModel(Organizations);
                        OrgInfo.IsEditMode = true;
                        ModelState.AddModelError("IsOrgEnabled", "Organization for the super admin cannot be deactivated.");
                        return(View("OrgInfo", OrgInfo));
                    }
                    else
                    {
                        OrgAdminInfoModel OrgInfo = new OrgAdminInfoModel();
                        Request.Organization.OrganizationKey = GetOrgKey(url);;

                        Organizations      = _isurveyFacade.GetOrganizationInfo(Request);
                        OrgInfo            = Mapper.ToOrgAdminInfoModel(Organizations);
                        OrgInfo.IsEditMode = true;
                        ModelState.AddModelError("OrgName", "The organization name provided already exists.");
                        return(View("OrgInfo", OrgInfo));
                    }
                }
                catch (Exception ex)
                {
                    return(View(OrgAdminInfoModel));
                }
            }
            else
            {
                // Add new Organization

                if (ModelState.IsValid)
                {
                    OrganizationRequest Request = new OrganizationRequest();
                    Request.Organization.Organization = OrgAdminInfoModel.OrgName;
                    Request.Organization.IsEnabled    = OrgAdminInfoModel.IsOrgEnabled;
                    UserDTO AdminInfo = new UserDTO();

                    AdminInfo.FirstName           = OrgAdminInfoModel.AdminFirstName;
                    AdminInfo.LastName            = OrgAdminInfoModel.AdminLastName;
                    AdminInfo.EmailAddress        = OrgAdminInfoModel.AdminEmail;
                    AdminInfo.Role                = 2;
                    AdminInfo.PhoneNumber         = "123456789";
                    AdminInfo.UGuid               = Guid.NewGuid();
                    Request.OrganizationAdminInfo = AdminInfo;

                    Request.UserRole = UserHighestRole;
                    Request.UserId   = UserId;
                    Request.Action   = "Insert";
                    try
                    {
                        OrganizationResponse     Result        = _isurveyFacade.SetOrganization(Request);
                        OrgListModel             OrgListModel  = new OrgListModel();
                        OrganizationResponse     Organizations = _isurveyFacade.GetUserOrganizations(Request);
                        List <OrganizationModel> Model         = Mapper.ToOrganizationModelList(Organizations.OrganizationList);
                        OrgListModel.OrganizationList = Model;

                        if (Result.Message.ToUpper() != "EXISTS")
                        {
                            OrgListModel.Message = "Organization " + OrgAdminInfoModel.OrgName + " has been created.";
                        }
                        else
                        {
                            // OrgListModel.Message = "The organization name provided already exists.";
                            OrgAdminInfoModel OrgInfo = new OrgAdminInfoModel();
                            //Request.Organization.OrganizationKey = GetOrgKey(url); ;

                            //Organizations = _isurveyFacade.GetOrganizationInfo(Request);
                            OrgInfo            = Mapper.ToOrgAdminInfoModel(Organizations);
                            OrgInfo.IsEditMode = false;
                            ModelState.AddModelError("OrgName", "The organization name provided already exists.");
                            return(View("OrgInfo", OrgInfo));
                        }
                        return(View("OrgList", OrgListModel));
                    }
                    catch (Exception ex)
                    {
                        return(View(OrgAdminInfoModel));
                    }
                }
                else
                {
                    return(View(OrgAdminInfoModel));
                }
            }
        }
Example #17
0
        //string responseid,string SurveyId, int ViewId, string CurrentPage
        // View =0 Root form
        public ActionResult Index(string formid, string responseId, int pagenumber = 1, int viewId = 0)
        {
            bool   reset     = false;
            string sortField = null;
            string sortOrder = null;

            if (Request.QueryString["sortfield"] != null)
            {
                sortField = Request.QueryString["sortfield"];
                SetSessionValue(UserSession.Key.SortField, sortField);
            }
            if (Request.QueryString["sort"] != null)
            {
                sortOrder = Request.QueryString["sort"];
                SetSessionValue(UserSession.Key.SortOrder, sortOrder);
            }
            if (string.IsNullOrWhiteSpace(sortOrder))
            {
                sortOrder = GetStringSessionValue(UserSession.Key.SortOrder, defaultValue: null);
                if (string.IsNullOrWhiteSpace(sortOrder))
                {
                    sortOrder = AppSettings.GetStringValue(AppSettings.Key.DefaultSortOrder);
                }
            }
            if (string.IsNullOrWhiteSpace(sortField))
            {
                sortField = GetStringSessionValue(UserSession.Key.SortField, defaultValue: null);
                if (string.IsNullOrWhiteSpace(sortField))
                {
                    sortField = AppSettings.GetStringValue(AppSettings.Key.DefaultSortField);
                }
            }
            bool.TryParse(Request.QueryString["reset"], out reset);
            if (reset)
            {
                RemoveSessionValue(UserSession.Key.SortOrder);
                RemoveSessionValue(UserSession.Key.SortField);
                RemoveSessionValue(UserSession.Key.SearchCriteria);
            }
            string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            ViewBag.Version = version;
            bool isAndroid = false;

            if (this.Request.UserAgent.IndexOf("Android", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                isAndroid = true;
            }
            if (viewId == 0)
            {
                //Following code checks if request is for new or selected form.
                if (GetStringSessionValue(UserSession.Key.RootFormId) == formid)
                {
                    _isNewRequest = false;
                }

                SetSessionValue(UserSession.Key.RootFormId, formid);
                RemoveSessionValue(UserSession.Key.RootResponseId);
                RemoveSessionValue(UserSession.Key.FormValuesHasChanged);
                SetSessionValue(UserSession.Key.IsEditMode, false);
                if (pagenumber == 0)
                {
                    pagenumber = 1;
                }
                var model = new FormResponseInfoModel();
                model.ViewId = viewId;
                int currentOrgId = GetIntSessionValue(UserSession.Key.CurrentOrgId, defaultValue: -1);
                model = GetSurveyResponseInfoModel(formid, pagenumber, sortOrder, sortField, currentOrgId);
                SetSessionValue(UserSession.Key.SelectedOrgId, model.FormInfoModel.OrganizationId);
                return(View("Index", model));
            }
            else
            {
                List <FormsHierarchyDTO> formsHierarchy = GetFormsHierarchy();
                int userId = SurveyHelper.GetDecryptUserId(Session[UserSession.Key.UserId].ToString());

                bool isMobileDevice = this.Request.Browser.IsMobileDevice;

                int requestedViewId = viewId;

                SetSessionValue(UserSession.Key.RequestedViewId, requestedViewId);
                SurveyModel surveyModel = new SurveyModel();

                surveyModel.RelateModel     = formsHierarchy.ToRelateModel(formid);
                surveyModel.RequestedViewId = requestedViewId;

                var relateSurveyId = formsHierarchy.Single(x => x.ViewId == viewId);

                if (!string.IsNullOrEmpty(responseId))
                {
                    surveyModel.FormResponseInfoModel = GetFormResponseInfoModels(relateSurveyId.FormId, responseId, formsHierarchy);
                    surveyModel.FormResponseInfoModel.NumberOfResponses = surveyModel.FormResponseInfoModel.ResponsesList.Count();

                    surveyModel.FormResponseInfoModel.ParentResponseId = responseId;
                }

                if (relateSurveyId.ResponseIds.Count() > 0)
                {
                    SurveyAnswerDTO surveyAnswerDTO = GetSurveyAnswer(relateSurveyId.ResponseIds[0].ResponseId, relateSurveyId.FormId);
                    var             form            = _surveyFacade.GetSurveyFormData(relateSurveyId.ResponseIds[0].SurveyId, 1, surveyAnswerDTO, isMobileDevice, null, null, isAndroid);
                    surveyModel.Form = form;
                    if (string.IsNullOrEmpty(responseId))
                    {
                        surveyModel.FormResponseInfoModel = GetFormResponseInfoModels(relateSurveyId.FormId, responseId, formsHierarchy);
                        surveyModel.FormResponseInfoModel.ParentResponseId = relateSurveyId.ResponseIds[0].ParentResponseId;
                    }

                    surveyModel.FormResponseInfoModel.FormInfoModel.FormName = form.SurveyInfo.SurveyName;
                    surveyModel.FormResponseInfoModel.FormInfoModel.FormId   = form.SurveyInfo.SurveyId;
                    surveyModel.FormResponseInfoModel.NumberOfResponses      = surveyModel.FormResponseInfoModel.ResponsesList.Count();
                }
                else
                {
                    FormResponseInfoModel responseInfoModel = new FormResponseInfoModel();
                    if (surveyModel.FormResponseInfoModel.ResponsesList.Count() > 0)
                    {
                        SurveyAnswerDTO surveyAnswerDTO = GetSurveyAnswer(surveyModel.FormResponseInfoModel.ResponsesList[0].Column0, relateSurveyId.FormId);
                        responseInfoModel = GetFormResponseInfoModels(relateSurveyId.FormId, responseId, formsHierarchy);
                        surveyModel.Form  = _surveyFacade.GetSurveyFormData(surveyAnswerDTO.SurveyId, 1, surveyAnswerDTO, isMobileDevice, null, null, isAndroid);
                        responseInfoModel.FormInfoModel.FormName = surveyModel.Form.SurveyInfo.SurveyName.ToString();
                        responseInfoModel.FormInfoModel.FormId   = surveyModel.Form.SurveyInfo.SurveyId.ToString();
                        responseInfoModel.ParentResponseId       = responseId;//SurveyModel.FormResponseInfoModel.ResponsesList[0].Column0;
                        responseInfoModel.NumberOfResponses      = surveyModel.FormResponseInfoModel.ResponsesList.Count();
                    }
                    else
                    {
                        var form1 = _surveyFacade.GetSurveyInfoModel(relateSurveyId.FormId);
                        responseInfoModel.FormInfoModel.FormName = form1.SurveyName.ToString();
                        responseInfoModel.FormInfoModel.FormId   = form1.SurveyId.ToString();
                        responseInfoModel.ParentResponseId       = responseId;
                    }
                    surveyModel.FormResponseInfoModel = responseInfoModel;
                }
                surveyModel.FormResponseInfoModel.ViewId = viewId;

                return(View("Index", surveyModel.FormResponseInfoModel));
            }
        }