private static void CheckFipsPolicy(MessageCollector messageCollector) { if (Settings.Default.OverrideFIPSCheck) { messageCollector.AddMessage(MessageClass.InformationMsg, "OverrideFIPSCheck is set. Will skip check...", true); return; } messageCollector.AddMessage(MessageClass.InformationMsg, "Checking FIPS Policy...", true); if (!FipsPolicyEnabledForServer2003() && !FipsPolicyEnabledForServer2008AndNewer()) { return; } var errorText = string.Format(Language.strErrorFipsPolicyIncompatible, GeneralAppInfo.ProductName); messageCollector.AddMessage(MessageClass.ErrorMsg, errorText, true); var ShouldIStayOrShouldIGo = CTaskDialog.MessageBox(Application.ProductName, Language.strCompatibilityProblemDetected, errorText, "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.OkCancel, ESysIcons.Warning, ESysIcons.Warning); if (CTaskDialog.VerificationChecked && ShouldIStayOrShouldIGo == DialogResult.OK) { messageCollector.AddMessage(MessageClass.ErrorMsg, "User requests that FIPS check be overridden", true); Settings.Default.OverrideFIPSCheck = true; Settings.Default.Save(); return; } if (ShouldIStayOrShouldIGo == DialogResult.Cancel) { Environment.Exit(1); } }
private void LogSystemData() { var osData = GetOperatingSystemData(); var architecture = GetArchitectureData(); var nonEmptyData = Array.FindAll(new[] { osData, architecture }, s => !string.IsNullOrEmpty(s)); var data = string.Join(" ", nonEmptyData); _messageCollector.AddMessage(MessageClass.InformationMsg, data, true); }
public void CreateConnectionsProvider(MessageCollector messageCollector) { messageCollector.AddMessage(MessageClass.DebugMsg, "Determining if we need a database syncronizer"); if (!Settings.Default.UseSQLServer) return; messageCollector.AddMessage(MessageClass.DebugMsg, "Creating database syncronizer"); Runtime.ConnectionsService.RemoteConnectionsSyncronizer = new RemoteConnectionsSyncronizer(new SqlConnectionsUpdateChecker()); Runtime.ConnectionsService.RemoteConnectionsSyncronizer.Enable(); }
private static void CheckFipsPolicy(MessageCollector messageCollector) { messageCollector.AddMessage(MessageClass.InformationMsg, "Checking FIPS Policy...", true); if (!FipsPolicyEnabledForServer2003() && !FipsPolicyEnabledForServer2008AndNewer()) { return; } var errorText = string.Format(Language.strErrorFipsPolicyIncompatible, GeneralAppInfo.ProductName, GeneralAppInfo.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); messageCollector.AddMessage(MessageClass.ErrorMsg, errorText, true); MessageBox.Show(FrmMain.Default, errorText); Environment.Exit(1); }
public static void OpenConnection(ConnectionInfo.Force Force) { try { if (Windows.treeForm.tvConnections.SelectedNode.Tag == null) { return; } if (ConnectionTreeNode.GetNodeType(ConnectionTree.SelectedNode) == TreeNodeType.Connection | ConnectionTreeNode.GetNodeType(ConnectionTree.SelectedNode) == TreeNodeType.PuttySession) { OpenConnection((ConnectionInfo)Windows.treeForm.tvConnections.SelectedNode.Tag, Force); } else if (ConnectionTreeNode.GetNodeType(ConnectionTree.SelectedNode) == TreeNodeType.Container) { foreach (TreeNode tNode in ConnectionTree.SelectedNode.Nodes) { if (ConnectionTreeNode.GetNodeType(tNode) == TreeNodeType.Connection | ConnectionTreeNode.GetNodeType(ConnectionTree.SelectedNode) == TreeNodeType.PuttySession) { if (tNode.Tag != null) { OpenConnection((ConnectionInfo)tNode.Tag, Force); } } } } } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message); } }
private static void cMenConnectionPanelScreen_Click(object sender, EventArgs e) { Screen screen = null; DockContent panel = null; try { IEnumerable tagEnumeration = (IEnumerable)((ToolStripMenuItem)sender).Tag; if (tagEnumeration != null) { foreach (Object obj in tagEnumeration) { if (obj is Screen) { screen = (Screen)obj; } else if (obj is DockContent) { panel = (DockContent)obj; } } Screens.SendPanelToScreen(panel, screen); } } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, "Caught Exception: " + Environment.NewLine + ex.Message); } }
public static bool SaveReport() { StreamReader streamReader = null; StreamWriter streamWriter = null; try { streamReader = new StreamReader(SettingsFileInfo.exePath + "\\Report.log"); string text = streamReader.ReadToEnd(); streamReader.Close(); streamWriter = new StreamWriter(GeneralAppInfo.ReportingFilePath, true); streamWriter.Write(text); return(true); } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strLogWriteToFileFinalLocationFailed + Environment.NewLine + ex.Message, true); return(false); } finally { if (streamReader != null) { streamReader.Close(); streamReader.Dispose(); } if (streamWriter != null) { streamWriter.Close(); streamWriter.Dispose(); } } }
private static void CheckLenovoAutoScrollUtility(MessageCollector messageCollector) { messageCollector.AddMessage(MessageClass.InformationMsg, "Checking Lenovo AutoScroll Utility...", true); if (!Settings.Default.CompatibilityWarnLenovoAutoScrollUtility) { return; } var proccesses = new Process[] { }; try { proccesses = Process.GetProcessesByName("virtscrl"); } catch (InvalidOperationException ex) { messageCollector.AddExceptionMessage("Error in CheckLenovoAutoScrollUtility", ex); } if (proccesses.Length <= 0) { return; } CTaskDialog.MessageBox(Application.ProductName, Language.strCompatibilityProblemDetected, string.Format(Language.strCompatibilityLenovoAutoScrollUtilityDetected, Application.ProductName), "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.Ok, ESysIcons.Warning, ESysIcons.Warning); if (CTaskDialog.VerificationChecked) { Settings.Default.CompatibilityWarnLenovoAutoScrollUtility = false; } }
public static void Prot_Event_Connected(object sender) { ProtocolBase prot = (ProtocolBase)sender; MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strConnectionEventConnected, true); MessageCollector.AddMessage(MessageClass.ReportMsg, string.Format(Language.strConnectionEventConnectedDetail, prot.InterfaceControl.Info.Hostname, prot.InterfaceControl.Info.Protocol.ToString(), Environment.UserName, prot.InterfaceControl.Info.Description, prot.InterfaceControl.Info.UserField)); }
public static void Prot_Event_Closed(object sender) { try { ProtocolBase Prot = (ProtocolBase)sender; MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strConnenctionCloseEvent, true); MessageCollector.AddMessage(MessageClass.ReportMsg, string.Format(Language.strConnenctionClosedByUser, Prot.InterfaceControl.Info.Hostname, Prot.InterfaceControl.Info.Protocol.ToString(), Environment.UserName)); Prot.InterfaceControl.Info.OpenConnections.Remove(Prot); if (Prot.InterfaceControl.Info.OpenConnections.Count < 1 && Prot.InterfaceControl.Info.IsQuickConnect == false) { ConnectionTreeNode.SetNodeImage(Prot.InterfaceControl.Info.TreeNode, TreeImageType.ConnectionClosed); } if (Prot.InterfaceControl.Info.PostExtApp != "") { ExternalTool extA = GetExtAppByName(Prot.InterfaceControl.Info.PostExtApp); if (extA != null) { extA.Start(Prot.InterfaceControl.Info); } } } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnenctionCloseEventFailed + Environment.NewLine + ex.Message, true); } }
public static void SaveConnections(bool Update = false) { if (!IsConnectionsFileLoaded) { return; } try { if (Update && Settings.Default.UseSQLServer == false) { return; } if (SQLConnProvider != null) { SQLConnProvider.Disable(); } ConnectionsSaver conS = new ConnectionsSaver(); if (!Settings.Default.UseSQLServer) { conS.ConnectionFileName = GetStartupConnectionFileName(); } conS.ConnectionList = ConnectionList; conS.ContainerList = ContainerList; conS.Export = false; conS.SaveSecurity = new Security.Save(); conS.RootTreeNode = Windows.treeForm.tvConnections.Nodes[0]; if (Settings.Default.UseSQLServer) { conS.SaveFormat = ConnectionsSaver.Format.SQL; conS.SQLHost = Convert.ToString(Settings.Default.SQLHost); conS.SQLDatabaseName = Convert.ToString(Settings.Default.SQLDatabaseName); conS.SQLUsername = Convert.ToString(Settings.Default.SQLUser); var cryptographyProvider = new LegacyRijndaelCryptographyProvider(); conS.SQLPassword = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.SQLPass), GeneralAppInfo.EncryptionKey); } conS.SaveConnections(); if (Settings.Default.UseSQLServer) { LastSqlUpdate = DateTime.Now; } } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionsFileCouldNotBeSaved + Environment.NewLine + ex.Message); } finally { SQLConnProvider?.Enable(); } }
public void MessageAddedToList() { var message = Substitute.For <IMessage>(); _messageCollector.AddMessage(message); Assert.That(_messageCollector.Messages, Does.Contain(message)); }
private void SetSupportedCulture() { if (mRemoteNG.Settings.Default.OverrideUICulture == "" || !SupportedCultures.IsNameSupported(mRemoteNG.Settings.Default.OverrideUICulture)) { return; } Thread.CurrentThread.CurrentUICulture = new CultureInfo(mRemoteNG.Settings.Default.OverrideUICulture); _messageCollector.AddMessage(MessageClass.InformationMsg, $"Override Culture: {Thread.CurrentThread.CurrentUICulture.Name}/{Thread.CurrentThread.CurrentUICulture.NativeName}", true); }
public static void OpenConnection(ConnectionInfo ConnectionInfo, ConnectionInfo.Force Force) { try { OpenConnectionFinal(ConnectionInfo, Force, null); } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message); } }
private static void OpenConnectionFinal(ConnectionInfo ConnectionInfo, ConnectionInfo.Force Force, Form ConForm) { try { if (ConnectionInfo.Hostname == "" && ConnectionInfo.Protocol != ProtocolType.IntApp) { MessageCollector.AddMessage(MessageClass.WarningMsg, Language.strConnectionOpenFailedNoHostname); return; } StartPreConnectionExternalApp(ConnectionInfo); if ((Force & ConnectionInfo.Force.DoNotJump) != ConnectionInfo.Force.DoNotJump) { if (SwitchToOpenConnection(ConnectionInfo)) { return; } } ProtocolFactory protocolFactory = new ProtocolFactory(); ProtocolBase newProtocol = protocolFactory.CreateProtocol(ConnectionInfo); string connectionPanel = SetConnectionPanel(ConnectionInfo, Force); Form connectionForm = SetConnectionForm(ConForm, connectionPanel); Control connectionContainer = SetConnectionContainer(ConnectionInfo, connectionForm); SetConnectionFormEventHandlers(newProtocol, connectionForm); SetConnectionEventHandlers(newProtocol); BuildConnectionInterfaceController(ConnectionInfo, newProtocol, connectionContainer); newProtocol.Force = Force; if (newProtocol.Initialize() == false) { newProtocol.Close(); return; } if (newProtocol.Connect() == false) { newProtocol.Close(); return; } ConnectionInfo.OpenConnections.Add(newProtocol); SetTreeNodeImages(ConnectionInfo); frmMain.Default.SelectedConnection = ConnectionInfo; } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message); } }
public static void SaveConnections(bool update = false) { if (ConnectionTreeModel == null) { return; } try { if (update && Settings.Default.UseSQLServer == false) { return; } RemoteConnectionsSyncronizer?.Disable(); var connectionsSaver = new ConnectionsSaver(); if (!Settings.Default.UseSQLServer) { connectionsSaver.ConnectionFileName = GetStartupConnectionFileName(); } connectionsSaver.Export = false; connectionsSaver.SaveFilter = new SaveFilter(); connectionsSaver.ConnectionTreeModel = ConnectionTreeModel; if (Settings.Default.UseSQLServer) { connectionsSaver.SaveFormat = ConnectionsSaver.Format.SQL; connectionsSaver.SQLHost = Convert.ToString(Settings.Default.SQLHost); connectionsSaver.SQLDatabaseName = Convert.ToString(Settings.Default.SQLDatabaseName); connectionsSaver.SQLUsername = Convert.ToString(Settings.Default.SQLUser); var cryptographyProvider = new LegacyRijndaelCryptographyProvider(); connectionsSaver.SQLPassword = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.SQLPass), EncryptionKey); } connectionsSaver.SaveConnections(); if (Settings.Default.UseSQLServer) { LastSqlUpdate = DateTime.Now; } } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionsFileCouldNotBeSaved + Environment.NewLine + ex.Message); } finally { RemoteConnectionsSyncronizer?.Enable(); } }
public static void Report(string Text) { try { StreamWriter sWr = new StreamWriter(SettingsFileInfo.exePath + "\\Report.log", true); sWr.WriteLine(Text); sWr.Close(); } catch (Exception) { MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strLogWriteToFileFailed); } }
public static Form AddPanel(string title = "", bool noTabber = false) { try { var connectionForm = new ConnectionWindow(new DockContent()); BuildConnectionWindowContextMenu(connectionForm); SetConnectionWindowTitle(title, connectionForm); ShowConnectionWindow(connectionForm); PrepareTabControllerSupport(noTabber, connectionForm); return(connectionForm); } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, "Couldn\'t add panel" + Environment.NewLine + ex.Message); return(null); } }
public static void Prot_Event_ErrorOccured(object sender, string ErrorMessage) { try { MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strConnectionEventErrorOccured, true); ProtocolBase Prot = (ProtocolBase)sender; if (Prot.InterfaceControl.Info.Protocol == ProtocolType.RDP) { if (Convert.ToInt32(ErrorMessage) > -1) { MessageCollector.AddMessage(MessageClass.WarningMsg, string.Format(Language.strConnectionRdpErrorDetail, ErrorMessage, ProtocolRDP.FatalErrors.GetError(ErrorMessage))); } } } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionEventConnectionFailed + Environment.NewLine + ex.Message, true); } }
private static void cMenConnectionPanelRename_Click(Object sender, EventArgs e) { try { ConnectionWindow conW = default(ConnectionWindow); conW = (ConnectionWindow)((ToolStripMenuItem)sender).Tag; string nTitle = ""; input.InputBox(Language.strNewTitle, Language.strNewTitle + ":", ref nTitle); if (!string.IsNullOrEmpty(nTitle)) { conW.SetFormText(nTitle.Replace("&", "&&")); } } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, "Couldn\'t rename panel" + Environment.NewLine + ex.Message); } }
public static void Prot_Event_Disconnected(object sender, string DisconnectedMessage) { try { MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strProtocolEventDisconnected, DisconnectedMessage), true); ProtocolBase Prot = (ProtocolBase)sender; if (Prot.InterfaceControl.Info.Protocol == ProtocolType.RDP) { string ReasonCode = DisconnectedMessage.Split("\r\n".ToCharArray())[0]; string desc = DisconnectedMessage.Replace("\r\n", " "); if (Convert.ToInt32(ReasonCode) > 3) { MessageCollector.AddMessage(MessageClass.WarningMsg, Language.strRdpDisconnected + Environment.NewLine + desc); } } } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, string.Format(Language.strProtocolEventDisconnectFailed, ex.Message), true); } }
private static void cMenConnectionPanelScreens_DropDownOpening(Object sender, EventArgs e) { try { ToolStripMenuItem cMenScreens = (ToolStripMenuItem)sender; cMenScreens.DropDownItems.Clear(); for (int i = 0; i <= Screen.AllScreens.Length - 1; i++) { ToolStripMenuItem cMenScreen = new ToolStripMenuItem(Language.strScreen + " " + Convert.ToString(i + 1)); cMenScreen.Tag = new ArrayList(); cMenScreen.Image = Resources.Monitor_GoTo; (cMenScreen.Tag as ArrayList).Add(Screen.AllScreens[i]); (cMenScreen.Tag as ArrayList).Add(cMenScreens.Tag); cMenScreen.Click += cMenConnectionPanelScreen_Click; cMenScreens.DropDownItems.Add(cMenScreen); } } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, "Couldn\'t enumerate screens" + Environment.NewLine + ex.Message); } }
public void ParseArguments(IEnumerable <string> cmdlineArgs) { //if (!cmdlineArgs.Any()) return; _messageCollector.AddMessage(MessageClass.DebugMsg, "Parsing cmdline arguments"); try { var args = new CmdArgumentsInterpreter(cmdlineArgs); ParseResetPositionArg(args); ParseResetPanelsArg(args); ParseResetToolbarArg(args); ParseNoReconnectArg(args); ParseCustomConnectionPathArg(args); } catch (Exception ex) { _messageCollector.AddExceptionMessage(Language.strCommandLineArgsCouldNotBeParsed, ex, logOnly: false); } }
public void LoadExternalAppsFromXML() { #if !PORTABLE var oldPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), GeneralAppInfo.ProductName, SettingsFileInfo.ExtAppsFilesName); #endif var newPath = Path.Combine(SettingsFileInfo.SettingsPath, SettingsFileInfo.ExtAppsFilesName); var xDom = new XmlDocument(); if (File.Exists(newPath)) { _messageCollector.AddMessage(MessageClass.InformationMsg, $"Loading External Apps from: {newPath}", true); xDom.Load(newPath); } #if !PORTABLE else if (File.Exists(oldPath)) { _messageCollector.AddMessage(MessageClass.InformationMsg, $"Loading External Apps from: {oldPath}", true); xDom.Load(oldPath); } #endif else { _messageCollector.AddMessage(MessageClass.WarningMsg, "Loading External Apps failed: Could not FIND file!"); return; } if (xDom.DocumentElement == null) { _messageCollector.AddMessage(MessageClass.WarningMsg, "Loading External Apps failed: Could not LOAD file!"); return; } foreach (XmlElement xEl in xDom.DocumentElement.ChildNodes) { var extA = new ExternalTool { DisplayName = xEl.Attributes["DisplayName"].Value, FileName = xEl.Attributes["FileName"].Value, Arguments = xEl.Attributes["Arguments"].Value }; // check before, since old save files won't have this set if (xEl.HasAttribute("WorkingDir")) { extA.WorkingDir = xEl.Attributes["WorkingDir"].Value; } if (xEl.HasAttribute("RunElevated")) { extA.RunElevated = bool.Parse(xEl.Attributes["RunElevated"].Value); } if (xEl.HasAttribute("WaitForExit")) { extA.WaitForExit = bool.Parse(xEl.Attributes["WaitForExit"].Value); } if (xEl.HasAttribute("TryToIntegrate")) { extA.TryIntegrate = bool.Parse(xEl.Attributes["TryToIntegrate"].Value); } if (xEl.HasAttribute("ShowOnToolbar")) { extA.ShowOnToolbar = bool.Parse(xEl.Attributes["ShowOnToolbar"].Value); } _messageCollector.AddMessage(MessageClass.InformationMsg, $"Adding External App: {extA.DisplayName} {extA.FileName} {extA.Arguments}", true); Runtime.ExternalToolsService.ExternalTools.Add(extA); } _externalToolsToolStrip.SwitchToolBarText(mRemoteNG.Settings.Default.ExtAppsTBShowText); _externalToolsToolStrip.AddExternalToolsToToolBar(); }