/// <summary> /// Write out our changes back to the TaskInfo /// </summary> public void FinializeTaskInfo() { mTaskInfo.SetName(this.TaskName); mTaskInfo.SetPriority(this.TaskPriority); mTaskInfo.SetAssignedTo(this.TaskAssignedTo); mTaskInfo.SetPercentComplete(this.TaskPercentage); mTaskInfo.SetComment(this.TaskComments); mTaskInfo.SetDueDate(MOG_Time.GetVersionTimestamp()); }
private string GetLocalFileTimestamp(string localFile) { string localTimeStamp = ""; FileInfo fileInfo = new FileInfo(localFile); if (fileInfo != null && fileInfo.Exists) { localTimeStamp = MOG_Time.FormatTimestamp(MOG_Time.GetVersionTimestamp(fileInfo.LastWriteTime), ""); } return(localTimeStamp); }
private void UpdateItem(ListViewItem item) { string status = ""; string username = ""; string comment = ""; string localTimestamp = ""; // Find our desired columns int statusIdx = FindColumn("Status"); int userIdx = FindColumn("User"); int commentIdx = FindColumn("Comment"); int localTimestampIdx = FindColumn("Local Timestamp"); int serverTimestampIdx = FindColumn("Server Timestamp"); int localFileIdx = FindColumn("LocalFile"); int repositoryFileIdx = FindColumn("RepositoryFile"); string repositoryFile = item.SubItems[repositoryFileIdx].Text; MOG_Filename repositoryAssetFilename = new MOG_Filename(repositoryFile); // Check if this file exist locally? string localFile = item.SubItems[localFileIdx].Text; if (localFile.Length != 0) { // Obtain the localFile info FileInfo fileInfo = new FileInfo(localFile); // Does this local file exist? if (fileInfo != null && fileInfo.Exists) { // Compare our local file's timestamp to the server's revision localTimestamp = MOG_Time.GetVersionTimestamp(fileInfo.LastWriteTime); if (localTimestamp == repositoryAssetFilename.GetVersionTimeStamp()) { // Indicate this item is synced and up-to-date status = "Up-to-date"; } else { // Indicate this item is synced status = "Out-of-date"; } } else { // Indicate this item is not synced status = "unSynced"; } } else { // Indicate this item is not synced status = "unSynced"; } // Check if this file exists in the repository? if (repositoryFile.Length != 0) { // Check the lock statusIdx of the asset MOG_Command sourceLock = MOG_ControllerProject.PersistentLock_Query(repositoryAssetFilename.GetAssetFullName()); if (sourceLock.IsCompleted() && sourceLock.GetCommand() != null) { MOG_Command lockHolder = sourceLock.GetCommand(); // Obtain the lock info item.ImageIndex = MogUtil_AssetIcons.GetLockedBinaryIcon(repositoryFile); username = lockHolder.GetUserName(); comment = lockHolder.GetDescription(); // Check if this is locked by me? if (username == MOG_ControllerProject.GetUserName()) { status = "CheckedOut"; } else { status = "Locked"; } } else { // Update this file's icon item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(repositoryFile); } } // Update the item with the new information item.SubItems[statusIdx].Text = status; item.SubItems[userIdx].Text = username; item.SubItems[commentIdx].Text = comment; item.SubItems[localTimestampIdx].Text = MogUtils_StringVersion.VersionToString(localTimestamp); item.SubItems[serverTimestampIdx].Text = MogUtils_StringVersion.VersionToString(repositoryAssetFilename.GetVersionTimeStamp()); // Update the color for this locked item UpdateListViewItemColors(item, status); }
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); } }
private string GetAutoVersion() { return(MOG_Time.GetVersionTimestamp()); }
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); }
private void btnCreate_Click(object sender, EventArgs e) { if (IsInformationValid()) { string[] platforms = Platform.Split(",".ToCharArray()); // Make sure there was something specified before we do anything if (platforms.Length > 0) { bool bPromptUser = true; bool bCreatePackage = true; bool bRebuildPackage = false; foreach (string platform in platforms) { // Create the new package name MOG_Filename assetName = MOG_Filename.CreateAssetName(Classification, platform.Trim(), PackageName); // Check if we should prompt the user? if (bPromptUser) { // Don't bother the user again bPromptUser = false; // Check if this was a platform specific package? if (assetName.IsPlatformSpecific()) { // Check if there are ANY assiciated assets with this new platform-specific package? if (MOG_ControllerPackage.GetAssociatedAssetsForPackage(assetName).Count > 0) { // Prompt the user if they wish to automatically populate this new platform-specific packages? string message = "Whenever new platform-specific packages are created, they sometimes need to be populated if existing package assignments exist.\n\n" + "MOG has detected this to be the case and recommends you to automatically populated this package."; MOGPromptResult result = MOG_Prompt.PromptResponse("Automatically populate this new platform-specific package?", message, MOGPromptButtons.YesNo); switch (result) { case MOGPromptResult.Yes: bCreatePackage = true; bRebuildPackage = true; break; case MOGPromptResult.No: bCreatePackage = true; bRebuildPackage = false; break; case MOGPromptResult.Cancel: bCreatePackage = false; bRebuildPackage = false; break; } } } } // Check if we should create the package? if (bCreatePackage) { MOG_Filename newPackage = MOG_ControllerProject.CreatePackage(assetName, SyncTarget); if (newPackage != null) { // Post the new package into the project mAssetName = newPackage; string jobLabel = "NewPackageCreated." + MOG_ControllerSystem.GetComputerName() + "." + MOG_Time.GetVersionTimestamp(); MOG_ControllerProject.PostAssets(MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName(), jobLabel); // Check if we should rebuild the package? if (bRebuildPackage) { jobLabel = "PopulateNewPackage." + MOG_ControllerSystem.GetComputerName() + "." + MOG_Time.GetVersionTimestamp(); // Schedule the rebuild command MOG_ControllerPackage.RebuildPackage(assetName, jobLabel); // Start the job MOG_ControllerProject.StartJob(jobLabel); } // Well, this is a bit of a hack but was the easiest and safest way to ensure unique JobIDs... // JobIDs are only accurate to the microsecond so lets sleep for a very short time. Thread.Sleep(10); // Setting the dialog's result will automatically close the dialog since we proceeded to create the package DialogResult = DialogResult.OK; } } } } } }
/// <summary> /// Open an explorer window in the target of the selected asset(s) /// </summary> /// <param name="sender"> Must be a ListView and have a string[] in its Tag describing the columns</param> /// <param name="e"></param> private void RemoveMenuItem_Click(object sender, System.EventArgs e) { ArrayList selectedItems = ControlGetSelectedItems(); string message = ""; foreach (guiAssetTreeTag tag in selectedItems) { if (tag.Execute) { message = message + tag.FullFilename + "\n"; } } if (MOG_Prompt.PromptResponse("Are you sure you want to remove all of these assets from the project?", message, MOGPromptButtons.OKCancel) == MOGPromptResult.OK) { // Obtain a unique bless label string jobLabel = "RemoveAsset." + MOG_ControllerSystem.GetComputerName() + "." + MOG_Time.GetVersionTimestamp(); foreach (guiAssetTreeTag tag in selectedItems) { if (tag.Execute) { MOG_Filename filename = new MOG_Filename(tag.FullFilename); // Make sure we are an asset before showing log if (filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset) { if (guiAssetController.RemoveBlessed(filename, jobLabel)) { tag.ItemRemove(); } } } } // Start the job MOG_ControllerProject.StartJob(jobLabel); } }
/// <summary> /// Create Package for each platform in this Project /// </summary> private MOG_Filename CreatePackageForPlatform(NodeLabelEditEventArgs e, MOG_Filename packageName, TreeNode parent) { // Initialize our ArrayList for MOG_Property objects ArrayList targetSyncPath = null; // If our node name already exists, return... if (!ValidateNewNodeName(e, packageName)) { return null; } // If our targetSyncPath is null, even after we try to get a valid one, return... if (targetSyncPath == null && (targetSyncPath = GetValidTargetSyncPath(e, packageName)) == null) { return null; } MOG_Property syncTargetPathProperty = targetSyncPath[0] as MOG_Property; // Create the new package MOG_Filename createdPackageFilename = MOG_ControllerProject.CreatePackage(packageName, syncTargetPathProperty.mValue); if (createdPackageFilename == null) { return null; } RenameNode(e, createdPackageFilename); // Post the projects new assets string jobLabel = "NewPackageCreated." + MOG_ControllerSystem.GetComputerName() + "." + MOG_Time.GetVersionTimestamp(); MOG_ControllerProject.PostAssets(MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName(), jobLabel); // Return our created package return createdPackageFilename; }
/// <summary> /// Handle new date pick in dataTime picker /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TaskDueDateTimePicker_ValueChanged(object sender, System.EventArgs e) { DateTimePicker item = (DateTimePicker)sender; mTaskInfo.SetDueDate(MOG_Time.GetVersionTimestamp()); }