Ejemplo n.º 1
0
        /// <summary>
        /// Downloader
        /// </summary>
        /// <param name="selectedItems"></param>
        /// <param name="sourceID"></param>
        /// <param name="localPath"></param>
        public void CopyMultipleElement(List <Local> selectedItems, string sourceID, string localPath, ref bool workError)
        {
            //Download
            foreach (var item in selectedItems)
            {
                if (!item.NameOfLocal.Equals(".."))
                {
                    if (item.ExtensionOfLocal.Equals("dir"))
                    {
                        FileBasics.CreateNewDirectory(localPath, item.NameOfLocal);

                        List <Local> recFiles = FileListingFull(item.Id);
                        string       newPath  = localPath + "\\" + item.NameOfLocal;
                        CopyMultipleElement(recFiles, item.Id, newPath, ref workError);
                    }
                    else
                    {
                        try
                        {
                            Download(localPath, item.NameOfLocal, item.Id);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("Dropbox Access Error: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                            workError = true;
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Uploader
        /// </summary>
        /// <param name="selectedItems"></param>
        /// <param name="destinationID"></param>
        public void CopyMultipleElement(List <Local> selectedItems, string destinationID, List <FileAttributes> F, ref bool workError)
        {
            //Upload
            foreach (var item in selectedItems)
            {
                if (!item.NameOfLocal.Equals(".."))
                {
                    if (item.ExtensionOfLocal.Equals("dir"))
                    {
                        string newFolder = CreateFolder(item.NameOfLocal, destinationID);

                        string       selectedItem = item.PathOfLocal + "\\" + item.NameOfLocal;
                        List <Local> dirs         = new List <Local>();
                        List <Local> files        = new List <Local>();
                        List <Local> recFiles     = FileBasics.FullListing(ref newFolder, ref dirs, ref files, ref newFolder, F);
                        CopyMultipleElement(recFiles, newFolder, F, ref workError);
                    }
                    else
                    {
                        try
                        {
                            Upload(item, destinationID);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("Dropbox Access Error: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                            workError = true;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        static public void DeleteMultipleElement(List <Local> selectedSourceItems, ref bool workerror)
        {
            MessageBoxResult r = MessageBox.Show("Do you really want to delete the selected items?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes);

            if (r == MessageBoxResult.Yes)
            {
                foreach (Local item in selectedSourceItems)
                {
                    FileBasics.Delete(item.PathOfLocal, ref workerror);
                }
            }
        }
Ejemplo n.º 4
0
        static public void CopyMultipleElements(List <Local> selectedSourceItems, List <Local> destinationItems, string destinationDir, ref bool workerror)
        {
            bool overwriteable   = true;
            bool existingElement = false;

            //megnézzük léteznek e már az állományok a célnál
            foreach (Local s in selectedSourceItems)
            {
                foreach (Local d in destinationItems)
                {
                    if (s.NameOfLocal.Equals(d.NameOfLocal))
                    {
                        existingElement = true;
                    }
                }
            }
            if (existingElement == true)
            {
                MessageBoxResult r = MessageBox.Show("Do you want to overwrite the existing files?", "Warning: File already exists!", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes);
                if (r == MessageBoxResult.Yes)
                {
                    overwriteable = true;
                }
                else
                {
                    overwriteable = false;
                }
            }
            //másoljuk a kiválasztott elemeket
            foreach (Local item in selectedSourceItems)
            {
                try
                {
                    FileBasics.Copy(item.PathOfLocal, item.NameOfLocal, destinationDir, overwriteable);
                }

                catch (UnauthorizedAccessException)
                {
                    workerror = true;
                    MessageBox.Show("Access Denied", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Ejemplo n.º 5
0
        static public void MoveMultipleElements(List <Local> selectedSourceItems, List <Local> destinationItems, string destinationDir, ref bool workerror)
        {
            bool overwriteable   = false;
            bool existingElement = false;

            foreach (Local s in selectedSourceItems)
            {
                foreach (Local d in destinationItems)
                {
                    if (s.NameOfLocal.Equals(d.NameOfLocal))
                    {
                        existingElement = true;
                    }
                }
            }
            if (existingElement == true)
            {
                MessageBoxResult r = MessageBox.Show("Do you want to overwrite the existing files?", "Warning: File already exists!", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes);
                if (r == MessageBoxResult.Yes)
                {
                    overwriteable = true;
                }
                else
                {
                    overwriteable = false;
                }
            }
            foreach (Local item in selectedSourceItems)
            {
                try
                {
                    FileBasics.Move(item.PathOfLocal, item.NameOfLocal, destinationDir, overwriteable, ref workerror);
                }
                catch (UnauthorizedAccessException)
                {
                    MessageBox.Show("Access Denied", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Ejemplo n.º 6
0
        static public List <Local> FullListing(ref string actualDir, ref List <Local> directories, ref List <Local> files, ref string prevDir, List <FileAttributes> F)
        {
            //Összeállítjuk a megjelenítendő listát
            string path = actualDir;

            directories = FileBasics.DirListing(ref path, F, prevDir);
            files       = FileBasics.FileListing(ref path, F, prevDir);
            actualDir   = path;
            List <Local> tempList = new List <Local>();

            tempList.Add(new Local("", "", "..", "", "", ""));
            foreach (Local a in directories)
            {
                tempList.Add(a);
            }
            foreach (Local a in files)
            {
                tempList.Add(a);
            }
            prevDir = actualDir;
            return(tempList);
        }