static public int GetFileIconIndex(string filename, string overlayIcon) { if (mFileTypeManager == null) { mFileTypeManager = new IconListManager(mAssetTypeImages, IconReader.IconSize.Small); } int returnInt = 0; // Make sure this is a full path, if not append the tools directory to it? string overlayIconFilename = MOG_ControllerSystem.LocateTool(overlayIcon); // Try getting a File Icon if (File.Exists(filename) && File.Exists(overlayIconFilename)) { returnInt = mFileTypeManager.AddFileOverlayIcon(filename, "MISSING", overlayIconFilename); } // If we got the default index, return our Class Icon index if (returnInt == 0) { return(GetAssetIconIndex(filename, null)); } else { return(returnInt); } }
private bool IsTextBoxValid(TextBox textBox) { // Check if this textBox is enabled? if (textBox.Enabled) { // Check if we have any text? if (!String.IsNullOrEmpty(textBox.Text) && !MOG_ControllerSystem.InvalidWindowsPathCharactersCheck(textBox.Text, true)) { // Color us green textBox.BackColor = Color.PaleGreen; return(true); } else { // Color us red textBox.BackColor = Color.Tomato; } } else { // Color us red textBox.BackColor = Color.LightGray; } return(false); }
static private int LoadIcon(string imageFileName, string assetClassName) { try { if (imageFileName != null && imageFileName.Length > 0) { // Load the icon specified by the Icon= key string iconName = imageFileName; // Make sure this is a full path, if not append the tools directory to it? iconName = MOG_ControllerSystem.LocateTool(imageFileName); // Make sure that the icon file exists if (iconName.Length > 0 && DosUtils.FileExist(iconName)) { // Get the image Image image = new Bitmap(iconName); return(InternalAddIconToLists(assetClassName, iconName, image)); } } } catch (Exception e) { MOG_Report.ReportSilent("Load Icon", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL); } return(0); }
private void niconSystemTrayIcon_DoubleClick(object sender, System.EventArgs e) { MOG_CommandSlave manager = (MOG_CommandSlave)MOG_ControllerSystem.GetCommandManager(); mLogWindow = new CommandLineLog(manager); mLogWindow.Show(); }
// Show the command line output private void mnuItmShowLog_Click(object sender, System.EventArgs e) { MOG_CommandSlave manager = (MOG_CommandSlave)MOG_ControllerSystem.GetCommandManager(); mLogWindow = new CommandLineLog(manager); mLogWindow.Show(); }
private void RefreshLists() { // get connection lists MOG_CommandServerCS commandServer = (MOG_CommandServerCS)MOG_ControllerSystem.GetCommandManager(); if (commandServer == null) { return; } this.slaveList = commandServer.GetRegisteredSlaves(); this.clientList = commandServer.GetRegisteredClients(); this.editorList = commandServer.GetRegisteredEditors(); this.serverList = new ArrayList(); // build server's "command" MOG_Command command = new MOG_Command(); command.SetComputerName(MOG_ControllerSystem.GetComputerName()); command.SetComputerIP(MOG_ControllerSystem.GetComputerIP()); command.SetNetworkID(1); command.SetCommandType(0); command.SetDescription(""); this.serverList.Add(command); }
public void KillCommand() { try { List <ListViewItem> killed = new List <ListViewItem>(); foreach (ListViewItem item in mainForm.CommandspendingListView.SelectedItems) { UInt32 commandID = Convert.ToUInt32(item.SubItems[(int)CommandsColumns.COMMANDID].Text); if (MOG_ControllerSystem.KillCommandFromServer(commandID)) { killed.Add(item); } } foreach (ListViewItem item in killed) { item.Remove(); } } catch (Exception e) { MOG_Report.ReportMessage("Kill Command Error", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR); } }
bool ReleaseInactiveSlaves() { // Make sure we didn't just barely request a new slave? if (DateTime.Now > mNextSlaveRequstTime) { // Check if we have any remaining auto-launched slaves that can be shut down? if (mAutoLaunchedSlaveNames.Count != 0) { // Check if enough time has passed since our last shutdown? if (DateTime.Now > mNextSlaveReleaseTime) { // Get the slave off of the bottom of our mAutoLaunchedSlaveNames string slaveName = (String)mAutoLaunchedSlaveNames[mAutoLaunchedSlaveNames.Count - 1]; // Remove this slave from our list RemoveAutoLaunchedSlaveName(slaveName); // Check if there is already a slave running on this machine? if (LocateAvailableSlaveByComputerName(slaveName) != null) { // Inform this slave to terminate itself MOG_ControllerSystem.ShutdownSlave(slaveName); mNextSlaveReleaseTime = DateTime.Now.AddSeconds(5); return(true); } } } } return(false); }
static public List <string> GetPlatforms(string project) { List <string> platformNames = new List <string>(); MOG_Project projectPtr; if (project.Length != 0) { projectPtr = MOG_ControllerSystem.GetSystem().GetProject(project); } else { projectPtr = MOG_ControllerProject.GetProject(); } // Make sure we have an active project if (projectPtr != null) { ArrayList platforms = MOG_ControllerProject.GetProject().GetPlatforms(); // Add a comboBox item for every platform foreach (MOG_Platform platform in platforms) { platformNames.Add(platform.mPlatformName); } } return(platformNames); }
public void InitializeSQLControl() { packetSize = "4096"; // Try and get our current settings string connectionString = ""; if (MOG_ControllerSystem.GetDB() != null && MOG_ControllerSystem.GetDB().GetConnectionString().Length > 0) { connectionString = MOG_ControllerSystem.GetDB().GetConnectionString(); LoadConnectionString(connectionString.Trim("@".ToCharArray())); } else { // packet size=4096;integrated security=SSPI;data source="NEMESIS";persist security info=False;initial catalog=mog security = "SSPI"; persistSecurity = "False"; dataSource = ""; initialCatalog = "mog"; SQLServerComboBox.Text = dataSource; SQLDatabaseComboBox.Text = initialCatalog; } mConnectString = ""; }
static public void MOGGlobalViewRemoteMachineInit(MogMainForm mainForm) { // Reset our list to a virgin state for (int x = mainForm.remoteMachinesToolStripMenuItem.DropDownItems.Count; x > 1; x--) { ToolStripItem item = mainForm.remoteMachinesToolStripMenuItem.DropDownItems[x - 1]; if (string.Compare(item.Text, "&Add...", true) != 0) { mainForm.remoteMachinesToolStripMenuItem.DropDownItems.RemoveAt(x - 1); } } ArrayList machineNames = MOG_ControllerSystem.LocateTools("RemoteConnections", "*.RDP"); machineNames.Sort(); // Add a separator ToolStripSeparator separator = new ToolStripSeparator(); mainForm.remoteMachinesToolStripMenuItem.DropDownItems.Add(separator); // Add each machine name foreach (string machine in machineNames) { ToolStripMenuItem Item = new ToolStripMenuItem(Path.GetFileNameWithoutExtension(machine)); Item.Click += new System.EventHandler(MainMenuViewClass.MOGGlobalViewRemoteMachine_Click); mainForm.remoteMachinesToolStripMenuItem.DropDownItems.Add(Item); } }
public VersionManagerClass(MOG_ServerManagerMainForm main) { mainForm = main; mainForm.VersionFilesListView.SmallImageList = MogUtil_AssetIcons.Images; ListViewSortManager serverVersions = new ListViewSortManager(mainForm.ServerListView, new Type[] { typeof(ListViewTextCaseInsensitiveSort), typeof(ListViewTextCaseInsensitiveSort) }); ListViewSortManager clientVersions = new ListViewSortManager(mainForm.ClientListView, new Type[] { typeof(ListViewTextCaseInsensitiveSort), typeof(ListViewTextCaseInsensitiveSort) }); mListViewSort_Manager.Add(serverVersions); mListViewSort_Manager.Add(clientVersions); mListViewSort_Manager.Add(new ListViewSortManager(mainForm.VersionFilesListView, new Type[] { typeof(ListViewTextCaseInsensitiveSort), typeof(ListViewDateSort), typeof(ListViewInt64Sort) } )); serverVersions.Sort(0, SortOrder.Descending); clientVersions.Sort(0, SortOrder.Descending); DeploymentDirectory = MOG_ControllerSystem.GetSystem().GetConfigFile().GetString("MOG", "Updates"); DeploymentDirectory = DeploymentDirectory.ToLower().Replace(MOG_Tokens.GetSystemRepositoryPath().ToLower(), MOG_ControllerSystem.GetSystemRepositoryPath()); }
static private int LoadIcon(string imageFileName, string assetClassName) { try { // Load the icon specified by the Icon= key string iconName = imageFileName; // Make sure this is a full path, if not append the tools directory to it? iconName = MOG_ControllerSystem.LocateTool(imageFileName); lock (mAssetTypes) { // Make sure that the icon file exists if (iconName.Length > 0 && DosUtils.FileExist(iconName)) { // Get the image Image myImage = new Bitmap(iconName); // Add the image and the type to the arrayLists mAssetTypeImages.Images.Add(myImage); mAssetTypes.Add(assetClassName, mAssetTypeImages.Images.Count - 1); return(mAssetTypeImages.Images.Count - 1); } } } catch (Exception e) { MOG_Report.ReportMessage("Load Icon", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL); } return(0); }
/// <summary> /// Keeps user from renaming multiple asset labels. /// </summary> private void RenameNewLabelTextBox_TextChanged(object sender, System.EventArgs e) { try { // Check for invalid characters in the new name if (MOG_ControllerSystem.InvalidMOGCharactersCheck(RenameNewLabelTextBox.Text, true)) { RenameNewLabelTextBox.Text = MOG_ControllerSystem.ReplaceInvalidCharacters(RenameNewLabelTextBox.Text); } // For Rename Label, we only need to worry about one asset... if (mFullFilename != null) { MOG_Filename currentFilename = new MOG_Filename(this.mFullFilename); string targetName = GetTargetName(currentFilename, RenameNewClassNameTextBox.Text, RenameNewPlatformComboBox.Text, RenameNewLabelTextBox.Text); ChangeAssetFilenameInListView(targetName); // Update the imported files column if (RenameFiles.Checked && bInitialized) { ChangeAssetImportnameInListView(RenameNewLabelTextBox.Text); } } } // Eat any errors we get catch (Exception ex) { MOG_Prompt.PromptMessage("Error With Value", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.ALERT); } }
public void ShellSpawnWithLock() { if (mBinary == null || mAsset == null) { MOG_Prompt.PromptMessage("Spawn Viewer Error!", "One of the following was not initialized: Viewer, Binary, Asset", Environment.StackTrace); return; } else { MOG_Command command = new MOG_Command(); // Get Asset Lock command = MOG.COMMAND.MOG_CommandFactory.Setup_LockReadRequest(mAsset.GetOriginalFilename(), "Asset View - Open Asset"); if (MOG_ControllerSystem.GetCommandManager().CommandProcess(command)) { string output = ""; if (mViewer != null && mViewer.Length == 0) { guiCommandLine.ShellExecute(mBinary); } else { guiCommandLine.ShellExecute(mViewer, mBinary, ProcessWindowStyle.Normal, ref output); } command = MOG.COMMAND.MOG_CommandFactory.Setup_LockReadRelease(mAsset.GetOriginalFilename()); MOG_ControllerSystem.GetCommandManager().CommandProcess(command); } } }
public void Initialize() { MOG_CommandServerCS server = (MOG_CommandServerCS)MOG_ControllerSystem.GetCommandManager(); mainForm.LocksListView.Items.Clear(); ArrayList activeWriteLocks = new ArrayList(server.GetActiveWriteLocks()); foreach (MOG_Command myLock in activeWriteLocks) { ListViewItem item = InitNewLockItem(myLock); if (item != null) { mainForm.LocksListView.Items.Add(item); } } ArrayList activeReadLocks = new ArrayList(server.GetActiveReadLocks()); foreach (MOG_Command myLock in activeReadLocks) { ListViewItem item = InitNewLockItem(myLock); if (item != null) { mainForm.LocksListView.Items.Add(item); } } mainForm.LocksRequestLocksListView.Items.Clear(); }
internal bool ConfirmLicense(MOG_Command pCommand) { bool bLicense = false; // Check if we are a client? MOG_CommandServerCS commandServer = (MOG_CommandServerCS)(MOG_ControllerSystem.GetCommandManager()); if (commandServer != null) { // Check if this client is already registered? if (commandServer.LocateClientByID(pCommand.GetNetworkID()) != null) { // JohnRen - Bummer, we can't check this because they may have just expired and now be legitamately running on the 4 connections // // Now double check the date of this command to ensure it hasn't expired // DateTime commandDate = MOG_Time.GetDateTimeFromTimeStamp(pCommand.GetCommandTimeStamp()); // if (!mTimeBomb.HasExpired(commandDate)) // { // Indicate this client is licensed bLicense = true; // } } else { // Let's try to obtain a license if (CanObtainLicense(pCommand)) { // Indicate this client got a license bLicense = true; } } } return(bLicense); }
public void GetCommandSnapShot() { // Clear our existing list mainForm.CommandspendingListView.Items.Clear(); // Obtain the server MOG_CommandServerCS server = (MOG_CommandServerCS)(MOG_ControllerSystem.GetCommandManager()); if (server != null) { // Get all the pending commands ArrayList commands = server.GetAllPendingCommands(); foreach (MOG_Command command in commands) { ListViewItem item = new ListViewItem(); item.Text = command.ToString(); item.SubItems.Add(command.GetAssetFilename().GetOriginalFilename()); item.SubItems.Add(command.GetComputerName()); item.SubItems.Add(command.GetComputerIP()); item.SubItems.Add(command.GetNetworkID().ToString()); item.SubItems.Add(command.GetCommandID().ToString()); item.SubItems.Add(command.GetCommandTimeStamp()); item.SubItems.Add(command.GetComputerName()); item.SubItems.Add(command.GetAssetFilename().GetOriginalFilename()); item.ForeColor = Color.Black; item.ImageIndex = GetImageIndex(command.GetCommandType()); item.Name = command.GetCommandID().ToString(); // Add the new item mainForm.CommandspendingListView.Items.Add(item); } } }
/// <summary> /// Populate all the mog aware directories within the 'MyProjects' node /// </summary> private void PopulateMogProjects() { TreeNode mogProjects = new TreeNode("MyProjects", 1, 1); GameDataTreeView.Nodes.Add(mogProjects); string userName = MOG_ControllerProject.GetUserName_DefaultAdmin(); // Get a list of all our projects that the server knows about ArrayList projectsArray = MOG_DBSyncedDataAPI.GetAllSyncedLocations(MOG_ControllerSystem.GetComputerName(), null, userName); if (projectsArray != null && projectsArray.Count > 0) { foreach (MOG_DBSyncedLocationInfo project in projectsArray) { // Hash our local tab name string LocalBranchName = "@" + project.mWorkingDirectory; MOG_ControllerSyncData targetGameData = new MOG_ControllerSyncData(project.mWorkingDirectory, project.mProjectName, project.mBranchName, project.mPlatformName, userName); TreeNode projectNode = new TreeNode(LocalBranchName, 4, 4); projectNode.Tag = new guiAssetTreeTag(project.mWorkingDirectory, projectNode, targetGameData); FillDirectory(projectNode, project.mWorkingDirectory, targetGameData); mogProjects.Nodes.Add(projectNode); } } // Create the helper project mogProjects.Nodes.Add("<Create new local branch>"); mogProjects.Expand(); }
private void SQLTestButton_Click(object sender, System.EventArgs e) { // Test the connection string // Attempt to open a connection to make sure we will work? BuildConnectionString(); // SqlConnection myConnection = new SqlConnection(mConnectString); // try // { // myConnection.Open(); // } // catch(Exception ex) if (!MOG_ControllerSystem.InitializeDatabase(mConnectString, "", "")) { //MOG_Report.ReportMessage("SQL Database", "Could not open SQL database!", MOGPromptButtons.OK); Utils.ShowMessageBoxExclamation("Couldn't connect to SQL database " + this.SQLDatabaseComboBox.Text + " on server " + SQLServerComboBox.Text, "Connection Failure"); return; } //MOG_Report.ReportMessage("SQL Database", "Successfully connected to SQL database " + SQLServerComboBox.Text + "!",MOGPromptButtons.OK); Utils.ShowMessageBoxInfo("Successfully connected to SQL database " + this.SQLDatabaseComboBox.Text + " on server " + SQLServerComboBox.Text, "Connection Successful"); // notify others that we clicked the Test button OnTestButtonClicked(); }
private void MogProcess() { while (!MOG_Main.isShutdown()) { try { MOG_Main.Process(); } catch (Exception ex) { MOG_Command pNotify = new MOG_Command(); pNotify.Setup_NotifySystemException("MogProcess:Exception Error durring Mog.Process" + "\n\nMessage: " + ex.ToString() + "\n\nStackTrace:" + ex.StackTrace.ToString()); MOG_ControllerSystem.GetCommandManager().CommandProcess(pNotify); MOG_REPORT.LogError("MogProcess", "Exception Error durring Mog.Process"); MOG_REPORT.LogError("MogProcess", ex.ToString()); MOG_REPORT.LogError("MogProcess", ex.StackTrace.ToString()); } Thread.Sleep(100); } Application.Exit(); mMogProcess.Abort(); mMogProcess = null; }
public void DisplayRefreshSlaveStatus() { //this needs to walk the connections and add all the connected computers. MOG_CommandServerCS commandServer = (MOG_CommandServerCS)MOG_ControllerSystem.GetCommandManager(); if (commandServer == null) { return; } ArrayList slavesArray = commandServer.GetRegisteredSlaves(); foreach (Object item in slavesArray) { MOG_Command connection = (MOG_Command)item; if (connection.GetCommandType() == MOG_COMMAND_TYPE.MOG_COMMAND_None) { // Find item ListViewItem lItem = LocateListViewItem(mainForm.lviewMonitor, connection.GetNetworkID()); if (lItem != null) { if (string.Compare(lItem.SubItems[(int)MONITOR_TABS.INFORMATION].Text, "Idle") != 0) { lItem.SubItems[(int)MONITOR_TABS.INFORMATION].Text = "Idle"; } } } } }
public void LoadFilter(string filterName) { // Is this an already fully qualified name? if (DosUtils.ExistFast(filterName) == false) { // No, then lets assume it came from the user's tools directory filterName = MOG_ControllerSystem.LocateTool(filterName + ".sync"); } SyncFilterComboBox.Text = Path.GetFileNameWithoutExtension(filterName); SyncFilterComboBox.Tag = filterName; if (DosUtils.ExistFast(filterName)) { //if (ClassificationTreeView.Visible) //{ // Reset the tree ClassificationTreeView.Initialize(OnWorkerCompleteLoadFilter); //} //else //{ // OnWorkerCompleteLoadFilter(); //} } }
private void Restore(string projName, string iniFilename) { // make sure iniFilename points to valid file if (File.Exists(iniFilename)) { // make sure directory exists if (Directory.Exists(MOG_ControllerSystem.GetSystemDeletedProjectsPath() + "\\" + projName)) { if (DosUtils.DirectoryExistFast(MOG_ControllerSystem.GetSystemProjectsPath() + "\\" + projName)) { // A project of this name already exists MOG_Prompt.PromptMessage("Project Name Conflict", "Projects cannot be restored over the top of another active project."); return; } List <string> args = new List <string>(); args.Add(projName); args.Add(iniFilename); string message = "Please wait while MOG restores deleted project.\n" + " PROJECT: " + projName; ProgressDialog progress = new ProgressDialog("Restoring project", message, Restore_Worker, args, false); progress.ShowDialog(); } } }
// checks projName against known project names, both those in the repository and in the database public static bool DuplicateProjectNameCheck(string projName, bool verbose) { // make sure we don't have a project called projName locally foreach (string existingProjName in MOG_ControllerSystem.GetSystem().GetProjectNames()) { if (existingProjName.ToLower() == projName.ToLower()) { if (verbose) { Utils.ShowMessageBoxExclamation("Duplicate project name.\nA project called " + projName + " already exists.", "Duplicate Project Name"); } return(false); } } // make sure projName doesn't exist in the tables if (MOG_ControllerSystem.GetDB().ProjectTablesExist(projName)) { // allow user to overwrite the tables if he wants if (Utils.ShowMessageBoxConfirmation("Project information tables for a project named " + projName + " currently exist in the database.\nWould you like to overwrite these tables?", "Overwrite Duplicate Tables?") == MOGPromptResult.No) { return(false); } // remove the tables MOG_ControllerSystem.GetDB().DeleteProjectTables(projName); } return(true); }
public void RetaskCommand() { foreach (ListViewItem item in mainForm.lviewMonitor.SelectedItems) { int netId = Convert.ToInt32(item.SubItems[(int)guiMonitor.MONITOR_TABS.ID].Text); MOG_ControllerSystem.RetaskAssignedSlaveCommand(netId); } }
/// <summary> /// Default constructor /// </summary> public MogControl_TaskEditor() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); mDb = MOG_ControllerSystem.GetDB(); TaskAsscociatedAssetsListView.SmallImageList = MogUtil_AssetIcons.Images; }
/// <summary> /// Edit the ripper in notepad /// </summary> private void EditRipper() { if (this.PropertiesList.Length > 0) { MOG_Properties properties = PropertiesList[0] as MOG_Properties; // Get the assigned ripper information string ripper = properties.AssetRipper; string tool = DosUtils.FileStripArguments(properties.AssetRipper); string args = DosUtils.FileGetArguments(properties.AssetRipper); // Do we have a ripper to edit? if (ripper.Length > 0) { // Locate the ripper ripper = MOG_ControllerSystem.LocateTool("", tool); if (ripper.Length > 0) { // Edit the ripper guiCommandLine.ShellSpawn("Notepad.exe", ripper); } else { // If not, do we want to create one? if (MOG_Prompt.PromptResponse("No Ripper Found", "This appears to be a new ripper.\n" + "RIPPER: " + tool + "\n\n" + "Would you like to create a new one for editing?", MOGPromptButtons.YesNo) == MOGPromptResult.Yes) { // Create a new one using the user's specified name string defaultRipperName = tool; ripper = Path.Combine(MOG_ControllerProject.GetProject().GetProjectToolsPath(), defaultRipperName); // Do we want to start from the template? if (MOG_Prompt.PromptResponse("Use Ripper Template", "Would you like to base the new ripper from MOG's ripper template?", MOGPromptButtons.YesNo) == MOGPromptResult.Yes) { // If so, copy the template to this new ripper string template = MOG_ControllerSystem.GetSystemRepositoryPath() + "\\Tools\\Rippers\\TemplateComplex_ripper.bat"; DosUtils.CopyFast(template, ripper, false); } // Launch the editor string output = ""; guiCommandLine.ShellExecute("Notepad.exe", ripper, System.Diagnostics.ProcessWindowStyle.Normal, ref output); // Now, set this new ripper as the ripper assigned to this asset restoring the users args properties.AssetRipper = ripper + " " + args; this.PropertiesRippingRipperComboBox.Text = properties.AssetRipper; } } } else { MOG_Prompt.PromptMessage("Edit Ripper", "There is no ripper to edit."); } } }
public MogUtil_ClassificationLoader() { // Attempt to use the normal default template defaultClassesPath = MOG_ControllerSystem.LocateInstallItem("ProjectTemplates\\Default"); if (defaultClassesPath.Length == 0) { // Fallback to using the library template defaultClassesPath = MOG_ControllerSystem.LocateInstallItem("ProjectTemplates\\Library"); } }
public EventCallbacks(FormMainSlave main) { mainForm = main; MOG_Callbacks callbacks = new MOG_Callbacks(); callbacks.mPreEventCallback = new MOG_CallbackCommandEvent(this.CommandPreEventCallBack); callbacks.mEventCallback = new MOG_CallbackCommandEvent(this.CommandEventCallBack); MOG_ControllerSystem.GetCommandManager().SetCallbacks(callbacks); }