Exemple #1
0
        private ListViewItem CreateListViewItemForAsset(MOG_Filename asset)
        {
            ListViewItem item = null;

            // Only put the asset in the list if it is actually a library asset
            if (asset.IsLibrary())
            {
                // Make sure we have something valid in our Filename
                if (asset.GetAssetLabel().Length > 0)
                {
                    item = new ListViewItem(asset.GetAssetLabel());

                    // Get the source imported file
                    MOG_Filename repositoryAssetFilename = MOG_ControllerRepository.GetAssetBlessedVersionPath(asset, asset.GetVersionTimeStamp());
                    string       repositoryFile          = MOG_ControllerLibrary.ConstructBlessedFilenameFromAssetName(repositoryAssetFilename);
                    string       localFile = MOG_ControllerLibrary.ConstructLocalFilenameFromAssetName(repositoryAssetFilename);
                    string       extension = DosUtils.PathGetExtension(localFile);

                    // Populate the item
                    item.SubItems.Add(extension);                                   // Extension
                    item.SubItems.Add(asset.GetAssetClassification());              // Classification
                    item.SubItems.Add("");                                          // User
                    item.SubItems.Add("");                                          // Comment
                    item.SubItems.Add("");                                          // Local TimeStamp
                    item.SubItems.Add(asset.GetVersionTimeStampString(""));         // Server Timestamp
                    item.SubItems.Add("New");                                       // Status
                    item.SubItems.Add(asset.GetAssetFullName());                    // Fullname
                    item.SubItems.Add(localFile);                                   // LocalFile
                    item.SubItems.Add(repositoryFile);                              // RepositoryFile

                    // Update the item
                    UpdateItem(item);
                }
            }

            return(item);
        }
Exemple #2
0
        public void RefreshItem(MOG_Command command)
        {
            // No reason to bother if they have no library working directory
            if (MOG_ControllerLibrary.GetWorkingDirectory().Length == 0)
            {
                return;
            }

            // Make sure this contains an encapsulated command?
            MOG_Command encapsulatedCommand = command.GetCommand();

            if (encapsulatedCommand != null)
            {
                // No reason to bother if they are in a different project
                if (string.Compare(MOG_ControllerProject.GetProjectName(), encapsulatedCommand.GetProject(), true) != 0)
                {
                    return;
                }

                // Check if this encapsulatedCommand contains a valid assetFilename?
                if (encapsulatedCommand.GetAssetFilename().GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                {
                    // No reason to bother if this asset's classification doesn't match their mCurrentClassification
                    if (string.Compare(CurrentClassification, encapsulatedCommand.GetAssetFilename().GetAssetClassification(), true) != 0)
                    {
                        return;
                    }
                }

                // Can we find the asset node of this file?
                int itemid = FindListItem(encapsulatedCommand.GetAssetFilename().GetAssetFullName());
                if (itemid == -1)
                {
                    // Check if this was a post command?
                    if (encapsulatedCommand.GetCommandType() == MOG_COMMAND_TYPE.MOG_COMMAND_Post)
                    {
                        // Create a new item
                        ListViewItem item = CreateListViewItemForAsset(encapsulatedCommand.GetAssetFilename());
                        if (item != null)
                        {
                            LibraryListView.Items.Add(item);
                            itemid = FindListItem(encapsulatedCommand.GetAssetFilename().GetAssetFullName());
                        }
                    }
                }

                // Now check if we finally found our itemid?
                if (itemid != -1)
                {
                    ListViewItem item = LibraryListView.Items[itemid];
                    if (item != null)
                    {
                        int classificationIdx  = FindColumn("Classification");
                        int nameIdx            = FindColumn("Name");
                        int statusIdx          = FindColumn("Status");
                        int userIdx            = FindColumn("User");
                        int commentIdx         = FindColumn("Comment");
                        int localFileIdx       = FindColumn("LocalFile");
                        int repositoryFileIdx  = FindColumn("RepositoryFile");
                        int localTimestampIdx  = FindColumn("Local Timestamp");
                        int serverTimestampIdx = FindColumn("Server Timestamp");
                        int fullname           = FindColumn("Fullname");
                        int extensionIdx       = FindColumn("Extension");

                        // Determin the type of encapsulated command
                        switch (encapsulatedCommand.GetCommandType())
                        {
                        case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRelease:
                        case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRelease:
                            UpdateItem(item);
                            break;

                        case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest:
                        case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest:
                            string status   = "";
                            string comment  = encapsulatedCommand.GetDescription();
                            string username = encapsulatedCommand.GetUserName();
                            if (String.Compare(MOG_ControllerProject.GetUserName(), encapsulatedCommand.GetUserName(), true) == 0)
                            {
                                status = "CheckedOut";
                            }
                            else
                            {
                                status = "Locked";
                            }

                            item.ImageIndex = MogUtil_AssetIcons.GetLockedBinaryIcon(item.SubItems[repositoryFileIdx].Text);
                            item.SubItems[commentIdx].Text = comment;
                            item.SubItems[userIdx].Text    = username;
                            item.SubItems[statusIdx].Text  = status;

                            UpdateListViewItemColors(item, status);
                            break;

                        case MOG_COMMAND_TYPE.MOG_COMMAND_Post:
                            item.SubItems[repositoryFileIdx].Text = MOG_ControllerLibrary.ConstructBlessedFilenameFromAssetName(encapsulatedCommand.GetAssetFilename());
                            UpdateItem(item);
                            break;

                        case MOG_COMMAND_TYPE.MOG_COMMAND_RemoveAssetFromProject:
                            // Make sure to remove this file just incase it had been previously synced
                            MOG_ControllerLibrary.Unsync(encapsulatedCommand.GetAssetFilename());
                            // Proceed to delete this item
                            RemoveItem(itemid);
                            break;
                        }

                        // Update the item's colors
                        UpdateListViewItemColors(item, item.SubItems[statusIdx].Text);
                    }
                }
            }
        }