Esempio n. 1
0
        public void ImportFile(string path)
        {
            if (System.IO.File.Exists(path) && !System.IO.Directory.Exists(path))
            {
                if (!string.IsNullOrEmpty(path) && QueueController.IsFormat(path, ContextHelper.GetAudioFormats()))
                {
                    importFileName = new FileInfo(path).Name;
                    importScanCount++;

                    try
                    {
                        IMediaItem track = QueueController.GetMediaItem(new Uri(path));
                        if (track != null)
                        {
                            track.Source = Values.Source.Catalog;
                            track.Type   = MediaTypes.Audio;
                            PersistenceController.SaveMediaItem(track);
                            importHitCount++;

                            if (importStatusUpdateCallback != null)
                            {
                                ImportStatusUpdateEventArgs args = GetImportEventArgs(path);
                                importStatusUpdateCallback(this, args);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        importErrorCount++;

                        if (importStatusUpdateCallback != null)
                        {
                            ImportStatusUpdateEventArgs args = GetImportEventArgs(path);
                            importStatusUpdateCallback(this, args);
                        }

                        MessageBox.Show(string.Format("The following file could not be imported: \n{0}\n\n{1}", path, ex.Message), "IMPORT ERROR");
                    }
                }
                else
                {
                    if (importStatusUpdateCallback != null)
                    {
                        ImportStatusUpdateEventArgs args = GetImportEventArgs(path);
                        importStatusUpdateCallback(this, args);
                    }
                }

                importRow.Cells[TASK_COL_PROGRESS].Value = GetImportProgess();
                importRow.Cells[TASK_COL_DETAILS].Value  = GetImportDetails();
            }
        }