예제 #1
0
        private async Task CreateCredentials()
        {
            var readablePass = PasswordInput.ToStandardString();

            if (String.IsNullOrEmpty(ServerNameInput) || String.IsNullOrEmpty(UserNameInput) || String.IsNullOrEmpty(readablePass))
            {
                IoC.Get <IAlertService>().Show("Fill all fields!");
                return;
            }

            UnauthorizedCredentials = new FTPcredentialsModel(ServerNameInput, UserNameInput, PasswordInput);

            if (await Authorize())
            {
                AuthorizedCredentials.Add(UnauthorizedCredentials);
                ClientModel = new FTPclientModel(AuthorizedCredentials.LastOrDefault()); //TODO IoC container
                List <string> response = await ClientModel.FtpGetAllFilesAsync();

                IoC.Get <RemoteExplorerControlVM>().GetItemsFromResponse(response);
                IoC.Get <RemoteExplorerControlVM>().CurrentPath = ClientModel.Uri;
            }

            else
            {
                IoC.Get <IAlertService>().Show("Incorrect credentials!");
            }
        }
예제 #2
0
        private async Task <bool> Authorize()
        {
            //TODO IoC container
            ClientModel = new FTPclientModel(UnauthorizedCredentials);

            return(await ClientModel.AuthorizeFTPConnectionsAsync());
        }
예제 #3
0
        private async Task Edit()
        {
            if (SelectedItems != null)
            {
                Ftp = new FTPclientModel(IoC.Get <AuthorizationControlVM>().AuthorizedCredentials.FirstOrDefault());

                var path = Path.GetTempPath();

                var item = SelectedItems.FirstOrDefault();

                if (item != null)
                {
                    if (item.Type == DirectoryItems.Folder)
                    {
                        IoC.Get <IAlertService>().Show("Cant edit a directory!");
                        return;
                    }

                    await Ftp.FtpDownloadFilesAsync(item.Path, $"{path}\\{item.Name}");

                    Process p = new Process();
                    p.Exited             += new EventHandler(ProcessEnded);
                    p.StartInfo.FileName  = $"{path}\\{item.Name}";
                    p.EnableRaisingEvents = true;
                    p.Start();
                }
            }
        }
예제 #4
0
        private async Task CreateDir(InputBoxVM input)
        {
            if (!String.IsNullOrEmpty(FileFolderName))
            {
                Ftp = new FTPclientModel(IoC.Get <AuthorizationControlVM>().AuthorizedCredentials.FirstOrDefault());

                await Ftp.CreateDirectorysAsync(FileFolderName);

                Items.Add(new DirectoryItemVM(CurrentPath, DirectoryItems.Folder));
            }
        }
예제 #5
0
        private async Task Download()
        {
            var target = IoC.Get <LocalExplorerControlVM>().CurrentPath;

            if (SelectedItems != null && !String.IsNullOrEmpty(target))
            {
                Ftp = new FTPclientModel(IoC.Get <AuthorizationControlVM>().AuthorizedCredentials.FirstOrDefault());

                foreach (var item in SelectedItems)
                {
                    await Ftp.FtpDownloadFilesAsync(item.Path, $"{target}\\{item.Name}");

                    IoC.Get <LocalExplorerControlVM>().CurrentFolderItems.Add(item);
                    IoC.Get <TransferProgressControlVM>().TransferQueue.Remove(item);
                }
            }
        }
예제 #6
0
        private async Task Delete()
        {
            if (SelectedItems != null)
            {
                Ftp = new FTPclientModel(IoC.Get <AuthorizationControlVM>().AuthorizedCredentials.FirstOrDefault());

                if (IoC.Get <IAlertService>().YesNo("Are you sure that you want to delete all selected item(s)!"))
                {
                    foreach (var item in SelectedItems)
                    {
                        await Ftp.FtpDeleteFileAsync(item.Path, item.Type);

                        Items.Remove(item);
                    }
                }
            }
        }
예제 #7
0
        private async Task UploadFile()
        {
            var credentials = IoC.Get <AuthorizationControlVM>().AuthorizedCredentials.FirstOrDefault();

            if (SelectedItems != null && credentials != null)
            {
                Ftp = new FTPclientModel(credentials); //TODO IoC container

                foreach (var item in SelectedItems)
                {
                    await Ftp.FtpUploadFileAsync(item.Path);

                    IoC.Get <RemoteExplorerControlVM>().Items.Add(item);
                    IoC.Get <TransferProgressControlVM>().TransferQueue.Remove(item);
                }
            }
        }