Esempio n. 1
0
        private void RefreshWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker         = sender as BackgroundWorker;
            string           trashDirectory = MOG_ControllerProject.GetActiveUser().GetUserPath() + "\\Trash";

            mSize = 0;

            ArrayList assets = MOG_DBInboxAPI.InboxGetAssetListWithProperties("Trash", MOG_ControllerProject.GetActiveUser().GetUserName(), "", "");
            int       i      = 0;

            foreach (MOG_DBInboxProperties asset in assets)
            {
                // Create the properties for this asset
                MOG_Properties pProperties = new MOG_Properties(asset.mProperties);

                worker.ReportProgress(i, asset.mAsset.GetAssetName());

                // Create the ListViewItem
                ListViewItem item = guiAssetManager.NewListViewItem(asset.mAsset, pProperties.Status, pProperties);

                if (!string.IsNullOrEmpty(pProperties.Size))
                {
                    mSize += long.Parse(pProperties.Size);
                }

                worker.ReportProgress(i, item);
                i++;
            }
        }
        private string FormatString(guiAssetTreeTag tag, string format)
        {
            // Replace out any string options {}
            if (format.IndexOf("{projectRoot}") != -1)
            {
                format = format.Replace("{projectRoot}", MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory());
            }

            // Replace out any string options {}
            if (format.IndexOf("{projectName}") != -1)
            {
                format = format.Replace("{projectName}", MOG_ControllerProject.GetProjectName());
            }

            // Replace out any string options {}
            if (format.IndexOf("{LoginUserName}") != -1)
            {
                format = format.Replace("{LoginUserName}", MOG_ControllerProject.GetActiveUser().GetUserName());
            }

            // Replace out any string options {}
            if (format.IndexOf("{SelectedItem}") != -1)
            {
                format = format.Replace("{SelectedItem}", tag.FullFilename);
            }

            return(format);
        }
Esempio n. 3
0
        /// <summary>
        /// Try to rebuild all of our user boxes based on what's on the HDD
        /// </summary>
        /// <param name="mainForm"></param>
        static public void MOGGlobalViewRebuildInbox(MogMainForm mainForm)
        {
            if (mainForm.mAssetManager != null)
            {
                // Initialize our variables...
                string boxDirectory = mainForm.mAssetManager.mInboxAssetsDirectory;
                string userPath     = MOG_ControllerProject.GetActiveUser().GetUserPath();
                // If we have a proper boxDirectory, add a "\\" to it
                if (boxDirectory.Length > 0)
                {
                    boxDirectory += "\\";
                }

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

                // Now rebuild local window
                if (mainForm.mAssetManager.mLocal != null && MOG_ControllerProject.GetCurrentSyncDataController() != null)
                {
                    MOG_ControllerInbox.RebuildInboxView(String.Concat(MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory(), "\\MOG\\UpdatedTray"), false);
                    mainForm.mAssetManager.mLocal.RefreshWindow();
                }
            }
        }
Esempio n. 4
0
 public void InitializeUsers()
 {
     if (MOG_ControllerProject.IsUser())
     {
         // Set the current active users box
         mCurrentUsersBox = MOG_ControllerProject.GetActiveUser().GetUserName();
     }
     else
     {
         mCurrentUsersBox = "Login to project...";
     }
 }
 public void RefreshInbox()
 {
     if (!mWorkerInbox.IsBusy)
     {
         // Only do this if we have an active project and user
         if (MOG_ControllerProject.GetProject() != null &&
             MOG_ControllerProject.GetActiveUser() != null)
         {
             mAssetManager.mainForm.Cursor = Cursors.WaitCursor;
             mWorkerInbox.RunWorkerAsync("InBox");
         }
     }
 }
        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);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Update the inboxes with the new command that just came in
        /// </summary>
        /// <param name="command"></param>
        public void RefreshWindowsBoth(MOG_Command command)
        {
            MOG_Filename del = new MOG_Filename(command.GetSource());
            MOG_Filename add = new MOG_Filename(command.GetDestination());

            // We need to strip off the root folder so that we get a more accurate user path
            // Without this change, we got y:\\Projects\Users when we selected a root drive at the repository
            string userPath = MOG_ControllerProject.GetActiveUser().GetUserPath().ToLower();

            // Check if the add is within the inboxes
            if (add.IsWithinInboxes())
            {
                // Check if we are not within the path that is relevant for this user?
                if (!add.IsWithinPath(userPath))
                {
                    // Eat it
                    add.SetFilename("");
                }
            }
            // Check if this is outside our current workspace directory?
            else if (add.IsLocal())
            {
                // Check if we are not within the path that is relevant for this user?
                if (!add.IsWithinPath(MOG_ControllerProject.GetWorkspaceDirectory()))
                {
                    // Eat it
                    add.SetFilename("");
                }
            }

            // Check if the del is within the inboxes
            if (del.IsWithinInboxes())
            {
                // Check if we are not within the path that is relevant for this user?
                if (!del.IsWithinPath(userPath))
                {
                    // Eat it
                    del.SetFilename("");
                }
            }
            // Check if this is outside our current workspace directory?
            else if (del.IsLocal())
            {
                // Check if we are not within the path that is relevant for this user?
                if (!del.IsWithinPath(MOG_ControllerProject.GetWorkspaceDirectory()))
                {
                    // Eat it
                    del.SetFilename("");
                }
            }

            // Determin which one we can test for the asset type?
            MOG_Filename check = (add.GetOriginalFilename().Length != 0) ? add : del;

            switch (check.GetFilenameType())
            {
            case MOG_FILENAME_TYPE.MOG_FILENAME_Group:
            case MOG_FILENAME_TYPE.MOG_FILENAME_Asset:
            case MOG_FILENAME_TYPE.MOG_FILENAME_Link:
                if (mAssets != null)
                {
                    mAssets.RefreshBox(add, del, command);
                }
                break;
            }

            //Application.DoEvents();
        }
Esempio n. 8
0
        /// <summary>
        /// Find the correct listview for this new asset name
        /// </summary>
        /// <param name="box"></param>
        /// <param name="type"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public ListView IsolateListView(string box, MOG_FILENAME_TYPE type, string userName)
        {
            // Bail if this is an event for anothers box but not if the username is blank.  Blank user names are from our local data window
            if (MOG_ControllerProject.IsProject() &&
                MOG_ControllerProject.GetActiveUser() != null &&
                (string.Compare(userName, MOG_ControllerProject.GetActiveUser().GetUserName(), true) != 0) &&
                (userName.Length != 0))
            {
                return(null);
            }

            if (string.Compare(box, "Inbox", true) == 0)
            {
                mActiveAssetsDirectory = mInboxAssetsDirectory;
                switch (type)
                {
                case MOG_FILENAME_TYPE.MOG_FILENAME_Asset:
                case MOG_FILENAME_TYPE.MOG_FILENAME_Group:
                case MOG_FILENAME_TYPE.MOG_FILENAME_Link:
                    return(mainForm.AssetManagerInboxListView);

                default:
                    return(null);
                }
            }
            else if (string.Compare(box, "Drafts", true) == 0)
            {
                mActiveAssetsDirectory = mInboxAssetsDirectory;
                switch (type)
                {
                case MOG_FILENAME_TYPE.MOG_FILENAME_Asset:
                case MOG_FILENAME_TYPE.MOG_FILENAME_Group:
                case MOG_FILENAME_TYPE.MOG_FILENAME_Link:
                    return(mainForm.AssetManagerDraftsListView);

                default:
                    return(null);
                }
            }
            else if (string.Compare(box, "Outbox", true) == 0)
            {
                mActiveAssetsDirectory = mOutboxAssetsDirectory;
                switch (type)
                {
                case MOG_FILENAME_TYPE.MOG_FILENAME_Asset:
                case MOG_FILENAME_TYPE.MOG_FILENAME_Group:
                case MOG_FILENAME_TYPE.MOG_FILENAME_Link:
                    return(mainForm.AssetManagerSentListView);

                default:
                    return(null);
                }
            }
            else if (string.Compare(box, "Trash", true) == 0)
            {
                mActiveAssetsDirectory = "";
                switch (type)
                {
                case MOG_FILENAME_TYPE.MOG_FILENAME_Asset:
                case MOG_FILENAME_TYPE.MOG_FILENAME_Group:
                case MOG_FILENAME_TYPE.MOG_FILENAME_Link:
                    return(mainForm.AssetManagerTrashListView);

                default:
                    return(null);
                }
            }
            else if (string.Compare(box, "", true) == 0)
            {
                mActiveAssetsDirectory = "";
                switch (type)
                {
                case MOG_FILENAME_TYPE.MOG_FILENAME_Asset:                              // This is an asset in the local data area
                case MOG_FILENAME_TYPE.MOG_FILENAME_Group:
                case MOG_FILENAME_TYPE.MOG_FILENAME_Link:
                    return(this.mLocal.GetLocalWorkSpaceListView());

                default:
                    return(null);
                }
            }


            return(null);
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
0
        public ListViewItem[] RefreshUsersBox(BackgroundWorker worker, string desiredBox, string contentsFileDirectory)
        {
            MOG_Time now = new MOG_Time();

            ArrayList assets = MOG_DBInboxAPI.InboxGetAssetListWithProperties(desiredBox, MOG_ControllerProject.GetActiveUser().GetUserName(), "", "");

            ListViewItem[] items = new ListViewItem[assets.Count];

            int x = 0;

            foreach (MOG_DBInboxProperties asset in assets)
            {
                // Create the properties for this asset
                MOG_Properties pProperties = new MOG_Properties(asset.mProperties);

                string message = "Refreshing:\n" +
                                 "     " + asset.mAsset.GetAssetClassification() + "\n" +
                                 "     " + asset.mAsset.GetAssetName();
                worker.ReportProgress(x, message);

                // Update the ListViewItem
                ListViewItem item = guiAssetManager.NewListViewItem(asset.mAsset, pProperties.Status, pProperties);
                items[x++] = item;
            }

            return(items);
        }
Esempio n. 11
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);
        }