static private DialogResult LockMessage(string message, MOG_Command desiredLockInfo, MOG_Command currentLockHolderInfo) { MOG_Time desiredLockTime = new MOG_Time(); desiredLockTime.SetTimeStamp(desiredLockInfo.GetCommand().GetCommandTimeStamp()); string desiredLockName = desiredLockInfo.GetAssetFilename().GetAssetFullName(); // Check if this asset is a classification if (desiredLockName.Length == 0) { desiredLockName = desiredLockInfo.GetAssetFilename().GetOriginalFilename(); } string desiredUser = desiredLockInfo.GetCommand().GetUserName().Length != 0 ? desiredLockInfo.GetCommand().GetUserName() : desiredLockInfo.GetCommand().GetComputerName(); string desiredMachine = desiredLockInfo.GetCommand().GetComputerName(); string desiredDescription = desiredLockInfo.GetCommand().GetDescription().Trim(); // Current lock holder MOG_Time currentLockTime = new MOG_Time(); currentLockTime.SetTimeStamp(currentLockHolderInfo.GetCommandTimeStamp()); string currentLockName = currentLockHolderInfo.GetAssetFilename().GetAssetFullName(); // Check if this asset is a classification if (currentLockName.Length == 0) { currentLockName = currentLockHolderInfo.GetAssetFilename().GetOriginalFilename(); } string currentLockUser = currentLockHolderInfo.GetUserName().Length != 0 ? currentLockHolderInfo.GetUserName() : currentLockHolderInfo.GetComputerName(); string currentLockMachine = currentLockHolderInfo.GetComputerName(); string currentLockDescription = currentLockHolderInfo.GetDescription().Trim(); return(MessageBox.Show(message + "\n\n" + desiredLockName + "\n" + " USER: "******"\n" + " MACHINE: " + desiredMachine + "\n" + " DESCRIPTION: " + desiredDescription + "\n" + " TIME: " + desiredLockTime.FormatString("") + "\n\n Colliding Lock:\n\n" + currentLockName + "\n" + " USER: "******"\n" + " MACHINE: " + currentLockMachine + "\n" + " DESCRIPTION: " + currentLockDescription + "\n" + " TIME: " + currentLockTime.FormatString(""), "Asset Locked!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question)); }
public bool GetTasksFromBox(string box, string section, Color textColor, System.Windows.Forms.ListView listViewToFill) { MOG_Ini contents = new MOG_Ini(); // Get a handle to the inbox\contents.info FileInfo file = new FileInfo(String.Concat(mParent.mMog.GetActiveUser().GetUserPath(), "\\", box, "\\Contents.info")); // If the .info file exists, open it if (file.Exists) { // Load the file contents.Load(file.FullName); // Find the items in the INBOX section if (contents.SectionExist(section)) { for (int i = 0; i < contents.CountKeys(section); i++) { ListViewItem node = new ListViewItem(); String assetName = contents.GetKeyNameByIndex(section, i); // Set the due date MOG_Time t = new MOG_Time(); t.SetTimeStamp(contents.GetString(assetName, "DUEDATE")); DateTime dueDate = t.ToDateTime(); node.Text = (contents.GetString(assetName, "TITLE")); // Name node.SubItems.Add(dueDate.ToString()); node.SubItems.Add(contents.GetString(assetName, "TIME")); node.SubItems.Add(contents.GetString(assetName, "CREATOR")); node.SubItems.Add(contents.GetString(assetName, "PRIORITY")); node.SubItems.Add(contents.GetString(assetName, "STATUS")); node.SubItems.Add(contents.GetString(assetName, "ASSET")); node.SubItems.Add(String.Concat(file.DirectoryName, "\\", assetName)); // Fullname node.SubItems.Add(box); // Current box node.ForeColor = textColor; node.ImageIndex = 0; //SetAssetIcon(String.Concat(mParent.mMog.GetActiveUser().GetUserPath(), "\\", box, "\\", assetName)); listViewToFill.Items.Add(node); } } contents.Close(); } return(true); }
private ListViewItem InitNewRequestItem(MOG_Command command) { if ((command.GetCommandType() == MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest) || (command.GetCommandType() == MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest)) { ListViewItem item = new ListViewItem(); MOG_Time time = new MOG_Time(); time.SetTimeStamp(command.GetCommandTimeStamp()); item.Text = command.ToString(); item.SubItems.Add(command.GetAssetFilename().GetOriginalFilename()); item.SubItems.Add(command.GetComputerIP()); item.SubItems.Add(time.FormatString("")); item.SubItems.Add(command.GetComputerName()); item.SubItems.Add(command.GetUserName()); item.SubItems.Add(Convert.ToString(command.GetNetworkID())); item.SubItems.Add(command.GetDescription()); item.SubItems.Add(command.ToString()); switch (command.GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest: item.Text = "Read Lock"; item.ForeColor = Color.Green; item.ImageIndex = 0; break; case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest: item.Text = "Write Lock"; item.ForeColor = Color.Red; item.ImageIndex = 0; break; } return(item); } return(null); }
public void RefreshBox(MOG_Filename add, MOG_Filename del, MOG_Command command) { Color textColorAdd = Color.Black; Color textColorDel = Color.Black; // Dont add if we dont have a valid box if (add.GetBoxName().Length == 0 && del.GetBoxName().Length == 0) { return; } ListView currentViewAdd = mParent.IsolateListView(add.GetBoxName(), add.GetType(), add.GetUserName(), ref textColorAdd); ListView currentViewDel = mParent.IsolateListView(del.GetBoxName(), del.GetType(), del.GetUserName(), ref textColorDel); if (currentViewAdd == currentViewDel) { // Check to see if this item already exists? int index = mParent.ListViewItemFindItem(add.GetFilename(), currentViewAdd); if (index != -1) { currentViewAdd.Items[index].SubItems[(int)guiAssetManager.TaskBoxColumns.STATUS].Text = command.GetDescription(); currentViewAdd.Items[index].SubItems[(int)guiAssetManager.TaskBoxColumns.FULLNAME].Text = add.GetFullFilename(); currentViewAdd.Items[index].ForeColor = textColorAdd; for (int x = 0; x < currentViewAdd.Items[index].SubItems.Count; x++) { currentViewAdd.Items[index].SubItems[x].ForeColor = textColorAdd; } } } else { if (currentViewDel != null) { int index = mParent.ListViewItemFindItem(del.GetFilename(), currentViewDel); if (index != -1) { currentViewDel.Items[index].Remove(); } } if (currentViewAdd != null) { // Check to see if this item already exists? int index = mParent.ListViewItemFindItem(add.GetFilename(), currentViewAdd); if (index != -1) { currentViewAdd.Items[index].SubItems[(int)guiAssetManager.TaskBoxColumns.STATUS].Text = command.GetDescription(); currentViewAdd.Items[index].SubItems[(int)guiAssetManager.TaskBoxColumns.FULLNAME].Text = add.GetFullFilename(); currentViewAdd.Items[index].ForeColor = textColorAdd; for (int x = 0; x < currentViewAdd.Items[index].SubItems.Count; x++) { currentViewAdd.Items[index].SubItems[x].ForeColor = textColorAdd; } } else { MOG_ControllerTask assetController = new MOG_ControllerTask(mParent.mMog); if (!assetController.Open(add.GetFullFilename())) { return; } ListViewItem item = new ListViewItem(); item.Text = assetController.GetTitle(); MOG_Time t = new MOG_Time(); t.SetTimeStamp(assetController.GetDueDate()); item.SubItems.Add(t.ToDateTime().ToString()); item.SubItems.Add(assetController.GetFileInfo().LastWriteTime.ToString()); item.SubItems.Add(assetController.GetCreator()); item.SubItems.Add(assetController.GetPriority()); item.SubItems.Add(assetController.GetStatus()); item.SubItems.Add(assetController.GetAsset()); item.SubItems.Add(assetController.GetAssetFilename().GetFullFilename()); item.SubItems.Add(assetController.GetAssetFilename().GetBoxName()); item.ForeColor = Color.Black; for (int x = 0; x < item.SubItems.Count; x++) { item.SubItems[x].ForeColor = textColorAdd; } item.ImageIndex = 0; //SetAssetIcon(String.Concat(mParent.mMog.GetActiveUser().GetUserPath(), "\\", box, "\\", assetName)); currentViewAdd.Items.Add(item); assetController.Close(); } } } // Update the tab RefreshTab(command); }
private ListViewItem InitNewLockItem(MOG_Command command) { if (command != null) { if ((command.GetCommandType() == MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest) || (command.GetCommandType() == MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest)) { ListViewItem item = new ListViewItem(); MOG_Time time = new MOG_Time(); time.SetTimeStamp(command.GetCommandTimeStamp()); // Gather appropriate lock info from the command's MOG_Filename string label = ""; string classification = ""; // Check if this is an asset? if (command.GetAssetFilename().GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset) { // Get the label and classifciation of the asset label = command.GetAssetFilename().GetAssetLabel(); classification = command.GetAssetFilename().GetAssetClassification(); // Obtain the proper icon item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(command.GetAssetFilename().GetOriginalFilename()); } // Check if this is a classification-level by seeing if it ends with a '*'? else if (command.GetAssetFilename().GetOriginalFilename().EndsWith("*")) { // Do our best to illustrate a classification-level lock label = "*"; classification = command.GetAssetFilename().GetOriginalFilename().Trim("*".ToCharArray()); // Obtain the proper icon item.ImageIndex = MogUtil_AssetIcons.GetClassIconIndex(classification); } //LOCK_COLUMNS {LABEL, CLASSIFICATION, USER, DESCRIPTION, MACHINE, IP, ID, TIME, FULLNAME, TYPE}; item.Text = label; item.SubItems.Add(classification); item.SubItems.Add(command.GetUserName()); item.SubItems.Add(command.GetDescription()); item.SubItems.Add(command.GetComputerName()); item.SubItems.Add(command.GetComputerIP()); item.SubItems.Add(Convert.ToString(command.GetNetworkID())); item.SubItems.Add(time.FormatString("")); item.SubItems.Add(command.GetAssetFilename().GetOriginalFilename()); switch (command.GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest: item.SubItems.Add("Read Lock"); item.ForeColor = Color.Green; break; case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest: item.SubItems.Add("Write Lock"); item.ForeColor = Color.Red; break; } return(item); } } return(null); }
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); } } } }