private void UploadFiles(IEnumerable <string> filePaths, int workerId) { if (_ftpClient.IsBusy) { MessageBox.Show("В данный момент невозможно выполнить загрузку. Попробуйте позже"); return; } var workerPath = GetWorkerPath(workerId); // Worker directory doesnt exist if (workerPath == null) { var workerName = new IdToNameConverter().Convert(workerId, typeof(string), "FullName", new CultureInfo("ru-RU")) .ToString(); // Get right name of worker directory var renamedWorkerName = GetRenamedFileName(workerName); workerPath = string.Format("{0}_[id]{1}", renamedWorkerName, workerId); // Create worker directory _ftpClient.MakeDirectory(string.Concat(_ftpClient.CurrentPath, workerPath, "/")); } foreach (var filePath in filePaths) { var fileName = Path.GetFileName(filePath); var adress = string.Concat(_ftpClient.CurrentPath, workerPath, "/", fileName); if (!_ftpClient.FileExist(adress)) { _sc.AddFileToWorker(Convert.ToInt32(StaffListBox.SelectedValue), fileName, AdministrationClass.CurrentWorkerId, App.BaseClass.GetDateFromSqlServer()); } else { if (MetroMessageBox.Show("Файл '" + fileName + "' уже существует в данном каталоге. \n\n" + "Заменить существующий файл?", string.Empty, MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes) { return; } } var uri = new Uri(adress); if (_processWindow != null) { _processWindow.Close(true); } _processWindow = new WaitWindow { Text = "Загрузка файла..." }; _processWindow.Show(Window.GetWindow(this), true); _ftpClient.UploadFileCompleted += OnFtpClientUploadFileCompleted; _ftpClient.UploadFileAsync(uri, "STOR", filePath); } }
private void OnBlockingOperationsFinished(object sender, EventArgs e) { if (_isSleeping) { Application.Current.Dispatcher?.Invoke(() => _waitWindow.Close()); } }
public void Test(object o) { WaitWindow waitcontrol = new WaitWindow(); // System.Windows.MessageBox.Show("The file type is wrong!"); waitcontrol.Show(); Task task = Task.Run(() => { for (int i = 0; i < 10000; i++) { for (int j = 0; j < 1000; j++) { for (int m = 0; m < 1000; m++) { } } } }); task.Wait(); System.Windows.MessageBox.Show("The file typewwg!"); waitcontrol.Close(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { wait.Close(); }catch (Exception ex) { } }
/// <summary> Ends Waiting flow </summary> public void EndWaiting() { if (window != null) { window.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => { window.Close(); })); } }
private async void Button_Click(object sender, RoutedEventArgs e) { var dialog = new WaitWindow(); var task = WorkAsync(dialog.Progress); var dialogTask = dialog.ShowDialogAsync(); await task; dialog.Close(); await dialogTask; }
private void UpdateResInfos() { WaitWindow waitWindow = new WaitWindow("Сваляне на резервации от сървъра..."); ReservationInfos = new List <ReservationInfo>(Context.Reservations .Include(r => r.Room) .Include(r => r.Guest) .Include(r => r.Transactions) .Select(x => new ReservationInfo(x))); waitWindow.Close(); }
private void MessageReceived(NotificationMessage notificationMessage) { Dispatcher.BeginInvoke(new Action(() => { if (notificationMessage.Notification == Messages.ShowWaitWindow) { if (_waitWindow != null) { _waitWindow.Close(); } _connected = false; _waitWindow = new WaitWindow("Logging in, please wait...", true); _waitWindow.Owner = this; _waitWindow.ShowDialog(); } else if (notificationMessage.Notification == Messages.NavigateToMainWindow) { _connected = true; if (_waitWindow != null) { _waitWindow.Close(); } Close(); } else if (notificationMessage.Notification == Messages.DismissWaitWindow) { if (_waitWindow != null) { _waitWindow.Close(); _waitWindow = null; } } })); }
protected void Complete() { Action p = new Action(delegate() { if (ww.Visible) { ww.Close(); } }); Migrate(p); autoReset.Set(); }
private void NotificationMessageReceived(NotificationMessageEx message) { Dispatcher.BeginInvoke(new Action(() => { if (message.Notification == MsgDestination.WindowApiExtension) // Csak akkor foglalkozunk az özenettel, ha nekünk szól { switch (message.Command) { case MsgCommand.CloseWindow: this.Close(); break; case MsgCommand.ShowDialogQuestion: DialogMessageEx dialogMessageEx = (DialogMessageEx)message.Parameters[0]; var result = MessageBox.Show(dialogMessageEx.Content, dialogMessageEx.Caption, MessageBoxButton.OKCancel, MessageBoxImage.Question); dialogMessageEx.Callback.Invoke(result); break; case MsgCommand.ShowWaitWindow: if (waitWindow != null) { waitWindow.Close(); } waitWindow = new WaitWindow("Loading please wait..."); waitWindow.Closed += waitWindow_Closed; waitWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; waitWindow.Owner = this; waitWindow.Show(); break; case MsgCommand.CloseWaitWindow: if (waitWindow != null) { waitWindow.Closed -= waitWindow_Closed; waitWindow.Close(); waitWindow = null; } break; } } })); }
private void DownloadQueueFile() { while (true) { if (!_downloadItems.Any()) { return; } var fileDirectoryInfo = _downloadItems.Dequeue(); if (fileDirectoryInfo.IsDirectory) { return; } if (_processWindow != null) { _processWindow.Close(true); } _downloadedChangesCount = 250; var path = fileDirectoryInfo.Adress; var uri = new Uri(path); _fileSize = _ftpClient.GetFileSize(fileDirectoryInfo.Adress); var newFile = Path.Combine(_neededDownloadDirectoryPath, fileDirectoryInfo.Name); if (File.Exists(newFile)) { if ( MessageBox.Show( string.Format("Файл '{0}' уже существует в указанной папке, заменить файл?", fileDirectoryInfo.Name), "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes) { continue; } } _processWindow = new WaitWindow { Text = "Загрузка файла..." }; _processWindow.Show(Window.GetWindow(this), true); _ftpClient.DownloadFileCompleted += OnFtpClientDownloadFileCompleted; _ftpClient.DownloadFileAsync(uri, newFile); break; } }
private async void ApplyChanges() { if (SourceSearchResults.Any(s => s.TuSelected)) { System.Windows.Application.Current.Dispatcher.Invoke(delegate { _waitWindow = new WaitWindow(); _waitWindow.Show(); }); var selectedSearchResult = SourceSearchResults.Where(s => s.TuSelected).ToList(); List <AnonymizeTranslationMemory> tusToAnonymize; //file base tms var fileBasedSearchResult = selectedSearchResult.Where(t => !t.IsServer).ToList(); if (fileBasedSearchResult.Count > 0) { BackupFileBasedTm(); tusToAnonymize = GetTranslationUnitsToAnonymize(fileBasedSearchResult); Tm.AnonymizeFileBasedTu(tusToAnonymize); } //server based tms var serverBasedSearchResult = selectedSearchResult.Where(t => t.IsServer).ToList(); if (serverBasedSearchResult.Count > 0) { tusToAnonymize = GetTranslationUnitsToAnonymize(serverBasedSearchResult); var uri = new Uri(_tmViewModel.Credentials.Url); var translationProvider = new TranslationProviderServer(uri, false, _tmViewModel.Credentials.UserName, _tmViewModel.Credentials.Password); BackupServerBasedTm(translationProvider, tusToAnonymize); Tm.AnonymizeServerBasedTu(translationProvider, tusToAnonymize); } RemoveSelectedTusToAnonymize(); _waitWindow?.Close(); } else { await _dialogCoordinator.ShowMessageAsync(this, "", "Please select at least one translation unit to apply the changes"); } }
public void LoadSteps() { LoadStepWindow dlg = new LoadStepWindow(); dlg.ShowDialog(); var waitWindow = new WaitWindow(); waitWindow.Show(); var old = m_Record; m_Record = dlg.Record; if (m_Record == null && old != null) { m_Record = old; } if (m_Record != null) { ShowAll(); } waitWindow.Close(); }
/// <summary> /// Loads all workers. /// </summary> public async void LoadWorkersAsync() { #pragma warning disable CS4014 Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() => { try { WaitWindow.ShowDialog(); } catch (InvalidOperationException e) { } })); #pragma warning restore CS4014 App.SetConnectionResource(); switch (App.DataSource) { case ConnectionResource.LOCALAPI: Workers = new ObservableCollection <Worker>(await new WebServiceManager <Worker>().GetAllAsync()); break; case ConnectionResource.LOCALMYSQL: using (var ctx = new MysqlDbContext(ConnectionResource.LOCALMYSQL)) { Workers = new ObservableCollection <Worker>(await ctx.DbSetWorkers.Include(w => w.Address).ToListAsync()); } break; default: break; } await Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() => { WaitWindow.Close(); })); }
/// <summary> /// Loads all products. /// </summary> public async void LoadProductsAsync(bool inStockOnly = false) { #pragma warning disable CS4014 Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() => { try { WaitWindow.ShowDialog(); } catch (InvalidOperationException e) { } })); #pragma warning restore CS4014 App.SetConnectionResource(); switch (App.DataSource) { case ConnectionResource.LOCALAPI: if (inStockOnly) { CPUs = new ObservableCollection <CPU>(await new WebServiceManager <CPU>().GetAllAsync(true)); GPUs = new ObservableCollection <GPU>(await new WebServiceManager <GPU>().GetAllAsync(true)); Motherboards = new ObservableCollection <Motherboard>(await new WebServiceManager <Motherboard>().GetAllAsync(true)); Rams = new ObservableCollection <Memory>(await new WebServiceManager <Memory>().GetAllAsync(true)); StorageComponents = new ObservableCollection <Storage>(await new WebServiceManager <Storage>().GetAllAsync(true)); PSUs = new ObservableCollection <PSU>(await new WebServiceManager <PSU>().GetAllAsync(true)); Cases = new ObservableCollection <Case>(await new WebServiceManager <Case>().GetAllAsync(true)); } else { try { CPUs = new ObservableCollection <CPU>(await new WebServiceManager <CPU>().GetAllAsync()); GPUs = new ObservableCollection <GPU>(await new WebServiceManager <GPU>().GetAllAsync()); Motherboards = new ObservableCollection <Motherboard>(await new WebServiceManager <Motherboard>().GetAllAsync()); Rams = new ObservableCollection <Memory>(await new WebServiceManager <Memory>().GetAllAsync()); StorageComponents = new ObservableCollection <Storage>(await new WebServiceManager <Storage>().GetAllAsync()); PSUs = new ObservableCollection <PSU>(await new WebServiceManager <PSU>().GetAllAsync()); Cases = new ObservableCollection <Case>(await new WebServiceManager <Case>().GetAllAsync()); } catch (TaskCanceledException e) { LoadProductsAsync(inStockOnly); } } break; case ConnectionResource.LOCALMYSQL: using (var ctx = new MysqlDbContext(ConnectionResource.LOCALMYSQL)) { if (inStockOnly) { CPUs = new ObservableCollection <CPU>(await ctx.DbSetCPUs.Where(cpu => cpu.Stock > 0).ToListAsync()); GPUs = new ObservableCollection <GPU>(await ctx.DbSetGPUs.Where(gpu => gpu.Stock > 0).ToListAsync()); Motherboards = new ObservableCollection <Motherboard>(await ctx.DbSetMotherboards.Where(mb => mb.Stock > 0).ToListAsync()); Rams = new ObservableCollection <Memory>(await ctx.DbSetMemories.Where(ram => ram.Stock > 0).ToListAsync()); StorageComponents = new ObservableCollection <Storage>(await ctx.DbSetStorages.Where(storage => storage.Stock > 0).ToListAsync()); PSUs = new ObservableCollection <PSU>(await ctx.DbSetPSUs.Where(psu => psu.Stock > 0).ToListAsync()); Cases = new ObservableCollection <Case>(await ctx.DbSetCases.Where(pcCase => pcCase.Stock > 0).ToListAsync()); } else { CPUs = new ObservableCollection <CPU>(await ctx.DbSetCPUs.ToListAsync()); GPUs = new ObservableCollection <GPU>(await ctx.DbSetGPUs.ToListAsync()); Motherboards = new ObservableCollection <Motherboard>(await ctx.DbSetMotherboards.ToListAsync()); Rams = new ObservableCollection <Memory>(await ctx.DbSetMemories.ToListAsync()); StorageComponents = new ObservableCollection <Storage>(await ctx.DbSetStorages.ToListAsync()); PSUs = new ObservableCollection <PSU>(await ctx.DbSetPSUs.ToListAsync()); Cases = new ObservableCollection <Case>(await ctx.DbSetCases.ToListAsync()); } } break; default: break; } await Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() => { WaitWindow.Close(); })); }
void MessageReceived(NotificationMessage notificationMessage) { Dispatcher.BeginInvoke(new Action(() => { if (notificationMessage.Notification == Messages.ShowWaitWindowLoading) { if (waitWindow != null) { waitWindow.Close(); } waitWindow = new WaitWindow("Loading please wait...") { Owner = this }; waitWindow.Closed += (sender, e) => viewModel.CancelLoading(); waitWindow.ShowDialog(); } else if (notificationMessage.Notification == Messages.ShowWaitWindowSaving) { if (waitWindow != null) { waitWindow.Close(); } waitWindow = new WaitWindow("Saving please wait...") { Owner = this }; waitWindow.Closed += (sender, e) => viewModel.CancelLoading(); waitWindow.ShowDialog(); } else if (notificationMessage.Notification == Messages.ShowAboutWindow) { if (aboutWindow != null) { aboutWindow.Close(); } aboutWindow = new AboutWindow(viewModel.GetApplicationInformation().ProductName) { DataContext = notificationMessage.Target, Owner = this }; aboutWindow.ShowDialog(); } else if (notificationMessage.Notification == Messages.ShowSettings) { if (settingsWindow != null) { settingsWindow.Close(); } settingsWindow = new SettingsWindow { DataContext = notificationMessage.Target, Owner = this }; settingsWindow.ShowDialog(); } else if (notificationMessage.Notification == Messages.DismissWaitWindow) { if (waitWindow != null) { waitWindow.Close(); waitWindow = null; } } else if (notificationMessage.Notification == Messages.DismissSettingsWindow) { if (settingsWindow != null) { settingsWindow.Close(); settingsWindow = null; } } else if (notificationMessage.Notification == Messages.ReValidateAllRows) { RevalidateAllRows(); } else if (notificationMessage.Notification == Messages.RefreshDataGridRowNumbers) { CustumerDataGrid.Items.Refresh(); } })); }
public void CloseWaitDialog() { _waitDialog.Close(); }