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); }
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); }
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); }