Esempio n. 1
0
        public static IList<Recording> GeneralSqlQuery(string command)
        {
            using (IRecordingRepository recordingRepository = new RecordingRepository(true))
            {
                IEnumerable<Mediaportal.TV.Server.TVDatabase.Entities.Recording> allqueryRecordings = recordingRepository.ObjectContext.ExecuteStoreQuery<Mediaportal.TV.Server.TVDatabase.Entities.Recording>(command);
                recordingRepository.UnitOfWork.SaveChanges();

                IList<Recording> myrecordings = new List<Recording>();
                foreach (Mediaportal.TV.Server.TVDatabase.Entities.Recording myrecording in allqueryRecordings)
                {
                    Recording newrecording = new Recording();
                    newrecording.IdRecording = myrecording.IdRecording;
                    newrecording.Title = myrecording.Title;
                    newrecording.FileName = myrecording.FileName;
                    if (myrecording.IdChannel != null)
                    {
                        newrecording.IdChannel = (int)myrecording.IdChannel;
                    }
                    else
                    {
                        newrecording.IdChannel = -1;
                    }
                    newrecording.StartTime = myrecording.StartTime;
                    newrecording.EndTime = myrecording.EndTime;
                    newrecording.Description = myrecording.Description;
                    newrecording.EpisodeName = myrecording.EpisodeName;
                    newrecording.EpisodeNum = myrecording.EpisodeNum;
                    newrecording.EpisodePart = myrecording.EpisodePart;
                    if (myrecording.ProgramCategory != null)
                        newrecording.Genre = myrecording.ProgramCategory.Category;
                    else
                        newrecording.Genre = string.Empty;
                    if (myrecording.IdSchedule != null)
                    {
                        newrecording.Idschedule = (int)myrecording.IdSchedule;
                    }
                    else
                    {
                        newrecording.Idschedule = -1;
                    }
                    newrecording.KeepUntil = myrecording.KeepUntil;
                    if (myrecording.KeepUntilDate != null)
                    {
                        newrecording.KeepUntilDate = (DateTime)myrecording.KeepUntilDate;
                    }
                    else
                    {
                        newrecording.KeepUntilDate = DateTime.ParseExact("2999-01-30_00:00", "yyyy-MM-dd_HH:mm", System.Globalization.CultureInfo.InvariantCulture);
                    }
                    newrecording.SeriesNum = myrecording.SeriesNum;
                    newrecording.StopTime = myrecording.StopTime;
                    newrecording.TimesWatched = myrecording.TimesWatched;
                    //add whatever you need here

                    myrecordings.Add(newrecording);
                }
                return myrecordings;
            }
        }
Esempio n. 2
0
        //ILogger Log = ServiceRegistration.Get<ILogger>();

        #region public methods
        public static IList<Recording> ListAll()
        {
            DateTime start = DateTime.Now; //DEBUG PERFORMANCE
            
            IList<Mediaportal.TV.Server.TVDatabase.Entities.Recording> rawrecordingstv = ServiceAgents.Instance.RecordingServiceAgent.ListAllActiveRecordingsByMediaType(Mediaportal.TV.Server.TVDatabase.Entities.Enums.MediaTypeEnum.TV);
            DateTime end = DateTime.Now; //DEBUG PERFORMANCE
            Log.Debug("IList<Recording> ListAll() time=" + end.Subtract(start).TotalSeconds.ToString()); //DEBUG PERFORMANCE
            IList<Recording> allrecordings = new List<Recording>();
            foreach (Mediaportal.TV.Server.TVDatabase.Entities.Recording myrecording in rawrecordingstv)
            {
                Recording newrecording = new Recording();
                newrecording.IdRecording = myrecording.IdRecording;
                newrecording.Title = myrecording.Title;
                newrecording.FileName = myrecording.FileName;
                if (myrecording.IdChannel != null)
                {
                    newrecording.IdChannel = (int)myrecording.IdChannel;
                }
                else
                {
                    newrecording.IdChannel = -1;
                }
                newrecording.StartTime = myrecording.StartTime;
                newrecording.EndTime = myrecording.EndTime;
                newrecording.Description = myrecording.Description;
                newrecording.EpisodeName = myrecording.EpisodeName;
                newrecording.EpisodeNum = myrecording.EpisodeNum;
                newrecording.EpisodePart = myrecording.EpisodePart;
                if (myrecording.ProgramCategory != null)
                    newrecording.Genre = myrecording.ProgramCategory.Category;
                else
                    newrecording.Genre = string.Empty;
                if (myrecording.IdSchedule != null)
                {
                    newrecording.Idschedule = (int)myrecording.IdSchedule;
                }
                else
                {
                    newrecording.Idschedule = -1;
                }
                newrecording.KeepUntil = myrecording.KeepUntil;
                if (myrecording.KeepUntilDate != null)
                {
                    newrecording.KeepUntilDate = (DateTime)myrecording.KeepUntilDate;
                }
                else
                {
                    newrecording.KeepUntilDate = DateTime.ParseExact("2999-01-30_00:00", "yyyy-MM-dd_HH:mm", System.Globalization.CultureInfo.InvariantCulture);
                }
                newrecording.SeriesNum = myrecording.SeriesNum;
                newrecording.StopTime = myrecording.StopTime;
                newrecording.TimesWatched = myrecording.TimesWatched;
                //add whatever you need here
                Log.Debug("myrecording = " + myrecording.Title);
                Log.Debug("myrecording keepuntildate== " + newrecording.KeepUntilDate.ToString());
                allrecordings.Add(newrecording);
                
            }
            DateTime start3 = DateTime.Now; //DEBUG PERFORMANCE
            IList<Mediaportal.TV.Server.TVDatabase.Entities.Recording> rawrecordingsradio = ServiceAgents.Instance.RecordingServiceAgent.ListAllActiveRecordingsByMediaType(Mediaportal.TV.Server.TVDatabase.Entities.Enums.MediaTypeEnum.Radio);
            DateTime end3 = DateTime.Now; //DEBUG PERFORMANCE
            Log.Debug("IList<Recording> ListAll() time=" + end3.Subtract(start3).TotalSeconds.ToString()); //DEBUG PERFORMANCE
            
            foreach (Mediaportal.TV.Server.TVDatabase.Entities.Recording myrecording in rawrecordingsradio)
            {
                Recording newrecording = new Recording();
                newrecording.IdRecording = myrecording.IdRecording;
                newrecording.Title = myrecording.Title;
                newrecording.FileName = myrecording.FileName;
                if (myrecording.IdChannel != null)
                {
                    newrecording.IdChannel = (int)myrecording.IdChannel;
                }
                else
                {
                    newrecording.IdChannel = -1;
                }
                newrecording.StartTime = myrecording.StartTime;
                newrecording.EndTime = myrecording.EndTime;
                newrecording.Description = myrecording.Description;
                newrecording.EpisodeName = myrecording.EpisodeName;
                newrecording.EpisodeNum = myrecording.EpisodeNum;
                newrecording.EpisodePart = myrecording.EpisodePart;
                if (myrecording.ProgramCategory != null)
                    newrecording.Genre = myrecording.ProgramCategory.Category;
                else
                    newrecording.Genre = string.Empty;
                if (myrecording.IdSchedule != null)
                {
                    newrecording.Idschedule = (int)myrecording.IdSchedule;
                }
                else
                {
                    newrecording.Idschedule = -1;
                }
                newrecording.KeepUntil = myrecording.KeepUntil;
                if (myrecording.KeepUntilDate != null)
                {
                    newrecording.KeepUntilDate = (DateTime)myrecording.KeepUntilDate;
                }
                else
                {
                    newrecording.KeepUntilDate = DateTime.ParseExact("2999-01-30_00:00", "yyyy-MM-dd_HH:mm", System.Globalization.CultureInfo.InvariantCulture);
                }
                newrecording.SeriesNum = myrecording.SeriesNum;
                newrecording.StopTime = myrecording.StopTime;
                newrecording.TimesWatched = myrecording.TimesWatched;
                //add whatever you need here


                Log.Debug("myrecording = " + myrecording.Title);
                Log.Debug("myrecording keepuntildate== " + newrecording.KeepUntilDate.ToString());
                allrecordings.Add(newrecording);
            }
            DateTime end2 = DateTime.Now; //DEBUG PERFORMANCE
            Log.Debug("IList<Recording> ListAll() total time=" + end2.Subtract(start).TotalSeconds.ToString()); //DEBUG PERFORMANCE
            return allrecordings;
        }
Esempio n. 3
0
        public static Recording Retrieve(int idRecording)
        {
            Mediaportal.TV.Server.TVDatabase.Entities.Recording myrecording = ServiceAgents.Instance.RecordingServiceAgent.GetRecording(idRecording);
            Recording newrecording = new Recording();
            newrecording.IdRecording = myrecording.IdRecording;
            newrecording.Title = myrecording.Title;
            newrecording.FileName = myrecording.FileName;
            if (myrecording.IdChannel != null)
            {
                newrecording.IdChannel = (int)myrecording.IdChannel;
            }
            else
            {
                newrecording.IdChannel = -1;
            }
            newrecording.StartTime = myrecording.StartTime;
            newrecording.EndTime = myrecording.EndTime;
            newrecording.Description = myrecording.Description;
            newrecording.EpisodeName = myrecording.EpisodeName;
            newrecording.EpisodeNum = myrecording.EpisodeNum;
            newrecording.EpisodePart = myrecording.EpisodePart;
            if (myrecording.ProgramCategory != null)
                newrecording.Genre = myrecording.ProgramCategory.Category;
            else
                newrecording.Genre = string.Empty;
            if (myrecording.IdSchedule != null)
            {
                newrecording.Idschedule = (int)myrecording.IdSchedule;
            }
            else
            {
                newrecording.Idschedule = -1;
            }
            newrecording.KeepUntil = myrecording.KeepUntil;
            if (myrecording.KeepUntilDate != null)
            {
                newrecording.KeepUntilDate = (DateTime)myrecording.KeepUntilDate;
            }
            else
            {
                newrecording.KeepUntilDate = DateTime.ParseExact("2999-01-30_00:00", "yyyy-MM-dd_HH:mm", System.Globalization.CultureInfo.InvariantCulture);
            }
            newrecording.SeriesNum = myrecording.SeriesNum;
            newrecording.StopTime = myrecording.StopTime;
            newrecording.TimesWatched = myrecording.TimesWatched;
            //add whatever you need here

            return newrecording;

        }