Beispiel #1
0
        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
            {
                EWEManagerService.EWEManagerServiceClient        Client  = ServiceClient.GetClient(pEndPointAddress, pIsAuthenticated, pIsWsHTTPBinding);
                Epi.Web.Enter.Common.Message.OrganizationRequest Request = new Epi.Web.Enter.Common.Message.OrganizationRequest();
                var Result = Client.GetOrganization(Request);
                this.PingResultTextBox.Text = "Successfully Created Service Client";
            }
            catch (Exception ex)
            {
                this.PingResultTextBox.Text = "Failed to create Service Client:\n\n" + ex.Message;
            }
        }
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                EWEManagerService.EWEManagerServiceClient           Client  = ServiceClient.GetClient();
                Epi.Web.Enter.Common.Message.PreFilledAnswerRequest Request = new Epi.Web.Enter.Common.Message.PreFilledAnswerRequest();
                Guid OrganizationGuid = new Guid(passwordBox1.Password);
                Guid SurveyGuid       = new Guid(SurveyId.Text);
                Guid ParentId;
                if (!string.IsNullOrEmpty(this.ParentId.Text))
                {
                    ParentId = new Guid(this.ParentId.Text);
                }
                else
                {
                    ParentId = Guid.Empty;
                }
                Guid ResponseId = new Guid(this.ResponseId.Text);
                Dictionary <string, string> Values = new Dictionary <string, string>();

                foreach (var item in listView1.Items)
                {
                    Values.Add(((System.Data.DataRowView)(item)).Row[0].ToString(), ((System.Data.DataRowView)(item)).Row[1].ToString());
                }
                Request.AnswerInfo.UserId          = 2;
                Request.AnswerInfo.OrganizationKey = OrganizationGuid;
                Request.AnswerInfo.SurveyId        = SurveyGuid;
                Request.AnswerInfo.ParentRecordId  = ParentId;
                Request.AnswerInfo.ResponseId      = ResponseId;
                // Request.AnswerInfo
                Request.AnswerInfo.SurveyQuestionAnswerList = Values;
                var Result = Client.SetSurveyAnswer(Request);



                if (Result.Status == "Success")
                {
                    this.Result.AppendText("\nResponse Id: " + Result.SurveyResponseID);
                    this.Result.AppendText("\nResponse URL: " + Result.SurveyResponseUrl);
                    this.Result.AppendText("\nPass Code: " + Result.SurveyResponsePassCode);
                }
                else
                {
                    if (Result.ErrorMessageList.Count() > 0)
                    {
                        foreach (var item in Result.ErrorMessageList)
                        {
                            this.Result.AppendText("\n" + item.Key + " : " + item.Value);
                        }
                    }
                }
            }
            catch (Exception ex)

            {
                this.Result.AppendText("An Error occurred  while trying to insert a response");
            }
        }
        private void GetKey_Clik(object sender, RoutedEventArgs e)
        {
            EWEManagerService.EWEManagerServiceClient        client  = ServiceClient.GetClient();
            Epi.Web.Enter.Common.Message.OrganizationRequest Request = new Epi.Web.Enter.Common.Message.OrganizationRequest();

            this.ONameEditTextBox1.Clear();
            this.checkBox1.IsChecked = false;
            richTextBox1.Document.Blocks.Clear();
            try
            {
                if (!string.IsNullOrEmpty(passwordBox1.Password.ToString()) && IsGuid(passwordBox1.Password.ToString()))
                {
                    if (OnamelistBox1.Items.Count > 0)
                    {
                        if (!string.IsNullOrEmpty(OnamelistBox1.SelectedItem.ToString()))
                        {
                            Request.Organization.Organization = this.OnamelistBox1.SelectedItem.ToString();
                            Request.AdminSecurityKey          = new Guid(passwordBox1.Password);
                            Epi.Web.Enter.Common.Message.OrganizationResponse Result = client.GetOrganization(Request);
                            EditOtextBox1.Clear();
                            ONameEditTextBox1.Clear();
                            if (Result.Message != null)
                            {
                                richTextBox1.AppendText(Result.Message.ToString());
                            }

                            if (Result.OrganizationList != null)
                            {
                                for (int i = 0; i < Result.OrganizationList.Count; i++)
                                {
                                    // EditOtextBox1.Text = Cryptography.Decrypt(Result.OrganizationList[i].OrganizationKey.ToString());
                                    EditOtextBox1.Text          = Result.OrganizationList[i].OrganizationKey.ToString();
                                    this.ONameEditTextBox1.Text = Result.OrganizationList[i].Organization;
                                    this.checkBox1.IsChecked    = Result.OrganizationList[i].IsEnabled;
                                }
                            }
                        }
                        else
                        {
                            richTextBox1.AppendText("Please selet a organization name.");
                        }
                    }
                    else
                    {
                        richTextBox1.AppendText("Please selet a organization name.");
                    }
                }
                else
                {
                    richTextBox1.AppendText("Admin pass  is required and Should be a Guid.");
                }
            }
            catch (Exception ex)
            {
                richTextBox1.AppendText("Error occurred while trying to get new organization keys.  ");
            }
        }
        private void AddOrganization_Click(object sender, RoutedEventArgs e)
        {
            MessagerichTextBox1.Document.Blocks.Clear();
            EWEManagerService.EWEManagerServiceClient        client  = ServiceClient.GetClient();
            Epi.Web.Enter.Common.Message.OrganizationRequest Request = new Epi.Web.Enter.Common.Message.OrganizationRequest();
            MessagerichTextBox1.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.Enter.Common.Message.OrganizationResponse Result = client.SetOrganization(Request);
                            MessagerichTextBox1.Document.Blocks.Clear();
                            OrganizationtextBox1.Clear();
                            GeneratedkeytextBox1.Clear();
                            if (Result.Message.ToString().Contains("Successfully"))
                            {
                                MessagerichTextBox1.Foreground = Brushes.Green;
                            }
                            MessagerichTextBox1.AppendText(Result.Message.ToString());
                        }
                        else
                        {
                            MessagerichTextBox1.AppendText("Please generate organization key.");
                        }
                    }
                    else
                    {
                        MessagerichTextBox1.AppendText("Organization Name is required.");
                    }
                }
                else
                {
                    MessagerichTextBox1.AppendText("Admin pass  is required and Should be a Guid.");
                }
            }
            catch (Exception ex)
            {
                MessagerichTextBox1.AppendText("Error occurred while trying to add new organization key. Please  try again. ");
            }
        }
        //Save_Click
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            MessagerichTextBox1.Document.Blocks.Clear();
            EWEManagerService.EWEManagerServiceClient        client  = ServiceClient.GetClient();
            Epi.Web.Enter.Common.Message.OrganizationRequest Request = new Epi.Web.Enter.Common.Message.OrganizationRequest();
            richTextBox1.Foreground = Brushes.Red;
            richTextBox1.Document.Blocks.Clear();


            try
            {
                if (!string.IsNullOrEmpty(passwordBox1.Password.ToString()) && IsGuid(passwordBox1.Password.ToString()))
                {
                    if (checkBox1.IsChecked == true)
                    {
                        Request.Organization.IsEnabled = true;
                    }
                    else
                    {
                        Request.Organization.IsEnabled = false;
                    }
                    Request.AdminSecurityKey          = new Guid(passwordBox1.Password);
                    Request.Organization.Organization = ONameEditTextBox1.Text;
                    //Request.Organization.OrganizationKey = Cryptography.Encrypt(EditOtextBox1.Text);
                    Request.Organization.OrganizationKey = EditOtextBox1.Text.ToString();
                    Epi.Web.Enter.Common.Message.OrganizationResponse Result = client.UpdateOrganizationInfo(Request);


                    if (Result.Message.ToString().Contains("Successfully"))
                    {
                        richTextBox1.Foreground = Brushes.Green;
                        GetOrganizationNames();
                        this.OnamelistBox1.SelectedItem = Request.Organization.Organization;
                    }
                    richTextBox1.AppendText(Result.Message.ToString());
                }
                else
                {
                    richTextBox1.AppendText("Admin pass  is required and Should be a Guid.");
                }
            }
            catch (Exception ex)
            {
                richTextBox1.AppendText("Error occurred while updating organization info. Please  try again. ");
            }
        }
        public void GetOrganizationNames()
        {
            EWEManagerService.EWEManagerServiceClient        client  = ServiceClient.GetClient();
            Epi.Web.Enter.Common.Message.OrganizationRequest Request = new Epi.Web.Enter.Common.Message.OrganizationRequest();

            richTextBox1.Document.Blocks.Clear();

            try
            {
                if (!string.IsNullOrEmpty(passwordBox1.Password.ToString()) && IsGuid(passwordBox1.Password.ToString()))
                {
                    Request.AdminSecurityKey = new Guid(passwordBox1.Password);
                    // Epi.Web.Enter.Common.Message.OrganizationResponse Result = client.GetOrganizationInfo(Request);
                    Epi.Web.Enter.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
                {
                    richTextBox1.AppendText("Admin pass  is required and Should be a Guid.");
                }
            }
            catch (Exception ex)
            {
                richTextBox1.AppendText("Error occurred while trying to get all organization names. ");
            }
        }
        private void Edit_Clik(object sender, RoutedEventArgs e)
        {
            //if (!string.IsNullOrEmpty(EditOtextBox1.Text))
            //{
            EWEManagerService.EWEManagerServiceClient        client  = ServiceClient.GetClient();
            Epi.Web.Enter.Common.Message.OrganizationRequest Request = new Epi.Web.Enter.Common.Message.OrganizationRequest();

            richTextBox1.Document.Blocks.Clear();
            try
            {
                if (!string.IsNullOrEmpty(passwordBox1.Password.ToString()) && IsGuid(passwordBox1.Password.ToString()))
                {
                    Request.AdminSecurityKey             = new Guid(passwordBox1.Password);
                    Request.Organization.OrganizationKey = EditOtextBox1.Text;
                    Epi.Web.Enter.Common.Message.OrganizationResponse Result = client.GetOrganizationByKey(Request);
                    if (Result.OrganizationList != null)
                    {
                        for (int i = 0; i < Result.OrganizationList.Count; i++)
                        {
                            this.ONameEditTextBox1.Text = Result.OrganizationList[i].Organization;
                            this.checkBox1.IsChecked    = Result.OrganizationList[i].IsEnabled;
                        }
                    }
                }
                else
                {
                    richTextBox1.AppendText("Admin pass  is required and Should be a Guid.");
                }
            }
            catch (Exception ex)
            {
                richTextBox1.AppendText("Error occurred while trying to get organization Info. ");
            }
            //}
            //else {
            //    richTextBox1.AppendText("Please select organization key.");

            //}
        }
        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());
            }
        }
        private void UpdateSurveyButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.selectedIndex > -1)
            {
                SurveyInfoResponseTextBox.Document.Blocks.Clear();

                EWEManagerService.EWEManagerServiceClient client = ServiceClient.GetClient();

                Epi.Web.Enter.Common.Message.SurveyInfoRequest Request = new Epi.Web.Enter.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
                {
                    Epi.Web.Enter.Common.Message.SurveyInfoResponse Result = client.SetSurveyInfo(Request);


                    // SurveyInfoResponseTextBox.AppendText("Succefully updated survey:");
                    SurveyInfoResponseTextBox.AppendText(Result.Message);

                    //SurveyInfoResponseTextBox.AppendText(Result.PublishInfo.IsPulished.ToString());
                    //SurveyInfoResponseTextBox.AppendText("\nURL: ");
                    //SurveyInfoResponseTextBox.AppendText(Result.PublishInfo.URL);
                    //SurveyInfoResponseTextBox.AppendText("\nStatus Text: ");
                    //SurveyInfoResponseTextBox.AppendText(Result.PublishInfo.StatusText);
                }
                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());
                }
            }
        }
        public static EWEManagerService.EWEManagerServiceClient GetClient(string pEndPointAddress, bool pIsAuthenticated, bool pIsWsHttpBinding = true)
        {
            EWEManagerService.EWEManagerServiceClient result = null;
            try
            {
                if (pIsAuthenticated) // Windows Authentication
                {
                    System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
                    binding.Name                   = "BasicHttpBinding";
                    binding.CloseTimeout           = new TimeSpan(0, 1, 0);
                    binding.OpenTimeout            = new TimeSpan(0, 1, 0);
                    binding.ReceiveTimeout         = new TimeSpan(0, 10, 0);
                    binding.SendTimeout            = new TimeSpan(0, 1, 0);
                    binding.AllowCookies           = false;
                    binding.BypassProxyOnLocal     = false;
                    binding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard;
                    binding.MaxBufferPoolSize      = long.Parse(ConfigurationManager.AppSettings["MaxBufferPoolSize"]);//524288;
                    binding.MaxReceivedMessageSize = long.Parse(ConfigurationManager.AppSettings["MaxReceivedMessageSize"]);
                    binding.MessageEncoding        = System.ServiceModel.WSMessageEncoding.Text;
                    binding.TextEncoding           = System.Text.Encoding.UTF8;
                    binding.TransferMode           = System.ServiceModel.TransferMode.Buffered;
                    binding.UseDefaultWebProxy     = true;
                    binding.ReaderQuotas.MaxDepth  = int.Parse(ConfigurationManager.AppSettings["MaxDepth"]);                            //32;
                    binding.ReaderQuotas.MaxStringContentLength = int.Parse(ConfigurationManager.AppSettings["MaxStringContentLength"]); //8192;
                    binding.ReaderQuotas.MaxArrayLength         = int.Parse(ConfigurationManager.AppSettings["MaxArrayLength"]);         //16384;
                    binding.ReaderQuotas.MaxBytesPerRead        = int.Parse(ConfigurationManager.AppSettings["MaxBytesPerRead"]);        //4096;
                    binding.ReaderQuotas.MaxNameTableCharCount  = int.Parse(ConfigurationManager.AppSettings["MaxNameTableCharCount"]);  //16384;

                    binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly;
                    binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
                    binding.Security.Transport.ProxyCredentialType  = System.ServiceModel.HttpProxyCredentialType.None;
                    binding.Security.Transport.Realm = string.Empty;

                    binding.Security.Message.ClientCredentialType = System.ServiceModel.BasicHttpMessageCredentialType.UserName;

                    System.ServiceModel.EndpointAddress endpoint = new System.ServiceModel.EndpointAddress(pEndPointAddress);

                    result = new EWEManagerService.EWEManagerServiceClient(binding, endpoint);
                    result.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                    result.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
                }
                else
                {
                    if (pIsWsHttpBinding)
                    {
                        System.ServiceModel.WSHttpBinding binding = new System.ServiceModel.WSHttpBinding();
                        binding.Name                   = "WSHttpBinding";
                        binding.CloseTimeout           = new TimeSpan(0, 1, 0);
                        binding.OpenTimeout            = new TimeSpan(0, 1, 0);
                        binding.ReceiveTimeout         = new TimeSpan(0, 10, 0);
                        binding.SendTimeout            = new TimeSpan(0, 1, 0);
                        binding.BypassProxyOnLocal     = false;
                        binding.TransactionFlow        = false;
                        binding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard;
                        binding.MaxBufferPoolSize      = long.Parse(ConfigurationManager.AppSettings["MaxBufferPoolSize"]);//524288;
                        binding.MaxReceivedMessageSize = long.Parse(ConfigurationManager.AppSettings["MaxReceivedMessageSize"]);
                        binding.MessageEncoding        = System.ServiceModel.WSMessageEncoding.Text;
                        binding.TextEncoding           = System.Text.Encoding.UTF8;
                        binding.UseDefaultWebProxy     = true;
                        binding.AllowCookies           = false;

                        binding.ReaderQuotas.MaxDepth = int.Parse(ConfigurationManager.AppSettings["MaxDepth"]);                             //32;
                        binding.ReaderQuotas.MaxStringContentLength = int.Parse(ConfigurationManager.AppSettings["MaxStringContentLength"]); //8192;
                        binding.ReaderQuotas.MaxArrayLength         = int.Parse(ConfigurationManager.AppSettings["MaxArrayLength"]);         //16384;
                        binding.ReaderQuotas.MaxBytesPerRead        = int.Parse(ConfigurationManager.AppSettings["MaxBytesPerRead"]);        //4096;
                        binding.ReaderQuotas.MaxNameTableCharCount  = int.Parse(ConfigurationManager.AppSettings["MaxNameTableCharCount"]);  //16384;

                        binding.ReliableSession.Ordered           = true;
                        binding.ReliableSession.InactivityTimeout = new TimeSpan(0, 10, 0);
                        binding.ReliableSession.Enabled           = false;

                        binding.Security.Mode = System.ServiceModel.SecurityMode.Message;
                        binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
                        binding.Security.Transport.ProxyCredentialType  = System.ServiceModel.HttpProxyCredentialType.None;
                        binding.Security.Transport.Realm = string.Empty;
                        binding.Security.Message.ClientCredentialType       = System.ServiceModel.MessageCredentialType.Windows;
                        binding.Security.Message.NegotiateServiceCredential = true;

                        System.ServiceModel.EndpointAddress endpoint = new System.ServiceModel.EndpointAddress(pEndPointAddress);

                        result = new EWEManagerService.EWEManagerServiceClient(binding, endpoint);
                    }
                    else
                    {
                        System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
                        binding.Name                   = "BasicHttpBinding";
                        binding.CloseTimeout           = new TimeSpan(0, 1, 0);
                        binding.OpenTimeout            = new TimeSpan(0, 1, 0);
                        binding.ReceiveTimeout         = new TimeSpan(0, 10, 0);
                        binding.SendTimeout            = new TimeSpan(0, 1, 0);
                        binding.AllowCookies           = false;
                        binding.BypassProxyOnLocal     = false;
                        binding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard;
                        binding.MaxBufferPoolSize      = long.Parse(ConfigurationManager.AppSettings["MaxBufferPoolSize"]);//524288;
                        binding.MaxReceivedMessageSize = long.Parse(ConfigurationManager.AppSettings["MaxReceivedMessageSize"]);
                        binding.MessageEncoding        = System.ServiceModel.WSMessageEncoding.Text;
                        binding.TextEncoding           = System.Text.Encoding.UTF8;
                        binding.TransferMode           = System.ServiceModel.TransferMode.Buffered;
                        binding.UseDefaultWebProxy     = true;
                        binding.ReaderQuotas.MaxDepth  = int.Parse(ConfigurationManager.AppSettings["MaxDepth"]);                            //32;
                        binding.ReaderQuotas.MaxStringContentLength = int.Parse(ConfigurationManager.AppSettings["MaxStringContentLength"]); //8192;
                        binding.ReaderQuotas.MaxArrayLength         = int.Parse(ConfigurationManager.AppSettings["MaxArrayLength"]);         //16384;
                        binding.ReaderQuotas.MaxBytesPerRead        = int.Parse(ConfigurationManager.AppSettings["MaxBytesPerRead"]);        //4096;
                        binding.ReaderQuotas.MaxNameTableCharCount  = int.Parse(ConfigurationManager.AppSettings["MaxNameTableCharCount"]);  //16384;

                        binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly;
                        binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
                        binding.Security.Transport.ProxyCredentialType  = System.ServiceModel.HttpProxyCredentialType.None;
                        binding.Security.Transport.Realm = string.Empty;

                        System.ServiceModel.EndpointAddress endpoint = new System.ServiceModel.EndpointAddress(pEndPointAddress);

                        result = new EWEManagerService.EWEManagerServiceClient(binding, endpoint);
                    }
                }
            }
            catch (FaultException <CustomFaultException> cfe)
            {
                throw cfe;
            }
            catch (FaultException fe)
            {
                throw fe;
            }
            catch (SecurityNegotiationException sne)
            {
                throw sne;
            }
            catch (CommunicationException ce)
            {
                throw ce;
            }
            catch (TimeoutException te)
            {
                throw te;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Beispiel #11
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());
            }
        }
Beispiel #12
0
        private void DownloadSurveyAnswersButton_Click(object sender, RoutedEventArgs e)
        {
            EWEManagerService.EWEManagerServiceClient client = ServiceClient.GetClient();

            Epi.Web.Enter.Common.Message.SurveyAnswerRequest Request = new Epi.Web.Enter.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.Enter.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.Enter.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.GridPageSize = PageSize;
                            Epi.Web.Enter.Common.Message.SurveyAnswerResponse Result = client.GetSurveyAnswer(Request);
                            SurveyAnswerResponseTextBox.AppendText(string.Format(" -Number of available records: {0}\n\n", Result.SurveyResponseList.Count));
                            foreach (Epi.Web.Enter.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());
            }
        }
Beispiel #13
0
        private void SubmitRequestButton_Click(object sender, RoutedEventArgs e)
        {
            ServiceResponseTextBox.Document.Blocks.Clear();
            this.OpenURLButton.IsEnabled = false;

            EWEManagerService.EWEManagerServiceClient client = ServiceClient.GetClient();

            Epi.Web.Enter.Common.Message.PublishRequest Request = new Epi.Web.Enter.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;
            Request.SurveyInfo.OwnerId         = 2;//HardCode
            try
            {
                Epi.Web.Enter.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());
            }
        }