Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Text.RegularExpressions;
- using InterplayWSTest.InterplayWS;
- namespace InterplayWSCSharpTest
- {
- class Program
- {
- static DateTime midnight;
- static AssetsPortTypeClient port;
- static UserCredentialsType creds;
- static void Main(string[] args)
- {
- Console.WriteLine("Interplay WS Test");
- midnight = DateTime.Now.Date.AddDays(1).AddTicks(-1);
- Console.WriteLine("Print out reservations that will expire today.");
- port = new AssetsPortTypeClient();
- creds = new UserCredentialsType();
- creds.Username = "uuuu";
- creds.Password = "pppp";
- string path = "interplay://WGC/Projects/";
- ListFolderContents(path);
- Console.Write("Hit enter to end.");
- Console.ReadLine();
- }
- private static void ListFolderContents(string path)
- {
- Console.WriteLine(path);
- GetChildrenType getChildrenParams = new GetChildrenType();
- getChildrenParams.InterplayURI = path;
- getChildrenParams.IncludeFolders = true; // get folders
- getChildrenParams.IncludeFoldersSpecified = true;
- getChildrenParams.IncludeMOBs = false; // no mobs
- getChildrenParams.IncludeMOBsSpecified = true;
- getChildrenParams.IncludeFiles = false; // no files
- getChildrenParams.IncludeFilesSpecified = true;
- getChildrenParams.ReturnAttributes = new AttributeType[1];
- getChildrenParams.ReturnAttributes[0] = new AttributeType();
- getChildrenParams.ReturnAttributes[0].Group = "USER";
- getChildrenParams.ReturnAttributes[0].Name = "Display Name";
- GetChildrenResponseType getChildrenResponse = port.GetChildren(creds, getChildrenParams);
- if (getChildrenResponse.Results != null && getChildrenResponse.Results.Length > 0)
- {
- foreach (AssetDescriptionType ad in getChildrenResponse.Results)
- {
- string childPath = null;
- foreach (AttributeType att in ad.Attributes)
- {
- if (att.Group.Equals("USER") && att.Name.Equals("Display Name"))
- childPath = att.Value;
- }
- InspectReservations(ad.InterplayURI);
- if (childPath != null)
- ListFolderContents(path + "/" + childPath);
- }
- }
- }
- private static void InspectReservations(string uri)
- {
- GetReservationsType getReservationsParams = new GetReservationsType();
- getReservationsParams.InterplayURIs = new string[1];
- getReservationsParams.InterplayURIs[0] = uri;
- // first call to get the mobs
- GetReservationsResponseType getReservationsResponse = port.GetReservations(creds, getReservationsParams);
- if (getReservationsResponse.Results != null && getReservationsResponse.Results.Length > 0)
- {
- foreach (ReservationInformationType ri in getReservationsResponse.Results)
- {
- if (ri.ReservationDetails != null)
- {
- foreach (ReservationDetailsType rd in ri.ReservationDetails)
- {
- DateTime theDate = DateTime.Parse(rd.ExpirationDate);
- if (theDate < midnight)
- {
- Console.WriteLine("Expiring reservation: " + rd.ReservedAsset + ", " + rd.ReservedBy + ", " + rd.ExpirationDate);
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement