public static void CreateTag(Label label) { Log.Info(string.Format("Creating Tag for label {0}", label.actionString)); RunCommand("tag", label.date, "-a", label.Tag, "-m", "\"" + label.actionString.Replace("\\", "\\\\") + "\""); }
public static Label[] GetLabelHistory() { Log.Info("Getting Vault label history"); List<string> args = new List<string>(); if (!string.IsNullOrWhiteSpace(Program.options.StartDate)) { args.Add("-begindate"); args.Add("\"" + Program.options.StartDate + "\""); } if (!string.IsNullOrWhiteSpace(Program.options.EndDate)) { args.Add("-enddate"); args.Add("\"" + Program.options.EndDate + "\""); } args.Add(" -rowlimit"); args.Add("0"); args.Add(" -datesort"); args.Add("asc"); args.Add(" -includeactions"); args.Add("label"); args.Add("\"" + Program.options.VaultRepoPath + "\""); string output = RunCommand("history", args.ToArray()); List<Label> labels = new List<Label>(); XmlDocument xml = new XmlDocument(); xml.LoadXml(output); DateTime? startdate = string.IsNullOrEmpty(Program.options.StartDate) ? (DateTime?)null : DateTime.Parse(Program.options.StartDate); DateTime? enddate = string.IsNullOrEmpty(Program.options.EndDate) ? (DateTime?)null : DateTime.Parse(Program.options.EndDate); foreach (XmlNode node in xml.DocumentElement.SelectNodes("//vault/history/item")) { if (node.NodeType != XmlNodeType.Element) { continue; } XmlElement element = node as XmlElement; if (element == null) { continue; } Label label = new Label(); label.version = int.Parse(element.Attributes["version"].Value); label.date = DateTime.Parse(element.Attributes["date"].Value); label.actionString = element.Attributes["actionString"].Value; if ((startdate.HasValue && (label.date < startdate.Value)) || (enddate.HasValue && (label.date > enddate.Value))) { Log.Debug("Skipping label due to date being out of range: " + label.actionString); continue; } labels.Add(label); } // sort based on the versions numerically labels.Sort(new Comparison<Label>(delegate (Label a, Label b) { return a.version.CompareTo(b.version); })); Log.Info(string.Format("{0} labels loaded", labels.Count)); foreach(Label label in labels) { Log.Debug("Label: " + label.Tag + " loaded for date " + label.date.ToString()); } return labels.ToArray(); }