Ejemplo n.º 1
0
        private void PackageManagementForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            guiUserPrefs.SaveDynamic_LayoutPrefs(guiUserPrefs.PackageManagementForm_Text, this);

            // Check if we were modyifying assets?
            if (ModifyingAssets)
            {
                // Itterate through all the assets and mark them as being modified
                foreach (ListViewItem item in AssetList.Items)
                {
                    MOG_Filename assetFilename = item.Tag as MOG_Filename;
                    if (assetFilename != null)
                    {
                        // Open up this asset so we can remove the package relationships
                        MOG_ControllerAsset asset = MOG_ControllerAsset.OpenAsset(assetFilename);
                        if (asset != null)
                        {
                            if (asset.GetProperties().NativeDataType)
                            {
                                MOG_ControllerInbox.UpdateInboxView(asset, MOG_AssetStatusType.Processed);
                            }
                            else
                            {
                                MOG_ControllerInbox.UpdateInboxView(asset, MOG_AssetStatusType.Modified);
                            }
                            asset.Close();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void MarkLocalAssetBlessed(MOG_Filename assetFilename, string blessedTimestamp)
        {
            // Walk through all of our workspaces
            foreach (MOG_ControllerSyncData workspace in mWorkspaces.Values)
            {
                // Check if this is the current workspace?  or
                // Check if this workspace is active?
                if (workspace == MOG_ControllerProject.GetCurrentSyncDataController() ||
                    workspace.IsAlwaysActive())
                {
                    // Build the expected path to this asset in our local workspace
                    MOG_Filename workspaceAsset = MOG_Filename.GetLocalUpdatedTrayFilename(workspace.GetSyncDirectory(), assetFilename);
                    // Open the local asset
                    MOG_ControllerAsset localAsset = MOG_ControllerAsset.OpenAsset(workspaceAsset);
                    if (localAsset != null)
                    {
                        // Stamp this locally update asset with the newly blessed revision timestamp
                        localAsset.GetProperties().BlessedTime = blessedTimestamp;

                        // Change the state of this asset to blessed
                        MOG_ControllerInbox.UpdateInboxView(localAsset, MOG_AssetStatusType.Blessed);
                        localAsset.Close();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Try to rebuild all of our user boxes based on what's on the HDD
        /// </summary>
        /// <param name="mainForm"></param>
        static public void MOGGlobalViewRebuildInbox(MogMainForm mainForm)
        {
            if (mainForm.mAssetManager != null)
            {
                // Initialize our variables...
                string boxDirectory = mainForm.mAssetManager.mInboxAssetsDirectory;
                string userPath     = MOG_ControllerProject.GetActiveUser().GetUserPath();
                // If we have a proper boxDirectory, add a "\\" to it
                if (boxDirectory.Length > 0)
                {
                    boxDirectory += "\\";
                }

                // Rebuild our contents.info and the database based on what's in the HDD
                UpdateBox(userPath, "Inbox", boxDirectory, false);
                UpdateBox(userPath, "Drafts", boxDirectory, false);
                UpdateBox(userPath, "Outbox", boxDirectory, false);
                UpdateBox(userPath, "Trash", boxDirectory, true);

                // Now rebuild local window
                if (mainForm.mAssetManager.mLocal != null && MOG_ControllerProject.GetCurrentSyncDataController() != null)
                {
                    MOG_ControllerInbox.RebuildInboxView(String.Concat(MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory(), "\\MOG\\UpdatedTray"), false);
                    mainForm.mAssetManager.mLocal.RefreshWindow();
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// UpdateBox to reflect what's on the HDD
        /// </summary>
        /// <param name="userPath"></param>
        /// <param name="boxName"></param>
        /// <param name="boxDirectory"></param>
        /// <param name="sendUpdateCommand"></param>
        static private void UpdateBox(string userPath, string boxName, string boxDirectory, bool sendUpdateCommand)
        {
            string        targetContentsFile = string.Concat(userPath, "\\", boxName, "\\", boxDirectory);
            DirectoryInfo dir = new DirectoryInfo(targetContentsFile);

            if (dir.Exists)
            {
                MOG_ControllerInbox.RebuildInboxView(targetContentsFile, sendUpdateCommand);
            }
        }
Ejemplo n.º 5
0
        public static bool Process(string fullName)
        {
            try
            {
                MOG_ControllerInbox.RipAsset(new MOG_Filename(fullName));
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("Process", fullName + "\n\n" + e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Remove packages from Assets currently selected.  Use CheckForBlessedAssetMessage() before calling.
        /// </summary>
        /// <param name="packagesToRemove">ArrayList of MOG_Property objects for packages to be removed</param>
        private void RemovePackageLinkFromAssets(ArrayList packagesToRemove)
        {
            foreach (ListViewItem item in AssetList.Items)
            {
                MOG_Filename assetFilename = item.Tag as MOG_Filename;
                if (assetFilename != null)
                {
                    // If this asset is not a blessed Asset, and it's not a classification...
                    if (!assetFilename.IsBlessed() && assetFilename.GetFilenameType() != MOG_FILENAME_TYPE.MOG_FILENAME_Unknown)
                    {
                        // Open up this asset so we can remove the package relationships
                        MOG_ControllerAsset asset = MOG_ControllerAsset.OpenAsset(assetFilename);
                        if (asset != null)
                        {
                            // Remove the packages
                            asset.GetProperties().RemovePackages(packagesToRemove);
                            // Depending on how the user clicked, it is possible that an inherited package assignment can be left behind as a non-inherited property
                            // The following code ensures all non-inherited package assignments are flushed by restamping any non-inherited assignemnts.
                            asset.GetProperties().SetProperties(asset.GetProperties().GetNonInheritedPackages());

                            // Make sure we keep the group in sync with our new assignment
                            MOG_ControllerAsset.SetDefaultGroup(asset);

                            // Change the state of the asset to indicate it has been modified
                            MOG_ControllerInbox.UpdateInboxView(asset, MOG_AssetStatusType.Modifying);
                            ModifyingAssets = true;

                            asset.Close();
                        }
                    }
                    else
                    {
                        // We should be looking at a classification, so treat it as such...
                        MOG_Properties properties = MOG_Properties.OpenClassificationProperties(assetFilename.GetOriginalFilename());
                        if (properties != null)
                        {
                            properties.RemovePackages(packagesToRemove);
                            properties.Close();
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public bool Remove(MOG_Filename filename, BackgroundWorker worker)
        {
            Debug.Write(filename.GetOriginalFilename(), "\nClick_Delete");
            MOG_ControllerInbox.Delete(filename);

            // Check if this asset was within our own inbox?
            if (string.Compare(filename.GetUserName(), MOG_ControllerProject.GetUserName_DefaultAdmin(), true) == 0)
            {
                // Check if this was one of our drafts or inbox assets?
                if (filename.IsDrafts() || filename.IsInbox())
                {
                    // Add this asset to all of our active workspaces
                    if (WorkspaceManager.RemoveAssetFromWorkspaces(filename, true, worker))
                    {
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 8
0
        private void Rename_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            bRenameSuccessful = true;

            try
            {
                // Store a list of assets we were unable to rename
                string listOfFailedRenames = "";

                // Iterates through asset(s) to be renamed.
                for (int i = 0; i < mSourceFiles.Count && !worker.CancellationPending; i++)
                {
                    string asset = mSourceFiles[i] as string;

                    // We jump here when we ignore errors (for missing files)
                    MOG_Filename assetName  = new MOG_Filename(asset);
                    string       targetName = GetTargetName(assetName);

                    // Rename the file with a new MOG_Controller
                    MOG_ControllerInbox.Rename(assetName, targetName, this.RenameFiles.Checked);

                    worker.ReportProgress(i * 100 / mSourceFiles.Count);
                }

                if (listOfFailedRenames.Length > 0)
                {
                    MOG_Prompt.PromptMessage("Failed Rename", "Unable to rename the following because "
                                             + "you account does not have the permission to do so:\r\n\r\n"
                                             + listOfFailedRenames);
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("Rename ERROR!", "The following error occured: \n"
                                         + ex.Source + " <-- " + ex.Message, ex.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
                bRenameSuccessful = false;
            }
        }
Ejemplo n.º 9
0
        void CommandEventCallBack_Invoked(MOG_Command command)
        {
            switch (command.GetCommandType())
            {
            case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemAlert:
            case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemError:
            case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemException:
                #region MOG_COMMAND_NotifySystemException
                MOG_ALERT_LEVEL level = MOG_ALERT_LEVEL.ALERT;
                switch (command.GetCommandType())
                {
                case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemAlert:
                    level = MOG_ALERT_LEVEL.ALERT;
                    break;

                case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemError:
                    level = MOG_ALERT_LEVEL.ERROR;
                    break;

                case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemException:
                    level = MOG_ALERT_LEVEL.CRITICAL;
                    break;
                }
                MOG_Prompt.PromptMessage(command.GetTitle(), command.GetDescription(), command.GetSource(), level);
                #endregion
                break;

            case MOG_COMMAND_TYPE.MOG_COMMAND_LockPersistentNotify:
                #region MOG_COMMAND_LockPersistentNotify
                // Check if this is the same project?
                MOG_Command lockInfo = command.GetCommand();
                if (lockInfo != null)
                {
                    // Check if we are on the locks tab?
                    if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Locks", true) == 0)
                    {
                        if (mainForm.mLibraryManager != null)
                        {
                            mainForm.mLibraryManager.RefreshItem(command);
                        }
                    }

                    // Check if this lock is related to our project?
                    if (MOG_Filename.IsClassificationValidForProject(lockInfo.GetAssetFilename().GetOriginalFilename(), MOG_ControllerProject.GetProjectName()))
                    {
                        // Check if we are on the workspace tab?
                        if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Workspace", true) == 0)
                        {
                            if (mainForm.mAssetManager != null)
                            {
                                mainForm.mAssetManager.RefreshLockStatus(command);
// JohnRen - Removed because this is just too slow when the server sends us a ton of locks at startup
//								mainForm.LocalBranchMogControl_GameDataDestinationTreeView.RefreshFileLockStatus(command);
                                mainForm.mAssetManager.mLocal.RefreshLockStatus(command);
                            }
                        }
                        // Check if we are on the project tab?
                        else if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Project", true) == 0)
                        {
                            if (mainForm.mProjectManager != null)
                            {
                                mainForm.mProjectManager.UpdateAsset(command);
                            }
                        }
                        // Check if we are on the library tab?
                        else if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Library", true) == 0)
                        {
                            if (mainForm.mLibraryManager != null)
                            {
                                mainForm.mLibraryManager.RefreshItem(command);
                            }
                        }

                        // Check if this notify just got processed?
                        if (command.GetOptions().Contains("{Processed}"))
                        {
                            // Check if we have a local workspace defined?
                            MOG_ControllerSyncData workspace = MOG_ControllerProject.GetCurrentSyncDataController();
                            if (workspace != null)
                            {
                                // Time to check if this was our lock that just got released?
                                if (string.Compare(lockInfo.GetUserName(), MOG_ControllerProject.GetUserName(), true) == 0 &&
                                    string.Compare(lockInfo.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0)
                                {
                                    // Is this lockInfo for an asset?
                                    if (lockInfo.GetAssetFilename().GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                                    {
                                        // Check the user's privilege
                                        MOG_Privileges privileges = MOG_ControllerProject.GetPrivileges();
                                        if (!privileges.GetUserPrivilege(MOG_ControllerProject.GetUserName(), MOG_PRIVILEGE.IgnoreSyncAsReadOnly))
                                        {
                                            MOG_Filename bestAssetFilename = lockInfo.GetAssetFilename();

                                            // Check if there is a better inbox asset that can be substituted?
                                            MOG_Filename inboxAssetFilename = MOG_ControllerInbox.LocateBestMatchingAsset(bestAssetFilename);
                                            if (inboxAssetFilename != null)
                                            {
                                                bestAssetFilename = inboxAssetFilename;
                                            }

                                            // Check if this asset has it's files synced as read only?
                                            MOG_Properties properties = new MOG_Properties(bestAssetFilename);
                                            if (properties.SyncAsReadOnly)
                                            {
                                                switch (lockInfo.GetCommandType())
                                                {
                                                case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest:
                                                    workspace.SetLocalFileAttributes(lockInfo.GetAssetFilename(), FileAttributes.Normal);
                                                    break;

                                                case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRelease:
                                                    workspace.SetLocalFileAttributes(lockInfo.GetAssetFilename(), FileAttributes.ReadOnly);
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion
                break;

            case MOG_COMMAND_TYPE.MOG_COMMAND_ViewUpdate:
                #region MOG_COMMAND_ViewUpdate

                // Make sure this is relevant to our active project?
                if (string.Compare(command.GetProject(), MOG_ControllerProject.GetProjectName(), true) != 0)
                {
                    break;
                }

                if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Project", true) == 0)
                {
                    // Process the auto process and package commands
                    switch (MOG_AssetStatus.GetType(command.GetDescription()))
                    {
                    case MOG_AssetStatusType.Modified:
                    case MOG_AssetStatusType.Unprocessed:
                        // Check to see if this command comes from us
                        if (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) != 0)
                        {
                            break;
                        }

                        // Check for Auto Process
                        if (mainForm.AssetManagerAutoProcessCheckBox.Checked &&
                            string.Compare(command.GetUserName(), MOG_ControllerProject.GetUser().GetUserName(), true) == 0)
                        {
                            guiAssetController.Process(command.GetDestination());
                        }
                        break;

                    //KLK - This may be overkill because we are on the Project tab and why do we want to change their local package button
                    case MOG_AssetStatusType.Packaged:
                        break;

                    case MOG_AssetStatusType.Unpackaged:
                    case MOG_AssetStatusType.Repackage:
                    case MOG_AssetStatusType.PackageError:
                    case MOG_AssetStatusType.Unpackage:
                        // We just got a new asset.  Make sure we inform the gui that a package is now required
                        if (mainForm.mAssetManager != null)
                        {
                            mainForm.mAssetManager.RefreshWindowsBoth(command);
                        }
                        break;
                    }
                }

                //if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Workspace", true) == 0)
                if (true)
                {
                    if (string.Compare(command.GetDescription(), "UnGrouped", true) == 0)
                    {
                        command.SetDestination("");
                    }

                    try
                    {
                        // Filter out updates to other computers that share our username and project
                        if ((string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) != 0) &&
                            (string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Copied), true) == 0 ||
                             string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Unpackaged), true) == 0 ||
                             string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Repackage), true) == 0 ||
                             string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Packaged), true) == 0 ||
                             string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.PackageError), true) == 0 ||
                             string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Unpackage), true) == 0))
                        {
                            return;
                        }
                        else
                        {
                            mainForm.mAssetManager.RefreshWindowsBoth(command);
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.Write(e.ToString());
                    }

                    // JohnRen - Changed...
                    // The ViewUpdate command contains the computer name of who generated the view command...not the computer name of the originator of the rip
                    // Because of this, AutoUpdate local would not work anytime somebody else's slave performed the rip.
                    // Changed the AutoUpdate events to respect the login user instead of the computer name because this will be 100% correct...
                    // However, multiple users will experience the event if they are logged in as the same user.
                    //					// Process the auto process and package commands
                    //					// only do this code if the command came from us
                    //					if (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0)
                    MOG_Filename destinationFilename = new MOG_Filename(command.GetDestination());
                    if (string.Compare(destinationFilename.GetUserName(), MOG_ControllerProject.GetUserName(), true) == 0)
                    {
                        switch (MOG_AssetStatus.GetType(command.GetDescription()))
                        {
                        case MOG_AssetStatusType.Modified:
                        case MOG_AssetStatusType.Unprocessed:
                            // Check for Auto Process
                            if (mainForm.AssetManagerAutoProcessCheckBox.Checked)
                            {
                                // Only auto-process this if it is in the drafts folder
                                if (destinationFilename.IsDrafts())
                                {
                                    // Make sure we are the ones that requested it
                                    if (string.Compare(command.GetUserName(), MOG_ControllerProject.GetUser().GetUserName(), true) == 0 &&
                                        (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0))
                                    {
                                        guiAssetController.Process(command.GetDestination());
                                    }
                                }
                            }
                            break;

                        case MOG_AssetStatusType.Imported:
                            // Only auto-process this if it is in the drafts folder
                            if (destinationFilename.IsDrafts())
                            {
                                // Make sure we are the ones that requested it
                                if (string.Compare(command.GetUserName(), MOG_ControllerProject.GetUser().GetUserName(), true) == 0 &&
                                    (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0))
                                {
                                    guiAssetController.UpdateLocal(command.GetDestination(), false);
                                }
                            }
                            break;

                        case MOG_AssetStatusType.Processed:
                        case MOG_AssetStatusType.Sent:
                            // Check if the MainForm's AutoUpdate button is checked?
                            if (mainForm.AssetManagerAutoUpdateLocalCheckBox.Checked)
                            {
                                // Only auto-process this if it is in the drafts folder
                                if (destinationFilename.IsDrafts())
                                {
                                    // Make sure we are the ones that requested it
                                    if (string.Compare(command.GetUserName(), MOG_ControllerProject.GetUser().GetUserName(), true) == 0 &&
                                        (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0))
                                    {
                                        // Check if we have a current workspace?
                                        if (MOG_ControllerProject.GetCurrentSyncDataController() != null)
                                        {
                                            guiAssetController.UpdateLocal(command.GetDestination(), false);
                                        }
                                    }
                                }
                            }
                            break;

                        case MOG_AssetStatusType.Rebuilt:
                            if (mainForm.mAssetManager != null)
                            {
                                mainForm.mAssetManager.RefreshActiveWindow();
                            }
                            break;

                        case MOG_AssetStatusType.Deleted:
                            MOG_Filename assetName = new MOG_Filename(command.GetSource());
                            if (assetName.IsTrash() && mainForm.mAssetManager != null && mainForm.mAssetManager.mTrash != null && mainForm.AssetManagerInboxTabControl.SelectedTab.Name == "AssetManagerTrashTabPage")
                            {
                                mainForm.mAssetManager.mTrash.RefreshRemove(command);
                            }
                            else if (assetName.IsLocal() && mainForm.mAssetManager != null)
                            {
                                MOG_Filename tempAssetName = new MOG_Filename(command.GetSource());
                            }
                            break;
                        }
                    }
                }

                #endregion
                break;

            case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterEditor:
                #region MOG_COMMAND_RegisterEditor
                // We just lost an Editor
                WorkspaceManager.RegisterEditor(command.GetWorkingDirectory());
                #endregion
                break;

            case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownEditor:
                #region MOG_COMMAND_ShutdownEditor
                // We just lost an Editor
                WorkspaceManager.ShutdownEditor(command.GetWorkingDirectory());
                #endregion
                break;

            case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionLost:
                #region MOG_COMMAND_ConnectionLost
                // The server was shutdown
                Bitmap DisconnectedIcon = new Bitmap(mainForm.StatusBarImageList.Images[1]);
                mainForm.MOGStatusBarConnectionStatusBarPanel.Icon        = System.Drawing.Icon.FromHandle(DisconnectedIcon.GetHicon());
                mainForm.MOGStatusBarConnectionStatusBarPanel.Text        = "Disconnected";
                mainForm.MOGStatusBarConnectionStatusBarPanel.ToolTipText = "Server is disconnected!";
                #endregion
                break;

            case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionNew:
                #region MOG_COMMAND_ConnectionNew
                Bitmap ConnectedIcon = new Bitmap(mainForm.StatusBarImageList.Images[0]);
                mainForm.MOGStatusBarConnectionStatusBarPanel.Icon        = System.Drawing.Icon.FromHandle(ConnectedIcon.GetHicon());
                mainForm.MOGStatusBarConnectionStatusBarPanel.Text        = "Connected";
                mainForm.MOGStatusBarConnectionStatusBarPanel.ToolTipText = mainForm.RefreshConnectionToolText();
                #endregion
                break;

            case MOG_COMMAND_TYPE.MOG_COMMAND_Complete:
                #region MOG_COMMAND_Complete
                // Make sure this contains an encapsulated command?
                if (command.GetCommand() != null)
                {
                    // Determin the type of encapsulated command
                    switch (command.GetCommand().GetCommandType())
                    {
                    case MOG_COMMAND_TYPE.MOG_COMMAND_Post:
                        #region MOG_COMMAND_PostComplete
                        if (mainForm != null)
                        {
                            // Check if we are on a tab that cares about this event?
                            if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Connections", true) == 0)
                            {
                                if (mainForm.mConnectionManager != null)
                                {
                                    // Only listen for the final Post w/o any assetFilename listed or else we would cause too many full refreshes
                                    if (command.GetCommand().GetAssetFilename().GetOriginalFilename().Length == 0)
                                    {
                                        // Refresh the pending package listview
                                        mainForm.mConnectionManager.RefreshMerging();
                                        // Refresh the pending post listview
                                        mainForm.mConnectionManager.RefreshPosting();
                                    }
                                }
                            }

                            // Check if this remove was successful?
                            if (command.GetCommand().IsCompleted())
                            {
// Someday this would be nice, but the library tab does refresh when it gets reselected so we need to process this event even though we are on another tab
//								// Check if we are on a tab that cares about this event?
//								if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Library", true) == 0)
//								{
                                if (command.GetCommand().GetAssetFilename().IsLibrary())
                                {
                                    if (mainForm.mLibraryManager != null)
                                    {
                                        mainForm.mLibraryManager.RefreshItem(command);
                                    }
                                }
//								}
                                // Check if we are on a tab that cares about this event?
                                if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Project", true) == 0)
                                {
                                    if (mainForm.mProjectManager != null)
                                    {
                                        mainForm.mProjectManager.MakeAssetCurrent(command.GetCommand().GetAssetFilename());
                                    }
                                }
                            }
                        }
                        #endregion
                        break;

                    case MOG_COMMAND_TYPE.MOG_COMMAND_ReinstanceAssetRevision:
                        #region MOG_COMMAND_ReinstanceAssetRevision
                        // Check if this remove was successful?
                        if (command.GetCommand().IsCompleted())
                        {
                            if (mainForm.mProjectManager != null)
                            {
                                mainForm.mProjectManager.RemoveAssetFromProject(new MOG_Filename(command.GetCommand().GetSource()));
                                mainForm.mProjectManager.MakeAssetCurrent(command.GetCommand().GetAssetFilename());
                            }
                            if (mainForm.LibraryExplorer != null)
                            {
                                mainForm.LibraryExplorer.LibraryListView.RefreshItem(command);
                            }
                        }
                        #endregion
                        break;

                    case MOG_COMMAND_TYPE.MOG_COMMAND_RemoveAssetFromProject:
                        #region MOG_COMMAND_RemoveAssetFromProject
                        // Check if this remove was successful?
                        if (command.GetCommand().IsCompleted())
                        {
                            if (mainForm.mProjectManager != null)
                            {
                                mainForm.mProjectManager.RemoveAssetFromProject(command.GetCommand().GetAssetFilename());
                            }
                            if (mainForm.LibraryExplorer != null)
                            {
                                mainForm.LibraryExplorer.LibraryListView.RefreshItem(command);
                            }
                        }
                        #endregion
                        break;

                    case MOG_COMMAND_TYPE.MOG_COMMAND_NetworkPackageMerge:
                    case MOG_COMMAND_TYPE.MOG_COMMAND_LocalPackageMerge:
                    case MOG_COMMAND_TYPE.MOG_COMMAND_EditorPackageMergeTask:
                    case MOG_COMMAND_TYPE.MOG_COMMAND_NetworkPackageRebuild:
                        WorkspaceManager.EndPackaging(command.GetCommand().GetWorkingDirectory());
                        break;
                    }
                }
                #endregion
                break;

            case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveConnection:
                #region MOG_COMMAND_NotifyActiveConnection
                if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Connections", true) == 0)
                {
                    if (mainForm.mConnectionManager != null)
                    {
                        mainForm.mConnectionManager.UpdateConnections(command);
                    }
                }
                #endregion
                break;

            // These are the all around locks requested commands from the server
            case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveLock:
                #region MOG_COMMAND_NotifyActiveLock
                switch (command.GetCommand().GetCommandType())
                {
                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:
                    if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Locks", true) == 0)
                    {
                        if (mainForm.mLockManager != null)
                        {
                            mainForm.mLockManager.RefreshLockWindows(command);
                        }
                    }
                    break;
                }
                #endregion
                break;

            case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshProject:
                #region MOG_COMMAND_RefreshProject
                MainMenuProjectsClass.MOGGlobalRefreshProject(mainForm);
                #endregion
                break;

            case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshApplication:
                break;

            case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshTools:
                break;

            // These are the all around general commands from the server
            case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveCommand:
                #region MOG_COMMAND_NotifyActiveCommand
                // The command manager needs to know about all commands
                if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Connections", true) == 0)
                {
                    if (mainForm.mConnectionManager != null)
                    {
                        mainForm.mConnectionManager.UpdateCommands(command);
                    }
                }
                #endregion
                break;
            }
        }
Ejemplo n.º 10
0
        private bool AddPackageLinkToAssets(string packageName, Color color, bool markAsInherited, bool setPackageProperties)
        {
            bool success = true;

            ListViewItem item = FindAssignmentListItem(packageName);

            if (item == null)
            {
                item           = new ListViewItem(packageName);
                item.ForeColor = color;
                AssignmentList.Items.Add(item);

                if (setPackageProperties)
                {
                    success = false;

                    ArrayList PackageAssignmentProps = new ArrayList();
                    PackageAssignmentProps.Add(CreatePackageAssignmentProperty(packageName));

                    // Go through our listview items again to Add or Remove assets we found in the previous foreach loop
                    foreach (ListViewItem assetItem in AssetList.Items)
                    {
                        MOG_Filename assetFilename = assetItem.Tag as MOG_Filename;
                        if (assetFilename != null &&
                            assetFilename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                        {
                            // If this asset is not a blessed Asset, and it's not a classification...
                            if (!assetFilename.IsBlessed())
                            {
                                MOG_ControllerAsset asset = MOG_ControllerAsset.OpenAsset(assetFilename);
                                if (asset != null)
                                {
                                    if (asset.GetProperties().AddPackages(PackageAssignmentProps))
                                    {
                                        success = true;

                                        // Make sure we keep the group in sync with our new assignment
                                        MOG_ControllerAsset.SetDefaultGroup(asset);

                                        // Change the state of the asset to indicate it has been modified
                                        MOG_ControllerInbox.UpdateInboxView(asset, MOG_AssetStatusType.Modifying);
                                        ModifyingAssets = true;
                                    }

                                    asset.Close();
                                }
                            }
                            else
                            {
                                MOG_Prompt.PromptMessage("Cannot add PackageAssignments to Blessed Assets",
                                                         "Please copy the Asset to your Inbox and change its package assignments from there so it can be properly processed and re-Blessed.",
                                                         "",
                                                         MOG.PROMPT.MOG_ALERT_LEVEL.ALERT);
                            }
                        }
                        else if (assetFilename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Unknown)
                        {
                            // We should be looking at a classification, so treat it as such...
                            MOG_Properties properties = MOG_Properties.OpenClassificationProperties(assetFilename.GetOriginalFilename());
                            if (properties != null)
                            {
                                if (properties.AddPackages(PackageAssignmentProps))
                                {
                                    success = true;
                                }
                                properties.Close();
                            }
                        }
                    }
                }
            }

            if (item != null && markAsInherited)
            {
                item.Font = new Font(AssignmentList.Font, FontStyle.Italic);
            }

            if (!success)
            {
                MOG_Report.ReportMessage("Error Adding Package Assignment", "Failed to add package assignment!", Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
            }

            return(success);
        }
Ejemplo n.º 11
0
        public static void BlessAssets_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker    worker     = sender as BackgroundWorker;
            List <object>       parameters = e.Argument as List <object>;
            List <MOG_Filename> filenames  = parameters[0] as List <MOG_Filename>;
            string comment      = parameters[1] as string;
            bool   maintainLock = (bool)parameters[2];

            bool   bUserAltered = false;
            string loginUser    = MOG_ControllerProject.GetUser().GetUserName();
            string activeUser   = MOG_ControllerProject.GetActiveUser().GetUserName();

            // Make sure the inbox that we are in matches the logged in user
            if (string.Compare(MOG_ControllerProject.GetUser().GetUserName(), MOG_ControllerProject.GetActiveUser().GetUserName(), true) != 0)
            {
                // Login as this user so that his bless targets will be respected during this bless!
                MOG_ControllerProject.LoginUser(MOG_ControllerProject.GetActiveUser().GetUserName());
                bUserAltered = true;
            }

            // Obtain a unique bless jobLabel
            string timestamp = MOG_Time.GetVersionTimestamp();
            string jobLabel  = "Bless." + MOG_ControllerSystem.GetComputerName() + "." + timestamp;

            // Changed to a for-loop to facilitate the loop breakout box on bless failure below
            for (int assetIndex = 0; assetIndex < filenames.Count; assetIndex++)
            {
                MOG_Filename asset = filenames[assetIndex] as MOG_Filename;
                if (asset != null)
                {
                    string message = "Blessing:\n" +
                                     "     " + asset.GetAssetClassification() + "\n" +
                                     "     " + asset.GetAssetName();
                    worker.ReportProgress(assetIndex * 100 / filenames.Count, message);

                    // Try to bless each asset and report if there is a failure
                    try
                    {
                        if (MOG_ControllerInbox.BlessAsset(asset, comment, maintainLock, jobLabel, worker))
                        {
                            WorkspaceManager.MarkLocalAssetBlessed(asset, timestamp);
                        }
                        else
                        {
                            // If there are more assets to bless, ask the user how to proceed
                            if (assetIndex < filenames.Count - 1)
                            {
                                MOGPromptResult result = MOG_Prompt.PromptResponse("Bless Error", "An error has occurred while blessing " + asset.GetAssetFullName() + "\nWould you like to continue blessing assets?", MOGPromptButtons.YesNo);
                                if (result == MOGPromptResult.Yes)
                                {
                                    // continue with the next asset
                                    continue;
                                }
                                else if (result == MOGPromptResult.No)
                                {
                                    // bail
                                    return;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        // Send this Exception back to the server
                        MOG_Report.ReportMessage("Bless", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL);

                        // Check if we are logged in an anyone?
                        if (MOG_ControllerProject.IsUser())
                        {
                            // Send a notification to the ofending user
                            MOG_Report.ReportMessage("Bless", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
                        }
                    }
                }
            }

            // Start the job
            MOG_ControllerProject.StartJob(jobLabel);

            // Restore user if changed
            if (bUserAltered)
            {
                MOG_ControllerProject.LoginUser(loginUser);
                MOG_ControllerProject.SetActiveUserName(activeUser);
            }
        }