public List<Records> GetRecords() { Records[] recs = new Records[_records.Count]; lock (_records) { _records.CopyTo(recs); } return recs.ToList(); }
internal void Add(Channel ch, DateTime start, DateTime end, RecordStatus status, string name = "") { Records rec = new Records("http://127.0.0.1:" + _device.Web.Port, _outpath) { Id = Guid.NewGuid().ToString(), }; if (string.IsNullOrEmpty(name)) { if (ch.epg_id > 0 && end < DateTime.Today.AddDays(1).AddTicks(-1)) { var epgs = _device.RecordsProvider.GetListOfEpg(ch.epg_id); if (epgs != null && epgs.Count > 0) { var epg = epgs.FirstOrDefault( epg1 => epg1.StartTime <start.Add(start - epg1.StartTime) && epg1.EndTime> end); if (epg != null && epg.EndTime.AddMinutes(30) < end) { rec.Name = string.Format("[{0}-{1}] {2} - {3}", start.ToString("dd/MM/yy HH:mm"), end.ToString("dd/MM/yy HH:mm"), ch.name, epg.name); } } } if (string.IsNullOrEmpty(rec.Name)) { rec.Name = string.Format("[{1}-{2}] {0}", ch.name, start.ToString("dd/MM/yy HH:mm"), end.ToString("dd/MM/yy HH:mm")); } } else { rec.Name = name; } rec.Start = start; rec.End = end; rec.Status = status; rec.TorrentId = ch.id; Add(rec); }
private void LoadRecords() { _records.Clear(); XDocument xdoc; lock (_xmloc) { if (!File.Exists(P2pProxyApp.ApplicationDataFolder + "/records.xml")) { var xd = new XDocument(); xd.Add(new XElement("Records")); xd.Save(P2pProxyApp.ApplicationDataFolder + "/records.xml"); } try { xdoc = XDocument.Load(P2pProxyApp.ApplicationDataFolder + "/records.xml"); } catch (Exception) { return; } } var xRecords = xdoc.Element("Records"); if (xRecords != null) { var xrecs = xRecords.Elements("Record"); var xElements = xrecs as XElement[] ?? xrecs.ToArray(); if (xElements.Any()) { foreach (var xrec in xElements) { var rec = new Records("http://127.0.0.1:" + _device.Web.Port, _outpath); var buf = xrec.Attribute("Name"); if (buf != null) rec.Name = buf.Value; else continue; buf = xrec.Attribute("Start"); if (buf != null) rec.Start = ParseDateTime(buf.Value); else continue; buf = xrec.Attribute("End"); if (buf != null) rec.End = ParseDateTime(buf.Value); else continue; buf = xrec.Attribute("Status"); if (buf != null) rec.Status = (RecordStatus)Enum.Parse(typeof(RecordStatus), buf.Value, true); else continue; buf = xrec.Attribute("TorrentId"); if (buf != null) rec.TorrentId = Convert.ToInt32(buf.Value); else continue; buf = xrec.Attribute("Id"); if (buf != null) rec.Id = buf.Value; else continue; if (rec.Status == RecordStatus.Starting || rec.Status == RecordStatus.Pause || rec.Status == RecordStatus.Start) rec.Status = RecordStatus.Finished; if ((rec.Status == RecordStatus.Wait || rec.Status == RecordStatus.Init) && rec.End < DateTime.Now) continue; if (rec.Status == RecordStatus.Finished && !File.Exists(_outpath + "/" + rec.Id + ".ts")) continue; Add(rec); } } } }
void record_Finished(Records sender) { SaveRecords(); //string file = new Uri(Path.Combine(_outpath, sender.Id + ".ts")).LocalPath; //_device.Proxy.AddVodToVlc(sender.Id, file); }
public void Add(Records record) { lock (_records) { _records.Add(record); } record.Finished += record_Finished; if (record.Status == RecordStatus.Finished) record_Finished(record); SaveRecords(); }
internal void Add(Channel ch, DateTime start, DateTime end, RecordStatus status, string name="") { Records rec = new Records("http://127.0.0.1:" + _device.Web.Port, _outpath) { Id = Guid.NewGuid().ToString(), }; if (string.IsNullOrEmpty(name)) { if (ch.epg_id > 0 && end < DateTime.Today.AddDays(1).AddTicks(-1)) { var epgs = _device.RecordsProvider.GetListOfEpg(ch.epg_id); if (epgs != null && epgs.Count > 0) { var epg = epgs.FirstOrDefault( epg1 => epg1.StartTime < start.Add(start - epg1.StartTime) && epg1.EndTime > end); if (epg != null && epg.EndTime.AddMinutes(30) < end) { rec.Name = string.Format("[{0}-{1}] {2} - {3}", start.ToString("dd/MM/yy HH:mm"), end.ToString("dd/MM/yy HH:mm"), ch.name, epg.name); } } } if (string.IsNullOrEmpty(rec.Name)) rec.Name = string.Format("[{1}-{2}] {0}", ch.name, start.ToString("dd/MM/yy HH:mm"), end.ToString("dd/MM/yy HH:mm")); } else rec.Name = name; rec.Start = start; rec.End = end; rec.Status = status; rec.TorrentId = ch.id; Add(rec); }
private void LoadRecords() { _records.Clear(); XDocument xdoc; lock (_xmloc) { if (!File.Exists(P2pProxyApp.ApplicationDataFolder + "/records.xml")) { var xd = new XDocument(); xd.Add(new XElement("Records")); xd.Save(P2pProxyApp.ApplicationDataFolder + "/records.xml"); } try { xdoc = XDocument.Load(P2pProxyApp.ApplicationDataFolder + "/records.xml"); } catch (Exception) { return; } } var xRecords = xdoc.Element("Records"); if (xRecords != null) { var xrecs = xRecords.Elements("Record"); var xElements = xrecs as XElement[] ?? xrecs.ToArray(); if (xElements.Any()) { foreach (var xrec in xElements) { var rec = new Records("http://127.0.0.1:" + _device.Web.Port, _outpath); var buf = xrec.Attribute("Name"); if (buf != null) { rec.Name = buf.Value; } else { continue; } buf = xrec.Attribute("Start"); if (buf != null) { rec.Start = ParseDateTime(buf.Value); } else { continue; } buf = xrec.Attribute("End"); if (buf != null) { rec.End = ParseDateTime(buf.Value); } else { continue; } buf = xrec.Attribute("Status"); if (buf != null) { rec.Status = (RecordStatus)Enum.Parse(typeof(RecordStatus), buf.Value, true); } else { continue; } buf = xrec.Attribute("TorrentId"); if (buf != null) { rec.TorrentId = Convert.ToInt32(buf.Value); } else { continue; } buf = xrec.Attribute("Id"); if (buf != null) { rec.Id = buf.Value; } else { continue; } if (rec.Status == RecordStatus.Starting || rec.Status == RecordStatus.Pause || rec.Status == RecordStatus.Start) { rec.Status = RecordStatus.Finished; } if ((rec.Status == RecordStatus.Wait || rec.Status == RecordStatus.Init) && rec.End < DateTime.Now) { continue; } if (rec.Status == RecordStatus.Finished && !File.Exists(_outpath + "/" + rec.Id + ".ts")) { continue; } Add(rec); } } } }
private void FrmOnChoosed(Telecast epg, Channel ch) { Records rec = new Records("http://127.0.0.1:" + _app.Device.Web.Port, _app.Device.Records.RecordsPath) { Name = string.Format("{0}", epg.name), Id = Guid.NewGuid().ToString(), Start = epg.StartTime, End = epg.EndTime, Status = RecordStatus.Init, TorrentId = ch.id }; _app.Device.Records.Add(rec); }
private void AddRec(Records rec) { var dgvr = new DataGridViewRow {Tag = rec}; dgvr.Cells.Add(new DataGridViewImageCell()); switch (rec.Status) { case RecordStatus.Finished: dgvr.Cells[0].Value = Properties.Resources.finished; break; case RecordStatus.Pause: dgvr.Cells[0].Value = Properties.Resources.pause; break; case RecordStatus.Wait: dgvr.Cells[0].Value = Properties.Resources.waitrec; break; case RecordStatus.Start: dgvr.Cells[0].Value = Properties.Resources.record; break; case RecordStatus.Starting: dgvr.Cells[0].Value = Properties.Resources.starting; break; default: dgvr.Cells[0].Value = Properties.Resources.init; break; } dgvr.Cells.Add(new DataGridViewTextBoxCell()); dgvr.Cells[1].Value = rec.Name; dgvr.Cells.Add(new DataGridViewTextBoxCell()); dgvr.Cells[2].Value = rec.Start.ToString(); dgvr.Cells.Add(new DataGridViewTextBoxCell()); dataGridView1.Columns[2].DefaultCellStyle.Format = "G"; dgvr.Cells[3].Value = rec.End.ToString(); dataGridView1.Columns[3].DefaultCellStyle.Format = "G"; lock (dataGridView1.Rows) { dataGridView1.Rows.Add(dgvr); } }