예제 #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();
            }
        }
예제 #2
0
        public void EndImportDirectory(IAsyncResult result)
        {
            lock (importLock)
            {
                importStatus = TaskStatus.Completed;
            }

            if (importRow != null)
            {
                importRow.Cells[TASK_COL_STATUS].Value = IMPORT_TASK_STATUS_COMPLETED;
            }

            if (importStatusUpdateCallback != null)
            {
                TimeSpan importCompletedTime     = DateTime.Now.Subtract(importStart);
                ImportStatusUpdateEventArgs args = new ImportStatusUpdateEventArgs(importScanCount, importHitCount, importErrorCount, importCompletedTime);
                importStatusUpdateCallback(this, args);
            }
        }
예제 #3
0
		private void importStatusUpdated(object sender, ImportStatusUpdateEventArgs args)
		{
			if (InvokeRequired)
			{
				ImportStatusUpdateDelegate updateDelegate = new ImportStatusUpdateDelegate(importStatusUpdated);
				Invoke(updateDelegate, new object[]{sender, args});
			}
			else
			{
				currentStatusToolStripLabel.Text = string.Format("Importing: [{0}/{1}/{2}] {3}", args.ImportCount, args.ScanCount, args.ErrorCount, args.Path);
				if (args.Completed)
				{
					MessageBox.Show(string.Format("Files Imported: {0}\nFiles Scanned: {1}\nErrors: {2}\nTime Elapsed: {3}", args.ImportCount, args.ScanCount, args.ErrorCount, args.CompletedTime), "IMPORT COMPLETED");
				}
			}
		}
예제 #4
0
		public void EndImportDirectory(IAsyncResult result)
		{
			lock(importLock)
			{
				importStatus = TaskStatus.Completed;
			}
		
			if (importRow != null)
			{
				importRow.Cells[TASK_COL_STATUS].Value = IMPORT_TASK_STATUS_COMPLETED;
			}
		
			if (importStatusUpdateCallback != null)
			{
				TimeSpan importCompletedTime = DateTime.Now.Subtract(importStart);
				ImportStatusUpdateEventArgs args = new ImportStatusUpdateEventArgs(importScanCount, importHitCount, importErrorCount, importCompletedTime);
				importStatusUpdateCallback(this, args);
			}
		}