private void DeleteDomain() { var children = _view.PnlDomainContainer.Children; for (var i = children.Count - 1; i >= 0; i--) { if (children[i].GetType() == typeof(LDAPDomainExpanderElement)) { var expander = children[i] as LDAPDomainExpanderElement; if (expander.Model.IsActived) { var confirmdialog = new ConfirmDialog("Are you sure you want to delete selected domain?", "CONFIRM DELETE"); confirmdialog.ConfirmText.Text = "Are you sure you want to delete selected domain?"; confirmdialog.BtnOk.Focus(); if (confirmdialog.ShowDialog() == true) { if (!expander.Model.IsNotSaved) { var deleteBg = new BackgroundWorker(); deleteBg.DoWork += DeleteBg_DoWork; deleteBg.RunWorkerAsync(expander.Model.Id); } _view.PnlDomainContainer.Children.RemoveAt(i); ApplicationContext.LDAPList.RemoveAll(r => r.Id == expander.Model.Id); LDAPTreeDataSource = new ObservableCollection <DirectoryNode>(); } break; } } } }
public static bool ConfirmDialog(string message) { bool confirm = false; using (ConfirmDialog Dialog = new ConfirmDialog() { Message = message, ForeColor = this.ForeColour, BackColor = this.BackColour, ButtonBackColour = this.ButtonBackColour, ButtonForeColour = this.ButtonForeColour, ButtonFlatStyle = this.ButtonFlatStyle }) { DialogResult dr = Dialog.ShowDialog(); if (dr == DialogResult.Yes) { confirm = true; } else { confirm = false; } } return(confirm); }
private void ConfirmAlbumRemove(int albumID) { IsBusy = true; Task <Album> albumFetchTask = Task.Factory.StartNew <Album>(() => { return(dataService.GetAlbum(albumID)); }, TaskScheduler.Default); Task finishFetchTask = albumFetchTask.ContinueWith((a) => { IsBusy = false; var removingAlbum = a.Result; if (removingAlbum != null) { ConfirmDialog confirm = new ConfirmDialog() { HeaderText = "Remove album confirmation", MessageText = String.Format("Do you really want to delete album {0}? " + "All listenings and tracks will be also removed", removingAlbum.Name) }; if (confirm.ShowDialog() == true) { RemoveAlbumImpl(removingAlbum); } } }, TaskScheduler.FromCurrentSynchronizationContext()); //var album = dataService.GetAlbum(albumID); }
private void OnMenuSelected(Button btn) { if (btn == null) { return; } switch (btn.Name) { case UIConstant.BtnSoftwareAddPackage: DisplayAddOrEditDialog(0); break; case UIConstant.BtnSoftwareEditPackage: var selectedId = ViewList.First(r => r.IsSelected).Id; DisplayAddOrEditDialog(selectedId); break; case UIConstant.BtnSoftwareDeletePackage: var confirmDlg = new ConfirmDialog("Are you sure you want to delete?", "Delete Software"); if (confirmDlg.ShowDialog() == true) { DeleteContent(); } break; } }
private void OnRemoveListeningCommand(object parameter) { if (SelectedListening == null) { Notify("Please select listening first", NotificationType.Warning); } else { ConfirmDialog dialog = new ConfirmDialog() { HeaderText = "Listening remove confirmation", MessageText = "Do you really want to remove listening: " + SelectedListening.Date.ToShortDateString() + " ?" }; if (dialog.ShowDialog() == true) { bool deleted = dataService.RemoveListening(SelectedListening); if (deleted) { Notify("Listening has been successfully removed", NotificationType.Success); } else { Notify("Can't remove selected listening. See log for details", NotificationType.Error); } LoadListenings(); } } }
private void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { var page = new ConfirmDialog(); page.Caption = "错误信息"; page.Message = GetInnerException(e.Exception).Message; page.ShowDialog(); e.Handled = true; }
private void OnSavePolicyCommand(object arg) { if (string.IsNullOrWhiteSpace(POCServer) || string.IsNullOrWhiteSpace(Key) || Port == null) { _messageDialog.ShowMessageDialog("Server information (POCServer, Port, Key) cannot be null", "Message"); return; } if (SynchronizationInterval == null || TransferInterval == null || (SynchronizationInterval != null && SynchronizationInterval <= 0) || (TransferInterval != null && TransferInterval <= 0)) { _messageDialog.ShowMessageDialog("Time interval cannot be null or less than 0", "Message"); return; } var pocAgent = new POCAgent { POCServer = POCServer, Key = Key, Port = Port.Value, Name = Name, NeighborhoodWatch = NeighborhoodWatch, ActiveTransfer = ActiveTransfer, UpdateSource = UpdateSource, SyncInterval = SynchronizationInterval.Value, TransferInterval = TransferInterval.Value, Color = PolicyColor, Id = Id }; if (pocServerOrigin != POCServer || portOrigin != Port.Value || keyOrigin != Key) { var confirmDlg = new ConfirmDialog("Are you sure you want to save these informations?", "Save policy"); if (confirmDlg.ShowDialog() == true) { using (var sc = new POCServiceClient("NetTcpBinding_IPOCService")) { var requestData = EncryptionHelper.EncryptString(JsonConvert.SerializeObject(pocAgent), KeyEncryption); sc.EditPolicy(requestData); UpdatePocAgent(pocAgent); } } } else { using (var sc = new POCServiceClient("NetTcpBinding_IPOCService")) { var requestData = EncryptionHelper.EncryptString(JsonConvert.SerializeObject(pocAgent), KeyEncryption); sc.EditPolicy(requestData); UpdatePocAgent(pocAgent); } } }
private void RemoveProduct() { ConfirmDialog confirmDialog = new ConfirmDialog("CẢNH BÁO", "Mặt hàng này sẽ không tồn tại trong hệ thống nếu tiếp tục. Xác nhận xóa mặt hàng?", (Action) delegate { ProductModel.RemoveFromDatabase(SelectedProduct.ID); }); confirmDialog.ShowDialog(); listProductModel.LoadAllProduct(); bufferList = listProductModel.List; }
private void RemoveIngridient() { ConfirmDialog confirmDialog = new ConfirmDialog("CẢNH BÁO", "Nguyên liệu này sẽ không tồn tại trong hệ thống nếu tiếp tục. Xác nhận xóa nguyên liệu?", (Action) delegate { IngridientModel.RemoveFromDatabase(SelectedIngridient.ID); }); confirmDialog.ShowDialog(); listIngridientModel.LoadAllIngridient(); bufferList = listIngridientModel.List; }
private void OnAttachGenresKeyboardCommand(object parameter) { /* * Currently Genres filtered collection is loaded synchronously. This means that when we press Enter key * Genres collection is already loaded. Please take into account this behavour in case of any changes */ KeyEventArgs args = parameter as KeyEventArgs; if (args != null && args.Key == Key.Enter) { var matchingGenre = Genres.Where(g => g.Name == GenresFilterValue).FirstOrDefault(); if (matchingGenre == null) { ConfirmDialog confirm = new ConfirmDialog() { HeaderText = "Create new genre confirmation", MessageText = String.Format("Do you really want to create new genre {0}", GenresFilterValue) }; if (confirm.ShowDialog() == true) { matchingGenre = new Genre() { Name = GenresFilterValue }; if (!dataService.SaveGenre(matchingGenre)) { Notify("Can't save new genre to database. See log for details", NotificationType.Error); matchingGenre = null; } else { LoadGenres(); } } } if (matchingGenre != null) { SelectedGenres = new List <Genre>() { matchingGenre }; } RaiseAttachGenresEvent(SelectedGenres); } }
private void ResetDatabase_buttonClick(object sender, RoutedEventArgs e) { var confirmDialog = new ConfirmDialog() { Owner = Window.GetWindow(this) }; confirmDialog.ShowDialog(); if (confirmDialog.DialogResult != null && confirmDialog.DialogResult == true) { var dbCommun = new DatabaseCommunicator(); dbCommun.ResetDatabase(); } }
public static bool ShowConfirmBox(this FrameworkElement source, string message, string caption = null) { var dialog = new ConfirmDialog() { Message = message, Owner = Window.GetWindow(source) }; if (caption == null) { dialog.Title = Lang.GetText(App.Name); } return(dialog.ShowDialog() == true); }
/// <summary> /// 子列表项目键盘事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SubItemOnKeyDown(object sender, KeyEventArgs e) { //按下删除键 if (e.Key == Key.Delete) { var subListView = (ListView)sender; //获取选中对象 var selected = subListView.SelectedItem as DeviceSyncItem; if (null == selected) { return; } var selectedDevice = (MediaDevice)DeviceListCombobox.SelectedItem; var selectedDriver = (DeviceDriverViewModel)DriverListCombobox.SelectedItem; if (selected.SourceView == SyncDeviceType.PHONE && (null == selectedDevice || null == selectedDriver)) { return; } var confirmDialog = new ConfirmDialog(AlertLevel.WARN, string.Format((string)Application.Current.FindResource("DeleteConfirm"), selected.NameView)); //确认删除 if (confirmDialog.ShowDialog().GetValueOrDefault()) { //从电脑删除 if (selected.SourceView == SyncDeviceType.PC) { FileUtil.DeleteFile(Path.Combine(selected.FolderView, selected.NameView)); } else { //从手机删除 using (selectedDevice) { selectedDevice.Connect(); var targetFile = Path.Combine(selectedDriver.ValueView, selected.FolderView, selected.NameView); if (selectedDevice.FileExists(targetFile)) { selectedDevice.DeleteFile(targetFile); } selectedDevice.Disconnect(); } } //从vm中移除对象 var subListViewItemSource = (ObservableCollection <DeviceSyncItem>)subListView.ItemsSource; subListViewItemSource.Remove(selected); } } }
private void DeletePolicy() { var confirmDlg = new ConfirmDialog("Are you sure you want to delete these informations?", "Delete policy"); if (confirmDlg.ShowDialog() == true) { if (ApplicationContext.PoliciesList != null) { var listId = ApplicationContext.PoliciesList.Select(r => r.Id).ToList(); var requestObj = new StringAuthenticateObject { StringAuth = "OK", StringValue = string.Join(",", listId) }; using (var sc = new POCServiceClient("NetTcpBinding_IPOCService")) { var requestData = EncryptionHelper.EncryptString(JsonConvert.SerializeObject(requestObj), KeyEncryption); sc.DeletePolicy(requestData); } foreach (var policyElementViewModel in ApplicationContext.PoliciesList) { //policyElementViewModel.IsActived = true; _view.PnlPolicyContainer.Children.Remove(policyElementViewModel._view); } ApplicationContext.POCAgentList.RemoveAll( r => ApplicationContext.PoliciesList.Select(r2 => r2.Id).Contains(r.Id)); ApplicationContext.PoliciesList.Clear(); if (_view.PnlPolicyContainer.Children.Count > 0 && ApplicationContext.POCAgentList.Count > 0) { var item = ApplicationContext.POCAgentList.FirstOrDefault(i => i.Id == Id); if (item == null) { Id = ApplicationContext.POCAgentList.FirstOrDefault().Id; BuildPage(); } } else { BtnSaveVisible = false; } } } }
private void export_Click(object sender, RoutedEventArgs e) { string dbPath = this.filePath.Text; if (dbPath == null || dbPath.Trim().Equals("")) { this.info.Content = "请选择有效路径!"; return; } //获取文件名,不带路径 string fileNameExt = this.filePath.Text.Substring(this.filePath.Text.LastIndexOf("\\") + 1); fileNameExt.Insert(1, "dameng"); string dir = this.filePath.Text; try { if(File.Exists(dir)) { ConfirmDialog confirm = new ConfirmDialog("导出数据","当前路径已经存在同名文件,要覆盖吗?"); if(confirm.ShowDialog() == true) { this.info.Content = "正在导出文件到" + dir + " ......"; System.IO.File.Copy(AppDomain.CurrentDomain.BaseDirectory + "/data/ETTS_test.db", dir,true); this.info.Content = "文件已经导出到" + dir + " !"; } } else { this.info.Content = "正在导出文件到" + dir + " ......"; System.IO.File.Copy(AppDomain.CurrentDomain.BaseDirectory + "/data/ETTS_test.db", dir); this.info.Content = "文件已经导出到" + dir + " !"; } } catch (Exception) { Message msg = new Message("导出数据", "导出文件出错!"); msg.ShowDialog(); } //fs.Close(); }
public Key ShowMessage(string message, string caption = "提示信息", Brush icon = null, List <Tuple <string, Key, Action> > btns = null) { var dialog = new ConfirmDialog(); dialog.Caption = caption; dialog.Message = message; dialog.IconBrush = icon; if (btns != null) { foreach (var btn in btns) { dialog.AddButton(btn.Item1, btn.Item2, btn.Item3); } } dialog.ShowDialog(); return(dialog.ResultKey); }
private IEnumerator removeInnerScheme(UIScheme.InnerContainer container, ConfirmDialog dialog) { dialog.ShowDialog("Удалить схему " + container.SchemeName + "?", "Удалив схему, будут удалены все связанные с ней ссылки"); yield return(new WaitWhile(() => dialog.DialogResult == DialogResult.NotReady)); var dialogResult = dialog.DialogResult; dialog.Dispose(); if (dialogResult == DialogResult.Cancel) { yield break; } CurrentScheme.DeleteInnerScheme(container); yield break; }
private void UpdateWasteMark(bool isWaste) { if (CurrentAlbum == null) { Notify("Please select album first", NotificationType.Info); return; } if (CurrentAlbum.IsWaste != isWaste) // we're actually changing waste status { ConfirmDialog confirm = new ConfirmDialog() { HeaderText = isWaste == true ? "Confirm waste mark" : "Confirm waste mark removal", MessageText = isWaste == true?String.Format("Do you really want to mark album {0} as wasted?", CurrentAlbum.Name) : String.Format("Do you really want to unmark album {0} as wasted?", CurrentAlbum.Name) }; if (confirm.ShowDialog() == true) { CurrentAlbum.IsWaste = isWaste; IsBusy = true; Task <bool> saveAlbumTask = Task.Factory.StartNew <bool>(() => { return(dataService.SaveAlbumWasted(CurrentAlbum)); }, TaskScheduler.Default); Task finishedTask = saveAlbumTask.ContinueWith((t) => { IsBusy = false; if (t.Result) { LoadAlbums(); } else { Notify("Can't update album. See log for details", NotificationType.Error); } }, TaskScheduler.FromCurrentSynchronizationContext()); } } }
private void ConfirmAndWasteArtist(bool isWaste, IList <Album> albums) { ConfirmDialog confirm = new ConfirmDialog() { HeaderText = isWaste == true ? "Confirm waste mark" : "Confirm waste mark removal", MessageText = isWaste == true?String.Format("Do you really want to mark artist {0} as wasted?", CurrentArtist.Name) : String.Format("Do you really want to unmark artist {0} as wasted?", CurrentArtist.Name), CheckBoxText = isWaste ? String.Format("Also waste all albums of {0}", CurrentArtist.Name) : String.Empty }; if (confirm.ShowDialog() == true) { bool wasteChildAlbums = confirm.CheckBoxChecked; CurrentArtist.IsWaste = isWaste; IsBusy = true; Task <bool> saveArtistTask = Task.Factory.StartNew <bool>(() => { return(dataService.SaveArtistWasted(CurrentArtist, wasteChildAlbums)); }, TaskScheduler.Default); Task finishedTask = saveArtistTask.ContinueWith((t) => { IsBusy = false; if (t.Result) { LoadArtists(); if (!IsWasteVisible) { // selected artists becomes invisible, so hide it's albums also ArtistAlbums.Clear(); } } else { Notify("Can't update artist. See log for details", NotificationType.Error); } }, TaskScheduler.FromCurrentSynchronizationContext()); } }
private void Delete_ButtonClick(object sender, RoutedEventArgs e) { var dbCommunicator = new DatabaseCommunicator(); var confirmDialog = new ConfirmDialog() { Owner = Window.GetWindow(this) }; confirmDialog.ShowDialog(); if (confirmDialog.DialogResult != null && confirmDialog.DialogResult == true) { if (NotesListBox.SelectedItem is Note selectedItem) { dbCommunicator.Remove <Note>(x => x.Id == selectedItem.Id); _notes.Remove(selectedItem); ResetTextBox(TextBoxReadonly); } } }
/// <summary> /// Deletes a file or many. /// </summary> /// <param name="action"></param> private void DeleteFile(object action) { var dialog = new ConfirmDialog { Title = "Delete file(s)", Message = "Are you sure you want to delete the selected file(s)?\r\n\r\nYou may lose your changes!", ButtonSet = ConfirmDialog.ButtonsSet.OK_CANCEL }; dialog.ShowDialog(); var pressedButton = (Button)dialog.PressedButton; if (pressedButton != null && ((string)pressedButton.Content) == "OK") { var collection = (IList)action; var items = collection.Cast <StatusItem>(); LibGit2Sharp.Repository repo = null; // Loop through all selected status items and remove the files physically (and in some cases also from the repository). foreach (StatusItem item in items) { // TODO: --cached ? File.Delete(RepositoryFullPath + "/" + item.Filename); if (!item.Status.HasFlag(LibGit2Sharp.FileStatus.Untracked)) { if (!(repo is LibGit2Sharp.Repository)) { repo = new LibGit2Sharp.Repository(RepositoryFullPath); } repo.Index.Unstage(RepositoryFullPath + "/" + item.Filename); } } if (repo is LibGit2Sharp.Repository) { repo.Dispose(); } } }
///////////////////////////////////////////////////////////////////////////// // button event handler private void CancelButton_Click(object sender, EventArgs e) { try { if (IsAllTextboxEmpty() == false) { ConfirmDialog dialog = new ConfirmDialog("프로젝트를 생성하지 않고 프로그램을 종료합니다."); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { return; } } this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void OnSaveConfigurationCommand(object parameter) { if (NHibernateConfig == null) { Notify("Config isn't loaded", NotificationType.Error); return; } ConfirmDialog dialog = new ConfirmDialog() { HeaderText = "Artist remove confirmation", MessageText = "Do you really want to save configuration? Backup will be create automatically" }; if (dialog.ShowDialog() == true) { //backup old config DirectoryInfo dir = new DirectoryInfo(BackupDir); if (!dir.Exists) { dir.Create(); } string newName = "backup" + DateTime.Now.ToBinary().ToString() + '-' + NHibernateConfig.FileName; string fullPath = BackupDir + "\\" + newName; File.Copy(NHibernateConfig.FileName, fullPath, true); if (NHibernateConfig.Save(NHibernateConfig.FileName)) { Notify( String.Format("Configuration has been successfully saved. Created backup {0}", newName), NotificationType.Success); TestNewNHibernateConfiguration(); } else { Notify("Can't save configuration. Unexpected error", NotificationType.Error); } } }
private void OnRemoveArtistCommand(object parameter) { if (CurrentArtist == null) { Notify("Please select artist to be removed", NotificationType.Warning); return; } ConfirmDialog dialog = new ConfirmDialog() { HeaderText = "Artist remove confirmation", MessageText = "Do you really want to remove artist: " + CurrentArtist.Name + " ? All referenced albums, listenings and tracks will be also removed." }; if (dialog.ShowDialog() == true) { IsBusy = true; Task <bool> removeArtistTask = Task.Factory.StartNew <bool>(() => { return(dataService.RemoveArtist(CurrentArtist)); }, TaskScheduler.Default); Task finishTask = removeArtistTask.ContinueWith((r) => { IsBusy = false; if (r.Result) { Notify("Artist has been successfully removed", NotificationType.Success); eventAggregator.GetEvent <ArtistRemovedEvent>().Publish(CurrentArtist.ID); LoadArtists(); } else { Notify("Can't remove selected artist. See log for details", NotificationType.Error); } }, TaskScheduler.FromCurrentSynchronizationContext()); } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (!Config.ExitSilently && !SystemShutdown) { using var dialog = new ConfirmDialog(); if (dialog.ShowDialog(Form) != DialogResult.Yes) { e.Cancel = true; return; } } if (SystemShutdown) { _listFormGroup.WaitForCloseAll(); } else { _listFormGroup.Close(); // 各自で終了処理するのでシャットダウン時は不要 } Config.Location = (Form.WindowState == FormWindowState.Normal ? Form.Bounds : Form.RestoreBounds).Location; Config.ShowHpInPercent = _c.fleetPanel.ShowHpInPercent; }
private void BtnCofirm_Click(object sender, EventArgs e) { int index = dataGridView1.SelectedRows[0].Index; DateTime date = DateTime.Parse(dataGridView1.Rows[index].Cells[0].Value.ToString()); string from = dataGridView1.Rows[index].Cells[2].Value.ToString(); string to = dataGridView1.Rows[index].Cells[3].Value.ToString(); string flightNumber = dataGridView1.Rows[index].Cells[4].Value.ToString(); FlightViewModel temp = new FlightViewModel(); temp = (listtemp.Where(x => x.DateFlight == date && x.From.Equals(from) && x.To.Equals(to) && x.FlightNumber.Equals(flightNumber)).FirstOrDefault()); using (ConfirmDialog confirm = new ConfirmDialog(temp, true)) { if (confirm.ShowDialog() == DialogResult.OK) { //Update confirm to Schedule flightDao.UpdateConfirmViewModel(temp); list = GetReloadList(); SetDataToView(list); } } }
/// <summary> /// Shows the dialog. /// </summary> /// <param name="state">The state.</param> /// <param name="message">The message.</param> /// <param name="title">The title.</param> /// <returns>MessageBoxResult.</returns> private static MessageBoxResult ShowDialog(DialogState state, string message, string title = "Information Dialog") { var dialogView = PageNavigatorHelper._MainWindow.MessageDialogView; switch (state) { case DialogState.Warning: dialogView.ShowMessageDialog(message, title, state); return(MessageBoxResult.OK); case DialogState.Error: dialogView.ShowMessageDialog(message, title, state); return(MessageBoxResult.OK); case DialogState.Confirm: var confirmDialog = new ConfirmDialog(message, title); confirmDialog.BtnOk.Focus(); return(confirmDialog.ShowDialog() ?? false ? MessageBoxResult.Yes : MessageBoxResult.No); default: dialogView.ShowMessageDialog(message, title, state); return(MessageBoxResult.OK); } }
/// <summary> /// Deletes a tag. /// </summary> /// <param name="action"></param> public void DeleteTag(object action) { var tag = (Tag)action; var dialog = new ConfirmDialog { Title = "Deleting a tag", Message = String.Format("Are you sure you want to delete this tag ({0})?", tag.Name) }; dialog.ShowDialog(); var pressedButton = dialog.PressedButton; if (pressedButton == null || ((string)pressedButton.Content) != "OK") { return; } Task.Run(() => { using (var repo = new LibGit2Sharp.Repository(RepositoryFullPath)) { // Remove the tag from the Git repository. repo.Tags.Delete(tag.CanonicalName); // Reload all tags. LoadTags(); Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Normal, (Action)(() => tag.Target.Tags.Remove(tag)) ); } }); }
private void btnMixedGroupUser_Click(object sender, RoutedEventArgs e) { Log.Debug("Protocal Stack Log: (SpnvPage)btnMixedGroupUser_Click, Start"); Button button = sender as Button; if (button == null) { return; } User user = button.DataContext as User; if (user == null) { return; } //先判定4个主通道 var channels = _subsystem.Channels.Channels; foreach (var channel in channels) { if (channel.CallDestNum == user.Number) { //channel.CallState不能单独作为判定依据 //用户来电==>挂起其他通话,接通当前通话 //只有IsIncomingCall为True时,IsStateBlinking才为True,所以此处单独使用IsStateBlinking作为判定条件 if (channel.IsStateBlinking) { _subsystem.Channels.HoldActiveCall(); App.SIPUA.Answer(channel.CallId); Log.Debug(String.Format("Protocal Stack Log: (SpnvPage)btnMixedGroupUser_Click, Main Channel, User Incoming, Hold Active, Answer:{0}, End", channel.CallId)); return; } //通话中==>挂断当前通话 if (channel.IsStateConnected) { App.SIPUA.Hangup(channel.CallId); Log.Debug(String.Format("Protocal Stack Log: (SpnvPage)btnMixedGroupUser_Click, Main Channel, User Connected, Hangup:{0}, End", channel.CallId)); return; } //在呼叫对方==>挂断当前通话 if (channel.CallState == sua_inv_state.PJSIP_INV_STATE_EARLY && channel.IsIncomingCall == false) { App.SIPUA.Hangup(channel.CallId); Log.Debug(String.Format("Protocal Stack Log: (SpnvPage)btnMixedGroupUser_Click, Main Channel, User Connecting Not Connected, Hangup:{0}, End", channel.CallId)); return; } } } //判定左手柄 var leftHandset = _subsystem.LeftHandset; if (leftHandset != null && leftHandset.RemoteNumber == user.Number) { //用户来电会在通道中显示,不会在左右手柄 //通话中==>挂断当前通话 if (leftHandset.CallState == sua_inv_state.PJSIP_INV_STATE_CONFIRMED) { leftHandset.Hangup(); Log.Debug("Protocal Stack Log: (SpnvPage)btnMixedGroupUser_Click, leftHandset, User Connected, Hangup, End"); return; } //在呼叫对方==>挂断当前通话 if (leftHandset.CallState == sua_inv_state.PJSIP_INV_STATE_EARLY) { leftHandset.Hangup(); Log.Debug("Protocal Stack Log: (SpnvPage)btnMixedGroupUser_Click, leftHandset, User Connecting Not Answered, Hangup, End"); return; } } //判断右手柄 var rightHandset = _subsystem.RightHandset; if (rightHandset != null && rightHandset.RemoteNumber == user.Number) { //用户来电会在通道中显示,不会在左右手柄 //通话中==>挂断当前通话 if (rightHandset.CallState == sua_inv_state.PJSIP_INV_STATE_CONFIRMED) { rightHandset.Hangup(); Log.Debug("Protocal Stack Log: (SpnvPage)btnMixedGroupUser_Click, rightHandset, User Connected, Hangup, End"); return; } //在呼叫对方==>挂断当前通话 if (rightHandset.CallState == sua_inv_state.PJSIP_INV_STATE_EARLY) { rightHandset.Hangup(); Log.Debug("Protocal Stack Log: (SpnvPage)btnMixedGroupUser_Click, rightHandset, User Connecting Not Answered, Hangup, End"); return; } } //发起呼叫 //int callId = -1; //_subsystem.Channels.MakeCall(_subsystem.AccountId, user.Number, ref callId); Log.Debug("_________before_____ConfirmDialog____________"); ConfirmDialog dialog = new ConfirmDialog(_subsystem, user.Number) { }; dialog.Owner = Window.GetWindow(this); dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner; dialog.ShowDialog(); Log.Debug("_________after_____ConfirmDialog____________"); //Log.Debug(String.Format("Protocal Stack Log: (SpnvPage)btnMixedGroupUser_Click, Make Call:{0},{1},{2}", _subsystem.AccountId, user.Number, callId)); //Log.Debug("Protocal Stack Log: (SpnvPage)btnMixedGroupUser_Click, End"); }
private void btnMixedGroup_Click(object sender, RoutedEventArgs e) { Log.Debug("Protocal Stack Log: (SpnvPage)btnMixedGroup_Click, Start"); Button button = sender as Button; if (button == null) { Log.Debug("Protocal Stack Log: (SpnvPage)btnMixedGroup_Click, button == null, False End"); return; } Group mixGroup = (Group)button.DataContext; if (mixGroup == null) { Log.Debug("Protocal Stack Log: (SpnvPage)btnMixedGroup_Click, mixGroup == null, False End"); return; } string prefix = _subsystem.PrefixInfo.GetPrefix(DialPrefixType.DialConference); if (string.IsNullOrEmpty(prefix)) { Log.Debug("Protocal Stack Log: (SpnvPage)btnMixedGroup_Click, wrong prefix, False End"); return; } string grpstr = _subsystem.PrefixInfo.GetGroupDialString(mixGroup); string mixconfnum = string.Format("{0}{1}", prefix, grpstr); //先判断主通道 var channels = _subsystem.Channels.Channels; foreach (var channel in channels) { if (channel.IsGroupCall && channel.CallDestNum == mixconfnum) { //挂断会议 App.SIPUA.Hangup(channel.CallId); Log.Debug(String.Format("Protocal Stack Log: (SpnvPage)btnMixedGroup_Click, Conf In Main Channel, Hangup:{0} End", channel.CallId)); return; } } //判断左手柄 var leftHandset = _subsystem.LeftHandset; if (leftHandset != null && leftHandset.RemoteNumber == mixconfnum) { leftHandset.Hangup(); Log.Debug("Protocal Stack Log: (SpnvPage)btnMixedGroup_Click, Conf In leftHandset, Hangup, End"); return; } //判断右手柄 var rightHandset = _subsystem.RightHandset; if (rightHandset != null && rightHandset.RemoteNumber == mixconfnum) { rightHandset.Hangup(); Log.Debug("Protocal Stack Log: (SpnvPage)btnMixedGroup_Click, Conf In rightHandset, Hangup, End"); return; } //以上皆无,则发起会议 //int callId = -1; //_subsystem.Channels.MakeCall(_subsystem.AccountId, mixconfnum, ref callId); Log.Debug("_________before_____ConfirmDialog____________"); ConfirmDialog dialog = new ConfirmDialog(_subsystem, mixconfnum) { }; dialog.Owner = Window.GetWindow(this); dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner; dialog.ShowDialog(); Log.Debug("_________after_____ConfirmDialog____________"); //Log.Debug(String.Format("Protocal Stack Log: (SpnvPage)btnMixedGroup_Click, Make Call:{0},{1},{2}", _subsystem.AccountId, mixconfnum, callId)); //Log.Debug("Protocal Stack Log: (SpnvPage)btnMixedGroup_Click, End"); }
//========================================================================================= // //========================================================================================= private void OnUploadWorkerDoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; using (UploadHelper helper = (UploadHelper)e.Argument) { bool allskip = false; bool allfile = false; try { helper.beginTime = DateTime.Now; helper.numberOfFiles = this.filelistGridView.RowCount; for (int i = 0; i < helper.numberOfFiles; i++) { AppMediator.SINGLETON.Ping(); // index, vname, vsize, vtype, rname, fpath, status DataRow uprow = this.filelistGridView.GetDataRow(i); helper.fileName = Path.Combine(uprow["fpath"].ToString(), uprow["rname"].ToString()); FileInfo fileInfo = new FileInfo(helper.fileName); if (fileInfo.Length == 0) { continue; } DataSet fileSet = null; bool uploadOk = true; bool exists = false; string fileId = String.Empty; helper.fileNumber = i + 1; helper.fileLength = fileInfo.Length; // guid, companyid, fileid, ftype, vsize, vtype, rname, title, description, wdate helper.InfoRow["rname"] = fileInfo.Name; helper.InfoRow["vsize"] = helper.fileLength; helper.InfoRow["vtype"] = helper.GetMIMEType(fileInfo.Extension); if (AppMediator.SINGLETON.PrepareUploadFile(helper.InfoSet, out fileId, out helper.uploadDay, out helper.fileGuid, out helper.maxChunkSize) == false) { fileSet = AppMediator.SINGLETON.GetFileInfo(fileId); if (allskip == true || fileSet == null) { helper.totalFileLength -= helper.fileLength; helper.statusMessage = "skipped"; worker.ReportProgress(helper.percentProgrss, helper as object); continue; } exists = true; if (allfile == false && fileSet != null) { uploadOk = false; DataRow filerow = fileSet.Tables[0].Rows[0]; if (filerow["cmodify"].ToString() == "T" && filerow["cfile"].ToString() == "T") { TimeSpan span = DateTime.Now - helper.beginTime; ConfirmDialog dialog = new ConfirmDialog(helper.MainBox, fileSet, fileInfo); switch (dialog.ShowDialog()) { // '예' // 현재 파일 Upload case DialogResult.Yes: uploadOk = true; break; // 모두 '예' // 나머지 모든 파일 Upload case DialogResult.OK: uploadOk = true; allfile = true; break; // '아니오' case DialogResult.No: break; // 모두 '아니오' // 나머지 모든 파일을 Skip 한다. case DialogResult.Cancel: uploadOk = false; allskip = true; break; // '취소' case DialogResult.Ignore: e.Cancel = true; break; } helper.beginTime = DateTime.Now - span; if (e.Cancel == true) { break; } } } } if (uploadOk == false) { AppMediator.SINGLETON.FailureCloseUploadFile(helper.fileGuid); helper.totalFileLength -= helper.fileLength; helper.statusMessage = "canceled"; worker.ReportProgress(helper.percentProgrss, helper as object); continue; } string title = fileInfo.Name; string contents = String.Empty; if (helper.numberOfFiles == 1) { if (this.SingleFileUpload(fileInfo.Name, ref title, ref contents) == false) { e.Cancel = true; break; } } helper.InfoRow["title"] = title; helper.InfoRow["description"] = contents; using (FileStream stream = new FileStream(helper.fileName, FileMode.Open, FileAccess.Read)) { int iterations = 0; helper.fileLength = stream.Length; helper.fileName = stream.Name; helper.fileWriteSize = 0; int chunksize = 16 * 1024; byte[] buffer = new byte[chunksize]; int bytesRead = stream.Read(buffer, 0, chunksize); while (bytesRead > 0) { if (worker.CancellationPending == true) { break; } try { if (AppMediator.SINGLETON.UploadFile(helper.fileGuid, buffer, helper.fileWriteSize, bytesRead) == true) { if (iterations == UploadHelper.AVERAGE_COUNT + 1) { long timeForInitChunks = (long)DateTime.Now.Subtract(helper.beginTime).TotalMilliseconds; long averageChunkTime = Math.Max(1, timeForInitChunks / UploadHelper.AVERAGE_COUNT); chunksize = (int)Math.Min(helper.maxChunkSize, chunksize * UploadHelper.PREFERRED_TRANSFER_DURATION / averageChunkTime); Array.Resize <byte>(ref buffer, chunksize); } helper.fileWriteSize += bytesRead; helper.totalWriteSize += bytesRead; helper.statusMessage = "transferring"; worker.ReportProgress(helper.percentProgrss, helper as object); } else { throw new Exception("server side error!"); } } catch (Exception ex) { if (helper.NumRetries++ < helper.MaxRetries) { // rewind the filestream and keep trying stream.Position -= bytesRead; } else { stream.Close(); throw new Exception(String.Format("Error occurred during upload, too many retries. \n{0}", ex.ToString())); } } bytesRead = stream.Read(buffer, 0, chunksize); iterations++; } stream.Close(); if (worker.CancellationPending == true) { break; } if (helper.CheckFileHash() == true) { helper.InfoRow["guid"] = Path.GetFileNameWithoutExtension(helper.fileGuid); if (exists == true && fileSet != null) { DataRow filerow = fileSet.Tables[0].Rows[0]; string guid = filerow["guid"].ToString(); string fileid = filerow["fileid"].ToString(); DateTime wdate = Convert.ToDateTime(filerow["wdate"].ToString()); AppMediator.SINGLETON.DeleteFile(guid, fileid, wdate); } AppMediator.SINGLETON.SuccessCloseUploadFile(helper.uploadDay, helper.fileGuid, helper.InfoSet); helper.statusMessage = "completed"; worker.ReportProgress(helper.percentProgrss, helper as object); } } } if (worker.CancellationPending == false && e.Cancel == false) { e.Result = helper as object; e.Cancel = false; return; } } catch (Exception ex) { OFileLog.SNG.WriteLog(ex.ToString()); string error = AppMediator.SINGLETON.ResourceHelper.TranslateWord("작업 중 오류가 발생하였습니다.") + Environment.NewLine + ex.Message; MessageBox.Show(error); } if (String.IsNullOrEmpty(helper.fileGuid) == false) { AppMediator.SINGLETON.FailureCloseUploadFile(helper.fileGuid); } helper.statusMessage = "stopped"; worker.ReportProgress(helper.percentProgrss, helper as object); e.Cancel = true; return; } }