示例#1
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);
        }
示例#2
0
        string ResolveToken(string token)
        {
            string value = "";

            // Make sure this token starts with the '{'?
            if (token.StartsWith("{"))
            {
                // Get the name of this token
                string[] parts = token.Split("{}.".ToCharArray(), 3);
                // Make sure this resembled a real token?
                if (parts.Length == 3)
                {
                    // Check for any contained commands?
                    string testToken = "{" + parts[1] + "}";
                    // Determine which token we have?
                    switch (testToken)
                    {
                    // Repository Tokens
                    case TOKEN_Repository_Path:
                        value = MOG_ControllerSystem.GetSystemRepositoryPath();
                        break;

                    case TOKEN_Repository_ProjectsPath:
                        value = MOG_ControllerSystem.GetSystemProjectsPath();
                        break;

                    case TOKEN_Repository_ToolsPath:
                        value = MOG_ControllerSystem.GetSystemRepositoryPath() + "\\Tools";
                        break;

                    case TOKEN_Repository_Project_Path:
                        value = MOG_ControllerProject.GetProjectPath();
                        break;

                    case TOKEN_Repository_Project_ToolsPath:
                        value = MOG_ControllerProject.GetProjectPath() + "\\Tools";
                        break;

                    case TOKEN_Repository_Project_AssetsPath:
                        value = MOG_ControllerRepository.GetRepositoryPath();
                        break;

                    case TOKEN_Repository_Project_ArchivePath:
                        value = MOG_ControllerRepository.GetArchivePath();
                        break;

                    case TOKEN_Repository_Project_UsersPath:
                        value = MOG_ControllerProject.GetProjectPath() + "\\Users";
                        break;

                    // Project Tokens
                    case TOKEN_Project_Name:
                        value = MOG_ControllerProject.GetProjectName();
                        break;

                    case TOKEN_Project_BranchName:
                        value = MOG_ControllerProject.GetBranchName();
                        break;

                    case TOKEN_Project_UserName:
                        value = MOG_ControllerProject.GetUserName_DefaultAdmin();
                        break;

                    case TOKEN_Project_PlatformName:
                        value = MOG_ControllerProject.GetPlatformName();
                        break;

                    case TOKEN_Project_WorkspaceDirectory:
                        value = MOG_ControllerProject.GetWorkspaceDirectory();
                        break;

                    // Ripper Tokens
                    case TOKEN_Ripper_SourcePath:
                        value = mRipperSourcePath;
                        break;

                    case TOKEN_Ripper_SourceFilePattern:
                        value = mRipperSourceFilePattern;
                        break;

                    case TOKEN_Ripper_DestinationPath:
                        value = mRipperDestinationPath;
                        break;

                    // Package Tokens
                    case TOKEN_Package_WorkspaceDirectory:
                        if (mPackageFileInfo != null)
                        {
                            value = mPackageFileInfo.mPackageWorkspaceDirectory;
                        }
                        break;

                    case TOKEN_Package_DataDirectory:
                        if (mPackageFileInfo != null)
                        {
                            value = mPackageFileInfo.mPackageDataDirectory;
                        }
                        break;

                    case TOKEN_Package_PackageFile_Filename:
                        if (mPackageFileInfo != null)
                        {
                            value = mPackageFileInfo.mPackageFile;
                        }
                        break;

                    case TOKEN_Package_PackageFile_FullName:
                    {
                        MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment));
                        value = packageFilename.GetAssetFullName();
                    }
                    break;

                    case TOKEN_Package_PackageFile_Classification:
                    {
                        MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment));
                        value = packageFilename.GetAssetClassification();
                    }
                    break;

                    case TOKEN_Package_PackageFile_Label:
                    {
                        MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment));
                        value = packageFilename.GetAssetLabel();
                    }
                    break;

                    case TOKEN_Package_PackageFile_Platform:
                    {
                        MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment));
                        value = packageFilename.GetAssetPlatform();
                    }
                    break;

                    case TOKEN_Package_PackageFile_Group:
                        value = MOG_ControllerPackage.GetPackageGroups(mPackageAssignment);
                        break;

                    case TOKEN_Package_PackageFile_Object:
                        value = MOG_ControllerPackage.GetPackageObjects(mPackageAssignment);
                        break;

                    // Inbox Tokens
                    case TOKEN_Inbox_UserName:
                        value = mAssetFilename.GetUserName();
                        break;

                    case TOKEN_Inbox_UserPath:
                        value = mAssetFilename.GetUserPath();
                        break;

                    case TOKEN_Inbox_BoxName:
                        value = mAssetFilename.GetBoxName();
                        break;

                    case TOKEN_Inbox_BoxPath:
                        value = mAssetFilename.GetBoxPath();
                        break;

                    // Asset Tokens
                    case TOKEN_Asset_AssetName_Path:
                        value = mAssetFilename.GetPath();
                        break;

                    case TOKEN_Asset_AssetName_FullName:
                        value = mAssetFilename.GetAssetFullName();
                        break;

                    case TOKEN_Asset_AssetName_Classification:
                        value = mAssetFilename.GetAssetClassification();
                        break;

                    case TOKEN_Asset_AssetName_Name:
                        value = mAssetFilename.GetAssetName();
                        break;

                    case TOKEN_Asset_AssetName_PlatformName:
                        value = mAssetFilename.GetAssetPlatform();
                        break;

                    case TOKEN_Asset_AssetName_Label:
                        value = mAssetFilename.GetAssetLabel();
                        break;

                    case TOKEN_Asset_ImportedFile:
                    case TOKEN_Asset_RippedFile:
                        value = ResolveToken_AssetFile(token);
                        break;

                    case TOKEN_Asset_Property:
                        value = ResolveToken_Property(token);
                        break;

                    case TOKEN_Asset_ClassificationPath:
                        value = MOG_Filename.GetClassificationPath(mAssetFilename.GetAssetClassification());
                        break;

                    case TOKEN_Asset_VersionTimeStamp:
                        value = mAssetFilename.GetVersionTimeStamp();
                        break;
                    }

                    // Check if we have a command?
                    if (parts[2] != ".")
                    {
                    }
                }
            }

            return(value);
        }
        public void RefreshBox(MOG_Filename add, MOG_Filename del, MOG_Command command)
        {
            Color    textColorAdd   = Color.Black;
            Color    textColorDel   = Color.Black;
            ListView currentViewAdd = mParent.IsolateListView(add.GetBoxName(), add.GetType(), add.GetUserName(), ref textColorAdd);
            ListView currentViewDel = mParent.IsolateListView(del.GetBoxName(), del.GetType(), del.GetUserName(), ref textColorDel);

            if (currentViewAdd == currentViewDel)
            {
                // Check to see if this item already exists?
                int index = ListViewItemMessagesFindItem(add.GetFullFilename(), currentViewAdd);
                if (index != -1)
                {
                    currentViewAdd.Items[index].SubItems[(int)guiAssetManager.MessageBoxColumns.STATUS].Text   = command.GetDescription();
                    currentViewAdd.Items[index].SubItems[(int)guiAssetManager.MessageBoxColumns.BOX].Text      = add.GetBoxName();
                    currentViewAdd.Items[index].SubItems[(int)guiAssetManager.MessageBoxColumns.FULLNAME].Text = add.GetFullFilename();
                    currentViewAdd.Items[index].ForeColor = textColorAdd;
                    for (int x = 0; x < currentViewAdd.Items[index].SubItems.Count; x++)
                    {
                        currentViewAdd.Items[index].SubItems[x].ForeColor = textColorAdd;
                    }
                }
            }
            else
            {
                if (currentViewDel != null)
                {
                    int index = ListViewItemMessagesFindItem(del.GetFullFilename(), currentViewDel);
                    if (index != -1)
                    {
                        currentViewDel.Items[index].Remove();
                    }
                }

                if (currentViewAdd != null)
                {
                    // Check to see if this item already exists?
                    int index = ListViewItemMessagesFindItem(add.GetFullFilename(), currentViewAdd);
                    if (index != -1)
                    {
                        currentViewAdd.Items[index].SubItems[(int)guiAssetManager.MessageBoxColumns.STATUS].Text   = command.GetDescription();
                        currentViewAdd.Items[index].SubItems[(int)guiAssetManager.MessageBoxColumns.FULLNAME].Text = add.GetFullFilename();
                        currentViewAdd.Items[index].ForeColor = textColorAdd;
                        for (int x = 0; x < currentViewAdd.Items[index].SubItems.Count; x++)
                        {
                            currentViewAdd.Items[index].SubItems[x].ForeColor = textColorAdd;
                        }
                    }
                    else
                    {
                        MOG_ControllerMessage assetController = new MOG_ControllerMessage(mParent.mMog);
                        if (!assetController.Open(add.GetFullFilename()))
                        {
                            return;
                        }

                        // Create the newly added node
                        ListViewItem item = mParent.CreateListViewNode(assetController.GetSubject(),
                                                                       assetController.GetFrom(),
                                                                       assetController.GetFileInfo().LastWriteTime.ToString(),
                                                                       assetController.GetTo(),
                                                                       assetController.GetStatus(),
                                                                       "",
                                                                       assetController.GetAssetFilename().GetFullFilename(),
                                                                       assetController.GetAssetFilename().GetBoxName(),
                                                                       Color.Black);

                        currentViewAdd.Items.Add(item);

                        assetController.Close();
                    }
                }
            }

            // Update the Tab
            RefreshTab(command);
        }
        public void RefreshBox(MOG_Filename add, MOG_Filename del, MOG_Command command)
        {
            Color textColorAdd = Color.Black;
            Color textColorDel = Color.Black;

            // Dont add if we dont have a valid box
            if (add.GetBoxName().Length == 0 && del.GetBoxName().Length == 0)
            {
                return;
            }

            ListView currentViewAdd = mParent.IsolateListView(add.GetBoxName(), add.GetType(), add.GetUserName(), ref textColorAdd);
            ListView currentViewDel = mParent.IsolateListView(del.GetBoxName(), del.GetType(), del.GetUserName(), ref textColorDel);

            if (currentViewAdd == currentViewDel)
            {
                // Check to see if this item already exists?
                int index = mParent.ListViewItemFindItem(add.GetFilename(), currentViewAdd);
                if (index != -1)
                {
                    currentViewAdd.Items[index].SubItems[(int)guiAssetManager.TaskBoxColumns.STATUS].Text   = command.GetDescription();
                    currentViewAdd.Items[index].SubItems[(int)guiAssetManager.TaskBoxColumns.FULLNAME].Text = add.GetFullFilename();
                    currentViewAdd.Items[index].ForeColor = textColorAdd;
                    for (int x = 0; x < currentViewAdd.Items[index].SubItems.Count; x++)
                    {
                        currentViewAdd.Items[index].SubItems[x].ForeColor = textColorAdd;
                    }
                }
            }
            else
            {
                if (currentViewDel != null)
                {
                    int index = mParent.ListViewItemFindItem(del.GetFilename(), currentViewDel);
                    if (index != -1)
                    {
                        currentViewDel.Items[index].Remove();
                    }
                }

                if (currentViewAdd != null)
                {
                    // Check to see if this item already exists?
                    int index = mParent.ListViewItemFindItem(add.GetFilename(), currentViewAdd);
                    if (index != -1)
                    {
                        currentViewAdd.Items[index].SubItems[(int)guiAssetManager.TaskBoxColumns.STATUS].Text   = command.GetDescription();
                        currentViewAdd.Items[index].SubItems[(int)guiAssetManager.TaskBoxColumns.FULLNAME].Text = add.GetFullFilename();
                        currentViewAdd.Items[index].ForeColor = textColorAdd;
                        for (int x = 0; x < currentViewAdd.Items[index].SubItems.Count; x++)
                        {
                            currentViewAdd.Items[index].SubItems[x].ForeColor = textColorAdd;
                        }
                    }
                    else
                    {
                        MOG_ControllerTask assetController = new MOG_ControllerTask(mParent.mMog);
                        if (!assetController.Open(add.GetFullFilename()))
                        {
                            return;
                        }

                        ListViewItem item = new ListViewItem();

                        item.Text = assetController.GetTitle();

                        MOG_Time t = new MOG_Time();
                        t.SetTimeStamp(assetController.GetDueDate());
                        item.SubItems.Add(t.ToDateTime().ToString());

                        item.SubItems.Add(assetController.GetFileInfo().LastWriteTime.ToString());
                        item.SubItems.Add(assetController.GetCreator());
                        item.SubItems.Add(assetController.GetPriority());
                        item.SubItems.Add(assetController.GetStatus());
                        item.SubItems.Add(assetController.GetAsset());
                        item.SubItems.Add(assetController.GetAssetFilename().GetFullFilename());
                        item.SubItems.Add(assetController.GetAssetFilename().GetBoxName());
                        item.ForeColor = Color.Black;
                        for (int x = 0; x < item.SubItems.Count; x++)
                        {
                            item.SubItems[x].ForeColor = textColorAdd;
                        }

                        item.ImageIndex = 0;                        //SetAssetIcon(String.Concat(mParent.mMog.GetActiveUser().GetUserPath(), "\\", box, "\\", assetName));
                        currentViewAdd.Items.Add(item);

                        assetController.Close();
                    }
                }
            }

            // Update the tab
            RefreshTab(command);
        }
示例#5
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;
            }
        }
示例#6
0
        static public bool AddAssetToWorkspaces(MOG_Filename assetFilename, bool userInitiated, BackgroundWorker worker)
        {
            bool bFailed = false;

            // Open the asset now to save time later so it doesn't need to be opened for each workspace
            MOG_ControllerAsset asset = MOG_ControllerAsset.OpenAsset(assetFilename);

            if (asset != null)
            {
                try
                {
                    // Walk through all of our workspaces
                    foreach (MOG_ControllerSyncData workspace in mWorkspaces.Values)
                    {
                        bool bAddAsset = false;

                        // Check if this workspace is active?
                        if (workspace.IsAlwaysActive())
                        {
                            bAddAsset = true;
                        }
                        // Imported asset has special logic
                        else if (asset.GetProperties().Status == MOG_AssetStatus.GetText(MOG_AssetStatusType.Imported))
                        {
                            // Check if this asset originated from within this workspace?  (special case added for SmartBomb so editor will always update the workspace of an object sent from the editor)
                            if (DosUtils.PathIsWithinPath(workspace.GetSyncDirectory(), asset.GetProperties().SourcePath))
                            {
                                bAddAsset = true;
                            }
                            // Check if the user actually initiated this event?
                            else if (userInitiated &&
                                     workspace == MOG_ControllerProject.GetCurrentSyncDataController())
                            {
                                bAddAsset = true;
                            }
                        }
                        // All other assets should simply go into the current
                        else if (workspace == MOG_ControllerProject.GetCurrentSyncDataController())
                        {
                            bAddAsset = true;
                        }

                        // Should this asset be added?
                        if (bAddAsset)
                        {
                            // Decide if the user wants to be notified about the asset's update
                            bool bInformUser = userInitiated;
                            // Check if no worker was specified?  or
                            // Check if this isn't the active workspace?
                            if (worker == null ||
                                workspace != MOG_ControllerProject.GetCurrentSyncDataController())
                            {
                                // Don't bother the user about any problems
                                bInformUser = false;
                            }

                            // Check if we can add this asset to the local workspace?
                            if (workspace.CanAddAssetToLocalWorkspace(asset, bInformUser))
                            {
                                // Check if this asset comming from an inbox?   and
                                // Check if this asset comming from our inbox?   and
                                // Check if this asset's current state is 'Imported'  and
                                // Check if this asset originated from this workspace?
                                // Finally, Make sure this wasn't user initiated?
                                if (assetFilename.IsWithinInboxes() &&
                                    string.Compare(assetFilename.GetUserName(), MOG_ControllerProject.GetUserName(), true) == 0 &&
                                    string.Compare(asset.GetProperties().Status, MOG_AssetStatus.GetText(MOG_AssetStatusType.Imported), true) == 0 &&
                                    MOG_Filename.IsWithinPath(workspace.GetSyncDirectory(), asset.GetProperties().SourcePath) &&
                                    !userInitiated)
                                {
                                    // Looks like we can proceed to import
                                    if (!workspace.AddAssetToLocalUpdatedTray(asset, worker))
                                    {
                                        bFailed = true;
                                    }

                                    // Continue on to the next asset
                                    continue;
                                }

                                // Proceed to add the asset to this workspace
                                if (!workspace.AddAssetToLocalWorkspace(asset, worker))
                                {
                                    bFailed = true;
                                }
                            }
                        }
                    }
                }
                finally
                {
                    asset.Close();
                }
            }
            else
            {
                bFailed = true;
            }

            if (!bFailed)
            {
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Refresh an assets status from a ViewUpdate Command
        /// </summary>
        public void RefreshBox(MOG_Filename add, MOG_Filename del, MOG_Command command)
        {
            lock (mAssetManager)
            {
                ListView currentViewAdd = mAssetManager.IsolateListView(add.GetBoxName(), add.GetFilenameType(), add.GetUserName());
                ListView currentViewDel = mAssetManager.IsolateListView(del.GetBoxName(), del.GetFilenameType(), del.GetUserName());

                // Don't continue if we don't have a valid add and del box
                if ((currentViewAdd == null) && (currentViewDel == null))
                {
                    return;
                }

                // Begin the update
                if (currentViewAdd != null)
                {
                    currentViewAdd.BeginUpdate();
                }
                if (currentViewDel != null)
                {
                    currentViewDel.BeginUpdate();
                }

                string status = command.GetDescription();

                mAssetManager.mainForm.mSoundManager.PlayStatusSound("AssetEvents", status);

                try
                {
                    // Obtain the properties from the command
                    MOG_Properties pProperties  = null;
                    string[]       commandProps = command.GetVeriables().Split("$".ToCharArray());
                    if (commandProps != null)
                    {
                        ArrayList realProps = new ArrayList();

                        // Convert the commandProps into a list of real Properties
                        for (int i = 0; i < commandProps.Length; i++)
                        {
                            // Confirm this appears to be a valid prop?
                            if (commandProps[i].StartsWith("["))
                            {
                                MOG_Property commandProp = new MOG_Property(commandProps[i]);

                                // Make sure the property was initialized correctly?
                                if (commandProp.mSection.Length > 0 &&
                                    commandProp.mKey.Length > 0)
                                {
                                    // Add this realProp
                                    realProps.Add(commandProp);
                                }
                            }
                        }

                        // Construct the pProperties from the realProps
                        pProperties = new MOG_Properties(realProps);

                        // If we have a valid gameDataController, set our platform scope
                        if (MOG_ControllerProject.GetCurrentSyncDataController() != null)
                        {
                            pProperties.SetScope(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName());
                        }
                    }

                    // Check if we are just updating an item in the same list?
                    if (currentViewAdd == currentViewDel)
                    {
                        // Check to see if this item already exists?
                        int targetIndex = mAssetManager.ListViewItemFindFullItem(del, currentViewDel);
                        int sourceIndex = mAssetManager.ListViewItemFindFullItem(add, currentViewAdd);
                        if (sourceIndex != -1)
                        {
                            // Update the existing item
                            ListViewItem item = currentViewAdd.Items[sourceIndex];
                            guiAssetManager.UpdateListViewItem(item, add, status, pProperties);

                            // If there was also a target index, we need to delete it because the source became the target.
                            if (targetIndex != -1 &&
                                targetIndex != sourceIndex)
                            {
                                ListViewItem removeItem = currentViewAdd.Items[targetIndex];

                                // Make sure to clear our stateImage index which will clear the checked state before we attempt to remove the node or we will throw
                                removeItem.StateImageIndex = 0;

                                currentViewAdd.Items.Remove(removeItem);
                            }
                        }
                        // Special case when we are dealing with a renamed file
                        else if (targetIndex != -1 && sourceIndex == -1)
                        {
                            // Get the old item
                            ListViewItem item = currentViewDel.Items[targetIndex];

                            // Update it to the new renamed item
                            guiAssetManager.UpdateListViewItem(item, add, status, pProperties);
                        }
                        else
                        {
                            // Add a new item
                            CreateListViewItem(currentViewAdd, add, status, pProperties);
                            // Make sure we always keep our tab's text up-to-date
                            mAssetManager.UpdateAssetManagerTabText(add);
                        }
                    }
                    else
                    {
                        // Looks like we may need to do both the add and the remove
                        // Check if we have the currentViewDel?
                        if (currentViewDel != null)
                        {
                            int index = mAssetManager.ListViewItemFindFullItem(del, currentViewDel);
                            if (index != -1)
                            {
                                ListViewItem item = currentViewDel.Items[index];

                                // Make sure to clear our stateImage index which will clear the checked state before we attempt to remove the node or we will throw
                                item.StateImageIndex = 0;

                                // Remove the item from the list
                                currentViewDel.Items.Remove(item);

                                // Make sure we always keep our tab's text up-to-date
                                mAssetManager.UpdateAssetManagerTabText(del);
                            }
                        }

                        // Check if we have the currentViewAdd?
                        if (currentViewAdd != null)
                        {
                            // Check to see if this item already exists?
                            int sourceIndex = mAssetManager.ListViewItemFindFullItem(add, currentViewAdd);
                            if (sourceIndex != -1)
                            {
                                // Update the existing item
                                ListViewItem item = currentViewAdd.Items[sourceIndex];
                                guiAssetManager.UpdateListViewItem(item, add, status, pProperties);
                            }
                            else
                            {
                                // Add a new item
                                CreateListViewItem(currentViewAdd, add, status, pProperties);
                                // Make sure we always keep our tab's text up-to-date
                                mAssetManager.UpdateAssetManagerTabText(add);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MOG_Report.ReportSilent("RefreshBox", ex.Message, ex.StackTrace);
                }

                // End the update
                if (currentViewAdd != null)
                {
                    currentViewAdd.EndUpdate();
                }
                if (currentViewDel != null)
                {
                    currentViewDel.EndUpdate();
                }
            }
        }