Vault插件示例--Vault Explorer与Thin Client的集成。

Autodesk Vault 2014的Subscription 包中有一个组件叫作Thin Client。这个瘦客户端有着全新的界面,又给了咱们一个全新的选择。ThinClient实际是在Vault Server端架设了一个web站点,用户只须要浏览器就能够直接查看Vault数据,而不需安装Vault Explorer软件。固然也不消耗License,就不用掏钱了,哈哈、css

除了省费用外,关键仍是方便,好比咱们在设计流程中须要主管领导审核,咱们须要主管领导安装Vault Explorer客户端。并且每次设计更改完毕后请领导审批时还要费不少口舌,“领导,您进到XX目录的XX子目录,而后找到我改的xx文件,您看合适不?”如今有了ThinClient,直接给领导一个ULR链接,“领导,这是我最近的更改,妥否请批示。”是否是简单的不少?html

 

如今就写一个插件来实现Vault Explorer和Thin Client的集成。咱们的目标是为文件夹和文件添加右键菜单,生成Thin Client的ULR并在默认浏览器中打开。如图:git

image  image

对于文件,以下: github

image image

 

固然,你还能够更进一步,把这个ULR保存到数据库中,或者你的ERP系统等,从而实现Vault和其余系统的集成。web

你能够使用Vault 插件向导来建立这个插件,下面是核心代码:数据库

    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);
        }



      }



    }

 

完整代码已经发布到了Github.com, 请到https://github.com/ADN-DevTech/Vault_Thinclient_Integration 下载。浏览器

相关文章
相关标签/搜索