Пример #1
0
        public void BuildMerge(bool ShowSyncWindow, bool silent, string tag, string filter, bool updateModifiedMissing, bool cleanUnknownFiles)
        {
            //get the sync data controller
            MOG_ControllerSyncData gameDataHandle = MOG_ControllerProject.GetCurrentSyncDataController();

            //if we don't have one infom the user that we need one
            if (gameDataHandle == null)
            {
                MOG_Prompt.PromptMessage("Update Build", "Cannot update a build without a valid local Workspace and Workspace tab created.  Create a local Workspace first then try again.", Environment.StackTrace);
                return;
            }

            SyncLatestForm update = new SyncLatestForm(mainForm, mainForm.mAdministratorMode, tag, filter, mDefaultUpdateBuildType, gameDataHandle.GetSyncDirectory(), mCurrentVersion, mHidePlatforms, updateModifiedMissing, cleanUnknownFiles);

            try
            {
                //if we are expected to show the SyncWindow
                if (ShowSyncWindow)
                {
                    if (update.ShowDialog(mainForm) == DialogResult.OK)
                    {
                        // Make sure we update our local variables that could get changed within the dialog
                        tag = update.SyncTag;
                        updateModifiedMissing = update.UpdateBuildCheckMissingCheckBox.Checked;
                        cleanUnknownFiles     = update.UpdateBuildCleanUnknownFilesCheckBox.Checked;
                    }
                    else
                    {
                        //the result is not ok, so do not proceed with the sync
                        return;
                    }
                }

                //get the sync directory from the SyncDataController
                string targetProjectPath = gameDataHandle.GetSyncDirectory();

                // Get the current SyncData controller
                MOG_ControllerSyncData sync = MOG_ControllerProject.GetCurrentSyncDataController();
                if (sync != null)
                {
                    // Check if the user has specified a cleaning?
                    if (cleanUnknownFiles)
                    {
                        // Check if we need to clean the workspace?
                        string startingPath = sync.GetSyncDirectory();
                        try
                        {
                            MogUtil_WorkspaceCleaner cleaner = new MogUtil_WorkspaceCleaner();
                            cleaner.Clean(startingPath);
                        }
                        catch (Exception ex)
                        {
                            MOG_Prompt.PromptMessage("Clean", "The cleaner exited with the following error (" + ex.Message + ")");
                        }
                    }

                    // Attempt to use the dialog's MOG_LocalSyncInfo
                    MOG_LocalSyncInfo localSyncInfo = update.mLocalSyncInfo;
                    if (localSyncInfo == null)
                    {
                        // Looks like we need to build our own MOG_LocalSyncInfo
                        string computerName   = MOG_ControllerSystem.GetComputerName();
                        string projectName    = MOG_ControllerProject.GetProjectName();
                        string platformName   = MOG_ControllerProject.GetPlatformName();
                        string syncDirectory  = MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory();
                        string userName       = MOG_ControllerProject.GetUserName();
                        string classification = MOG_ControllerProject.GetProjectName();
                        localSyncInfo = new MOG_LocalSyncInfo(computerName, projectName, platformName, syncDirectory, tag, userName, classification, "");
                    }

                    // Check if we want to update missing
                    sync.SyncRepositoryData(MOG_ControllerProject.GetProjectName(), update.Exclusions, update.Inclusions, updateModifiedMissing, localSyncInfo);

                    // Show the summary file
                    SyncLatestSummaryForm summary = new SyncLatestSummaryForm(sync.GetSyncLog());
                    if (silent)
                    {
                        summary.Show(mainForm);
                    }
                    else
                    {
                        summary.ShowDialog(mainForm);
                    }
                }

                guiUserPrefs.SaveDynamic_LayoutPrefs("AssetManager", mainForm);

                update.Dispose();
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("Update", "Could not perform update due to error:\n\n" + e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR);
            }
        }
Пример #2
0
        /// <summary>
        /// Create a virtual node of directories only based on its fullpath
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="parent"></param>
        /// <param name="controller"></param>
        /// <param name="delimiter"></param>
        /// <param name="fullPath"></param>
        /// <param name="verifyFilename"></param>
        /// <param name="VirtualImageIndex"></param>
        /// <param name="NonVirtualImageIndex"></param>
        /// <param name="VirtualFileImageIndex"></param>
        /// <param name="NonVirtualFileImageIndex"></param>
        /// <returns></returns>
        private TreeNode CreateTreeNodeFullPath(TreeView tree, TreeNode parent, MOG_ControllerSyncData controller, string delimiter, string fullPath, string verifyFilename, DirectorySetInfo fileInfo,
                                                int VirtualImageIndex, int NonVirtualImageIndex, int VirtualFileImageIndex, int NonVirtualFileImageIndex, bool directoriesOnly)
        {
            TreeNodeCollection topNodes = null;

            // Get our collections to search
            if (parent != null)
            {
                topNodes = parent.Nodes;
            }
            else
            {
                topNodes = tree.Nodes;
            }

            // Split the full path by the delimiter passed in
            string[] lastNodeParts = fullPath.Split(delimiter.ToCharArray());

            // find the first name
            TreeNode alreadyExistNode = null;

            if (parent != null && string.Compare(parent.Text, lastNodeParts[0], true) == 0)
            {
                alreadyExistNode = parent;
            }
            else
            {
                alreadyExistNode = FindTreeNode(topNodes, lastNodeParts[0]);
            }

            // if exist find then next from the children of the first
            if (alreadyExistNode != null)
            {
                // Is this a file or directory
                if (fileInfo.Type == DirectorySetInfo.TYPE.Folder || fileInfo.Type == DirectorySetInfo.TYPE.FolderName)
                {
                    // Must be a directory
                    if (Directory.Exists(verifyFilename))
                    {
                        alreadyExistNode.ImageIndex         = NonVirtualImageIndex;
                        alreadyExistNode.SelectedImageIndex = NonVirtualImageIndex;
                        alreadyExistNode.ForeColor          = SystemColors.ControlText;
                    }
                    else
                    {
                        alreadyExistNode.ImageIndex         = VirtualImageIndex;
                        alreadyExistNode.SelectedImageIndex = VirtualImageIndex;
                        alreadyExistNode.ForeColor          = SystemColors.GrayText;
                    }
                }
                else
                {
                    // Must be a file
                    if (File.Exists(verifyFilename))
                    {
                        alreadyExistNode.ImageIndex         = NonVirtualFileImageIndex;
                        alreadyExistNode.SelectedImageIndex = NonVirtualFileImageIndex;
                        alreadyExistNode.ForeColor          = SystemColors.ControlText;
                    }
                    else
                    {
                        alreadyExistNode.ImageIndex         = VirtualFileImageIndex;
                        alreadyExistNode.SelectedImageIndex = VirtualFileImageIndex;
                        alreadyExistNode.ForeColor          = SystemColors.GrayText;
                    }
                }

                string LastNodePath = "";
                // Update our path to be less than what it was
                for (int i = 1; i < lastNodeParts.Length; i++)
                {
                    if (LastNodePath.Length == 0)
                    {
                        LastNodePath = lastNodeParts[i];
                    }
                    else
                    {
                        LastNodePath = LastNodePath + "\\" + lastNodeParts[i];
                    }
                }

                if (LastNodePath.Length > 0)
                {
                    // recurse into this function for the next node
                    parent = CreateTreeNodeFullPath(tree, alreadyExistNode, controller, delimiter, LastNodePath, verifyFilename, fileInfo, VirtualImageIndex, NonVirtualImageIndex, VirtualFileImageIndex, NonVirtualFileImageIndex, directoriesOnly);
                }
            }
            // if not, create it and all its children right here
            else
            {
                foreach (string nodeLeafName in lastNodeParts)
                {
                    if (nodeLeafName.Length > 0)
                    {
                        // If we are a file and this is a directoriesOnly create, skip
                        if (fileInfo.Type == DirectorySetInfo.TYPE.File && directoriesOnly)
                        {
                            break;
                        }

                        // Create a node
                        TreeNode        newChild = new TreeNode(nodeLeafName);
                        guiAssetTreeTag info     = new guiAssetTreeTag(verifyFilename, newChild, controller, true);

                        // Is this a file or directory
                        if (fileInfo.Type == DirectorySetInfo.TYPE.Folder || fileInfo.Type == DirectorySetInfo.TYPE.FolderName)
                        {
                            // Set our type
                            info.TagType = guiAssetTreeTag.TREE_FOCUS.FOLDER;

                            // Must be a directory
                            if (Directory.Exists(verifyFilename))
                            {
                                newChild.ImageIndex         = NonVirtualImageIndex;
                                newChild.SelectedImageIndex = NonVirtualImageIndex;
                                newChild.ForeColor          = SystemColors.ControlText;
                            }
                            else
                            {
                                newChild.ImageIndex         = VirtualImageIndex;
                                newChild.SelectedImageIndex = VirtualImageIndex;
                                newChild.ForeColor          = SystemColors.GrayText;
                            }
                        }
                        else
                        {
                            // Set our type
                            info.TagType = guiAssetTreeTag.TREE_FOCUS.FILE;

                            // Must be a file
                            if (File.Exists(verifyFilename))
                            {
                                newChild.ImageIndex         = NonVirtualFileImageIndex;
                                newChild.SelectedImageIndex = NonVirtualFileImageIndex;
                                newChild.ForeColor          = SystemColors.ControlText;
                            }
                            else
                            {
                                newChild.ImageIndex         = VirtualFileImageIndex;
                                newChild.SelectedImageIndex = VirtualFileImageIndex;
                                newChild.ForeColor          = SystemColors.GrayText;
                            }
                        }

                        if (parent != null)
                        {
                            parent.Nodes.Add(newChild);
                            parent = newChild;
                        }
                        else
                        {
                            int index = tree.Nodes.Add(newChild);
                            parent = tree.Nodes[index];
                        }

                        newChild.Tag = info;
                    }
                }

                // If we are a file and this is a directoriesOnly create, skip
                if (fileInfo.Type == DirectorySetInfo.TYPE.File && directoriesOnly)
                {
                    return(null);
                }
                return(parent);
            }

            return(null);
        }
Пример #3
0
        /// <summary>
        /// Fetch the next set of files and folders for this parent folder
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="fullPath"></param>
        /// <param name="targetGameData"></param>
        private void VirtualExpand(TreeNode parent, string fullPath, MOG_ControllerSyncData targetGameData)
        {
            try
            {
                // If we have a gameData target we need to remove it from our path prepatory to the Dictionary lookup of the children of this folder
                if (targetGameData != null)
                {
                    // Also remove any begininng backslashes
                    fullPath = fullPath.Replace(targetGameData.GetSyncDirectory(), "").TrimStart("\\".ToCharArray());
                }

                // Search our btree for the children of this folder
                IDictionaryEnumerator file = this.mSyncTargetFiles.GetFiles(fullPath).GetEnumerator();

                // Now itterate through those children
                while (file.MoveNext())
                {
                    string fullDirectoryName = "";
                    // we now need to reconstruct the full path to this file or folder
                    if (fullPath.Length == 0)
                    {
                        fullDirectoryName = targetGameData.GetSyncDirectory() + "\\" + file.Key as string;
                    }
                    else
                    {
                        fullDirectoryName = targetGameData.GetSyncDirectory() + "\\" + fullPath + "\\" + file.Key as string;
                    }

                    DirectorySetInfo fileInfo = (DirectorySetInfo)file.Value;

                    // Create the node
                    TreeNode newNode = CreateTreeNodeFullPath(GameDataTreeView, parent, targetGameData, "\\", file.Key as string, fullDirectoryName, fileInfo, 0, 0, 0, 0, true);

                    // If this is a newly created node and it is a folder, we assume it has children and create a black node beneath it
                    if (newNode != null && newNode.Nodes.Count == 0)
                    {
                        guiAssetTreeTag info           = (guiAssetTreeTag)newNode.Tag;
                        string          relationalPath = "";

                        // Get a relational path to this folder
                        if (fullPath.Length == 0)
                        {
                            relationalPath = file.Key as string;
                        }
                        else
                        {
                            relationalPath = fullPath + "\\" + file.Key as string;
                        }

                        // If this file is a folder and has children, create a place holder 'blank'
                        if (info != null && info.TagType == guiAssetTreeTag.TREE_FOCUS.FOLDER && mSyncTargetFiles.HasFolderChildren(relationalPath, false))
                        {
                            newNode.Nodes.Add("BLANK");
                        }
                    }
                }
            }
            catch
            {
            }
        }
Пример #4
0
 static public bool RemoveWorkspace(MOG_ControllerSyncData workspace)
 {
     return(RemoveWorkspace(workspace.GetSyncDirectory()));
 }
        /// <summary>
        /// Create a Directory TreeNode checking to see if this directory is a MOG sync target
        /// </summary>
        /// <param name="fullname"></param>
        /// <returns></returns>
        private TreeNode CreateDirectoryNode(string fullname, MOG_ControllerSyncData targetGameData)
        {
            string name = fullname;

            try
            {
                name = Path.GetFileName(fullname);
            }
            catch
            {
            }
            //Check active user for null/empty string and default to Admin if that is the case.
            string userName = MOG_ControllerProject.GetUserName_DefaultAdmin();

            TreeNode directory = new TreeNode(name);

            directory.Tag = new guiAssetTreeTag(fullname, directory);

            // This is a virtual directory
            if (targetGameData != null)
            {
                directory.ImageIndex         = 5;
                directory.SelectedImageIndex = 5;
                directory.Tag = new guiAssetTreeTag(fullname, directory, targetGameData);
            }
            else
            {
                // Is this a MOG controlled directory - Always remove ' characters when talking to the database?
                if (MOG.DATABASE.MOG_DBSyncedDataAPI.DoesSyncedLocationExist(MOG_ControllerSystem.GetComputerName(), null, null, fullname.Replace("'", ""), userName))
                {
                    ArrayList gameDataArray = MOG.DATABASE.MOG_DBSyncedDataAPI.GetAllSyncedLocations(MOG_ControllerSystem.GetComputerName(), fullname.Replace("'", ""), userName);

                    if (gameDataArray.Count == 1)
                    {
                        MOG_DBSyncedLocationInfo dbLocation = (MOG_DBSyncedLocationInfo)gameDataArray[0];
                        MOG_ControllerSyncData   gameData   = new MOG_ControllerSyncData(dbLocation.mWorkingDirectory, dbLocation.mProjectName, dbLocation.mBranchName, dbLocation.mPlatformName, userName);
                        directory.Tag = new guiAssetTreeTag(fullname, directory, gameData);
                    }
                    else if (gameDataArray.Count > 1)
                    {
                        MOG_Report.ReportMessage("Create Mog Aware directory", "Got back too many gameDataControllers for this directory!\n\nDIRECTORY: " + fullname + "\n\nTaking first one...", Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
                        MOG_DBSyncedLocationInfo dbLocation = (MOG_DBSyncedLocationInfo)gameDataArray[0];
                        MOG_ControllerSyncData   gameData   = new MOG_ControllerSyncData(dbLocation.mWorkingDirectory, dbLocation.mProjectName, dbLocation.mBranchName, dbLocation.mPlatformName, userName);
                        directory.Tag = new guiAssetTreeTag(fullname, directory, gameData);
                    }
                    else if (gameDataArray.Count == 0)
                    {
                        MOG_Report.ReportMessage("Create Mog Aware directory", "Got back zero gameDataControllers for this directory!\n\nDIRECTORY: " + fullname, Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
                        return(directory);
                    }

                    directory.ImageIndex         = 4;
                    directory.SelectedImageIndex = 4;
                }
                else
                {
                    directory.ImageIndex         = 3;
                    directory.SelectedImageIndex = 3;
                }
            }

            return(directory);
        }
        /// <summary>
        /// Fill the current parent node with all the files and directories found in the directory name provided
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="directoryName"></param>
        private void FillDirectory(TreeNode parent, string directoryName, MOG_ControllerSyncData targetGameData)
        {
            // Clear out our temp child
            if (parent != null && (parent.Nodes.Count == 1 && parent.Nodes[0].Text == "BLANK"))
            {
                parent.Nodes.Clear();
            }

            try
            {
                // Get a valid direcotry
                DirectoryInfo dir = new DirectoryInfo(directoryName);

                // Make sure it exits
                if (!dir.Exists)
//				if (!dir.Exists || dir.GetDirectories().Length < GetAllProjectSyncTargetFileForDirectory(targetGameData, directoryName).Count)
//				{
//					// Maybe its a virtual drive
//					if (targetGameData != null)
//					{
//						// Get virtual directories
//						ArrayList virtualDirectories = GetAllProjectSyncTargetFileForDirectory(targetGameData, directoryName);
//
//						// Add each found directory to the tree
//						foreach(string virtualDirectory in virtualDirectories)
//						{
//							// Create the node
//							TreeNode child = CreateDirectoryNode(virtualDirectory, targetGameData);
//
//							// Check if the child has children
//							//						if (di.GetDirectories().Length != 0 || (di.GetFiles().Length != 0 && MOGShowFiles))
//						{
//							// If so, add a temp child
//							child.Nodes.Add("BLANK");
//						}
//
//							// If we have a parent add this child
//							if (parent != null)
//							{
//								parent.Nodes.Add(child);
//							}
//							else
//							{
//								// Else add it to the master tree
//								GameDataTreeView.Nodes.Add(child);
//							}
//						}
//					}
//					else
                {
                    throw new DirectoryNotFoundException("directory does not exist:" + directoryName);
                }
//				}

                // Add each found directory to the tree
                foreach (DirectoryInfo di in dir.GetDirectories())
                {
                    // Create the node
                    TreeNode child = CreateDirectoryNode(di.FullName, null);

                    // Check if the child has children
                    if (di.GetDirectories().Length != 0 || (di.GetFiles().Length != 0 && MOGShowFiles))
                    {
                        // If so, add a temp child
                        child.Nodes.Add("BLANK");
                    }

                    // If we have a parent add this child
                    if (parent != null)
                    {
                        parent.Nodes.Add(child);
                    }
                    else
                    {
                        // Else add it to the master tree
                        GameDataTreeView.Nodes.Add(child);
                    }
                }

                // Now get the files
                if (MOGShowFiles)
                {
                    foreach (FileInfo fi in dir.GetFiles())
                    {
                        TreeNode child = new TreeNode(fi.Name, mWindowsExplorerIcons.AddFileIcon(fi.FullName), mWindowsExplorerIcons.AddFileIcon(fi.FullName));
                        child.Tag = new guiAssetTreeTag(fi.FullName, child);

                        // If we have a parent add this child
                        if (parent != null)
                        {
                            parent.Nodes.Add(child);
                        }
                        else
                        {
                            // Else add it to the master tree
                            GameDataTreeView.Nodes.Add(child);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }