/*******************************************************************************\ * Download last update of selected region. 2 methods : * * - The first one is when the user click on the button to dl last updates. * * - The second one is part of the Analytics batch * \*******************************************************************************/ private void DLLastUpdateButton_Click(object sender, EventArgs e) { if (!_Worker.IsBusy) { StopButton.Enabled = ButtonEnabled.True; /* Clear interface */ ProgressBar.Value = 0; ProgressLabel.Text = "-"; DirFileCounterLabel.Text = ""; FTPBrowserHeaderGroup.ValuesPrimary.Heading = "FTP Browser :"; /* Clear list of files to dl */ _FilesToDownload.Clear(); /* Reset root */ _Root = new Directory(); /* Get region to connect */ Region regionToConnect = new Region(); foreach (Region element in _RegionsList) { if (element.Get_RegionName().Equals(FTPTreeView.SelectedNode.Text.ToString()))//if (element.Get_RegionName().Equals(FTPListDataGridView.CurrentCell.Value)) { regionToConnect = element; break; } } /* Set credentials & current folder */ _ConnectedRegion = regionToConnect; _FtpAPI.Set_Host(regionToConnect.Get_FtpHost()); _FtpAPI.Set_Root(regionToConnect.Get_FtpHost()); _FtpAPI.Set_User(regionToConnect.Get_Login()); _FtpAPI.Set_Password(regionToConnect.Get_Password()); _Root.Set_IsRoot(true); _Root.Set_Name("Root"); _Root.Set_Path(regionToConnect.Get_FtpHost()); /* Start backgroundworker to get files */ LogcatRichTextBox.AppendText("Connecting to " + regionToConnect.Get_RegionName() + " : " + regionToConnect.Get_FtpHost() + "... "); List<object> arguments = new List<object>(); arguments.Add("DlLastUp"); _Worker.RunWorkerAsync(arguments); } }
/**********************************************************************\ * Synchronize local file with FTP server * * - Get the newest file in local and Download all files in server * * which are relatively more recent. * \**********************************************************************/ private void SynchronizeLocalFileButton_Click(object sender, EventArgs e) { if (!_Worker.IsBusy) { /* Clear files to dl */ _FtpAPI.Reset_DownloadedFilesTarget(); _FilesToDownload.Clear(); /* Get region from list and check if its target directory has been defined */ Region regionToConnect = new Region(); foreach (Region element in _RegionsList) { if (element.Get_RegionName().Equals(FTPTreeView.SelectedNode.Text.ToString()))//if (element.Get_RegionName().Equals(FTPListDataGridView.CurrentCell.Value)) { regionToConnect = element; break; } } if (String.IsNullOrEmpty(regionToConnect.Get_TargetDirectory()) || !System.IO.Directory.Exists(regionToConnect.Get_TargetDirectory())) { KryptonMessageBox.Show("Target directory not defined, or directory doesn't exist !", "Error while checking the target directory", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { /* Reset root */ _Root = new Directory(); /* Set credentials & current folder */ _ConnectedRegion = regionToConnect; _FtpAPI.Set_Host(regionToConnect.Get_FtpHost()); _FtpAPI.Set_Root(regionToConnect.Get_FtpHost()); _FtpAPI.Set_User(regionToConnect.Get_Login()); _FtpAPI.Set_Password(regionToConnect.Get_Password()); _Root.Set_IsRoot(true); _Root.Set_Name("Root"); _Root.Set_Path(regionToConnect.Get_FtpHost()); /* Start backgroundworker to get files*/ LogcatRichTextBox.AppendText("Connecting to " + regionToConnect.Get_RegionName() + " : " + regionToConnect.Get_FtpHost() + "... "); List<object> arguments = new List<object>(); arguments.Add("SyncLF"); _Worker.RunWorkerAsync(arguments); } } }
private void Connect() { ConnectButton.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False; StopButton.Enabled = ButtonEnabled.True; DLLastUpdateButton.Enabled = false; SynchronizeLocalFileButton.Enabled = false; FileExplorerListView.SetSortIcon(0, SortOrder.None); FileExplorerListView.ListViewItemSorter = new ListViewItemComparer(0, SortOrder.Ascending); DirFileCounterLabel.Text = ""; /* Reset current directory */ _Root = new Directory(); /* Get region to connect */ Region regionToConnect = new Region(); foreach (Region element in _RegionsList) { if (element.Get_RegionName().Equals(FTPTreeView.SelectedNode.Text.ToString()))//if (element.Get_RegionName().Equals(FTPListDataGridView.CurrentCell.Value)) { regionToConnect = element; break; } } _ConnectedRegion = regionToConnect; /* Set credentials & current folder */ _FtpAPI.Set_Host(regionToConnect.Get_FtpHost()); _FtpAPI.Set_Root(regionToConnect.Get_FtpHost()); _FtpAPI.Set_User(regionToConnect.Get_Login()); _FtpAPI.Set_Password(regionToConnect.Get_Password()); _Root.Set_IsRoot(true); _Root.Set_Name("Root"); _Root.Set_Path(regionToConnect.Get_FtpHost()); /* Start backgroundworker to get files*/ FTPBrowserHeaderGroup.ValuesPrimary.Heading = "FTP Browser (" + regionToConnect.Get_RegionName() + ") :"; LogcatRichTextBox.AppendText("Connecting to " + regionToConnect.Get_RegionName() + " : " + regionToConnect.Get_FtpHost() + "... "); FileExplorerListView.Items.Clear(); List<object> arguments = new List<object>(); arguments.Add("GetDir"); _Worker.RunWorkerAsync(arguments); }
public void DLLastUpdate(Region regionToConnect) { if (!_Worker.IsBusy) { StopButton.Enabled = ButtonEnabled.True; /* Clear list of files to dl */ _FilesToDownload.Clear(); /* Reset root */ _Root = new Directory(); /* Set credentials & current folder */ _ConnectedRegion = regionToConnect; _FtpAPI.Set_Host(regionToConnect.Get_FtpHost()); _FtpAPI.Set_Root(regionToConnect.Get_FtpHost()); _FtpAPI.Set_User(regionToConnect.Get_Login()); _FtpAPI.Set_Password(regionToConnect.Get_Password()); _Root.Set_IsRoot(true); _Root.Set_Name("Root"); _Root.Set_Path(regionToConnect.Get_FtpHost()); /* Start backgroundworker to get files */ //LogcatRichTextBox.AppendText("Connecting to " + regionToConnect.Get_RegionName() + " : " + regionToConnect.Get_FtpHost() + "... "); //List<object> arguments = new List<object>(); //arguments.Add("DlLastUp"); //_Worker.RunWorkerAsync(arguments); } }