protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListFoldersRequest request;

            try
            {
                request = new ListFoldersRequest
                {
                    WorkspaceId   = WorkspaceId,
                    OpcRequestId  = OpcRequestId,
                    AggregatorKey = AggregatorKey,
                    Fields        = Fields,
                    Name          = Name,
                    Identifier    = Identifier,
                    Page          = Page,
                    Limit         = Limit,
                    SortOrder     = SortOrder,
                    SortBy        = SortBy
                };
                IEnumerable <ListFoldersResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.FolderSummaryCollection, true);
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
        public List<Folder> Get(ListFoldersRequest request)
        {
            if (request.ParentId != default (int))
                return Repository.Where(x => x.ParentFolderId == request.ParentId).ToList();

            if (request.Ids != default(int[]))
                return Repository.GetByIds(request.Ids).ToList();
            return Repository.GetAll().ToList();
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListFoldersRequest request;

            try
            {
                request = new ListFoldersRequest
                {
                    CatalogId    = CatalogId,
                    DataAssetKey = DataAssetKey,
                    DisplayName  = DisplayName,
                    BusinessName = BusinessName,
                    DisplayOrBusinessNameContains = DisplayOrBusinessNameContains,
                    DisplayNameContains           = DisplayNameContains,
                    LifecycleState  = LifecycleState,
                    ParentFolderKey = ParentFolderKey,
                    Path            = Path,
                    ExternalKey     = ExternalKey,
                    TimeCreated     = TimeCreated,
                    TimeUpdated     = TimeUpdated,
                    CreatedById     = CreatedById,
                    UpdatedById     = UpdatedById,
                    HarvestStatus   = HarvestStatus,
                    LastJobKey      = LastJobKey,
                    Fields          = Fields,
                    SortBy          = SortBy,
                    SortOrder       = SortOrder,
                    Limit           = Limit,
                    Page            = Page,
                    OpcRequestId    = OpcRequestId
                };
                IEnumerable <ListFoldersResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.FolderCollection, true);
                }
                if (!ParameterSetName.Equals(AllPageSet) && !ParameterSetName.Equals(LimitSet) && response.OpcNextPage != null)
                {
                    WriteWarning("This operation supports pagination and not all resources were returned. Re-run using the -All option to auto paginate and list all resources.");
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Example #4
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListFoldersRequest request;

            try
            {
                request = new ListFoldersRequest
                {
                    CatalogId           = CatalogId,
                    DataAssetKey        = DataAssetKey,
                    DisplayName         = DisplayName,
                    DisplayNameContains = DisplayNameContains,
                    LifecycleState      = LifecycleState,
                    ParentFolderKey     = ParentFolderKey,
                    Path          = Path,
                    ExternalKey   = ExternalKey,
                    TimeCreated   = TimeCreated,
                    TimeUpdated   = TimeUpdated,
                    CreatedById   = CreatedById,
                    UpdatedById   = UpdatedById,
                    HarvestStatus = HarvestStatus,
                    LastJobKey    = LastJobKey,
                    Fields        = Fields,
                    SortBy        = SortBy,
                    SortOrder     = SortOrder,
                    Limit         = Limit,
                    Page          = Page,
                    OpcRequestId  = OpcRequestId
                };
                IEnumerable <ListFoldersResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.FolderCollection, true);
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListFoldersRequest request;

            try
            {
                request = new ListFoldersRequest
                {
                    WorkspaceId   = WorkspaceId,
                    OpcRequestId  = OpcRequestId,
                    AggregatorKey = AggregatorKey,
                    Fields        = Fields,
                    Name          = Name,
                    NameContains  = NameContains,
                    Identifier    = Identifier,
                    Page          = Page,
                    Limit         = Limit,
                    SortOrder     = SortOrder,
                    SortBy        = SortBy
                };
                IEnumerable <ListFoldersResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.FolderSummaryCollection, true);
                }
                if (!ParameterSetName.Equals(AllPageSet) && !ParameterSetName.Equals(LimitSet) && response.OpcNextPage != null)
                {
                    WriteWarning("This operation supports pagination and not all resources were returned. Re-run using the -All option to auto paginate and list all resources.");
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Example #6
0
        private static void Main(string[] args)
        {
            var hosts = new[] {
                new { ConfigName = "testing", Description = "Via SLB and ELB" }
            };

            foreach (var host in hosts)
            {
                Console.WriteLine("Testing: {0} ({1})", host.Description, host.ConfigName);

                try
                {
                    SessionManagementClient smc = new SessionManagementClient();
                    AuthenticationInfo auth = new AuthenticationInfo();

                    // Use an account that is a member of groups that have the right permissions.
                    auth.Password = "******";
                    auth.UserKey = "testAccount";
                    auth.AuthCode = String.Empty;

                    // Names of folders to scan
                    string[] folderNames = new string[] { "One Folder", "Some other folder name" };

                    List<Session> sessions = new List<Session>();

                    Pagination pagination = new Pagination { PageNumber = 0, MaxNumberResults = maxPerPage };
                    ListFoldersRequest request = new ListFoldersRequest { Pagination = pagination };

                    // Get all the folders we need to index
                    foreach (string folderName in folderNames)
                    {
                        ListFoldersResponse response = smc.GetFoldersList(auth, request, folderName);
                        foreach (Folder folder in response.Results)
                        {
                            // Confirm we found a folder with the exact right name, then add.
                            if (folder.Name.ToLower() == folderName.ToLower())
                            {
                                Console.WriteLine("\tSearching folder: " + folderName);
                                sessions.AddRange(searchForSessions(auth, smc, folder));
                            }
                        }
                    }

                    if (sessions.Count > 0)
                    {
                        string gsaStream = sessionsAsGsaStream(sessions);

                        Console.WriteLine("\tAll sessions: \n" + gsaStream);
                    }
                    else
                    {
                        Console.WriteLine("\tFound zero sessions.");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("\tError: " + e.Message);
                }

                Console.WriteLine();
            }

            Console.WriteLine("\nCompleted");
            Console.ReadLine();
        }
Example #7
0
        /// <summary>
        /// Gets the unique ID of the folder specified by <paramref name="folderName"/>.
        /// </summary>
        /// <param name="folderName">name fo the folder to the ID for.</param>
        /// <param name="rrMgr">The client in which holds the information about the recorder <paramref name="recorderName"/>.</param>
        /// <param name="rrAuth">The authentication information for which to access the information from <paramref name="rrMgr"/>.</param>
        /// <param name="rrID">The unique ID of a recorder.</param>
        /// <param name="sessionMgr">The client in which holds the information about the folder <paramref name="folderName"/>.</param>
        /// <param name="sessionAuth">The authentication information for which to access the information from <paramref name="sessionMgr"/></param>
        /// <returns>Returns the unique ID, if found. Else, returns Guid.Empty</returns>
        public static Guid GetFolderID(string folderName,
                                       ISessionManagement sessionMgr,
                                       SessionManagement46.AuthenticationInfo sessionAuth)
        {
            if (folderName != "")
            {
                // if the foldername is a guid, trust it literally
                Guid folderId;
                if (Guid.TryParse(folderName, out folderId))
                {
                    return(folderId);
                }

                // otherwise use the sessionmanagement api
                SessionManagement46.Pagination pagination = new SessionManagement46.Pagination()
                {
                    MaxNumberResults = 10,
                    PageNumber       = 0
                };
                ListFoldersRequest request = new ListFoldersRequest()
                {
                    Pagination     = pagination,
                    ParentFolderId = Guid.Empty,
                    SortBy         = FolderSortField.Relavance
                };
                // try to get the folder up to 3 times
                ListFoldersResponse response = null;
                for (int retries = 0; retries < 3; retries++)
                {
                    try
                    {
                        // Add quotes here to search for exact folder name
                        response = sessionMgr.GetFoldersList(sessionAuth, request, "\"" + folderName + "\"");
                        break;
                    }
                    catch
                    {
                        // catch the FaultException if the request times out.
                    }
                }
                // if the response is null, then the GetFoldersList request has failed all retry attempts.
                // By returning Guid.Empty, the validation process of a ScheduleRecording will catch it as a generic
                // RecordingValidity.BadFolderID error code. A more descriptive error code can be considered such as
                // RecordingValidityCode.TimeOutError, and this would have to throw an exception or return a special
                // Guid to differentiate it from a regular RecordingValidityCode.BadFolderID (ie a Guid with all 1s)
                if (response == null)
                {
                    // This is the timeout case, maybe have a special reserved Guid to reflect this.
                    return(Guid.Empty);
                }
                // we check the number of results and if there is more than 1 result/match then
                // folder name is ambiguous (not unique) and so return Guid.Empty
                if (response.Results.Length == 1)
                {
                    return(response.Results[0].Id);
                }
                else
                {
                    Console.WriteLine(
                        "{0} results for {1}: {2}",
                        response.Results.Length,
                        folderName,
                        response.Results.Length > 0
                                ? string.Join("\n\t", response.Results.Select(f => f.Name))
                                : "");
                    return(Guid.Empty);
                }
            }
            return(Guid.Empty);
        }