예제 #1
0
        public static async Task <bool> promoRightsAsync()
        {
            AcLocks locks = new AcLocks();

            if (!(await locks.initAsync(_selStreams)))
            {
                return(false);
            }

            // list them ordered by stream name then 'To' lock followed by 'From' lock
            foreach (AcLock lk in locks.OrderBy(n => n.Name).ThenByDescending(n => n.Kind))
            {
                Console.WriteLine(lk);
            }

            return(true);
        }
예제 #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);
        }
예제 #3
0
        // General program startup initialization.
        private static async Task <bool> initAsync()
        {
            // initialize our logging support so we can log errors
            if (!AcDebug.initAcLogging())
            {
                Console.WriteLine("Logging support initialization failed.");
                return(false);
            }

            // in the event of an unhandled exception, save it to our log file before the program terminates
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AcDebug.unhandledException);

            // ensure we're logged into AccuRev
            string prncpl = await AcQuery.getPrincipalAsync();

            if (String.IsNullOrEmpty(prncpl))
            {
                AcDebug.Log($"Not logged into AccuRev.{Environment.NewLine}Please login and try again.");
                return(false);
            }

            // initialize our depots list class variable from PromoRights.exe.config
            if (!initAppConfigData())
            {
                return(false);
            }

            _users = new AcUsers(null, null, includeGroupsList: true);
            _locks = new AcLocks();
            bool[] arr = await Task.WhenAll(
                _users.initAsync(),       // all users with their respective group membership list initialized
                _locks.initAsync(_depots) // locks on all streams in select depots from PromoRights.exe.config
                );

            return(arr != null && arr.All(n => n == true));
        }