public MainWindow() { _pipeFactory = new ChannelFactory <IWCFService>( new NetNamedPipeBinding(), new EndpointAddress( "net.pipe://localhost/PipeWeatherService")); _pipeProxy = _pipeFactory.CreateChannel(); _jsonPaths = new List <string>() { @"C:\Users\Kamil\source\repos\WeatherService\textEN.json", @"C:\Users\Kamil\source\repos\WeatherService\textPL.json" }; _isPlLang = false; _isRunning = true; IsFahrenheit = false; IsFahrenheitFeel = false; SelectedCity = "ToruĊ"; DataContext = this; InitializeComponent(); AppTextObj = Utilities.JsonReader <AppStaticText>(_jsonPaths[0]); //GetLocationEvent(); //Location = "Unislaw"; //WeatherCurrentData = new WeatherCurrentData("Unislaw"); GetData(); }
private bool connectToService() { try { InstanceContext site = new InstanceContext(this); NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.ReliableSession.Ordered = true; tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.None; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.None; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress myEndpoint = new EndpointAddress("net.tcp://" + Common.DBConnection + ":8731/WCFService/"); var myChannelFactory = new DuplexChannelFactory <IWCFService>(site, tcpBinding); wcfObj = myChannelFactory.CreateChannel(myEndpoint); wcfObj.Subscribe(); logging.AddToLog("Connected to Service", true); //reloadPlugins(); return(true); } catch (Exception ex) { logging.AddToLog("Unable to connect to service. Is it running? - " + ex.Message, true); return(false); } }
protected override void OnStart(string[] args) { Common.InitialiseLogFolder(); logging.AddToLog("OnStart", true); InstanceContext site = new InstanceContext(this); NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.ReliableSession.Ordered = true; tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.None; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.None; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress myEndpoint = new EndpointAddress("net.tcp://" + Common.DBConnection + ":8731/WCFService/"); var myChannelFactory = new DuplexChannelFactory <IWCFService>(site, tcpBinding); wcfObj = myChannelFactory.CreateChannel(myEndpoint); wcfObj.Subscribe(); Common.CreateComputerObject(sourceName); try { logging.AddToLog("Creating Service object", true); OSAEObject svcobj = OSAEObjectManager.GetObjectByName("SERVICE-" + Common.ComputerName); if (svcobj == null) { OSAEObjectManager.ObjectAdd("SERVICE-" + Common.ComputerName, "SERVICE-" + Common.ComputerName, "SERVICE", "", "SYSTEM", true); } OSAEObjectStateManager.ObjectStateSet("SERVICE-" + Common.ComputerName, "ON", sourceName); } catch (Exception ex) { logging.AddToLog("Error creating service object - " + ex.Message, true); } if (connectToService()) { Thread loadPluginsThread = new Thread(new ThreadStart(LoadPlugins)); loadPluginsThread.Start(); } //Clock.Interval = 5000; //Clock.Start(); //Clock.Elapsed += new System.Timers.ElapsedEventHandler(checkConnection); }
private void ConnectToService() { InstanceContext site = new InstanceContext(this); NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.ReliableSession.Ordered = true; tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.None; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.None; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress myEndpoint = new EndpointAddress("net.tcp://" + Common.WcfServer + ":8731/WCFService/"); var myChannelFactory = new DuplexChannelFactory<IWCFService>(site, tcpBinding); wcfObj = myChannelFactory.CreateChannel(myEndpoint); wcfObj.Subscribe(); }
protected void Page_Load(object sender, EventArgs e) { InstanceContext site = new InstanceContext(this); NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.ReliableSession.Ordered = true; tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.None; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.None; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress myEndpoint = new EndpointAddress("net.tcp://" + Common.DBConnection + ":8731/WCFService/"); var myChannelFactory = new DuplexChannelFactory <IWCFService>(site, tcpBinding); wcfObj = myChannelFactory.CreateChannel(myEndpoint); wcfObj.Subscribe(); if (!Page.IsPostBack) { loadPlugins(); } }
private bool connectToService() { try { InstanceContext site = new InstanceContext(this); NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.ReliableSession.Ordered = true; tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.None; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.None; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress myEndpoint = new EndpointAddress("net.tcp://" + Common.WcfServer + ":8731/WCFService/"); var myChannelFactory = new DuplexChannelFactory<IWCFService>(site, tcpBinding); wcfObj = myChannelFactory.CreateChannel(myEndpoint); wcfObj.Subscribe(); logging.AddToLog("Connected to Service", true); return true; } catch (Exception ex) { logging.AddToLog("Unable to connect to service. Is it running? - " + ex.Message, true); return false; } }
protected override void OnStart(string[] args) { Common.InitialiseLogFolder(); logging.AddToLog("OnStart", true); InstanceContext site = new InstanceContext(this); NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.ReliableSession.Ordered = true; tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.None; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.None; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress myEndpoint = new EndpointAddress("net.tcp://" + Common.WcfServer + ":8731/WCFService/"); var myChannelFactory = new DuplexChannelFactory<IWCFService>(site, tcpBinding); wcfObj = myChannelFactory.CreateChannel(myEndpoint); wcfObj.Subscribe(); Common.CreateComputerObject(sourceName); try { logging.AddToLog("Creating Service object", true); OSAEObject svcobj = OSAEObjectManager.GetObjectByName("SERVICE-" + Common.ComputerName); if (svcobj == null) { OSAEObjectManager.ObjectAdd("SERVICE-" + Common.ComputerName, "SERVICE-" + Common.ComputerName, "SERVICE", "", "SYSTEM", true); } OSAEObjectStateManager.ObjectStateSet("SERVICE-" + Common.ComputerName, "ON", sourceName); } catch (Exception ex) { logging.AddToLog("Error creating service object - " + ex.Message, true); } if (connectToService()) { Thread loadPluginsThread = new Thread(new ThreadStart(LoadPlugins)); loadPluginsThread.Start(); } //Clock.Interval = 5000; //Clock.Start(); //Clock.Elapsed += new System.Timers.ElapsedEventHandler(checkConnection); }
private void Window_Loaded(object sender, RoutedEventArgs e) { //imgUpdate.Source = (ImageSource)FindResource("upgrade.png"); // Test the connection to the DB is valid before we start else the UI will // hang when it tries to connect if (!Common.TestConnection()) { MessageBox.Show("The OSA DB could not be contacted, Please ensure the correct address is specified and the DB is available"); return; } loadPlugins(); InstanceContext site = new InstanceContext(this); NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.ReliableSession.Ordered = true; tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.None; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.None; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress myEndpoint = new EndpointAddress("net.tcp://" + Common.DBConnection + ":8731/WCFService/"); var myChannelFactory = new DuplexChannelFactory<IWCFService>(site, tcpBinding); wcfObj = myChannelFactory.CreateChannel(myEndpoint); wcfObj.Subscribe(); Thread thread = new Thread(() => messageHost(OSAEWCFMessageType.CONNECT, "connected")); thread.Start(); try { myService.ServiceName = "OSAE"; string svcStatus = myService.Status.ToString(); if (svcStatus == "Running") { lbl_isRunning.Content = "RUNNING"; btnService.Content = "Stop"; } else if (svcStatus == "Stopped") { lbl_isRunning.Content = "STOPPED"; btnService.Content = "Start"; } } catch { try { myService.ServiceName = "OSAE Client"; string svcStatus = myService.Status.ToString(); if (svcStatus == "Running") { lbl_isRunning.Content = "RUNNING"; btnService.Content = "Stop"; } else if (svcStatus == "Stopped") { lbl_isRunning.Content = "STOPPED"; btnService.Content = "Start"; } } catch { lbl_isRunning.Content = "NOT INSTALLED"; btnService.IsEnabled = false; } } Clock.Interval = 1000; Clock.Elapsed += new System.Timers.ElapsedEventHandler(CheckService); Clock.Start(); pingTimer.Interval = 30000; pingTimer.Elapsed += new System.Timers.ElapsedEventHandler(Ping); pingTimer.Start(); //dgLocalPlugins.SelectedIndex = 0; }
private void Window_Loaded(object sender, RoutedEventArgs e) { //imgUpdate.Source = (ImageSource)FindResource("upgrade.png"); // Test the connection to the DB is valid before we start else the UI will // hang when it tries to connect if (!Common.TestConnection()) { MessageBox.Show("The OSA DB could not be contacted, Please ensure the correct address is specified and the DB is available"); return; } loadPlugins(); InstanceContext site = new InstanceContext(this); NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.ReliableSession.Ordered = true; tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.None; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.None; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress myEndpoint = new EndpointAddress("net.tcp://" + Common.DBConnection + ":8731/WCFService/"); var myChannelFactory = new DuplexChannelFactory <IWCFService>(site, tcpBinding); wcfObj = myChannelFactory.CreateChannel(myEndpoint); wcfObj.Subscribe(); Thread thread = new Thread(() => messageHost(OSAEWCFMessageType.CONNECT, "connected")); thread.Start(); try { myService.ServiceName = "OSAE"; string svcStatus = myService.Status.ToString(); if (svcStatus == "Running") { lbl_isRunning.Content = "RUNNING"; btnService.Content = "Stop"; } else if (svcStatus == "Stopped") { lbl_isRunning.Content = "STOPPED"; btnService.Content = "Start"; } } catch { try { myService.ServiceName = "OSAE Client"; string svcStatus = myService.Status.ToString(); if (svcStatus == "Running") { lbl_isRunning.Content = "RUNNING"; btnService.Content = "Stop"; } else if (svcStatus == "Stopped") { lbl_isRunning.Content = "STOPPED"; btnService.Content = "Start"; } } catch { lbl_isRunning.Content = "NOT INSTALLED"; btnService.IsEnabled = false; } } Clock.Interval = 1000; Clock.Elapsed += new System.Timers.ElapsedEventHandler(CheckService); Clock.Start(); pingTimer.Interval = 30000; pingTimer.Elapsed += new System.Timers.ElapsedEventHandler(Ping); pingTimer.Start(); //dgLocalPlugins.SelectedIndex = 0; }
public ServiceInteraction() { ic = new WCFServiceClient(); }
protected void Page_Load(object sender, EventArgs e) { InstanceContext site = new InstanceContext(this); NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.ReliableSession.Ordered = true; tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.None; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.None; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress myEndpoint = new EndpointAddress("net.tcp://" + Common.DBConnection + ":8731/WCFService/"); var myChannelFactory = new DuplexChannelFactory<IWCFService>(site, tcpBinding); wcfObj = myChannelFactory.CreateChannel(myEndpoint); wcfObj.Subscribe(); if (!Page.IsPostBack) { loadPlugins(); } }