コード例 #1
0
ファイル: Extension.cs プロジェクト: mberntsen/AddStepFile
        private void Handle_AddStepFileCmd_Execute(object sender, CommandItemEventArgs e)
        {
            Util.DoAction(delegate
            {
                IEnumerable <long> ItemIds = from s in e.Context.CurrentSelectionSet
                                             where s.TypeId == SelectionTypeId.Item
                                             select s.Id;

                if (ItemIds.Any() == false)
                {
                    return;
                }
                Item[] items = ServiceManager.ItemService.GetItemsByIds(ItemIds.ToArray());

                using (AddStepFileForm frm = new AddStepFileForm())
                {
                    frm.Credentials = e.Context.Application.VaultContext.GetCredentials();
                    frm.Items.AddRange(items);
                    if (frm.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                }
            });
        }
コード例 #2
0
        /// <summary>
        /// This is the function that is called whenever the custom command is executed.
        /// </summary>
        /// <param name="s">The sender object.  Usually not used.</param>
        /// <param name="e">The event args.  Provides additional information about the environment.</param>
        void Camlink3_1CommandHandler(object s, CommandItemEventArgs e)
        {
            try
            {
                VDF.Vault.Currency.Connections.Connection connection = e.Context.Application.Connection;

                // The Context part of the event args tells us information about what is selected.
                // Run some checks to make sure that the selection is valid.
                if (e.Context.CurrentSelectionSet.Count() == 0)
                {
                    MessageBox.Show("Nothing is selected");
                }
                else
                {
                    Screen      screen     = Screen.FromPoint(Cursor.Position);
                    ExportToSym exportForm = new ExportToSym(e.Context.CurrentSelectionSet, connection);
                    exportForm.StartPosition = FormStartPosition.Manual;
                    exportForm.Left          = screen.Bounds.Location.X + 250;
                    exportForm.Top           = screen.Bounds.Location.Y + 150;
                    exportForm.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                // If something goes wrong, we don't want the exception to bubble up to Vault Explorer.
                MessageBox.Show("Error: " + ex.Message);
            }
        }
        public void QueuePrintPDFCommandHandler(object s, CommandItemEventArgs e)
        {
            // Queue a job
            //
            const string PrintJobTypeName  = "Horst.File.PrintPDF";
            const string PrintJob_EntityId = "EntityId";  // this was changed from FileMasterID to EntityID

            foreach (ISelection vaultObj in e.Context.CurrentSelectionSet)
            {
                JobParam[] paramList = new JobParam[3];

                JobParam entityIdParam = new JobParam();
                entityIdParam.Name = PrintJob_EntityId;
                entityIdParam.Val  = vaultObj.Id.ToString();
                paramList[0]       = entityIdParam;

                JobParam fileNameParam = new JobParam();
                fileNameParam.Name = "EntityClassId";
                fileNameParam.Val  = "USER-REQUESTED " + vaultObj.Label;
                paramList[1]       = fileNameParam;

                JobParam lifeCycleTransitionParam = new JobParam();
                lifeCycleTransitionParam.Name = "LifeCycleTransitionId";
                lifeCycleTransitionParam.Val  = "88";
                paramList[2] = lifeCycleTransitionParam;

                // Add the job to the queue
                //
                e.Context.Application.Connection.WebServiceManager.JobService.AddJob(
                    PrintJobTypeName, String.Format("Print PDF - {0}", fileNameParam.Val),
                    paramList, 100);
            }
        }
コード例 #4
0
        private void Handle_FindOrphanedFilesCmd_Execute(object sender, CommandItemEventArgs e)
        {
            Util.DoAction(delegate
            {
                IEnumerable <long> folderIds = from s in e.Context.CurrentSelectionSet
                                               where s.TypeId == SelectionTypeId.Folder
                                               select s.Id;

                if (folderIds.Any() == false)
                {
                    return;
                }
                Connection conn  = e.Context.Application.Connection;
                Folder[] folders = conn.WebServiceManager.DocumentService.GetFoldersByIds(folderIds.ToArray());

                using (FindOrphanedFilesForm frm = new FindOrphanedFilesForm())
                {
                    frm.Connection = e.Context.Application.Connection;

                    frm.Folders.AddRange(folders);
                    if (frm.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    if (frm.SelectedFile != null)
                    {
                        e.Context.GoToLocation = new LocationContext(SelectionTypeId.File, frm.SelectedFile.Path);
                    }
                }
            });
        }
コード例 #5
0
        public void QueueFileUpdateCommandHandler(object s, CommandItemEventArgs e)
        {
            // Queue a job
            //
            const string PublishJobTypeName      = "Horst.File.FileUpdate";
            const string PublishJob_FileMasterId = "FileMasterId";
            const string PublishJob_FileName     = "FileName";

            foreach (ISelection vaultObj in e.Context.CurrentSelectionSet)
            {
                JobParam[] paramList     = new JobParam[2];
                JobParam   masterIdParam = new JobParam();
                masterIdParam.Name = PublishJob_FileMasterId;
                masterIdParam.Val  = vaultObj.Id.ToString();
                paramList[0]       = masterIdParam;

                JobParam fileNameParam = new JobParam();
                fileNameParam.Name = PublishJob_FileName;
                fileNameParam.Val  = vaultObj.Label;
                paramList[1]       = fileNameParam;

                // Add the job to the queue
                //
                e.Context.Application.Connection.WebServiceManager.JobService.AddJob(
                    PublishJobTypeName, String.Format("File Update - {0}", fileNameParam.Val),
                    paramList, 10);
            }
        }
コード例 #6
0
        private void QueueItemJob(object s, CommandItemEventArgs e)
        {
            var errorItems   = new List <string>();
            var successItems = new List <string>();

            foreach (var selection in e.Context.CurrentSelectionSet.Reverse())
            {
                if (selection.TypeId.EntityClassId != "ITEM")
                {
                    return;
                }
                var item = _connection.WebServiceManager.ItemService.GetLatestItemByItemNumber(selection.Label);

                try
                {
                    var jobParams = new List <JobParam>
                    {
                        new JobParam {
                            Name = "EntityClassId", Val = "ITEM"
                        },
                        new JobParam {
                            Name = "EntityId", Val = item.Id.ToString()
                        }
                    };

                    var job = _connection.WebServiceManager.JobService.AddJob(_jobType,
                                                                              $"Transfers item {item.ItemNum} to Fusion Lifecycle", jobParams.ToArray(), 100);

                    if (job != null)
                    {
                        successItems.Add(item.ItemNum);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    errorItems.Add(item.ItemNum);
                }
            }


            if (successItems.Count > 0)
            {
                MessageBox.Show($@"Job '{_jobType}' successfully triggered for item{(successItems.Count > 1 ? "s": "")} {string.Join(", ", successItems)}!",
                                @"Add Job",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }

            if (errorItems.Count > 0)
            {
                MessageBox.Show($@"Error while triggering job '{_jobType}' for item{(errorItems.Count > 1 ? "s" : "")} {string.Join(", ", errorItems)}!",
                                @"Add Job",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
コード例 #7
0
 /// <summary>
 /// Protected method that is call when a new Command as been added to instance of Command Manager
 /// </summary>
 /// <param name="item">Instance of Control</param>
 /// <param name="cmd">The <see cref="Command"/> associated with <paramref name="item"/></param>
 /// <remarks>
 /// Can be overridden in derived classes.
 /// Method is also responsible for calling <see cref="InstanceAdded"/> event on successful adding of <paramref name="item"/>.
 /// </remarks>
 protected internal virtual void OnInstanceAdded(T item, Command cmd)
 {
     hashInstances.Add(item, cmd);
     if (InstanceAdded != null)
     {
         CommandItemEventArgs <T> args = new CommandItemEventArgs <T>(item, cmd);
         InstanceAdded(this, args);
     }
 }
コード例 #8
0
        private void GoToFlcItem(object s, CommandItemEventArgs e)
        {
            long entityId  = 0;
            var  selection = e.Context.CurrentSelectionSet.First();

            if (selection.TypeId == SelectionTypeId.Item)
            {
                var item = _connection.WebServiceManager.ItemService.GetLatestItemByItemNumber(selection.Label);
                entityId = item.MasterId;
            }
            if (selection.TypeId == SelectionTypeId.File)
            {
                var file = _connection.WebServiceManager.DocumentService.GetLatestFileByMasterId(selection.Id);
                entityId = file.MasterId;
            }
            if (selection.TypeId == SelectionTypeId.FileVersion)
            {
                var file = _connection.WebServiceManager.DocumentService.GetFileById(selection.Id);
                entityId = file.MasterId;
            }
            if (selection.TypeId == SelectionTypeId.Folder)
            {
                var folder = _connection.WebServiceManager.DocumentService.GetFolderById(selection.Id);
                entityId = folder.Id;
            }
            if (selection.TypeId == SelectionTypeId.ChangeOrder)
            {
                var changeOrder = _connection.WebServiceManager.ChangeOrderService.GetChangeOrderByNumber(selection.Label);
                entityId = changeOrder.Id;
            }

            if (entityId == 0)
            {
                return;
            }

            var entAttrs = _connection.WebServiceManager.PropertyService.GetEntityAttributes(entityId, _attributeNs);
            var entAttr  = entAttrs?.SingleOrDefault(a => a.Attr.Equals(_attributeName));

            if (entAttr == null)
            {
                //TODO: connect to FLC and query item by number
                return;
            }

            var attribute = new EntAttrEx(entAttr, _attributeNs);
            var urn       = attribute.Val;

            if (string.IsNullOrEmpty(urn))
            {
                return;
            }

            var url = $"https://{attribute.Tenant}.autodeskplm360.net/plm/workspaces/{attribute.Workspace}/items/itemDetails?view=full&tab=details&mode=view&itemId={urn.Replace(":", "%60").Replace(".", ",")}";

            Process.Start(url);
        }
コード例 #9
0
 void backupCmd_Execute(object sender, CommandItemEventArgs e)
 {
     try
     {
         Backup();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
コード例 #10
0
        /// <summary>
        /// This is the function that is called whenever the custom command is executed.
        /// </summary>
        /// <param name="s">The sender object.  Usually not used.</param>
        /// <param name="e">The event args.  Provides additional information about the environment.</param>
        void HelloWorldCommandHandler(object s, CommandItemEventArgs e)
        {
            try
            {
                VDF.Vault.Currency.Connections.Connection connection = e.Context.Application.Connection;

                // The Context part of the event args tells us information about what is selected.
                // Run some checks to make sure that the selection is valid.
                if (e.Context.CurrentSelectionSet.Count() == 0)
                {
                    MessageBox.Show("Nothing is selected");
                }
                else if (e.Context.CurrentSelectionSet.Count() > 1)
                {
                    MessageBox.Show("This function does not support multiple selections");
                }
                else
                {
                    // we only have one item selected, which is the expected behavior

                    ISelection selection = e.Context.CurrentSelectionSet.First();

                    // Look of the File object.  How we do this depends on what is selected.
                    File selectedFile = null;
                    if (selection.TypeId == SelectionTypeId.File)
                    {
                        // our ISelection.Id is really a File.MasterId
                        selectedFile = connection.WebServiceManager.DocumentService.GetLatestFileByMasterId(selection.Id);
                    }
                    else if (selection.TypeId == SelectionTypeId.FileVersion)
                    {
                        // our ISelection.Id is really a File.Id
                        selectedFile = connection.WebServiceManager.DocumentService.GetFileById(selection.Id);
                    }

                    if (selectedFile == null)
                    {
                        MessageBox.Show("Selection is not a file.");
                    }
                    else
                    {
                        // this is the message we hope to see
                        MessageBox.Show(String.Format("Hello World! The file size is: {0} bytes",
                                                      selectedFile.FileSize));
                    }
                }
            }
            catch (Exception ex)
            {
                // If something goes wrong, we don't want the exception to bubble up to Vault Explorer.
                MessageBox.Show("Error: " + ex.Message);
            }
        }
コード例 #11
0
 /// <summary>
 /// Protected method that is call when a new Command as been removed from instance of Command Manager
 /// </summary>
 /// <param name="item">Instance of Control</param>
 /// <param name="cmd">The <see cref="Command"/> associated with <paramref name="item"/></param>
 /// <remarks>
 /// Can be overridden in derived classes.
 /// Method is also responsible for calling <see cref="InstanceRemoved"/> event on successful removing of <paramref name="item"/>.
 /// </remarks>
 protected internal virtual void OnInstanceRemoved(T item, Command cmd)
 {
     if (hashInstances.ContainsKey((T)item))
     {
         hashInstances.Remove((T)item);
         if (InstanceRemoved != null)
         {
             CommandItemEventArgs <T> args = new CommandItemEventArgs <T>(item, cmd);
             InstanceRemoved(this, args);
         }
     }
 }
コード例 #12
0
 void command_Execute(object sender, CommandItemEventArgs e)
 {
     try
     {
         string vaultName  = e.Context.Application.Connection.Vault;
         string serverName = e.Context.Application.Connection.Server;
         ConfigureThunderdome(serverName, vaultName, e);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
コード例 #13
0
        private void CreateOrderCommand(object s, CommandItemEventArgs e)
        {
            var wsm  = e.Context.Application.Connection.WebServiceManager;
            var file = wsm.DocumentService.GetFileById(e.Context.CurrentSelectionSet.First().Id);

            var dialog = new OrganisationPickerDialog(e.Context.Application.Connection);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var orderNumber = dialog.OrderNumber;
                var entity      = dialog.Selection.FirstOrDefault();
                if (entity == null)
                {
                    return;
                }

                var link = wsm.DocumentService.AddLink(
                    entity.EntityIterationId, "FILE", file.Id, null);

                var propDefs           = wsm.PropertyService.GetPropertyDefinitionsByEntityClassId("LINK");
                var propDefOrderNumber = propDefs.SingleOrDefault
                                             (p => p.DispName == "Order Number");
                var propDefOrderFileId = propDefs.SingleOrDefault(
                    p => p.DispName == "Order File ID");
                if (propDefOrderNumber == null || propDefOrderFileId == null)
                {
                    throw new ConfigurationErrorsException(
                              "The UDPs 'Order Number' and 'Order File ID' have to be present!");
                }

                var paramOrderNumber = new PropInstParam
                {
                    PropDefId = propDefOrderNumber.Id,
                    Val       = orderNumber
                };
                var paramOrderFileVersion = new PropInstParam
                {
                    PropDefId = propDefOrderFileId.Id,
                    Val       = file.Id
                };
                var propInstParamArray = new PropInstParamArray
                {
                    Items = new[] { paramOrderNumber, paramOrderFileVersion }
                };

                wsm.DocumentServiceExtensions.UpdateLinkProperties(
                    new[] { link.Id }, new[] { propInstParamArray });
            }
        }
        public void QueuePrintPDFFolderCommandHandler(object s, CommandItemEventArgs e)
        {
            using (StreamWriter debugFile = new StreamWriter(@"C:\Users\lorne\Documents\Pdfs\debug10.txt", true))
            {
                foreach (ISelection vaultObj in e.Context.CurrentSelectionSet)
                {
                    //ISelection vaultObj = null;
                    //vaultObj = (ISelection)e.Context.CurrentSelectionSet;

                    debugFile.WriteLine(vaultObj.Id.ToString());
                    Folder rootFolder = e.Context.Application.Connection.WebServiceManager.DocumentService.GetFolderById(vaultObj.Id);
                    debugFile.WriteLine(rootFolder.ToString());
                    VaultFoldertoPDF(rootFolder, e.Context.Application.Connection.WebServiceManager);
                }
            }
        }
コード例 #15
0
        private void ShowSubscription(object s, CommandItemEventArgs e)
        {
            var connection = e.Context.Application.Connection;

            if (vaultCom.connection == null)
            {
                vaultCom.InitializeFromConnection(application.Connection);
            }
            string vaultName = connection.Vault, vaultUri = connection.Server;

            SynchronizationTree tree = new SynchronizationTree(vaultName, vaultUri);

            try
            {
                tree = SynchronizationTree.ReadTree(vaultName, vaultUri);

                if (tree.IsEmpty())
                {
                    var result = MessageBox.Show("No subscriptions found for this vault. Try harder?", "Try harder?", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        tree = SynchronizationTree.ReadTree(vaultName, vaultUri, tryHarder: true);
                    }
                }
            }
            catch (Exception ex)
            {
                var result = MessageBox.Show("[ERROR] " + ex.Message + "\r\nDo you want to continue?", "Error", MessageBoxButtons.OKCancel);
                if (result == DialogResult.Cancel)
                {
                    return;
                }
            }

            ShowSubscriptionsForm form = new ShowSubscriptionsForm(tree, StartSyncThread, vaultCom);

            form.ShowDialog();
        }
コード例 #16
0
 void SelectViewerAppCommandHandler(object s, CommandItemEventArgs e)
 {
     selectDirectViewerApp();
 }
コード例 #17
0
 private void HandleUnsubscribe(object s, CommandItemEventArgs e)
 {
     SubscribeOrUnsubscribe(e.Context.CurrentSelectionSet, subscribe: false);
 }
        void VaultCreateFromTemplateCommandHandler(object s, CommandItemEventArgs e)
        {
            ISelection selectedFile = null;
            CommandItem ci = (CommandItem) s;
            foreach (ISelection f in e.Context.CurrentSelectionSet)
            {
                selectedFile = f;
            }

            if (ci.Id == "\\More...\\")
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                string extensionfolder = Application.ExecutablePath;
                extensionfolder = System.IO.Path.GetDirectoryName(extensionfolder);
                extensionfolder += "\\Extensions\\VaultCreateFromTemplate";
                openFileDialog.InitialDirectory = extensionfolder;
                openFileDialog.Filter = "XML Files(*.xml)|*.xml";
                openFileDialog.Multiselect = false;
                openFileDialog.ShowDialog();
                if (openFileDialog.FileName != "")
                {
                    LoadConfigurationFile(openFileDialog.FileName, mDocSvc.GetFolderById(selectedFile.Id).FullName);
                }
            }
            else
            {
                LoadConfigurationFile(ci.Id, mDocSvc.GetFolderById(selectedFile.Id).FullName);
            }
        }
コード例 #19
0
        private void ConfigureThunderdome(string serverName, string vaultName, CommandItemEventArgs e)
        {
            Connection conn = e.Context.Application.Connection;

            if (!Util.IsAdmin(conn))
            {
                MessageBox.Show("Only administrators can use this function");
                return;
            }

            //string userFolder = m_mgr.KnowledgeVaultService.GetVaultOption(USER_FOLDER_OPTION);
            string          deployFolderPath = conn.WebServiceManager.KnowledgeVaultService.GetVaultOption(DEFAULT_FOLDER_OPTION);
            string          deploymentXml    = conn.WebServiceManager.KnowledgeVaultService.GetVaultOption(DEPLOYMENT_CONFIG_OPTION);
            DeploymentModel deploymentModel  = DeploymentModel.Load(deploymentXml);

            Configure    cfgDialog = new Configure(deployFolderPath, deploymentModel, vaultName, conn);
            DialogResult result    = cfgDialog.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            DeploymentModel deploymentModel2 = cfgDialog.GetSelectedDataModel();

            if (!deploymentModel2.Containers.Any())
            {
                return;
            }

            // zip up the files and upload to Vault
            string  tempFile = System.IO.Path.GetTempFileName();
            ZipFile zip      = ZipFile.Create(tempFile);

            zip.BeginUpdate();


            foreach (DeploymentContainer container in deploymentModel2.Containers)
            {
                foreach (DeploymentItem item in container.DeploymentItems)
                {
                    item.Zip(zip, container);
                }
            }

            zip.CommitUpdate();
            zip.Close();

            Folder deployFolder = cfgDialog.DeploymentFolder;

            conn.WebServiceManager.KnowledgeVaultService.SetVaultOption(DEFAULT_FOLDER_OPTION, deployFolder.FullName);

            Autodesk.Connectivity.WebServices.File vaultPackage = Util.AddOrUpdateFile(
                tempFile, PACKAGE_NAME, deployFolder, conn);

            System.IO.File.Delete(tempFile);

            // we just updated the package, so we are definately up to date.
            Settings   settings = Settings.Load();
            VaultEntry entry    = settings.GetOrCreateEntry(serverName, vaultName);

            entry.LastUpdate = vaultPackage.CkInDate;
            settings.Save();

            deploymentXml = deploymentModel2.ToXml();
            conn.WebServiceManager.KnowledgeVaultService.SetVaultOption(DEPLOYMENT_CONFIG_OPTION, deploymentXml);

            MessageBox.Show("Deployment Created");
            e.Context.ForceRefresh = true;
            e.Context.GoToLocation = new LocationContext(SelectionTypeId.File, deployFolder.FullName + "/" + PACKAGE_NAME);
            return;
        }
コード例 #20
0
        void ThinClientUrlCmd_Execute(object sender, CommandItemEventArgs e)
        {
            WebServiceManager webMgr = currentConnection.WebServiceManager;

            ISelection selectedItem = e.Context.CurrentSelectionSet.FirstOrDefault <ISelection>();

            if (selectedItem != null)
            {
                Uri    serverUri = new Uri(webMgr.InformationService.Url);
                string url;

                if (selectedItem.TypeId == SelectionTypeId.File)
                {
                    File file = webMgr.DocumentService.GetLatestFileByMasterId(selectedItem.Id);
                    if (file == null)
                    {
                        return;
                    }

                    string[] ids = webMgr.KnowledgeVaultService.GetPersistentIds(
                        VDF.Vault.Currency.Entities.EntityClassIds.Files,
                        new long[] { file.Id },
                        Autodesk.Connectivity.WebServices.EntPersistOpt.Latest);

                    string id = ids[0];
                    id  = id.TrimEnd('=');
                    url = string.Format("{0}://{1}/AutodeskTC/{1}/{2}#/Entity/Details?id=m{3}=&itemtype=File",
                                        serverUri.Scheme, serverUri.Host, currentConnection.Vault, id);

                    //Open with default broswer
                    Process.Start(url);

                    //copy url to clipboard
                    Clipboard.SetText(url);
                }

                if (selectedItem.TypeId == SelectionTypeId.Folder)
                {
                    Folder folder = webMgr.DocumentService.GetFolderById(selectedItem.Id);
                    if (folder == null)
                    {
                        return;
                    }

                    string[] ids = webMgr.KnowledgeVaultService.GetPersistentIds(
                        VDF.Vault.Currency.Entities.EntityClassIds.Folder,
                        new long[] { folder.Id },
                        Autodesk.Connectivity.WebServices.EntPersistOpt.Latest);

                    string id = ids[0];
                    id  = id.TrimEnd('=');
                    url = string.Format("{0}://{1}/AutodeskTC/{1}/{2}#/Entity/Entities?folder=m{3}=&start=0",
                                        serverUri.Scheme, serverUri.Host, currentConnection.Vault, id);

                    //Open with default broswer
                    Process.Start(url);

                    //copy url to clipboard
                    Clipboard.SetText(url);
                }
            }
        }
コード例 #21
0
        void BomItemExportOdooCommandHandler(object s, CommandItemEventArgs e)
        {
            try
            {
                VDF.Vault.Currency.Connections.Connection connection = e.Context.Application.Connection;

                // The Context part of the event args tells us information about what is selected.
                // Run some checks to make sure that the selection is valid.
                if (e.Context.CurrentSelectionSet.Count() == 0)
                {
                    MessageBox.Show("Nothing is selected");
                }
                else if (e.Context.CurrentSelectionSet.Count() > 1)
                {
                    MessageBox.Show("This function does not support multiple selections");
                }
                else
                {
                    // we only have one item selected, which is the expected behavior
                    ISelection selection = e.Context.CurrentSelectionSet.First();

                    // Look of the File object.  How we do this depends on what is selected.
                    Autodesk.Connectivity.WebServices.Item selectedItem = null;
                    if (selection.TypeId == SelectionTypeId.Bom)
                    {
                        // our ISelection.Id is really a File.MasterId
                        selectedItem = connection.WebServiceManager.ItemService.GetItemsByIds(new long[] { selection.Id }).First();
                    }
                    //else if (selection.TypeId == SelectionTypeId.FileVersion)
                    //{
                    //    // our ISelection.Id is really a File.Id
                    //    selectedItem = connection.WebServiceManager.DocumentService.GetFileById(selection.Id);
                    //}

                    if (selectedItem == null)
                    {
                        MessageBox.Show("Selection is not an item.");
                    }
                    else
                    {
                        // this is the message we hope to see
                        //MessageBox.Show(String.Format("Hello World! The file size is: {0} bytes",
                        //selectedFile.FileSize));
                    }

                    VDF.Vault.Settings.AcquireFilesSettings settings = new VDF.Vault.Settings.AcquireFilesSettings(connection);

                    //VDF.Vault.Currency.Entities.FileIteration selFiles = new Vault.Currency.Entities.FileIteration(connection, selectedFile);


                    //Vault.Currency.Entities.FileIteration file = selFiles;
                    okToProcess = false;
                    ExecuteOdoo(selectedItem, connection, okToProcess);
                }
            }
            catch (Exception ex)
            {
                // If something goes wrong, we don't want the exception to bubble up to Vault Explorer.
                MessageBox.Show("Error: " + ex.Message);
            }
        }
コード例 #22
0
        void BomItemExportCommandHandler(object s, CommandItemEventArgs e)
        {
            try
            {
                VDF.Vault.Currency.Connections.Connection connection = e.Context.Application.Connection;

                // The Context part of the event args tells us information about what is selected.
                // Run some checks to make sure that the selection is valid.
                if (e.Context.CurrentSelectionSet.Count() == 0)
                {
                    MessageBox.Show("Nothing is selected");
                }
                else if (e.Context.CurrentSelectionSet.Count() > 1)
                {
                    MessageBox.Show("This function does not support multiple selections");
                }
                else
                {
                    // we only have one item selected, which is the expected behavior
                    ISelection selection = e.Context.CurrentSelectionSet.First();

                    // Look of the File object.  How we do this depends on what is selected.
                    Autodesk.Connectivity.WebServices.Item selectedItem = null;
                    if (selection.TypeId == SelectionTypeId.Bom)
                    {
                        // our ISelection.Id is really a File.MasterId
                        selectedItem = connection.WebServiceManager.ItemService.GetItemsByIds(new long[] { selection.Id }).First();
                    }

                    if (selectedItem == null)
                    {
                        MessageBox.Show("Selection is not an item.");
                    }
                    else
                    {
                        VDF.Vault.Settings.AcquireFilesSettings settings = new VDF.Vault.Settings.AcquireFilesSettings(connection);

                        ItemAssoc[] subItemAssociations = GetChildItems(selectedItem, connection);

                        // first update the top level item
                        UpdateItem(selectedItem, connection);

                        // then also all the child items
                        ItemService itemSvc = connection.WebServiceManager.ItemService;
                        foreach (ItemAssoc subItemAssoc in subItemAssociations)
                        {
                            long subID = subItemAssoc.CldItemID;

                            Item subItem = itemSvc.GetItemsByIds(new long[] { subID })[0];

                            if (subItem != null)
                            {
                                UpdateItem(subItem, connection);
                            }
                        }

                        // attempt to update all items at once, i didn't get it to work yet...
                        //Item[] itemArray = new Item[subItemAssociations.Count() + 1];
                        //itemArray[0] = selectedItem;

                        //int index = 1;
                        //ItemService itemSvc = connection.WebServiceManager.ItemService;
                        //foreach (ItemAssoc assoc in subItemAssociations)
                        //{
                        //    long subID = assoc.CldItemID;
                        //    Item subItem = itemSvc.GetItemsByIds(new long[] { subID })[0];
                        //    itemArray[index] = subItem;
                        //    index++;
                        //}

                        //UpdateItems(itemArray, connection);
                        okToProcess = true;
                        Execute(selectedItem, connection, okToProcess);
                    }
                }
            }
            catch (Exception ex)
            {
                // If something goes wrong, we don't want the exception to bubble up to Vault Explorer.
                MessageBox.Show("Error: " + ex.Message);
            }
        }
コード例 #23
0
//#if DEBUG
        private void RunTests(object s, CommandItemEventArgs e)
        {
            //RunTests(true);
        }
コード例 #24
0
        void cmd_Execute(object sender, CommandItemEventArgs e)
        {
            Util.DoAction(delegate
            {
                Connection conn = e.Context.Application.Connection;

                // lookup the server product to see if we are Vault Professional
                // remember the value so we don't have to look it up again in this session
                if (m_isVaultPro == null)
                {
                    Product[] products = conn.WebServiceManager.InformationService.GetSystemProducts();
                    m_isVaultPro       = products.Any(n => n.ProductName == "Autodesk.Productstream");
                }

                FinderDialog dialog = new FinderDialog(m_isVaultPro.Value, conn);
                DialogResult result = dialog.ShowDialog();

                if (result == DialogResult.OK && dialog.GoToLocation)
                {
                    LocationContext location = null;

                    if (dialog.GoToEntity.EntityClass.ServerId == VDF.Vault.Currency.Entities.EntityClassIds.ChangeOrders)
                    {
                        VDF.Vault.Currency.Entities.ChangeOrder co = dialog.GoToEntity as VDF.Vault.Currency.Entities.ChangeOrder;
                        if (co != null)
                        {
                            location = new LocationContext(SelectionTypeId.ChangeOrder, co.Number);
                        }
                    }
                    else if (dialog.GoToEntity.EntityClass.ServerId == VDF.Vault.Currency.Entities.EntityClassIds.CustomObject)
                    {
                        VDF.Vault.Currency.Entities.CustomObject custom = dialog.GoToEntity as VDF.Vault.Currency.Entities.CustomObject;
                        if (custom != null)
                        {
                            CustEnt custEnt = custom;
                            SelectionTypeId selectionType = new SelectionTypeId(custom.Definition.SystemName);
                            location = new LocationContext(selectionType, custEnt.Num);
                        }
                    }
                    else if (dialog.GoToEntity.EntityClass.ServerId == VDF.Vault.Currency.Entities.EntityClassIds.Files)
                    {
                        VDF.Vault.Currency.Entities.FileIteration file = dialog.GoToEntity as VDF.Vault.Currency.Entities.FileIteration;
                        if (file != null)
                        {
                            location = new LocationContext(SelectionTypeId.File, file.Parent.FullName + "/" + file.EntityName);
                        }
                    }
                    else if (dialog.GoToEntity.EntityClass.ServerId == VDF.Vault.Currency.Entities.EntityClassIds.Folder)
                    {
                        VDF.Vault.Currency.Entities.Folder folder = dialog.GoToEntity as VDF.Vault.Currency.Entities.Folder;
                        if (folder != null)
                        {
                            location = new LocationContext(SelectionTypeId.Folder, folder.FullName);
                        }
                    }
                    else if (dialog.GoToEntity.EntityClass.ServerId == VDF.Vault.Currency.Entities.EntityClassIds.Items)
                    {
                        VDF.Vault.Currency.Entities.ItemRevision item = dialog.GoToEntity as VDF.Vault.Currency.Entities.ItemRevision;
                        if (item != null)
                        {
                            location = new LocationContext(SelectionTypeId.Item, item.ItemNumber);
                        }
                    }

                    if (location != null)
                    {
                        e.Context.GoToLocation = location;
                    }
                }
            });
        }