private void DownloadSurveyAnswersButton_Click(object sender, RoutedEventArgs e) { SurveyManagerService.ManagerServiceClient client = ServiceClient.GetClient(); Epi.Web.Common.Message.SurveyAnswerRequest Request = new Epi.Web.Common.Message.SurveyAnswerRequest(); foreach (string id in SurveyAnswerIdListBox.Items) { Request.Criteria.SurveyAnswerIdList.Add(id); } if (!string.IsNullOrEmpty(this.SurveyAnswerCriteria_SurveyIdTextBox.Text.Trim())) { Request.Criteria.SurveyId = this.SurveyAnswerCriteria_SurveyIdTextBox.Text; } if (!string.IsNullOrEmpty(this.passUserPublishKeySurveyResponse.Password.Trim()) && IsGuid(passUserPublishKeySurveyResponse.Password)) { Request.Criteria.UserPublishKey = new Guid(this.passUserPublishKeySurveyResponse.Password); } else { MessageBox.Show("Publish key is not in correct format"); return; } if (this.datePicker1.SelectedDate != null) { Request.Criteria.DateCompleted = (DateTime)this.datePicker1.SelectedDate; } if ((bool)this.OnlyCompletedCheckBox.IsChecked) { Request.Criteria.StatusId = 3; } //chkIsSizeRequestSurveyResponse //Checking the Organization key guid is in correct format if (!IsGuid(passOrganizationKey.Password)) { MessageBox.Show("Organization key is not in correct format"); return; } //Assign the organization key Request.Criteria.OrganizationKey = new Guid(passOrganizationKey.Password); SurveyAnswerResponseTextBox.Document.Blocks.Clear(); int PageNumber = 0; int PageSize = 0; try { if (this.chkIsSizeRequestSurveyResponse.IsChecked == true) { Request.Criteria.ReturnSizeInfoOnly = true; Epi.Web.Common.Message.SurveyAnswerResponse Result = client.GetSurveyAnswer(Request); if (!string.IsNullOrEmpty(Result.Message)) { SurveyAnswerResponseTextBox.AppendText(string.Format(Result.Message)); } else { SurveyAnswerResponseTextBox.AppendText(string.Format(" - Number of Pages: {0} \n\n", Result.NumberOfPages)); SurveyAnswerResponseTextBox.AppendText(string.Format(" - Pages Size: {0} ", Result.PageSize)); } } else { Request.Criteria.ReturnSizeInfoOnly = true; Epi.Web.Common.Message.SurveyAnswerResponse SizeResult = client.GetSurveyAnswer(Request); if (!string.IsNullOrEmpty(SizeResult.Message)) { SurveyAnswerResponseTextBox.AppendText(string.Format(SizeResult.Message)); } else { PageSize = SizeResult.PageSize; Request.Criteria.ReturnSizeInfoOnly = false; SurveyAnswerResponseTextBox.AppendText(string.Format(" - Number of Pages: {0} \n\n", SizeResult.NumberOfPages)); SurveyAnswerResponseTextBox.AppendText(string.Format(" - Pages Size: {0} \n", SizeResult.PageSize)); for (int i = 1; i <= SizeResult.NumberOfPages; i++) { Request.Criteria.PageNumber = i; Request.Criteria.PageSize = PageSize; Epi.Web.Common.Message.SurveyAnswerResponse Result = client.GetSurveyAnswer(Request); SurveyAnswerResponseTextBox.AppendText(string.Format(" -Number of available records: {0}\n\n", Result.SurveyResponseList.Count)); foreach (Epi.Web.Common.DTO.SurveyAnswerDTO SurveyAnswer in Result.SurveyResponseList) { SurveyAnswerResponseTextBox.AppendText(string.Format("{0} - {1} - {2} - {3}\n", SurveyAnswer.ResponseId, SurveyAnswer.Status, SurveyAnswer.DateUpdated, SurveyAnswer.XML)); } } } } } catch (FaultException <CustomFaultException> cfe) { SurveyAnswerResponseTextBox.AppendText("FaultException<CustomFaultException>:\n"); SurveyAnswerResponseTextBox.AppendText(cfe.ToString()); } catch (FaultException fe) { SurveyAnswerResponseTextBox.AppendText("FaultException:\n"); SurveyAnswerResponseTextBox.AppendText(fe.ToString()); } catch (CommunicationException ce) { SurveyAnswerResponseTextBox.AppendText("CommunicationException:\n"); SurveyAnswerResponseTextBox.AppendText(ce.ToString()); } catch (TimeoutException te) { SurveyAnswerResponseTextBox.AppendText("TimeoutException:\n"); SurveyAnswerResponseTextBox.AppendText(te.ToString()); } catch (Exception ex) { SurveyAnswerResponseTextBox.AppendText("Exception:\n"); SurveyAnswerResponseTextBox.AppendText(ex.ToString()); } }
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)); } }
private void DownloadSurveyAnswersButton_Click(object sender, RoutedEventArgs e) { SurveyManagerService.ManagerServiceClient client = ServiceClient.GetClient(); Epi.Web.Common.Message.SurveyAnswerRequest Request = new Epi.Web.Common.Message.SurveyAnswerRequest(); foreach (string id in SurveyAnswerIdListBox.Items) { Request.Criteria.SurveyAnswerIdList.Add(id); } if (!string.IsNullOrEmpty(this.SurveyAnswerCriteria_SurveyIdTextBox.Text.Trim())) { Request.Criteria.SurveyId = this.SurveyAnswerCriteria_SurveyIdTextBox.Text; } if (!string.IsNullOrEmpty(this.UserPublishKeytextBox.Text.Trim())) { Request.Criteria.UserPublishKey = new Guid(this.UserPublishKeytextBox.Text); } if (this.datePicker1.SelectedDate != null) { Request.Criteria.DateCompleted = (DateTime)this.datePicker1.SelectedDate; } if ((bool)this.OnlyCompletedCheckBox.IsChecked) { Request.Criteria.StatusId = 1; } SurveyAnswerResponseTextBox.Document.Blocks.Clear(); try { Epi.Web.Common.Message.SurveyAnswerResponse Result = client.GetSurveyAnswer(Request); SurveyAnswerResponseTextBox.AppendText(string.Format("{0} - records.\n\n", Result.SurveyResponseList.Count)); foreach (Epi.Web.Common.DTO.SurveyAnswerDTO SurveyAnswer in Result.SurveyResponseList) { SurveyAnswerResponseTextBox.AppendText(string.Format("{0} - {1} - {2} - {3}\n", SurveyAnswer.ResponseId, SurveyAnswer.Status, SurveyAnswer.DateUpdated, SurveyAnswer.XML)); } } catch (FaultException <CustomFaultException> cfe) { SurveyAnswerResponseTextBox.AppendText("FaultException<CustomFaultException>:\n"); SurveyAnswerResponseTextBox.AppendText(cfe.ToString()); } catch (FaultException fe) { SurveyAnswerResponseTextBox.AppendText("FaultException:\n"); SurveyAnswerResponseTextBox.AppendText(fe.ToString()); } catch (CommunicationException ce) { SurveyAnswerResponseTextBox.AppendText("CommunicationException:\n"); SurveyAnswerResponseTextBox.AppendText(ce.ToString()); } catch (TimeoutException te) { SurveyAnswerResponseTextBox.AppendText("TimeoutException:\n"); SurveyAnswerResponseTextBox.AppendText(te.ToString()); } catch (Exception ex) { SurveyAnswerResponseTextBox.AppendText("Exception:\n"); SurveyAnswerResponseTextBox.AppendText(ex.ToString()); } }