// Initialize our class variables from EvilTwins.exe.config.
        // Returns true if variables were successfully initialized, false otherwise.
        // ConfigurationErrorsException caught and logged in
        // %LOCALAPPDATA%\AcTools\Logs\EvilTwins-YYYY-MM-DD.log on initialization failure.
        private static bool initAppConfigData()
        {
            bool ret = true; // assume success

            try
            {
                _twinsExcludeFile = AcQuery.getAppConfigSetting <string>("TwinsExcludeFile").Trim();
                DepotsSection depotsConfigSection = ConfigurationManager.GetSection("Depots") as DepotsSection;
                if (depotsConfigSection == null)
                {
                    AcDebug.Log("Error in Program.initAppConfigData creating DepotsSection");
                    ret = false;
                }
                else
                {
                    _selDepots = depotsConfigSection.Depots;
                }
            }

            catch (ConfigurationErrorsException exc)
            {
                Process       currentProcess = Process.GetCurrentProcess();
                ProcessModule pm             = currentProcess.MainModule;
                AcDebug.Log($"Invalid data in {pm.ModuleName}.config{Environment.NewLine}{exc.Message}");
                ret = false;
            }

            return(ret);
        }
Beispiel #2
0
        // General program startup initialization routines.
        // Returns true if initialization was successful, false otherwise.
        private static bool init()
        {
            // initialize logging support for reporting program 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 Stranded.exe.config
            if (!initAppConfigData())
            {
                return(false);
            }
            // initialize our logging support to log stranded elements found
            if (!initStrandedFoundLogging())
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        // Initialize our class variables with values from LatestPromotions.exe.config. Returns true if all values
        // successfully read and class variables initialized, false otherwise. ConfigurationErrorsException caught
        // and logged in %LOCALAPPDATA%\AcTools\Logs\LatestPromotions-YYYY-MM-DD.log on initialization failure.
        private static bool initAppConfigData()
        {
            bool ret = true; // assume success

            try
            {
                _fromHoursAgo = AcQuery.getAppConfigSetting <int>("FromHoursAgo");
                _outputFile   = AcQuery.getAppConfigSetting <string>("OutputFile").Trim();

                ADSection adSection = ConfigurationManager.GetSection("activeDir") as ADSection;
                if (adSection == null)
                {
                    AcDebug.Log("Error in Program.initAppConfigData creating ADSection");
                    ret = false;
                }
                else
                {
                    _domains    = adSection.Domains;
                    _properties = adSection.Props;
                }

                DepotsSection depotsConfigSection = ConfigurationManager.GetSection("Depots") as DepotsSection;
                if (depotsConfigSection == null)
                {
                    AcDebug.Log("Error in Program.initAppConfigData creating DepotsSection");
                    ret = false;
                }
                else
                {
                    _selDepots = depotsConfigSection.Depots;
                }

                StreamsSection streamsConfigSection = ConfigurationManager.GetSection("Streams") as StreamsSection;
                if (streamsConfigSection == null)
                {
                    AcDebug.Log("Error in Program.initAppConfigData creating StreamsSection");
                    ret = false;
                }
                else
                {
                    _selStreams = streamsConfigSection.Streams;
                }
            }

            catch (ConfigurationErrorsException exc)
            {
                Process       currentProcess = Process.GetCurrentProcess();
                ProcessModule pm             = currentProcess.MainModule;
                AcDebug.Log($"Invalid data in {pm.ModuleName}.config{Environment.NewLine}{exc.Message}");
                ret = false;
            }

            return(ret);
        }
Beispiel #4
0
        // Get the list of triggers created with the mktrig command for the specified
        // depots. Returns Triggers object on success, otherwise null on error.
        private async static Task <Triggers> getTriggersAsync()
        {
            List <string> depots = await AcQuery.getDepotNameListAsync(); // names of all depots in repository

            if (depots == null)
            {
                return(null);
            }
            Triggers triggers = new Triggers(depots);

            return((await triggers.initAsync()) ? triggers : null);
        }
Beispiel #5
0
        // 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);
        }
Beispiel #7
0
        // Initialize our class variables from LatestTransactions.exe.config. Returns true if class variables
        // initialized successfully, false otherwise. ConfigurationErrorsException caught and logged in
        // %LOCALAPPDATA%\AcTools\Logs\LatestTransactions-YYYY-MM-DD.log on initialization failure.
        private static bool initAppConfigData()
        {
            bool ret = false; // assume failure

            try
            {
                _fileName     = AcQuery.getAppConfigSetting <string>("FileName").Trim();
                _fileLocation = AcQuery.getAppConfigSetting <string>("FileLocation").Trim();
                ret           = true;
            }

            catch (ConfigurationErrorsException exc)
            {
                Process       currentProcess = Process.GetCurrentProcess();
                ProcessModule pm             = currentProcess.MainModule;
                AcDebug.Log($"Invalid data in {pm.ModuleName}.config{Environment.NewLine}{exc.Message}");
            }

            return(ret);
        }
        // General program startup initialization. Returns true if the operation succeeded, false otherwise.
        private static bool init()
        {
            try
            {
                // ensure we're logged into AccuRev
                Task<string> prncpl = AcQuery.getPrincipalAsync();
                if (String.IsNullOrEmpty(prncpl.Result))
                {
                    Console.WriteLine($"Not logged into AccuRev.{Environment.NewLine}Please login and try again.");
                    return false;
                }

                if (!isCurrDirInWSpace())
                {
                    Console.WriteLine($"No workspace found for location {Environment.CurrentDirectory}");
                    return false;
                }

                char[] sep = new char[] { };
                string temp = AcQuery.getAppConfigSetting<string>("SkipOver").Trim();
                if (!String.IsNullOrEmpty(temp))
                    _skipOver = temp.Split(sep);
                else
                    _skipOver = new string[] { };
            }

            catch (ConfigurationErrorsException exc)
            {
                Process currentProcess = Process.GetCurrentProcess();
                ProcessModule pm = currentProcess.MainModule;
                Console.WriteLine($"Invalid data in {pm.ModuleName}.config{Environment.NewLine}{exc.Message}");
            }

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

            return true;
        }
        // Initialize our ElementType array class variable with values from XLinked.exe.config.
        // Returns true if successfully read and initialized, false otherwise. ConfigurationErrorsException
        // caught and logged in %LOCALAPPDATA%\AcTools\Logs\XLinked-YYYY-MM-DD.log on initialization failure.
        private static bool initAppConfigData()
        {
            bool ret = false; // assume failure

            try
            {
                string[] arr = AcQuery.getAppConfigSetting <string>("ElementTypes")
                               .Split(',').Select(s => s.Trim()).ToArray();
                _etypes = Array.ConvertAll(arr, new Converter <string, ElementType>(n =>
                                                                                    (ElementType)Enum.Parse(typeof(ElementType), n)));
                ret = true;
            }

            catch (ConfigurationErrorsException exc)
            {
                Process       currentProcess = Process.GetCurrentProcess();
                ProcessModule pm             = currentProcess.MainModule;
                AcDebug.Log($"Invalid data in {pm.ModuleName}.config{Environment.NewLine}{exc.Message}");
            }

            return(ret);
        }
        // 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);
            }

            // 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 ElementType array class variable from XLinked.exe.config
            if (!initAppConfigData())
            {
                return(false);
            }

            _depots = new AcDepots(dynamicOnly: true); // dynamic streams only
            Task <bool> dini = _depots.initAsync();

            if (!dini.Result)
            {
                AcDebug.Log($"Depots list initialization failed. See log file:{Environment.NewLine}" +
                            $"{AcDebug.getLogFile()}");
                return(false);
            }

            return(true);
        }
        // General program startup initialization. Returns true if initialization was successful, 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);
            }

            // 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 depots list class variable with select depots from WSpaceTransLevel.exe.config
            if (!initAppConfigData())
            {
                return(false);
            }

            // initialize our workspaces list class variable
            Task <bool> wslist = initWSListAsync();

            if (!wslist.Result)
            {
                AcDebug.Log($"Workspaces list initialization failed. See log file:{Environment.NewLine}{AcDebug.getLogFile()}");
                return(false);
            }

            return(true);
        }
Beispiel #12
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));
        }
Beispiel #13
0
        // General program initialization routines. Returns true if initialization was successful, 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);
            }

            // 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 LatestTransactions.exe.config
            if (!initAppConfigData())
            {
                return(false);
            }

            // list of all depot names in the repository
            _depots = AcQuery.getDepotNameListAsync().Result;
            if (_depots == null)
            {
                return(false);
            }

            return(true);
        }
Beispiel #14
0
        public static async Task <bool> userChangesAsync(string user, string startTime, string endTime)
        {
            Console.WriteLine($@"User: {user}, ""{startTime} - {endTime}""{Environment.NewLine}");
            List <string> depots = await AcQuery.getDepotNameListAsync();

            if (depots == null)
            {
                return(false);                // operation failed, check log file
            }
            foreach (string depot in depots)
            {
                // start-end times reversed as workaround for AccuRev issue 15780
                string   time = $"{endTime} - {startTime}";
                AcResult r1   = await AcCommand.runAsync($@"hist -p ""{depot}"" -t ""{time}"" -u ""{user}"" -k keep -fx");

                if (r1 == null || r1.RetVal != 0)
                {
                    return(false);                              // operation failed
                }
                XElement x1 = XElement.Parse(r1.CmdResult);
                foreach (XElement t in x1.Elements("transaction"))
                {
                    int    transID  = (int)t.Attribute("id");
                    string tcomment = t.acxComment();
                    Console.WriteLine($"Depot: {depot}, {{{transID}}} {(DateTime)t.acxTime("time")}" +
                                      $"{(String.IsNullOrEmpty(tcomment) ? String.Empty : ", " + tcomment)}");

                    foreach (XElement v in t.Elements("version"))
                    {
                        string path = (string)v.Attribute("path");
                        Console.WriteLine($"\tEID: {(int)v.Attribute("eid")} {path} ({(string)v.Attribute("real")})");
                        string mergedAgainstNamed = v.acxMergedAgainstNamed();
                        Console.WriteLine($"\tReal: {v.acxRealNamed()}, Ancestor: {v.acxAncestorNamed()}" +
                                          $"{(String.IsNullOrEmpty(mergedAgainstNamed) ? String.Empty : ", Merged against: " + mergedAgainstNamed)}");

                        string   realNamed = (string)v.Attribute("realNamedVersion");
                        AcResult r2        = await AcCommand.runAsync($@"annotate -v ""{realNamed}"" -fxtu ""{path}""");

                        if (r2 == null || r2.RetVal != 0)
                        {
                            return(false);                              // operation failed
                        }
                        // get this transaction from the annotate results
                        XElement x2    = XElement.Parse(r2.CmdResult);
                        XElement trans = (from a in x2.Descendants("trans")
                                          where (int)a.Attribute("number") == transID && // comparing transaction ID's
                                          (string)a.Attribute("principal_name") == user &&
                                          (string)a.Attribute("version_name") == realNamed
                                          select a).SingleOrDefault();
                        if (trans != null)
                        {
                            XElement diff = trans.Parent;                  // get diff element for this transaction from annotate results
                            foreach (XElement ln in diff.Elements("line")) // line elements are transaction element siblings
                            {
                                Console.WriteLine($"\tLine number: {(int)ln.Attribute("number")} \"{(string)ln.Attribute("type")}\" {{{(int)ln.Attribute("trans")}}}, {(string)ln}");
                            }
                        }

                        Console.WriteLine();
                    }
                }
            }

            return(true);
        }