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 下載。瀏覽器

相關文章
相關標籤/搜索