예제 #1
0
        static void Main(string[] args)
        {
            ILogService             logService = new FileLogService(typeof(Program));
            HelloWorldServiceClient client     = new HelloWorldServiceClient();

            logService.Info("Preparing to call the Hello World Service");
            Console.WriteLine(client.GetMessage("Console Client App"));
            logService.Info("Hello World Service has returned");
            Console.WriteLine("Log has been written");
            Console.WriteLine("Press any key to exit...");
            Console.Read();
        }
예제 #2
0
        public static void StartService(int port)
        {
            try
            {
                ILogService logService = new FileLogService(typeof(DataEngine));
                logService.Info("启动数据服务引擎...");

                // UriBuilder builder = new UriBuilder(Uri.UriSchemeNetTcp, "localhost", port, "/Data");
                UriBuilder builder = new UriBuilder(Uri.UriSchemeNetPipe, "localhost");

                _host = new ServiceHost(typeof(DataService), builder.Uri);

                ServiceThrottlingBehavior throttling = _host.Description.Behaviors.Find <ServiceThrottlingBehavior>();

                if (throttling != null)
                {
                    throttling.MaxConcurrentSessions = maxConnections;
                }
                else
                {
                    throttling = new ServiceThrottlingBehavior();
                    throttling.MaxConcurrentSessions = maxConnections;

                    _host.Description.Behaviors.Add(throttling);
                }

                //GlobalErrorBehaviorAttribute errorBehavior = _host.Description.Behaviors.Find<GlobalErrorBehaviorAttribute>();
                //if (errorBehavior == null)
                //{
                //    _host.Description.Behaviors.Add(errorBehavior);
                //}

                _host.AddServiceEndpoint(typeof(IDataService), CommunicationSettingsFactory.CreateDataServicePipeBinding(Timeout), "IDataService");
                _host.AddServiceEndpoint(typeof(IPingService), CommunicationSettingsFactory.CreateDataServicePipeBinding(Timeout), "IPingService");
                _host.Open();
            }
            catch (Exception ex)
            {
                _logService.Error(string.Format("ExistCatch:Error:<-{0}->:{1} \r\n Error detail:{2}", "StartService", ex.Message, ex.ToString()));
            }
        }
예제 #3
0
 public static void UpdateStrategy(Command updateStrategyCommand)
 {
     UpdateStrategy(updateStrategyCommand.CommandText);
     _fLogService.Info(string.Format("@CommandLog@Command Execute finished####Code={0},id={1},source={2},Target={3},updateStrategyCommandText={4},Description={5}", updateStrategyCommand.Code.ToString(), updateStrategyCommand.Id, updateStrategyCommand.Source, updateStrategyCommand.Target.ToString(), updateStrategyCommand.CommandText, updateStrategyCommand.Description));
 }