public void AssetImportFromShell(string[] files, bool separate, bool looseFileMatching)
        {
            // If we are not the login user, switch us
            if (string.Compare(MOG_ControllerProject.GetActiveUser().GetUserName(), MOG_ControllerProject.GetUser().GetUserName(), true) != 0)
            {
                guiUser user = new guiUser(mAssetManager.mainForm);
                mAssetManager.mainForm.AssetManagerActiveUserComboBox.Text = MOG_ControllerProject.GetUser().GetUserName();
                user.SetActiveUser(MOG_ControllerProject.GetUser().GetUserName());
                mAssetManager.RefreshActiveWindow();
            }

            if (separate)
            {
                guiAssetController.ImportSeparately(files, looseFileMatching);
            }
            else
            {
                guiAssetController.ImportAsOne(files, looseFileMatching);
            }
        }
Example #2
0
        public int GetImage()
        {
            switch (mType)
            {
            case TaskType.Department:
                return(1);

            case TaskType.User:
                return(2);

            case TaskType.Task:
                // Check if this is assigned to this user
                string userId = MOG_ControllerProject.GetUser().GetUserName();

                if (mTaskInfo != null)
                {
                    if (string.Compare(userId, GetTaskInfo().GetAssignedTo(), true) != 0)
                    {
                        return(4);                                // This is assigned to someone else
                    }
                    else
                    {
                        // Check to see if this is a child task
                        if (GetTaskInfo().GetParent().Length > 0)
                        {
                            return(6);
                        }
                        else
                        {
                            return(3);                                    // This is assigned to me
                        }
                    }
                }
                else
                {
                    return(3);
                }
            }
            return(7);
        }
        private void PopulateFilters()
        {
            GetLatestFiltersToolStripMenuItem.DropDownItems.Clear();

            // Get the last set active tag
            string active = "";

            if (GetLatestFiltersToolStripMenuItem.Tag is string)
            {
                active = GetLatestFiltersToolStripMenuItem.Tag as string;
                AddFilterItem(active, "None");
            }
            else
            {
                AddFilterItem("None", "None");
            }

            // Get the users tools
            if (MOG_ControllerProject.GetUser() != null)
            {
                // Get all the filter files found within the users tools directory
                foreach (string filter in Directory.GetFiles(MOG_ControllerProject.GetUser().GetUserToolsPath(), "*.sync"))
                {
                    AddFilterItem(active, filter);
                }
            }

            if (!DesignMode)
            {
                // Get project tools
                // Get all the filter files found within the users tools directory
                string toolsPath = Path.Combine(MOG_ControllerProject.GetProjectPath(), "Tools");
                foreach (string filter in Directory.GetFiles(toolsPath, "*.sync"))
                {
                    AddFilterItem(active, filter);
                }
            }
        }
Example #4
0
        void ExportTo_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            List <object>    args   = e.Argument as List <object>;
            ArrayList        items  = args[0] as ArrayList;
            EXPORTS          format = (EXPORTS)args[1];

            string tempListFilename;

            switch (format)
            {
            case EXPORTS.EXCEL:
                tempListFilename = CreateUniqueFilename(MOG_ControllerProject.GetUser().GetUserToolsPath(), "AssetList.slk");
                break;

            case EXPORTS.TEXT:
                tempListFilename = CreateUniqueFilename(MOG_ControllerProject.GetUser().GetUserToolsPath(), "AssetList.txt");
                break;

            default:
                tempListFilename = "";
                break;
            }

            // Clear out any previous temp file
            if (DosUtils.FileExist(tempListFilename))
            {
                DosUtils.FileDelete(tempListFilename);
            }

            for (int i = 0; i < items.Count; i++)
            {
                ListViewItem item = items[i] as ListViewItem;

                string message = "Adding:\n" +
                                 "     " + item.SubItems[(int)ASSET_LIST.NAME].Text;
                worker.ReportProgress(i * 100 / items.Count, message);

                string text = item.SubItems[(int)ASSET_LIST.NAME].Text + "\t" +
                              item.SubItems[(int)ASSET_LIST.CLASSIFICATION].Text + "\t" +
                              item.SubItems[(int)ASSET_LIST.PLATFORM].Text + "\t" +
                              item.SubItems[(int)ASSET_LIST.VERSION].Text + "\t" +
                              item.SubItems[(int)ASSET_LIST.SIZE].Text + "\t" +
                              item.SubItems[(int)ASSET_LIST.OWNER].Text;

                switch (format)
                {
                case EXPORTS.EXCEL:
                    DosUtils.AppendTextToSlkFile(tempListFilename, text);
                    break;

                case EXPORTS.TEXT:
                    DosUtils.AppendTextToFile(tempListFilename, text + "\r\n");
                    break;

                default:
                    break;
                }
            }

            if (format == EXPORTS.EXCEL)
            {
                DosUtils.FileCloseSlk(tempListFilename);
            }

            e.Result = tempListFilename;
        }
Example #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;
            }
        }
Example #6
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);
            }
        }
Example #7
0
        /// <summary>
        /// Returns true if user has privilege to rename a blessed asset
        /// </summary>
        /// <returns></returns>
        private bool CheckPrivilegeToRename()
        {
            string userName = MOG_ControllerProject.GetUser().GetUserName();

            return(MOG_ControllerProject.GetPrivileges().GetUserPrivilege(userName, MOG_PRIVILEGE.RenameBlessedAsset));
        }
Example #8
0
        public void SaveFilter(string filterName)
        {
            string filename = Path.Combine(MOG_ControllerProject.GetUser().GetUserToolsPath(), filterName + ".sync");

            mFilter.Save(filename);
        }
Example #9
0
        private void UpdateFilterDropDown(string selectedText)
        {
            SyncFilterComboBox.Items.Clear();
            //int comboWidth = SyncFilterComboBox.Width;

            // Get the users tools
            if (MOG_ControllerProject.GetUser() != null)
            {
                // Get all the filter files found within the users tools directory
                foreach (string filter in Directory.GetFiles(MOG_ControllerProject.GetUser().GetUserToolsPath(), "*.sync"))
                {
                    // Add the names of each one of them to the comboBox
                    int index = SyncFilterComboBox.Items.Add(new ComboBoxItem(Path.GetFileNameWithoutExtension(filter), Path.Combine(MOG_ControllerProject.GetUser().GetUserToolsPath(), filter)));
                    SyncFilterComboBox.AutoCompleteCustomSource.Add(Path.GetFileNameWithoutExtension(filter));

                    // Adjust the width
                    //SyncFilterComboBox.Width = SyncFilterComboBox.PreferredSize.Width;

                    if (Path.GetFileNameWithoutExtension(filter) == selectedText)
                    {
                        SyncFilterComboBox.SelectedIndex = index;
                    }
                }
            }

            if (!DesignMode)
            {
                // Get project tools
                // Get all the filter files found within the users tools directory
                string toolsPath = Path.Combine(MOG_ControllerProject.GetProjectPath(), "Tools");
                foreach (string filter in Directory.GetFiles(toolsPath, "*.sync"))
                {
                    // Add the names of each one of them to the comboBox
                    int index = SyncFilterComboBox.Items.Add(new ComboBoxItem(Path.GetFileNameWithoutExtension(filter), Path.Combine(toolsPath, filter)));

                    // Adjust the width
                    //SyncFilterComboBox.Width = SyncFilterComboBox.PreferredSize.Width;

                    if (Path.GetFileNameWithoutExtension(filter) == selectedText)
                    {
                        SyncFilterComboBox.SelectedIndex = index;
                    }
                }
            }
        }
Example #10
0
        public bool SetLoginUser(string userName)
        {
            string ActiveUser, LoginUser;

            // Make sure the user specified is not a label
            if (userName.IndexOf("[") != -1)
            {
                return(false);
            }

            if (MOG_ControllerProject.LoginUser(userName) != null)
            {
                // Update tab pages
                if (mainForm.mAssetManager != null)
                {
                    ActiveUser = mainForm.mAssetManager.GetActiveUser();
                    LoginUser  = MOG_ControllerProject.GetUser().GetUserName();

                    if (MOG_ControllerProject.GetActiveUser() != null)
                    {
                        mainForm.mAssetManager.SetActiveUser(MOG_ControllerProject.GetActiveUser().GetUserName());
                        ActiveUser = MOG_ControllerProject.GetActiveUser().GetUserName();
                    }
                }
                else
                {
                    ActiveUser = "******";
                    LoginUser  = "******";
                }

                // Update tab pages
                if (mainForm.mProjectManager != null)
                {
                    mainForm.mProjectManager.Initialize();
                }

                if (mainForm.mAssetManager != null)
                {
                    mainForm.mAssetManager.LatentInitialize();

                    // Only load branches if we have already booted MOG
                    if (mainForm.mAssetManager.mLoadBranches == false)
                    {
                        mainForm.mAssetManager.mLocal.LoadUserLocalBranches();
                    }

                    // Initialize the Tasks Window
                    //mainForm.AssetManagerTaskWindow.InitializeForUser();
                }

                if (mainForm.mLibraryManager != null)
                {
                    mainForm.mLibraryManager.Initialize();
                }

                // Enable the logout button
                mainForm.AssetManagerLogoutButton.Enabled = true;

                // Also set the default active user
                SetActiveUser(userName);

                // Set the status bar
                mainForm.MOGStatusBarUserBarPanel.Text = userName;

                // Save our prefs file
                guiUserPrefs.SaveStatic_ProjectPrefs();

                return(true);
            }

            mainForm.AssetManagerLogoutButton.Enabled = false;
            return(false);
        }
Example #11
0
        private void SyncSaveButton_Click(object sender, System.EventArgs e)
        {
            SyncSaveFileDialog.InitialDirectory = MOG_ControllerProject.GetUser().GetUserToolsPath();

            // Save this custom sync file
            if (SyncSaveFileDialog.ShowDialog() == DialogResult.OK)
            {
                string  syncFilename = SyncSaveFileDialog.FileName;
                MOG_Ini syncFile     = new MOG_Ini(syncFilename);

                foreach (TreeNode sectionNode in XboxSincTreeView.Nodes)
                {
                    string section = sectionNode.Text;

                    foreach (TreeNode keyNode in sectionNode.Nodes)
                    {
                        string key = keyNode.Text;

                        if (keyNode.Nodes.Count > 0)
                        {
                            foreach (TreeNode valNode in keyNode.Nodes)
                            {
                                string val = valNode.Text;

                                syncFile.PutString(section, key, val);
                            }
                        }
                        else
                        {
                            syncFile.PutSectionString(section, key);
                        }
                    }
                }

                // Verify that the newly created sync file has the correct number amount of sections
                if (syncFile.SectionExist("Filemap"))
                {
                    if (syncFile.CountKeys("Filemap") > 0 && string.Compare(SyncProjectMapComboBox.Text, "None") == 0)
                    {
                        MOG_Prompt.PromptMessage("Missing syncfile data", "The required 'FILEMAP' section was not found in this custom sync file.  Aborting...");
                        syncFile.CloseNoSave();
                        return;
                    }
                }
                else
                {
                    MOG_Prompt.PromptMessage("Missing syncfile data", "The required 'FILEMAP' section was not found in this custom sync file.  Aborting...");
                    syncFile.CloseNoSave();
                    return;
                }

                // Make sure we have a valid root definition
                if (syncFile.SectionExist(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName()))
                {
                    if (syncFile.CountKeys(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName()) > 0 && string.Compare(SyncProjectMapComboBox.Text, "None") == 0)
                    {
                        MOG_Prompt.PromptMessage("Missing syncfile data", "The required '" + MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName() + "' section was not found in this custom sync file.  Aborting...");
                        syncFile.CloseNoSave();
                        return;
                    }
                }
                else
                {
                    MOG_Prompt.PromptMessage("Missing syncfile data", "The required '" + MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName() + "' section was not found in this custom sync file.  Aborting...");
                    syncFile.CloseNoSave();
                    return;
                }

                // Save out our new syncFile
                syncFile.Save();
                SyncSaveButton.Enabled = false;

                mUserMap = syncFile.GetFilename();
            }
        }
Example #12
0
        private void LoadUserSyncFiles()
        {
            #region Initialize the project filemaps
            // Get any additional maps
            SyncProjectMapComboBox.Items.Clear();
            FileInfo [] files = DosUtils.FileGetList(MOG_ControllerProject.GetProject().GetProjectToolsPath(), "*.sync");
            if (files != null)
            {
                // Add the default 'none'
                SyncProjectMapComboBox.Items.Add("None");

                foreach (FileInfo file in files)
                {
                    SyncProjectMapComboBox.Items.Add(file.Name);
                }

                if (files.Length > 0)
                {
                    SyncProjectMapComboBox.SelectedIndex = 0;
                }
            }

            // Set the project map
            if (mProjectMap.Length != 0)
            {
                SyncProjectMapComboBox.Text = mProjectMap;
            }
            else
            {
                mProjectMap = "None";
                SyncProjectMapComboBox.Text = mProjectMap;
            }
            #endregion

            #region Initialize the user filemaps
            // Get any aditional sync files
            SyncUserMapComboBox.Items.Clear();
            files = DosUtils.FileGetList(MOG_ControllerProject.GetUser().GetUserToolsPath(), "*.sync");
            if (files != null)
            {
                // Add the default user map
                SyncUserMapComboBox.Items.Add("None");

                foreach (FileInfo file in files)
                {
                    SyncUserMapComboBox.Items.Add(file.Name);
                }

                if (files.Length > 0)
                {
                    SyncUserMapComboBox.SelectedIndex = 0;
                }
            }

            // Set the user map
            if (mUserMap.Length != 0)
            {
                SyncUserMapComboBox.Text = mUserMap;
            }
            else
            {
                mUserMap = "None";
                SyncUserMapComboBox.Text = mUserMap;
            }
            #endregion
        }
Example #13
0
        static private void LaunchBuild(MogMainForm mainForm, string command, MOG_Ini options)
        {
            // Extract the Build's Options
            string BuildPlatform = "";
            string BuildType     = "";

            // Split up the Build's Options
            string [] commands = command.Trim().Split(" ".ToCharArray());
            if (command.Length == 0 || commands.Length < 1)
            {
                MOG_Prompt.PromptMessage("Request build", "Bad or missing command (" + command + ") in request build!", Environment.StackTrace);
                return;
            }

            BuildType = commands[0];

            if (commands.Length > 1)
            {
                BuildPlatform = commands[1];
            }


            // Get the list of available slaves to use for builds
            // Get the highest slaves
            string validSlaves = "";

            if (options.SectionExist("Builds.ValidSlaves") &&
                options.KeyExist("Builds.ValidSlaves", "Builds"))
            {
                validSlaves = options.GetString("Builds.ValidSlaves", "Builds");
            }

            string buildTypeSection = "Builds." + BuildType;

            // Locate the buildTool within the Build.Options.Info file
            string buildTool = "";

            // Determine what the executable name is
            if (options.SectionExist(buildTypeSection))
            {
                // Check for a buildTypeSection level validSlaves definition
                if (options.SectionExist("Builds.ValidSlaves") && options.KeyExist("Builds.ValidSlaves", buildTypeSection))
                {
                    validSlaves = options.GetString("Builds.ValidSlaves", buildTypeSection);
                }

                // Check if a specific BuildPlatform was specified? and
                // Check if we have keys in our buildTypeSection?
                if (BuildPlatform.Length > 0 &&
                    options.CountKeys(buildTypeSection) > 0)
                {
                    // Obtain the build tool for this build type and BuildPlatform
                    buildTool = options.GetString(buildTypeSection, BuildPlatform);
                    if (buildTool.Length > 0)
                    {
                        // Check for a BuildPlatform level validSlaves definition
                        if (options.SectionExist("Builds.ValidSlaves") && options.KeyExist("Builds.ValidSlaves", buildTypeSection + "." + BuildPlatform))
                        {
                            validSlaves = options.GetString("Builds.ValidSlaves", buildTypeSection + "." + BuildPlatform);
                        }
                    }
                }
                else if (options.KeyExist("Builds", BuildType))
                {
                    buildTool = options.GetString("Builds", BuildType);
                }
                else
                {
                }
            }

            // Make sure we have a valid build tool?
            if (buildTool.Length > 0)
            {
                // Locate the buildTool in the tools directories
                string buildToolRelativePath = Path.GetDirectoryName(buildTool);
                buildTool = MOG_ControllerSystem.LocateTool(buildToolRelativePath, buildTool);
                if (buildTool.Length > 0)
                {
                    //:: -----------------------------------------------------------------------
                    //:: MOG ENVIRONMENT VARIABLES
                    //:: -----------------------------------------------------------------------
                    string EnvVariables = MOG_EnvironmentVars.CreateToolsPathEnvironmentVariableString(buildToolRelativePath) + "," +
                                          MOG_EnvironmentVars.GetBuildProjectName() + "=" + MOG_ControllerProject.GetProjectName() + "," +
                                          MOG_EnvironmentVars.GetBuildProjectBranchName() + "=" + MOG_ControllerProject.GetBranchName() + "," +
                                          MOG_EnvironmentVars.GetBuildType() + "=" + BuildType + "," +
                                          MOG_EnvironmentVars.GetBuildPlatformName() + "=" + BuildPlatform + "," +
                                          MOG_EnvironmentVars.GetBuildTool() + "=" + buildTool + "," +
                                          MOG_EnvironmentVars.GetBuildToolPath() + "=" + System.IO.Path.GetDirectoryName(buildTool) + "," +
                                          MOG_EnvironmentVars.GetBuildRequestedBy() + "=" + MOG_ControllerProject.GetUser().GetUserName();

                    // Fire off the build
                    if (MOG_ControllerProject.Build(buildTool, validSlaves, MOG_ControllerProject.GetUser().GetUserName(), EnvVariables))
                    {
                        string message = "Build Request Successfull.\n" +
                                         "You will be notified when it is completed.";
                        MessageBox.Show(message, "Refresh Build", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    string message = "MOG was unable to locate the specified build tool.\n" +
                                     "BUILD TOOL: " + buildTool + "\n\n" +
                                     "Your MOG Administrator may need to internalize this tool before it will work.";
                    MOG_Prompt.PromptMessage("Request Build", message);
                }
            }
            else
            {
                string message = "No build tool was located for the selected build type.\n" +
                                 "BUILD TYPE: " + buildTypeSection + "\n\n" +
                                 "Your MOG Administrator may need to edit the 'Build.Options.Info' file to configure this build type.";
                MOG_Prompt.PromptMessage("Request Build", message);
            }
        }
		/// <summary>
		/// Add group or object to the database
		/// </summary>
		private bool AddGroupToDatabase(string addCandidate, MOG_Filename packageAsset)
		{
			// Are we platform generic?
			bool success = true;

			if (packageAsset.GetAssetPlatform() == "All")
			{
				string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);
				if (packageVersion.Length > 0)
				{
					success = MOG_DBPackageAPI.AddPackageGroupName(packageAsset, packageVersion, addCandidate, MOG_ControllerProject.GetUser().GetUserName());
				}
			}

			// We are platform generic, loop through all platforms then
			ArrayList platforms = MOG_ControllerProject.GetProject().GetPlatforms();
			for (int p = 0; p < platforms.Count && success; p++)
			{
				MOG_Platform platform = (MOG_Platform)platforms[p];

				// Set this package to be platform specific for this platform name
				packageAsset = MOG_Filename.CreateAssetName(packageAsset.GetAssetClassification(), platform.mPlatformName, packageAsset.GetAssetLabel());
				string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);
				if (packageVersion.Length > 0)
				{
					// Add to the database
					success &= MOG_DBPackageAPI.AddPackageGroupName(packageAsset, packageVersion, addCandidate, MOG_ControllerProject.GetUser().GetUserName());
				}
			}

			return success;
		}
		/// <summary>
		/// Remove a Group or Package Object from the database
		/// </summary>
		/// <param name="removeCandidate">Full path of Group or Object with 
		/// '/' as delimiter, starting from package name.</param>
		/// <param name="packageAsset">The Asset that is the Package</param>
		/// <param name="platformGeneric">
		/// Whether or not this is a platform Generic operation.  
		/// 
		/// This is where the "Show Platform Specific" checkbox would 
		/// plug in from the PackageManagementTreeView
		/// </param>
		/// <returns>Bool indicating success/failure</returns>
		public bool RemoveGroupFromDatabase(string removeCandidate, MOG_Filename packageAsset)
		{
			try
			{
				bool success = true;

				// Get the current version of this package
				string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);

				// Check to see if any assets reference this
				if (MOG_DBPackageAPI.GetAllAssetsInPackageGroup(packageAsset, packageVersion, removeCandidate).Count == 0)
				{
					// If all is ok, remove it from the database
					success &= MOG_DBPackageAPI.RemovePackageGroupName(packageAsset, packageVersion, removeCandidate, MOG_ControllerProject.GetUser().GetUserName());
				}
				else
				{
					throw (new Exception("Cannot remove object or group that is used by active assets!"));
				}

				// Are we platform generic?
				if (String.Compare(packageAsset.GetAssetPlatform(), "All", true) == 0)
				{
					// We are platform generic, loop through all platforms then
					ArrayList platforms = MOG_ControllerProject.GetProject().GetPlatforms();
					for (int p = 0; p < platforms.Count; p++)
					{
						MOG_Platform platform = (MOG_Platform)platforms[p];

						// Set this package to be platform specific for this platform name
						packageAsset = MOG_Filename.CreateAssetName(packageAsset.GetAssetClassification(), platform.mPlatformName, packageAsset.GetAssetLabel());
						packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);
						if (packageVersion.Length > 0)
						{
							// Check to see if any assets reference this
							if (MOG_DBPackageAPI.GetAllAssetsInPackageGroup(packageAsset, packageVersion, removeCandidate).Count == 0)
							{
								// If all is ok, remove it from the database
								success &= MOG_DBPackageAPI.RemovePackageGroupName(packageAsset, packageVersion, removeCandidate, MOG_ControllerProject.GetUser().GetUserName());
							}
							else
							{
								throw (new Exception("Cannot remove object or group that is used by active assets!"));
							}
						}
					}
				}

				return success;
			}
			catch (Exception e)
			{
				// Get the current version of this package
				string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);

				// See if we can report to the user about why this node could not be deleted
				ArrayList assignedAssets = MOG_DBPackageAPI.GetAllAssetsInPackageGroup(packageAsset, packageVersion, removeCandidate);

				if (assignedAssets != null)
				{
					// Walk all associated assets and make a list
					string assets = "";
					foreach (MOG_Filename assetName in assignedAssets)
					{
						if (assets.Length == 0)
						{
							assets = assetName.GetEncodedFilename();
						}
						else
						{
							assets = assets + "\n" + assetName.GetEncodedFilename();
						}
					}

					// Tell the user
					MOG_Prompt.PromptMessage("Remove node", "Cannot remove this node because the following assets are assigned to it:\n\n" + assets);
				}
				else
				{
					// This must have been another problem
					MOG_Prompt.PromptMessage("Remove node", "Cannot remove this node.\nMessage\n" + e.Message);
				}
			}

			return false;
		}