/// <summary>
		/// Add group or object to the database
		/// </summary>
		private bool AddGroupToDatabase(string addCandidate, MOG_Filename packageAsset)
		{
			// Are we platform generic?
			bool success = true;

			if (packageAsset.GetAssetPlatform() == "All")
			{
				string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);
				if (packageVersion.Length > 0)
				{
					success = MOG_DBPackageAPI.AddPackageGroupName(packageAsset, packageVersion, addCandidate, MOG_ControllerProject.GetUser().GetUserName());
				}
			}

			// We are platform generic, loop through all platforms then
			ArrayList platforms = MOG_ControllerProject.GetProject().GetPlatforms();
			for (int p = 0; p < platforms.Count && success; p++)
			{
				MOG_Platform platform = (MOG_Platform)platforms[p];

				// Set this package to be platform specific for this platform name
				packageAsset = MOG_Filename.CreateAssetName(packageAsset.GetAssetClassification(), platform.mPlatformName, packageAsset.GetAssetLabel());
				string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);
				if (packageVersion.Length > 0)
				{
					// Add to the database
					success &= MOG_DBPackageAPI.AddPackageGroupName(packageAsset, packageVersion, addCandidate, MOG_ControllerProject.GetUser().GetUserName());
				}
			}

			return success;
		}
Пример #2
0
 private void UpdateAssetVerifyIcon(MOG_Filename verifyFile)
 {
     if (verifyFile.GetType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
     {
         if (MOG_ControllerSystem.GetDB() != null &&
             MOG_DBAssetAPI.GetAssetVersion(verifyFile) != null &&
             MOG_DBAssetAPI.GetAssetVersion(verifyFile).Length != 0)
         {
             // This is a perfect asset that has a prior version
             this.AssetValidPictureBox.Image = new Bitmap(AssetValidImageList.Images[2]);
         }
         else
         {
             // good asset with no prior version
             this.AssetValidPictureBox.Image = new Bitmap(AssetValidImageList.Images[1]);
         }
     }
     else
     {
         // Bad Asset name
         this.AssetValidPictureBox.Image = new Bitmap(AssetValidImageList.Images[0]);
     }
 }
Пример #3
0
        /// <summary>
        /// Load a report form from a file and populate it
        /// </summary>
        /// <param name="filename"></param>
        public void LoadReportList(string filename)
        {
            MOG_Ini report = new MOG_Ini(filename);

            // Set the form title
            Text = Path.GetFileName(filename);

            if (report.SectionExist("ASSETS"))
            {
                ListListView.Items.Clear();

                ListListView.BeginUpdate();

                ProgressMax(report.CountKeys("ASSETS"));

                for (int x = 0; x < report.CountKeys("ASSETS"); x++)
                {
                    MOG_Filename mogAsset  = new MOG_Filename(report.GetKeyNameByIndexSLOW("ASSETS", x));
                    string       extraInfo = report.GetKeyByIndexSLOW("ASSETS", x);

                    MOG_Properties pProperties = new MOG_Properties(mogAsset);

                    string version        = mogAsset.GetVersionTimeStamp();
                    string currentVersion = MOG_DBAssetAPI.GetAssetVersion(mogAsset);                    //mCurrentInfo.GetString("ASSETS", mogAsset.GetAssetName());

                    MOG_Time assetTime        = new MOG_Time(version);
                    MOG_Time currentAssetTime = new MOG_Time(currentVersion);

                    ListViewItem item = new ListViewItem();

                    // We have support for the old lists as well as the new ones that have extra information stored.
                    if (string.Compare(extraInfo, "ReportList", true) != 0)
                    {
                        string [] extraItems = extraInfo.Split(",".ToCharArray());
                        foreach (string extra in extraItems)
                        {
                            if (item.Text.Length == 0)
                            {
                                item.Text = extra;
                            }
                            else
                            {
                                item.SubItems.Add(extra);
                            }
                        }

                        // Update the version
                        if (assetTime.Compare(currentAssetTime) != 0)
                        {
                            item.SubItems[FindColumn("Version")].Text      = currentAssetTime.FormatString("");
                            item.SubItems[FindColumn("Version")].ForeColor = Color.Red;
                        }
                    }
                    else
                    {
                        item = AddItemToListView(mogAsset, pProperties, MOG_ControllerRepository.GetAssetBlessedVersionPath(mogAsset, version).GetEncodedFilename());

                        // Get version
                        if (assetTime.Compare(currentAssetTime) != 0)                                                                                           // Version
                        {
                            item.SubItems[FindColumn("Version")].Text      = currentAssetTime.FormatString("");
                            item.SubItems[FindColumn("Version")].ForeColor = Color.Red;
                            version = currentVersion;
                        }
                        else
                        {
                            item.SubItems[FindColumn("Version")].Text = assetTime.FormatString("");
                        }
                    }

                    // Icon
                    item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(mogAsset.GetAssetFullName());

                    ListListView.Items.Add(item);

                    ProgressStep();
                }

                UpdateAssetTotals();
                ListListView.EndUpdate();
                ProgressReset();
            }
        }
Пример #4
0
        static protected void assetTreeViewCreate_AddVersionNodes(TreeView tree, TreeNode parent, int defaultIndex)
        {
            // Add version nodes
            TreeNode versionRoot = new TreeNode(VERSION_TOKEN, defaultIndex, 0);

            versionRoot.Tag = parent.Tag;
            parent.Nodes.Clear();

            // Date format string
            string dateFormat = MOG_Tokens.GetMonth_1() + "/" + MOG_Tokens.GetDay_1() + "/" + MOG_Tokens.GetYear_4()
                                + " " + MOG_Tokens.GetHour_1() + ":" + MOG_Tokens.GetMinute_2() + " " + MOG_Tokens.GetAMPM();

            // Create a tag for ease of use
            guiAssetTreeTag parentTag = (guiAssetTreeTag)parent.Tag;

            // Get the lastest version string
            string versionStr = MOG_DBAssetAPI.GetAssetVersion(new MOG_Filename(parentTag.FullFilename));

            // Populate HDD versions
            DirectoryInfo[] hddVersions = DosUtils.DirectoryGetList(parentTag.FullFilename, "");
            // Arrange it latest date first
            Array.Reverse(hddVersions);

            // Populate DB versions
            ArrayList dbVersions = MOG_DBAssetAPI.GetAllAssetRevisions(new MOG_Filename(parentTag.FullFilename));

            // Turn off sorting for this part of the tree
            tree.Sorted = false;
            foreach (DirectoryInfo version in hddVersions)
            {
                // Create a new versionNode
                MOG_Filename versionFile = new MOG_Filename(version.FullName);
                string       textLabel   = "<" + versionFile.GetVersionTimeStampString(dateFormat) + ">";
                TreeNode     versionNode = new TreeNode(textLabel, defaultIndex, 0);
                // Add guiAssetTreeTag and change color to indicate HDD-only status
                versionNode.Tag = new guiAssetTreeTag(version.FullName,
                                                      guiAssetTreeTag.TREE_FOCUS.VERSION, true);

                // If this is a version matched in the DB, color is black
                if (assetTreeViewCreate_IsAssetVersionInDB(dbVersions, version.Name))
                {
                    versionNode.ForeColor = Color.Black;
                }
                // Else, turn color gray
                else
                {
                    versionNode.ForeColor = Color.DarkGray;
                }

//glk:  This still needs to be tested against the case where there is no directory that matches the verion in versionStr

                // If this is the most recent asset, display it as such
                if (versionStr == versionFile.GetVersionTimeStamp())
                {
                    versionNode.ForeColor = Color.Blue;
                    // Create a currentVersion node, manually cloning versionNode
                    //  glk: object.Clone() does not function properly
                    TreeNode currentVersion = new TreeNode(textLabel,
                                                           versionNode.ImageIndex, versionNode.SelectedImageIndex);
                    currentVersion.ForeColor = Color.Blue;
                    currentVersion.Tag       = new guiAssetTreeTag(version.FullName,
                                                                   guiAssetTreeTag.TREE_FOCUS.VERSION, true);

                    // Keep tree from drawing itself for a bit
                    tree.BeginUpdate();

                    // Document the horizontal and vertical
                    //  positions of tree's scrollbar using extern functions
                    int horizPos = GetHScrollPosition(tree);
                    int vertPos  = GetVScrollPosition(tree);

                    // Expand the tree: This is the operation which causes
                    //  really erratic behavior from TreeView Control
                    currentVersion.Expand();

                    // Add ghost node for further expansion
                    currentVersion.Nodes.Add(new TreeNode(""));
                    parent.Nodes.Add(currentVersion);

                    // Set the scrollbar horizontal and vertical positions
                    //  back to what they were.
                    SetHScrollPosition(tree, horizPos);
                    SetVScrollPosition(tree, vertPos);

                    // Allow tree to draw itself
                    tree.EndUpdate();
                }
                // Add new placeholder for further expansion
                versionNode.Nodes.Add(new TreeNode(""));
                versionRoot.Nodes.Add(versionNode);
            }
            parent.Nodes.Add(versionRoot);
            // Turn sorting back on
            tree.Sorted = true;
        }
		/// <summary>
		/// Remove a Group or Package Object from the database
		/// </summary>
		/// <param name="removeCandidate">Full path of Group or Object with 
		/// '/' as delimiter, starting from package name.</param>
		/// <param name="packageAsset">The Asset that is the Package</param>
		/// <param name="platformGeneric">
		/// Whether or not this is a platform Generic operation.  
		/// 
		/// This is where the "Show Platform Specific" checkbox would 
		/// plug in from the PackageManagementTreeView
		/// </param>
		/// <returns>Bool indicating success/failure</returns>
		public bool RemoveGroupFromDatabase(string removeCandidate, MOG_Filename packageAsset)
		{
			try
			{
				bool success = true;

				// Get the current version of this package
				string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);

				// Check to see if any assets reference this
				if (MOG_DBPackageAPI.GetAllAssetsInPackageGroup(packageAsset, packageVersion, removeCandidate).Count == 0)
				{
					// If all is ok, remove it from the database
					success &= MOG_DBPackageAPI.RemovePackageGroupName(packageAsset, packageVersion, removeCandidate, MOG_ControllerProject.GetUser().GetUserName());
				}
				else
				{
					throw (new Exception("Cannot remove object or group that is used by active assets!"));
				}

				// Are we platform generic?
				if (String.Compare(packageAsset.GetAssetPlatform(), "All", true) == 0)
				{
					// We are platform generic, loop through all platforms then
					ArrayList platforms = MOG_ControllerProject.GetProject().GetPlatforms();
					for (int p = 0; p < platforms.Count; p++)
					{
						MOG_Platform platform = (MOG_Platform)platforms[p];

						// Set this package to be platform specific for this platform name
						packageAsset = MOG_Filename.CreateAssetName(packageAsset.GetAssetClassification(), platform.mPlatformName, packageAsset.GetAssetLabel());
						packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);
						if (packageVersion.Length > 0)
						{
							// Check to see if any assets reference this
							if (MOG_DBPackageAPI.GetAllAssetsInPackageGroup(packageAsset, packageVersion, removeCandidate).Count == 0)
							{
								// If all is ok, remove it from the database
								success &= MOG_DBPackageAPI.RemovePackageGroupName(packageAsset, packageVersion, removeCandidate, MOG_ControllerProject.GetUser().GetUserName());
							}
							else
							{
								throw (new Exception("Cannot remove object or group that is used by active assets!"));
							}
						}
					}
				}

				return success;
			}
			catch (Exception e)
			{
				// Get the current version of this package
				string packageVersion = MOG_DBAssetAPI.GetAssetVersion(packageAsset);

				// See if we can report to the user about why this node could not be deleted
				ArrayList assignedAssets = MOG_DBPackageAPI.GetAllAssetsInPackageGroup(packageAsset, packageVersion, removeCandidate);

				if (assignedAssets != null)
				{
					// Walk all associated assets and make a list
					string assets = "";
					foreach (MOG_Filename assetName in assignedAssets)
					{
						if (assets.Length == 0)
						{
							assets = assetName.GetEncodedFilename();
						}
						else
						{
							assets = assets + "\n" + assetName.GetEncodedFilename();
						}
					}

					// Tell the user
					MOG_Prompt.PromptMessage("Remove node", "Cannot remove this node because the following assets are assigned to it:\n\n" + assets);
				}
				else
				{
					// This must have been another problem
					MOG_Prompt.PromptMessage("Remove node", "Cannot remove this node.\nMessage\n" + e.Message);
				}
			}

			return false;
		}