diff --git a/Step.UI/ServerControlWindow.Designer.cs b/Step.UI/ServerControlWindow.Designer.cs index bfff1810..933df0c1 100644 --- a/Step.UI/ServerControlWindow.Designer.cs +++ b/Step.UI/ServerControlWindow.Designer.cs @@ -94,7 +94,8 @@ namespace Step.UI // // openUiButton // - this.openUiButton.Location = new System.Drawing.Point(12, 385); + this.openUiButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.openUiButton.Location = new System.Drawing.Point(12, 381); this.openUiButton.Name = "openUiButton"; this.openUiButton.Size = new System.Drawing.Size(104, 42); this.openUiButton.TabIndex = 1; @@ -492,7 +493,7 @@ namespace Step.UI this.ThreadsInfo.HorizontalScrollbarSize = 10; this.ThreadsInfo.Location = new System.Drawing.Point(4, 38); this.ThreadsInfo.Name = "ThreadsInfo"; - this.ThreadsInfo.Size = new System.Drawing.Size(320, 287); + this.ThreadsInfo.Size = new System.Drawing.Size(320, 281); this.ThreadsInfo.TabIndex = 1; this.ThreadsInfo.Text = "Active Threads Info"; this.ThreadsInfo.VerticalScrollbarBarColor = true; @@ -537,7 +538,8 @@ namespace Step.UI // // stopServerButton // - this.stopServerButton.Location = new System.Drawing.Point(234, 385); + this.stopServerButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.stopServerButton.Location = new System.Drawing.Point(234, 381); this.stopServerButton.Name = "stopServerButton"; this.stopServerButton.Size = new System.Drawing.Size(106, 42); this.stopServerButton.TabIndex = 3; @@ -548,7 +550,8 @@ namespace Step.UI // // TestJSButton // - this.TestJSButton.Location = new System.Drawing.Point(122, 385); + this.TestJSButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.TestJSButton.Location = new System.Drawing.Point(122, 381); this.TestJSButton.Name = "TestJSButton"; this.TestJSButton.Size = new System.Drawing.Size(106, 42); this.TestJSButton.TabIndex = 2; diff --git a/Step.UI/ServerControlWindow.cs b/Step.UI/ServerControlWindow.cs index eca8dd36..327e5459 100644 --- a/Step.UI/ServerControlWindow.cs +++ b/Step.UI/ServerControlWindow.cs @@ -1,27 +1,26 @@ -using System; +using Step.Model; +using Step.Model.DTOModels; +using System; using System.Collections.Generic; using System.ComponentModel; -using System.Data; using System.Diagnostics; using System.IO; using System.Threading; using System.Windows.Forms; -using Step.Model; using TeamDev.SDK.MVVM; using static Step.Config.ServerConfig; using static Step.Utils.Constants; -using Step.Model.DTOModels; namespace Step.UI { public partial class ServerControlWindow : MetroFramework.Forms.MetroForm { - String HomePageUI; - String TestJSPageUI; - bool ncStatus = false; - bool isUpdatingThreads = false; - List MVVMListeners; - + private String HomePageUI; + private String TestJSPageUI; + private bool ncStatus = false; + private bool isUpdatingThreads = false; + private List MVVMListeners; + public ServerControlWindow() { InitializeComponent(); @@ -41,8 +40,10 @@ namespace Step.UI InitializeMessageListeners(); - MessageServices.Current.Subscribe(SHOW_MSG_UI, (a, b) => { - this.Invoke((MethodInvoker)delegate (){ this.Focus(); MessageBox.Show(a.ToString()); }); }); + MessageServices.Current.Subscribe(SHOW_MSG_UI, (a, b) => + { + this.Invoke((MethodInvoker)delegate () { this.Focus(); MessageBox.Show(a.ToString()); }); + }); } private static ServerControlWindow ctrlwindow = null; @@ -74,7 +75,6 @@ namespace Step.UI } } - private bool _closing = false; // Avoid closing the window @@ -109,13 +109,12 @@ namespace Step.UI private void StopServerItem_Click(object sender, EventArgs e) { //Unsubscrube MVVM threads - foreach(RegistrationInfo Info in MVVMListeners) + foreach (RegistrationInfo Info in MVVMListeners) MessageServices.Current.UnSubscribe(Info); MessageServices.Current.Publish("StopServer"); } - private void StartCMSClient(string url) { //Setup the Path Variable @@ -124,15 +123,13 @@ namespace Step.UI //Check if the system is 64/32 bit if (Environment.Is64BitOperatingSystem && File.Exists(BASE_PATH + @"\Client\x64\CMS_Client.exe")) CMSClientPath = BASE_PATH + @"\Client\x64\CMS_Client.exe"; - else if (File.Exists(BASE_PATH + @"\Client\x86\CMS_Client.exe")) CMSClientPath = BASE_PATH + @"\Client\x86\CMS_Client.exe"; if (!String.IsNullOrEmpty(CMSClientPath)) Process.Start(CMSClientPath, url); else - MessageBox.Show("CMS_Client.Exe not found"); - + MessageBox.Show("CMS_Client.Exe not found"); } private void TestJSButton_Click(object sender, EventArgs e) @@ -149,7 +146,7 @@ namespace Step.UI ErrorMessageModel message = (ErrorMessageModel)a; // If error has a fatal level, icon must be error message.ErrorLevel = message.ErrorLevel > (int)ERROR_LEVEL.ERROR ? (int)ERROR_LEVEL.ERROR : message.ErrorLevel; - + if (!this.IsDisposed) this.Invoke((MethodInvoker)delegate () { @@ -159,14 +156,13 @@ namespace Step.UI //ShowMessage on UI TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + message.Message; }); - })); MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_NC_STATUS, (a, b) => { bool newNcStatus = (bool)a; - if(ncStatus != newNcStatus) + if (ncStatus != newNcStatus) { ncStatus = newNcStatus; string title = "NC not connected"; @@ -181,11 +177,11 @@ namespace Step.UI } if (!this.IsDisposed) - this.Invoke((MethodInvoker)delegate () { + this.Invoke((MethodInvoker)delegate () + { StepNotifyIcon.ShowBalloonTip(1000, title, message, toolTipIcon); TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + title; }); - } if (ncStatus) @@ -194,40 +190,40 @@ namespace Step.UI { StepNotifyIcon.Icon = Properties.Resources.Step_Icon; }); - else - { - if(!this.IsDisposed) - this.Invoke((MethodInvoker)delegate () - { - TXTName.Text = ""; - TXTNcSerial.Text = ""; - TXTCMSMach.Text = ""; - TXTSftVers.Text = ""; - TXTNCProc.Text = ""; - TXTTime.Text = ""; - TXTLang.Text = ""; - StepNotifyIcon.Icon = Properties.Resources.Step_Disconnected; - }); - } + else + { + if (!this.IsDisposed) + this.Invoke((MethodInvoker)delegate () + { + TXTName.Text = ""; + TXTNcSerial.Text = ""; + TXTCMSMach.Text = ""; + TXTSftVers.Text = ""; + TXTNCProc.Text = ""; + TXTTime.Text = ""; + TXTLang.Text = ""; + StepNotifyIcon.Icon = Properties.Resources.Step_Disconnected; + }); + } //Other type if (!this.IsDisposed) - this.Invoke((MethodInvoker)delegate () { + this.Invoke((MethodInvoker)delegate () + { CHNcConnected.Checked = ncStatus; }); - })); MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_THREADS_STATUS, (a, b) => { //Other type if (!this.IsDisposed) - this.Invoke((MethodInvoker)delegate () { - - if(!isUpdatingThreads) + this.Invoke((MethodInvoker)delegate () + { + if (!isUpdatingThreads) { - isUpdatingThreads = true; - Dictionary Threads = new Dictionary((Dictionary)a) ; + isUpdatingThreads = true; + Dictionary Threads = new Dictionary((Dictionary)a); //Begin the update LISTThreadStatus.BeginUpdate(); //clear the List @@ -239,7 +235,6 @@ namespace Step.UI LISTThreadStatus.EndUpdate(); isUpdatingThreads = false; } - }); })); @@ -249,7 +244,8 @@ namespace Step.UI //Other type if (!this.IsDisposed) - this.Invoke((MethodInvoker)delegate () { + this.Invoke((MethodInvoker)delegate () + { TXTName.Text = data.NcModel; TXTNcSerial.Text = data.SerialNumber; TXTCMSMach.Text = data.CmsMachineIdNumber; @@ -258,7 +254,7 @@ namespace Step.UI TXTLang.Text = data.Language; TXTTime.Text = data.DateTime.ToShortDateString() + " " + data.DateTime.ToShortTimeString(); }); - })); + })); } } -} +} \ No newline at end of file diff --git a/Step/App_Start/Startup.cs b/Step/App_Start/Startup.cs index e195c368..4ec0e53c 100644 --- a/Step/App_Start/Startup.cs +++ b/Step/App_Start/Startup.cs @@ -1,21 +1,17 @@ -using System; using Microsoft.Owin; -using Owin; -using System.Web.Http; -using Microsoft.Owin.StaticFiles; using Microsoft.Owin.FileSystems; -using System.Configuration; using Microsoft.Owin.Security.OAuth; -using Microsoft.Owin.Cors; +using Microsoft.Owin.StaticFiles; +using Owin; using Step.Provider; -using Microsoft.AspNet.SignalR; -using Microsoft.AspNet.SignalR.Hubs; -using Step.Attributes; using Step.Utils; -using static Step.Config.ServerConfig; +using System; +using System.Configuration; using System.IO; -using System.Net.NetworkInformation; using System.Net; +using System.Net.NetworkInformation; +using System.Web.Http; +using static Step.Config.ServerConfig; [assembly: OwinStartup(typeof(Step.App_Start.Startup))] @@ -24,6 +20,7 @@ namespace Step.App_Start public class Startup { public static OAuthAuthorizationServerOptions OAuthOptions; + public void Configuration(IAppBuilder app) { // Configure HTTP @@ -63,11 +60,11 @@ namespace Step.App_Start } private void ConfigureWebApiOAuth(IAppBuilder app) - { + { // Create new authorization options OAuthOptions = new OAuthAuthorizationServerOptions { - // Login and Token generation end point + // Login and Token generation end point TokenEndpointPath = new PathString("/Token"), Provider = new ApplicationOAuthProvider(), // Bearer token expiration time @@ -87,7 +84,7 @@ namespace Step.App_Start //app.Map("/signalr", map => //{ // map.UseCors(CorsOptions.AllowAll); - // // Debug + // // Debug // HubConfiguration hubConfiguration = new HubConfiguration // { // EnableDetailedErrors = true @@ -120,4 +117,4 @@ namespace Step.App_Start return isAvailable; } } -} +} \ No newline at end of file diff --git a/Step/Controllers/SignalR/NcHub.cs b/Step/Controllers/SignalR/NcHub.cs index ebb63f06..f320d784 100644 --- a/Step/Controllers/SignalR/NcHub.cs +++ b/Step/Controllers/SignalR/NcHub.cs @@ -11,8 +11,6 @@ using static Step.Utils.Constants; namespace Step.Controllers.SignalR { - [SignalRAuthorize(FunctionAccess = "functionAccess", Action = ACTIONS.READ)] - public class NcHub : Hub { public static List ConnectedClients = new List(); @@ -59,7 +57,6 @@ namespace Step.Controllers.SignalR } } - [SignalRAuthorize(FunctionAccess = "functionAccess", Action = ACTIONS.READ)] public void RefreshAllAlarms() { using (NcHandler ncHandler = new NcHandler())