public bool AddRecording(RecordingSummary recording)
 {
     string key = GetRecordingKey(recording.RecordingFileName);
     if (key != null)
     {
         if (!_allRecordings.ContainsKey(key))
         {
             _allRecordings[key] = recording;
             return true;
         }
     }
     return false;
 }
 public string GetRecordingDisplayText(RecordingSummary recording, bool addChannelName)
 {
     StringBuilder programTitle = new StringBuilder(recording.CreateProgramTitle());
     programTitle.Append(" - ");
     if (addChannelName)
     {
         programTitle.Append(recording.ChannelDisplayName).Append(" - ");
     }
     programTitle.AppendFormat("{0:g}", recording.ProgramStartTime);
     return programTitle.ToString();
 }
Exemple #3
0
        public static string GetRecordingThumb(RecordingSummary recording,bool createNewThumbIfNotFound, int size)
        {
            string thumb = string.Format("{0}\\{1}{2}", Thumbs.TVRecorded,recording.RecordingId,".jpg");
            if (Utils.FileExistsInCache(thumb))
            {
                //local thumb
                return thumb;
            }
            else if (createNewThumbIfNotFound)
            {
                //no local thumb found, ask one from the server and save it
                if (size < 0)
                {
                    size = 0;
                }

                byte[] jpegData = Proxies.ControlService.GetRecordingThumbnail(recording.RecordingId, size, size, null, recording.RecordingStartTime).Result;
                if (jpegData != null)
                {
                    try
                    {
                        using (System.Drawing.Image img = System.Drawing.Image.FromStream(new MemoryStream(jpegData)))
                        {
                            img.Save(thumb, System.Drawing.Imaging.ImageFormat.Jpeg);
                        }
                    }
                    catch { }
                    jpegData = null;
   
                    if (Utils.FileExistsInCache(thumb))
                    {
                        return thumb;
                    }
                }
            }
            return string.Empty;
        }
 public bool ContainsRecording(RecordingSummary recording)
 {
     return ContainsRecording(recording.RecordingFileName);
 }
 private bool RemoveRecordingNode(TreeNodeCollection nodes, RecordingSummary recording)
 {
     foreach (TreeNode node in nodes)
     {
         if (node.Nodes.Count > 0)
         {
             if (RemoveRecordingNode(node.Nodes, recording))
             {
                 return true;
             }
         }
         if (node.Tag == recording)
         {
             TreeNode parentNode = node.Parent;
             node.Remove();
             if (parentNode != null)
             {
                 if (parentNode.Nodes.Count == 0)
                 {
                     parentNode.Remove();
                 }
                 else
                 {
                     RecordingGroup group = parentNode.Tag as RecordingGroup;
                     if (group != null)
                     {
                         group.RecordingsCount--;
                         parentNode.Text = GetGroupDisplayText(group);
                     }
                 }
             }
             return true;
         }
     }
     return false;
 }
 private static string GetRecordingDisplayText(RecordingSummary recording, bool addChannelName)
 {
     StringBuilder programTitle = new StringBuilder(recording.CreateProgramTitle());
     programTitle.Append(" - ");
     if (addChannelName)
     {
         programTitle.Append(recording.ChannelDisplayName).Append(" - ");
     }
     programTitle.Append(FormatDateWithTime(recording.ProgramStartTime, true));
     return programTitle.ToString();
 }
        private static TreeNode AddRecordingNode(System.Collections.IList nodes, RecordingSummary recording, bool addChannelName)
		{
			TreeNode recordingNode = new TreeNode(GetRecordingDisplayText(recording, addChannelName));
            nodes.Add(recordingNode);
			recordingNode.Tag = recording;
            SetRecordingNodeIcon(recordingNode);
			return recordingNode;
		}
 public MissingRecording(RecordingSummary recording, bool deleteRecording)
 {
     _recording = recording;
     _deleteRecording = deleteRecording;
 }
Exemple #9
0
        private void ExportRecording(RecordingSummary recording)
        {
            Recording metadata = Utility.GetRecordingMetadataFromAds(recording.RecordingFileName);

            string destinationPath = _destinationTextBox.Text;

            if (_createDirectoriesCheckBox.Checked)
            {
                string directoryName = null;

                switch (_directoryNameComboBox.SelectedIndex)
                {
                    case DirectoryNameIndex.Title:
                        directoryName = recording.Title;
                        break;

                    case DirectoryNameIndex.Schedule:
                        directoryName = recording.ScheduleName;
                        break;

                    case DirectoryNameIndex.Channel:
                        directoryName = recording.ChannelDisplayName;
                        break;

                    case DirectoryNameIndex.Date:
                        directoryName = String.Format(CultureInfo.CurrentCulture,
                            "{0}-{1:00}-{2:00}", recording.ProgramStartTime.Year, recording.ProgramStartTime.Month, recording.ProgramStartTime.Day);
                        break;
                }

                if (!String.IsNullOrEmpty(directoryName))
                {
                    destinationPath = Path.Combine(destinationPath, ArgusTV.Common.Utility.MakeValidFileName(directoryName));
                    if (!Directory.Exists(destinationPath))
                    {
                        Directory.CreateDirectory(destinationPath);
                    }
                }
            }

            SortedList<long, string> filesToCopy = new SortedList<long, string>();

            string sourceDirectory = Path.GetDirectoryName(recording.RecordingFileName);
            string sourceNameWithoutExtension = Path.GetFileNameWithoutExtension(recording.RecordingFileName);

            DirectoryInfo dirInfo = new DirectoryInfo(sourceDirectory);
            foreach (FileInfo fileInfo in dirInfo.GetFiles(sourceNameWithoutExtension + "*"))
            {
                long size = fileInfo.Length;
                while (filesToCopy.ContainsKey(size))
                {
                    size++;
                }
                filesToCopy.Add(size, fileInfo.FullName);
            }

            foreach (string fileName in filesToCopy.Values)
            {
                string destinationFileName = Path.Combine(destinationPath, Path.GetFileName(fileName));
                Microsoft.VisualBasic.Devices.Computer computer = new Microsoft.VisualBasic.Devices.Computer();
                computer.FileSystem.CopyFile(fileName, destinationFileName,
                    Microsoft.VisualBasic.FileIO.UIOption.AllDialogs, Microsoft.VisualBasic.FileIO.UICancelOption.ThrowException);
            }

            string destinationRecordingFileName = Path.Combine(destinationPath, Path.GetFileName(recording.RecordingFileName));
            if (_exportMetadataCheckBox.Checked
                || (metadata != null && !CheckMetadataCopied(destinationRecordingFileName)))
            {
                metadata = Utility.GetRecordingMetadata(recording.RecordingFileName);
                if (metadata == null)
                {
                    metadata = Proxies.ControlService.GetRecordingById(recording.RecordingId).Result;
                }
                if (metadata != null)
                {
                    Utility.WriteRecordingMetadataFile(destinationRecordingFileName, metadata);
                }
            }
        }