EaBIM一直以来积极响应国家“十二五”推进建筑业信息化的号召,对建筑领域的信息技术开展深入技术交流和探讨!致力于打造“BIM-建筑师-生态技术”三位一体综合资源交流共享平台,希望为BIM与可持续设计理念及技术的普及做出微小的贡献!!!

萧闫子 发表于 2014-1-14 10:32:45

Migrating Folder Property sample app to Vault 2012

Doug called up everyone to help migrating his Vault sample apps in his blog HELP - Too many sample apps, and I’m taking one of them - the Folder Property. This sample is to show you how to use Vault API to find all files in Vault, also find the specific property for each Vault file, change the value of the property. It also demonstrates how to find files through specifying search condition, e.g. the Date version created is bigger than specific time.This sample also implements the function of detecting what file is editable. In some cases, the file is not editable because it’s released or checked out. I used this function last time when I wrote an article for our Newsletter about how to customize the report page of Vault. I copied that function below:      /// <summary>      /// Remove files that we know that we cannot edit.      /// </summary>      protected List<Document.File> PruneFileList(IEnumerable<Document.File> files)      {            List<Document.File> retVal = new List<FolderProperty.Document.File>();             foreach (Document.File f in files)            {                if (f == null || f.Id <= 0 || f.Cloaked || f.CheckedOut)                  continue;                 if (f.FileLfCyc != null && f.FileLfCyc.Consume)                  continue;                 retVal.Add(f);            }            return retVal;      }Now you can download the migrated sample app from:http://barbarahan.download.csdn.net/If you want to know what to do for porting this sample to Vault 2012, here is some information that I am happy to share:1.       Open the sample project in VS 2008;2.       Remove the web reference folder from the solution explorer window, and add reference to Autodesk.Connectivity.WebServices.DLL located in Vault 2012 SDK/bin folder, and ensure the Copy Local to be True.3.       Build project and fix the compiling error – most of errors are failing to find object in some namespace. Replacing the old namespace, such as Document, with Autodesk.Connectivity.WebServices would resolve this sort of error. Other errors are caused by some functions being changed in Vault 2012, for example CheckInFile function has a new parameter and 4 parameters are removed, so you need to re-write some codes to set up the new parameter. Here is a sample for adjusting the code to make CheckInFile work:Replace FileAssociations class:    public class FileAssociations    {      public List<long> DependFileIds;      public List<string> DependSources;      public List<long> AttachFileIds;      public List<string> AttachSources;       public FileAssociations(FileAssocArray fileAssocArray)      {            DependFileIds = new List<long>();            DependSources = new List<string>();            AttachFileIds = new List<long>();            AttachSources = new List<string>();             if (fileAssocArray == null || fileAssocArray.FileAssocs == null)                return;             foreach (FileAssoc assoc in fileAssocArray.FileAssocs)            {                if (assoc.Typ == AssociationType.Attachment)                {                  AttachFileIds.Add(assoc.CldFile.Id);                  AttachSources.Add(assoc.Source);                }                else if (assoc.Typ == AssociationType.Dependency)                {                  DependFileIds.Add(assoc.CldFile.Id);                  DependSources.Add(assoc.Source);                }            }      } }With the new one:      public FileAssociations(FileAssocArray fileAssocArray)      {             if (fileAssocArray != null)            {                if (fileAssocArray.FileAssocs != null)                {                  fileAssocParams = new ArrayList();                  foreach (FileAssoc assoc in fileAssocArray.FileAssocs)                  {                        FileAssocParam param1 = new FileAssocParam();                        param1.CldFileId = assoc.CldFile.Id;                        param1.RefId = assoc.RefId;                        param1.Source = assoc.Source;                        param1.Typ = assoc.Typ;                        param1.ExpectedVaultPath = assoc.ExpectedVaultPath;                        fileAssocParams.Add(param1);                  }                }            }      }} Replace the following lines which calls CheckinFile function to check file in Vault:    try    {      docSvc.CheckinFile(files.MasterId, "Setting folder property",            false, files.ModDate,            associations.DependFileIds.ToArray(), associations.DependSources.ToArray(),            associations.AttachFileIds.ToArray(), associations.AttachSources.ToArray(),            null, true, null, files.FileClass, files.Hidden, null);    }With these lines:   try    {      // Get bom                         BOM tbom = docSvc.GetBOMByFileId(files.Id);       FileAssocParam[] paramArray = null;      if (associations.fileAssocParams!=null)            paramArray = (FileAssocParam[])associations.fileAssocParams.ToArray(typeof(FileAssocParam));       docSvc.CheckinFile(files.MasterId, "Setting folder property",            false, files.ModDate,            paramArray,            tbom, true,null, files.FileClass, files.Hidden, null);    } 4.       Debug the app and fix the run-time error – I got a couple of null exceptions, e.g. some files have no FileAssocs and the code doesn’t detect this situation, so I went forward to fix these. Another run-time error that I could’t forget is that the property Id for Date Version Created is changed. In old version of the sample app, the Id is set to -31, and when I ran this app, one error incured and said the property Id is not right. I opened a SDK sample named “VaultFileBrowser” because I recalled it could set the serach condition so I can step in to find the Date Version Created property information through debugging it. I got “5” for that property’s Id. That is it.It is quite straightforward to update this sample app. If you see anything wrong with the new version, please feel free to let me know.文章来源:http://blog.csdn.net/barbarahan

妮可 发表于 2016-3-25 10:53:57

    <( ̄︶ ̄)>不错o!~

妮可 发表于 2016-2-25 10:08:25

支持一下    (● ̄(エ) ̄●)

EaBIM门户编辑 发表于 2017-6-2 09:46:09

就是来点赞的哦

dgpeihua 发表于 2014-2-21 14:49:29

顶起来…………

影馨 发表于 2014-2-25 10:57:40

顶!!!!!!!!!!

dglei88 发表于 2014-2-25 10:59:12

顶起来…………

levin 发表于 2014-2-25 11:01:59

顶!!!!!!!!!!!!!!!!!!!!!!!!!

一梦千寻 发表于 2014-2-25 11:02:35

顶!!!!!!!!!!

levin 发表于 2014-2-25 11:05:39

路过!!!
帮顶……

静儿 发表于 2014-2-25 11:06:21

顶!!!!!!!!!!!!!!!!!!!!!!!!!

车奴 发表于 2014-2-25 11:08:44

顶......
楼下跟上.....

烈火ivk 发表于 2014-2-25 11:11:54

路过!!!
不发表意见……

zpklfruV 发表于 2014-2-25 11:12:36

路过!!!
不发表意见……

筱雅 发表于 2014-2-25 11:15:51

路过!!!
帮顶……

gba8297517 发表于 2014-2-25 11:16:34

顶!!!!!!!!!!

chen_0003 发表于 2014-2-25 11:19:55

顶!!!!!!!!!!

沧海冷月 发表于 2014-2-25 11:20:41

路过!!!
不发表意见……
页: [1] 2 3 4 5 6 7 8 9 10
查看完整版本: Migrating Folder Property sample app to Vault 2012