Ejemplo n.º 1
0
        /// <summary>
        /// Add a MOG_Command to the NotifyEventForm
        /// </summary>
        /// <param name="command"></param>
        public void AddCommand(MOG_Command command)
        {
            string commandStr = "";

            switch (command.GetCommandType())
            {
            case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemAlert:
                commandStr = "ALERT";
                break;

            case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemError:
                commandStr = "ERROR";
                break;

            case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemException:
                commandStr = "EXCEPTION";
                break;

            default:
                commandStr = command.ToString();
                break;
            }

            ListViewItem item = new ListViewItem(commandStr);

            item.SubItems.Add(command.GetDescription());
            item.SubItems.Add(MOG.TIME.MOG_Time.FormatTimestamp(command.GetCommandTimeStamp(), ""));
            this.listView1.Items.Add(item);
        }
Ejemplo n.º 2
0
        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 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();
     }
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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;
                }
            }
        }
Ejemplo n.º 6
0
        bool CanObtainLicense(MOG_Command pCommand)
        {
            bool bLicense = false;

            // Get our server command manager?
            MOG_CommandServerCS commandServer = (MOG_CommandServerCS)(MOG_ControllerSystem.GetCommandManager());

            if (commandServer != null)
            {
                // This client is not accounted for, check the license file to see if he can fit into the current situation
                if (EnsureValidLicense())
                {
                    // We have a license file
                    if (!mTimeBomb.IsValidMacAddress())
                    {
                        //The Mac address is bad
                        String message = String.Concat("This MOG Server's machine hasn't been properly licensed.\n",
                                                       "You will be limited to 2 client connections.\n",
                                                       "Contact Mogware to transfer this license.");

                        MOG_Command pBroadcast = MOG_CommandFactory.Setup_NetworkBroadcast("", message);
                        commandServer.SendToConnection(pCommand.GetNetworkID(), pBroadcast);
                    }
                    else
                    {
                        // Since the Mac address is ok, what about the expiration?
                        DateTime commandDate = MOG_Time.GetDateTimeFromTimeStamp(pCommand.GetCommandTimeStamp());
                        if (mTimeBomb.HasExpired() ||
                            mTimeBomb.HasExpired(commandDate))
                        {
                            //Oh man this license file is expired
                            String message = String.Concat("The MOG Server has been unable to renew the MOG License.\n",
                                                           "You will be limited to 2 client connections.\n",
                                                           "Please make sure the MOG Server machine has internet access.");

                            MOG_Command pBroadcast = MOG_CommandFactory.Setup_NetworkBroadcast("", message);
                            commandServer.SendToConnection(pCommand.GetNetworkID(), pBroadcast);
                        }
                        // Check if we are going to expire soon?
                        else if (mTimeBomb.WillExpireSoon())
                        {
                            // Inform the user of our impending doom
                            String message = String.Concat("The MOG Server has been unable to renew the MOG License.\n",
                                                           "EXPIRATION DATE: ", mTimeBomb.GetExpireDate().ToString(), "\n",
                                                           "Please make sure the MOG Server machine has internet access.");
                            MOG_Command pBroadcast = MOG_CommandFactory.Setup_NetworkBroadcast("", message);
                            commandServer.SendToConnection(pCommand.GetNetworkID(), pBroadcast);
                        }
                    }
                }
                else
                {
                    // There is no license file at all
                    String message = String.Concat("You're using an unlicensed server.\n",
                                                   "You will be limited to 2 client connections.\n",
                                                   "Licensing can be performed in the ServerManager.");

                    MOG_Command pBroadcast = MOG_CommandFactory.Setup_NetworkBroadcast("", message);
                    commandServer.SendToConnection(pCommand.GetNetworkID(), pBroadcast);
                }

                // Call this to see if any more clients can be licensed
                if (IsLicenseAvailable())
                {
                    bLicense = true;
                }
                else
                {
                    // Notify client of failed command request
                    string message = String.Concat("No more available licenses on the server.\n\n",
                                                   "This client cannot be launched until another client is closed.\n",
                                                   "Additional seats can be licensed in the ServerManager.");
                    MOG_Command pBroadcast = MOG_CommandFactory.Setup_NetworkBroadcast("", message);
                    commandServer.SendToConnection(pCommand.GetNetworkID(), pBroadcast);
                }
            }

            return(bLicense);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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);
                    }
                }
            }
        }