private void PingButton_Click(object sender, RoutedEventArgs e)
        {
            this.PingResultTextBox.Text = "";
            string pEndPointAddress = this.EndPointURLTextBox.Text;
            bool   pIsAuthenticated = false;
            bool   pIsWsHTTPBinding = true;

            if ((bool)this.YesRadioButton.IsChecked)
            {
                pIsAuthenticated = true;
            }

            if ((bool)this.wsHTTPRadioButton.IsChecked)
            {
                pIsWsHTTPBinding = true;
            }
            else
            {
                pIsWsHTTPBinding = false;
            }


            try
            {
                int ServiceVersion = ServiceClient.GetServiceVersion();

                if (ServiceVersion == 1)
                {
                    SurveyManagerServiceV4.ManagerServiceV4Client Client  = ServiceClient.GetClientV4(pEndPointAddress, pIsAuthenticated, pIsWsHTTPBinding);
                    Epi.Web.Common.Message.OrganizationRequest    Request = new Epi.Web.Common.Message.OrganizationRequest();
                    var Result = Client.GetOrganization(Request);
                }
                else if (ServiceVersion == 2)
                {
                    SurveyManagerServiceV2.ManagerServiceV2Client Client  = ServiceClient.GetClientV2(pEndPointAddress, pIsAuthenticated, pIsWsHTTPBinding);
                    Epi.Web.Common.Message.OrganizationRequest    Request = new Epi.Web.Common.Message.OrganizationRequest();
                    var Result = Client.GetOrganization(Request);
                }
                else if (ServiceVersion == 3)
                {
                    SurveyManagerServiceV3.ManagerServiceV3Client Client  = ServiceClient.GetClientV3(pEndPointAddress, pIsAuthenticated, pIsWsHTTPBinding);
                    Epi.Web.Common.Message.OrganizationRequest    Request = new Epi.Web.Common.Message.OrganizationRequest();
                    var Result = Client.GetOrganization(Request);
                }
                else if (ServiceVersion == 4)
                {
                    SurveyManagerServiceV4.ManagerServiceV4Client Client  = ServiceClient.GetClientV4(pEndPointAddress, pIsAuthenticated, pIsWsHTTPBinding);
                    Epi.Web.Common.Message.OrganizationRequest    Request = new Epi.Web.Common.Message.OrganizationRequest();
                    var Result = Client.GetOrganization(Request);
                }
                this.PingResultTextBox.Text = "Successfully Created Service Client";

                this.PingResultTextBox.Text = "Successfully Created Service Client";
            }
            catch (Exception ex)
            {
                this.PingResultTextBox.Text = "Failed to create Service Client:\n\n" + ex.Message;
            }
        }
Пример #2
0
        private void SubmitRequestButton_Click(object sender, RoutedEventArgs e)
        {

            ServiceResponseTextBox.Document.Blocks.Clear();
            this.OpenURLButton.IsEnabled = false;

           // SurveyManagerService.ManagerServiceClient client = ServiceClient.GetClient();

            Epi.Web.Common.Message.PublishRequest Request = new Epi.Web.Common.Message.PublishRequest();
            if (this.datePicker1.SelectedDate == null)
            {
                TimeSpan t = new TimeSpan(10, 0, 0, 0);
                Request.SurveyInfo.ClosingDate = DateTime.Now + t;
            }
            else
            {
                Request.SurveyInfo.ClosingDate = (DateTime)this.datePicker1.SelectedDate;
            }

            Request.SurveyInfo.DepartmentName = this.DepartmentTextBox.Text;
            Request.SurveyInfo.IntroductionText = new TextRange(this.IntroductionTextBox.Document.ContentStart, this.IntroductionTextBox.Document.ContentEnd).Text;
            Request.SurveyInfo.ExitText = new TextRange(this.ExitTextTextBox.Document.ContentStart, this.ExitTextTextBox.Document.ContentEnd).Text;
            if ((bool)this.IsSingleResponseCheckBox.IsChecked)
            {
                Request.SurveyInfo.SurveyType = 1;
            }
            else
            {
                Request.SurveyInfo.SurveyType = 2;
            }

            Request.SurveyInfo.OrganizationName = this.OrganizationTextBox.Text;
            Request.SurveyInfo.SurveyName = this.SurveyNameTextBox.Text;
            Request.SurveyInfo.SurveyNumber = this.SurveyNumberTextBox.Text;
            Request.SurveyInfo.XML = new TextRange(this.TemplateXMLTextBox.Document.ContentStart, this.TemplateXMLTextBox.Document.ContentEnd).Text;
           
            //Checking the publish key guid is in correct format
            if (!IsGuid(txtPublishKey.Text))
            {
                MessageBox.Show("Publish key is not in correct format");
                return;
            }

            Request.SurveyInfo.UserPublishKey = new Guid(txtPublishKey.Text);
            //get the Organization key and assign it to SurveyInfoDTO object under PublishRequest
            string strOrganizationKey = passOrganizationKey.Password.ToString();
            if (!IsGuid(strOrganizationKey))
            {
                MessageBox.Show("Organization key is not in correct format");
                return;
            }
            Guid gOrganizationkey = new Guid(strOrganizationKey);
            Request.SurveyInfo.OrganizationKey = gOrganizationkey;
            try
            {


            int ServiceVersion =   ServiceClient.GetServiceVersion();

            if (ServiceVersion == 1)
                {
                SurveyManagerService.ManagerServiceClient client = ServiceClient.GetClient();
                Epi.Web.Common.Message.PublishResponse Result = client.PublishSurvey(Request);

                passOrganizationKey.Password = string.Empty;
                URL = Result.PublishInfo.URL;
                ServiceResponseTextBox.AppendText("is published: ");
                ServiceResponseTextBox.AppendText(Result.PublishInfo.IsPulished.ToString());
                ServiceResponseTextBox.AppendText("\nURL: ");
                ServiceResponseTextBox.AppendText(Result.PublishInfo.URL);
                ServiceResponseTextBox.AppendText("\nStatus Text: ");
                ServiceResponseTextBox.AppendText(Result.PublishInfo.StatusText);
                ServiceResponseTextBox.AppendText("\n User Publish Key: ");
                ServiceResponseTextBox.AppendText(UserPublishKey.ToString());
                this.OpenURLButton.IsEnabled = Result.PublishInfo.IsPulished;
                }

            else if (ServiceVersion == 2)
                {
                SurveyManagerServiceV2.ManagerServiceV2Client client = ServiceClient.GetClientV2();
                Epi.Web.Common.Message.PublishResponse Result = client.PublishSurvey(Request);

                passOrganizationKey.Password = string.Empty;
                URL = Result.PublishInfo.URL;
                ServiceResponseTextBox.AppendText("is published: ");
                ServiceResponseTextBox.AppendText(Result.PublishInfo.IsPulished.ToString());
                ServiceResponseTextBox.AppendText("\nURL: ");
                ServiceResponseTextBox.AppendText(Result.PublishInfo.URL);
                ServiceResponseTextBox.AppendText("\nStatus Text: ");
                ServiceResponseTextBox.AppendText(Result.PublishInfo.StatusText);
                ServiceResponseTextBox.AppendText("\n User Publish Key: ");
                ServiceResponseTextBox.AppendText(UserPublishKey.ToString());
                this.OpenURLButton.IsEnabled = Result.PublishInfo.IsPulished;
                }
            else if (ServiceVersion == 3)
            {
                SurveyManagerServiceV3.ManagerServiceV3Client client = ServiceClient.GetClientV3();
                Epi.Web.Common.Message.PublishResponse Result = client.PublishSurvey(Request);

                passOrganizationKey.Password = string.Empty;
                URL = Result.PublishInfo.URL;
                ServiceResponseTextBox.AppendText("is published: ");
                ServiceResponseTextBox.AppendText(Result.PublishInfo.IsPulished.ToString());
                ServiceResponseTextBox.AppendText("\nURL: ");
                ServiceResponseTextBox.AppendText(Result.PublishInfo.URL);
                ServiceResponseTextBox.AppendText("\nStatus Text: ");
                ServiceResponseTextBox.AppendText(Result.PublishInfo.StatusText);
                ServiceResponseTextBox.AppendText("\n User Publish Key: ");
                ServiceResponseTextBox.AppendText(UserPublishKey.ToString());
                this.OpenURLButton.IsEnabled = Result.PublishInfo.IsPulished;
            }




             
                
            }
            catch (FaultException<CustomFaultException> cfe)
            {
                ServiceResponseTextBox.AppendText("FaultException<CustomFaultException>:\n");
                ServiceResponseTextBox.AppendText(cfe.ToString());
            }
            catch (FaultException fe)
            {
                ServiceResponseTextBox.AppendText("FaultException:\n");
                ServiceResponseTextBox.AppendText(fe.ToString());
            }
            catch (CommunicationException ce)
            {
                ServiceResponseTextBox.AppendText("CommunicationException:\n");
                ServiceResponseTextBox.AppendText(ce.ToString());
            }
            catch (TimeoutException te)
            {
                ServiceResponseTextBox.AppendText("TimeoutException:\n");
                ServiceResponseTextBox.AppendText(te.ToString());
            }
            catch (Exception ex)
            {
                ServiceResponseTextBox.AppendText("Exception:\n");
                ServiceResponseTextBox.AppendText(ex.ToString());
            }
        }
Пример #3
0
        public void GetOrganizationNames()
        {
            richTextBox1.AppendText("Simo is here");

            Epi.Web.Common.Message.OrganizationRequest Request = new Epi.Web.Common.Message.OrganizationRequest();

            richTextBox1.Document.Blocks.Clear();

            try
            {
                if (!string.IsNullOrEmpty(passwordBox1.Password.ToString()) && IsGuid(passwordBox1.Password.ToString()))
                {
                    int ServiceVersion = ServiceClient.GetServiceVersion();

                    if (ServiceVersion == 1)
                    {
                        Request.AdminSecurityKey = new Guid(passwordBox1.Password);
                        SurveyManagerService.ManagerServiceClient   client = ServiceClient.GetClient();
                        Epi.Web.Common.Message.OrganizationResponse Result = client.GetOrganizationNames(Request);


                        OnamelistBox1.Items.Clear();
                        if (Result.Message != null)
                        {
                            richTextBox1.AppendText(Result.Message.ToString());
                        }
                        if (Result.OrganizationList != null)
                        {
                            for (int i = 0; i < Result.OrganizationList.Count; i++)
                            {
                                this.OnamelistBox1.Items.Add(Result.OrganizationList[i].Organization + "___" + Result.OrganizationList[i].OrganizationId);
                            }
                            this.OnamelistBox1.SelectedIndex = 0;
                        }
                    }

                    else if (ServiceVersion == 2)
                    {
                        Request.AdminSecurityKey = new Guid(passwordBox1.Password);
                        SurveyManagerServiceV2.ManagerServiceV2Client client = ServiceClient.GetClientV2();
                        Epi.Web.Common.Message.OrganizationResponse   Result = client.GetOrganizationNames(Request);


                        OnamelistBox1.Items.Clear();
                        if (Result.Message != null)
                        {
                            richTextBox1.AppendText(Result.Message.ToString());
                        }
                        if (Result.OrganizationList != null)
                        {
                            for (int i = 0; i < Result.OrganizationList.Count; i++)
                            {
                                this.OnamelistBox1.Items.Add(Result.OrganizationList[i].Organization);
                            }
                            this.OnamelistBox1.SelectedIndex = 0;
                        }
                    }
                    else if (ServiceVersion == 3)
                    {
                        Request.AdminSecurityKey = new Guid(passwordBox1.Password);
                        SurveyManagerServiceV3.ManagerServiceV3Client client = ServiceClient.GetClientV3();
                        Epi.Web.Common.Message.OrganizationResponse   Result = client.GetOrganizationNames(Request);


                        OnamelistBox1.Items.Clear();
                        if (Result.Message != null)
                        {
                            richTextBox1.AppendText(Result.Message.ToString());
                        }
                        if (Result.OrganizationList != null)
                        {
                            for (int i = 0; i < Result.OrganizationList.Count; i++)
                            {
                                this.OnamelistBox1.Items.Add(Result.OrganizationList[i].Organization);
                            }
                            this.OnamelistBox1.SelectedIndex = 0;
                        }
                    }
                    else if (ServiceVersion == 4)
                    {
                        Request.AdminSecurityKey = new Guid(passwordBox1.Password);
                        SurveyManagerServiceV4.ManagerServiceV4Client client = ServiceClient.GetClientV4();
                        Epi.Web.Common.Message.OrganizationResponse   Result = client.GetOrganizationNames(Request);


                        OnamelistBox1.Items.Clear();
                        if (Result.Message != null)
                        {
                            richTextBox1.AppendText(Result.Message.ToString());
                        }
                        if (Result.OrganizationList != null)
                        {
                            for (int i = 0; i < Result.OrganizationList.Count; i++)
                            {
                                this.OnamelistBox1.Items.Add(Result.OrganizationList[i].Organization);
                            }
                            this.OnamelistBox1.SelectedIndex = 0;
                        }
                        if (this.OnamelistBox1.SelectedItem != null)
                        {
                            GetOrgUsers();
                        }
                    }
                    else
                    {
                        richTextBox1.AppendText("Error occurred while trying to get all organization names.");
                    }
                }
                else
                {
                    richTextBox1.AppendText("Admin key  is required and Should be a Guid.");
                }
            }
            catch (Exception ex)
            {
                richTextBox1.AppendText("Error occurred while trying to get all organization names. ");
            }
        }
Пример #4
0
        private void AddOrganization_Click(object sender, RoutedEventArgs e)
        {
            richTextBox1.Document.Blocks.Clear();

            Epi.Web.Common.Message.OrganizationRequest Request = new Epi.Web.Common.Message.OrganizationRequest();


            richTextBox1.Foreground = Brushes.Red;



            try
            {
                if (!string.IsNullOrEmpty(passwordBox1.Password.ToString()) && IsGuid(passwordBox1.Password.ToString()))
                {
                    if (!string.IsNullOrEmpty(OrganizationtextBox1.Text.ToString()))
                    {
                        if (!string.IsNullOrEmpty(GeneratedkeytextBox1.Text.ToString()))
                        {
                            Request.Organization.IsEnabled    = true;
                            Request.AdminSecurityKey          = new Guid(passwordBox1.Password);
                            Request.Organization.Organization = OrganizationtextBox1.Text;
                            //Request.Organization.OrganizationKey = Cryptography.Encrypt(this.GeneratedkeytextBox1.Text);
                            Request.Organization.OrganizationKey = this.GeneratedkeytextBox1.Text.ToString();
                            // Epi.Web.Common.Message.OrganizationResponse Result = client.SetOrganization(Request);
                            var Organizationtext = OrganizationtextBox1.Text.ToString();
                            var Generatedkey     = GeneratedkeytextBox1.Text.ToString();
                            richTextBox1.Document.Blocks.Clear();
                            OrganizationtextBox1.Clear();
                            GeneratedkeytextBox1.Clear();
                            int ServiceVersion = ServiceClient.GetServiceVersion();

                            if (ServiceVersion == 1)
                            {
                                SurveyManagerService.ManagerServiceClient Client = ServiceClient.GetClient();

                                Epi.Web.Common.Message.OrganizationResponse Result = Client.SetOrganization(Request);

                                if (Result.Message.ToString().Contains("Successfully"))
                                {
                                    Page_AddUser Page_AddUser = new Page_AddUser(new Guid(Generatedkey), new Guid(passwordBox1.Password), Organizationtext, "", false);
                                    this.NavigationService.Navigate(Page_AddUser);
                                    richTextBox1.Foreground = Brushes.Green;
                                    richTextBox1.AppendText(Result.Message.ToString());
                                }
                                else
                                {
                                    richTextBox1.Foreground = Brushes.Red;
                                    richTextBox1.AppendText(Result.Message.ToString());
                                }
                            }
                            else if (ServiceVersion == 2)
                            {
                                SurveyManagerServiceV2.ManagerServiceV2Client Client = ServiceClient.GetClientV2();

                                Epi.Web.Common.Message.OrganizationResponse Result = Client.SetOrganization(Request);

                                if (Result.Message.ToString().Contains("Successfully"))
                                {
                                    Page_AddUser Page_AddUser = new Page_AddUser(new Guid(Generatedkey), new Guid(passwordBox1.Password), Organizationtext, "", false);
                                    this.NavigationService.Navigate(Page_AddUser);
                                    richTextBox1.Foreground = Brushes.Green;
                                    richTextBox1.AppendText(Result.Message.ToString());
                                }
                                else
                                {
                                    richTextBox1.Foreground = Brushes.Red;
                                    richTextBox1.AppendText(Result.Message.ToString());
                                }
                            }
                            else if (ServiceVersion == 3)
                            {
                                SurveyManagerServiceV3.ManagerServiceV3Client Client = ServiceClient.GetClientV3();

                                Epi.Web.Common.Message.OrganizationResponse Result = Client.SetOrganization(Request);

                                if (Result.Message.ToString().Contains("Successfully"))
                                {
                                    Page_AddUser Page_AddUser = new Page_AddUser(new Guid(Generatedkey), new Guid(passwordBox1.Password), Organizationtext, "", false);
                                    this.NavigationService.Navigate(Page_AddUser);
                                    richTextBox1.Foreground = Brushes.Green;
                                    richTextBox1.AppendText(Result.Message.ToString());
                                }
                                else
                                {
                                    richTextBox1.Foreground = Brushes.Red;
                                    richTextBox1.AppendText(Result.Message.ToString());
                                }
                            }
                            else if (ServiceVersion == 4)
                            {
                                SurveyManagerServiceV4.ManagerServiceV4Client Client = ServiceClient.GetClientV4();

                                Epi.Web.Common.Message.OrganizationResponse Result = Client.SetOrganization(Request);

                                if (Result.Message.ToString().Contains("Successfully"))
                                {
                                    Page_AddUser Page_AddUser = new Page_AddUser(new Guid(Generatedkey), new Guid(passwordBox1.Password), Organizationtext, "", false);
                                    this.NavigationService.Navigate(Page_AddUser);
                                    richTextBox1.Foreground = Brushes.Green;
                                    richTextBox1.AppendText(Result.Message.ToString());
                                }
                                else
                                {
                                    richTextBox1.Foreground = Brushes.Red;
                                    richTextBox1.AppendText(Result.Message.ToString());
                                }
                            }
                        }
                        else
                        {
                            richTextBox1.AppendText("Please generate organization key.");
                        }
                    }
                    else
                    {
                        richTextBox1.AppendText("Organization Name is required.");
                    }
                }
                else
                {
                    richTextBox1.AppendText("Admin key  is required and Should be a Guid.");
                }
            }
            catch (Exception ex)
            {
                richTextBox1.AppendText("Error occurred while trying to add new organization key. Please  try again. ");
            }
        }
Пример #5
0
        private void DownloadSurveyInfoButton_Click(object sender, RoutedEventArgs e)
        {
            //if (ServiceVersion == "V1")
            //    {
            //    SurveyManagerService.ManagerServiceClient client = ServiceClient.GetClient();
            //    }

            //else if (ServiceVersion == "V2")
            //    {
            //    SurveyManagerServiceV2.ManagerServiceV2Client client = ServiceClient.GetClientV2();
            //    }
            Epi.Web.Common.Message.SurveyInfoRequest Request = new Epi.Web.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
            {
                int ServiceVersion = ServiceClient.GetServiceVersion();

                if (ServiceVersion == 1)
                {
                    SurveyManagerService.ManagerServiceClient client = ServiceClient.GetClient();
                    Epi.Web.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.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));
                    }
                }

                else if (ServiceVersion == 2)
                {
                    SurveyManagerServiceV2.ManagerServiceV2Client client = ServiceClient.GetClientV2();
                    Epi.Web.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.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));
                    }
                }


                else if (ServiceVersion == 3)
                {
                    SurveyManagerServiceV3.ManagerServiceV3Client client = ServiceClient.GetClientV3();
                    Epi.Web.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.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());
            }
        }
Пример #6
0
        private void UpdateSurveyButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.selectedIndex > -1)
            {
                SurveyInfoResponseTextBox.Document.Blocks.Clear();



                Epi.Web.Common.Message.SurveyInfoRequest Request = new Epi.Web.Common.Message.SurveyInfoRequest();
                Request.Action = "Update";
                if (this.datePicker1.SelectedDate == null)
                {
                    TimeSpan t = new TimeSpan(10, 0, 0, 0);
                    this.SurveyInfoList[this.selectedIndex].ClosingDate = DateTime.Now + t;
                }
                else
                {
                    this.SurveyInfoList[this.selectedIndex].ClosingDate = (DateTime)this.datePicker1.SelectedDate;
                }

                this.SurveyInfoList[this.selectedIndex].DepartmentName   = this.DepartmentTextBox.Text;
                this.SurveyInfoList[this.selectedIndex].IntroductionText = new TextRange(this.IntroductionTextBox.Document.ContentStart, this.IntroductionTextBox.Document.ContentEnd).Text;
                this.SurveyInfoList[this.selectedIndex].ExitText         = new TextRange(this.ExitTextTextBox.Document.ContentStart, this.ExitTextTextBox.Document.ContentEnd).Text;
                if ((bool)this.IsSingleResponseCheckBox.IsChecked)
                {
                    this.SurveyInfoList[this.selectedIndex].SurveyType = 1;
                }
                else
                {
                    this.SurveyInfoList[this.selectedIndex].SurveyType = 2;
                }

                this.SurveyInfoList[this.selectedIndex].OrganizationName = this.OrganizationTextBox.Text;
                this.SurveyInfoList[this.selectedIndex].SurveyName       = this.SurveyNameTextBox.Text;
                this.SurveyInfoList[this.selectedIndex].SurveyNumber     = this.SurveyNumberTextBox.Text;

                if (this.IsTestMode.IsChecked == true)
                {
                    this.SurveyInfoList[this.selectedIndex].IsDraftMode = true;
                }
                else
                {
                    this.SurveyInfoList[this.selectedIndex].IsDraftMode = false;
                }
                this.SurveyInfoList[this.selectedIndex].XML = new TextRange(this.TemplateXMLTextBox.Document.ContentStart, this.TemplateXMLTextBox.Document.ContentEnd).Text;
                if (!string.IsNullOrEmpty(this.OrgTextBox1.Text))
                {
                    this.SurveyInfoList[this.selectedIndex].OrganizationKey = new Guid(OrgTextBox1.Text);
                }
                else
                {
                }
                if (!string.IsNullOrEmpty(this.TextBoxPublish.Text))
                {
                    this.SurveyInfoList[this.selectedIndex].UserPublishKey = new Guid(this.TextBoxPublish.Text);
                }
                else
                {
                }
                Request.SurveyInfoList.Add(this.SurveyInfoList[this.selectedIndex]);

                try
                {
                    int ServiceVersion = ServiceClient.GetServiceVersion();

                    if (ServiceVersion == 1)
                    {
                        SurveyManagerService.ManagerServiceClient client = ServiceClient.GetClient();
                        Epi.Web.Common.Message.SurveyInfoResponse Result = client.SetSurveyInfo(Request);

                        SurveyInfoResponseTextBox.AppendText(Result.Message);
                    }

                    else if (ServiceVersion == 2)
                    {
                        SurveyManagerServiceV2.ManagerServiceV2Client client = ServiceClient.GetClientV2();
                        Epi.Web.Common.Message.SurveyInfoResponse     Result = client.SetSurveyInfo(Request);

                        SurveyInfoResponseTextBox.AppendText(Result.Message);
                    }

                    else if (ServiceVersion == 3)
                    {
                        SurveyManagerServiceV3.ManagerServiceV3Client client = ServiceClient.GetClientV3();
                        Epi.Web.Common.Message.SurveyInfoResponse     Result = client.SetSurveyInfo(Request);

                        SurveyInfoResponseTextBox.AppendText(Result.Message);
                    }
                }
                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());
                }
            }
        }