Exemple #1
0
        public DateTime UpdateRecords(DateTime date, string host, int rec_id = 0)
        {
            if (_lastUpdate + _maxAge < DateTime.Now)
            {
                if (_childItems.Count == 0)
                {
                    UpdateChannels();
                }
                var ch = (ItemContainer)_childItems.Find(item => item.Id.Split("|".ToCharArray())[0] == rec_id.ToString());
                if (date != DateTime.Today)
                {
                    ch = GetContainterByDate(date, ch);
                }
                ch.ClearChild();
                date = ((DateTime)ch.Tag).Date;
                var records = new TTVApi.ArcRecords(rec_id, date).Run(_device.Proxy.SessionState.session);
                if (!records.IsSuccess && records.Error == TTVApi.ApiError.incorrect)
                {
                    while (!_device.Proxy.Login() || _device.Proxy.SessionState.Error == TTVApi.ApiError.noconnect)
                    {
                    }
                    if (!_device.Proxy.SessionState.IsSuccess)
                    {
                        throw new Exception("No authorized");
                    }
                }
                if (!records.IsSuccess && records.Error == TTVApi.ApiError.norecord && date != DateTime.Today)
                {
                    return(date);
                }
                var bufdate = date.AddDays(-1);
                ch.AddChild(new ItemContainer(ch, _device)
                {
                    Type     = MediaType.Video,
                    IconUrl  = ch.IconUrl,
                    Id       = rec_id + "|" + bufdate.ToShortDateString(),
                    Title    = bufdate.ToShortDateString(),
                    ParentId = ParentId + "_" + Id,
                    Tag      = bufdate.AddTicks(1)
                });

                foreach (var rec in records.records)
                {
                    ItemStream itemrec = new ItemStream(ch, MediaType.Video, _device)
                    {
                        Type       = MediaType.Video,
                        IconUrl    = ch.IconUrl,
                        Id         = rec.record_id.ToString(),
                        Title      = String.Format("[{0}]{1}", rec.Time.ToShortTimeString(), rec.name),
                        ParentId   = ch.GetIds(),
                        Tag        = rec.Time.AddSeconds(1),
                        ContentUrl = String.Format("{0}/archive/play?id={1}", host, rec.record_id)
                    };
                    ch.AddChild(itemrec);
                }
            }
            return(date);
        }
Exemple #2
0
        public DateTime UpdateRecords(DateTime date, string host, int rec_id = 0)
        {
            if (_lastUpdate + _maxAge < DateTime.Now)
            {
                if (_childItems.Count == 0)
                    UpdateChannels();
                var ch = (ItemContainer)_childItems.Find(item => item.Id.Split("|".ToCharArray())[0] == rec_id.ToString());
                if (date != DateTime.Today)
                {
                    ch = GetContainterByDate(date, ch);
                }
                ch.ClearChild();
                date = ((DateTime) ch.Tag).Date;
                var records = new TTVApi.ArcRecords(rec_id, date).Run(_device.Proxy.SessionState.session);
                if (!records.IsSuccess && records.Error == TTVApi.ApiError.incorrect)
                {
                    while (!_device.Proxy.Login() || _device.Proxy.SessionState.Error == TTVApi.ApiError.noconnect)
                    {

                    }
                    if (!_device.Proxy.SessionState.IsSuccess)
                        throw new Exception("No authorized");
                }
                if (!records.IsSuccess && records.Error == TTVApi.ApiError.norecord && date != DateTime.Today)
                    return date;
                var bufdate = date.AddDays(-1);
                ch.AddChild(new ItemContainer(ch, _device)
                                {
                                    Type = MediaType.Video,
                                    IconUrl = ch.IconUrl,
                                    Id = rec_id + "|" + bufdate.ToShortDateString(),
                                    Title = bufdate.ToShortDateString(),
                                    ParentId = ParentId + "_" + Id,
                                    Tag = bufdate.AddTicks(1)
                                });
               
                foreach (var rec in records.records)
                {
                    
                    ItemStream itemrec = new ItemStream(ch, MediaType.Video, _device)
                    {
                        Type = MediaType.Video,
                        IconUrl = ch.IconUrl,
                        Id = rec.record_id.ToString(),
                        Title = String.Format("[{0}]{1}", rec.Time.ToShortTimeString(), rec.name),
                        ParentId = ch.GetIds(),
                        Tag = rec.Time.AddSeconds(1),
                        ContentUrl = String.Format("{0}/archive/play?id={1}", host, rec.record_id)
                    };
                    ch.AddChild(itemrec);
                }
            }
            return date;
        }