コード例 #1
0
        /// <summary>
        /// Moves the media item part to the specified root folder
        /// </summary>
        /// <param name="rootFolder">Root folder to move the media item part to</param>
        private void Organise(OrganisingRootFolder rootFolder)
        {
            Progress = 0;

            if (RequiresMove)
            {
                FileInfo source = new FileInfo(Part.Location.Value);

                DirectoryInfo di = new DirectoryInfo(rootFolder.Path.Value);

                if (!di.Exists)
                {
                    throw new DirectoryNotFoundException("Root folder \"" + di.FullName + "\" does not exist");
                }

                String destinationFilename = di.FullName;

                if (!destinationFilename.EndsWith("\\"))
                {
                    destinationFilename += "\\";
                }

                destinationFilename += OrganisedPath;

                FileInfo destination = new FileInfo(destinationFilename);

                if (destination.Exists)
                {
                    throw new System.Exception("\"" + destinationFilename + "\" already exists");
                }

                if (!destination.Directory.Exists)
                {
                    destination.Directory.Create();
                }

                MovePart(source, destinationFilename);

                Part.Location = destinationFilename;
                MediaItem.Save();
            }
            else
            {
                Progress = Part.Size;
            }

            if (MediaItem.IsHidden)
            {
                File.SetAttributes(Part.Location.Value, FileAttributes.Hidden);
            }
            else
            {
                File.SetAttributes(Part.Location.Value, FileAttributes.Normal);
            }
        }
コード例 #2
0
        /// <summary>
        /// Organises the parts
        /// </summary>
        private void Organise(object data)
        {
            try
            {
                timeStarted = DateTime.Now;
                timeTakenTimer.Start();

                OrganisedCount       = 0;
                TotalBytesTransfered = 0;
                TimeTaken            = TimeSpan.FromSeconds(0);

                OrganisingRootFolder[] rootFolders = data as OrganisingRootFolder[];

                //reset progress of parts
                foreach (OrganisingMediaItemPart part in Parts)
                {
                    part.Progress = 0;
                }

                foreach (OrganisingMediaItemPart part in Parts)
                {
                    OrganisingRootFolder[] sortedRootFolders = OrganisingRootFolder.SortForMediaItem(part.MediaItem, rootFolders);

                    SelectedPart = part;

                    CancelMediaItemsOperationEventArgs e = new CancelMediaItemsOperationEventArgs(new MediaItem[1] {
                        part.MediaItem
                    });
                    OnOrganisingMediaItem(e);

                    part.Organise(this, sortedRootFolders, e.Cancel, e.ReasonForCancel);

                    OrganisedCount++;
                }
            }
            catch (ThreadAbortException)
            {
                //do nothing
            }

            timeTakenTimer.Stop();
            SelectedPart = null;
            IsOrganising = false;
            OnFinishedOrganising();
        }
コード例 #3
0
 /// <summary>
 /// Initialises a new instance of the MatchedOrganisingRootFolder class
 /// </summary>
 /// <param name="rootFolder">Root folder that was matched to a media item</param>
 /// <param name="matches">Number times the root folder could be matched to a media item</param>
 public MatchedOrganisingRootFolder(OrganisingRootFolder rootFolder, Int32 matches)
 {
     RootFolder = rootFolder;
     Matches    = matches;
 }