private ItemContainer GetContainterByDate(DateTime date, ItemContainer container) { if (container.Count() == 0 || date == DateTime.Today) { return(container); } ItemContainer ch = (ItemContainer)container.GetChild(0); TimeSpan ts = DateTime.Today - date; for (int i = 0; i < ts.Days - 1 && ch.Count() > 0; i++) { ch = (ItemContainer)ch.GetChild(0); } return(ch); }
public override void BrowseMetadata(XmlWriter writer, string idParams, string host, HashSet <string> filterSet) { if (string.IsNullOrEmpty(idParams)) { base.BrowseMetadata(writer, idParams, host, filterSet); } else { var aids = idParams.Split("_".ToCharArray(), 2, StringSplitOptions.RemoveEmptyEntries); var chdt = aids[0].Split("|".ToCharArray()); DateTime date = DateTime.Today; if (chdt.Length > 1) { date = DateTime.Parse(chdt[1] ?? DateTime.Today.ToShortDateString()); } if (_childItems.Count == 0) { UpdateChannels(); TimeSpan ts = DateTime.Today - date; for (int i = 0; i <= ts.Days; i++) { UpdateRecords(DateTime.Today.AddDays(-1 * i), host, int.Parse(chdt[0])); } } string root = chdt[0] + "|" + DateTime.Today.ToShortDateString(); ItemContainer container = (_childItems.First(item => item.Id.Split("_".ToCharArray())[0] == root) as ItemContainer); container = GetContainterByDate(date, container); if (aids.Length < 2) { container.BrowseMetadata(writer, string.Empty, host, filterSet); } else { container.GetChild(aids[1]).BrowseMetadata(writer, string.Empty, host, filterSet); } //_childItems.First(item => item.Id == aids[0]).BrowseMetadata(writer, aids.Length > 1 ? aids[1] : string.Empty, host, filterSet); } }
private ItemContainer GetContainterByDate(DateTime date, ItemContainer container) { if (container.Count() == 0 || date == DateTime.Today) return container; ItemContainer ch = (ItemContainer)container.GetChild(0); TimeSpan ts = DateTime.Today - date; for (int i = 0; i < ts.Days - 1 && ch.Count() > 0; i++) { ch = (ItemContainer) ch.GetChild(0); } return ch; }