コード例 #1
0
ファイル: Service1.asmx.cs プロジェクト: bangush/csharp
 public Programme(Programme prg)
     : base()
 {
     credits    = prg.credits;
     categories = prg.categories;
     start      = prg.start;
     stop       = prg.stop;
     channel    = prg.channel;
     title      = prg.title;
     subtitle   = prg.subtitle;
     desc       = prg.desc;
     episodenum = prg.episodenum;
 }
コード例 #2
0
ファイル: Service1.asmx.cs プロジェクト: bangush/csharp
 private Programme CloneProgramme(Programme prg)
 {
     return(new Programme()
     {
         categories = prg.categories,
         channel = prg.channel,
         channelname = prg.channelname,
         credits = prg.credits,
         date = prg.date,
         desc = prg.desc,
         episodenum = prg.episodenum,
         start = prg.start,
         stop = prg.stop,
         subtitle = prg.subtitle,
         title = prg.title
     });
 }
コード例 #3
0
ファイル: Service1.asmx.cs プロジェクト: bangush/csharp
        public GetProgrammesResponse GetProgrammes(GetProgrammesRequest request)
        {
            GetProgrammesResponse resp = new GetProgrammesResponse();

            try
            {
                List <Programme> programmes = GetDeSeProgrammes();
                var rpsta = request.programme.start;
                var rpsto = request.programme.stop;

                Programme oldprg = new Programme();
                var       list1  = programmes.Where(x => ((string.IsNullOrEmpty(request.programme.channel) ? true : request.programme.channel.Split(';').Contains(x.channel.ToLower())) &&
                                                          (string.IsNullOrEmpty(request.programme.title) ? true : x.title.ToLower().Contains(request.programme.title.ToLower())) &&
                                                          (string.IsNullOrEmpty(request.programme.channel) ? true : request.programme.channel.Split(';').Contains(x.channel.ToLower())) &&
                                                          (string.IsNullOrEmpty(request.programme.subtitle) ? true : x.subtitle.ToLower().Contains(request.programme.subtitle.ToLower())) &&
                                                          ((request.programme.credits == null || (request.programme.credits != null && request.programme.credits.Count == 0)) ? true : x.credits.Any(y => request.programme.credits.Contains(y))) &&
                                                          ((request.programme.categories == null || (request.programme.categories != null && request.programme.categories.Count == 0)) ? true : x.categories.Any(y => request.programme.categories.Contains(y))))
                                                    ).ToList <Programme>();
                var list2 = list1.Where(x => x.stop >= rpsta && x.stop <= rpsto).ToList <Programme>();
                var list3 = list1.Where(x => x.start >= rpsta && x.stop <= rpsto).ToList <Programme>();
                var list4 = list1.Where(x => x.start >= rpsta && x.stop >= rpsto && x.start <= rpsto).ToList <Programme>();
                var list5 = list1.Where(x => x.start <= rpsta && x.stop >= rpsto).ToList <Programme>();
                list1 = list2.Concat(list3).ToList <Programme>();
                list1 = list1.Concat(list4).ToList <Programme>();
                list1 = list1.Concat(list5).ToList <Programme>();


                foreach (Programme prg in list1.Distinct())
                {
                    try
                    {
                        if (prg.channel.Equals(oldprg.channel))
                        {
                            if (!prg.start.Equals(oldprg.stop))
                            {
                                Programme prgdiff = new Programme()
                                {
                                    start   = oldprg.stop,
                                    stop    = prg.start,
                                    title   = "Sändningsuppehåll!",
                                    channel = prg.channel,
                                    desc    = "Uppehåll i sändning!"
                                };
                                resp.programmes.Add(prgdiff);
                            }
                        }
                        resp.programmes.Add(prg);
                        oldprg = CloneProgramme(prg);
                    }
                    catch (Exception ex)
                    {
                        resp.exception = ex.Message + " " + ex.StackTrace;
                    }
                }
            }
            catch (Exception ex)
            {
                resp.exception = ex.Message + " " + ex.StackTrace;
            }
            finally {
            }
            return(resp);
        }