/// <summary> /// recupero dati per i FP /// </summary> /// <returns>Lista dei dati relativi agli FP</returns> public static List<FP> RecuperaFP() { List<FP> fp = new List<FP>(); XmlTextReader reader = new XmlTextReader("fp_Data.xml"); while (reader.Read()) { if (reader.Name.Equals("linguaggio") && reader.NodeType.Equals(XmlNodeType.Element)) { FP tmp = new FP(); while (reader.MoveToNextAttribute()) { if (reader.Name.Equals("name")) { tmp.Linguaggio = reader.Value; } else if (reader.Name.Equals("data")) { tmp.Dato = int.Parse(reader.Value); } } fp.Add(tmp); } } reader.Close(); return fp; }
/// <summary> /// creazione WI /// </summary> /// <param name="tfs"> /// connessione tfs in oggetto /// </param> /// <param name="items"> /// lista di items, dati linguaggio /// </param> /// <param name="tp"> /// progetto in oggetto /// </param> /// <param name="cIS"> /// Configuration Item Software /// </param> public static void CreateWI(TfsTeamProjectCollection tfs, List<string> items, string tp, string cIS) { List<FP> fp = XML.RecuperaFP(); DateTime now = DateTime.Now; double totAlma = 0; double costi = double.Parse(System.Configuration.ConfigurationManager.AppSettings["ConvCost"]); List<FP> linguaggio = new List<FP>(); WorkItemStore store = tfs.GetService<WorkItemStore>(); Project proj = store.Projects[tp]; if (!proj.WorkItemTypes.Contains("QAReport")) { string xmlPath = "wit/QAReport.xml"; System.IO.StreamReader xmlStreamReader = new System.IO.StreamReader(xmlPath); System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.Load(xmlStreamReader); System.Xml.XmlElement firstElement = (System.Xml.XmlElement)xmlDoc.DocumentElement; proj.WorkItemTypes.Import(firstElement); } store.RefreshCache(true); proj = store.Projects[tp]; WorkItemType type = proj.WorkItemTypes["QAReport"]; WorkItem workItem = new WorkItem(type); workItem["Title"] = cIS + " " + now; //workItem["CISoftware"] = cIS; workItem["DataD"] = now; CSCount csc = TFS.AllChangeset(tfs, tp); workItem["NChangeset"] = csc.NonAssociato; workItem["AllChangeset"] = csc.All; int i = 0; if (items.Count == 0) { workItem["DescrizioneHtml"] = "<table width='100%'><tr><th style='border-bottom:1px solid black'>Data</th><th style='border-bottom:1px solid black'>Linguaggio</th><th style='border-bottom:1px solid black'>Nr Files</th><th style='border-bottom:1px solid black'>Righe di Codice</th><th style='border-bottom:1px solid black'>Utenti</th></tr><tr>"; } else { workItem["DescrizioneHtml"] = "<table width='100%'><tr><th style='border-bottom:1px solid black'>Data</th><th style='border-bottom:1px solid black'>Linguaggio</th><th style='border-bottom:1px solid black'>Nr Files</th><th style='border-bottom:1px solid black'>Righe di Codice</th><th style='border-bottom:1px solid black'>Utenti</th></tr><tr>"; FP tmp = new FP(); foreach (string item in items) { if (i == 5) { i = 0; workItem["DescrizioneHtml"] += "</tr><tr>"; } if (i == 1) { tmp.Linguaggio = item; } if (i == 3) { tmp.Dato = int.Parse(item); totAlma += tmp.Dato; } workItem["DescrizioneHtml"] += "<td style='border-bottom:1px solid black'>" + item + "</td>"; // workItem.Attachments.Add(new Attachment("")); i++; if (i == 5) { linguaggio.Add(tmp); tmp = new FP(); } } workItem["DescrizioneHtml"] += "</tr></table>"; double valoreFP = XML.AnalisiFP(linguaggio, fp); workItem["FP"] = valoreFP; workItem["ValoreCustom"] = totAlma; workItem["FP Totali"] = FPTotali; workItem["Valore Totale"] = CostiTotali; workItem["ControlloTask"] = TFS.ControlloTask(tfs, tp).ToString(); workItem["ControlloSprint"] = TFS.ControlloSprint(tfs, tp).ToString(); if (TFS.CsNoWI.Count != 0) { workItem["DescrizioneChange"] = "<table width='100%'><tr><th style='border-bottom:1px solid black'>ChangesetID</th><th style='border-bottom:1px solid black'>User</th><th style='border-bottom:1px solid black'>Data Creazione</th><th style='border-bottom:1px solid black'>Commento</th></tr>"; foreach (Change_Data item in TFS.CsNoWI) { workItem["DescrizioneChange"] += "<tr>"; workItem["DescrizioneChange"] += "<td style='border-bottom:1px solid black'><A href='" + tfs.Uri.AbsolutePath + "web/UI/Pages/Scc/ViewChangeset.aspx?changeset=" + item.Id + "'>" + item.Id + "</A></td>"; workItem["DescrizioneChange"] += "<td style='border-bottom:1px solid black'>" + item.User + "</td>"; workItem["DescrizioneChange"] += "<td style='border-bottom:1px solid black'>" + item.Data + "</td>"; if (string.IsNullOrEmpty(item.Comment)) { workItem["DescrizioneChange"] += "<td style='border-bottom:1px solid black'> -- </td>"; } else { workItem["DescrizioneChange"] += "<td style='border-bottom:1px solid black'>" + item.Comment + "</td>"; } workItem["DescrizioneChange"] += "</tr>"; } workItem["DescrizioneChange"] += "</table>"; } } Array result = workItem.Validate().ToArray(); try { workItem.Save(); } catch (Exception e) { Logger.Error(new LogInfo(System.Reflection.MethodBase.GetCurrentMethod(), "INT", string.Format("errore creazione WI: {0}", e.Message))); throw e; } FPTotali = 0; CostiTotali = 0; }
/// <summary> /// metodo di controllo dei totali(FP e Costi) /// </summary> public static void ControlloTotali() { string repDir = System.Configuration.ConfigurationManager.AppSettings["repDir"]; DirectoryInfo dinfo = Directory.CreateDirectory(repDir); List<string> pass = new List<string>(); var elenco = dinfo.EnumerateFiles("*.xml", SearchOption.AllDirectories); foreach (FileInfo f in elenco) { using (XmlTextReader reader = new XmlTextReader(f.FullName)) { while (reader.Read()) { if (reader.Name.Equals("language") && reader.NodeType.Equals(XmlNodeType.Element)) { int inizio = f.Name.IndexOf("#") + 1; int fine = f.Name.Length - 4; pass.Add(f.Name.Substring(inizio, fine - inizio)); while (reader.MoveToNextAttribute()) { if (reader.Name.Equals("name") || reader.Name.Equals("files_count") || reader.Name.Equals("code")) { pass.Add(reader.Value); } } } } } double totLine = 0; List<FP> fp = XML.RecuperaFP(); double costi = double.Parse(System.Configuration.ConfigurationManager.AppSettings["ConvCost"]); List<FP> linguaggio = new List<FP>(); FP tmp = new FP(); int i = 0; foreach (string item in pass) { if (i == 4) { i = 0; } if (i == 1) { tmp.Linguaggio = item; } if (i == 3) { tmp.Dato = int.Parse(item); totLine += tmp.Dato; } i++; if (i == 4) { linguaggio.Add(tmp); tmp = new FP(); } } double valoreFP = AnalisiFP(linguaggio, fp); TFS.FPTotali = valoreFP; TFS.CostiTotali = totLine; } }