private void SurveyInfoworker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { try { SurveyManagerServiceV2.ManagerServiceV2Client client = Epi.Core.ServiceClient.ServiceClient.GetClientV2(); Configuration config = Configuration.GetNewInstance(); SurveyManagerServiceV2.SurveyInfoRequest Request = (SurveyManagerServiceV2.SurveyInfoRequest)((object[])e.Argument)[0]; SurveyManagerServiceV2.SurveyInfoResponse Result = (SurveyManagerServiceV2.SurveyInfoResponse)((object[])e.Argument)[1]; Result = client.GetSurveyInfo(Request); if (Result != null && Result.SurveyInfoList.Length > 0) { SurveyName = Result.SurveyInfoList[0].SurveyName; DepartmentName = Result.SurveyInfoList[0].DepartmentName; SurveyNumber = Result.SurveyInfoList[0].SurveyNumber; OrganizationName = Result.SurveyInfoList[0].OrganizationName; StartDate = Result.SurveyInfoList[0].StartDate; CloseDate = Result.SurveyInfoList[0].ClosingDate; IsDraftMode = Result.SurveyInfoList[0].IsDraftMode; IntroductionText = Result.SurveyInfoList[0].IntroductionText; ExitText = Result.SurveyInfoList[0].ExitText; TemplateXML = Result.SurveyInfoList[0].XML; OrganizationKey = Result.SurveyInfoList[0].OrganizationKey.ToString(); SurveyType = Result.SurveyInfoList[0].SurveyType; UserPublishKey = Result.SurveyInfoList[0].UserPublishKey.ToString(); //SurveyId = Result.SurveyInfoList[0].SurveyId; } } catch (FaultException <CustomFaultException> cfe) { // this.BeginInvoke(new FinishWithCustomFaultExceptionDelegate(FinishWithCustomFaultException), cfe); } catch (FaultException fe) { //this.BeginInvoke(new FinishWithFaultExceptionDelegate(FinishWithFaultException), fe); } catch (SecurityNegotiationException sne) { //this.BeginInvoke(new FinishWithSecurityNegotiationExceptionDelegate(FinishWithSecurityNegotiationException), sne); } catch (CommunicationException ce) { //this.BeginInvoke(new FinishWithCommunicationExceptionDelegate(FinishWithCommunicationException), ce); } catch (TimeoutException te) { // this.BeginInvoke(new FinishWithTimeoutExceptionDelegate(FinishWithTimeoutException), te); } catch (Exception ex) { //this.BeginInvoke(new FinishWithExceptionDelegate(FinishWithException), ex); } }
private bool ValidateSittings() { bool IsValid = true; try { SurveyManagerServiceV2.ManagerServiceV2Client client = Epi.Core.ServiceClient.ServiceClient.GetClientV2(); SurveyManagerServiceV2.OrganizationRequest Request = new SurveyManagerServiceV2.OrganizationRequest(); SurveyManagerServiceV2.OrganizationDTO orgDTO = new SurveyManagerServiceV2.OrganizationDTO(); Request.Organization = orgDTO; var Result = client.GetOrganization(Request); } catch (Exception ex) { IsValid = false; } return(IsValid); }
public static SurveyManagerServiceV2.ManagerServiceV2Client GetClientV2(string pEndPointAddress, bool pIsAuthenticated, bool pIsWsHttpBinding = true) { Configuration config = Configuration.GetNewInstance(); SurveyManagerServiceV2.ManagerServiceV2Client result = null; try { if (pIsAuthenticated) // Windows Authentication { System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding(); binding.Name = "BasicHttpBinding"; binding.CloseTimeout = new TimeSpan(0, 10, 0); binding.OpenTimeout = new TimeSpan(0, 10, 0); binding.ReceiveTimeout = new TimeSpan(0, 10, 0); binding.SendTimeout = new TimeSpan(0, 10, 0); binding.AllowCookies = false; binding.BypassProxyOnLocal = false; binding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard; binding.MaxBufferPoolSize = config.Settings.WebServiceMaxBufferPoolSize;//524288; binding.MaxReceivedMessageSize = config.Settings.WebServiceMaxReceivedMessageSize; binding.MessageEncoding = System.ServiceModel.WSMessageEncoding.Text; binding.TextEncoding = System.Text.Encoding.UTF8; binding.TransferMode = System.ServiceModel.TransferMode.Buffered; binding.UseDefaultWebProxy = true; binding.ReaderQuotas.MaxDepth = config.Settings.WebServiceReaderMaxDepth;//32; binding.ReaderQuotas.MaxStringContentLength = config.Settings.WebServiceReaderMaxStringContentLength; binding.ReaderQuotas.MaxArrayLength = config.Settings.WebServiceReaderMaxArrayLength; binding.ReaderQuotas.MaxBytesPerRead = config.Settings.WebServiceReaderMaxBytesPerRead; binding.ReaderQuotas.MaxNameTableCharCount = config.Settings.WebServiceReaderMaxNameTableCharCount; System.ServiceModel.EndpointAddress endpoint = new System.ServiceModel.EndpointAddress(pEndPointAddress); if (endpoint.Uri.Scheme == "http") { 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; } else { binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport; binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.None; } binding.Security.Message.ClientCredentialType = System.ServiceModel.BasicHttpMessageCredentialType.UserName; result = new SurveyManagerServiceV2.ManagerServiceV2Client(binding, endpoint); result.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; result.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => { return(true); }; } else { if (pIsWsHttpBinding) { System.ServiceModel.WSHttpBinding binding = new System.ServiceModel.WSHttpBinding(); binding.Name = "WSHttpBinding"; binding.CloseTimeout = new TimeSpan(0, 10, 0); binding.OpenTimeout = new TimeSpan(0, 10, 0); binding.ReceiveTimeout = new TimeSpan(0, 10, 0); binding.SendTimeout = new TimeSpan(0, 10, 0); binding.BypassProxyOnLocal = false; binding.TransactionFlow = false; binding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard; binding.MaxBufferPoolSize = config.Settings.WebServiceMaxBufferPoolSize;//524288; binding.MaxReceivedMessageSize = config.Settings.WebServiceMaxReceivedMessageSize; binding.MessageEncoding = System.ServiceModel.WSMessageEncoding.Text; binding.TextEncoding = System.Text.Encoding.UTF8; binding.UseDefaultWebProxy = true; binding.AllowCookies = false; binding.ReaderQuotas.MaxDepth = config.Settings.WebServiceReaderMaxDepth;//32; binding.ReaderQuotas.MaxStringContentLength = config.Settings.WebServiceReaderMaxStringContentLength; binding.ReaderQuotas.MaxArrayLength = config.Settings.WebServiceReaderMaxArrayLength; binding.ReaderQuotas.MaxBytesPerRead = config.Settings.WebServiceReaderMaxBytesPerRead; binding.ReaderQuotas.MaxNameTableCharCount = config.Settings.WebServiceReaderMaxNameTableCharCount; 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 SurveyManagerServiceV2.ManagerServiceV2Client(binding, endpoint); } else { System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding(); binding.Name = "BasicHttpBinding"; binding.CloseTimeout = new TimeSpan(0, 10, 0); binding.OpenTimeout = new TimeSpan(0, 10, 0); binding.ReceiveTimeout = new TimeSpan(0, 10, 0); binding.SendTimeout = new TimeSpan(0, 10, 0); binding.AllowCookies = false; binding.BypassProxyOnLocal = false; binding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard; binding.MaxBufferPoolSize = config.Settings.WebServiceMaxBufferPoolSize;//524288; binding.MaxReceivedMessageSize = config.Settings.WebServiceMaxReceivedMessageSize; binding.MessageEncoding = System.ServiceModel.WSMessageEncoding.Text; binding.TextEncoding = System.Text.Encoding.UTF8; binding.TransferMode = System.ServiceModel.TransferMode.Buffered; binding.UseDefaultWebProxy = true; binding.ReaderQuotas.MaxDepth = config.Settings.WebServiceReaderMaxDepth;//32; binding.ReaderQuotas.MaxStringContentLength = config.Settings.WebServiceReaderMaxStringContentLength; binding.ReaderQuotas.MaxArrayLength = config.Settings.WebServiceReaderMaxArrayLength; binding.ReaderQuotas.MaxBytesPerRead = config.Settings.WebServiceReaderMaxBytesPerRead; binding.ReaderQuotas.MaxNameTableCharCount = config.Settings.WebServiceReaderMaxNameTableCharCount; System.ServiceModel.EndpointAddress endpoint = new System.ServiceModel.EndpointAddress(pEndPointAddress); if (endpoint.Uri.Scheme == "http") { 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; } else { binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport; binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.None; } result = new SurveyManagerServiceV2.ManagerServiceV2Client(binding, endpoint); System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => { return(true); }; } } } 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); }