コード例 #1
0
ファイル: DBManager.cs プロジェクト: hanlonal/CSE4982013
        public List<ImperativeTrendAnalysis> GetImperativeTrendAnalysis(string iniName, string regName, string counName, string busTypeName, string fromDateStr, string toDateStr)
        {
            List<BOM> bomList;
            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")
                {
                    bomList = GetBOMSForImperativeRegionAndBusinessType(iniName, regName, counName, busTypeName, fromDate, toDate);
                }

                else
                {
                    bomList = GetBOMSForImperativeRegion(iniName, regName, counName, fromDate, toDate);
                }
            }

            else
            {
                if (busTypeName != "All")
                {
                    bomList = GetBOMSForImperativeBusinessType(iniName, busTypeName, fromDate, toDate);
                }

                else
                {
                    bomList = GetBOMSForImperative(iniName, fromDate, toDate);
                }
            }

            List<ImperativeTrendAnalysis> itaList = new List<ImperativeTrendAnalysis>();
            ImperativeTrendAnalysis ita;
            CLIENT client;
            foreach (BOM bom in bomList)
            {
                if (bom.EFFECTIVENESS.HasValue && bom.CRITICALITY.HasValue && bom.DIFFERENTIAL.HasValue)
                {
                    ita = new ImperativeTrendAnalysis();
                    client = bom.CLIENT;
                    ita.Date = client.STARTDATE;
                    ita.Region = client.COUNTRY.REGION.NAME.TrimEnd();
                    ita.Country = client.COUNTRY.NAME.TrimEnd();
                    ita.BusinessType = client.BUSINESSTYPE.NAME.TrimEnd();
                    ita.Country = ita.Region;
                    ita.Effectiveness = bom.EFFECTIVENESS.Value;
                    ita.Criticality = bom.CRITICALITY.Value;
                    ita.Differentiation = bom.DIFFERENTIAL.Value;
                    ita.Name = iniName;
                    itaList.Add(ita);
                }
            }

            return itaList;
        }
コード例 #2
0
ファイル: AnalyticsForm.cs プロジェクト: hanlonal/CSE4982013
        private void CreateImperativeToTrack(string region, string country, string business, string from, string to)
        {
            if (currentlyBeingTracked == "" || currentlyBeingTracked == "Imperative")
            {
                List<ImperativeTrendAnalysis> imperatives = new List<ImperativeTrendAnalysis>();
                imperatives = db.GetImperativeTrendAnalysis(imperativesComboBox.Text, region, country, business, from, to);
                ImperativeTrendAnalysis init = new ImperativeTrendAnalysis();

                if (imperatives.Count > 0)
                {
                    imperatives.Sort((x, y) => DateTime.Compare(x.Date, y.Date));
                    float diff = imperatives.Average(d => d.Differentiation);
                    float crit = imperatives.Average(d => d.Criticality);
                    float effect = imperatives.Average(d => d.Effectiveness);

                    init.Effectiveness = effect;
                    init.Criticality = crit;
                    init.Country = "All";
                    init.Differentiation = diff;
                    init.BusinessType = business;
                    init.Region = region;
                    init.Name = imperativesComboBox.Text;
                    init.Type1 = TrendAnalysisEntity.Type.Master;
                    imperativesToTrack.Add(init);
                    foreach (ImperativeTrendAnalysis i in imperatives)
                    {
                        init.Children++;
                        i.Type1 = TrendAnalysisEntity.Type.Child;
                        imperativesToTrack.Add(i);
                    }

                    trendGridView.Columns["Collapse"].Visible = true;
                }
                else
                    MessageBox.Show("Query did not return any results");
                trendGridView.DataSource = null;
                trendGridView.DataSource = imperativesToTrack;
                trendGridView.Refresh();
                currentlyBeingTracked = "Imperative";

                if (metricsComboBox.Enabled)
                {
                    testingLabel.Text = metricsComboBox.Text;
                    CreateLineGraph(imperativesToTrack, "Imperatives", metricsComboBox.Text);
                }

                CreateLineGraph(imperativesToTrack, "Imperatives", "");
            }
            else
            {
                MessageBox.Show("You can only track one entity type at a time. Please clear grid and try again.");
            }
        }