/// <summary> /// Starts the Heartbeat signal. /// </summary> public void StartHeartbeat() { this.waitHandle = new AutoResetEvent(true); wcfService = WcfService.Instance; threadStopped = false; heartBeatThread = new Thread(RunHeartBeatThread); heartBeatThread.Start(); }
public void Start_Import_Of_GStandard_When_RefreshDatabase_Is_Called() { bool started = false; //var importService = GetImportServiceMock(x => started = true); //var dataService = GetDataServiceMock(null); Bootstrapper.ConfigureStructureMap(); var wcfService = new WcfService(); wcfService.RefreshDatabase(); Assert.IsTrue(started); }
public void Start_Import_Of_GStandard_When_RefreshDatabase_Is_Called() { bool started = false; var importService = GetImportServiceMock(x => started = true); var dataService = GetDataServiceMock(null); var wcfService = new WcfService(dataService, importService); wcfService.RefreshDatabase(); Assert.IsTrue(started); }
public TaskManager(PluginManager pluginCache, ILog log) { this.pluginManager = pluginCache; this.log = log; this.slaveTasks = new Dictionary<Guid, SnapshotInfo>(); cts = new CancellationTokenSource(); ct = cts.Token; waitHandle = new AutoResetEvent(true); wcfService = WcfService.Instance; checkpointInterval = Settings.Default.CheckpointInterval; checkpointCheckInterval = Settings.Default.CheckpointCheckInterval; System.Threading.Tasks.Task.Factory.StartNew(Checkpointing, ct); }
public ResoView(WcfService.Dto.NotaCreditoDto notaCredito) { InitializeComponent(); try { this.notaCredito = notaCredito; var viewModel = (Reso.ResoViewModel)ViewModel; if (viewModel != null) { viewModel.NotaCredito = notaCredito; } } catch (Exception ex) { UtilityError.Write(ex); } }
public SALView(WcfService.Dto.CommessaDto commessa) { InitializeComponent(); try { this.commessa = commessa; var viewModel = (SAL.SALViewModel)ViewModel; if (viewModel != null) { viewModel.Commessa = commessa; } } catch (Exception ex) { UtilityError.Write(ex); } }
public ArticoloView(WcfService.Dto.FatturaAcquistoDto fatturaAcquisto) { InitializeComponent(); try { this.fatturaAcquisto = fatturaAcquisto; var viewModel = (Articolo.ArticoloViewModel)ViewModel; if (viewModel != null) { viewModel.FatturaAcquisto = fatturaAcquisto; } } catch (Exception ex) { UtilityError.Write(ex); } }
public IncassoView(WcfService.Dto.FatturaVenditaDto fatturaVendita) { InitializeComponent(); try { this.fatturaVendita = fatturaVendita; var viewModel = (Incasso.IncassoViewModel)ViewModel; if (viewModel != null) { viewModel.FatturaVendita = fatturaVendita; } } catch (Exception ex) { UtilityError.Write(ex); } }
public IncassoView(WcfService.Dto.CommittenteDto committente) { InitializeComponent(); try { this.committente = committente; var viewModel = (Incasso.IncassoViewModel)ViewModel; if (viewModel != null) { viewModel.Committente = committente; } } catch (Exception ex) { UtilityError.Write(ex); } }
public PagamentoView(WcfService.Dto.FornitoreDto fornitore) { InitializeComponent(); try { this.fornitore = fornitore; var viewModel = (Pagamento.PagamentoViewModel)ViewModel; if (viewModel != null) { viewModel.Fornitore = fornitore; } } catch (Exception ex) { UtilityError.Write(ex); } }
void clientUnit_ValCompleted(object sender, WcfService.ValCompletedEventArgs e) { IList<double> list = new List<double>(); list = e.Result; UnitObj uo = new UnitObj(); uo.Power = list[0]; uo.Flow = list[1]; uo.Pressure = list[2]; uo.Temperature = list[3]; uo.ReheatTemperature = list[4]; uo.Vacuum = list[5]; uo.Efficiency = list[6]; uo.Heatconsumption = list[7]; uo.Coalconsumption = list[8]; IList<UnitObj> lt = new List<UnitObj>(); lt.Add(uo); dgData.ItemsSource = lt; }
public WcfService GetWcfService(string serviceType, string serviceContractVersion, string machineIP) { try { using (WcfConfigDataContext data = new WcfConfigDataContext()) { var wcfServices = data.Services.Where(s => s.ServiceType == serviceType).ToList(); var wcfService = wcfServices.Where(s => (machineIP.Contains(s.ServerMachineIP))).FirstOrDefault(); if (wcfService == null ) wcfService = wcfServices.Where(s => s.ServerMachineIP == "*" ).FirstOrDefault(); var service = new WcfService { ServiceType = serviceType, ServiceBehaviorXml = wcfService.ServiceBehaviorXml != null ? wcfService.ServiceBehaviorXml.ToString() : "", Endpoints = (from ep in data.ServiceEndpoints where ep.ServiceType == serviceType && ep.ServiceContractVersion == serviceContractVersion && (ep.ServerMachineIP == wcfService.ServerMachineIP || ep.ServerMachineIP == "*") select new WcfServiceEndpoint { EndpointBehaviorXml = ep.ServiceEndpointBehaviorXml != null ? ep.ServiceEndpointBehaviorXml.ToString() : "", EndpointBindingName = ep.ServiceEndpointBindingName, EndpointName = ep.ServiceEndpointName, EndpointPort = ep.ServiceEndpointPort, ServiceContractType = ep.ServiceContractType, EndpointBindingType = ep.Binding.BindingType, EndpointBindingXml = ep.Binding.BindingXml != null ? ep.Binding.BindingXml.ToString() : "", EndpointProtocol = ep.Binding.BindingProtocol }).ToArray() }; return service; } } catch (Exception ex) { LocalLogService.Log(ex.ToString()); return null; } }
private ServiceCommandOutput<object> CheckServiceConnectivity(string port, ServiceType type, ServiceSecurityMode mode) { var service = new WcfService<ICommandService<object>, DummyNativeCommandService>("localhost", ServiceName); service.AddBinding(BindingFactory.Create(new BindingConfiguration {Port = port, ServiceType = type})); if (mode == ServiceSecurityMode.BasicSSL) { var serviceSecurity = new ServiceSecurity { SecurityMode = ServiceSecurityMode.BasicSSL, CertificateConfiguration = _certificateConfiguration }; service.SetSecured(serviceSecurity); } service.Host(); var client = WcfClient<ICommandService<object>>.Create(type, "localhost", port, ServiceName, "api", mode); var output = client.Contract.ExecuteCommand("test", "token"); service.Stop(); return output; }
protected override void OnStart(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; var contextSettings = new ContextSettings { CommandFactory = new CommandFactory() }; HostContext.CreateFrom(_arguments.GetValue("configPath", "konfdb.json"), contextSettings); CurrentHostContext.Default.Log.Info("Agent Started: DataManagement"); #region Run Command Service ServiceFacade = new ServiceCore(); string internalSessionId = Guid.NewGuid().ToString(); // Ensure that the super user admin exists ServiceFacade.ExecuteCommand(new ServiceRequestContext { Command = String.Format("NewUser /name:{0} /pwd:{1} /cpwd:{1} /role:admin /silent", CurrentHostContext.Default.Config.Runtime.SuperUser.Username, CurrentHostContext.Default.Config.Runtime.SuperUser.Password), SessionId = internalSessionId }); // Ensure that the super user readonly exists ServiceFacade.ExecuteCommand(new ServiceRequestContext { Command = String.Format("NewUser /name:{0}_ro /pwd:{1} /cpwd:{1} /role:readonly /silent", CurrentHostContext.Default.Config.Runtime.SuperUser.Username, CurrentHostContext.Default.Config.Runtime.SuperUser.Password), SessionId = internalSessionId }); var serviceConfig = CurrentHostContext.Default.Config.Runtime.Server; _serviceHostNative = new WcfService<ICommandService<object>, NativeCommandService>("localhost", "CommandService"); _serviceHostJson = new WcfService<ICommandService<string>, JsonCommandService>("localhost", "CommandService"); for (int i = 0; i < serviceConfig.Count; i++) { var configuration = new BindingConfiguration { Port = serviceConfig[i].Port.ToString(CultureInfo.InvariantCulture), ServiceType = serviceConfig[i].GetWcfServiceType() }; var binding = BindingFactory.Create(configuration); if (binding.DataTypes.IsSet(DataTypeSupport.Native)) { _serviceHostNative.AddBinding(binding); } else if (binding.DataTypes.IsSet(DataTypeSupport.Json)) { _serviceHostJson.AddBinding(binding); } } if (CurrentHostContext.Default.Config.Runtime.ServiceSecurity == ServiceSecurityMode.BasicSSL) { var serviceSecurity = new ServiceSecurity { CertificateConfiguration = CurrentHostContext.Default.Config.Certificate.Default, SecurityMode = CurrentHostContext.Default.Config.Runtime.ServiceSecurity }; _serviceHostJson.SetSecured(serviceSecurity); _serviceHostNative.SetSecured(serviceSecurity); } _serviceHostNative.Host(); _serviceHostJson.Host(); var authOutput = ServiceFacade.ExecuteCommand(new ServiceRequestContext { Command = String.Format("UserAuth /name:{0} /pwd:{1}", CurrentHostContext.Default.Config.Runtime.SuperUser.Username, CurrentHostContext.Default.Config.Runtime.SuperUser.Password), SessionId = internalSessionId }); var authenticationOutput = authOutput.Data as AuthenticationOutput; if (authenticationOutput == null) { throw new InvalidOperationException( "Could not authenticate server user: "******"GetSettings", SessionId = internalSessionId }); if (settingsOutput != null && settingsOutput.Data != null) { var settings = (Dictionary<string, string>) settingsOutput.Data; foreach (var setting in settings) { CurrentHostContext.Default.ApplicationParams.Add(setting.Key, setting.Value); } } //AppContext.Current.Log.Info("Agent Started: " + _serviceHostNative); //AppContext.Current.Log.Info("Agent Started: " + _serviceHostJson); #endregion _thread = new Thread(RunInBackground) { Name = "ShellService", IsBackground = true }; _shutdownEvent = new ManualResetEvent(false); _thread.Start(); }
/// <summary> /// Main method for the client /// </summary> public void Start() { abortRequested = false; EventLogManager.ServiceEventLog = ServiceEventLog; try { //start the client communication service (pipe between slave and slave gui) slaveComm = new ServiceHost(typeof(SlaveCommunicationService)); try { slaveComm.Open(); } catch (AddressAlreadyInUseException ex) { if (ServiceEventLog != null) { EventLogManager.LogException(ex); } } // delete all left over task directories pluginManager.CleanPluginTemp(); SlaveClientCom.Instance.LogMessage("Hive Slave started"); wcfService = WcfService.Instance; RegisterServiceEvents(); StartHeartbeats(); // Start heartbeats thread DispatchMessageQueue(); // dispatch messages until abortRequested } catch (Exception ex) { if (ServiceEventLog != null) { EventLogManager.LogException(ex); } else { //try to log with SlaveClientCom.Instance. if this works the user sees at least a message, //else an exception will be thrown anyways. SlaveClientCom.Instance.LogMessage(string.Format("Uncaught exception: {0} {1} Core is going to shutdown.", ex.ToString(), Environment.NewLine)); } ShutdownCore(); } finally { DeregisterServiceEvents(); waitShutdownSem.Release(); } }
/// <summary>Loads settings and UI for the page.</summary> /// <param name="sender">The object that called the event.</param> /// <param name="e">The <c>System.Windows.RoutedEventArgs</c> instance containing the event data.</param> void Init(object sender, RoutedEventArgs e) { if (Utilities.RebootNeeded) { Core.Instance.UpdateAction = UpdateAction.RebootNeeded; } if (init) { return; } init = true; this.DataContext = Core.Instance; // Subscribe to events RestoreUpdates.RestoredHiddenUpdate += SettingsChanged; WcfService.SettingsChanged += SettingsChanged; Search.ErrorOccurred += this.ErrorOccurred; Search.SearchCompleted += this.SearchCompleted; UpdateInfo.UpdateSelectionChanged += this.UpdateSelectionChanged; Core.UpdateActionChanged += this.SetUI; WcfService.DownloadProgressChanged += this.DownloadProgressChanged; WcfService.DownloadDone += this.DownloadCompleted; WcfService.InstallProgressChanged += this.InstallProgressChanged; WcfService.InstallDone += this.InstallCompleted; WcfService.ErrorOccurred += this.ErrorOccurred; WcfService.ServiceError += this.ErrorOccurred; if (App.IsDev) { this.tbDevNote.Visibility = Visibility.Visible; this.Title += " - " + Properties.Resources.DevChannel; } if (App.IsBeta) { this.Title += " - " + Properties.Resources.BetaChannel; } Core.Instance.UpdateAction = UpdateAction.NoUpdates; if (Core.IsReconnect) { Core.Instance.UpdateAction = UpdateAction.ConnectingToService; this.timer = new Timer { Enabled = true, Interval = 30000 }; this.timer.Elapsed -= this.CheckIfConnecting; this.timer.Elapsed += this.CheckIfConnecting; WcfService.Connect(); } else if (File.Exists(Path.Combine(App.AllUserStore, "updates.sui"))) { DateTime lastCheck = File.GetLastWriteTime(Path.Combine(App.AllUserStore, "updates.sui")); DateTime today = DateTime.Now; if (lastCheck.Month == today.Month && lastCheck.Year == today.Year) { if (lastCheck.Day == today.Day || lastCheck.Day + 1 == today.Day || lastCheck.Day + 2 == today.Day || lastCheck.Day + 3 == today.Day || lastCheck.Day + 4 == today.Day || lastCheck.Day + 5 == today.Day) { WcfService.Disconnect(); if (File.Exists(Path.Combine(App.AllUserStore, "updates.sui"))) { Task.Factory.StartNew( () => Search.SetUpdatesFound( Utilities.Deserialize <Collection <Sui> >( Path.Combine(App.AllUserStore, "updates.sui")))); } } } else { try { File.Delete(Path.Combine(App.AllUserStore, "updates.sui")); } catch (Exception f) { if (!(f is UnauthorizedAccessException || f is IOException)) { Utilities.ReportError(f, ErrorType.GeneralError); throw; } } Core.Instance.UpdateAction = UpdateAction.CheckForUpdates; } } else { if (Utilities.RebootNeeded) { Core.Instance.UpdateAction = UpdateAction.RebootNeeded; return; } if (Settings.Default.LastUpdateCheck == DateTime.MinValue) { Core.Instance.UpdateAction = UpdateAction.CheckForUpdates; } if (!Settings.Default.LastUpdateCheck.Date.Equals(DateTime.Now.Date)) { Core.Instance.UpdateAction = UpdateAction.CheckForUpdates; } } }
protected override void OnStart(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; var contextSettings = new ContextSettings { CommandFactory = new CommandFactory() }; HostContext.CreateFrom(_arguments.GetValue("configPath", "konfdb.json"), contextSettings); CurrentHostContext.Default.Log.Info("Agent Started: DataManagement"); #region Run Command Service ServiceFacade = new ServiceCore(); string internalSessionId = Guid.NewGuid().ToString(); // Ensure that the super user admin exists ServiceFacade.ExecuteCommand(new ServiceRequestContext { Command = String.Format("NewUser /name:{0} /pwd:{1} /cpwd:{1} /role:admin /silent", CurrentHostContext.Default.Config.Runtime.SuperUser.Username, CurrentHostContext.Default.Config.Runtime.SuperUser.Password), SessionId = internalSessionId }); // Ensure that the super user readonly exists ServiceFacade.ExecuteCommand(new ServiceRequestContext { Command = String.Format("NewUser /name:{0}_ro /pwd:{1} /cpwd:{1} /role:readonly /silent", CurrentHostContext.Default.Config.Runtime.SuperUser.Username, CurrentHostContext.Default.Config.Runtime.SuperUser.Password), SessionId = internalSessionId }); var serviceConfig = CurrentHostContext.Default.Config.Runtime.Server; _serviceHostNative = new WcfService <ICommandService <object>, NativeCommandService>("localhost", "CommandService"); _serviceHostJson = new WcfService <ICommandService <string>, JsonCommandService>("localhost", "CommandService"); for (int i = 0; i < serviceConfig.Count; i++) { var configuration = new BindingConfiguration { Port = serviceConfig[i].Port.ToString(CultureInfo.InvariantCulture), ServiceType = serviceConfig[i].GetWcfServiceType() }; var binding = BindingFactory.Create(configuration); if (binding.DataTypes.IsSet(DataTypeSupport.Native)) { _serviceHostNative.AddBinding(binding); } else if (binding.DataTypes.IsSet(DataTypeSupport.Json)) { _serviceHostJson.AddBinding(binding); } } if (CurrentHostContext.Default.Config.Runtime.ServiceSecurity == ServiceSecurityMode.BasicSSL) { var serviceSecurity = new ServiceSecurity { CertificateConfiguration = CurrentHostContext.Default.Config.Certificate.Default, SecurityMode = CurrentHostContext.Default.Config.Runtime.ServiceSecurity }; _serviceHostJson.SetSecured(serviceSecurity); _serviceHostNative.SetSecured(serviceSecurity); } _serviceHostNative.Host(); _serviceHostJson.Host(); var authOutput = ServiceFacade.ExecuteCommand(new ServiceRequestContext { Command = String.Format("UserAuth /name:{0} /pwd:{1}", CurrentHostContext.Default.Config.Runtime.SuperUser.Username, CurrentHostContext.Default.Config.Runtime.SuperUser.Password), SessionId = internalSessionId }); var authenticationOutput = authOutput.Data as AuthenticationOutput; if (authenticationOutput == null) { throw new InvalidOperationException( "Could not authenticate server user: "******"GetSettings", SessionId = internalSessionId }); if (settingsOutput != null && settingsOutput.Data != null) { var settings = (Dictionary <string, string>)settingsOutput.Data; foreach (var setting in settings) { CurrentHostContext.Default.ApplicationParams.Add(setting.Key, setting.Value); } } //AppContext.Current.Log.Info("Agent Started: " + _serviceHostNative); //AppContext.Current.Log.Info("Agent Started: " + _serviceHostJson); #endregion _thread = new Thread(RunInBackground) { Name = "ShellService", IsBackground = true }; _shutdownEvent = new ManualResetEvent(false); _thread.Start(); }
private ChannelFactory <IWcfTimelineService> CreateChannel() { return(WcfService.CreateChannel <IWcfTimelineService>("IWcfTimelineService")); }
public void GivenIHaveATypeProviderForTheTCPEndpoint() { var service = new WcfService<ITestWcfService>("TcpClient"); var provider = new WcfConnectionProvider(new[] { service }); this.testContext.Access = new TypeAccessProvider(PermissionsProvider.Default, new[] { provider }); }
public void TestCloningMessageTypes() { // Arrange. // External bus with WCF service with specified address. var externalSubManager = new Mock <ISubscriptionsManager>(); externalSubManager .Setup(m => m.GetSubscriptions(It.Is <string>(s => s == "myid"), It.IsAny <bool>())) .Returns(() => new[] { new Subscription() { MessageType = new MessageType() { ID = "First" } }, new Subscription() { MessageType = new MessageType() { ID = "Second" } }, new Subscription() { MessageType = new MessageType() { ID = "Third" } } }); var wcfService = new WcfService(externalSubManager.Object, GetMockSendingManager(), GetMockReceivingManager(), GetMockLogger()) { UseWcfSettingsFromConfig = false, Binding = new BasicHttpBinding(), Address = new Uri("http://localhost:12343/SBService") }; var serviceBusSettings = new ServiceBusSettings { Components = new[] { wcfService } }; var serviceBus = new ServiceBus(serviceBusSettings, GetMockLogger()); // Cross-bus communication service with connection to the bus. var repository = new Mock <IObjectRepository>(); repository .Setup(r => r.GetAllServiceBuses()) .Returns(() => new[] { new Bus() { ManagerAddress = "http://localhost:12343/SBService" } }); repository .Setup(r => r.GetAllMessageTypes()) .Returns(() => new[] { new MessageType() { ID = "Second" } }); var crossSubManager = new Mock <ISubscriptionsManager>(); var service = new CrossBusCommunicationService(crossSubManager.Object, repository.Object, GetMockLogger()) { ScanningTimeout = 100, ServiceID4SB = "myid", CloneMessageTypesScanningCycles = 0 }; // Act. serviceBus.Start(); RunSBComponentFullCycle(service, 1000); serviceBus.Stop(); // Assert. crossSubManager.Verify(r => r.CreateMessageType(It.Is <NameCommentStruct>(ncs => ncs.Id == "First")), Times.Once); crossSubManager.Verify(r => r.CreateMessageType(It.Is <NameCommentStruct>(ncs => ncs.Id == "Second")), Times.Never); crossSubManager.Verify(r => r.CreateMessageType(It.Is <NameCommentStruct>(ncs => ncs.Id == "Third")), Times.Once); }
private ChannelFactory <IWcfSSOServerService> CreateChannel() { return(WcfService.CreateChannel <IWcfSSOServerService>("IWcfSSOServerService")); }
private void RunCommandService() { _serviceFacade = new ServiceCore(); string internalSessionId = Guid.NewGuid().ToString(); // Ensure that the super user admin exists _serviceFacade.ExecuteCommand(new ServiceRequestContext { Command = String.Format("NewUser /name:{0} /pwd:{1} /cpwd:{1} /role:admin /silent", AzureContext.Current.Config.Runtime.SuperUser.Username, AzureContext.Current.Config.Runtime.SuperUser.Password), SessionId = internalSessionId }); // Ensure that the super user readonly exists _serviceFacade.ExecuteCommand(new ServiceRequestContext { Command = String.Format("NewUser /name:{0}_ro /pwd:{1} /cpwd:{1} /role:readonly /silent", AzureContext.Current.Config.Runtime.SuperUser.Username, AzureContext.Current.Config.Runtime.SuperUser.Password), SessionId = internalSessionId }); var serviceConfig = AzureContext.Current.Config.Runtime.Server; _serviceHostNative = new WcfService<ICommandService<object>, NativeCommandService>("localhost", "CommandService"); _serviceHostJson = new WcfService<ICommandService<string>, JsonCommandService>("localhost", "CommandService"); for (int i = 0; i < serviceConfig.Count; i++) { var configuration = new BindingConfiguration { Port = serviceConfig[i].Port.ToString(CultureInfo.InvariantCulture), ServiceType = serviceConfig[i].GetWcfServiceType() }; var binding = BindingFactory.Create(configuration); if (binding.DataTypes.IsSet(DataTypeSupport.Native)) { _serviceHostNative.AddBinding(binding); } else if (binding.DataTypes.IsSet(DataTypeSupport.Json)) { _serviceHostJson.AddBinding(binding); } } if (AzureContext.Current.Config.Runtime.ServiceSecurity == ServiceSecurityMode.BasicSSL) { var serviceSecurity = new ServiceSecurity { CertificateConfiguration = AzureContext.Current.Config.Certificate.Default, SecurityMode = AzureContext.Current.Config.Runtime.ServiceSecurity }; _serviceHostJson.SetSecured(serviceSecurity); _serviceHostNative.SetSecured(serviceSecurity); } _serviceHostNative.Host(); _serviceHostJson.Host(); var authOutput = _serviceFacade.ExecuteCommand(new ServiceRequestContext { Command = String.Format("UserAuth /name:{0} /pwd:{1}", AzureContext.Current.Config.Runtime.SuperUser.Username, AzureContext.Current.Config.Runtime.SuperUser.Password), SessionId = internalSessionId }); var authenticationOutput = authOutput.Data as AuthenticationOutput; if (authenticationOutput == null) { throw new InvalidOperationException( "Could not authenticate server user: "******"GetSettings", SessionId = internalSessionId }); if (settingsOutput != null && settingsOutput.Data != null) { var settings = (Dictionary<string, string>) settingsOutput.Data; foreach (var setting in settings) { CurrentContext.Default.ApplicationParams.Add(setting.Key, setting.Value); } } //AppContext.Current.Log.Info("Agent Started: " + _serviceHostNative); //AppContext.Current.Log.Info("Agent Started: " + _serviceHostJson); }