private ListViewItem LocateItem(MOG_Command command, ListView view) { // This is a much faster way to check if the command already exists in our list if (view.Items.ContainsKey(command.GetCommandID().ToString())) { return(view.Items[mainForm.CommandspendingListView.Items.IndexOfKey(command.GetCommandID().ToString())]); } return(null); }
internal bool RecoverCommand(MOG_Command pCommand) { bool bRecovered = false; // Get the appropriate command list for this command HybridDictionary commandList = GetJobCommandList(pCommand); if (commandList != null) { if (commandList.Contains(pCommand.GetCommandID().ToString())) { // Clear the assigned slave pCommand.SetAssignedSlaveID(0); commandList[pCommand.GetCommandID().ToString()] = pCommand; bRecovered = true; } } return(bRecovered); }
internal bool AddCommand(MOG_Command pCommand) { bool bSuccess = false; // Check if this is the StartJob command? if (pCommand.GetCommandType() == MOG.COMMAND.MOG_COMMAND_TYPE.MOG_COMMAND_StartJob) { mStartJobCommand = pCommand; bSuccess = true; } else { // Check if this command has requested to have duplicate commands removed? if (pCommand.IsRemoveDuplicateCommands()) { // Scan the Server's command queue looking for any other instance of this same command? if (RemoveDuplicateCommands(pCommand)) { } } // Check if this is a completed command? if (pCommand.GetCommandType() == MOG.COMMAND.MOG_COMMAND_TYPE.MOG_COMMAND_Complete) { // Immediately process 'Complete' commands if (ProcessCommand(pCommand)) { // Remove the original command that is encapsulated within this 'Complete' command RemoveCommand(pCommand.GetCommand()); bSuccess = true; } } else { // Get the appropriate command list for this command HybridDictionary commandList = GetJobCommandList(pCommand); if (commandList != null) { // Make sure we always clear the command's assigned slave or else it will never get processed pCommand.SetAssignedSlaveID(0); // Add this command to the appropriate list for later processing commandList[pCommand.GetCommandID().ToString()] = pCommand; bSuccess = true; } } } return(bSuccess); }
internal bool Command_KillCommand(MOG_Command pCommand) { // Enumerate through all the jobs foreach (MOG_JobInfo job in mJobOrder) { if (job != null) { // Attempt to remove the command from this job job.KillCommand(pCommand.GetCommandID()); } } // Check the active slaves to see if it is being processed? // Just in case the command we want to kill has already been tasked out to a slave for (int c = 0; c < mActiveSlaves.Count; c++) { // Check this slave's assigned command? MOG_Command activeSlave = (MOG_Command)mActiveSlaves[c]; MOG_Command pActiveCommand = activeSlave.GetCommand(); if (pActiveCommand != null) { // Checkif the CommandID matches? if (pActiveCommand.GetCommandID() == pCommand.GetCommandID()) { // Clear the command this slave is working on activeSlave.SetCommand(null); // Always kill the connection to this slave just in case it was hung by the command MOG_ControllerSystem.ShutdownSlave(activeSlave.GetNetworkID()); break; } } } // Always eat this command return(true); }
internal bool RemoveCommand(MOG_Command pCommand) { bool bRemoved = false; // Get the appropriate command list for this command HybridDictionary commandList = GetJobCommandList(pCommand); if (commandList != null) { commandList.Remove(pCommand.GetCommandID().ToString()); bRemoved = true; } return(bRemoved); }
internal bool ReleaseSlave(MOG_Command pCommand) { // Scan mActiveSlaves looking for one that matches this command // This way is safer just in case NetworkIDs get reset from a reconnect event for (int s = 0; s < mActiveSlaves.Count; s++) { MOG_Command pSlave = (MOG_Command)mActiveSlaves[s]; // Check if this slave is working on something? if (pSlave.GetCommand() != null) { // Check if the CommandID matches? if (pSlave.GetCommand().GetCommandID() == pCommand.GetCommandID()) { // Clear this slave's command pSlave.SetCommand(null); // Refresh the command's SetAssignedSlaveID pCommand.SetAssignedSlaveID(pSlave.GetNetworkID()); // Send out needed Notify command MOG_Command pNotify = MOG_CommandFactory.Setup_NotifyActiveConnection(pSlave); mServerCommandManager.SendToActiveTab("Connections", pNotify); pNotify = MOG_CommandFactory.Setup_NotifyActiveCommand(pCommand); mServerCommandManager.SendToActiveTab("Connections", pNotify); // Insert the slave at the top of mAvailableSlaves so it will be immeadiately reused mAvailableSlaves.Insert(0, pSlave); // Erase the slave from mActiveSlaves mActiveSlaves.RemoveAt(s); // Return the command that the slave was processing for reference return(true); } } } string message = String.Concat("Server could not release slave because it failed to locate the slave in mActiveSlaves\n", "Command:", pCommand.ToString(), " NetworkID:", pCommand.GetNetworkID(), " Asset:", pCommand.GetAssetFilename().GetOriginalFilename()); MOG_Report.ReportMessage("Server", message, Environment.StackTrace, MOG_ALERT_LEVEL.ERROR); return(false); }
public void LoadCommand(MOG_Command command) { tbComputer.Text = command.GetComputerName(); tbDate.Text = MogUtils_StringVersion.VersionToString(command.GetCommandTimeStamp()); tbIp.Text = command.GetComputerIP(); tbID.Text = command.GetCommandID().ToString(); tbProject.Text = command.GetProject(); tbType.Text = command.GetCommandType().ToString(); tbUser.Text = command.GetUserName(); tbBranch.Text = command.GetBranch(); tbJobId.Text = command.GetJobLabel(); tbBlocking.Text = command.IsBlocking().ToString(); tbSlaveID.Text = command.mAssignedSlaveID.ToString(); tbCompleted.Text = command.IsCompleted().ToString(); tbValidSlaves.Text = command.GetValidSlaves(); if (command.GetAssetFilename() != null) { tbAssetName.Text = command.GetAssetFilename().GetAssetFullName(); } }
public void RefreshWindow(MOG_Command command) { if (command == null) { GetCommandSnapShot(); } else { ListViewItem item = null; switch (command.GetCommandType()) { // Eat these commands, we don't need to show them in this window case MOG_COMMAND_TYPE.MOG_COMMAND_None: case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionKill: case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionLost: case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionNew: case MOG_COMMAND_TYPE.MOG_COMMAND_InstantMessage: case MOG_COMMAND_TYPE.MOG_COMMAND_LockCopy: case MOG_COMMAND_TYPE.MOG_COMMAND_LockMove: case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRelease: case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest: case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRelease: case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest: case MOG_COMMAND_TYPE.MOG_COMMAND_LoginProject: case MOG_COMMAND_TYPE.MOG_COMMAND_LoginUser: case MOG_COMMAND_TYPE.MOG_COMMAND_NetworkBroadcast: case MOG_COMMAND_TYPE.MOG_COMMAND_NewBranch: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveCommand: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveConnection: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveLock: case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterClient: case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterCommandLine: case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterEditor: case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterSlave: case MOG_COMMAND_TYPE.MOG_COMMAND_RemoveAssetFromProject: case MOG_COMMAND_TYPE.MOG_COMMAND_RequestActiveCommands: case MOG_COMMAND_TYPE.MOG_COMMAND_RequestActiveConnections: case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownClient: case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownCommandLine: case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownEditor: case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownSlave: case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshApplication: case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshTools: case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshProject: case MOG_COMMAND_TYPE.MOG_COMMAND_ViewConnection: case MOG_COMMAND_TYPE.MOG_COMMAND_ViewLock: case MOG_COMMAND_TYPE.MOG_COMMAND_ActiveViews: case MOG_COMMAND_TYPE.MOG_COMMAND_ViewUpdate: case MOG_COMMAND_TYPE.MOG_COMMAND_AssetProcessed: break; default: string commandString = command.ToString(); if (command.IsCompleted()) { item = LocateItem(command, mainForm.CommandspendingListView); while (item != null) { item.Remove(); item = LocateItem(command, mainForm.CommandspendingListView); } } else { // See if it already exists if (LocateItem(command, mainForm.CommandspendingListView) == null) { item = new ListViewItem(); item.Text = command.ToString(); item.SubItems.Add(command.GetAssetFilename().GetOriginalFilename()); item.SubItems.Add(command.GetComputerName().ToString()); item.SubItems.Add(command.GetComputerIP().ToString()); 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.ImageIndex = GetImageIndex(command.GetCommandType()); // Assign the Key for this listViewItem item.Name = command.GetCommandID().ToString(); mainForm.CommandspendingListView.Items.Add(item); } } break; } } }
public void UpdateCommands(MOG_Command command) { ListViewItem item; MOG_Command action = command.GetCommand(); if (action != null) { bool bAdd = false; bool bRemove = false; switch (action.GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_None: case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionKill: case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionLost: case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionNew: case MOG_COMMAND_TYPE.MOG_COMMAND_InstantMessage: case MOG_COMMAND_TYPE.MOG_COMMAND_LaunchSlave: case MOG_COMMAND_TYPE.MOG_COMMAND_LockCopy: case MOG_COMMAND_TYPE.MOG_COMMAND_LockMove: case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRelease: case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest: case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRelease: case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest: case MOG_COMMAND_TYPE.MOG_COMMAND_LoginProject: case MOG_COMMAND_TYPE.MOG_COMMAND_LoginUser: case MOG_COMMAND_TYPE.MOG_COMMAND_NetworkBroadcast: case MOG_COMMAND_TYPE.MOG_COMMAND_NewBranch: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveCommand: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveConnection: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveLock: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemAlert: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemError: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemException: case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterClient: case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterCommandLine: case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterEditor: case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterSlave: case MOG_COMMAND_TYPE.MOG_COMMAND_RequestActiveCommands: case MOG_COMMAND_TYPE.MOG_COMMAND_RequestActiveConnections: case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownClient: case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownCommandLine: case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownEditor: case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownSlave: case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshApplication: case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshTools: case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshProject: case MOG_COMMAND_TYPE.MOG_COMMAND_ViewConnection: case MOG_COMMAND_TYPE.MOG_COMMAND_ViewLock: case MOG_COMMAND_TYPE.MOG_COMMAND_ActiveViews: case MOG_COMMAND_TYPE.MOG_COMMAND_ViewUpdate: // Eat these commands, we don't need to show them in this window break; case MOG_COMMAND_TYPE.MOG_COMMAND_Complete: // Drill one more level into this Complete command action = action.GetCommand(); bRemove = true; break; // All other commands can simply be added default: bAdd = true; break; } // Check if we are removing the command? if (bRemove) { // Strip out any matching commands do { // Find it using specific information // item = LocateItem((int)CommandsColumns.COMMANDID, action.GetCommandID().ToString(), mainForm.ConnectionManagerCommandsListView); item = LocateCommandItem(action); if (item != null) { item.Remove(); } } while(item != null); } // Check if we are adding the command? if (bAdd) { // Find it using a generic approach item = LocateCommandItem(action); if (item != null) { // Check if this could replace an existing command? if (action.IsRemoveDuplicateCommands()) { // Remove the duplicate item.Remove(); item = null; } } // Check if the item already exists if (item == null) { //It doesn't already exist, so let's make a new one item = new ListViewItem(); MOG_Time time = new MOG_Time(); time.SetTimeStamp(command.GetCommandTimeStamp()); string assetFullName = "PROJECT: " + action.GetProject() + " ASSET: " + action.GetAssetFilename().GetAssetOriginalFullName(); if (string.Compare(action.GetProject(), MOG_ControllerProject.GetProjectName(), true) == 0) { assetFullName = action.GetAssetFilename().GetAssetFullName(); } item.Text = action.ToString(); item.SubItems.Add(assetFullName); item.SubItems.Add(action.GetPlatform()); item.SubItems.Add(action.IsCompleted() ? "Working" : ""); item.SubItems.Add(action.GetJobLabel()); item.SubItems.Add(action.GetComputerName().ToString()); item.SubItems.Add(action.GetComputerIP().ToString()); item.SubItems.Add(action.GetNetworkID().ToString()); item.SubItems.Add(action.GetCommandID().ToString()); item.Tag = action; item.ImageIndex = GetImageIndex(action.GetCommandType()); mainForm.ConnectionManagerCommandsListView.Items.Add(item); } } } }