public static MOG_Property RepairProperty(MOG_Property propertyObject) { MOG_Property fixedPropertyObject = null; string key = propertyObject.mKey; string section = propertyObject.mSection; string propertySection = propertyObject.mPropertySection; string propertyKey = propertyObject.mPropertyKey; string propertyValue = propertyObject.mPropertyValue; MOG_Property tempProperty = MOG_PropertyFactory.MOG_Relationships.New_RelationshipAssignment("", "", "", ""); MOG_Property tempPackageProperty = MOG_PropertyFactory.MOG_Relationships.New_PackageAssignment("", "", ""); MOG_Property tempSourceFileProperty = MOG_PropertyFactory.MOG_Relationships.New_AssetSourceFile(""); // Check if this property is a package relationship? if (string.Compare(section, tempPackageProperty.mSection, true) == 0) { string assetName = MOG_ControllerPackage.GetPackageName(propertyKey); string groups = MOG_ControllerPackage.GetPackageGroups(propertyKey); string objects = MOG_ControllerPackage.GetPackageObjects(propertyKey); // Remap various properties making sure we correct any problem areas MOG_Filename assetFilename = null; // Check if this property is a SourceFile relationship? if (string.Compare(propertySection, tempSourceFileProperty.mPropertySection, true) == 0) { // Check if the specified file is within the library? if (MOG_ControllerLibrary.IsPathWithinLibrary(propertyKey)) { // Map this library file to a real asset name assetFilename = MOG_ControllerProject.MapFilenameToLibraryAssetName(assetName, MOG_ControllerProject.GetPlatformName()); if (assetFilename != null) { fixedPropertyObject = MOG_PropertyFactory.MOG_Relationships.New_AssetSourceFile(assetFilename.GetFullFilename()); } } } else { // Try to find the assetname for the specified asset ArrayList assets = MOG_ControllerProject.MapFilenameToAssetName(assetName, MOG_ControllerProject.GetPlatformName(), MOG_ControllerProject.GetWorkspaceDirectory()); if (assets == null || assets.Count == 0) { // The package could not be found if (string.Compare(propertySection, tempPackageProperty.mPropertySection, true) == 0) { // Check if we actually had something specified? if (assetName.Length > 0) { // Set the deafult packageFilename info string assetClassification = ""; string assetPlatformName = "All"; string assetLabel = DosUtils.PathGetFileNameWithoutExtension(assetName); string syncTargetPath = DosUtils.PathGetDirectoryPath(assetName); // Check if the assetName was already a valid MOG_Filename? MOG_Filename packageFilename = new MOG_Filename(assetName); if (packageFilename.GetAssetClassification().Length > 0) { assetClassification = MOG_Filename.AppendAdamObjectNameOnClassification(packageFilename.GetAssetClassification()); } if (packageFilename.GetAssetPlatform().Length > 0) { assetPlatformName = packageFilename.GetAssetPlatform(); } if (packageFilename.GetAssetLabel().Length > 0) { assetLabel = packageFilename.GetAssetLabel(); } // Prompt user to complete the unknown information about this packageFile string message = "MOG has detected a new package assignment to a previously non-existing package. Please complete the following red fields so that a proper package can be created in MOG."; PackageCreator creator = new PackageCreator(); creator.Classification = assetClassification; creator.PackageName = assetLabel; creator.SyncTarget = syncTargetPath; creator.Platform = assetPlatformName; if (creator.ShowDialog() == DialogResult.OK) { // Use this newly created packageFilename as our assetFilename to be fixed assetFilename = creator.AssetName; } else { // The PackageName is invalid message = "New Package Not Created.\n" + "The user chose not to create a new package."; MOG_Report.ReportMessage("Package Assignment", message, Environment.StackTrace, MOG_ALERT_LEVEL.ERROR); } } else { // The PackageName is invalid string message = "Invalid PackageName specified.\n" + "The packaged asset was not assigned to a package."; MOG_Report.ReportMessage("Package Assignment", message, Environment.StackTrace, MOG_ALERT_LEVEL.ERROR); } } } else { // Always use the first one assetFilename = assets[0] as MOG_Filename; MOG_ControllerProject.MapFilenameToAssetName_WarnAboutAmbiguousMatches(assetName, assets); } // Now do we finally have a package asset name? if (assetFilename != null) { // Replace the propertyObject with the fixed up one fixedPropertyObject = MOG_PropertyFactory.MOG_Relationships.New_RelationshipAssignment(propertySection, assetFilename.GetAssetFullName(), groups, objects); } } } // Check if we fixed the property? if (fixedPropertyObject != null) { return(fixedPropertyObject); } return(propertyObject); }
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); } }
string ResolveToken(string token) { string value = ""; // Make sure this token starts with the '{'? if (token.StartsWith("{")) { // Get the name of this token string[] parts = token.Split("{}.".ToCharArray(), 3); // Make sure this resembled a real token? if (parts.Length == 3) { // Check for any contained commands? string testToken = "{" + parts[1] + "}"; // Determine which token we have? switch (testToken) { // Repository Tokens case TOKEN_Repository_Path: value = MOG_ControllerSystem.GetSystemRepositoryPath(); break; case TOKEN_Repository_ProjectsPath: value = MOG_ControllerSystem.GetSystemProjectsPath(); break; case TOKEN_Repository_ToolsPath: value = MOG_ControllerSystem.GetSystemRepositoryPath() + "\\Tools"; break; case TOKEN_Repository_Project_Path: value = MOG_ControllerProject.GetProjectPath(); break; case TOKEN_Repository_Project_ToolsPath: value = MOG_ControllerProject.GetProjectPath() + "\\Tools"; break; case TOKEN_Repository_Project_AssetsPath: value = MOG_ControllerRepository.GetRepositoryPath(); break; case TOKEN_Repository_Project_ArchivePath: value = MOG_ControllerRepository.GetArchivePath(); break; case TOKEN_Repository_Project_UsersPath: value = MOG_ControllerProject.GetProjectPath() + "\\Users"; break; // Project Tokens case TOKEN_Project_Name: value = MOG_ControllerProject.GetProjectName(); break; case TOKEN_Project_BranchName: value = MOG_ControllerProject.GetBranchName(); break; case TOKEN_Project_UserName: value = MOG_ControllerProject.GetUserName_DefaultAdmin(); break; case TOKEN_Project_PlatformName: value = MOG_ControllerProject.GetPlatformName(); break; case TOKEN_Project_WorkspaceDirectory: value = MOG_ControllerProject.GetWorkspaceDirectory(); break; // Ripper Tokens case TOKEN_Ripper_SourcePath: value = mRipperSourcePath; break; case TOKEN_Ripper_SourceFilePattern: value = mRipperSourceFilePattern; break; case TOKEN_Ripper_DestinationPath: value = mRipperDestinationPath; break; // Package Tokens case TOKEN_Package_WorkspaceDirectory: if (mPackageFileInfo != null) { value = mPackageFileInfo.mPackageWorkspaceDirectory; } break; case TOKEN_Package_DataDirectory: if (mPackageFileInfo != null) { value = mPackageFileInfo.mPackageDataDirectory; } break; case TOKEN_Package_PackageFile_Filename: if (mPackageFileInfo != null) { value = mPackageFileInfo.mPackageFile; } break; case TOKEN_Package_PackageFile_FullName: { MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment)); value = packageFilename.GetAssetFullName(); } break; case TOKEN_Package_PackageFile_Classification: { MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment)); value = packageFilename.GetAssetClassification(); } break; case TOKEN_Package_PackageFile_Label: { MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment)); value = packageFilename.GetAssetLabel(); } break; case TOKEN_Package_PackageFile_Platform: { MOG_Filename packageFilename = (mPackageFileInfo != null) ? mPackageFileInfo.mPackageAssetFilename : new MOG_Filename(MOG_ControllerPackage.GetPackageName(mPackageAssignment)); value = packageFilename.GetAssetPlatform(); } break; case TOKEN_Package_PackageFile_Group: value = MOG_ControllerPackage.GetPackageGroups(mPackageAssignment); break; case TOKEN_Package_PackageFile_Object: value = MOG_ControllerPackage.GetPackageObjects(mPackageAssignment); break; // Inbox Tokens case TOKEN_Inbox_UserName: value = mAssetFilename.GetUserName(); break; case TOKEN_Inbox_UserPath: value = mAssetFilename.GetUserPath(); break; case TOKEN_Inbox_BoxName: value = mAssetFilename.GetBoxName(); break; case TOKEN_Inbox_BoxPath: value = mAssetFilename.GetBoxPath(); break; // Asset Tokens case TOKEN_Asset_AssetName_Path: value = mAssetFilename.GetPath(); break; case TOKEN_Asset_AssetName_FullName: value = mAssetFilename.GetAssetFullName(); break; case TOKEN_Asset_AssetName_Classification: value = mAssetFilename.GetAssetClassification(); break; case TOKEN_Asset_AssetName_Name: value = mAssetFilename.GetAssetName(); break; case TOKEN_Asset_AssetName_PlatformName: value = mAssetFilename.GetAssetPlatform(); break; case TOKEN_Asset_AssetName_Label: value = mAssetFilename.GetAssetLabel(); break; case TOKEN_Asset_ImportedFile: case TOKEN_Asset_RippedFile: value = ResolveToken_AssetFile(token); break; case TOKEN_Asset_Property: value = ResolveToken_Property(token); break; case TOKEN_Asset_ClassificationPath: value = MOG_Filename.GetClassificationPath(mAssetFilename.GetAssetClassification()); break; case TOKEN_Asset_VersionTimeStamp: value = mAssetFilename.GetVersionTimeStamp(); break; } // Check if we have a command? if (parts[2] != ".") { } } } return(value); }
private static void ImportPrevious_Worker(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; List <object> args = e.Argument as List <object>; bool looseMatching = (bool)args[0]; string[] sourceFullNames = (args[1]) as string[]; //string[] sourceFullNames = e.Argument as string[]; mInvalidAssetNames.Clear(); mNewAssetNames.Clear(); mNewAssetProperties.Clear(); // Check if asset has been previously imported into the system for (int i = 0; i < sourceFullNames.Length && !worker.CancellationPending; i++) { string sourceFullName = sourceFullNames[i]; ArrayList previousSourceFiles = new ArrayList(); string message = "Importing:\n" + " " + Path.GetDirectoryName(sourceFullName) + "\n" + " " + Path.GetFileName(sourceFullName); worker.ReportProgress(i * 100 / sourceFullNames.Length, message); // Check if this is a directory? if (DosUtils.DirectoryExistFast(sourceFullName)) { // Obtain the list of contained files ArrayList containedFiles = DosUtils.FileGetRecursiveList(sourceFullName, "*.*"); if (containedFiles != null) { // Map these filenames to all the possible assetnames previousSourceFiles = MOG_ControllerProject.MapFilenamesToAssetNames(containedFiles, MOG_ControllerProject.GetPlatformName(), null); } } else { // Map this filename to all possible assetnames previousSourceFiles = MOG_ControllerProject.MapFilenameToAssetName(sourceFullName, MOG_ControllerProject.GetPlatformName(), MOG_ControllerProject.GetWorkspaceDirectory()); } // Are we loose matching? if (looseMatching) { // Did we get back only 2 files if (previousSourceFiles.Count == 2) { // Is the second one a blank? MOG_Filename file = previousSourceFiles[1] as MOG_Filename; if (file.GetFullFilename().Length == 0) { // Then remove it! previousSourceFiles.RemoveAt(1); } } } if (previousSourceFiles.Count == 1) { MOG_Filename previousFile = previousSourceFiles[0] as MOG_Filename; if (MogMainForm.MainApp.AssetManagerAutoImportCheckBox.Checked) { // Create the correct controller MOG_ControllerAsset.CreateAsset(sourceFullName, previousFile.GetEncodedFilename(), false); } else { // Create a new invalid name ImportFile invalidName = new ImportFile(sourceFullName); // Add all possible matches to this name foreach (MOG_Filename potentialMatch in previousSourceFiles) { // Make sure we have a valid match? if (potentialMatch != null && potentialMatch.GetOriginalFilename().Length > 0) { invalidName.mPotentialFileMatches.Add(potentialMatch); } } // Add to our invalidNames array mInvalidAssetNames.Add(invalidName); } } else { // Create a new invalid name ImportFile invalidName = new ImportFile(sourceFullName); // Add all possible matches to this name foreach (MOG_Filename potentialMatch in previousSourceFiles) { // Make sure we have a valid match? if (potentialMatch != null && potentialMatch.GetOriginalFilename().Length > 0) { invalidName.mPotentialFileMatches.Add(potentialMatch); } } // Add to our invalidNames array mInvalidAssetNames.Add(invalidName); } } }