Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
0
        static public bool AddAssetToWorkspaces(MOG_Filename assetFilename, bool userInitiated, BackgroundWorker worker)
        {
            bool bFailed = false;

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

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

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

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

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

                                    // Continue on to the next asset
                                    continue;
                                }

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

            if (!bFailed)
            {
                return(true);
            }
            return(false);
        }