private void UpdatePlaylist(MyWebRequest req)
        {

            if (_lastUpdate + _maxAge < DateTime.Now)
            {
                
                DateTime date = req.Parameters.ContainsKey("date") ? ParseDateTime(req.Parameters["date"]) : DateTime.Today;
                _channels = new ArcList().Run(_device.Proxy.SessionState.session);
                _channels.channels.RemoveAll(c => _device.Filter.Check("ttv").Find("ch" + c.id).Check());
                if (req.Parameters.ContainsKey("channel_id"))
                {
                    int channel_id = int.Parse(req.Parameters["channel_id"]);
                    var ch = _channels.channels.FirstOrDefault(c => c.epg_id == channel_id);
                    if (ch != null)
                        _records = new ArcRecords(ch == null ? 0 : ch.epg_id, date).Run(_device.Proxy.SessionState.session);
                    else
                        throw new FileNotFoundException();
                }
                else
                {
                    _records = new ArcRecords(0, date).Run(_device.Proxy.SessionState.session);
                    var groups = _records.records.GroupBy(r => r.epg_id).ToArray();
                    foreach (var kp in groups)
                    {
                        var ch = _channels.channels.Where(c => c.epg_id == kp.Key);
                        if (!ch.Any())
                            _records.records.RemoveAll(r => r.epg_id == kp.Key);
                    }
                }
                    
                    
            }

            if (!_channels.IsSuccess && !_records.IsSuccess)
            {
                if (_channels.Error == ApiError.incorrect || _channels.Error == ApiError.noconnect ||
                    _records.Error == ApiError.incorrect || _records.Error == ApiError.noconnect)
                {
                    while (!_device.Proxy.Login() || _device.Proxy.SessionState.Error == ApiError.noconnect)
                    {
                    }
                    if (!_device.Proxy.SessionState.IsSuccess)
                    {
                        throw new Exception("Ошибка подключения");
                    }
                    UpdatePlaylist(req);
                }
                else
                    switch (_records.Error)
                    {
                        case ApiError.norecord:
                            throw new Exception("Нет записей");
                        case ApiError.noconnect:
                            throw new Exception("ошибка соединения с БД");
                        case ApiError.noparam:
                            throw new Exception("ошибка входных параметров");
                    }
            }
        }
Example #2
0
 private void AddArc(string start, string end, decimal weight)
 {
     ArcList.ForEach(arc =>
     {
         if (arc.Start.Equals(start) && arc.End.Equals(end))
         {
             throw new ArgumentException("添加了重复的边!");
         }
     });
     ArcList.Add(new Arc(start, end, weight));
 }
 private void GetChannelsRequest(MyWebRequest req)
 {
     var resp = req.GetResponse();
     resp.AddHeader(HttpHeader.ContentType, WebServer.GetMime(".xml").ToString());
     var res = new ArcList().Execute(_device.Proxy.SessionState.session, TypeResult.Xml);
     XDocument xd = XDocument.Load(res);
     var xchs = xd.Root.Element("channels").Elements().ToArray();
     foreach (var xch in xchs)
     {
         if (_device.Filter.Check("ttv").Find("ch" + xch.Attribute("id").Value).Check())
             xch.Remove();
     }
     MemoryStream ms = new MemoryStream();
     xd.Save(ms);
     ms.Position = 0;
     resp.AddHeader(HttpHeader.ContentLength, ms.Length.ToString());
     resp.SendHeaders();
     ms.CopyTo(resp.GetStream());
 }
Example #4
0
        public CEntityComplexShape(
            CTableLayer layer,
            Guid ToolPk)
            : base()
        {
            PK = ToolPk;

            foreach (CEntityLine line in layer.LineList)
            {
                LineList.Add(line);
            }

            foreach (CEntityCircle circle in layer.CircleList)
            {
                CircleList.Add(circle);
            }

            foreach (CEntityArc arc in layer.ArcList)
            {
                ArcList.Add(arc);
            }
        }
        private void GetChannelsRequest(MyWebRequest req)
        {
            var resp = req.GetResponse();

            resp.AddHeader(HttpHeader.ContentType, WebServer.GetMime(".xml").ToString());
            var       res  = new ArcList().Execute(_device.Proxy.SessionState.session, TypeResult.Xml);
            XDocument xd   = XDocument.Load(res);
            var       xchs = xd.Root.Element("channels").Elements().ToArray();

            foreach (var xch in xchs)
            {
                if (_device.Filter.Check("ttv").Find("ch" + xch.Attribute("id").Value).Check())
                {
                    xch.Remove();
                }
            }
            MemoryStream ms = new MemoryStream();

            xd.Save(ms);
            ms.Position = 0;
            resp.AddHeader(HttpHeader.ContentLength, ms.Length.ToString());
            resp.SendHeaders();
            ms.CopyTo(resp.GetStream());
        }
Example #6
0
 public Arc GetRouteByStartEnd(string start, string end)
 {
     return ArcList.Find(ar => ar.Start.Equals(start) && ar.End.Equals(end));
 }
        private void UpdatePlaylist(MyWebRequest req)
        {
            if (_lastUpdate + _maxAge < DateTime.Now)
            {
                DateTime date = req.Parameters.ContainsKey("date") ? ParseDateTime(req.Parameters["date"]) : DateTime.Today;
                _channels = new ArcList().Run(_device.Proxy.SessionState.session);
                _channels.channels.RemoveAll(c => _device.Filter.Check("ttv").Find("ch" + c.id).Check());
                if (req.Parameters.ContainsKey("channel_id"))
                {
                    int channel_id = int.Parse(req.Parameters["channel_id"]);
                    var ch         = _channels.channels.FirstOrDefault(c => c.epg_id == channel_id);
                    if (ch != null)
                    {
                        _records = new ArcRecords(ch == null ? 0 : ch.epg_id, date).Run(_device.Proxy.SessionState.session);
                    }
                    else
                    {
                        throw new FileNotFoundException();
                    }
                }
                else
                {
                    _records = new ArcRecords(0, date).Run(_device.Proxy.SessionState.session);
                    var groups = _records.records.GroupBy(r => r.epg_id).ToArray();
                    foreach (var kp in groups)
                    {
                        var ch = _channels.channels.Where(c => c.epg_id == kp.Key);
                        if (!ch.Any())
                        {
                            _records.records.RemoveAll(r => r.epg_id == kp.Key);
                        }
                    }
                }
            }

            if (!_channels.IsSuccess && !_records.IsSuccess)
            {
                if (_channels.Error == ApiError.incorrect || _channels.Error == ApiError.noconnect ||
                    _records.Error == ApiError.incorrect || _records.Error == ApiError.noconnect)
                {
                    while (!_device.Proxy.Login() || _device.Proxy.SessionState.Error == ApiError.noconnect)
                    {
                    }
                    if (!_device.Proxy.SessionState.IsSuccess)
                    {
                        throw new Exception("Ошибка подключения");
                    }
                    UpdatePlaylist(req);
                }
                else
                {
                    switch (_records.Error)
                    {
                    case ApiError.norecord:
                        throw new Exception("Нет записей");

                    case ApiError.noconnect:
                        throw new Exception("ошибка соединения с БД");

                    case ApiError.noparam:
                        throw new Exception("ошибка входных параметров");
                    }
                }
            }
        }