public Dictionary <string, int> GetAmountOfMessagesPerDate() { // todo Maybe the string date can be replaced with something else because now all the messages will do a tostring function Dictionary <string, int> amountOfMessagesPerDate = new Dictionary <string, int>(); // todo Cross year doensn't work MessageDateTime firstMessageDateTime = GetFirstMessageDateTime(); int year = 2000 + firstMessageDateTime.Year; for (int month = firstMessageDateTime.Month; month <= _lastMessage.DateTime.Month; month++) { int daysInMonth = DateTime.DaysInMonth(year, month); for (int i = 1; i <= daysInMonth; i++) { amountOfMessagesPerDate.Add($"{i}-{month}-{firstMessageDateTime.Year}", 0); } } foreach (KeyValuePair <string, List <Message> > keyValuePair in _messages) { if (keyValuePair.Key != "NVOK") { foreach (Message message in keyValuePair.Value) { amountOfMessagesPerDate[message.DateTime.GetDate()]++; } } } return(amountOfMessagesPerDate); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append(MessageDateTime.ToString(new CultureInfo("de-DE"))); sb.Append(Description); return(sb.ToString()); }
private void SetFirstMessageDate(MessageDateTime messageDateTime) { string hour; string minute; hour = messageDateTime.Hour < 10 ? "0" + messageDateTime.Hour : messageDateTime.Hour.ToString(); minute = messageDateTime.Minute < 10 ? "0" + messageDateTime.Minute : messageDateTime.Minute.ToString(); string dateTime = $"{messageDateTime.Day}-{messageDateTime.Month}-{messageDateTime.Year} {hour}:{minute}"; LblFirstMessage.Text = dateTime; }