public List<ITAttributeTrendAnalysis> GetITAttributeTrendAnalysis(string attName, string regName, string counName, string busTypeName, string fromDateStr, string toDateStr) { List<ITCAP> itcapList; DateTime toDate; DateTime fromDate; if (!DateTime.TryParse(fromDateStr, out fromDate)) { fromDate = DateTime.MinValue; } if (!DateTime.TryParse(toDateStr, out toDate)) { toDate = DateTime.MaxValue; } if (regName != "All") { if (busTypeName != "All") { itcapList = GetITCAPSForAttributeRegionAndBusinessType(attName, regName, counName, busTypeName, fromDate, toDate); } else { itcapList = GetITCAPSForAttributeRegion(attName, regName, counName, fromDate, toDate); } } else { if (busTypeName != "All") { itcapList = GetITCAPSForAttributeBusinessType(attName, busTypeName, fromDate, toDate); } else { itcapList = GetITCAPSForAttribute(attName, fromDate, toDate); } } List<ITAttributeTrendAnalysis> itataList = new List<ITAttributeTrendAnalysis>(); ITAttributeTrendAnalysis itata; CLIENT client; if (itcapList != null) { foreach (ITCAP itcap in itcapList) { if (itcap.ASIS.HasValue && itcap.TOBE.HasValue) { itata = new ITAttributeTrendAnalysis(); client = itcap.CLIENT; itata.Date = client.STARTDATE; itata.Country = client.COUNTRY.NAME.Trim(); itata.Region = client.COUNTRY.REGION.NAME.TrimEnd(); itata.BusinessType = client.BUSINESSTYPE.NAME.Trim(); itata.Country = itata.Region; itata.AsisScore = itcap.ASIS.Value; itata.TobeScore = itcap.TOBE.Value; itata.Name = attName; itataList.Add(itata); } } } return itataList; }
private void CreateITAttributeToTrack(string region, string country, string busi, string from, string to) { if (currentlyBeingTracked == "" || currentlyBeingTracked == "Attribute") { List<ITAttributeTrendAnalysis> attributes = new List<ITAttributeTrendAnalysis>(); attributes = db.GetITAttributeTrendAnalysis(itAttributesComboBox.Text, region, country, busi, from, to); ITAttributeTrendAnalysis ent = new ITAttributeTrendAnalysis(); if (attributes.Count > 0) { attributes.Sort((x, y) => DateTime.Compare(x.Date, y.Date)); ent.AsisScore = attributes.Average(d => d.AsisScore); ent.TobeScore = attributes.Average(d => d.TobeScore); ent.Type1 = TrendAnalysisEntity.Type.Master; ent.Name = itAttributesComboBox.Text; attributesToTrack.Add(ent); foreach (ITAttributeTrendAnalysis attr in attributes) { attr.Type1 = TrendAnalysisEntity.Type.Child; ent.Children++; attributesToTrack.Add(attr); } trendGridView.DataSource = null; trendGridView.DataSource = attributesToTrack; trendGridView.Refresh(); currentlyBeingTracked = "Attribute"; trendGridView.Columns["Collapse"].Visible = true; CreateITAttributeGraph(attributesToTrack, "Attribute", metricsComboBox.Text); } else MessageBox.Show("Query returned no results."); } else { MessageBox.Show("You can only track one entity type at a time. Please clear grid and try again."); } }