Exemple #1
0
        internal static IFFTAdapterService Initialise()
        {
            try
            {
                _logger.Info("");
                _logger.Info("------------------------------------");
                _logger.Info("starting FFTAdapterService Service");

                InsertFFTAdapterOperationLog.AddProcessLogFFTAdapterOperation("");
                InsertFFTAdapterOperationLog.AddProcessLogFFTAdapterOperation("------------------------------------");
                InsertFFTAdapterOperationLog.AddProcessLogFFTAdapterOperation("starting FFTAdapterService Service");

                var service = new FFTAdapterService();
                Uri httpUrl = new Uri("https://localhost:6530/FFTAdapterService");

                WebServiceHost controllerHost
                    = new WebServiceHost(typeof(FFTAdapterService), httpUrl);

                WebHttpBinding _webhttpbis = new WebHttpBinding(WebHttpSecurityMode.Transport);
                // WSHttpBinding _webhttpbis = new WSHttpBinding(SecurityMode.Transport);

                _webhttpbis.ReceiveTimeout         = TimeSpan.Parse("00:10:00");
                _webhttpbis.CloseTimeout           = TimeSpan.Parse("00:10:00");
                _webhttpbis.OpenTimeout            = TimeSpan.Parse("00:10:00");
                _webhttpbis.SendTimeout            = TimeSpan.Parse("00:10:00");
                _webhttpbis.MaxBufferPoolSize      = 2147483647; //524288;
                _webhttpbis.MaxBufferSize          = 2147483647;
                _webhttpbis.MaxReceivedMessageSize = 2147483647; //1073741823;
                _webhttpbis.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;

                XmlDictionaryReaderQuotas myReaderQuotas = new XmlDictionaryReaderQuotas();
                myReaderQuotas.MaxStringContentLength = 2147483647;
                myReaderQuotas.MaxArrayLength         = 2147483647;
                myReaderQuotas.MaxBytesPerRead        = 2147483647;
                myReaderQuotas.MaxDepth = 2147483647;
                myReaderQuotas.MaxNameTableCharCount = 2147483647;

                _webhttpbis.GetType().GetProperty("ReaderQuotas").SetValue(_webhttpbis, myReaderQuotas, null);
                //_webhttpbis.CrossDomainScriptAccessEnabled = true;
                var endpoint = controllerHost.AddServiceEndpoint(typeof(IFFTAdapterService), _webhttpbis, "");//WSHttpBinding

                ServiceThrottlingBehavior throttleBehavior = new ServiceThrottlingBehavior
                {
                    MaxConcurrentCalls     = 500,
                    MaxConcurrentInstances = 500,
                    MaxConcurrentSessions  = 500,
                };

                controllerHost.Description.Behaviors.Add(throttleBehavior);

                var _ServiceMetadataBehavior = controllerHost.Description.Behaviors.Find <ServiceMetadataBehavior>();
                if (_ServiceMetadataBehavior == null)
                {
                    _ServiceMetadataBehavior = new ServiceMetadataBehavior();
                    controllerHost.Description.Behaviors.Add(_ServiceMetadataBehavior);
                }

                _ServiceMetadataBehavior.HttpGetEnabled  = true;
                _ServiceMetadataBehavior.HttpsGetEnabled = true;

                var _ServiceDebugBehavior = controllerHost.Description.Behaviors.Find <ServiceDebugBehavior>();
                if (_ServiceDebugBehavior == null)
                {
                    _ServiceDebugBehavior = new ServiceDebugBehavior();
                    controllerHost.Description.Behaviors.Add(_ServiceDebugBehavior);
                }
                _ServiceDebugBehavior.IncludeExceptionDetailInFaults = true;

                var serviceCredential = controllerHost.Description.Behaviors.Find <ServiceCredentials>();
                if (serviceCredential == null)
                {
                    serviceCredential = new ServiceCredentials();
                    controllerHost.Description.Behaviors.Add(serviceCredential);
                }

                serviceCredential.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine,
                                                                    StoreName.My,
                                                                    X509FindType.FindByThumbprint,
                                                                    "f55bf424542522c6a6d833f933431a31baaf43de");
                controllerHost.Open();

                _logger.Info("listening at {0}", controllerHost.Description.Endpoints[0].ListenUri);
                _logger.Info("------------------------------------");
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);   //amit 04112016

                if (cams3SdkUser == null)
                {
                    cams3SdkUser = new Cams3SdkUser();
                }

                return(service);
            }
            catch (Exception ex)
            {
                _logger.Info("FFTAdapterService Initialise() Exception" + ex.Message);
                InsertFFTAdapterOperationLog.AddProcessLogFFTAdapterOperation("FFTAdapterService Initialise() Exception" + ex.Message);
            }
            return(null);
        }
Exemple #2
0
 static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) //amit 04112016
 {
     _logger.Info("FFTAdapterService service  Unhandled UI Exception" + (e.ExceptionObject as Exception).Message);
     InsertFFTAdapterOperationLog.AddProcessLogFFTAdapterOperation("FFTAdapterService service  Unhandled UI Exception" + (e.ExceptionObject as Exception).Message);
 }