Example #1
0
        /// <summary>
        /// Find a list view item withtin a list view bt full name
        /// </summary>
        /// <param name="name"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public int ListViewItemFindFullItem(MOG_Filename filename, ListView list)
        {
            // I really don't like this solution...but, we need to be able to find the index in the list,
            // In the future, I think we need to handle new unrecorded classifications differently.

            // Attempt to obtain the index of this item in the list
            int index = ListViewItemFindFullItem(filename.GetEncodedFilename(), list);

            if (index == -1)
            {
                // We should look one more time for the full name anytime we fail
                index = ListViewItemFindFullItem(filename.GetFullFilename(), list);
            }

            return(index);
        }
Example #2
0
        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 RefreshInbox(MOG_Command asset, MOG_Filename source, MOG_Filename destination)
        {
            // Skip this if we don't have an active project
            if (!mParent.mMog.IsProject())
            {
                return;
            }

            // Check for remove
            if (destination.GetFullFilename().Length == 0)
            {
                // We are removing
                int index = mParent.ListViewItemFindItem(source.GetFilename(), mParent.mainForm.AssetManagerInboxMessagesListViewFilter);
                if (index != -1)
                {
                    // Remove it from our list
                    mParent.mainForm.AssetManagerInboxAssetListView.Items[index].Remove();
                }
            }            // Check for new message
            else if (source.GetFullFilename().Length == 0)
            {
                // We are importing
                MOG_Controller assetController = MOG_Controller.CreateController(mParent.mMog, destination.GetFullFilename());
                if (!assetController.Open(destination.GetFullFilename()))
                {
                    return;
                }

                // Check if this message is to go to the outbox or inbox
                if (string.Compare(destination.GetBoxName(), "Outbox", true) == 0)
                {
                    // Create the newly added node
                    ListViewItem item = mParent.CreateListViewNode(assetController.GetPropertiesFile().GetString("MESSAGE", "SUBJECT"),
                                                                   assetController.GetPropertiesFile().GetString("MESSAGE", "FROM"),
                                                                   assetController.GetPropertiesFile().GetString("ASSET", "TIME"),
                                                                   "ATTACHMENTS",
                                                                   assetController.GetPropertiesFile().GetString("MESSAGE", "CC"),
                                                                   "",
                                                                   assetController.GetAssetFilename().GetFullFilename(),
                                                                   assetController.GetAssetFilename().GetBoxName(),
                                                                   Color.Black);

                    // Add it to our listView
                    mParent.mainForm.AssetManagerOutboxMessagesListViewFilter.Items.Add(item);
                }
                else
                {
                    // Create the newly added node
                    ListViewItem item = mParent.CreateListViewNode(assetController.GetPropertiesFile().GetString("MESSAGE", "SUBJECT"),
                                                                   assetController.GetPropertiesFile().GetString("MESSAGE", "TO"),
                                                                   assetController.GetPropertiesFile().GetString("ASSET", "TIME"),
                                                                   "ATTACHMENTS",
                                                                   assetController.GetPropertiesFile().GetString("MESSAGE", "CC"),
                                                                   "",
                                                                   assetController.GetAssetFilename().GetFullFilename(),
                                                                   assetController.GetAssetFilename().GetBoxName(),
                                                                   Color.Blue);

                    // Add it to our listView
                    mParent.mainForm.AssetManagerInboxMessagesListViewFilter.Items.Add(item);
                }

                assetController.Close();
            }
        }
        public void RefreshBox(MOG_Filename add, MOG_Filename del, MOG_Command command)
        {
            Color    textColorAdd   = Color.Black;
            Color    textColorDel   = Color.Black;
            ListView currentViewAdd = mParent.IsolateListView(add.GetBoxName(), add.GetType(), add.GetUserName(), ref textColorAdd);
            ListView currentViewDel = mParent.IsolateListView(del.GetBoxName(), del.GetType(), del.GetUserName(), ref textColorDel);

            if (currentViewAdd == currentViewDel)
            {
                // Check to see if this item already exists?
                int index = ListViewItemMessagesFindItem(add.GetFullFilename(), currentViewAdd);
                if (index != -1)
                {
                    currentViewAdd.Items[index].SubItems[(int)guiAssetManager.MessageBoxColumns.STATUS].Text   = command.GetDescription();
                    currentViewAdd.Items[index].SubItems[(int)guiAssetManager.MessageBoxColumns.BOX].Text      = add.GetBoxName();
                    currentViewAdd.Items[index].SubItems[(int)guiAssetManager.MessageBoxColumns.FULLNAME].Text = add.GetFullFilename();
                    currentViewAdd.Items[index].ForeColor = textColorAdd;
                    for (int x = 0; x < currentViewAdd.Items[index].SubItems.Count; x++)
                    {
                        currentViewAdd.Items[index].SubItems[x].ForeColor = textColorAdd;
                    }
                }
            }
            else
            {
                if (currentViewDel != null)
                {
                    int index = ListViewItemMessagesFindItem(del.GetFullFilename(), currentViewDel);
                    if (index != -1)
                    {
                        currentViewDel.Items[index].Remove();
                    }
                }

                if (currentViewAdd != null)
                {
                    // Check to see if this item already exists?
                    int index = ListViewItemMessagesFindItem(add.GetFullFilename(), currentViewAdd);
                    if (index != -1)
                    {
                        currentViewAdd.Items[index].SubItems[(int)guiAssetManager.MessageBoxColumns.STATUS].Text   = command.GetDescription();
                        currentViewAdd.Items[index].SubItems[(int)guiAssetManager.MessageBoxColumns.FULLNAME].Text = add.GetFullFilename();
                        currentViewAdd.Items[index].ForeColor = textColorAdd;
                        for (int x = 0; x < currentViewAdd.Items[index].SubItems.Count; x++)
                        {
                            currentViewAdd.Items[index].SubItems[x].ForeColor = textColorAdd;
                        }
                    }
                    else
                    {
                        MOG_ControllerMessage assetController = new MOG_ControllerMessage(mParent.mMog);
                        if (!assetController.Open(add.GetFullFilename()))
                        {
                            return;
                        }

                        // Create the newly added node
                        ListViewItem item = mParent.CreateListViewNode(assetController.GetSubject(),
                                                                       assetController.GetFrom(),
                                                                       assetController.GetFileInfo().LastWriteTime.ToString(),
                                                                       assetController.GetTo(),
                                                                       assetController.GetStatus(),
                                                                       "",
                                                                       assetController.GetAssetFilename().GetFullFilename(),
                                                                       assetController.GetAssetFilename().GetBoxName(),
                                                                       Color.Black);

                        currentViewAdd.Items.Add(item);

                        assetController.Close();
                    }
                }
            }

            // Update the Tab
            RefreshTab(command);
        }
        public void RefreshBox(MOG_Filename add, MOG_Filename del, MOG_Command command)
        {
            Color textColorAdd = Color.Black;
            Color textColorDel = Color.Black;

            // Dont add if we dont have a valid box
            if (add.GetBoxName().Length == 0 && del.GetBoxName().Length == 0)
            {
                return;
            }

            ListView currentViewAdd = mParent.IsolateListView(add.GetBoxName(), add.GetType(), add.GetUserName(), ref textColorAdd);
            ListView currentViewDel = mParent.IsolateListView(del.GetBoxName(), del.GetType(), del.GetUserName(), ref textColorDel);

            if (currentViewAdd == currentViewDel)
            {
                // Check to see if this item already exists?
                int index = mParent.ListViewItemFindItem(add.GetFilename(), currentViewAdd);
                if (index != -1)
                {
                    currentViewAdd.Items[index].SubItems[(int)guiAssetManager.TaskBoxColumns.STATUS].Text   = command.GetDescription();
                    currentViewAdd.Items[index].SubItems[(int)guiAssetManager.TaskBoxColumns.FULLNAME].Text = add.GetFullFilename();
                    currentViewAdd.Items[index].ForeColor = textColorAdd;
                    for (int x = 0; x < currentViewAdd.Items[index].SubItems.Count; x++)
                    {
                        currentViewAdd.Items[index].SubItems[x].ForeColor = textColorAdd;
                    }
                }
            }
            else
            {
                if (currentViewDel != null)
                {
                    int index = mParent.ListViewItemFindItem(del.GetFilename(), currentViewDel);
                    if (index != -1)
                    {
                        currentViewDel.Items[index].Remove();
                    }
                }

                if (currentViewAdd != null)
                {
                    // Check to see if this item already exists?
                    int index = mParent.ListViewItemFindItem(add.GetFilename(), currentViewAdd);
                    if (index != -1)
                    {
                        currentViewAdd.Items[index].SubItems[(int)guiAssetManager.TaskBoxColumns.STATUS].Text   = command.GetDescription();
                        currentViewAdd.Items[index].SubItems[(int)guiAssetManager.TaskBoxColumns.FULLNAME].Text = add.GetFullFilename();
                        currentViewAdd.Items[index].ForeColor = textColorAdd;
                        for (int x = 0; x < currentViewAdd.Items[index].SubItems.Count; x++)
                        {
                            currentViewAdd.Items[index].SubItems[x].ForeColor = textColorAdd;
                        }
                    }
                    else
                    {
                        MOG_ControllerTask assetController = new MOG_ControllerTask(mParent.mMog);
                        if (!assetController.Open(add.GetFullFilename()))
                        {
                            return;
                        }

                        ListViewItem item = new ListViewItem();

                        item.Text = assetController.GetTitle();

                        MOG_Time t = new MOG_Time();
                        t.SetTimeStamp(assetController.GetDueDate());
                        item.SubItems.Add(t.ToDateTime().ToString());

                        item.SubItems.Add(assetController.GetFileInfo().LastWriteTime.ToString());
                        item.SubItems.Add(assetController.GetCreator());
                        item.SubItems.Add(assetController.GetPriority());
                        item.SubItems.Add(assetController.GetStatus());
                        item.SubItems.Add(assetController.GetAsset());
                        item.SubItems.Add(assetController.GetAssetFilename().GetFullFilename());
                        item.SubItems.Add(assetController.GetAssetFilename().GetBoxName());
                        item.ForeColor = Color.Black;
                        for (int x = 0; x < item.SubItems.Count; x++)
                        {
                            item.SubItems[x].ForeColor = textColorAdd;
                        }

                        item.ImageIndex = 0;                        //SetAssetIcon(String.Concat(mParent.mMog.GetActiveUser().GetUserPath(), "\\", box, "\\", assetName));
                        currentViewAdd.Items.Add(item);

                        assetController.Close();
                    }
                }
            }

            // Update the tab
            RefreshTab(command);
        }
Example #6
0
        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);
                }
            }
        }
Example #7
0
        private static void ImportAsOne_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker            = sender as BackgroundWorker;
            List <object>    args              = e.Argument as List <object>;
            bool             looseFileMatching = (bool)args[0];

            string[]         sourceFilenames = (string[])args[1];
            HybridDictionary exactAssetNames = new HybridDictionary();
            HybridDictionary looseAssetNames = new HybridDictionary();

            for (int i = 0; i < sourceFilenames.Length && !worker.CancellationPending; i++)
            {
                string    filename   = sourceFilenames[i];
                ArrayList assetNames = new ArrayList();

                string message = "Mapping:\n" +
                                 "     " + Path.GetDirectoryName(filename) + "\n" +
                                 "     " + Path.GetFileName(filename);
                worker.ReportProgress(i * 100 / sourceFilenames.Length, message);

                if (DosUtils.DirectoryExistFast(filename))
                {
                    // Obtain the list of contained files
                    ArrayList containedFiles = DosUtils.FileGetRecursiveList(filename, "*.*");
                    if (containedFiles != null)
                    {
                        // Map these filenames to all the possible assetnames
                        assetNames = MOG_ControllerProject.MapFilenamesToAssetNames(containedFiles, "", worker);
                    }
                }
                else
                {
                    // Map this filename to all possible assetnames
                    assetNames = MOG_ControllerProject.MapFilenameToAssetName(filename, "", "");
                }

                // Check if we found some assetNames?
                if (assetNames != null)
                {
                    // Check if we are allowing loose matches? and
                    // Check if this is a possible loose match?
                    if (looseFileMatching &&
                        assetNames.Count == 2)
                    {
                        // Check if this is a blank?
                        MOG_Filename assetName = assetNames[1] as MOG_Filename;
                        if (assetName.GetFullFilename().Length == 0)
                        {
                            // Turn this into an exact match
                            assetNames.RemoveAt(1);
                        }
                    }

                    // Check if we found an exact match?
                    if (assetNames.Count == 1)
                    {
                        // Add this to our list of exactAssetNames if we haven't already found it
                        MOG_Filename assetName = assetNames[0] as MOG_Filename;
                        if (!exactAssetNames.Contains(assetName.GetAssetFullName()))
                        {
                            exactAssetNames[assetName.GetAssetFullName()] = assetName;
                        }
                    }
                    else
                    {
                        // Add all of the assetNames
                        foreach (MOG_Filename assetName in assetNames)
                        {
                            // Check if this is a blank?
                            if (assetName.GetFullFilename().Length == 0)
                            {
                                continue;
                            }

                            // Add this to our list of looseAssetNames if we haven't already found it
                            if (!looseAssetNames.Contains(assetName.GetAssetFullName()))
                            {
                                looseAssetNames[assetName.GetAssetFullName()] = assetName;
                            }
                        }
                    }
                }
            }

            // Check if we have any exact matches?
            if (exactAssetNames.Count > 0)
            {
                e.Result = new ArrayList(exactAssetNames.Values);
            }
            else
            {
                // Check if are allowing loose matching?
                if (looseFileMatching)
                {
                    e.Result = new ArrayList(looseAssetNames.Values);
                }
                else
                {
                    // Add back on the empty entry if it is needed
                    if (looseAssetNames.Count == 1)
                    {
                        looseAssetNames[""] = new MOG_Filename("");
                    }

                    // Return our list of foundAssets
                    e.Result = new ArrayList(looseAssetNames.Values);
                }
            }
        }