// General program startup initialization. private static bool init() { // initialize our logging support so we can log errors if (!AcDebug.initAcLogging()) { Console.WriteLine("Logging support initialization failed."); return(false); } // save an unhandled exception in log file before program terminates AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AcDebug.unhandledException); // ensure we're logged into AccuRev Task <string> prncpl = AcQuery.getPrincipalAsync(); if (String.IsNullOrEmpty(prncpl.Result)) { AcDebug.Log($"Not logged into AccuRev.{Environment.NewLine}Please login and try again."); return(false); } // initialize our class variables from LatestPromotions.exe.config if (!initAppConfigData()) { return(false); } // dynamic streams only in select depots _depots = new AcDepots(dynamicOnly: true); Task <bool> dini = _depots.initAsync(_selDepots); // no group membership initialization, include deactivated users _users = new AcUsers(_domains, _properties, includeGroupsList: false, includeDeactivated: true); Task <bool> uini = _users.initAsync(); Task <bool[]> all = Task.WhenAll(dini, uini); // finish initializing both lists in parallel if (all == null || all.Result.Any(n => n == false)) { return(false); } return(true); }
// General program startup initialization. Returns true if initialization succeeded, false otherwise. private static bool init() { // 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 Task <string> prncpl = AcQuery.getPrincipalAsync(); if (String.IsNullOrEmpty(prncpl.Result)) { AcDebug.Log($"Not logged into AccuRev.{Environment.NewLine}Please login and try again."); return(false); } // initialize our class variables from PromoCount.exe.config if (!initAppConfigData()) { return(false); } // initialize our logging support for program results if (!initPromoCountResultsLogging()) { return(false); } _users = new AcUsers(_domains, null, includeGroupsList: false, includeDeactivated: true); _depots = new AcDepots(dynamicOnly: true); Task <bool[]> lists = Task.WhenAll(_depots.initAsync(_selDepots), _users.initAsync()); if (lists == null || lists.Result.Any(n => n == false)) { return(false); } return(true); }
public static async Task <bool> permissionsAsync() { // since the default is the list of depots the script user can view, // this is typically run by an admin so that all depots are in the list AcDepots depots = new AcDepots(dynamicOnly: true); // dynamic streams only Task <bool> dini = depots.initAsync(); // include group membership initialization for each user (slower, but it's required here) AcUsers users = new AcUsers(_domains, null, includeGroupsList: true); Task <bool> uini = users.initAsync(); // initialize both lists in parallel bool[] lists = await Task.WhenAll(dini, uini); if (lists == null || lists.Any(n => n == false)) { return(false); } // show depots for these users only var arr = new[] { "thomas", "barnyrd", "madhuri", "robert" }; IEnumerable <AcUser> filter = users.Where(n => arr.Any(user => n.Principal.Name == user)); // list depots each user has permission to access // default order comparer sorts by display name from LDAP if available, otherwise principal name foreach (AcUser user in filter.OrderBy(n => n)) { string availDepots = await depots.canViewAsync(user); if (!String.IsNullOrEmpty(availDepots)) { Console.WriteLine($"{user}{Environment.NewLine}{availDepots}{Environment.NewLine}"); } } return(true); }
// 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)); }