示例#1
0
        public JobManagerService()
        {
            _logger = LogManager.GetCurrentClassLogger();

            OperationContext.Current.Channel.Closing += (sender, args) =>
            {
                JobManager.Instance.ClientLogHandler = null;
            };

            IJobManagerCallback callback = OperationContext.Current.GetCallbackChannel <IJobManagerCallback>();

            JobManager.Instance.ClientLogHandler = (id, log) =>
            {
                try
                {
                    callback.WriteLog(id, log);
                }
                catch (Exception e)
                {
                    _logger.Error(e, "ClientLogHandler Error.");
                }
            };
            JobManager.Instance.UpdateClientJobHandler = (job) =>
            {
                try
                {
                    callback.JobUpdated(job);
                }
                catch (Exception e)
                {
                    _logger.Error(e, "UpdateClientJobHandler Error.");
                }
            };
        }
 /// <summary>
 /// Creates a new instance of the <see cref="IJobManagerClient"/> implementation 
 /// using the specified callback object, configuration name, and service endpoint address.
 /// </summary>
 /// <param name="callback">
 /// The callback object to the channel to the service.
 /// </param>
 /// <param name="endpointConfigurationName">
 /// The name of the client endpoint information in the application configuration file.
 /// </param>
 /// <param name="remoteAddress">
 /// The address of the service endpoint to use.
 /// </param>
 /// <returns>
 /// A new instance of the <see cref="IJobManagerClient"/> implementation.
 /// </returns>
 public IJobManagerClient CreateClient(IJobManagerCallback callback, string endpointConfigurationName, EndpointAddress remoteAddress)
 {
     return new JobManagerClient(new InstanceContext(callback), endpointConfigurationName, remoteAddress);
 }
 /// <summary>
 /// Creates a new instance of the <see cref="IJobManagerClient"/> implementation 
 /// using the specified callback object.
 /// </summary>
 /// <param name="callback">
 /// The callback object to the channel to the service.
 /// </param>
 /// <returns>
 /// A new instance of the <see cref="IJobManagerClient"/> implementation.
 /// </returns>
 public IJobManagerClient CreateClient(IJobManagerCallback callback)
 {
     return new JobManagerClient(new InstanceContext(callback));
 }
 /// <summary>
 /// Creates a new instance of the <see cref="IJobManagerClient"/> implementation 
 /// using the specified callback object, binding, and service endpoint address.
 /// </summary>
 /// <param name="callback">
 /// The callback object to the channel to the service.
 /// </param>
 /// <param name="binding">
 /// The binding with which to call the service.
 /// </param>
 /// <param name="remoteAddress">
 /// The service endpoint address to use.
 /// </param>
 /// <returns>
 /// A new instance of the <see cref="IJobManagerClient"/> implementation.
 /// </returns>
 public IJobManagerClient CreateClient(IJobManagerCallback callback, Binding binding, EndpointAddress remoteAddress)
 {
     return new JobManagerClient(new InstanceContext(callback), binding, remoteAddress);
 }