public static PrimeSuiteServiceClient GetServiceClient(string iP)
        {
            try
            {

                string sIP = iP;
                string sServiceUrl = "http://" + sIP + "/PrimeSuiteAPI/APIv1.0/PrimeSuiteAPI.svc";
                System.ServiceModel.EndpointAddress oEndpointAddress = new System.ServiceModel.EndpointAddress(sServiceUrl);
                System.ServiceModel.BasicHttpBinding oBasicBinding = new System.ServiceModel.BasicHttpBinding();

                oBasicBinding.ReaderQuotas.MaxStringContentLength = 2147483647;
                //"5242880" = 5MB
                oBasicBinding.ReaderQuotas.MaxDepth = 2147483647;
                oBasicBinding.ReaderQuotas.MaxArrayLength = 2147483647;
                oBasicBinding.ReaderQuotas.MaxBytesPerRead = 2147483647;
                oBasicBinding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
                oBasicBinding.MaxBufferSize = 2147483647;
                oBasicBinding.MaxReceivedMessageSize = 2147483647;

                PrimeSuiteServiceClient client = new PrimeSuiteServiceClient(oBasicBinding, oEndpointAddress);
                ModifyDataContractSerializerBehavior(client.Endpoint);
                return (client);
            }
            catch (Exception ex)
            {
                //Throw New Exception("Error in " & sMethodFullName & ":" & vbNewLine & ex.Message & vbNewLine)
                throw ex;
            }
        }
 public ConsultarPerfil()
 {
     InitializeComponent();
     bind = new System.ServiceModel.BasicHttpBinding();
     endpoint = new System.ServiceModel.EndpointAddress(m_EndPoint);
     Wrapper = new ServiceReference.WSCosecolSoapClient(bind, endpoint);
 }
Esempio n. 3
0
        internal double DownloadShare(int index)
        {
            Share share = model.GetRemoteShares(index);

            string hash = share.Hash;
            string[] addresses = client.RequestDownload(hash);

            System.ServiceModel.BasicHttpBinding binding =
                new System.ServiceModel.BasicHttpBinding("BasicHttpBinding_Client");

            ClientImplementationClient cic =
                new ClientImplementationClient(binding,
                    new System.ServiceModel.EndpointAddress(Config.ClientBaseAddress(addresses[0])));

            DateTime time = DateTime.Now;

            using (var input = cic.Download(hash))
            {
                using (var file = System.IO.File.Create(share.Name))
                {
                    byte[] bytes = ReadFully(input);
                    file.Write(bytes, 0, bytes.Length);
                }
            }

            int diff = (DateTime.Now - time).Seconds;
            if (diff == 0)
            {
                diff = 1;
            }

            return share.Size / diff / 1024.0;
        }
        public Biopsia()
        {
            InitializeComponent();
            bind = new System.ServiceModel.BasicHttpBinding();
            endpoint = new System.ServiceModel.EndpointAddress(m_EndPoint);
            Wrapper = new ServiceReferenceClinica.WSClinicaSoapClient(bind, endpoint);

            imgURI = new Uri(sURL, UriKind.Relative);

            //FORMATO DE FECHA QUE DEVUELTE:
            //Ej. Friday, December 17, 2010
            fechaInformeArray = fechaInforme.ToLongDateString().Split();
            fechaInformeIngresado = getFechaEnFormatoMysql(fechaInforme.Date.ToShortDateString());

            //Al traducirla, sale el arreglo asi: Viernes Diciembre 17 2010
            traducirFecha(fechaInformeArray);
            //Dia actual en string junto y asignacion del año para el ID de las muestras
            fechaInformeString = fechaInformeArray[0] + " " + fechaInformeArray[1] + " " + fechaInformeArray[2] + ", " + fechaInformeArray[3];
            anioActual = "-" + fechaInformeArray[3].Substring(2);

            enableMainButtons(false);
            enableMatButtons(false);

            mainFlag = true;
            Wrapper.getMedicos_NombresCompleted += new EventHandler<ServiceReferenceClinica.getMedicos_NombresCompletedEventArgs>(getMedicosNombres);
            Wrapper.getMedicos_NombresAsync();
        }
Esempio n. 5
0
        internal void Connect(string addressString)
        {
            System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding("BasicHttpBinding_Server");
            System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(Config.ServerBaseAddress(addressString));
            client = new ServerClient(binding, address);

            LoadRemoteShares();
        }
Esempio n. 6
0
        public void Connect(string host)
        {
            var binding = new System.ServiceModel.BasicHttpBinding();
            var address = new System.ServiceModel.EndpointAddress("http://" + host + ":49153/upnp/control/basicevent1");
            var client = new BasicServicePortTypeClient(binding, address);
            var device = new WeMoDevice(this, client, (_devices.Count + 1).ToString());

            _devices.Add(device);
        }
        public IngresarAfiliado()
        {
            InitializeComponent();
            bind = new System.ServiceModel.BasicHttpBinding();
            endpoint = new System.ServiceModel.EndpointAddress(m_EndPoint);
            Wrapper = new ServiceReference.WSCosecolSoapClient(bind, endpoint);

            fechaRegistro_txt.Content = fecha;
        }
        public ControlDeUsuarios()
        {
            InitializeComponent();
            bind = new System.ServiceModel.BasicHttpBinding();
            endpoint = new System.ServiceModel.EndpointAddress(m_EndPoint);
            Wrapper = new ServiceReferenceClinica.WSClinicaSoapClient(bind, endpoint);

            enableButtons(false);
            estado.Text = "Obteniendo Datos...";
            mainFlag = true;
            Wrapper.getUsuariosCompleted += new EventHandler<ServiceReferenceClinica.getUsuariosCompletedEventArgs>(getUsuarios_Completed);
            Wrapper.getUsuariosAsync();
        }
Esempio n. 9
0
		public static MyDataService.GetDataClient GetService()
		{
			System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
			binding.MaxReceivedMessageSize = 2147483647; // int's max size
			binding.MaxBufferSize = 2147483647; // int's max size
			System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(new Uri(Application.Current.Host.Source, "../GetData.svc"));
			try
			{
				return new MyDataService.GetDataClient(binding, address);
			}
			catch (Exception e)
			{

			}
			return null;
		}
        public Home()
        {
            InitializeComponent();

            bind = new System.ServiceModel.BasicHttpBinding();
            endpoint = new System.ServiceModel.EndpointAddress(m_EndPoint);
            Wrapper = new ServiceReferenceClinica.WSClinicaSoapClient(bind, endpoint);

            for (int i = 0; i < flags.Length; i++)
            {
                flags[i] = false;
            }


            login.Closed += childWindow_Closed;
            if (!App.UserIsAuthenticated)
                login.Show();
        }
Esempio n. 11
0
        public void FaultOnDiffContractAndOps()
        {
            IWebHost host = ServiceHelper.CreateWebHostBuilder <Startup>(_output).Build();

            using (host)
            {
                host.Start();
                System.ServiceModel.BasicHttpBinding httpBinding = ClientHelper.GetBufferedModeBinding();
                var factory = new System.ServiceModel.ChannelFactory <ClientContract.ITestFaultOpContract>(httpBinding,
                                                                                                           new System.ServiceModel.EndpointAddress(new Uri("http://localhost:8080/BasicWcfService/FaultOnDiffContractsAndOpsService.svc")));
                ClientContract.ITestFaultOpContract channel = factory.CreateChannel();

                var factory2 = new System.ServiceModel.ChannelFactory <ClientContract.ITestFaultOpContractTypedClient>(httpBinding,
                                                                                                                       new System.ServiceModel.EndpointAddress(new Uri("http://localhost:8080/BasicWcfService/FaultOnDiffContractsAndOpsService.svc")));
                ClientContract.ITestFaultOpContractTypedClient channel2 = factory2.CreateChannel();

                //test variations count
                int    count        = 9;
                string faultToThrow = "Test fault thrown from a service";

                //Variation_TwoWayMethod
                try
                {
                    string s = channel.TwoWay_Method("");
                }
                catch (Exception e)
                {
                    count--;
                    Assert.NotNull(e);
                    Assert.IsType <System.ServiceModel.FaultException <string> >(e);
                    var ex = (System.ServiceModel.FaultException <string>)e;
                    Assert.Equal(faultToThrow, ex.Detail.ToString());
                }

                //Variation_TwoWayVoidMethod
                try
                {
                    channel.TwoWayVoid_Method("");
                }
                catch (Exception e)
                {
                    count--;
                    Assert.NotNull(e);
                    Assert.IsType <System.ServiceModel.FaultException <string> >(e);
                    var ex = (System.ServiceModel.FaultException <string>)e;
                    Assert.Equal(faultToThrow, ex.Detail.ToString());
                }

                //Variation_TwoWayStreamMethod
                try
                {
                    string testValue   = "This is a string that will be converted to a byte array";
                    Stream inputStream = new MemoryStream();
                    byte[] bytes       = Encoding.UTF8.GetBytes(testValue.ToCharArray());
                    foreach (byte b in bytes)
                    {
                        inputStream.WriteByte(b);
                    }

                    inputStream.Position = 0;

                    Stream       outputStream = channel.TwoWayStream_Method(inputStream);
                    StreamReader sr           = new StreamReader(outputStream, Encoding.UTF8);
                    sr.ReadToEnd();
                }
                catch (Exception e)
                {
                    count--;
                    Assert.NotNull(e);
                    Assert.IsType <System.ServiceModel.FaultException <string> >(e);
                    var ex = (System.ServiceModel.FaultException <string>)e;
                    Assert.Equal(faultToThrow, ex.Detail.ToString());
                }

                //Variation_TwoWayAsyncMethod
                try
                {
                    string response = channel.TwoWayAsync_MethodAsync("").GetAwaiter().GetResult();
                }
                catch (Exception e)
                {
                    count--;
                    Assert.NotNull(e);
                    Assert.IsType <System.ServiceModel.FaultException <string> >(e);
                    var ex = (System.ServiceModel.FaultException <string>)e;
                    Assert.Equal(faultToThrow, ex.Detail.ToString());
                }

                //Variation_MessageContractMethod
                // Send the two way message
                var fmc = new ClientContract.FaultMsgContract
                {
                    ID   = 123,
                    Name = ""
                };
                try
                {
                    ClientContract.FaultMsgContract fmcResult = channel.MessageContract_Method(fmc);
                }
                catch (Exception e)
                {
                    count--;
                    Assert.NotNull(e);
                    Assert.IsType <System.ServiceModel.FaultException <string> >(e);
                    var ex = (System.ServiceModel.FaultException <string>)e;
                    Assert.Equal(faultToThrow, ex.Detail.ToString());
                }

                //Variation_UntypedMethod
                System.ServiceModel.Channels.MessageVersion mv     = System.ServiceModel.Channels.MessageVersion.Soap11;
                System.ServiceModel.Channels.Message        msgOut = System.ServiceModel.Channels.Message.CreateMessage(mv, "http://tempuri.org/ITestFaultOpContract/Untyped_Method");
                System.ServiceModel.Channels.Message        msgIn  = channel.Untyped_Method(msgOut);
                if (msgIn.IsFault)
                {
                    count--;
                    System.ServiceModel.Channels.MessageFault mf = System.ServiceModel.Channels.MessageFault.CreateFault(msgIn, int.MaxValue);
                    Assert.Equal(faultToThrow, mf.GetDetail <string>());
                }

                //Variation_UntypedMethodReturns
                msgOut = System.ServiceModel.Channels.Message.CreateMessage(mv, "http://tempuri.org/ITestFaultOpContract/Untyped_MethodReturns");
                msgIn  = channel.Untyped_MethodReturns(msgOut);
                if (msgIn.IsFault)
                {
                    count--;
                    System.ServiceModel.Channels.MessageFault mf = System.ServiceModel.Channels.MessageFault.CreateFault(msgIn, int.MaxValue);
                    Assert.Equal(faultToThrow, mf.GetDetail <string>());
                }

                //Variation_TypedToUntypedMethod
                try
                {
                    channel2.Untyped_Method("");
                }
                catch (Exception e)
                {
                    count--;
                    Assert.NotNull(e);
                    Assert.IsType <System.ServiceModel.FaultException <string> >(e);
                    var ex = (System.ServiceModel.FaultException <string>)e;
                    Assert.Equal(faultToThrow, ex.Detail.ToString());
                }

                //Variation_TypedToUntypedMethodReturns
                try
                {
                    channel2.Untyped_MethodReturns("");
                }
                catch (Exception e)
                {
                    count--;
                    Assert.NotNull(e);
                    Assert.IsType <System.ServiceModel.FaultException <string> >(e);
                    var ex = (System.ServiceModel.FaultException <string>)e;
                    Assert.Equal(faultToThrow, ex.Detail.ToString());
                }

                Assert.Equal(0, count);
            }
        }
Esempio n. 12
0
        internal static FundingPilotSystem.Services.FPConfigurationService.IFPConfigurationService GetFPConfigurationServiceClient()
        {
            if (_fPConfigurationServiceClient == null)
            {
                System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(FPConfigurationServiceUrl);
                System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.None);
                binding.MaxReceivedMessageSize = Int32.MaxValue;

                binding.CloseTimeout = new TimeSpan(0, 30, 0);
                binding.OpenTimeout = new TimeSpan(0, 30, 0);
                binding.ReceiveTimeout = new TimeSpan(0, 30, 0);
                binding.SendTimeout = new TimeSpan(0, 30, 0);

                _fPConfigurationServiceClient = new FundingPilotSystem.Services.FPConfigurationService.FPConfigurationServiceClient(binding, address);
            }
            return _fPConfigurationServiceClient;
        }
        /// <summary>
        /// Construct method
        /// </summary>
        private void Construct()
        {
            try
            {
                this.config = Configuration.GetNewInstance();

                //this.importWorker = new BackgroundWorker();
                //this.importWorker.WorkerSupportsCancellation = true;

                //this.requestWorker = new BackgroundWorker();
                //this.requestWorker.WorkerSupportsCancellation = true;

                if (config.Settings.WebServiceAuthMode == 1) // 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      = config.Settings.WebServiceMaxBufferPoolSize;
                    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;
                    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.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(config.Settings.WebServiceEndpointAddress);

                    client = new SurveyManagerService.ManagerServiceClient(binding, endpoint);

                    client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                    client.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
                }
                else
                {
                    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      = config.Settings.WebServiceMaxBufferPoolSize;
                    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;
                    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(config.Settings.WebServiceEndpointAddress);

                    client = new SurveyManagerService.ManagerServiceClient(binding, endpoint);
                }
                this.wfList = new List <WebFieldData>();
            }
            catch (Exception ex)
            {
                //SetStatusMessage("Error: Web service information was not found.");
            }
        }
        public static ReportExportResult ExportReportToFormat(ReportViewerModel model, string format, int?startPage = 0, int?endPage = 0)
        {
            var definedReportParameters = GetReportParameters(model, true);

            var url = model.ServerUrl + ((model.ServerUrl.ToSafeString().EndsWith("/")) ? "" : "/") + "ReportExecution2005.asmx";

            var basicHttpBinding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly);

            basicHttpBinding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
            basicHttpBinding.MaxReceivedMessageSize = int.MaxValue;
            var service = new ReportServiceExecution.ReportExecutionServiceSoapClient(basicHttpBinding, new System.ServiceModel.EndpointAddress(url));

            service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            service.ClientCredentials.Windows.ClientCredential          = (System.Net.NetworkCredential)(model.Credentials ?? System.Net.CredentialCache.DefaultCredentials);

            var exportResult = new ReportExportResult();

            exportResult.CurrentPage = (startPage.ToInt32() <= 0 ? 1 : startPage.ToInt32());
            exportResult.SetParameters(definedReportParameters, model.Parameters);

            if (startPage == 0)
            {
                startPage = 1;
            }

            if (endPage == 0)
            {
                endPage = startPage;
            }

            var outputFormat = $"<OutputFormat>{format}</OutputFormat>";
            var htmlFragment = ((format.ToUpper() == "HTML4.0" && model.UseCustomReportImagePath == false && model.ViewMode == ReportViewModes.View) ? "<HTMLFragment>true</HTMLFragment>" : "");
            var deviceInfo   = $"<DeviceInfo>{outputFormat}<Toolbar>False</Toolbar>{htmlFragment}</DeviceInfo>";

            if (model.ViewMode == ReportViewModes.View && startPage.HasValue && startPage > 0)
            {
                deviceInfo = $"<DeviceInfo>{outputFormat}<Toolbar>False</Toolbar>{htmlFragment}<Section>{startPage}</Section></DeviceInfo>";
            }

            var reportParameters = new List <ReportServiceExecution.ParameterValue>();

            foreach (var parameter in exportResult.Parameters)
            {
                bool addedParameter = false;
                foreach (var value in parameter.SelectedValues)
                {
                    var reportParameter = new ReportServiceExecution.ParameterValue();
                    reportParameter.Name  = parameter.Name;
                    reportParameter.Value = value;
                    reportParameters.Add(reportParameter);

                    addedParameter = true;
                }

                if (!addedParameter)
                {
                    var reportParameter = new ReportServiceExecution.ParameterValue();
                    reportParameter.Name = parameter.Name;
                    reportParameters.Add(reportParameter);
                }
            }

            var executionHeader = new ReportServiceExecution.ExecutionHeader();

            ReportServiceExecution.ExecutionInfo executionInfo = null;
            string extension = null;
            string encoding  = null;
            string mimeType  = null;

            string[] streamIDs = null;
            ReportServiceExecution.Warning[] warnings = null;

            try
            {
                string historyID = null;
                executionInfo = service.LoadReportAsync(model.ReportPath, historyID).Result;
                executionHeader.ExecutionID = executionInfo.ExecutionID;

                var executionParameterResult = service.SetReportParameters(executionInfo.ExecutionID, reportParameters.ToArray(), "en-us").Result;

                var renderRequest = new ReportServiceExecution.Render2Request(format, deviceInfo, ReportServiceExecution.PageCountMode.Actual);
                var result        = service.Render2(executionInfo.ExecutionID, renderRequest).Result;

                extension = result.Extension;
                mimeType  = result.MimeType;
                encoding  = result.Encoding;
                warnings  = result.Warnings;
                streamIDs = result.StreamIds;

                executionInfo = service.GetExecutionInfo(executionHeader.ExecutionID).Result;

                exportResult.ReportData = result.Result;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            exportResult.ExecutionInfo = executionInfo;
            exportResult.Format        = format;
            exportResult.MimeType      = mimeType;
            exportResult.StreamIDs     = (streamIDs == null ? new List <string>() : streamIDs.ToList());
            exportResult.Warnings      = (warnings == null ? new List <ReportServiceExecution.Warning>() : warnings.ToList());

            if (executionInfo != null)
            {
                exportResult.TotalPages = executionInfo.NumPages;
            }

            return(exportResult);
        }
Esempio n. 15
0
        public void InvokeTaskBaseAsycn()
        {
            IWebHost host = ServiceHelper.CreateWebHostBuilder <Startup>(_output).Build();

            using (host)
            {
                host.Start();
                System.ServiceModel.BasicHttpBinding httpBinding = ClientHelper.GetBufferedModeBinding();
                var factory = new System.ServiceModel.ChannelFactory <ClientContract.ITestPrimitives>(httpBinding,
                                                                                                      new System.ServiceModel.EndpointAddress(new Uri("http://localhost:8080/TaskPrimitives/basichttp.svc")));
                ITestPrimitives channel = factory.CreateChannel();

                Task[] tasks = new Task[22];
                tasks[0]  = channel.GetInt();
                tasks[1]  = channel.GetByte();
                tasks[2]  = channel.GetSByte();
                tasks[3]  = channel.GetShort();
                tasks[4]  = channel.GetUShort();
                tasks[5]  = channel.GetDouble();
                tasks[6]  = channel.GetUInt();
                tasks[7]  = channel.GetLong();
                tasks[8]  = channel.GetULong();
                tasks[9]  = channel.GetChar();
                tasks[10] = channel.GetBool();
                tasks[11] = channel.GetFloat();
                tasks[12] = channel.GetDecimal();
                tasks[13] = channel.GetString();
                tasks[14] = channel.GetDateTime();
                tasks[15] = channel.GetintArr2D();
                tasks[16] = channel.GetfloatArr();
                tasks[17] = channel.GetbyteArr();
                tasks[18] = channel.GetnullableInt();
                tasks[19] = channel.GetTimeSpan();
                tasks[20] = channel.GetGuid();
                tasks[21] = channel.GetEnum();
                Task.WaitAll(tasks);

                Assert.Equal(12600, ((Task <int>)tasks[0]).Result);
                Assert.Equal(124, ((Task <byte>)tasks[1]).Result);
                Assert.Equal(-124, ((Task <sbyte>)tasks[2]).Result);
                Assert.Equal(567, ((Task <short>)tasks[3]).Result);
                Assert.Equal(112, ((Task <ushort>)tasks[4]).Result);
                Assert.Equal(588.1200, ((Task <double>)tasks[5]).Result);
                Assert.Equal(12566, (double)((Task <uint>)tasks[6]).Result);
                Assert.Equal(12566, ((Task <long>)tasks[7]).Result);
                Assert.Equal(12566, (double)((Task <ulong>)tasks[8]).Result);
                Assert.Equal('r', ((Task <char>)tasks[9]).Result);
                Assert.True(((Task <bool>)tasks[10]).Result);
                Assert.Equal(12566, ((Task <float>)tasks[11]).Result);
                Assert.Equal(12566.4565m, ((Task <decimal>)tasks[12]).Result);
                Assert.Equal("Hello Seattle", ((Task <string>)tasks[13]).Result);
                Assert.Equal(TestDateTime, ((Task <DateTime>)tasks[14]).Result);
                Assert.Equal(2, ((Task <int[][]>)tasks[15]).Result.Length);
                Assert.Equal(20, ((Task <float[]>)tasks[16]).Result.Length);
                Assert.Equal(10, ((Task <byte[]>)tasks[17]).Result.Length);
                Assert.Equal(100, ((Task <int?>)tasks[18]).Result);
                Assert.Equal("00:00:05", ((Task <TimeSpan>)tasks[19]).Result.ToString());
                Assert.Equal("7a1c7e9a-f4ce-4861-852c-c05ec59fad4d", ((Task <Guid>)tasks[20]).Result.ToString());
                Assert.Equal(Color.Blue, ((Task <Color>)tasks[21]).Result);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Retuns the newly constructed and configured WCF bindig derived class instance of the specified type.
        /// </summary>
        /// <remarks>
        /// This function might get more important if other WCF bingis are supported.
        /// All settings to a specific binding shuld be made here.
        /// All binding are probably not needed.
        /// </remarks>
        /// <param name="endPoint">EndPoint entity containig iformation about, what type of binding to return and how to set it.</param>
        /// <returns>The new configured binding element.</returns>
        public static System.ServiceModel.Channels.Binding GetWCFBinding(EndPoint endPoint)
        {
            if (endPoint.RemotingMechanism == RemotingMechanism.TcpBinary)
                return null;

            System.ServiceModel.Channels.Binding ret = null;

            WCFBinding bindingEnum = endPoint.Binding;

            switch (bindingEnum)
            {
                #region BasicHttpBinding
                case WCFBinding.BasicHttpBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.BasicHttpBinding bhb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                bhb = new System.ServiceModel.BasicHttpBinding();
                                bhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                bhb.MaxReceivedMessageSize = Int32.MaxValue;
                                bhb.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                bhb = new System.ServiceModel.BasicHttpBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = bhb;
                        break;
                    }
                #endregion
                #region MsmqIntegrationBinding
                case WCFBinding.MsmqIntegrationBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding mib = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                mib = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding();
                                mib.Security.Mode = System.ServiceModel.MsmqIntegration.MsmqIntegrationSecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                mib = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = mib;
                        break;
                    }
                #endregion
                #region NetMsmqBinding
                case WCFBinding.NetMsmqBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.NetMsmqBinding nmb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                nmb = new System.ServiceModel.NetMsmqBinding();
                                nmb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                nmb.Security.Mode = System.ServiceModel.NetMsmqSecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                nmb = new System.ServiceModel.NetMsmqBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = nmb;
                        break;
                    }
                #endregion
                #region NetNamedPipeBinding
                case WCFBinding.NetNamedPipeBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.NetNamedPipeBinding nnpb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                nnpb = new System.ServiceModel.NetNamedPipeBinding();
                                nnpb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                nnpb.Security.Mode = System.ServiceModel.NetNamedPipeSecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                nnpb = new System.ServiceModel.NetNamedPipeBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = nnpb;
                        break;
                    }
                #endregion
                #region NetPeerTcpBinding
                case WCFBinding.NetPeerTcpBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.NetPeerTcpBinding nptb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                nptb = new System.ServiceModel.NetPeerTcpBinding();
                                nptb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                nptb.Security.Mode = System.ServiceModel.SecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                nptb = new System.ServiceModel.NetPeerTcpBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = nptb;
                        break;
                    }
                #endregion
                #region NetTcpBinding
                case WCFBinding.NetTcpBinding:
                    {
                        System.ServiceModel.NetTcpBinding ntb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                ntb = new System.ServiceModel.NetTcpBinding();
                                ntb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                ntb.MaxReceivedMessageSize = Int32.MaxValue;
                                ntb.Security.Mode = System.ServiceModel.SecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                ntb = new System.ServiceModel.NetTcpBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = ntb;
                        break;
                    }
                #endregion
                #region WSDualHttpBinding
                case WCFBinding.WSDualHttpBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.WSDualHttpBinding wdhb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                wdhb = new System.ServiceModel.WSDualHttpBinding();
                                wdhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                wdhb.Security.Mode = System.ServiceModel.WSDualHttpSecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                wdhb = new System.ServiceModel.WSDualHttpBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = wdhb;
                        break;
                    }
                #endregion
                #region WSFederationHttpBinding
                case WCFBinding.WSFederationHttpBinding:
                    {
                        //WARNING: untested code
                        System.ServiceModel.WSFederationHttpBinding wfhb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                wfhb = new System.ServiceModel.WSFederationHttpBinding();
                                wfhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                wfhb = new System.ServiceModel.WSFederationHttpBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = wfhb;
                        break;
                    }
                #endregion
                #region WSHttpBinding
                case WCFBinding.WSHttpBinding:
                    {
                        System.ServiceModel.WSHttpBinding whb = null;
                        switch (endPoint.BindingSettingType)
                        {
                            case WCFBindingSettingType.Default:
                                whb = new System.ServiceModel.WSHttpBinding();
                                whb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                                whb.MaxReceivedMessageSize = Int32.MaxValue;
                                whb.Security.Mode = System.ServiceModel.SecurityMode.None;
                                break;
                            case WCFBindingSettingType.UseConfigFile:
                                whb = new System.ServiceModel.WSHttpBinding(endPoint.BindingConfigurationName);
                                break;
                        }
                        ret = whb;
                        break;
                    }
                #endregion
            }

            return ret;
        }
Esempio n. 17
0
 private NodeServiceClient CreateConnection(string uri)
 {
     System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
     binding.TransferMode = System.ServiceModel.TransferMode.StreamedResponse;
     binding.MaxReceivedMessageSize = 52428800;
     binding.ReaderQuotas.MaxArrayLength = 5242880;
     return new NodeServiceClient(
         binding, new System.ServiceModel.EndpointAddress(uri));
 }
Esempio n. 18
0
        /// <summary>
        /// Private - SU dung ASPWebservices
        /// </summary>
        /// <param name="updateTime"></param>
        /// <param name="exchangeDetailRow"></param>
        /// <returns></returns>
        private databases.importDS.importPriceDataTable GetPriceFromWeb(DateTime updateTime, databases.baseDS.exchangeDetailRow exchangeDetailRow)
        {
            int idx = 0;

            clientSSI.AjaxWebServiceSoapClient client = null;
            try
            {
                client = new clientSSI.AjaxWebServiceSoapClient();
                //client = new clientSSI.AjaxWebServiceSoapClient(exchangeDetailRow.address);
                //HoSTC_ServiceSoapClient
                client.Endpoint.Address = new System.ServiceModel.EndpointAddress(exchangeDetailRow.address);
                System.ServiceModel.BasicHttpBinding binding = (client.Endpoint.Binding as System.ServiceModel.BasicHttpBinding);

                binding.OpenTimeout  = TimeSpan.FromSeconds(Consts.constWebServiceTimeOutInSecs);
                binding.CloseTimeout = binding.OpenTimeout;
                binding.SendTimeout  = binding.OpenTimeout;

                binding.MaxReceivedMessageSize = Consts.constWebServiceMaxReceivedMessageSize;
                binding.MaxBufferSize          = Consts.constWebServiceMaxReceivedMessageSize;

                binding.ReaderQuotas.MaxStringContentLength = Consts.constWebServiceMaxStringContentLength;
                binding.ReaderQuotas.MaxBytesPerRead        = Consts.constWebServiceMaxBytesPerRead;

                String s = String.Empty;
                switch (exchangeDetailRow.code.ToUpper().Trim())
                {
                case "HOSE_SSI":
                    //s = client.GetDataHoSTC2();
                    break;

                case "HASTC_SSI":
                    //s = client.GetDataHaSTC2();
                    break;

                default: return(null);
                }
                //Parsing
                List <string> tradeList = new List <string>(s.Split('#'));
                databases.importDS.importPriceDataTable importPriceTbl = new databases.importDS.importPriceDataTable();
                CultureInfo dataCulture = application.AppLibs.GetCulture(exchangeDetailRow.culture);
                for (idx = 0; idx < tradeList.Count; idx++)
                {
                    List <string> tradeData = new List <string>(tradeList[idx].Split('|'));
                    if (tradeData[8].Trim() == "" || tradeData[9].Trim() == "")
                    {
                        continue;
                    }
                    databases.importDS.importPriceRow importRow = importPriceTbl.NewimportPriceRow();
                    databases.AppLibs.InitData(importRow);
                    importRow.stockCode     = tradeData[0].ToString();
                    importRow.onDate        = updateTime;
                    importRow.closePrice    = decimal.Parse(tradeData[8], dataCulture);
                    importRow.volume        = decimal.Parse(tradeData[9], dataCulture);
                    importRow.isTotalVolume = false;//day ko phai total volume. Cai nay la volume tung thoi diem
                    importPriceTbl.AddimportPriceRow(importRow);
                }
                return(importPriceTbl);
            }
            catch (Exception er)
            {
                common.SysLog.WriteLog("Error : " + er.Message);
                return(null);
            }
            finally
            {
                if (client != null && client.State == System.ServiceModel.CommunicationState.Opened)
                {
                    client.Close();
                }
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Retuns the newly constructed and configured WCF bindig derived class instance of the specified type.
        /// </summary>
        /// <remarks>
        /// This function might get more important if other WCF bingis are supported.
        /// All settings to a specific binding shuld be made here.
        /// All binding are probably not needed.
        /// </remarks>
        /// <param name="endPoint">EndPoint entity containig iformation about, what type of binding to return and how to set it.</param>
        /// <returns>The new configured binding element.</returns>
        public static System.ServiceModel.Channels.Binding GetWCFBinding(EndPoint endPoint)
        {
            if (endPoint.RemotingMechanism == RemotingMechanism.TcpBinary)
            {
                return(null);
            }

            System.ServiceModel.Channels.Binding ret = null;

            WCFBinding bindingEnum = endPoint.Binding;

            switch (bindingEnum)
            {
                #region BasicHttpBinding
            case WCFBinding.BasicHttpBinding:
            {
                //WARNING: untested code
                System.ServiceModel.BasicHttpBinding bhb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    bhb = new System.ServiceModel.BasicHttpBinding();
                    bhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    bhb.MaxReceivedMessageSize = Int32.MaxValue;
                    bhb.Security.Mode          = System.ServiceModel.BasicHttpSecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    bhb = new System.ServiceModel.BasicHttpBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = bhb;
                break;
            }

                #endregion
                #region MsmqIntegrationBinding
            case WCFBinding.MsmqIntegrationBinding:
            {
                //WARNING: untested code
                System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding mib = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    mib = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding();
                    mib.Security.Mode = System.ServiceModel.MsmqIntegration.MsmqIntegrationSecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    mib = new System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = mib;
                break;
            }

                #endregion
                #region NetMsmqBinding
            case WCFBinding.NetMsmqBinding:
            {
                //WARNING: untested code
                System.ServiceModel.NetMsmqBinding nmb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    nmb = new System.ServiceModel.NetMsmqBinding();
                    nmb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    nmb.Security.Mode = System.ServiceModel.NetMsmqSecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    nmb = new System.ServiceModel.NetMsmqBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = nmb;
                break;
            }

                #endregion
                #region NetNamedPipeBinding
            case WCFBinding.NetNamedPipeBinding:
            {
                //WARNING: untested code
                System.ServiceModel.NetNamedPipeBinding nnpb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    nnpb = new System.ServiceModel.NetNamedPipeBinding();
                    nnpb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    nnpb.Security.Mode = System.ServiceModel.NetNamedPipeSecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    nnpb = new System.ServiceModel.NetNamedPipeBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = nnpb;
                break;
            }

                #endregion
                #region NetPeerTcpBinding
            case WCFBinding.NetPeerTcpBinding:
            {
                //WARNING: untested code
                System.ServiceModel.NetPeerTcpBinding nptb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    nptb = new System.ServiceModel.NetPeerTcpBinding();
                    nptb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    nptb.Security.Mode = System.ServiceModel.SecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    nptb = new System.ServiceModel.NetPeerTcpBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = nptb;
                break;
            }

                #endregion
                #region NetTcpBinding
            case WCFBinding.NetTcpBinding:
            {
                System.ServiceModel.NetTcpBinding ntb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    ntb = new System.ServiceModel.NetTcpBinding();
                    ntb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    ntb.MaxReceivedMessageSize = Int32.MaxValue;
                    ntb.Security.Mode          = System.ServiceModel.SecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    ntb = new System.ServiceModel.NetTcpBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = ntb;
                break;
            }

                #endregion
                #region WSDualHttpBinding
            case WCFBinding.WSDualHttpBinding:
            {
                //WARNING: untested code
                System.ServiceModel.WSDualHttpBinding wdhb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    wdhb = new System.ServiceModel.WSDualHttpBinding();
                    wdhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    wdhb.Security.Mode = System.ServiceModel.WSDualHttpSecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    wdhb = new System.ServiceModel.WSDualHttpBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = wdhb;
                break;
            }

                #endregion
                #region WSFederationHttpBinding
            case WCFBinding.WSFederationHttpBinding:
            {
                //WARNING: untested code
                System.ServiceModel.WSFederationHttpBinding wfhb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    wfhb = new System.ServiceModel.WSFederationHttpBinding();
                    wfhb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    wfhb = new System.ServiceModel.WSFederationHttpBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = wfhb;
                break;
            }

                #endregion
                #region WSHttpBinding
            case WCFBinding.WSHttpBinding:
            {
                System.ServiceModel.WSHttpBinding whb = null;
                switch (endPoint.BindingSettingType)
                {
                case WCFBindingSettingType.Default:
                    whb = new System.ServiceModel.WSHttpBinding();
                    whb.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
                    whb.MaxReceivedMessageSize = Int32.MaxValue;
                    whb.Security.Mode          = System.ServiceModel.SecurityMode.None;
                    break;

                case WCFBindingSettingType.UseConfigFile:
                    whb = new System.ServiceModel.WSHttpBinding(endPoint.BindingConfigurationName);
                    break;
                }
                ret = whb;
                break;
            }
                #endregion
            }


            return(ret);
        }
Esempio n. 20
0
        internal static MasterDataProviderService.IMasterDataProviderService GetMasterProviderServiceClient()
        {
            try
            {
                if (_masterProviderServiceClient == null)
                {
                    System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(MasterDataProviderServiceUrl);
                    System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.None);
                    binding.MaxReceivedMessageSize = Int32.MaxValue;

                    binding.CloseTimeout = new TimeSpan(0, 30, 0);
                    binding.OpenTimeout = new TimeSpan(0, 30, 0);
                    binding.ReceiveTimeout = new TimeSpan(0, 30, 0);
                    binding.SendTimeout = new TimeSpan(0, 30, 0);

                    _masterProviderServiceClient = new MasterDataProviderService.MasterDataProviderServiceClient(binding, address);
                }
                _masterProviderServiceClient.SetFPApplication(ServiceReferences.FPApplication);
                return _masterProviderServiceClient;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public Formulario()
 {
     InitializeComponent();
     bind = new System.ServiceModel.BasicHttpBinding();
     endpoint = new System.ServiceModel.EndpointAddress(m_EndPoint);
     Wrapper = new ServiceReferenceClinica.WSClinicaSoapClient(bind, endpoint);
 }
Esempio n. 22
0
        public MainPage()
        {
            DebugLogger.Instance.LogMsg("Initialising Glyma...   Url: " + HtmlPage.Document.DocumentUri);
            InitializeComponent();
            SetupNetworkChange(); //logs if the network is going up/down
            Sidebar.Handler = SuperGraph;
            ZommingControl.Handler = SuperGraph;
            Breadcrumbs.Handler = SuperGraph;
            SuperGraph.Ref = this;
            if (!App.IsDesignTime)
            {
                Loader.Visibility = Visibility.Visible;
                Breadcrumbs.BreadcrumbChanged += OnBreadcrumbChanged;
                Breadcrumbs.BreadcrumbClicked += OnBreadcrumbClicked;
                SuperGraph.DataContext = new SuperGraphProperties
                {
                    NodeTextWidth = GlymaParameters.NodeTextWidth,
                    NodeImageWidth = GlymaParameters.NodeImageWidth,
                    NodeImageHeight = GlymaParameters.NodeImageHeight
                };

                SoapEndPointFactory soapEndPointFactory = new SoapEndPointFactory(new Uri(App.Params.TransactionalMappingToolSvcUrl));
                var soapMapManager = new SoapProxy.SoapMapManager(soapEndPointFactory);

                _mapManager = soapMapManager;
                _mapManager.InitialiseMapManagerCompleted += OnInitialiseMapManagerCompleted;
                
                _mapManager.MapManagerActivityStatusUpdated += OnMapManagerActivityStatusUpdated;
                IoCContainer.GetInjectionInstance().RegisterComponent<Proxy.IMapManager, SoapProxy.SoapMapManager>(soapMapManager);

                var binding = new System.ServiceModel.BasicHttpBinding();
                binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly;
                binding.MaxReceivedMessageSize = 2147483647;

                var utilityServiceAddress = new System.ServiceModel.EndpointAddress(new Uri(App.Params.GlymaUtilitySvcUrl));
                var utilityManagerServiceClient = new UtilityProxy.Service.UtilityServiceManagerClient(binding, utilityServiceAddress);
                var exportServiceManager = new UtilityProxy.ExportServiceManager(utilityManagerServiceClient);
                IoCContainer.GetInjectionInstance().RegisterComponent<UtilityProxy.IExportServiceManager, UtilityProxy.ExportServiceManager>(exportServiceManager);
                exportServiceManager.IsExportingAvailableCompleted.RegisterEvent(IsExportingAvailableCompleted);

                _themeManager = new ThemeManager();

                SuperGraph.NodeClicked += NodeClicked;
                SuperGraph.FilesDropped += FilesDropped;

                var jsBridge = new JavaScriptBridge(SuperGraph);
                HtmlPage.RegisterScriptableObject("glymaMapCanvas", jsBridge);

                exportServiceManager.IsExportingAvailableAsync();
            }
        }
Esempio n. 23
0
        public void DatacontractFaults(string f)
        {
            IWebHost host = ServiceHelper.CreateWebHostBuilder <Startup>(_output).Build();

            using (host)
            {
                host.Start();
                System.ServiceModel.BasicHttpBinding httpBinding = ClientHelper.GetBufferedModeBinding();
                var factory = new System.ServiceModel.ChannelFactory <ClientContract.ITestDataContractFault>(httpBinding,
                                                                                                             new System.ServiceModel.EndpointAddress(new Uri("http://localhost:8080/BasicWcfService/DatacontractFaults.svc")));
                ClientContract.ITestDataContractFault channel = factory.CreateChannel();

                var factory2 = new System.ServiceModel.ChannelFactory <ClientContract.ITestDataContractFaultTypedClient>(httpBinding,
                                                                                                                         new System.ServiceModel.EndpointAddress(new Uri("http://localhost:8080/BasicWcfService/DatacontractFaults.svc")));
                ClientContract.ITestDataContractFaultTypedClient channel2 = factory2.CreateChannel();

                //test variations
                int count = 9;
                try
                {
                    channel.TwoWayVoid_Method(f);
                }
                catch (Exception e)
                {
                    count--;
                    FaultExceptionValidation(f, e);
                }

                try
                {
                    string s = channel.TwoWay_Method(f);
                }
                catch (Exception e)
                {
                    count--;
                    FaultExceptionValidation(f, e);
                }

                try
                {
                    Stream inputStream = new MemoryStream();
                    byte[] bytes       = Encoding.UTF8.GetBytes(f.ToCharArray());
                    foreach (byte b in bytes)
                    {
                        inputStream.WriteByte(b);
                    }

                    inputStream.Position = 0;
                    Stream       outputStream = channel.TwoWayStream_Method(inputStream);
                    StreamReader sr           = new StreamReader(outputStream, Encoding.UTF8);
                    string       outputText   = sr.ReadToEnd();
                    Assert.False(true, $"Error, Received Input: {outputText}");
                }
                catch (Exception e)
                {
                    count--;
                    FaultExceptionValidation(f, e);
                }

                try
                {
                    string response = channel.TwoWayAsync_Method(f).GetAwaiter().GetResult();
                    Assert.False(true, $"Error, Client received: {response}");
                }
                catch (Exception e)
                {
                    count--;
                    FaultExceptionValidation(f, e);
                }

                try
                {
                    var fmc = new ClientContract.FaultMsgContract
                    {
                        ID   = 123,
                        Name = f
                    };
                    ClientContract.FaultMsgContract fmcResult = channel.MessageContract_Method(fmc);
                    Assert.False(true, $"Error, Client received: {fmcResult.Name}");
                }
                catch (Exception e)
                {
                    count--;
                    FaultExceptionValidation(f, e);
                }

                System.ServiceModel.Channels.Message msgOut = System.ServiceModel.Channels.Message.CreateMessage(System.ServiceModel.Channels.MessageVersion.Soap11, "http://tempuri.org/ITestDataContractFault/Untyped_Method", f);
                System.ServiceModel.Channels.Message msgIn  = channel.Untyped_Method(msgOut);
                if (msgIn.IsFault)
                {
                    System.ServiceModel.Channels.MessageFault mf = System.ServiceModel.Channels.MessageFault.CreateFault(msgIn, int.MaxValue);
                    switch (f.ToLower())
                    {
                    case "somefault":
                        count--;
                        ClientContract.SomeFault sf = mf.GetDetail <ClientContract.SomeFault>();
                        Assert.Equal(123456789, sf.ID);
                        Assert.Equal("SomeFault", sf.message);
                        break;

                    case "outerfault":
                        count--;
                        ClientContract.OuterFault of = mf.GetDetail <ClientContract.OuterFault>();
                        sf = of.InnerFault;
                        Assert.Equal(123456789, sf.ID);
                        Assert.Equal("SomeFault as innerfault", sf.message);
                        break;

                    case "complexfault":
                        count--;
                        ClientContract.ComplexFault cf = mf.GetDetail <ClientContract.ComplexFault>();
                        string exp = "50:This is a test error string for fault tests.:123456789:SomeFault in complexfault:0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127:2147483647-214748364801-150-50:123456789:SomeFault in complexfaultnull234:Second somefault in complexfault";
                        Assert.Equal(exp, ComplexFaultToString(cf));
                        break;

                    default:
                        break;
                    }
                }

                msgOut = System.ServiceModel.Channels.Message.CreateMessage(System.ServiceModel.Channels.MessageVersion.Soap11, "http://tempuri.org/ITestDataContractFault/Untyped_MethodReturns", f);
                msgIn  = channel.Untyped_MethodReturns(msgOut);
                if (msgIn.IsFault)
                {
                    System.ServiceModel.Channels.MessageFault mf = System.ServiceModel.Channels.MessageFault.CreateFault(msgIn, int.MaxValue);
                    switch (f)
                    {
                    case "somefault":
                        count--;
                        ClientContract.SomeFault sf = mf.GetDetail <ClientContract.SomeFault>();
                        Assert.Equal(123456789, sf.ID);
                        Assert.Equal("SomeFault", sf.message);
                        break;

                    case "outerfault":
                        count--;
                        ClientContract.OuterFault of = mf.GetDetail <ClientContract.OuterFault>();
                        sf = of.InnerFault;
                        Assert.Equal(123456789, sf.ID);
                        Assert.Equal("SomeFault as innerfault", sf.message);
                        break;

                    case "complexfault":
                        count--;
                        ClientContract.ComplexFault cf = mf.GetDetail <ClientContract.ComplexFault>();
                        string exp = "50:This is a test error string for fault tests.:123456789:SomeFault in complexfault:0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127:2147483647-214748364801-150-50:123456789:SomeFault in complexfaultnull234:Second somefault in complexfault";
                        Assert.Equal(exp, ComplexFaultToString(cf));
                        break;

                    default:
                        break;
                    }
                }

                try
                {
                    string response = channel2.Untyped_Method(f);
                }
                catch (Exception e)
                {
                    count--;
                    FaultExceptionValidation(f, e);
                }

                try
                {
                    string response = channel2.Untyped_MethodReturns(f);
                }
                catch (Exception e)
                {
                    count--;
                    FaultExceptionValidation(f, e);
                }

                Assert.Equal(0, count);
            }
        }
Esempio n. 24
0
        //-----------------------------------------------------------------------------------------------------
        public void chargeVerify()
        {
            System.ServiceModel.EndpointAddress myEndpointAddress = new System.ServiceModel.EndpointAddress("https://token.melissadata.net/v3/SOAP/Service.svc");

            System.ServiceModel.BasicHttpBinding myBinding = new System.ServiceModel.BasicHttpBinding();
            myBinding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;

            SOAP2.ServiceClient client = new SOAP2.ServiceClient(myBinding, myEndpointAddress);

            SOAP2.ConsumeCreditsExRequest request = new SOAP2.ConsumeCreditsExRequest();
            request.License = licensekey;
            request.Source = "2611";
            request.TotalProductRecords = 1;
            request.ConsumeRecord = new SOAP2.ConsumeCreditsRecord[1];
            request.ConsumeRecord[0] = new SOAP2.ConsumeCreditsRecord();
            request.ConsumeRecord[0].Package = "pkgBorgVerify";
            request.ConsumeRecord[0].Product = "2701";
            request.ConsumeRecord[0].Quantity = this.verify;
            client.ConsumeCreditsEx(request);

            if (this.system.Contains("credit"))
            {
                int verifyCredit = (Convert.ToInt32(this.verify) * 1);
                string sverifyCredit = verifyCredit.ToString();
                Logger.Write(Logger.Severity.Info, "Total Charged Verify - Consumed Credit: ", sverifyCredit);
            }
        }
Esempio n. 25
0
 SPVelvet.ListsSoapClient GetServiceInstance()
 {
     var Basebinding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly);
     Basebinding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
     Basebinding.MaxReceivedMessageSize = 999999999;
     System.ServiceModel.Channels.Binding binding = Basebinding;
     System.ServiceModel.EndpointAddress addr = new System.ServiceModel.EndpointAddress(SpServiceUrl);
     SPVelvet.ListsSoapClient client = new SPVelvet.ListsSoapClient(binding, addr);
     client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
     client.ClientCredentials.Windows.ClientCredential = new NetworkCredential(UserName, Password, Domain);
     return client;
 }
Esempio n. 26
0
        //-----------------------------------------------------------------------------------------------------
        public void chargeAppend()
        {
            System.ServiceModel.EndpointAddress myEndpointAddress = new System.ServiceModel.EndpointAddress("https://token.melissadata.net/v3/SOAP/Service.svc");

            System.ServiceModel.BasicHttpBinding myBinding = new System.ServiceModel.BasicHttpBinding();
            myBinding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;

            SOAP2.ServiceClient client = new SOAP2.ServiceClient(myBinding, myEndpointAddress);

            SOAP2.ConsumeCreditsExRequest request = new SOAP2.ConsumeCreditsExRequest();

            request.License = licensekey;
            request.Source = "2611";
            request.ConsumeRecord = new SOAP2.ConsumeCreditsRecord[4];
            request.ConsumeRecord[0] = new SOAP2.ConsumeCreditsRecord();
            request.ConsumeRecord[0].Package = "pkgBorgAppend";
            request.ConsumeRecord[0].Product = "2704";
            request.ConsumeRecord[0].Quantity = this.appendname;
            request.ConsumeRecord[1] = new SOAP2.ConsumeCreditsRecord();
            request.ConsumeRecord[1].Package = "pkgBorgAppend";
            request.ConsumeRecord[1].Product = "2705";
            request.ConsumeRecord[1].Quantity = this.appendaddress;
            request.ConsumeRecord[2] = new SOAP2.ConsumeCreditsRecord();
            request.ConsumeRecord[2].Package = "pkgBorgAppend";
            request.ConsumeRecord[2].Product = "2706";
            request.ConsumeRecord[2].Quantity = this.appendphone;
            request.ConsumeRecord[3] = new SOAP2.ConsumeCreditsRecord();
            request.ConsumeRecord[3].Package = "pkgBorgAppend";
            request.ConsumeRecord[3].Product = "2707";
            request.ConsumeRecord[3].Quantity = this.appendemail;
            client.ConsumeCreditsEx(request);

            if (this.system.Contains("credit"))
            {
                int appendCredit = (Convert.ToInt32(this.appendname) * 3) + (Convert.ToInt32(this.appendaddress) * 5) + (Convert.ToInt32(this.appendphone) * 5) + (Convert.ToInt32(this.appendemail) * 5);
                string sappendCredit = appendCredit.ToString();
                Logger.Write(Logger.Severity.Info, "Total Charged Append - Consumed Credit: ", sappendCredit);
            }
        }
Esempio n. 27
0
        static void GenerateServiceOperationsFromEndpoint()
        {
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls11;
            System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
            binding.OpenTimeout   = new TimeSpan(0, 5, 0);
            binding.CloseTimeout  = new TimeSpan(0, 5, 0);
            binding.SendTimeout   = new TimeSpan(0, 5, 0);
            binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
            binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.None;
            binding.MaxBufferSize          = 64000000;
            binding.MaxReceivedMessageSize = 64000000;
            System.ServiceModel.EndpointAddress EndPoint = new System.ServiceModel.EndpointAddress("https://geapi.dqtelecharge.com/EAPI.svc");
            EAPIClient client = new EAPIClient(binding, EndPoint);

            string   fileName = @"EAPI.dll";
            Assembly assembly = Assembly.LoadFrom(fileName);

            ServiceContractDataResolver.ServiceContractDataResolver dcr = new ServiceContractDataResolver.ServiceContractDataResolver(assembly, new Dictionary <string, XmlDictionaryString>());

            MethodInfo[] testMethods = client.GetType().GetMethods();

            try
            {
                using (SqlConnection sqlConn = new SqlConnection("Data Source=LAPTOP-DHCHDQG6\\SQLEXPRESS;Initial Catalog=TestAutomation;Integrated Security=True"))
                {
                    //Open the database.
                    sqlConn.Open();
                    var result = false;

                    using (var sqlCmd = new SqlCommand())
                    {
                        foreach (MethodInfo m in testMethods)
                        {
                            //Skip async operations.
                            if (m.Name.Contains("SignOn") ||
                                m.Name.Contains("SignOff") ||
                                m.Name.Contains("StartNewSession") ||
                                m.Name.Contains("Ping") ||
                                m.Name.Contains("EndSession"))
                            {
                                continue;
                            }

                            if (m.DeclaringType.Name != "EAPIClient")
                            {
                                continue;
                            }

                            if (m.ReturnType == typeof(IAsyncResult))
                            {
                                continue;
                            }

                            if (m.ReturnType.BaseType.Name == "Task")
                            {
                                continue;
                            }

                            /*if (m.Name.Contains("OfferDetails"))
                             *  Debugger.Break();*/

                            Console.WriteLine("Generating method {0}, return type {1}", m.Name, m.ReturnType.Name);

                            //Run the stored procedures.
                            sqlCmd.Connection  = sqlConn;
                            sqlCmd.CommandType = CommandType.StoredProcedure;

                            //Methods
                            sqlCmd.CommandText = "ag_application_method_ins";
                            sqlCmd.Parameters.Clear();
                            sqlCmd.Parameters.Add(new SqlParameter("application_id", SqlDbType.Int)
                            {
                                Value = 1
                            });
                            sqlCmd.Parameters.Add(new SqlParameter("application_version_id", SqlDbType.Int)
                            {
                                Value = 1
                            });
                            sqlCmd.Parameters.Add(new SqlParameter("method_name", SqlDbType.VarChar)
                            {
                                Value = m.Name
                            });
                            sqlCmd.Parameters.Add(new SqlParameter("return_type", SqlDbType.VarChar)
                            {
                                Value = m.ReturnType.Name
                            });
                            int application_method_id = (int)sqlCmd.ExecuteScalar();

                            //Return type fields.
                            try
                            {
                                using (var sqlRespParmCmd = new SqlCommand())
                                {
                                    foreach (var returnProp in m.ReturnType.GetRuntimeProperties())
                                    {
                                        List <PropertyInfo> dataProperty = new List <PropertyInfo>();

                                        Console.WriteLine("<<< {0}", returnProp.Name);
                                        Console.WriteLine("\t*** {0}", returnProp.GetMethod.ReturnParameter);

                                        sqlRespParmCmd.Parameters.Clear();

                                        /*if (returnProp.Name == "OfferDescription")
                                         *  Debugger.Break();*/

                                        //TODO:This is where would store types in the database. so application_response_parametername, application_response_type
                                        if (returnProp.GetMethod.ReturnParameter.ParameterType.IsArray)
                                        {
                                            sqlRespParmCmd.Parameters.Add(new SqlParameter("is_container", SqlDbType.Int)
                                            {
                                                Value = 1
                                            });

                                            foreach (var returnDataProperty in returnProp.GetMethod.ReturnParameter.ParameterType.GetElementType().GetRuntimeProperties())
                                            {
                                                Console.WriteLine("\t\t``` {0}", returnDataProperty.Name);
                                                dataProperty.Add(returnDataProperty);
                                            }
                                        }
                                        else
                                        {
                                            sqlRespParmCmd.Parameters.Add(new SqlParameter("is_container", SqlDbType.Int)
                                            {
                                                Value = 0
                                            });

                                            /*foreach (var returnDataProperty in returnProp.GetMethod.ReturnParameter.ParameterType.GetRuntimeProperties())
                                             * {
                                             *  Console.WriteLine("\t\t``` {0}", returnDataProperty.Name);
                                             *  dataProperty.Add(returnDataProperty);
                                             * }*/
                                        }

                                        sqlRespParmCmd.Connection  = sqlConn;
                                        sqlRespParmCmd.CommandType = CommandType.StoredProcedure;
                                        sqlRespParmCmd.CommandText = "ag_application_method_response_parameters_ins";
                                        sqlRespParmCmd.Parameters.Add(new SqlParameter("application_method_id", SqlDbType.Int)
                                        {
                                            Value = application_method_id
                                        });
                                        sqlRespParmCmd.Parameters.Add(new SqlParameter("application_method_response_parameter_name", SqlDbType.VarChar)
                                        {
                                            Value = returnProp.Name
                                        });
                                        sqlRespParmCmd.Parameters.Add(new SqlParameter("position", SqlDbType.Int)
                                        {
                                            Value = 0
                                        });
                                        int application_method_response_id = (int)sqlRespParmCmd.ExecuteScalar();

                                        foreach (var property in dataProperty)
                                        {
                                            AddResponseDataTypeToTable(application_method_response_id, property, sqlCmd, sqlConn);
                                        }
                                    }
                                }
                            }
                            catch (SqlException ex)
                            {
                                Debugger.Log(1, "SQL", ex.Message);
                                Console.WriteLine(ex.Message);
                            }

                            //Operation input parameters.
                            using (var sqlParmCmd = new SqlCommand())
                            {
                                sqlParmCmd.Connection  = sqlConn;
                                sqlParmCmd.CommandType = CommandType.StoredProcedure;

                                ParameterInfo[] parameterInfo = m.GetParameters();
                                sqlParmCmd.CommandText = "ag_application_method_parameters_ins";

                                /*if (m.Name == "Contacts")
                                 *  Debugger.Break();*/

                                /*
                                 * For each method skip the token parameter info.
                                 * This type might have a different name for different APIs so there
                                 * should be a credentials table that has the names of the methods and types
                                 * that should be skipped.
                                 */
                                foreach (ParameterInfo p in parameterInfo)
                                {
                                    if (p.Name == "Toke" || p.Name == "token" || p.Name == "Token")
                                    {
                                        continue;
                                    }

                                    sqlParmCmd.Parameters.Clear();

                                    var RunTimeMethods    = p.ParameterType.GetRuntimeMethods();
                                    var RunTimeProperties = p.ParameterType.GetRuntimeProperties();

                                    foreach (PropertyInfo fi in RunTimeProperties)
                                    {
                                        /*if (fi.PropertyType.FullName.Contains("SQLTestAdapter.EAPIServiceReference.InquireINQUIRE"))
                                         * {
                                         *  Debugger.Break();
                                         * }*/

                                        sqlParmCmd.Parameters.Clear();
                                        Console.WriteLine("... {0}", fi.Name);
                                        sqlParmCmd.Parameters.Add(new SqlParameter("application_method_id", SqlDbType.Int)
                                        {
                                            Value = application_method_id
                                        });
                                        sqlParmCmd.Parameters.Add(new SqlParameter("application_method_name", SqlDbType.VarChar)
                                        {
                                            Value = m.Name
                                        });
                                        sqlParmCmd.Parameters.Add(new SqlParameter("application_method_parameter_name", SqlDbType.VarChar)
                                        {
                                            Value = fi.Name
                                        });
                                        sqlParmCmd.Parameters.Add(new SqlParameter("application_method_parameter_type", SqlDbType.VarChar)
                                        {
                                            Value = fi.PropertyType.FullName
                                        });
                                        sqlParmCmd.Parameters.Add(new SqlParameter("position", SqlDbType.Int)
                                        {
                                            Value = p.Position
                                        });

                                        /*
                                         * Here is how to serialize a struct!
                                         * object serializedType = System.Runtime.Serialization.FormatterServices.GetUninitializedObject(fi.PropertyType.GetElementType());
                                         * json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(serializedType);
                                         *
                                         */

                                        /*
                                         * Serialize method parameter types for testing the service with actual data.
                                         * Values to be input via a UI.
                                         */
                                        //TODO: DEBUG:
                                        //Just fudge for this test.
                                        //Type t = assembly.GetType(p.ParameterType.FullName);
                                        Type t   = assembly.GetType("Shubert.EApiWS." + p.ParameterType.Name);
                                        var  xml = dcr.serialize(t);
                                        sqlParmCmd.Parameters.Add(new SqlParameter("value", SqlDbType.NVarChar)
                                        {
                                            Value = xml
                                        });
                                        result = sqlParmCmd.ExecuteNonQuery() > 0;
                                    }
                                }
                            }
                        }

                        //XmlSerializer serializer = new XmlSerializer(typeof(Dictionary<string, XmlDictionaryString));
                        var typeDictionary = dcr.GetTypeDictionary();
                        foreach (KeyValuePair <string, XmlDictionaryString> entry in typeDictionary)
                        {
                            //Debugger.Break();
                            String query = "INSERT INTO application_filter_type_dictionary (application_id, application_version_id, type) VALUES (@application_id, @application_version_id, @type)";

                            using (SqlCommand command = new SqlCommand(query, sqlConn))
                            {
                                command.Parameters.AddWithValue("@application_id", 1);
                                command.Parameters.AddWithValue("@application_version_id", 1);
                                command.Parameters.AddWithValue("@type", entry.Value.ToString());

                                var ret = command.ExecuteNonQuery();

                                // Check Error
                                if (ret < 0)
                                {
                                    Console.WriteLine("Error inserting data into Database!");
                                }
                            }
                        }
                        //TextWriter tw = new StreamWriter(".");
                        //serializer.Serialize(tw, typeDictionary);
                        //Console.WriteLine("{0}", tw.ToString());
                    }

                    sqlConn.Close();
                }
            }
            catch (SqlException ex)
            {
                Debugger.Break();
                Debugger.Log(1, "SQL", ex.Message);
                Console.WriteLine(ex.Message);
            }
        }//GeneratefromEndPoint
Esempio n. 28
0
        public void VariousCollections()
        {
            IWebHost host = ServiceHelper.CreateWebHostBuilder<Startup>(_output).Build();
            using (host)
            {
                ClientContract.ITaskCollectionsTest collectionsTest = null;
                System.ServiceModel.ChannelFactory<ClientContract.ITaskCollectionsTest> channelFactory = null;
                host.Start();
                System.ServiceModel.BasicHttpBinding httpBinding = ClientHelper.GetBufferedModeBinding();
                channelFactory = new System.ServiceModel.ChannelFactory<ClientContract.ITaskCollectionsTest>(httpBinding,
                    new System.ServiceModel.EndpointAddress(new Uri("http://localhost:8080/BasicWcfService/TaskCollectionsTest.svc")));
                collectionsTest = channelFactory.CreateChannel();

                Task[] array;
                array = new Task[5];
                array[0] = collectionsTest.GetDictionary();
                array[1] = collectionsTest.GetList();
                array[2] = collectionsTest.GetSet();
                array[3] = collectionsTest.GetQueue();
                array[4] = collectionsTest.GetStack();
                Task.WaitAll(array, TimeSpan.FromSeconds(30));

                bool flag = true;
                Task<Dictionary<string, int>> task = array[0] as Task<Dictionary<string, int>>;
                Assert.True(task.Result.ContainsKey("Sam"));
                Assert.True(task.Result.ContainsKey("Sara"));
                if (!task.Result.ContainsKey("Sam") || !task.Result.ContainsKey("Sara"))
                {
                    flag = false;
                    _output.WriteLine("Expected collection to contain Sara and Sam.");
                    _output.WriteLine("Actual Result");
                    foreach (string text in task.Result.Keys)
                    {
                        _output.WriteLine(text);
                    }
                }

                Task<LinkedList<int>> task2 = array[1] as Task<LinkedList<int>>;
                Assert.Contains(100, task2.Result);
                Assert.Contains(40, task2.Result);
                if (!task2.Result.Contains(100) || !task2.Result.Contains(40))
                {
                    flag = false;
                    _output.WriteLine("Expected collection to contain 100 and 40.");
                    _output.WriteLine("Actual Result");
                    foreach (int num in task2.Result)
                    {
                        _output.WriteLine(num.ToString());
                    }
                }

                Task<HashSet<Book>> task3 = array[2] as Task<HashSet<Book>>;
                foreach (Book book in task3.Result)
                {
                    Assert.False(!book.Name.Equals("Whoa") && !book.Name.Equals("Dipper"));
                    if (!book.Name.Equals("Whoa") && !book.Name.Equals("Dipper"))
                    {
                        _output.WriteLine("Expected collection to contain Whoa and Dipper.");
                        _output.WriteLine(string.Format("Actual Result {0}", book.Name));
                        flag = false;
                    }
                }

                Task<Queue<string>> task4 = array[3] as Task<Queue<string>>;
                Assert.True(task4.Result.Contains("Panasonic"));
                Assert.True(task4.Result.Contains("Kodak"));
                if (!task4.Result.Contains("Panasonic") || !task4.Result.Contains("Kodak"))
                {
                    flag = false;
                    _output.WriteLine("Expected collection to contain Panasonic and Kodak.");
                    _output.WriteLine("Actual Result");
                    foreach (string text2 in task4.Result)
                    {
                        _output.WriteLine(text2);
                    }
                }

                Task<Stack<byte>> task5 = array[4] as Task<Stack<byte>>;
                Assert.True(task5.Result.Contains(45));
                Assert.True(task5.Result.Contains(10));
                if (!task5.Result.Contains(45) || !task5.Result.Contains(10))
                {
                    flag = false;
                    _output.WriteLine("Expected collection to contain 45 and 10.");
                    _output.WriteLine("Actual Result");
                    foreach (byte b in task5.Result)
                    {
                        _output.WriteLine(b.ToString());
                    }
                }
                if (!flag)
                {
                    throw new Exception("Test Failed");
                }

            }
        }
        /// <summary>
        /// Searches a specific report for your provided searchText and returns the page that it located the text on.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="searchText">The text that you want to search in the report</param>
        /// <param name="startPage">Starting page for the search to begin from.</param>
        /// <returns></returns>
        public static int?FindStringInReport(ReportViewerModel model, string searchText, int?startPage = 0)
        {
            var url = model.ServerUrl + ((model.ServerUrl.ToSafeString().EndsWith("/")) ? "" : "/") + "ReportExecution2005.asmx";

            var basicHttpBinding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly);

            basicHttpBinding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
            basicHttpBinding.MaxReceivedMessageSize = int.MaxValue;
            var service = new ReportServiceExecution.ReportExecutionServiceSoapClient(basicHttpBinding, new System.ServiceModel.EndpointAddress(url));

            service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            service.ClientCredentials.Windows.ClientCredential          = (System.Net.NetworkCredential)(model.Credentials ?? System.Net.CredentialCache.DefaultCredentials);

            var definedReportParameters = GetReportParameters(model, true);

            if (!startPage.HasValue || startPage == 0)
            {
                startPage = 1;
            }

            var exportResult = new ReportExportResult();

            exportResult.CurrentPage = startPage.ToInt32();
            exportResult.SetParameters(definedReportParameters, model.Parameters);

            var deviceInfo = $"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";

            var reportParameters = new List <ReportServiceExecution.ParameterValue>();

            foreach (var parameter in exportResult.Parameters)
            {
                bool addedParameter = false;
                foreach (var value in parameter.SelectedValues)
                {
                    var reportParameter = new ReportServiceExecution.ParameterValue();
                    reportParameter.Name  = parameter.Name;
                    reportParameter.Value = value;
                    reportParameters.Add(reportParameter);

                    addedParameter = true;
                }

                if (!addedParameter)
                {
                    var reportParameter = new ReportServiceExecution.ParameterValue();
                    reportParameter.Name = parameter.Name;
                    reportParameters.Add(reportParameter);
                }
            }

            var executionHeader = new ReportServiceExecution.ExecutionHeader();

            ReportServiceExecution.ExecutionInfo executionInfo = null;

            try
            {
                string historyID = null;
                executionInfo = service.LoadReportAsync(model.ReportPath, historyID).Result;
                executionHeader.ExecutionID = executionInfo.ExecutionID;
                var executionParameterResult = service.SetReportParameters(executionInfo.ExecutionID, reportParameters.ToArray(), "en-us").Result;

                return(service.FindString(executionInfo.ExecutionID, startPage.ToInt32(), executionInfo.NumPages, searchText).Result);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(0);
        }
Esempio n. 30
0
        static void Main(string[] args)
        {
            Console.Clear();
            Console.WriteLine("Battle City AI, Copyright (c) 1985 U.S. Robots and Mechanical Men, Inc.");
#if DEBUG
            Console.WriteLine("Mode: DEBUG");
#else
            Console.WriteLine("Mode: RELEASE");
#endif
            Console.WriteLine(Environment.NewLine + "Welcome, scalvin.");

            string botname = "ctf";

            Console.BufferHeight = 4096;
            Console.WindowWidth  = 132;
            Console.WindowHeight = 40;

            Debug.Listeners.Add(new TextWriterTraceListener(System.Console.Out));

            var endpoint = "http://localhost:7070/Challenge/ChallengeService";
            if (args.Length > 0)
            {
                endpoint = args[0];
            }
            if (args.Length > 1)
            {
                botname = args[1].ToLower();
            }

            System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
            binding.MaxReceivedMessageSize = Settings.MAX_SOAP_MSG_SIZE;
            System.ServiceModel.EndpointAddress remoteAddress = new System.ServiceModel.EndpointAddress(endpoint);
            client = new ChallengeService.ChallengeClient(binding, remoteAddress);

            try
            {
                ChallengeService.board result = client.login();
                board = new Board(result.states);
                board.endGamePoint = result.endGamePoint;

                // Set up the clock, and add all the tasks that should execute each cycle.
                clock = new Clock(Settings.SYNC_TICK, Settings.SYNC_DELTA_STEP_LO);

                // At the start of each cycle, process all events and prune the game trees.
                clock.AddTask(0, handleNewTick);

                // Some time through the cycle, post a preliminary move as backup.
                clock.AddTask(Settings.SCHEDULE_EARLY_MOVE, postEarlyMove);

                // Just before the end of the cycle, post the final best move found.
                clock.AddTask(Settings.SCHEDULE_FINAL_MOVE, postFinalMove);

                // In the first tick, the server status is read, and the clock is started based
                // on the reported millisecondsToNextTick.
                ChallengeService.game status = client.getStatus();
                board.Update(status);
                Console.Title = board.playerName;
                Debug.Listeners.Add(new TextWriterTraceListener(board.playerName + ".log"));

                switch (botname)
                {
                case "random":
                    bot = new AI_Random(board, client);
                    break;

                case "aggro":
                    bot = new AI_Aggro(board, client);
                    break;

                case "ctf":
                    bot = new AI_CTF(board, client);
                    break;

                default:
                    bot = new AI_Random(board, client);
                    break;
                }

                Console.WriteLine("Launching AI '{0}'" + Environment.NewLine, botname);

                clock.Start(status.millisecondsToNextTick + Settings.SYNC_INITIAL_DELAY);
                Debug.Flush();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
        }
Esempio n. 31
0
        private void PrtCheck(int InvNum)
        {
            string Address = @"http://vfiliasesb0:2580/process/Ges3ServicesUTF8Proc";

            System.ServiceModel.EndpointAddress  remoteAddress = new System.ServiceModel.EndpointAddress(Address);
            System.ServiceModel.Channels.Binding binding       = new System.ServiceModel.BasicHttpBinding();
            ((System.ServiceModel.BasicHttpBinding)binding).MaxReceivedMessageSize = 1024 * 1024;
            SrvGes.Ges3ServicesUTF8ObjClient Cl = new SrvGes.Ges3ServicesUTF8ObjClient(binding, remoteAddress);;


            DateTime Startdt = new DateTime(2018, 01, 02);
            DateTime?dt;
            int?     CodePost = 0;
            int?     CodePodr = 0;

            SrvGes.get_invoice_by_code_T_goodsRow[] GoodsOfInvoice = new  SrvGes.get_invoice_by_code_T_goodsRow[0];
            string res = Cl.get_invoice_by_code(InvNum, out dt, out CodePost, out CodePodr, out GoodsOfInvoice);

            SrvGes.get_GestoriGoods_T_GestoriGoodsRow[] Goods = new  SrvGes.get_GestoriGoods_T_GestoriGoodsRow[0];
            string res2 = Cl.get_GestoriGoods(CodePodr, out Goods);

            dt = dt.Value.AddHours((new Random()).Next(9, 20));
            dt = dt.Value.AddMinutes((new Random()).Next(0, 59));
            PDiscountCard.FRSSrv.AddCheckResponce Resp = new PDiscountCard.FRSSrv.AddCheckResponce();
            Resp.Attrs              = new PDiscountCard.FRSSrv.FRAttributes();
            Resp.Attrs.FNNumber     = "25765186321863";
            Resp.Attrs.INN          = "712306990379";
            Resp.Attrs.Klishe       = (new List <string> {
                "ООО ТРИНИТИ", "г. Москва, ул. Лесная, д.15"
            }).ToArray();
            Resp.Attrs.RN           = "00044887033128";
            Resp.Attrs.Smena        = (dt.Value - Startdt).Days;
            Resp.Attrs.TaxId        = 1;
            Resp.Attrs.TaxName      = "А: СУММА НДС 18%";
            Resp.Attrs.TaxPercent   = 1800;
            Resp.Attrs.TaxSystem    = "ОСН";
            Resp.Attrs.ZN           = "00307402685302";
            Resp.Attrs.PaymentNames = new Dictionary <int, string>();
            Resp.Attrs.PaymentNames.Add(1, "Наличные");

            Resp.Result                        = true;
            Resp.Check                         = new PDiscountCard.FRSSrv.FiskalCheck();
            Resp.Check.FROutData               = new PDiscountCard.FRSSrv.FCheckOutData();
            Resp.Check.FROutData.SmallNum      = (new Random()).Next(250);
            Resp.Check.FROutData.FD            = Resp.Attrs.Smena * 250 + Resp.Check.FROutData.SmallNum;
            Resp.Check.FROutData.FN            = "9283440300141038";
            Resp.Check.FROutData.FP            = (new Random()).Next(99999).ToString("00000") + (new Random()).Next(99999).ToString("00000");
            Resp.Check.FROutData.OperationType = 0;
            Resp.Check.FROutData.Smena         = Resp.Attrs.Smena;
            Resp.Check.SystemDate              = dt.Value;

            List <PDiscountCard.FRSSrv.FiskalDish> DL = new List <PDiscountCard.FRSSrv.FiskalDish> ();
            double Summ = 0;


            foreach (SrvGes.get_invoice_by_code_T_goodsRow G in GoodsOfInvoice)
            {
                string GName = Goods.Where(a => a.bar_cod == G.cod_good).First().good_name;
                PDiscountCard.FRSSrv.FiskalDish Fd = new PDiscountCard.FRSSrv.FiskalDish();
                Fd.Name  = GName;
                Fd.Price = G.price.Value;
                Fd.Count = G.quantity.Value;
                DL.Add(Fd);
                Summ += (double)Fd.Price * (double)Fd.Count;
                Resp.Check.Dishes = DL.ToArray();
            }
            Resp.Check.FROutData.FNSumm  = (decimal)Summ;
            Resp.Check.FROutData.SysDt   = dt.Value;
            Resp.Check.FROutData.QRAsStr = GetQRstr(Resp.Check.FROutData);
            List <PDiscountCard.FRSSrv.FiskalPayment> LP = new List <PDiscountCard.FRSSrv.FiskalPayment> ();

            LP.Add(
                new  PDiscountCard.FRSSrv.FiskalPayment()
            {
                Id   = 1,
                Summ = (decimal)Summ
            });

            //   List<Resp.Check.Payments>  LP = new List<Resp.Check.Payments> ();

            Resp.Check.Payments = LP.ToArray();
            //Resp.Check.FROutData.FNSumm="4444";

            PDiscountCard.FRSClientApp.PrintOnWinPrinter.PrintDoc2(new PDiscountCard.FRSClientApp.PrintDocArgs()
            {
                FStrs = PDiscountCard.FRSClientApp.FiscalCheckCreator.GetFisckalCheckVisual(Resp), QRAsStr = Resp.Check.FROutData.QRAsStr
            });
        }
Esempio n. 32
0
        internal static RegistrationService.IRegistrationServices GetRegistrationProcessClient()
        {
            if (_registrationServiceClient == null)
            {
                System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(RegistrationProcessServiceUrl);
                System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.None);
                binding.MaxReceivedMessageSize = Int32.MaxValue;

                binding.CloseTimeout = new TimeSpan(0, 30, 0);
                binding.OpenTimeout = new TimeSpan(0, 30, 0);
                binding.ReceiveTimeout = new TimeSpan(0, 30, 0);
                binding.SendTimeout = new TimeSpan(0, 30, 0);

                _registrationServiceClient = new RegistrationService.RegistrationServicesClient(binding, address);
            }
               _registrationServiceClient.SetFPApplication(ServiceReferences.FPApplication);
            return _registrationServiceClient;
        }
Esempio n. 33
0
        /// <summary>
        /// Construct method
        /// </summary>
        private void Construct()
        {
            try
            {
                this.config = Configuration.GetNewInstance();

                //this.importWorker = new BackgroundWorker();
                //this.importWorker.WorkerSupportsCancellation = true;

                //this.requestWorker = new BackgroundWorker();
                //this.requestWorker.WorkerSupportsCancellation = true;

                if (config.Settings.WebServiceAuthMode == 1) // 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 = config.Settings.WebServiceMaxBufferPoolSize;
                    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;
                    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.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(config.Settings.WebServiceEndpointAddress);

                    client = new SurveyManagerService.ManagerServiceClient(binding, endpoint);

                    client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                    client.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
                }
                else
                {
                    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 = config.Settings.WebServiceMaxBufferPoolSize;
                    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;
                    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(config.Settings.WebServiceEndpointAddress);

                    client = new SurveyManagerService.ManagerServiceClient(binding, endpoint);
                }
                this.wfList = new List<WebFieldData>();
            }
            catch (Exception ex)
            {
                //SetStatusMessage("Error: Web service information was not found.");
            }
        }
Esempio n. 34
0
        /**
         * <summary> Constructor for the <c>Connection</c> class for instantiation from Powershell.
         * <example> For use in powershell:
         * <code>
         * # Load the DLL into your Powershell session
         * Add-Type -Path "$PSScriptRoot\bin\Zenworks.dll"
         *
         * # Create a [Zenworks.Connection] instance using valid Zenworks credentials assuming
         * # the Zenworks service is running on "localhost" (i.e. code is running on a Zenworks primary)
         * $ZCMServer = "localhost"
         * $UserName = "******"
         * $Password = "******"
         * $ZenworksSOAPConnection = [Zenworks.Connection]::new($ZCMServer, $UserName, $Password)
         *
         * # Get the properties of the "/Bundles" folder
         * $ZenworksSOAPConnection.BundleAdmin.GetByUID("/Bundles")
         * </code>
         * </example>
         * </summary>
         */
        public Connection(string ZenworksServer, string UserName, string Password, string AddressingScheme = "http://")
        {
            // Variable to hold the constructed endpoint address for the creation of a new instance
            // of the respective ServiceClient class. The variable is being re-purposed for each
            // instantiation of
            System.ServiceModel.EndpointAddress ZenworksSOAPAddress;

            // The HTTP binding needs to be constructed differently depending on whether TLS is in use or not
            if (AddressingScheme == "https://")
            {
                this.ZenworksSOAPBinding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.Transport);
            }
            else
            {
                this.ZenworksSOAPBinding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly);
            }
            // Credential type is always "Basic" for HTTP basic authentication.
            this.ZenworksSOAPBinding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Basic;

            // increase the buffer and message sizes to 10 MB each as the defaults are too small for
            // the larger response messages returned by the Zenworks web services
            this.ZenworksSOAPBinding.MaxReceivedMessageSize = 10485760;
            this.ZenworksSOAPBinding.MaxBufferSize          = 10485760;

            // Initialize the BundleAdmin SOAP object for use with Powershell
            ZenworksSOAPAddress = new System.ServiceModel.EndpointAddress(AddressingScheme + ZenworksServer + "/zenworks-bundleadmin");
            this.BundleAdmin    = new Bundle.BundleAdminServiceClient(this.ZenworksSOAPBinding, ZenworksSOAPAddress);
            this.BundleAdmin.ClientCredentials.UserName.UserName = UserName;
            this.BundleAdmin.ClientCredentials.UserName.Password = Password;

            // Initialize the SettingsAdmin SOAP object for use with Powershell
            ZenworksSOAPAddress = new System.ServiceModel.EndpointAddress(AddressingScheme + ZenworksServer + "/zenworks-settingsadmin");
            this.SettingsAdmin  = new SystemSettings.SystemSettingsServiceClient(this.ZenworksSOAPBinding, ZenworksSOAPAddress);
            this.SettingsAdmin.ClientCredentials.UserName.UserName = UserName;
            this.SettingsAdmin.ClientCredentials.UserName.Password = Password;

            // Initialize the AssignmentAdmin SOAP object for use with Powershell
            ZenworksSOAPAddress  = new System.ServiceModel.EndpointAddress(AddressingScheme + ZenworksServer + "/zenworks-assignmentadmin");
            this.AssignmentAdmin = new Assignment.AssignmentServiceClient(this.ZenworksSOAPBinding, ZenworksSOAPAddress);
            this.AssignmentAdmin.ClientCredentials.UserName.UserName = UserName;
            this.AssignmentAdmin.ClientCredentials.UserName.Password = Password;

            // Initialize the DeviceAdmin SOAP object for use with Powershell
            ZenworksSOAPAddress = new System.ServiceModel.EndpointAddress(AddressingScheme + ZenworksServer + "/zenworks-deviceadmin");
            this.DeviceAdmin    = new Device.DeviceAdminServiceClient(this.ZenworksSOAPBinding, ZenworksSOAPAddress);
            this.DeviceAdmin.ClientCredentials.UserName.UserName = UserName;
            this.DeviceAdmin.ClientCredentials.UserName.Password = Password;

            // Initialize the UserAdmin SOAP object for use with Powershell
            ZenworksSOAPAddress = new System.ServiceModel.EndpointAddress(AddressingScheme + ZenworksServer + "/zenworks-useradmin");
            this.UserAdmin      = new User.UserAdminServiceClient(this.ZenworksSOAPBinding, ZenworksSOAPAddress);
            this.UserAdmin.ClientCredentials.UserName.UserName = UserName;
            this.UserAdmin.ClientCredentials.UserName.Password = Password;

            // Initialize the AdministratorAdmin SOAP object for use with Powershell
            ZenworksSOAPAddress     = new System.ServiceModel.EndpointAddress(AddressingScheme + ZenworksServer + "/zenworks-administratoradmin");
            this.AdministratorAdmin = new Administrator.AdministratorAdminServiceClient(this.ZenworksSOAPBinding, ZenworksSOAPAddress);
            this.AdministratorAdmin.ClientCredentials.UserName.UserName = UserName;
            this.AdministratorAdmin.ClientCredentials.UserName.Password = Password;

            // Initialize the RegistrationAdmin SOAP object for use with Powershell
            ZenworksSOAPAddress    = new System.ServiceModel.EndpointAddress(AddressingScheme + ZenworksServer + "/zenworks-registrationadmin");
            this.RegistrationAdmin = new Registration.RegistrationAdminServiceClient(this.ZenworksSOAPBinding, ZenworksSOAPAddress);
            this.RegistrationAdmin.ClientCredentials.UserName.UserName = UserName;
            this.RegistrationAdmin.ClientCredentials.UserName.Password = Password;

            // Initialize the GroupingAdmin SOAP object for use with Powershell
            ZenworksSOAPAddress = new System.ServiceModel.EndpointAddress(AddressingScheme + ZenworksServer + "/zenworks-groupingadmin");
            this.GroupingAdmin  = new Grouping.GroupingServiceClient(this.ZenworksSOAPBinding, ZenworksSOAPAddress);
            this.GroupingAdmin.ClientCredentials.UserName.UserName = UserName;
            this.GroupingAdmin.ClientCredentials.UserName.Password = Password;

            ZenworksSOAPAddress   = new System.ServiceModel.EndpointAddress(AddressingScheme + ZenworksServer + "/zenworks-credentialsadmin");
            this.CredentialsAdmin = new Credentials.CredentialsAdminServiceClient(this.ZenworksSOAPBinding, ZenworksSOAPAddress);
            this.CredentialsAdmin.ClientCredentials.UserName.UserName = UserName;
            this.CredentialsAdmin.ClientCredentials.UserName.Password = Password;
        } // Connection() constructor
Esempio n. 35
0
        public OperationResult ExecuteOperation(OperationInput input)
        {
            this.product = "2700,2701,2702,2703,2704,2705,2706,2707,2708,2709,2734";
            this.package = "pkgBorgCheck,pkgBorgVerify,pkgBorgMoveUpdate,pkgBorgGeoPoint,pkgBorgAppend,pkgBorgAppend,pkgBorgAppend,pkgBorgAppend,pkgBorgGeoCode,pkgIntAddressCheck,pkgIntGeoCode";

            if (this.system.Contains("credit"))
            {
                this.serviceUri = new Uri(CheckInputSizeRequest(licensekey));
                HttpWebRequest mykHttpWebRequest = null;
                HttpWebResponse mykHttpWebResponse = null;
                XmlDocument mykXMLDocument = null;
                XmlTextReader mykXMLReader = null;
                mykHttpWebRequest = WebRequest.Create(serviceUri) as HttpWebRequest;
                mykHttpWebRequest.Timeout = 60000;
                mykHttpWebRequest.ReadWriteTimeout = 60000;
                mykHttpWebRequest.Method = "GET";
                mykHttpWebRequest.ContentType = "application/xml; charset=utf-8";
                mykHttpWebRequest.Accept = "application/xml";

                bool calloutSuccess = false;
                while (!calloutSuccess)
                {
                    try
                    {
                        mykHttpWebResponse = (HttpWebResponse)mykHttpWebRequest.GetResponse();
                        calloutSuccess = true;
                    }
                    catch (WebException e)
                    {
                        calloutSuccess = false;
                    }
                }

                mykXMLDocument = new XmlDocument();
                mykXMLReader = new XmlTextReader(mykHttpWebResponse.GetResponseStream());
                mykXMLDocument.Load(mykXMLReader);
                XmlNode krequestNode = mykXMLDocument.DocumentElement.ChildNodes[2];
                int creditbalance;

                try
                {
                    if (input.Input[0].ObjectDefinitionFullName.Contains("Personator"))
                    {
                        this.row++;
                        this.counter++;
                        creditbalance = int.Parse(krequestNode.InnerText);
                    }
                    else
                    {
                        this.row++;
                        this.counter = this.counter + 20;
                        creditbalance = int.Parse(krequestNode.InnerText);
                    }
                }
                catch
                {
                    Logger.Write(Logger.Severity.Info, "Data Results", "Empty List");
                    Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException.ReferenceEquals("Data Results", "Empty List").ToString();
                    throw new System.ArgumentException("Data Results", "Empty List");
                }

                if (creditbalance > this.counter)
                {
                    this.IsConnected = true;
                    Logger.Write(Logger.Severity.Info, "Credit Check Good", "Successful! Credit Balance: " + creditbalance + "On row: " + this.row);
                }
                else
                {
                    if (this.geo > 0)
                    {
                        chargeGEO();
                    }
                    if (this.IntGeo > 0)
                    {
                        chargeIntGeo();
                    }
                    if (this.IntCheck > 0)
                    {
                        chargeIntCheck();
                    }
                    if (this.check > 0)
                    {
                        chargeCheck();
                    }
                    if (this.move > 0)
                    {
                        chargeMove();
                    }
                    if (this.verify > 0)
                    {
                        chargeVerify();
                    }
                    if (this.GeoBasic > 0)
                    {
                        chargeGeoCodeBasic();
                    }
                    if ((this.appendaddress > 0) || (this.appendphone > 0) || (this.appendemail > 0) || (this.appendname > 0))
                    {
                        chargeAppend();
                    }

                    Logger.Write(Logger.Severity.Info, "Process Exception", " Not enough Credits for row: " + this.row + " Estimated Balance: " + (creditbalance - this.counter) + ", Please purchase more credits at http://www.melissadata.com/dqt/credits.htm");
                    this.IsConnected = false;
                    throw new Scribe.Core.ConnectorApi.Exceptions.FatalErrorException("Processing Exception: Not enough Credits for row: " + this.row + " Estimated Balance: " + (creditbalance - this.counter) + ", Please purchase more credits at http://www.melissadata.com/dqt/credits.htm");
                }
            }

            ErrorResult[] ErrorResultArray = new ErrorResult[input.Input.Length];
            int[] ObjectsAffectedArray = new int[input.Input.Length];
            bool[] SuccessArray = new bool[input.Input.Length];
            var outputEntityArray = new DataEntity[input.Input.Length];

            if (input.Input[0].ObjectDefinitionFullName.Contains("Personator") || input.Input[0].ObjectDefinitionFullName.Contains("BulkPersonator"))
            {
                System.ServiceModel.BasicHttpBinding myBinding = new System.ServiceModel.BasicHttpBinding();
                myBinding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
                myBinding.MaxReceivedMessageSize = 900000000;
                System.ServiceModel.EndpointAddress myEndpointAddress = new System.ServiceModel.EndpointAddress("https://personator.melissadata.net/v3/SOAP/ContactVerify");
                SOAP.ServicemdContactVerifySOAPClient client = new SOAP.ServicemdContactVerifySOAPClient(myBinding, myEndpointAddress);
                SOAP.Request request = new SOAP.Request();
                request.CustomerID = licensekey;
                int numLoops = 0;
                if ((input.Input.Length % 100) == 0)
                {
                    numLoops = (int)(input.Input.Length / 100);
                }
                else
                {
                    numLoops = (int)(input.Input.Length / 100) + 1;
                }

                for (int i = 0; i < numLoops; i++)
                {
                    DataEntity data = null;
                    int floorDiv = (int)(input.Input.Length / 100);
                    int innerCount = 0;
                    request.Records = new SOAP.RequestRecord[((i < floorDiv) ? 100 : input.Input.Length % 100)];

                    for (int j = 0; j < ((i < floorDiv) ? 100 : input.Input.Length % 100); j++)
                    {
                        request.Records[j] = new SOAP.RequestRecord();
                        data = input.Input[innerCount];

                        if (data.Properties.ContainsKey("Input_RecordID"))
                        {
                            if (data.Properties["Input_RecordID"] == null)
                            {
                                request.Records[j].RecordID = "";
                            }
                            else
                            {
                                request.Records[j].RecordID = data.Properties["Input_RecordID"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_City"))
                        {
                            if (data.Properties["Input_City"] == null)
                            {
                                request.Records[j].City = "";
                            }
                            else
                            {
                                request.Records[j].City = data.Properties["Input_City"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_State"))
                        {
                            if (data.Properties["Input_State"] == null)
                            {
                                request.Records[j].State = "";
                            }
                            else
                            {
                                request.Records[j].State = data.Properties["Input_State"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_PostalCode"))
                        {
                            if (data.Properties["Input_PostalCode"] == null)
                            {
                                request.Records[j].PostalCode = "";
                            }
                            else
                            {
                                request.Records[j].PostalCode = data.Properties["Input_PostalCode"].ToString();
                            }
                        }

                        if ((data.Properties.ContainsKey("Setting_Columns")))
                        {
                            string Columns = data.Properties["Setting_Columns"].ToString();
                            string[] cols;
                            char[] charcolSeparators = new char[] { ',' };
                            cols = Columns.Split(charcolSeparators, 8, StringSplitOptions.RemoveEmptyEntries);
                            for (int c = 0; c < cols.Length; c++)
                            {
                                if ((data.Properties.ContainsKey("Setting_Columns")) && !cols[c].ToString().Trim().ToLower().Equals("grpaddressdetails") && (!cols[c].ToString().Trim().ToLower().Equals("grpcensus")) && (!cols[c].ToString().Trim().ToLower().Equals("grpgeocode")) && (!cols[c].ToString().Trim().ToLower().Equals("grpnamedetails")) && (!cols[c].ToString().Trim().ToLower().Equals("grpparsedaddress")) && (!cols[c].ToString().Trim().ToLower().Equals("grpparsedemail")) && (!cols[c].ToString().Trim().ToLower().Equals("grpparsedphone")) && (!cols[c].ToString().Trim().ToLower().Equals("grpall")) && (!cols[c].ToString().Trim().ToLower().Equals("grpdemographicbasic")))
                                {
                                    throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid Action, action must be either ({blank}, GrpAddressDetails, GrpCensus, GrpGeocode, GrpNameDetails, GrpParsedAddress, GrpParsedEmail, GrpParsedPhone, GrpAll");
                                }
                                else
                                {
                                    request.Columns = (!data.Properties.ContainsKey("Setting_Columns") ? "" : data.Properties["Setting_Columns"].ToString());
                                }
                            }
                        }

                        if (data.Properties.ContainsKey("Setting_Actions"))
                        {
                            if (data.Properties["Setting_Actions"] == null)
                            {
                                request.Actions = "check";
                            }
                            else
                            {
                                request.Actions = data.Properties["Setting_Actions"].ToString();
                            }
                        }
                        else
                        {
                            request.Actions = "check";
                        }

                        if ((data.Properties.ContainsKey("Setting_Actions")))
                        {
                            string Actions = data.Properties["Setting_Actions"].ToString();
                            string[] act;
                            char[] charSeparators = new char[] { ',' };
                            act = Actions.Split(charSeparators, 4, StringSplitOptions.RemoveEmptyEntries);
                            for (int k = 0; k < act.Length; k++)
                            {
                                if ((data.Properties.ContainsKey("Setting_Actions")) && !act[k].ToString().Trim().ToLower().Equals("append") && (!act[k].ToString().Trim().ToLower().Equals("check")) && (!act[k].ToString().Trim().ToLower().Equals("verify")) && (!act[k].ToString().Trim().ToLower().Equals("move")))
                                {
                                    throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid Action, action must be either (Check, Verify, Append, Move");
                                }
                                else
                                {
                                    request.Actions = (!data.Properties.ContainsKey("Setting_Actions") ? "Check" : data.Properties["Setting_Actions"].ToString());
                                }
                            }
                        }

                        if ((data.Properties.ContainsKey("Setting_AdvancedAddressCorrection")) && (!data.Properties["Setting_AdvancedAddressCorrection"].ToString().Trim().ToLower().Equals("on") && (!data.Properties["Setting_AdvancedAddressCorrection"].ToString().Trim().ToLower().Equals("off"))))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid AdvancedAddressCorrection Property, action must be either (on, off");
                        }
                        else
                        {
                            request.Options = request.Options + "AdvancedAddressCorrection:" + (!data.Properties.ContainsKey("Setting_AdvancedAddressCorrection") ? "off;" : data.Properties["Setting_AdvancedAddressCorrection"].ToString() + ";");
                        }

                        if ((data.Properties.ContainsKey("Setting_CentricHint")) && (!data.Properties["Setting_CentricHint"].ToString().Trim().ToLower().Equals("auto")) && (!data.Properties["Setting_CentricHint"].ToString().Trim().ToLower().Equals("address")) && (!data.Properties["Setting_CentricHint"].ToString().Trim().ToLower().Equals("phone")) && (!data.Properties["Setting_CentricHint"].ToString().Trim().ToLower().Equals("email")))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid CentricHint Property, action must be either (auto, address, phone, email");
                        }
                        else
                        {
                            request.Options = request.Options + "CentricHint:" + (!data.Properties.ContainsKey("Setting_CentricHint") ? "off;" : data.Properties["Setting_CentricHint"].ToString() + ";");
                        }
                        if ((data.Properties.ContainsKey("Setting_Append")) && (!data.Properties["Setting_Append"].ToString().Trim().ToLower().Equals("blank")) && (!data.Properties["Setting_Append"].ToString().Trim().ToLower().Equals("checkerror")) && (!data.Properties["Setting_Append"].ToString().Trim().ToLower().Equals("always")))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid Append Property, action must be either (checkerror, blank, always");
                        }
                        else
                        {
                            request.Options = request.Options + "Append:" + (!data.Properties.ContainsKey("Setting_Append") ? "Always;" : data.Properties["Setting_Append"].ToString() + ";");
                        }

                        if ((data.Properties.ContainsKey("Setting_UsePreferredCity")) && (!data.Properties["Setting_UsePreferredCity"].ToString().Trim().ToLower().Equals("on")) && (!data.Properties["Setting_UsePreferredCity"].ToString().Trim().ToLower().Equals("off")))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid Append Property, action must be either (off, on)");
                        }
                        else
                        {
                            request.Options = request.Options + "UsePreferredCity:" + (!data.Properties.ContainsKey("Setting_UsePreferredCity") ? "off;" : data.Properties["Setting_UsePreferredCity"].ToString() + ";");
                        }

                        if (data.Properties.ContainsKey("Input_AddressLine2"))
                        {
                            if (data.Properties["Input_AddressLine2"] == null)
                            {
                                request.Records[j].AddressLine2 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine2 = data.Properties["Input_AddressLine2"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_Country"))
                        {
                            if (data.Properties["Input_Country"] == null)
                            {
                                request.Records[j].Country = "";
                            }
                            else
                            {
                                request.Records[j].Country = data.Properties["Input_Country"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_CompanyName"))
                        {
                            if (data.Properties["Input_CompanyName"] == null)
                            {
                                request.Records[j].CompanyName = "";
                            }
                            else
                            {
                                request.Records[j].CompanyName = data.Properties["Input_CompanyName"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_FullName"))
                        {
                            if (data.Properties["Input_FullName"] == null)
                            {
                                request.Records[j].FullName = "";
                            }
                            else
                            {
                                request.Records[j].FullName = data.Properties["Input_FullName"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_LastName"))
                        {
                            if (data.Properties["Input_LastName"] == null)
                            {
                                request.Records[j].LastName = "";
                            }
                            else
                            {
                                request.Records[j].LastName = data.Properties["Input_LastName"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_PhoneNumber"))
                        {
                            if (data.Properties["Input_PhoneNumber"] == null)
                            {
                                request.Records[j].PhoneNumber = "";
                            }
                            else
                            {
                                request.Records[j].PhoneNumber = data.Properties["Input_PhoneNumber"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Input_AddressLine1"))
                        {
                            if (data.Properties["Input_AddressLine1"] == null)
                            {
                                request.Records[j].AddressLine1 = "";
                            }
                            else
                            {
                                request.Records[j].City = request.Records[j].City != null ? request.Records[j].City.Trim() : "";
                                request.Records[j].State = request.Records[j].State != null ? request.Records[j].State.Trim() : "";
                                request.Records[j].PostalCode = request.Records[j].PostalCode != null ? request.Records[j].PostalCode.Trim() : "";
                                request.Records[j].FreeForm = request.Records[j].FreeForm != null ? request.Records[j].FreeForm.Trim() : "";

                                if (request.Records[j].City == "" && request.Records[j].State == "" && request.Records[j].PostalCode == "" && request.Records[j].FreeForm == "")
                                {
                                    request.Records[j].AddressLine1 = "";
                                    request.Records[j].FreeForm = data.Properties["Input_AddressLine1"].ToString();
                                }
                                else
                                {
                                    request.Records[j].AddressLine1 = data.Properties["Input_AddressLine1"].ToString();
                                }
                            }
                        }

                        if (data.Properties.ContainsKey("Input_FreeForm"))
                        {
                            if (data.Properties["Input_FreeForm"] == null)
                            {
                                request.Records[j].FreeForm = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine1 = "";
                                request.Records[j].FreeForm = data.Properties["Input_FreeForm"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_EmailAddress"))
                        {
                            if (data.Properties["Input_EmailAddress"] == null)
                            {
                                request.Records[j].EmailAddress = "";
                            }
                            else
                            {
                                request.Records[j].EmailAddress = data.Properties["Input_EmailAddress"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Setting_Columns"))
                        {
                            if (data.Properties["Setting_Columns"] == null)
                            {
                                request.Columns = "";
                            }
                            else
                            {
                                request.Columns = data.Properties["Setting_Columns"].ToString();
                            }
                        }

                        if (request.Records[j].PostalCode == "" && request.Records[j].State == "" && request.Records[j].City == "" && request.Records[j].FreeForm == "")
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("City, State or Zipcode or Freeform required.");
                        }

                        innerCount++;
                    }

                    this.serviceUri = new Uri(RequestToken(licensekey, this.product, this.package, ((i < floorDiv) ? 100 : input.Input.Length % 100).ToString()));
                    HttpWebRequest myeHttpWebRequest = null;
                    HttpWebResponse myeHttpWebResponse = null;
                    XmlDocument myXMLDocument = null;
                    XmlTextReader myXMLReader = null;
                    myeHttpWebRequest = WebRequest.Create(serviceUri) as HttpWebRequest;
                    myeHttpWebRequest.Timeout = 60000;
                    myeHttpWebRequest.ReadWriteTimeout = 60000;
                    myeHttpWebRequest.Method = "GET";
                    myeHttpWebRequest.ContentType = "application/xml; charset=utf-8";
                    myeHttpWebRequest.Accept = "application/xml";

                    bool success = false;
                    while (!success)
                    {
                        try
                        {
                            myeHttpWebResponse = (HttpWebResponse)myeHttpWebRequest.GetResponse();
                            success = true;
                        }
                        catch (WebException e)
                        {
                            success = false;
                        }
                    }

                    myXMLDocument = new XmlDocument();

                    myXMLReader = new XmlTextReader(myeHttpWebResponse.GetResponseStream());
                    myXMLDocument.Load(myXMLReader);
                    XmlNode resultNode = myXMLDocument.DocumentElement.ChildNodes[0];
                    XmlNode tokenNode = myXMLDocument.DocumentElement.ChildNodes[1];
                    if (resultNode.InnerText.Contains("TS01") || resultNode.InnerText.Contains("TS02"))
                    {
                        request.CustomerID = tokenNode.InnerText;
                        Logger.Write(Logger.Severity.Info, "Connection Results", "Token Successful");
                    }
                    else
                    {
                        Logger.Write(Logger.Severity.Info, "Connection Results", "Token Successful");
                    }
                    SOAP.Response response = null;

                    while (response == null)
                    {
                        try
                        {
                            response = client.doContactVerify(request);
                        }
                        catch (Exception e)
                        {
                        }
                    }
                    for (int l = 0; l < response.Records.Length; l++)
                    {
                        List<PropertyInfo> responseProperties = response.Records[l].GetType().GetProperties().ToList();

                        var output = new DataEntity(input.Input[100 * i + l].ObjectDefinitionFullName);
                        if ((response.Records[l].Results.Contains("AS")))
                        {
                            this.check++;
                        }
                        if (response.Records[l].Results.Contains("GS05") || response.Records[l].Results.Contains("GS06"))
                        {
                            this.geo++;
                        }
                        if (response.Records[l].Results.Contains("GS01"))
                        {
                            this.GeoBasic++;
                        }
                        if (response.Records[l].Results.Contains("VR"))
                        {
                            this.verify++;
                        }
                        if (response.Records[l].Results.Contains("AS12"))
                        {
                            this.move++;
                        }
                        if (response.Records[l].Results.Contains("DA10"))
                        {
                            this.appendname++;
                        }
                        if (response.Records[l].Results.Contains("DA00"))
                        {
                            this.appendaddress++;
                        }
                        if (response.Records[l].Results.Contains("DA30"))
                        {
                            this.appendphone++;
                        }
                        if (response.Records[l].Results.Contains("DA40"))
                        {
                            this.appendemail++;
                        }
                        foreach (PropertyInfo property in responseProperties)
                        {
                            string getValue = property.GetValue(response.Records[l], null) != null ? property.GetValue(response.Records[l], null).ToString() : "";

                            output.Properties["MD_" + property.Name] = getValue;
                        }

                        outputEntityArray[i * 100 + l] = output;
                    }
                }

                ErrorResultArray = new ErrorResult[input.Input.Length];
                ObjectsAffectedArray = new int[input.Input.Length];
                SuccessArray = new bool[input.Input.Length];

                for (int x = 0; x < input.Input.Length; x++)
                {
                    ErrorResultArray[x] = new ErrorResult();
                    ObjectsAffectedArray[x] = 1;
                    SuccessArray[x] = true;
                }
            }

            if (input.Input[0].ObjectDefinitionFullName.Contains("Global_Address_Verification") || input.Input[0].ObjectDefinitionFullName.Contains("BulkGlobal"))
            {
                System.ServiceModel.BasicHttpBinding myBinding = new System.ServiceModel.BasicHttpBinding();
                myBinding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
                myBinding.MaxReceivedMessageSize = 900000000;
                System.ServiceModel.EndpointAddress myEndpointAddress = new System.ServiceModel.EndpointAddress("https://address.melissadata.net/v3/SOAP/GlobalAddress");
                SOAP3.AddressCheckSoapClient client = new SOAP3.AddressCheckSoapClient(myBinding, myEndpointAddress);
                SOAP3.Request request = new SOAP3.Request();
                request.CustomerID = licensekey;
                int numLoops = 0;
                if ((input.Input.Length % 100) == 0)
                {
                    numLoops = (int)(input.Input.Length / 100);
                }
                else
                {
                    numLoops = (int)(input.Input.Length / 100) + 1;
                }

                for (int i = 0; i < numLoops; i++)
                {
                    DataEntity data = null;
                    int floorDiv = (int)(input.Input.Length / 100);
                    int innerCount = 0;
                    request.Records = new SOAP3.RequestRecord[((i < floorDiv) ? 100 : input.Input.Length % 100)];
                    for (int j = 0; j < ((i < floorDiv) ? 100 : input.Input.Length % 100); j++)
                    {
                        request.Records[j] = new SOAP3.RequestRecord();
                        data = input.Input[innerCount];

                        if (data.Properties.ContainsKey("Input_RecordID"))
                        {
                            if (data.Properties["Input_RecordID"] == null)
                            {
                                request.Records[j].RecordID = "";
                            }
                            else
                            {
                                request.Records[j].RecordID = data.Properties["Input_RecordID"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_Organization"))
                        {
                            if (data.Properties["Input_Organization"] == null)
                            {
                                request.Records[j].Organization = "";
                            }
                            else
                            {
                                request.Records[j].Organization = data.Properties["Input_Organization"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Input_AddressLine1"))
                        {
                            if (data.Properties["Input_AddressLine1"] == null)
                            {
                                request.Records[j].AddressLine1 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine1 = data.Properties["Input_AddressLine1"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_AddressLine2"))
                        {
                            if (data.Properties["Input_AddressLine2"] == null)
                            {
                                request.Records[j].AddressLine2 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine2 = data.Properties["Input_AddressLine2"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_AddressLine3"))
                        {
                            if (data.Properties["Input_AddressLine3"] == null)
                            {
                                request.Records[j].AddressLine3 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine3 = data.Properties["Input_AddressLine3"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Input_AddressLine4"))
                        {
                            if (data.Properties["Input_AddressLine4"] == null)
                            {
                                request.Records[j].AddressLine4 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine4 = data.Properties["Input_AddressLine4"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_AddressLine5"))
                        {
                            if (data.Properties["Input_AddressLine5"] == null)
                            {
                                request.Records[j].AddressLine5 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine5 = data.Properties["Input_AddressLine5"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_AddressLine6"))
                        {
                            if (data.Properties["Input_AddressLine6"] == null)
                            {
                                request.Records[j].AddressLine6 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine6 = data.Properties["Input_AddressLine6"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_AddressLine7"))
                        {
                            if (data.Properties["Input_AddressLine7"] == null)
                            {
                                request.Records[j].AddressLine7 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine7 = data.Properties["Input_AddressLine7"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_AddressLine8"))
                        {
                            if (data.Properties["Input_AddressLine8"] == null)
                            {
                                request.Records[j].AddressLine8 = "";
                            }
                            else
                            {
                                request.Records[j].AddressLine8 = data.Properties["Input_AddressLine8"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_DoubleDependentLocality"))
                        {
                            if (data.Properties["Input_DoubleDependentLocality"] == null)
                            {
                                request.Records[j].DoubleDependentLocality = "";
                            }
                            else
                            {
                                request.Records[j].DoubleDependentLocality = data.Properties["Input_DoubleDependentLocality"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_DependentLocality"))
                        {
                            if (data.Properties["Input_DependentLocality"] == null)
                            {
                                request.Records[j].DependentLocality = "";
                            }
                            else
                            {
                                request.Records[j].DependentLocality = data.Properties["Input_DependentLocality"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Input_Locality"))
                        {
                            if (data.Properties["Input_Locality"] == null)
                            {
                                request.Records[j].Locality = "";
                            }
                            else
                            {
                                request.Records[j].Locality = data.Properties["Input_Locality"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_SubAdministrativeArea"))
                        {
                            if (data.Properties["Input_SubAdministrativeArea"] == null)
                            {
                                request.Records[j].SubAdministrativeArea = "";
                            }
                            else
                            {
                                request.Records[j].SubAdministrativeArea = data.Properties["Input_SubAdministrativeArea"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Input_AdministrativeArea"))
                        {
                            if (data.Properties["Input_AdministrativeArea"] == null)
                            {
                                request.Records[j].AdministrativeArea = "";
                            }
                            else
                            {
                                request.Records[j].AdministrativeArea = data.Properties["Input_AdministrativeArea"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_PostalCode"))
                        {
                            if (data.Properties["Input_PostalCode"] == null)
                            {
                                request.Records[j].PostalCode = "";
                            }
                            else
                            {
                                request.Records[j].PostalCode = data.Properties["Input_PostalCode"].ToString();
                            }
                        }
                        if (data.Properties.ContainsKey("Input_SubNationalArea"))
                        {
                            if (data.Properties["Input_SubNationalArea"] == null)
                            {
                                request.Records[j].SubNationalArea = "";
                            }
                            else
                            {
                                request.Records[j].SubNationalArea = data.Properties["Input_SubNationalArea"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Input_Country"))
                        {
                            if (data.Properties["Input_Country"] == null)
                            {
                                request.Records[j].Country = "";
                            }
                            else
                            {
                                request.Records[j].Country = data.Properties["Input_Country"].ToString();
                            }
                        }

                        if (data.Properties.ContainsKey("Setting_DeliveryLines"))
                        {
                            if (data.Properties["Setting_DeliveryLines"] == null)
                            {
                                request.Records[j].Country = "";
                            }
                            else
                            {
                                request.Records[j].Country = data.Properties["Setting_DeliveryLines"].ToString();
                            }
                        }

                        if ((data.Properties.ContainsKey("Setting_DeliveryLines")) && (!data.Properties["Setting_DeliveryLines"].ToString().Trim().ToLower().Equals("on") && (!data.Properties["Setting_DeliveryLines"].ToString().Trim().ToLower().Equals("off"))))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid DeliveryLines Property, action must be either (on, off");
                        }
                        else
                        {
                            request.Options = request.Options + "DeliveryLines:" + (!data.Properties.ContainsKey("Setting_DeliveryLines") ? "off;" : data.Properties["Setting_DeliveryLines"].ToString() + ";");
                        }

                        if ((data.Properties.ContainsKey("Setting_LineSeparator")) && (!data.Properties["Setting_LineSeparator"].ToString().Trim().ToLower().Equals("semicolon") && (!data.Properties["Setting_DeliveryLines"].ToString().Trim().ToLower().Equals("pipe") && (!data.Properties["Setting_LineSeparator"].ToString().Trim().ToLower().Equals("cr") && (!data.Properties["Setting_LineSeparator"].ToString().Trim().ToLower().Equals("lf") && (!data.Properties["Setting_LineSeparator"].ToString().Trim().ToLower().Equals("crlf") && (!data.Properties["Setting_LineSeparator"].ToString().Trim().ToLower().Equals("tab") && (!data.Properties["Setting_LineSeparator"].ToString().Trim().ToLower().Equals("br")))))))))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid LineSeparator Property, action must be either (semicolon (default), pipe, cr, lf, crlf, tab, br (line break)");
                        }
                        else
                        {
                            request.Options = request.Options + "LineSeparator:" + (!data.Properties.ContainsKey("LineSeparator") ? "SEMICOLON;" : data.Properties["Setting_DeliveryLines"].ToString() + ";");
                        }

                        if ((data.Properties.ContainsKey("Setting_OutputScript")) && (!data.Properties["Setting_OutputScript"].ToString().Trim().ToLower().Equals("nochange") && (!data.Properties["Setting_OutputScript"].ToString().Trim().ToLower().Equals("latn")) && (!data.Properties["Setting_OutputScript"].ToString().Trim().ToLower().Equals("native"))))
                        {
                            throw new Scribe.Core.ConnectorApi.Exceptions.InvalidExecuteOperationException("Invalid LineSeparator Property, action must be either (nochange (default), latn, native");
                        }
                        else
                        {
                            request.Options = request.Options + "OutputScript:" + (!data.Properties.ContainsKey("Setting_OutputScript") ? "nochange;" : data.Properties["Setting_OutputScript"].ToString() + ";");
                        }

                        if ((data.Properties.ContainsKey("Setting_CountryOfOrigin")))
                        {
                            request.Options = request.Options + "CountryOfOrigin:" + data.Properties["Setting_CountryOfOrigin"].ToString() + ";";
                        }

                        innerCount++;
                    }
                    this.serviceUri = new Uri(RequestToken(licensekey, this.product, this.package, ((i < floorDiv) ? 100 : input.Input.Length % 100).ToString()));

                    HttpWebRequest myeHttpWebRequest = null;
                    HttpWebResponse myeHttpWebResponse = null;
                    XmlDocument myXMLDocument = null;
                    XmlTextReader myXMLReader = null;
                    myeHttpWebRequest = WebRequest.Create(serviceUri) as HttpWebRequest;
                    myeHttpWebRequest.Timeout = 60000;
                    myeHttpWebRequest.ReadWriteTimeout = 60000;
                    myeHttpWebRequest.Method = "GET";
                    myeHttpWebRequest.ContentType = "application/xml; charset=utf-8";
                    myeHttpWebRequest.Accept = "application/xml";

                    bool success = false;
                    while (!success)
                    {
                        try
                        {
                            myeHttpWebResponse = (HttpWebResponse)myeHttpWebRequest.GetResponse();
                            success = true;
                        }
                        catch (WebException e)
                        {
                            success = false;
                        }
                    }

                    myXMLDocument = new XmlDocument();

                    myXMLReader = new XmlTextReader(myeHttpWebResponse.GetResponseStream());
                    myXMLDocument.Load(myXMLReader);
                    XmlNode resultNode = myXMLDocument.DocumentElement.ChildNodes[0];
                    XmlNode tokenNode = myXMLDocument.DocumentElement.ChildNodes[1];
                    if (resultNode.InnerText.Contains("TS01") || resultNode.InnerText.Contains("TS02"))
                    {
                        request.CustomerID = tokenNode.InnerText;
                        Logger.Write(Logger.Severity.Info, "Connection Results", "Token Successful");
                    }

                    SOAP3.Response response = client.doGlobalAddress(request);

                    for (int l = 0; l < response.Records.Length; l++)
                    {
                        List<PropertyInfo> responseProperties = response.Records[l].GetType().GetProperties().ToList();

                        var output = new DataEntity(input.Input[100 * i + l].ObjectDefinitionFullName);

                        if ((response.Records[l].Results.Contains("AV")))
                        {
                            this.IntCheck++;
                        }
                        if (response.Records[l].Results.Contains("GS"))
                        {
                            this.IntGeo++;
                        }

                        foreach (PropertyInfo property in responseProperties)
                        {
                            string getValue = property.GetValue(response.Records[l], null) != null ? property.GetValue(response.Records[l], null).ToString() : "";

                            output.Properties["MD_" + property.Name] = getValue;
                        }

                        outputEntityArray[i * 100 + l] = output;
                    }
                }

                ErrorResultArray = new ErrorResult[input.Input.Length];
                ObjectsAffectedArray = new int[input.Input.Length];
                SuccessArray = new bool[input.Input.Length];

                for (int x = 0; x < input.Input.Length; x++)
                {
                    ErrorResultArray[x] = new ErrorResult();
                    ObjectsAffectedArray[x] = 1;
                    SuccessArray[x] = true;
                }
            }

            foreach (var entity in outputEntityArray)
            {
                bulkQueue.Enqueue(entity);
            }

            return new OperationResult(input.Input.Length)
            {
                ErrorInfo = ErrorResultArray,
                ObjectsAffected = ObjectsAffectedArray,
                Output = outputEntityArray,
                Success = SuccessArray
            };
        }
Esempio n. 36
0
 private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
 {
     if ((endpointConfiguration == EndpointConfiguration.defaultEndpoint))
     {
         System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
         System.ServiceModel.Channels.TextMessageEncodingBindingElement textBindingElement = new System.ServiceModel.Channels.TextMessageEncodingBindingElement();
         result.Elements.Add(textBindingElement);
         System.ServiceModel.Channels.HttpTransportBindingElement httpBindingElement = new System.ServiceModel.Channels.HttpTransportBindingElement();
         httpBindingElement.AllowCookies           = true;
         httpBindingElement.MaxBufferSize          = int.MaxValue;
         httpBindingElement.MaxReceivedMessageSize = int.MaxValue;
         result.Elements.Add(httpBindingElement);
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.defaultBasic))
     {
         System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.AllowCookies           = true;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.basicHttpEndpoint))
     {
         System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.AllowCookies           = true;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.basicHttpsEndpoint))
     {
         System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.AllowCookies           = true;
         result.Security.Mode          = System.ServiceModel.BasicHttpSecurityMode.Transport;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.httpsoap11Endpoint))
     {
         System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.AllowCookies           = true;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.httpsoap12Endpoint))
     {
         System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
         System.ServiceModel.Channels.TextMessageEncodingBindingElement textBindingElement = new System.ServiceModel.Channels.TextMessageEncodingBindingElement();
         result.Elements.Add(textBindingElement);
         System.ServiceModel.Channels.HttpTransportBindingElement httpBindingElement = new System.ServiceModel.Channels.HttpTransportBindingElement();
         httpBindingElement.AllowCookies           = true;
         httpBindingElement.MaxBufferSize          = int.MaxValue;
         httpBindingElement.MaxReceivedMessageSize = int.MaxValue;
         result.Elements.Add(httpBindingElement);
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.httpbinaryEndpoint))
     {
         System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
         result.Elements.Add(new System.ServiceModel.Channels.BinaryMessageEncodingBindingElement());
         System.ServiceModel.Channels.HttpTransportBindingElement httpBindingElement = new System.ServiceModel.Channels.HttpTransportBindingElement();
         httpBindingElement.AllowCookies           = true;
         httpBindingElement.MaxBufferSize          = int.MaxValue;
         httpBindingElement.MaxReceivedMessageSize = int.MaxValue;
         result.Elements.Add(httpBindingElement);
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.httpssoap11Endpoint))
     {
         System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.AllowCookies           = true;
         result.Security.Mode          = System.ServiceModel.BasicHttpSecurityMode.Transport;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.httpssoap12Endpoint))
     {
         System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
         System.ServiceModel.Channels.TextMessageEncodingBindingElement textBindingElement = new System.ServiceModel.Channels.TextMessageEncodingBindingElement();
         result.Elements.Add(textBindingElement);
         System.ServiceModel.Channels.HttpsTransportBindingElement httpsBindingElement = new System.ServiceModel.Channels.HttpsTransportBindingElement();
         httpsBindingElement.AllowCookies           = true;
         httpsBindingElement.MaxBufferSize          = int.MaxValue;
         httpsBindingElement.MaxReceivedMessageSize = int.MaxValue;
         result.Elements.Add(httpsBindingElement);
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.nettcpdefaultBinding))
     {
         System.ServiceModel.NetTcpBinding result = new System.ServiceModel.NetTcpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         return(result);
     }
     if ((endpointConfiguration == EndpointConfiguration.nettcpdefaultBinding1))
     {
         System.ServiceModel.NetTcpBinding result = new System.ServiceModel.NetTcpBinding();
         result.MaxBufferSize          = int.MaxValue;
         result.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
         result.MaxReceivedMessageSize = int.MaxValue;
         result.Security.Mode          = System.ServiceModel.SecurityMode.None;
         return(result);
     }
     throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
 }
        public CompendiumMapDepthMap()
        {
            InitializeComponent();
            
            NodeRelationshipHelper nrh = new NodeRelationshipHelper();
            IoC.IoCContainer.GetInjectionInstance().RegisterComponent<NodeRelationshipHelper>(nrh);
            nrh.NodesConnected += new EventHandler(OnNodesConnected);

            this.MouseMove += new MouseEventHandler(CompendiumMapDepthMap_MouseMove);
            this.KeyDown += new KeyEventHandler(CompendiumMapDepthMap_KeyDown);
            this.MouseRightButtonDown += new MouseButtonEventHandler(CompendiumMapDepthMap_MouseRightButtonDown);
            this.MouseRightButtonUp += new MouseButtonEventHandler(CompendiumMapDepthMap_MouseRightButtonUp);
            this.MouseWheel += new MouseWheelEventHandler(CompendiumMapDepthMap_MouseWheel);
            this.MouseLeftButtonDown += new MouseButtonEventHandler(CompendiumMapDepthMap_MouseLeftButtonDown);
            this.MouseLeftButtonUp += new MouseButtonEventHandler(CompendiumMapDepthMap_MouseLeftButtonUp);
            
            this.Loaded += new RoutedEventHandler(CompendiumMapDepthMap_Loaded);

            if (!IsInDesignMode)
            {
                // TODO: The following code has been superceded;
                #region Obsolete
                if (string.IsNullOrEmpty(MappingToolSvcUrl))
                {
                    _nodeService = new DatabaseMappingService();
                }
                else
                {
                    _nodeService = new DatabaseMappingService(MappingToolSvcUrl);
                }
                IoC.IoCContainer.GetInjectionInstance().RegisterComponent<INodeService>(_nodeService);

                _typeManager = new TypeManager(_nodeService);
                IoC.IoCContainer.GetInjectionInstance().RegisterComponent<TypeManager>(_typeManager);

                _typeManager.InitialiseNodeTypeManagerCompleted += new EventHandler(InitialiseNodeTypeManagerCompleted);
                _typeManager.InitialiseNodeTypeManager();
                #endregion

                // TODO: Need to change this to pull from the params in the HTML declaration itself.
                TransactionalMappingToolSvcUrl = "http://glyma-dev/_vti_bin/sevensigma/transactionalmappingtoolservice.svc";

                System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
                binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly;
                binding.MaxReceivedMessageSize = 2147483647;

                System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(new Uri(TransactionalMappingToolSvcUrl));

                Service.TransactionalMappingToolServiceClient client = new Service.TransactionalMappingToolServiceClient(binding, address);

                //_mapManager = new SoapMapManager(client);

                IoC.IoCContainer.GetInjectionInstance().RegisterComponent<IMapManager>(_mapManager);

                _mapManager.InitialiseMapManagerCompleted += new EventHandler<InitialiseMapManagerEventArgs>(OnInitialiseMapManagerCompleted);
                _mapManager.InitialiseMapManagerAsync();
            }
        }
Esempio n. 38
0
        public PointsEditor(IEnumerable <IHierarchicalEmcosPoint> balancePoints, IEnumerable <IHierarchicalEmcosPoint> otherPoints, IWindowWithDialogs window)
        {
            _rootEmcosGroup = DEFAULT_ROOT_EMCOS_GROUP;
            _window         = window;

            EmcosPoints = new HierarchicalEmcosPointCollection(null, balancePoints);

            OtherPoints = new HierarchicalEmcosPointCollection(null, otherPoints);

            InitializeComponent();
            DataContext = this;

            NewPoints = new List <IHierarchicalEmcosPoint>();

            // настройка сервиса
            System.ServiceModel.Channels.Binding binding = new System.ServiceModel.BasicHttpBinding()
            {
                MaxBufferSize          = 10240000,
                MaxReceivedMessageSize = 10240000,
                Name = "ServiceSoap"
            };
            _emcosWebServiceClient = new EmcosTestWebService.ServiceSoapClient(binding,
                                                                               new System.ServiceModel.EndpointAddress(String.Format("http://{0}/{1}",
                                                                                                                                     EmcosSettings.Default.ServerAddress,
                                                                                                                                     EmcosSettings.Default.WebServiceName)));

            this.Loaded += (s, e) =>
            {
                //await LoadPointsFromServiceAsync();
            };

            CommandUpdate = new DelegateCommand(async() =>
            {
                await LoadPointsFromServiceAsync();
            });

            CommandDelete = new DelegateCommand(() =>
            {
                var dialog     = _window.DialogQuestion(String.Format("Точка '{0}' будет удалена. Вы уверены, что хотите продолжить?", _emcosPointsSelectedValue.Name));
                dialog.YesText = "Да, удалить";
                dialog.NoText  = "Отменить";
                dialog.Yes     = () =>
                {
                    _emcosPointsSelectedValue.Parent.Children.Remove(_emcosPointsSelectedValue);

                    if (NewPoints.Contains(_emcosPointsSelectedValue))
                    {
                        NewPoints.Remove(_emcosPointsSelectedValue);
                    }

                    if (DeletedPoints.Contains(_emcosPointsSelectedValue) == false)
                    {
                        DeletedPoints.Add(_emcosPointsSelectedValue);
                    }
                };
            }, (o) => _emcosPointsSelectedValue != null && _emcosPointsSelectedValue.Parent != null);

            CommandMoveUp = new DelegateCommand(() =>
            {
                int index = _emcosPointsSelectedValue.Parent.Children.IndexOf(_emcosPointsSelectedValue);
                _emcosPointsSelectedValue.Parent.Children.Move(index, index - 1);
            },
                                                (o) => _emcosPointsSelectedValue != null &&
                                                _emcosPointsSelectedValue.Parent != null &&
                                                _emcosPointsSelectedValue.Parent.Children.IndexOf(_emcosPointsSelectedValue) > 0
                                                );

            CommandMoveDown = new DelegateCommand(() =>
            {
                int index = _emcosPointsSelectedValue.Parent.Children.IndexOf(_emcosPointsSelectedValue);
                _emcosPointsSelectedValue.Parent.Children.Move(index, index + 1);
            },
                                                  (o) => _emcosPointsSelectedValue != null &&
                                                  _emcosPointsSelectedValue.Parent != null &&
                                                  _emcosPointsSelectedValue.Parent.Children.IndexOf(_emcosPointsSelectedValue) < _emcosPointsSelectedValue.Parent.ChildrenCount - 1);

            CommandClear = new DelegateCommand(() =>
            {
                var dialog     = _window.DialogQuestion("Список точек будет очищен. Вы уверены, что хотите продолжить?");
                dialog.YesText = "Да, очистить";
                dialog.NoText  = "Отменить";
                dialog.Yes     = () =>
                {
                    DeletedPoints.Clear();
                    DeletedPoints.AddRange(EmcosPoints.FlatItemsList);
                    EmcosPoints.Clear();
                    NewPoints.Clear();
                };
            }, (o) => EmcosPoints != null && EmcosPoints.Count > 0);

            CommandAdd = new DelegateCommand(() =>
            {
                if (_emcosPointsSelectedValue != null)
                {
                    _emcosPointsSelectedValue.Children.Add(_emcosPointsFromSiteSelectedValue);
                }
                else
                {
                    EmcosPoints.Add(_emcosPointsFromSiteSelectedValue);
                }

                if (NewPoints.Contains(_emcosPointsFromSiteSelectedValue) == false)
                {
                    NewPoints.Add(_emcosPointsFromSiteSelectedValue);
                }
            }, (o) => _emcosPointsFromSiteSelectedValue != null);

            CommandBalanceFormula = new DelegateCommand(() =>
            {
                BalanceFormulaEditor ctrl = new BalanceFormulaEditor();
                ctrl.DataContext          = Repository.Instance.GetGroupBalanceFormula(_emcosPointsSelectedValue.Id);

                var dialog = _window.DialogCustom(ctrl, TMPApplication.WpfDialogs.DialogMode.YesNo);

                dialog.YesText = "Записать";
                dialog.NoText  = "Отменить";
                dialog.Yes     = () =>
                {
                    ;
                };
            }, (o) => _emcosPointsSelectedValue != null && _emcosPointsSelectedValue.IsGroup);
        }