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)); } }
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 void UpdateSurveyResponse(SurveyInfoModel surveyInfoModel, string responseId, MvcDynamicForms.Form form, SurveyAnswerDTO surveyAnswerDTO, bool isSubmited, bool isSaved, int pageNumber, int orgId, int userId, string userName) { // 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(); surveyAnswerResponse.SurveyResponseList.Add(surveyAnswerDTO); ///2 Update the current survey response and save it _surveyAnswerRequest.Criteria.UserId = userId; _surveyAnswerRequest.Criteria.UserName = userName; SurveyHelper.UpdateSurveyResponse(surveyInfoModel, form, _surveyAnswerRequest, _surveyResponseBuilder, _dataEntryService, surveyAnswerResponse, responseId, surveyAnswerDTO, isSubmited, isSaved, pageNumber, orgId, userId); }
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)); }
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")); } }
/// <summary> /// Perform end of pipeline processing. /// </summary> protected override void EndProcessing() { if (this.MyInvocation?.MyCommand?.Version != null && SurveyHelper.GetInstance().ShouldPropmtSurvey(this.MyInvocation.MyCommand.ModuleName, this.MyInvocation.MyCommand.Version)) { WriteSurvey(); if (_qosEvent != null) { _qosEvent.SurveyPrompted = true; } } if (MetricHelper.IsCalledByUser()) { // Send telemetry when cmdlet is directly called by user LogQosEvent(); } else { // When cmdlet is called within another cmdlet, we will not add a new telemetry, but add the cmdlet name to InternalCalledCmdlets MetricHelper.AppendInternalCalledCmdlet(this.MyInvocation?.MyCommand?.Name); } LogCmdletEndInvocationInfo(); TearDownDebuggingTraces(); TearDownHttpClientPipeline(); _previousEndTime = DateTimeOffset.Now; base.EndProcessing(); }
private void btnNav_Click(object sender, RoutedEventArgs e) { if ((string)this.btnNav.Content != this.btnNav_Content) { return; } this.btnNav.Content = SurveyMsg.MsgbtnNav_SaveText; if (this.method_1()) { this.btnNav.Content = this.btnNav_Content; return; } List <VEAnswer> list = this.method_2(); this.oLogicEngine.PageAnswer = list; this.oPageNav.oLogicEngine = this.oLogicEngine; if (!this.oPageNav.CheckLogic(this.CurPageId)) { this.btnNav.Content = this.btnNav_Content; return; } this.method_3(list); if (SurveyHelper.Debug) { MessageBox.Show(SurveyHelper.ShowPageAnswer(list), SurveyMsg.MsgCaption, MessageBoxButton.OK, MessageBoxImage.Asterisk); } this.MyNav.PageAnswer = list; this.oPageNav.NextPage(this.MyNav, base.NavigationService); this.btnNav.Content = this.btnNav_Content; }
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)); } }
/// <summary> /// This method accepts a surveyId and responseId and creates the first survey response entry /// </summary> /// <param name="responseContext"></param> /// <param name="isEditMode"></param> /// <param name="currentOrgId"></param> /// <returns></returns> public SurveyAnswerDTO CreateSurveyAnswer(IResponseContext responseContext) { return(SurveyHelper.CreateSurveyResponse(responseContext, _surveyAnswerRequest, _surveyAnswerDTO, _surveyResponseBuilder, _dataEntryService)); }
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 void UpdatePassCode(string ResponseId, string Passcode) { // convert DTO to UserAuthenticationRquest _PassCodeDTO.ResponseId = ResponseId; _PassCodeDTO.PassCode = Passcode; UserAuthenticationRequest AuthenticationRequestObj = Mapper.ToUserAuthenticationObj(_PassCodeDTO); SurveyHelper.UpdatePassCode(AuthenticationRequestObj, _iSurveyAnswerRepository); }
public void UpdatePassCode(string responseId, string passcode) { // convert DTO to UserAuthenticationRquest var passCodeDTO = new PassCodeDTO { ResponseId = responseId, PassCode = passcode }; UserAuthenticationRequest authenticationRequest = passCodeDTO.ToUserAuthenticationObj(); SurveyHelper.UpdatePassCode(authenticationRequest, _securityDataService); }
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 void UpdateSurveyResponse(SurveyInfoModel surveyInfoModel, string responseId, MvcDynamicForms.Form form, Epi.Web.Common.DTO.SurveyAnswerDTO surveyAnswerDTO, bool IsSubmited, bool IsSaved, int PageNumber) { // 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 = GetSurveyAnswerResponse(responseId); ///2 Update the current survey response and save it SurveyHelper.UpdateSurveyResponse(surveyInfoModel, form, _surveyAnswerRequest, _surveyResponseXML, _iSurveyAnswerRepository, surveyAnswerResponse, responseId, surveyAnswerDTO, IsSubmited, IsSaved, PageNumber); }
public SurveyPage() { InitializeComponent(); List <Survey> survey = SurveyHelper.GetContext().Survey.ToList(); SurveyResult result = new SurveyResult() { MaleSum = survey.Where(n => n.Gender == "M").Count(), FemaleSum = survey.Where(n => n.Gender == "F").Count() }; GenderData.Items.Add(result); }
/// <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); }
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 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); }
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 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 List <PrintResponseModel> GetResponseList(string responseId, bool FromFinal) { List <FormsHierarchyDTO> FormsHierarchy = GetFormsHierarchy(responseId); SurveyModel SurveyModel = new SurveyModel(); // SurveyModel.Form = form; SurveyModel.RelateModel = Mapper.ToRelateModel(FormsHierarchy, Session["RootFormId"].ToString()); // Common.Message.SurveyAnswerResponse answerResponse = _isurveyFacade.GetSurveyAnswerResponse(responseId); // List <PrintResponseModel> PrintList = new List <PrintResponseModel>(); foreach (var form in SurveyModel.RelateModel) { foreach (var answerResponse in form.ResponseIds) { PrintResponseModel PrintResponseModel = new PrintResponseModel(); SurveyInfoModel surveyInfoModel = GetSurveyInfo(answerResponse.SurveyId); Common.Message.SurveyControlsRequest Request = new Common.Message.SurveyControlsRequest(); Request.SurveyId = answerResponse.SurveyId; Common.Message.SurveyControlsResponse List = _isurveyFacade.GetSurveyControlList(Request); var QuestionAnswerList = SurveyHelper.GetQuestionAnswerList(answerResponse.XML, List); var SourceTables = _isurveyFacade.GetSourceTables(Session["RootFormId"].ToString()); PrintResponseModel.ResponseList = SurveyHelper.SetCommentLegalValues(QuestionAnswerList, List, surveyInfoModel, SourceTables); PrintResponseModel.NumberOfPages = SurveyHelper.GetNumberOfPags(answerResponse.XML); PrintResponseModel.SurveyName = surveyInfoModel.SurveyName; PrintResponseModel.CurrentDate = DateTime.Now.ToString(); PrintResponseModel.ResponseId = responseId; PrintResponseModel.SurveyId = form.FormId; PrintResponseModel.IsFromFinal = FromFinal; PrintList.Add(PrintResponseModel); } } return(PrintList); }
/// <summary> /// get the survey form data /// </summary> /// <param name="surveyId"></param> /// <param name="pageNumber"></param> /// <param name="surveyAnswerDTO"></param> /// <param name="isMobileDevice"></param> /// <param name="surveyAnswerDTOList"></param> /// <param name="formsHierarchyDTOList"></param> /// <param name="isAndroid"></param> /// <returns></returns> public MvcDynamicForms.Form GetSurveyFormData( string surveyId, int pageNumber, SurveyAnswerDTO surveyAnswerDTO, bool isMobileDevice, List <SurveyAnswerDTO> surveyAnswerDTOList = null, List <FormsHierarchyDTO> formsHierarchyDTOList = null, bool isAndroid = false) { List <SurveyInfoDTO> surveyInfoDTOList = new List <SurveyInfoDTO>(); //Get the SurveyInfoDTO SurveyInfoDTO surveyInfoDTO; if (formsHierarchyDTOList == null) { surveyInfoDTO = SurveyHelper.GetSurveyInfoDTO(_surveyInfoRequest, _surveyInfoService, surveyId); if (surveyAnswerDTOList != null) { foreach (var item in surveyAnswerDTOList) { Epi.Cloud.Common.Message.SurveyInfoRequest request = new SurveyInfoRequest(); request.Criteria.SurveyIdList.Add(item.SurveyId); SurveyInfoDTO surveyInfoDTO2 = SurveyHelper.GetSurveyInfoDTO(request, _surveyInfoService, item.SurveyId); surveyInfoDTOList.Add(surveyInfoDTO2); } } } else { var SurveyInfoDTO = formsHierarchyDTOList.First(x => x.FormId == (surveyAnswerDTO != null ? surveyAnswerDTO.SurveyId : surveyId)); surveyInfoDTO = SurveyInfoDTO.SurveyInfo; surveyAnswerDTOList = new List <SurveyAnswerDTO>(); surveyAnswerDTOList.Add(surveyAnswerDTO); foreach (var item in formsHierarchyDTOList) { if (item.ResponseIds.Count() > 0) { var DTO = item.ResponseIds.FirstOrDefault(z => z.ResponseId == surveyAnswerDTO.ParentResponseId); if (DTO != null && !surveyAnswerDTOList.Contains(DTO)) { surveyAnswerDTOList.Add(DTO); } } } foreach (var item in surveyAnswerDTOList) { if (item != null) { var formsHierarchyDTO = formsHierarchyDTOList.FirstOrDefault(x => x.FormId == item.SurveyId); surveyInfoDTOList.Add(formsHierarchyDTO.SurveyInfo); } } } var formProvider = isMobileDevice ? new MobileFormProvider(surveyId) : new FormProvider(surveyId); MvcDynamicForms.Form form = formProvider.GetForm(surveyInfoDTO, pageNumber, surveyAnswerDTO, surveyAnswerDTOList, surveyInfoDTOList, isAndroid); return(form); }
/// <summary> /// This method accepts a surveyId and responseId and creates the first survey response entry /// </summary> /// <param name="SurveyId"></param> /// <returns></returns> public Epi.Web.Common.DTO.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 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)); }
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)); } } }
public void Execute(IServiceProvider serviceProvider) { SqlDataAccess sda = null; try { sda = new SqlDataAccess(); sda.openConnection(Globals.ConnectionString); #region | SERVICE | IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); #region | Validate Request | //Target yoksa veya Entity tipinde değilse, devam etme. if (!context.InputParameters.Contains("Target") || !(context.InputParameters["Target"] is Entity)) { return; } #endregion IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); #endregion Entity entity = (Entity)context.InputParameters["Target"]; #region | VARIABLES | List <ScoreLimit> lstLimits = new List <ScoreLimit>(); EntityReference portal = null; EntityReference user = null; if (entity.Contains("new_portalid") && entity["new_portalid"] != null) { portal = (EntityReference)entity["new_portalid"]; } if (entity.Contains("new_userid") && entity["new_userid"] != null) { user = (EntityReference)entity["new_userid"]; } #endregion MsCrmResultObject limitRes = ScoreHelper.GetScoreLimitsByType(ScoreType.Survey, sda); if (limitRes.Success) { lstLimits = (List <ScoreLimit>)limitRes.ReturnObject; for (int i = 0; i < lstLimits.Count; i++) { int recCount = 0; DateTime start = GeneralHelper.GetStartDateByScorePeriod(lstLimits[i].Period); DateTime end = GeneralHelper.GetEndDateByScorePeriod(lstLimits[i].Period); recCount = SurveyHelper.GetUserSurveyAnswerCount(portal.Id, user.Id, start, end, sda); if (lstLimits[i].Frequency >= recCount) { Score sc = new Score() { Point = lstLimits[i].Point, Portal = portal, User = user, ScoreType = ScoreType.Survey }; MsCrmResult scoreRes = ScoreHelper.CreateScore(sc, service); break; } } } } catch (Exception ex) { //LOG throw new InvalidPluginExecutionException(ex.Message); } finally { if (sda != null) { sda.closeConnection(); } } }
private void btnCheck_Click(object sender, RoutedEventArgs e) { if (File.Exists(SurveyHelper.DebugFlagFile)) { new DebugCheck().ShowDialog(); return; } MessageBox.Show("" + Environment.NewLine + SurveyMsg.MsgPrePageAnswer + this.oSurveybiz.GetInfoBySequenceId(SurveyHelper.SurveyID, SurveyHelper.SurveySequence - 1) + Environment.NewLine + SurveyHelper.ShowInfo(), SurveyMsg.MsgCaption, MessageBoxButton.OK, MessageBoxImage.Asterisk); }