public ListService() { //Configuration cfg = ConfigurationManager.OpenExeConfiguration((new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)).LocalPath); Config.Instance.Load( Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase) + ConfigurationManager.AppSettings["ConfigFilePath"]); // Subscribe to config file changes made by config object Config.Instance.SubscribeToAllConfigurationChanges(ConfigPropertyChanged); var appName = Config.Instance.ConfigObject.ADCConnectionOptions.ApplicationName; if (String.IsNullOrEmpty(appName) || String.IsNullOrWhiteSpace(appName)) { Config.Instance.ConfigObject.ADCConnectionOptions.ApplicationName = "LstSrvc"; Config.Instance.Save(); } // Create Device Server manager var dsManager = new DeviceServerManager(); // Congure the Device Servers dsManager.ServersCreate(Config.Instance.ConfigObject.ADCConnectionOptions.DeviceServersToInitialize); // Connect to the specified Device Servers foreach (var dsName in Config.Instance.ConfigObject.ADCConnectionOptions.DeviceServersToConnect) { dsManager.ServerStart(dsName); } InitializeListService(dsManager); _callbackCreator = () => OperationContext.Current.GetCallbackChannel <IListServiceClient>(); }
public ListService(DeviceServerManager adcConnect, Func <IListServiceClient> callbackCreator) { if (callbackCreator == null) { throw new ArgumentNullException("callbackCreator"); } Config.Instance.SubscribeToAllConfigurationChanges(ConfigPropertyChanged); InitializeListService(adcConnect); _callbackCreator = callbackCreator; }
public ListService(DeviceServerManager adcConnect) { Config.Instance.SubscribeToAllConfigurationChanges(ConfigPropertyChanged); InitializeListService(adcConnect); _callbackCreator = () => OperationContext.Current.GetCallbackChannel <IListServiceClient>(); _dataServiceManager = new DataServiceManager(); _dataServiceManager.DataBaseFieldsRetrieved += OnDatabaseFieldsRetrieve; _breakAwayManager = new BreakAwayManager(this); _breakAwayManager.OnBreakAwayListStatusChanged += OnBreakAwayStatusChanged; }
private DeviceServerManager GetDeviceServerManager() { var appName = Config.Instance.ConfigObject.ADCConnectionOptions.ApplicationName; if (String.IsNullOrEmpty(appName) || String.IsNullOrWhiteSpace(appName)) { Config.Instance.ConfigObject.ADCConnectionOptions.ApplicationName = "ListSrvc"; Config.Instance.Save(); } // Create Device Server manager var dsManager = new DeviceServerManager(); // Congure the Device Servers dsManager.ServersCreate(Config.Instance.ConfigObject.ADCConnectionOptions.DeviceServersToInitialize); // Connect to the specified Device Servers foreach (String dsName in Config.Instance.ConfigObject.ADCConnectionOptions.DeviceServersToConnect) { dsManager.ServerStart(dsName); } return(dsManager); }
/// <summary> /// Set Device Server Manager to use with this service, /// set up event handlers and fault converters /// </summary> /// <param name="adcConnect">Device Server Manager</param> private void InitializeListService(DeviceServerManager adcConnect) { _isStopped = false; _adcSrv = adcConnect; _adcSrv.ListChanged += OnListChanged; _adcSrv.EventsAdded += OnEventsAdded; _adcSrv.EventsDeleted += OnEventsDeleted; _adcSrv.EventsUpdated += OnEventsUpdated; _adcSrv.EventsMoved += OnEventsMoved; _adcSrv.ServerStatusChanged += OnServerStatusChanged; ExceptionToFaultConverter.RegisterConverter <ServerNotExistException, DeviceServerNotCreatedError>(ex => new DeviceServerNotCreatedError(ex.Source, ex.Message)); ExceptionToFaultConverter.RegisterConverter <ServerNotRunningException, DeviceServerNotRunningError>(ex => new DeviceServerNotRunningError(ex.Source, ex.Message)); ExceptionToFaultConverter.RegisterConverter <ServiceParametersValidationException, ServiceParametersValidationError>(ex => new ServiceParametersValidationError(ex.Source, ex.Message)); ExceptionToFaultConverter.RegisterConverter <ListServiceListLockedException, ListLockedError>(ex => new ListLockedError(ex.Source, ex.Message)); ExceptionToFaultConverter.RegisterConverter <ListServiceListNotEnabledException, ListServiceError>(ex => new ListServiceError(ex.Source, ex.Message)); ExceptionToFaultConverter.RegisterConverter <ServiceException, ListServiceError>(ex => new ListServiceError(ex.Source, ex.Message)); _clientsMonitor = new Timer(60000) { AutoReset = false }; _clientsMonitor.Elapsed += CheckClients; _clientsMonitor.Enabled = true; }