Пример #1
0
        public static async Task <bool> streamWkspaceMismatchAsync()
        {
            bool ret = false; // assume failure

            try
            {
                // all streams and not just dynamic, include hidden streams
                AcDepots depots = new AcDepots(dynamicOnly: false, includeHidden: true);
                if (!(await depots.initAsync()))
                {
                    return(false);
                }

                // all workspaces (not just the script user), include hidden workspaces
                AcWorkspaces wkspaces = new AcWorkspaces(depots, allWSpaces: true, includeHidden: true);
                if (!(await wkspaces.initAsync()))
                {
                    return(false);
                }

                foreach (AcDepot depot in depots.OrderBy(n => n))
                {
                    var query = from AcStream s in depot.Streams
                                join AcWorkspace w in wkspaces on s.Depot equals w.Depot
                                where w.ID == s.ID && !string.Equals(s.Name, w.Name) // stream ID's equal but names don't
                                orderby w.Name
                                select new
                    {
                        Hidden        = w.Hidden,
                        WorkspaceName = w.Name,
                        StreamName    = s.Name
                    };

                    foreach (var f in query)
                    {
                        Console.WriteLine($"{(f.Hidden ? "Hidden" : "Visible")} wspace: {f.WorkspaceName}, stream: {f.StreamName}");
                    }
                }

                ret = true; // operation succeeded
            }

            catch (Exception ecx)
            {
                Console.WriteLine($"Exception caught and logged in Program.streamWkspaceMismatchAsync{Environment.NewLine}{ecx.Message}");
            }

            return(ret);
        }
Пример #2
0
        public static async Task <bool> lockStreamsAsync()
        {
            // set 'To' lock on dynamic streams in select depots that have these strings in their name
            var selStreams = new[] { "DEV2", "UAT" };

            // lock for all except those in DEV_LEAD group
            AcGroups groups = new AcGroups();

            if (!(await groups.initAsync()))
            {
                return(false);
            }
            AcPrincipal group = groups.getPrincipal("DEV_LEAD");

            if (group == null)
            {
                return(false);
            }

            AcDepots depots = new AcDepots(dynamicOnly: true); // dynamic streams only in select depots

            if (!(await depots.initAsync(_selDepots)))
            {
                return(false);
            }
            foreach (AcDepot depot in depots.OrderBy(n => n)) // use default sort ordering
            {
                AcLocks locks = new AcLocks();
                if (!(await locks.initAsync(depot)))
                {
                    return(false);
                }

                IEnumerable <AcStream> filter = depot.Streams.Where(n => selStreams.Any(s => n.Name.Contains(s)));
                foreach (AcStream stream in filter.OrderBy(n => n)) // ..
                {
                    bool ret = await locks.lockAsync(stream.Name, "Authorized users only", LockKind.to, group);

                    Console.WriteLine($@"{stream} ""{LockKind.to}"" lock {(ret ? "succeeded" : "failed")}");
                }
            }

            return(true);
        }