/// <summary> /// Updates the mention, trend or SIR lists according to the message type. /// </summary> /// <param name="message"></param> private void UpdateLists(Message message) { // Update the relevant lists switch (message.MessageType) { case "E": URLList.Clear(); foreach (var item in processor.QuarantinedLinks) { URLList.Add("Link: " + item.Key.ToString() + "\nCount: " + item.Value.ToString()); } Email email = (Email)message; if (email.EmailType == "SIR") { SIRList.Clear(); SIR sir = (SIR)email; // Loop through SIRList and Add new instances foreach (var item in processor.SirList) { SIRList.Add("Sort Code: " + item.Key.ToString() + "\nCount: " + item.Value.ToString()); } } break; case "T": MentionList.Clear(); TrendList.Clear(); foreach (var item in processor.MentionsList) { MentionList.Add("Mention: " + item.Key.ToString() + "\nCount: " + item.Value.ToString()); } foreach (var item in processor.TrendingList) { TrendList.Add("Trend: " + item.Key.ToString() + "\nCount : " + item.Value.ToString()); } break; default: break; } }
public void CreateGraph(string comboboxInput, string timePeriod) { TrendList.Clear(); DateTime tempDayOfScheduleList = CompleteControlSchedulesList[0].Time; int timeHorizon = 0; int timeHorizonDivider = 0; DateTime currentItemDate = DateTime.Now; ConstantValues constantValues = new ConstantValues(); double minValue = 0; double maxValue = 0; if (timePeriod == "En Uge") { timeHorizon = 7; timeHorizonDivider = 1; } else if (timePeriod == "En Måned") { timeHorizon = 30; timeHorizonDivider = 3; } else if (timePeriod == "Et Kvartal") { timeHorizon = 91; timeHorizonDivider = 10; } else if (timePeriod == "Et År") { timeHorizon = 365; timeHorizonDivider = 30; } int amountOfItemsWithSameDate = 0; double tempTotalValue = 0; for (int i = 0; i < CompleteControlSchedulesList.Count; i++) { if (CompleteControlSchedulesList[i].Time >= DateTime.Now - new TimeSpan(timeHorizon, 0, 0, 0) && CompleteControlSchedulesList[i].Time <= DateTime.Now) { currentItemDate = CompleteControlSchedulesList[i].Time.Subtract(new TimeSpan(0, CompleteControlSchedulesList[i].Time.Hour, CompleteControlSchedulesList[i].Time.Minute, CompleteControlSchedulesList[i].Time.Second)); here: if (tempDayOfScheduleList <= currentItemDate + new TimeSpan(timeHorizonDivider, 0, 0, 0) && tempDayOfScheduleList >= currentItemDate) { amountOfItemsWithSameDate++; if (comboboxInput == "Vægt") { //todo check om weight er null selvom den ikke burde være tempTotalValue += (double)CompleteControlSchedulesList[i].Weight; minValue = constantValues.MinWeight; maxValue = constantValues.MaxWeight; } else if (comboboxInput == "MipMa") { tempTotalValue += (double)CompleteControlSchedulesList[i].MipMa; minValue = constantValues.MinMipMa; maxValue = constantValues.MaxMipMa; } else if (comboboxInput == "Lud Koncentration") { tempTotalValue += (double)CompleteControlSchedulesList[i].LudKoncentration; minValue = constantValues.MinLudkoncentration; maxValue = constantValues.MaxLudkoncentration; } continue; } if (amountOfItemsWithSameDate != 0) { TrendList.Add(new Trends(tempTotalValue / amountOfItemsWithSameDate, currentItemDate.Year + "/" + currentItemDate.Month + "/" + tempDayOfScheduleList.Day, minValue, maxValue)); } tempTotalValue = 0; amountOfItemsWithSameDate = 0; if (new TimeSpan(timeHorizonDivider, 0, 0, 0) <= currentItemDate - tempDayOfScheduleList) { tempDayOfScheduleList = currentItemDate; goto here; } } } if (amountOfItemsWithSameDate != 0) { TrendList.Add(new Trends(tempTotalValue / amountOfItemsWithSameDate, currentItemDate.Year + "/" + currentItemDate.Month + "/" + tempDayOfScheduleList.Day, minValue, maxValue)); } }