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