Advertisement
Guest User

ListFolderContents

a guest
Jul 28th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Text.RegularExpressions;
  7.  
  8. using InterplayWSTest3.InterplayWS;
  9.  
  10. namespace InterplayWSCSharpTest3
  11. {
  12.     class Program
  13.     {
  14.         private static int urlHeaderLengh = 0;
  15.         private static string theDate = "2014-04-13T05:00:00.000-0400";
  16.  
  17.         static void Main(string[] args)
  18.         {
  19.             Console.WriteLine("Interplay WS Test");
  20.             Console.WriteLine("Print out all assets created after " + theDate);
  21.  
  22.             AssetsPortTypeClient port = new AssetsPortTypeClient();
  23.  
  24.             UserCredentialsType creds = new UserCredentialsType();
  25.             creds.Username = "administrator";
  26.             creds.Password = "avid";
  27.  
  28.             string urlHeader = "interplay://WGC/Projects";
  29.             urlHeaderLengh = "interplay://WGC".Length;
  30.  
  31.             ListFolderContents(port, creds, urlHeader);
  32.  
  33.             Console.Write("Hit enter to end.");
  34.             Console.ReadLine();
  35.         }
  36.  
  37.         private static void ListFolderContents(AssetsPortTypeClient port, UserCredentialsType creds, string path)
  38.         {
  39.             Console.WriteLine(path);
  40.             ListMobs(port, creds, path);
  41.  
  42.             GetChildrenType getChildrenParams = new GetChildrenType();
  43.             getChildrenParams.InterplayURI = path;
  44.  
  45.             getChildrenParams.IncludeFolders = true;
  46.             getChildrenParams.IncludeFoldersSpecified = true;
  47.  
  48.             getChildrenParams.IncludeFiles = false;
  49.             getChildrenParams.IncludeFilesSpecified = true;
  50.  
  51.             getChildrenParams.IncludeMOBs = false;
  52.             getChildrenParams.IncludeMOBsSpecified = true;
  53.  
  54.             getChildrenParams.ReturnAttributes = new AttributeType[1];
  55.             getChildrenParams.ReturnAttributes[0] = new AttributeType();
  56.             getChildrenParams.ReturnAttributes[0].Group = "USER";
  57.             getChildrenParams.ReturnAttributes[0].Name = "Display Name";
  58.  
  59.             GetChildrenResponseType getChildrenResponse = port.GetChildren(creds, getChildrenParams);
  60.  
  61.             if (getChildrenResponse.Results != null && getChildrenResponse.Results.Length > 0)
  62.             {
  63.                 foreach (AssetDescriptionType ad in getChildrenResponse.Results)
  64.                 {
  65.                     string childPath = null;
  66.                     foreach (AttributeType att in ad.Attributes)
  67.                     {
  68.                         if (att.Group.Equals("USER") && att.Name.Equals("Display Name"))
  69.                             childPath = att.Value;
  70.                     }
  71.  
  72.                     if (childPath != null)
  73.                         ListFolderContents(port, creds, path + "/" + childPath);
  74.                 }
  75.             }
  76.         }
  77.  
  78.         private static void ListMobs(AssetsPortTypeClient port, UserCredentialsType creds, string path)
  79.         {
  80.             SearchType param = new SearchType();
  81.             param.InterplayPathURI = path;
  82.             param.SearchGroup = new SearchGroupType();
  83.             param.SearchGroup.Operator = "AND";
  84.             param.SearchGroup.AttributeCondition = new AttributeConditionType[2];
  85.  
  86.             param.SearchGroup.AttributeCondition[0] = new AttributeConditionType();
  87.             param.SearchGroup.AttributeCondition[0].Condition = "CONTAINS";
  88.             param.SearchGroup.AttributeCondition[0].Attribute = new AttributeType();
  89.             param.SearchGroup.AttributeCondition[0].Attribute.Group = "SYSTEM";
  90.             param.SearchGroup.AttributeCondition[0].Attribute.Name = "Path";
  91.             param.SearchGroup.AttributeCondition[0].Attribute.Value = path.Substring(urlHeaderLengh) + "/060a2b340101010101010f0013";
  92.  
  93.             param.SearchGroup.AttributeCondition[1] = new AttributeConditionType();
  94.             param.SearchGroup.AttributeCondition[1].Condition = "GREATER_THAN";
  95.             param.SearchGroup.AttributeCondition[1].Attribute = new AttributeType();
  96.             param.SearchGroup.AttributeCondition[1].Attribute.Group = "SYSTEM";
  97.             param.SearchGroup.AttributeCondition[1].Attribute.Name = "Creation Date";
  98.             param.SearchGroup.AttributeCondition[1].Attribute.Value = theDate;
  99.  
  100.             param.ReturnAttributes = new AttributeType[2];
  101.             param.ReturnAttributes[0] = new AttributeType();
  102.             param.ReturnAttributes[0].Group = "USER";
  103.             param.ReturnAttributes[0].Name = "Display Name";
  104.             param.ReturnAttributes[1] = new AttributeType();
  105.             param.ReturnAttributes[1].Group = "SYSTEM";
  106.             param.ReturnAttributes[1].Name = "Type";
  107.  
  108.             SearchRequest request = new SearchRequest();
  109.             request.UserCredentials = creds;
  110.             request.Search = param;
  111.  
  112.             SearchResponseType response = port.Search(creds, param);
  113.  
  114.             if (response.Results.Length > 0)
  115.             {
  116.                 foreach (AssetDescriptionType ad in response.Results)
  117.                 {
  118.                     foreach (AttributeType att in ad.Attributes)
  119.                     {
  120.                         if (att.Group.Equals("USER") && att.Name.Equals("Display Name"))
  121.                             Console.Write("  " + att.Name + " = " + att.Value);
  122.                         if (att.Group.Equals("SYSTEM") && att.Name.Equals("Type"))
  123.                             Console.WriteLine(", " + att.Name + " = " + att.Value);
  124.                     }
  125.                 }
  126.             }
  127.         }
  128.     }
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement