Example #1
0
        static public bool RequestPersistentLockWithRetry(string assetFullName, string description)
        {
            if (!guiAssetSourceLock.IsLockedWithRetry(assetFullName))
            {
SourceLockGet:
                MOG_Command sourceLock = MOG_ControllerProject.PersistentLock_Request(assetFullName, description);

                lockHolder = sourceLock.GetCommand();
                if (sourceLock.IsCompleted() &&
                    lockHolder != null)
                {
                    if (!sourceLock.IsCompleted() ||
                        lockHolder == null)
                    {
                        switch (LockMessage("Could not aquire this lock!", sourceLock, lockHolder))
                        {
                        case DialogResult.Retry:
                            goto SourceLockGet;
                        }
                    }
                }

                return(sourceLock.IsCompleted());
            }

            return(false);
        }
Example #2
0
        static public bool ReleasePersistentLockWithRetry(string assetFullName)
        {
SourceLockRelease:
            // Try to release the lock
            if (!MOG_ControllerProject.PersistentLock_Release(assetFullName))
            {
                // If we can't, tell us who has it
                MOG_Command sourceLock = MOG_ControllerProject.PersistentLock_Query(assetFullName);

                lockHolder = sourceLock.GetCommand();
                if (sourceLock.IsCompleted() &&
                    lockHolder != null)
                {
                    // Now check if someone had a lock on this asset
                    switch (LockMessage("This asset is currently locked by another user", sourceLock, lockHolder))
                    {
                    case DialogResult.Retry:
                        goto SourceLockRelease;
                    }

                    return(false);
                }
            }

            return(true);
        }
Example #3
0
        public void RefreshLockWindows(MOG_Command command)
        {
            MOG_Command lockCommand = command.GetCommand();

            //if (string.Compare(mainForm.SMOG_Main_TabControl.SelectedTab.Text, "Locks", true) == 0)
            if (lockCommand != null)
            {
                // If the command completed then it is a successful lock, if not then it is a request
                if (lockCommand.IsCompleted())
                {
                    switch (lockCommand.GetCommandType())
                    {
                    case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest:
                    case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest:
                        // Check if this is a lock that was waiting and now has succedded
                        ListViewItem oldReleaseLock = LocateListViewItem(mainForm.LockManagerPendingListView, lockCommand.GetAssetFilename().GetOriginalFilename());
                        if (oldReleaseLock != null)
                        {
                            oldReleaseLock.Remove();
                        }

                        //Put a new item in the list, but only if it doesn't exist in there already
                        if (LocateLockItem(lockCommand) == null)
                        {
                            // Create the new lock item
                            ListViewItem newLockItem = InitNewLockItem(lockCommand);
                            AddLockItem(newLockItem);
                        }

                        break;

                    case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRelease:
                    case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRelease:
                        ListViewItem releaseLock = LocateListViewItem(mainForm.LockManagerLocksListView, lockCommand.GetAssetFilename().GetOriginalFilename());
                        if (releaseLock != null)
                        {
                            releaseLock.Remove();
                        }
                        break;
                    }
                }
                else
                {
                    if (LocateListViewItem(mainForm.LockManagerPendingListView, lockCommand.GetAssetFilename().GetOriginalFilename()) == null)
                    {
                        ListViewItem item = InitNewLockItem(lockCommand);

                        if (item != null)
                        {
                            mainForm.LockManagerPendingListView.Items.Add(item);
                        }
                    }
                }
            }
        }
Example #4
0
        public void RefreshLockWindows(MOG_Command command)
        {
            if (string.Compare(mainForm.SMOG_Main_TabControl.SelectedTab.Text, "Locks", true) == 0)
            {
                // If the command completed then it is a successful lock, if not then it is a request
                if (command.IsCompleted())
                {
                    switch (command.GetCommandType())
                    {
                    case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest:
                    case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest:

                        // Check if this is a lock that was waiting and now has succedded
                        ListViewItem oldReleaseLock = LocateListViewItem(mainForm.LocksRequestLocksListView, command.GetAssetFilename().GetOriginalFilename(), command.GetComputerName());
                        if (oldReleaseLock != null)
                        {
                            oldReleaseLock.Remove();
                        }

                        // Create the new lock item
                        ListViewItem gotLock = InitNewLockItem(command);

                        if (gotLock != null)
                        {
                            mainForm.LocksListView.Items.Add(gotLock);
                        }
                        break;

                    case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRelease:
                    case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRelease:
                        ListViewItem releaseLock = LocateListViewItem(mainForm.LocksListView, command.GetAssetFilename().GetOriginalFilename(), command.GetComputerName());
                        if (releaseLock != null)
                        {
                            releaseLock.Remove();
                        }
                        break;
                    }
                }
                else
                {
                    if (LocateListViewItem(mainForm.LocksRequestLocksListView, command.GetAssetFilename().GetOriginalFilename(), command.GetComputerName()) == null)
                    {
                        ListViewItem item = InitNewRequestItem(command);

                        if (item != null)
                        {
                            mainForm.LocksRequestLocksListView.Items.Add(item);
                        }
                    }
                }
            }
        }
 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();
     }
 }
Example #6
0
        static public bool IsLockedWithRetry(string assetFullName)
        {
            if (assetFullName.Length != 0)
            {
TryGetLock:
                MOG_Command sourceLock = MOG_ControllerProject.PersistentLock_Query(assetFullName);

                lockHolder = sourceLock.GetCommand();
                // Now check if someone had a lock on this asset
                if (sourceLock.IsCompleted() &&
                    lockHolder != null)
                {
                    //The asset is locked
                    switch (LockMessage("This asset is currently locked!", sourceLock, lockHolder))
                    {
                    case DialogResult.Retry:
                        goto TryGetLock;
                    }
                    return(true);
                }
            }
            return(false);
        }
Example #7
0
        private void UpdateItem(ListViewItem item)
        {
            string status         = "";
            string username       = "";
            string comment        = "";
            string localTimestamp = "";

            // Find our desired columns
            int statusIdx          = FindColumn("Status");
            int userIdx            = FindColumn("User");
            int commentIdx         = FindColumn("Comment");
            int localTimestampIdx  = FindColumn("Local Timestamp");
            int serverTimestampIdx = FindColumn("Server Timestamp");
            int localFileIdx       = FindColumn("LocalFile");
            int repositoryFileIdx  = FindColumn("RepositoryFile");

            string       repositoryFile          = item.SubItems[repositoryFileIdx].Text;
            MOG_Filename repositoryAssetFilename = new MOG_Filename(repositoryFile);

            // Check if this file exist locally?
            string localFile = item.SubItems[localFileIdx].Text;

            if (localFile.Length != 0)
            {
                // Obtain the localFile info
                FileInfo fileInfo = new FileInfo(localFile);
                // Does this local file exist?
                if (fileInfo != null && fileInfo.Exists)
                {
                    // Compare our local file's timestamp to the server's revision
                    localTimestamp = MOG_Time.GetVersionTimestamp(fileInfo.LastWriteTime);
                    if (localTimestamp == repositoryAssetFilename.GetVersionTimeStamp())
                    {
                        // Indicate this item is synced and up-to-date
                        status = "Up-to-date";
                    }
                    else
                    {
                        // Indicate this item is synced
                        status = "Out-of-date";
                    }
                }
                else
                {
                    // Indicate this item is not synced
                    status = "unSynced";
                }
            }
            else
            {
                // Indicate this item is not synced
                status = "unSynced";
            }

            // Check if this file exists in the repository?
            if (repositoryFile.Length != 0)
            {
                // Check the lock statusIdx of the asset
                MOG_Command sourceLock = MOG_ControllerProject.PersistentLock_Query(repositoryAssetFilename.GetAssetFullName());
                if (sourceLock.IsCompleted() && sourceLock.GetCommand() != null)
                {
                    MOG_Command lockHolder = sourceLock.GetCommand();

                    // Obtain the lock info
                    item.ImageIndex = MogUtil_AssetIcons.GetLockedBinaryIcon(repositoryFile);
                    username        = lockHolder.GetUserName();
                    comment         = lockHolder.GetDescription();

                    // Check if this is locked by me?
                    if (username == MOG_ControllerProject.GetUserName())
                    {
                        status = "CheckedOut";
                    }
                    else
                    {
                        status = "Locked";
                    }
                }
                else
                {
                    // Update this file's icon
                    item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(repositoryFile);
                }
            }

            // Update the item with the new information
            item.SubItems[statusIdx].Text          = status;
            item.SubItems[userIdx].Text            = username;
            item.SubItems[commentIdx].Text         = comment;
            item.SubItems[localTimestampIdx].Text  = MogUtils_StringVersion.VersionToString(localTimestamp);
            item.SubItems[serverTimestampIdx].Text = MogUtils_StringVersion.VersionToString(repositoryAssetFilename.GetVersionTimeStamp());

            // Update the color for this locked item
            UpdateListViewItemColors(item, status);
        }
Example #8
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;
                }
            }
        }
Example #9
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);
                    }
                }
            }
        }