private void DownloadSurveyInfoButton_Click(object sender, RoutedEventArgs e)
        {
            EWEManagerService.EWEManagerServiceClient client = ServiceClient.GetClient();

            Epi.Web.Enter.Common.Message.SurveyInfoRequest Request = new Epi.Web.Enter.Common.Message.SurveyInfoRequest();

            if (!string.IsNullOrEmpty(this.SurveyCriteria_SurveyId.Text.Trim()))
            {
                Request.Criteria.SurveyIdList.Add(this.SurveyCriteria_SurveyId.Text);
            }

            if ((bool)this.SurveyCriteria_CurrentlyOpenCheckBox.IsChecked)
            {
                Request.Criteria.ClosingDate = DateTime.Now;
            }

            if (this.SurveyInfoCriteria_SurveyTypeListBox.SelectedIndex > -1)
            {
                Request.Criteria.SurveyType = int.Parse(((ListBoxItem)this.SurveyInfoCriteria_SurveyTypeListBox.Items[this.SurveyInfoCriteria_SurveyTypeListBox.SelectedIndex]).Tag.ToString());
            }

            if (!string.IsNullOrEmpty(this.OrgTextBox1.Text))
            {
                Request.Criteria.OrganizationKey = new Guid(OrgTextBox1.Text);
            }
            else
            {
            }
            if (!string.IsNullOrEmpty(this.TextBoxPublish.Text))
            {
                Request.Criteria.UserPublishKey = new Guid(this.TextBoxPublish.Text);
            }
            else
            {
            }
            SurveyInfoResponseTextBox.Document.Blocks.Clear();
            SearchResultListBox.Items.Clear();

            this.selectedIndex = -1;

            this.SurveyNameTextBox.Text             = "";
            this.DepartmentTextBox.Text             = "";
            this.SurveyNumberTextBox.Text           = "";
            this.OrganizationTextBox.Text           = "";
            this.datePicker1.SelectedDate           = DateTime.Now;
            this.IsSingleResponseCheckBox.IsChecked = false;
            this.IsTestMode.IsChecked = false;
            this.IntroductionTextBox.Document.Blocks.Clear();
            this.ExitTextTextBox.Document.Blocks.Clear();
            this.TemplateXMLTextBox.Document.Blocks.Clear();
            this.datePicker2.SelectedDate = DateTime.Now;
            try
            {
                Epi.Web.Enter.Common.Message.SurveyInfoResponse Result = client.GetSurveyInfo(Request);
                SurveyInfoList = Result.SurveyInfoList;
                SearchResultListBox.Items.Clear();



                SurveyInfoResponseTextBox.AppendText(string.Format("{0} - records. \n\n", Result.SurveyInfoList.Count));
                foreach (Epi.Web.Enter.Common.DTO.SurveyInfoDTO SurveyInfo in SurveyInfoList)
                {
                    //SurveyInfoResponseTextBox.AppendText(string.Format("{0} - {1} - {2}\n", SurveyInfo.SurveyId, SurveyInfo.SurveyName, SurveyInfo.ClosingDate));
                    //System.Collections.Generic.KeyValuePair<string, string> kvp = new KeyValuePair<string, string>(SurveyInfo.SurveyId,string.Format("{0} - {1} - {2}\n", SurveyInfo.SurveyId, SurveyInfo.SurveyName, SurveyInfo.ClosingDate));

                    SearchResultListBox.Items.Add(string.Format("{0} - {1} - {2}\n", SurveyInfo.SurveyId, SurveyInfo.SurveyName, SurveyInfo.ClosingDate));
                }
            }
            catch (FaultException <CustomFaultException> cfe)
            {
                SurveyInfoResponseTextBox.AppendText("FaultException<CustomFaultException>:\n");
                SurveyInfoResponseTextBox.AppendText(cfe.ToString());
            }
            catch (FaultException fe)
            {
                SurveyInfoResponseTextBox.AppendText("FaultException:\n");
                SurveyInfoResponseTextBox.AppendText(fe.ToString());
            }
            catch (CommunicationException ce)
            {
                SurveyInfoResponseTextBox.AppendText("CommunicationException:\n");
                SurveyInfoResponseTextBox.AppendText(ce.ToString());
            }
            catch (TimeoutException te)
            {
                SurveyInfoResponseTextBox.AppendText("TimeoutException:\n");
                SurveyInfoResponseTextBox.AppendText(te.ToString());
            }
            catch (Exception ex)
            {
                SurveyInfoResponseTextBox.AppendText("Exception:\n");
                SurveyInfoResponseTextBox.AppendText(ex.ToString());
            }
        }
Beispiel #2
0
        private void DownloadSurveyInfoButton_Click(object sender, RoutedEventArgs e)
        {
            EWEManagerService.EWEManagerServiceClient client = ServiceClient.GetClient();

            Epi.Web.Enter.Common.Message.SurveyInfoRequest Request = new Epi.Web.Enter.Common.Message.SurveyInfoRequest();


            //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);



            if (!string.IsNullOrEmpty(this.SurveyCriteria_SurveyId.Text.Trim()))
            {
                Request.Criteria.SurveyIdList.Add(this.SurveyCriteria_SurveyId.Text);
            }

            if ((bool)this.SurveyCriteria_CurrentlyOpenCheckBox.IsChecked)
            {
                Request.Criteria.ClosingDate = DateTime.Now;
            }

            if (this.SurveyInfoCriteria_SurveyTypeListBox.SelectedIndex > -1)
            {
                Request.Criteria.SurveyType = int.Parse(((ListBoxItem)this.SurveyInfoCriteria_SurveyTypeListBox.Items[this.SurveyInfoCriteria_SurveyTypeListBox.SelectedIndex]).Tag.ToString());
            }


            SurveyInfoResponseTextBox.Document.Blocks.Clear();

            int PageNumber = 0;
            int PageSize   = 0;

            try
            {
                if (this.chkIsSizeRequestSurveyInfo.IsChecked == true)
                {
                    Request.Criteria.ReturnSizeInfoOnly = true;
                    Epi.Web.Enter.Common.Message.SurveyInfoResponse Result = client.GetSurveyInfo(Request);
                    if (!string.IsNullOrEmpty(Result.Message))
                    {
                        SurveyInfoResponseTextBox.AppendText(string.Format(Result.Message));
                    }
                    else
                    {
                        SurveyInfoResponseTextBox.AppendText(string.Format(" - Number of Pages: {0}   \n\n", Result.NumberOfPages));
                        SurveyInfoResponseTextBox.AppendText(string.Format(" - Pages Size:   {0} \n ", Result.PageSize));
                    }
                }
                else
                {
                    // 2 Step process:
                    //      1 - get sizing information.
                    //      2 - Loop thru calls for query results


                    // 1 - get sizing information
                    Request.Criteria.ReturnSizeInfoOnly = true;
                    Epi.Web.Enter.Common.Message.SurveyInfoResponse SizeResult = client.GetSurveyInfo(Request);


                    if (!string.IsNullOrEmpty(SizeResult.Message))
                    {
                        SurveyInfoResponseTextBox.AppendText(string.Format(SizeResult.Message));
                    }
                    else
                    {
                        SurveyInfoResponseTextBox.AppendText(string.Format(" - Number of Pages: {0}   \n\n", SizeResult.NumberOfPages));
                        SurveyInfoResponseTextBox.AppendText(string.Format(" - Pages Size:   {0}  \n", SizeResult.PageSize));

                        // 2 - loop thru calls for query results
                        PageSize   = SizeResult.PageSize;
                        PageNumber = SizeResult.NumberOfPages;
                        Request.Criteria.ReturnSizeInfoOnly = false;

                        for (int i = 1; i <= PageNumber; i++)
                        {
                            Request.Criteria.PageNumber = i;

                            Epi.Web.Enter.Common.Message.SurveyInfoResponse Result = client.GetSurveyInfo(Request);

                            foreach (Epi.Web.Enter.Common.DTO.SurveyInfoDTO SurveyInfo in Result.SurveyInfoList)
                            {
                                SurveyInfoResponseTextBox.AppendText(string.Format("{0} - {1} - {2}\n", SurveyInfo.SurveyId, SurveyInfo.SurveyName, SurveyInfo.ClosingDate));
                            }
                        }
                    }
                }
            }
            catch (FaultException <CustomFaultException> cfe)
            {
                SurveyInfoResponseTextBox.AppendText("FaultException<CustomFaultException>:\n");
                SurveyInfoResponseTextBox.AppendText(cfe.ToString());
            }
            catch (FaultException fe)
            {
                SurveyInfoResponseTextBox.AppendText("FaultException:\n");
                SurveyInfoResponseTextBox.AppendText(fe.ToString());
            }
            catch (CommunicationException ce)
            {
                SurveyInfoResponseTextBox.AppendText("CommunicationException:\n");
                SurveyInfoResponseTextBox.AppendText(ce.ToString());
            }
            catch (TimeoutException te)
            {
                SurveyInfoResponseTextBox.AppendText("TimeoutException:\n");
                SurveyInfoResponseTextBox.AppendText(te.ToString());
            }
            catch (Exception ex)
            {
                SurveyInfoResponseTextBox.AppendText("Exception:\n");
                SurveyInfoResponseTextBox.AppendText(ex.ToString());
            }
        }