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