public PriviledgesForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.OldWidth = this.Width;
            MOG_Main.Init_Client("");
            mMogProcess = new Thread(new ThreadStart(this.MogProcess));
            mMogProcess.Start();
            MOG_ControllerProject.LoginProject("BlackJupiter", "CURRENT");
            MOG_ControllerProject.LoginUser("Admin");
            mPriviledges = MOG_ControllerProject.GetPriviledges();

            InitializeMainTreeView(mPriviledges);
        }
Exemple #2
0
        public static bool SetOffline(MogMainForm mainForm, bool offline)
        {
            if (offline)
            {
                // TODO KIER How do we go offline now?

//				string targetPath = string.Concat(MOG_ControllerProject.GetGameData().GetGameDataPath(), "\\MOG\\Offline");
//				if (MOG_ControllerProject.GetProject().Offline(targetPath))
//				{
//					// Disconnect from the server
//					MOG_ControllerSystem.GoOffline();
//
//					if (MOG_ControllerSystem.GetSystem().Load(MOG_Main.BuildDefaultConfigFile(targetPath, "", "")))
//					{
//						// Reload the project
//						MOG_ControllerProject.LoginProject(MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName());
//
//						// Set our gui
//						guiStartup.ConnectionStatus(mainForm, false);
//					}
//				}
            }
            else
            {
                // Connect to the server
                MOG_ControllerSystem.GoOnline();

                if (MOG_ControllerSystem.GetSystem().Load(MOG_Main.BuildDefaultConfigFile()))
                {
                    // Reload the project
                    MOG_ControllerProject.LoginProject(MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName());

                    // Login user
                    MOG_ControllerProject.LoginUser(MOG_ControllerProject.GetUser().GetUserName());

                    // Set our gui
                    guiStartup.ConnectionStatus(mainForm, true);
                }
            }

            return(true);
        }
        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);
            }
        }
Exemple #4
0
        private void CreateAssetConfigs_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            MOG_ControllerProject.LoginUser("Admin");

            // Construct a new common timestamp for all of these assets
            string timestamp = MOG_Time.GetVersionTimestamp();

            // Activate the properties cache to help save time during the importation process
            MOG_Properties.ActivatePropertiesCache(true);

            for (int nodeIndex = 0; nodeIndex < assetFilenameNodes.Count; nodeIndex++)
            {
                classTreeNode tn = assetFilenameNodes[nodeIndex] as classTreeNode;

                string fullAssetName = tn.FullPath;                //tn.Parent.FullPath + tn.Text;
                string fileList      = Utils.ArrayListToString(tn.importFiles, "");

                // Check if this is a library asset?
                bool bIsInLibrary = false;
                if (tn.TreeView != null)
                {
                    string fullPath = tn.FullPath + tn.TreeView.PathSeparator;
                    string testPath = tn.TreeView.PathSeparator + "Library" + tn.TreeView.PathSeparator;
                    if (fullPath.IndexOf(testPath, 0, StringComparison.CurrentCultureIgnoreCase) != -1)
                    {
                        bIsInLibrary = true;
                    }
                }

                MOG_Filename repositoryName = null;
                if (bIsInLibrary && tn.importFiles.Count > 0)
                {
                    // Use the timestamp of the file (Needed for out-of-date checks with library assets)
                    String   libraryTimestamp = "";
                    FileInfo file             = new FileInfo(tn.importFiles[0] as string);
                    if (file != null && file.Exists)
                    {
                        libraryTimestamp = MOG_Time.GetVersionTimestamp(file.LastWriteTime);
                    }
                    repositoryName = MOG_ControllerRepository.GetAssetBlessedVersionPath(new MOG_Filename(fullAssetName), libraryTimestamp);
                }
                else
                {
                    // Use the common timestamp for all the assets
                    repositoryName = MOG_ControllerRepository.GetAssetBlessedVersionPath(new MOG_Filename(fullAssetName), timestamp);
                }

                MOG_Filename createdAssetFilename = null;

                string message = "Importing:\n" +
                                 "     " + repositoryName.GetAssetClassification() + "\n" +
                                 "     " + repositoryName.GetAssetName();
                worker.ReportProgress(nodeIndex * 100 / assetFilenameNodes.Count, message);

                if (worker.CancellationPending)
                {
                    if (Utils.ShowMessageBoxConfirmation("Are you sure you want to cancel asset importation?", "Cancel Asset Importation?") == MOGPromptResult.Yes)
                    {
                        return;
                    }
                }

                try
                {
                    string dirScope = MOG_ControllerAsset.GetCommonDirectoryPath(this.projectRootPath, tn.importFiles);

                    // Construct our list non-inherited asset assuming none
                    ArrayList props = null;
                    if (tn.props != null)
                    {
                        // Ask the tn.props for the list of non-inherited properties
                        props = tn.props.GetNonInheritedProperties();
                    }
                    else
                    {
                        props = new ArrayList();

                        // Setup SyncTargetPath Property
                        string assetDirectoryScope = MOG_ControllerAsset.GetCommonDirectoryPath(this.projectRootPath, tn.importFiles);
                        if (assetDirectoryScope.Length > this.projectRootPath.Length)
                        {
                            string syncTargetPath = assetDirectoryScope.Substring(this.projectRootPath.Length + 1);
                            props.Add(MOG.MOG_PropertyFactory.MOG_Sync_OptionsProperties.New_SyncTargetPath(syncTargetPath));
                        }
                    }

                    // Proceed to import the asset
                    createdAssetFilename = MOG_ControllerAsset.CreateAsset(repositoryName, dirScope, tn.importFiles, null, props, false, false);
                    if (createdAssetFilename == null)
                    {
                        // it's probably a network problem (TODO: Check for sure)

                        // build a list of files for error message
                        string files = "\n\nFiles contained in " + tn.Text + "\n";
                        foreach (string fname in tn.importFiles)
                        {
                            files += "\t" + fname + "\n";
                        }

                        MOGPromptResult r = MOG_Prompt.PromptResponse("Import Error", "Importation of " + tn.FullPath + " failed.  Please ensure that the file is accessible and click Retry." + files, MOGPromptButtons.AbortRetryIgnore);
                        if (r == MOGPromptResult.Retry)
                        {
                            --nodeIndex;                                        // stay on the same node (continue auto-increments)
                            continue;
                        }
                        else if (r == MOGPromptResult.Abort)
                        {
                            RaiseAssetImport_Finish();
                            MOG_Prompt.PromptResponse("Cancelled", "Importation Cancelled", Environment.StackTrace, MOGPromptButtons.OK, MOG_ALERT_LEVEL.MESSAGE);
                            return;
                        }
                        else if (r == MOGPromptResult.Ignore)
                        {
                            continue;
                        }
                    }

                    // Schedule this asset for posting under this project name
                    MOG_ControllerProject.AddAssetForPosting(createdAssetFilename, MOG_ControllerProject.GetProjectName());
                }
                catch (Exception ex)
                {
                    MOG_Report.ReportMessage("Create Asset", "Could not correctly create asset.\nMessage=" + ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
                    continue;
                }
            }

            // Shut off the properties cache
            MOG_Properties.ActivatePropertiesCache(false);
        }
Exemple #5
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);
        }