/// <summary> /// 訊息對話窗設定 /// </summary> public async Task CheckDatabaseResult(MessageBoxModel messageBox, VerifyRecordResult verifyRecordResult) { MessageBox = messageBox; if (verifyRecordResult.Success == false) { if (verifyRecordResult.MessageId == CommonDomain.Enums.ErrorMessageEnum.客製化文字錯誤訊息) { string message; if (verifyRecordResult.Exception == null) { message = $"{verifyRecordResult.Message}"; } else { message = $"{verifyRecordResult.Message},例外異常:{verifyRecordResult.Exception.Message}"; } MessageBox.Show("400px", "200px", "發生例外異常", message, MessageBox.HiddenAsync); EventAggregator.GetEvent <ToastEvent>().Publish(new ToastPayload() { Title = "重要通知", Content = "系統發生例外異常,請查詢系統日誌系統來查看發生原因", Timeout = 7000, Color = "Red", }); } } await Task.Yield(); }
public bool Show() { var messageBox = new MessageBoxModel { Text = "Baza danych już istnieje. Czy chcesz ją usunąć?", Caption = "Info", Icon = MessageBoxImage.Question, Buttons = new[] { MessageBoxButtons.Yes("Tak"), MessageBoxButtons.No("Nie") }, IsSoundEnabled = false }; var buttons = messageBox.Buttons.ToArray(); buttons[0].IsDefault = false; buttons[1].IsDefault = true; MessageBox.Show(messageBox); switch (messageBox.Result) { case MessageBoxResult.No: return(false); case MessageBoxResult.Yes: return(true); default: throw new ArgumentOutOfRangeException(); } }
private void DebugToolstripItem_Click(object sender, RoutedEventArgs e) { if (settings.AdvancedMode) { var parent = Application.Current.MainWindow; if (parent != null) { var debugWnd = new DebugDialog(cpu, modules, MEMCFG, BMC, AsusWmi) { Owner = parent, Width = parent.Width, Height = parent.Height }; debugWnd.ShowDialog(); } } else { var messageBox = new MessageBoxModel { Text = "Debug functionality requires Advanced Mode.\n\n" + "Do you want to enable it now (the application will restart automatically)?", Caption = "Debug Report", Buttons = MessageBoxButtons.YesNoCancel() }; MessageBox.Show(messageBox); if (messageBox.Result == MessageBoxResult.Yes) { settings.AdvancedMode = true; Restart(); } } }
public bool Show() { var messageBox = new MessageBoxModel { Text = "Czy na pewno chcesz usunąć książkę?", Caption = "Info", Icon = MessageBoxImage.Warning, Buttons = new[] { MessageBoxButtons.Yes("Tak"), MessageBoxButtons.No("Nie") }, IsSoundEnabled = false }; MessageBox.Show(messageBox); switch (messageBox.Result) { case MessageBoxResult.No: return(false); case MessageBoxResult.Yes: return(true); default: throw new ArgumentOutOfRangeException(); } }
void NewCertificate(object o) { var errors = ValidateInputs(); if (!errors.ToString().IsNullOrEmpty()) { MessageBoxContent = new MessageBoxViewModel(CloseMessageBox, MessageBoxModel.Error("Errors generating Certificate - " + Environment.NewLine + errors.ToString())); IsMessageBoxVisible = true; return; } var keygen = KeyPairUtils.CreateGenerator(Repository.Srand, Model.KeyPairGenerator, Model.KeyStrength); var keypair = keygen.GenerateKeyPair(); //load the ca pfx file var caStore = X509Utils.LoadCAPfx(Repository.Instance.KeyStorePassword); var caCert = caStore.GetCertificate("ca").Certificate; var caKey = caStore.GetKey("ca").Key; var cert = X509Utils.GenerateUserCertificate(Model.X509Name, caCert.SubjectDN, Model.Validity, keypair.Public, caKey, Model.SignatureAlgorithm, KeyUsageUtils.GetKeyUsage(Model.KeyUsages), Model.ExtendedKeyUsages == null ? null : new ExtendedKeyUsage( KeyUsageUtils.GetExtendedKeyUsages( Model.ExtendedKeyUsages))); _newCertCompletedAction.Invoke(Model.CommonName, cert, keypair); }
public override void OnAuthorization(AuthorizationContext filterContext) { base.OnAuthorization(filterContext); bool skipAuthorization = filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), inherit: true) || filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(AllowAnonymousAttribute), inherit: true); if (skipAuthorization) { return; } #region 判断是否有该权限 if (permissions != null) { MessageBoxModel messageBox = new MessageBoxModel(); messageBox.No = Guid.NewGuid().ToString(); messageBox.Type = MessageBoxTip.Exception; messageBox.Title = "You do not have permission to access the possible link timeout "; if (!filterContext.HttpContext.Request.IsAuthenticated) { messageBox.Content = "Please re <a href=\"javascript:void(0)\" onclick=\"window.top.location.href='" + ManagerUtils.GetLoginPage() + "'\">sigin</a>"; } bool IsHasPermission = HttpContext.Current.User.Identity.IsInPermission(permissions); if (!IsHasPermission) { bool isAjaxRequest = filterContext.RequestContext.HttpContext.Request.IsAjaxRequest(); if (isAjaxRequest) { CustomJsonResult jsonResult = new CustomJsonResult(ResultType.Exception, messageBox.No, messageBox.Title, messageBox); jsonResult.JsonRequestBehavior = JsonRequestBehavior.AllowGet; filterContext.Result = jsonResult; filterContext.Result.ExecuteResult(filterContext); filterContext.HttpContext.Response.End(); return; } else { string masterName = "_LayoutHome"; if (filterContext.HttpContext.Request.QueryString["dialogtitle"] != null) { masterName = "_Layout"; } filterContext.Result = new ViewResult { ViewName = "MessageBox", MasterName = masterName, ViewData = new ViewDataDictionary { Model = messageBox } }; return; } } } #endregion }
void DataLoading() { List <Employee> employees = new List <Employee>(); try { DIConfig.ComposeContainer.ComposeParts(this); EmployeeLogic.Login = Credentials.Login; EmployeeLogic.Password = Credentials.Password; employees = EmployeeLogic.GetEmployees(); } catch (Exception ex) { MessageBoxVM = new MessageBoxModel() { Message = ErrorMessage.MakingMessageForMessageBox(ex), Caption = errCaption }; Log.WriteLogAsync(ex); } Mapper.Map <List <EmployeeView> >(employees) .ForEach(e => { e.PropertyChanged += (s, eArgs) => OnEmployeeViewChnaged(e, eArgs.PropertyName); e.EmplProjViews.CollectionChanged += (s, eArgs) => OnEmplProjViewsCountChanged(e, eArgs.NewItems, eArgs.OldItems); e.LeadProjViews.CollectionChanged += (s, eArgs) => OnLeadProjViewsCountChanged(e, eArgs.NewItems, eArgs.OldItems); EmployeeViews.Add(e); }); CurrentEmplView = EmployeeViews.FirstOrDefault(); }
private void OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { Log.Error("{Exception}", e.Exception); var messageBox = new MessageBoxModel { Text = $"An unhandled exception occurred: {e.Exception.Message}", Caption = "Fatal Error", Icon = MessageBoxImage.Error, Buttons = new[] { MessageBoxButtons.Custom("Reset Settings", EErrorKind.ResetSettings), MessageBoxButtons.Custom("Restart", EErrorKind.Restart), MessageBoxButtons.Custom("OK", EErrorKind.Ignore) }, IsSoundEnabled = false }; MessageBox.Show(messageBox); if (messageBox.Result == MessageBoxResult.Custom && (EErrorKind)messageBox.ButtonPressed.Id != EErrorKind.Ignore) { if ((EErrorKind)messageBox.ButtonPressed.Id == EErrorKind.ResetSettings) { UserSettings.Delete(); } ApplicationService.ApplicationView.Restart(); } e.Handled = true; }
private void PInfoListItem_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ListBoxItem senderItem = sender as ListBoxItem; string toDownload = senderItem.Tag.ToString(); MessageBoxModel downloadMsg = new MessageBoxModel { Text = "Downloading file from this url: " + toDownload, Caption = "Confirm download", Icon = AdonisUI.Controls.MessageBoxImage.Information, Buttons = new[] { MessageBoxButtons.Ok(), MessageBoxButtons.Cancel(), }, }; MessageBox.Show(downloadMsg); if (downloadMsg.Result == AdonisUI.Controls.MessageBoxResult.OK) { new WebClient().DownloadFile(new Uri(toDownload), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\FLauncher\Plugins\" + senderItem.Content + ".dll"); MessageBox.Show("Plugin download complete, restart FLauncher to use it", "Download Complete"); } }
public void OnException(ExceptionContext context) { var _Exception = context.Exception; if (_Exception is MessageBox _Error) { context.ExceptionHandled = true; context.HttpContext.Response.StatusCode = 200; if (_Error.Model.status == (int)EMessageBoxStatus.自定义) { context.Result = new JsonResult(_Error.Model.msg); } else { context.Result = new JsonResult(_Error.Model); } } else { Tools.Log.Write(_Exception, context.HttpContext.Connection.RemoteIpAddress.ToString());//nlog 写入日志到 txt var _MessageBoxModel = new MessageBoxModel($"服务端出现异常![异常消息:{_Exception.Message}]", EMessageBoxStatus.务端异常); context.Result = new JsonResult(_MessageBoxModel); } }
void CancelChanges() { if (EmployeeViews.Where(e => e.IsAdded).Count() > 0 || EmployeeViews.Where(e => e.IsChanged).Count() > 0 || EmployeeViews.Where(e => e.IsDeleted).Count() > 0) { MessageBoxVM = new MessageBoxModel() { Message = "Все внесённые изменения будут удалены. Продолжить?", Caption = "сотрудники", Buttons = MessageBoxButton.YesNo }; if (MessageBoxVM.Result == MessageBoxResult.Yes) { int numOfAdded = 0; foreach (var eV in EmployeeViews) { if (eV.IsAdded) { numOfAdded++; } if (eV.IsChanged) { eV.Name = eV.Backup.Name; if (eV.IsChanged) { eV.Surname = eV.Backup.Surname; } if (eV.IsChanged) { eV.MiddleName = eV.Backup.MiddleName; } if (eV.IsChanged) { eV.EMail = eV.Backup.EMail; } } if (eV.IsDeleted) { eV.IsDeleted = false; } } while (numOfAdded > 0) { EmployeeViews.Remove(EmployeeViews.First(eV => eV.IsAdded)); numOfAdded--; } if (EmployeeViews.FirstOrDefault(eV => eV.IsAdded || eV.IsDeleted) != null) { IsEmployeeViewsChanged = true; } else { IsEmployeeViewsChanged = false; } } } }
private void GenerateKey() { var sb = new StringBuilder(); sb.Append("Error generating Key").Append(Environment.NewLine); if (Model.Password.IsNullOrEmpty()) { sb.Append("Enter Password!").Append(Environment.NewLine); } if (Model.Salt.IsNullOrEmpty()) { sb.Append("Enter Salt!").Append(Environment.NewLine); } if (Model.KeySize <= 0) { sb.Append("Enter KeySize!").Append(Environment.NewLine); } if (!Model.BouncyImplementation && Model.Iterations <= 0) { sb.Append("Enter Iterations value!").Append(Environment.NewLine); } if (Model.BouncyImplementation && Model.Digest == null) { sb.Append("Select Digest!").Append(Environment.NewLine); } if (Model.BouncyImplementation && Model.DerivationFunction == null) { sb.Append("Select derivation function!").Append(Environment.NewLine); } var errors = sb.ToString(); if (!errors.IsNullOrEmpty()) { MessageBoxContent = new MessageBoxViewModel(CloseMessageBox, MessageBoxModel.Error(errors)); IsMessageBoxVisible = true; return; } byte[] password = Encoding.UTF32.GetBytes(Model.Password); byte[] salt = Encoding.UTF32.GetBytes(Model.Salt); if (Model.BouncyImplementation) { Model.Key = new byte[Model.KeySize]; var digest = Model.Digest.Instance <IDigest>(); var kdf = Model.DerivationFunction.Instance <BaseKdfBytesGenerator>(digest); var kdfParams = new KdfParameters(password, salt); kdf.Init(kdfParams); kdf.GenerateBytes(Model.Key, 0, Model.Key.Length); } else { var k1 = new Rfc2898DeriveBytes(password, salt, Model.Iterations); Model.Key = k1.GetBytes(Model.KeySize); } }
void FilterViewFromDB() { if (LoadFromDb == true) { List <Employee> employees = new List <Employee>(); try { if (EmployeeViews.Where(eV => eV.IsAdded).Count() > 0 || EmployeeViews.Where(eV => eV.IsChanged).Count() > 0 || EmployeeViews.Where(eV => eV.IsDeleted).Count() > 0) { MessageBoxVM = new MessageBoxModel() { Message = "Все внесённые изменения будут удалены. Продолжить?", Caption = "сотрудники", Buttons = MessageBoxButton.YesNo }; if (MessageBoxVM.Result == MessageBoxResult.Yes) { while (EmployeeViews.Count > 0) { EmployeeViews.Remove(EmployeeViews.First()); } employees = LoadFilteredDataFromDb(FilterControlName); } } else { while (EmployeeViews.Count > 0) { EmployeeViews.Remove(EmployeeViews.First()); } employees = LoadFilteredDataFromDb(FilterControlName); } } catch (Exception ex) { MessageBoxVM = new MessageBoxModel() { Message = ErrorMessage.MakingMessageForMessageBox(ex), Caption = errCaption }; Log.WriteLogAsync(ex); } Mapper.Map <List <EmployeeView> >(employees) .ForEach(e => { e.PropertyChanged += (s, eArgs) => OnEmployeeViewChnaged(e, eArgs.PropertyName); e.EmplProjViews.CollectionChanged += (s, eArgs) => OnEmplProjViewsCountChanged(e, eArgs.NewItems, eArgs.OldItems); e.LeadProjViews.CollectionChanged += (s, eArgs) => OnLeadProjViewsCountChanged(e, eArgs.NewItems, eArgs.OldItems); EmployeeViews.Add(e); }); } }
void SaveChanges() { MessageBoxVM = new MessageBoxModel() { Message = "Выполнить сохранение всех внесённых изменений?", Caption = EmployeeView.Surname + " " + EmployeeView.Name + " " + EmployeeView.MiddleName + ": Проекты", Buttons = MessageBoxButton.YesNo }; if (MessageBoxVM.Result == MessageBoxResult.Yes) { Employee employee = Mapper.Map <EmployeeView, Employee>(EmployeeView); IEnumerable <EmplProjView> emplProjViewsToAdd = EmplProjViews.Where(ePV => ePV.IsChanged && ePV.IsChecked); IEnumerable <EmplProjView> emplProjViewsToDelete = EmplProjViews.Where(ePV => ePV.IsChanged && ePV.IsChecked == false); List <Project> projsToAdd = Mapper.Map <IEnumerable <EmplProjView>, List <Project> >(emplProjViewsToAdd); List <Project> projsToDelete = Mapper.Map <IEnumerable <EmplProjView>, List <Project> >(emplProjViewsToDelete); bool IsChangesSaved = false; try { IsChangesSaved = EmplProjsLogic.SetProjectsToEmployee(employee, projsToAdd, projsToDelete); } catch (Exception ex) { MessageBoxVM = new MessageBoxModel() { Message = ErrorMessage.MakingMessageForMessageBox(ex), Caption = errCaption }; Log.WriteLogAsync(ex); } if (IsChangesSaved) { foreach (var emplProjView in emplProjViewsToAdd) { EmployeesViewModel.CurrentEmplView .EmplProjViews .Add(emplProjView); } foreach (var emplProjView in emplProjViewsToDelete) { EmployeesViewModel.CurrentEmplView .EmplProjViews .Remove(emplProjView); } foreach (var emplProjView in EmplProjViews) { emplProjView.IsChanged = false; emplProjView.BackupClear(); } IsEmplProjViewsChanged = false; } } }
public static string ProcessRequest(string Request, Socket sender) { Data data = new Data(); data.Type = Request.Split(new char[0])[0]; data.Contents = Request; for (int i = 0; i < data.Type.Length + 1; i++) { data.Contents = data.Contents.Substring(1, data.Contents.Length - 1); } if (data.Type == "MessageBox") { MessageBoxModel MessageBoxObj = new MessageBoxModel(); Console.Write("Başlık Girin: "); MessageBoxObj.Title = Console.ReadLine(); Console.Write("Açıklama Girin: "); MessageBoxObj.Description = Console.ReadLine(); Console.WriteLine("\n" + "1 - Tamam\n" + "2 - Evet/Hayır\n" + "3 - Tamam/İptal\n" + "4 - İptal/Yeniden Dene/Yoksay"); Console.Write("Buton Tipi: "); MessageBoxObj.BoxButtons = int.Parse(Console.ReadLine()); Console.WriteLine("\n" + "1 - Hata\n" + "2 - Bilgi\n" + "3 - Soru İşareti\n" + "4 - Uyarı"); Console.Write("Buton Tipi: "); MessageBoxObj.BoxIcon = int.Parse(Console.ReadLine()); data.Contents = JsonConvert.SerializeObject(MessageBoxObj); } if (data.Type == "-MessageBox") { data.Type = "MessageBox"; } else if (data.Type == "Heartrate") { InRandomizer = true; //sender.Shutdown(SocketShutdown.Both); //sender.Close(); SubprocessController sb = new SubprocessController(@"C:\Users\Torchizm\Desktop\MiBand-HeartrateOutput.exe"); sb.OutputDataReceived += Sb_OutputDataReceived; } return(JsonConvert.SerializeObject(data)); }
void SaveChanges() { MessageBoxVM = new MessageBoxModel() { Message = "Выполнить сохранение всех внесённых изменений?", Caption = ProjectView.ProjName + ": Выбор руководителя", Buttons = MessageBoxButton.YesNo }; if (MessageBoxVM.Result == MessageBoxResult.Yes) { Project project = Mapper.Map <ProjectView, Project>(ProjectView); ProjLeadView selectedProjLeadView = ProjLeadViews.FirstOrDefault(pLV => pLV.IsChanged && pLV.IsChecked); ProjLeadView previousProjLeadView = ProjLeadViews.FirstOrDefault(pLV => pLV.IsChanged && !pLV.IsChecked); Employee selectedLeader = Mapper.Map <ProjLeadView, Employee>(selectedProjLeadView); bool IsChangesSaved = false; try { IsChangesSaved = ProjLeadLogic.SetLeaderToProject(project, selectedLeader); } catch (Exception ex) { MessageBoxVM = new MessageBoxModel() { Message = ErrorMessage.MakingMessageForMessageBox(ex), Caption = errCaption }; Log.WriteLogAsync(ex); } if (IsChangesSaved) { if (ViewModelsContainer.EmployeesViewModel != null) { ViewModelsContainer.EmployeesViewModel.IsEmployeeViewsChangedByProjectsViewModel = true; if (previousProjLeadView != null) { ViewModelsContainer.EmployeesViewModel .EmployeeViews .First(eV => eV.Id == previousProjLeadView.Id) .LeadProjViews.Remove(Mapper.Map <EmplProjs.EmplProjView>(ProjectsViewModel.CurrentProjView)); } ViewModelsContainer.EmployeesViewModel.IsEmployeeViewsChangedByProjectsViewModel = false; } ProjectsViewModel.CurrentProjView.ProjLeadView = selectedProjLeadView; foreach (var projLeadView in ProjLeadViews) { projLeadView.IsChanged = false; } IsProjLeadViewsChanged = false; } } }
void SaveChanges() { MessageBoxVM = new MessageBoxModel() { Message = "Выполнить сохранение всех внесённых изменений?", Caption = ProjectView.ProjName + ": Сотрудники", Buttons = MessageBoxButton.YesNo }; if (MessageBoxVM.Result == MessageBoxResult.Yes) { Project project = Mapper.Map <ProjectView, Project>(ProjectView); IEnumerable <ProjEmplView> projEmplViewsToAdd = ProjEmplViews.Where(pEV => pEV.IsChanged && pEV.IsChecked); IEnumerable <ProjEmplView> projEmplViewsToDelete = ProjEmplViews.Where(pEV => pEV.IsChanged && pEV.IsChecked == false); List <Employee> projsToAdd = Mapper.Map <IEnumerable <ProjEmplView>, List <Employee> >(projEmplViewsToAdd); List <Employee> projsToDelete = Mapper.Map <IEnumerable <ProjEmplView>, List <Employee> >(projEmplViewsToDelete); bool IsChangesSaved = false; try { IsChangesSaved = ProjEmplsLogic.SetEmployeesToProject(project, projsToAdd, projsToDelete); } catch (Exception ex) { MessageBoxVM = new MessageBoxModel() { Message = ErrorMessage.MakingMessageForMessageBox(ex), Caption = errCaption }; Log.WriteLogAsync(ex); } if (IsChangesSaved) { foreach (var projEmplView in projEmplViewsToAdd) { ProjectsViewModel.CurrentProjView.ProjEmplViews.Add(projEmplView); } foreach (var projEmplView in projEmplViewsToDelete) { ProjectsViewModel.CurrentProjView.ProjEmplViews.Remove(projEmplView); } foreach (var projEmplView in ProjEmplViews) { projEmplView.IsChanged = false; projEmplView.BackupClear(); } IsProjEmplViewsChanged = false; } } }
public void ShowErrorBox(string errorMessage) { var messageBox = new MessageBoxModel { Text = $"Unfortunately an error occurred: {errorMessage}", Caption = "Ups?", Icon = MessageBoxImage.Error, Buttons = new [] { MessageBoxButtons.Ok() } }; MessageBox.Show(messageBox); }
public MainWindow() { ToolTipService.InitialShowDelayProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata(250)); ToolTipService.ShowDurationProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata(int.MaxValue)); InitializeComponent(); DataContext = _vm; if (ApplicationConfiguration.Instance.HasAcknowledgedDonationDialog) { return; } var messageBox = new MessageBoxModel { Text = "Hello, Gamer! \r\n\r\nDid you know this project was only possible with years of dedication and enthusiasm? " + "You're receiving this work for absolutely free. If it brings you joy please consider giving back to the " + "author's efforts and show your appreciation through a donation. \r\n\r\nThanks for your attention ❤️", Caption = "May I have your attention", Icon = MessageBoxImage.Question, Buttons = new[] { MessageBoxButtons.Cancel("Acknowledged"), MessageBoxButtons.Yes("Sure, show me how!") }, CheckBoxes = new[] { new MessageBoxCheckBoxModel("I've already donated or will consider it") { IsChecked = false, Placement = MessageBoxCheckBoxPlacement.BelowText } }, IsSoundEnabled = false }; MessageBox.Show(messageBox); switch (messageBox.Result) { case MessageBoxResult.Yes: Process.Start("https://vigem.org/Donations/"); break; } ApplicationConfiguration.Instance.HasAcknowledgedDonationDialog = messageBox.CheckBoxes.First().IsChecked; }
public MessageBoxResult ShowMessageBox(string text, string caption, MessageBoxImage icon, IEnumerable <IMessageBoxButtonModel> buttons) { var messageBox = new MessageBoxModel { Text = text, Caption = caption, Icon = icon, Buttons = buttons.ToArray() }; return(MessageBox.Show(messageBox)); }
void IExceptionFilter.OnException(ExceptionContext filterContext) { if (LogicalThreadContext.Properties["trackid"] == null) { if (HttpContext.Current.Session != null) { LogicalThreadContext.Properties["trackid"] = HttpContext.Current.Session.SessionID; } } ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); bool isAjaxRequest = filterContext.RequestContext.HttpContext.Request.IsAjaxRequest(); string controller = (string)filterContext.RouteData.Values["controller"]; string action = (string)filterContext.RouteData.Values["action"]; MessageBoxModel messageBox = new MessageBoxModel(); messageBox.No = Guid.NewGuid().ToString(); messageBox.Type = MessageBoxTip.Exception; messageBox.Title = "抱歉,访问出错"; // messageBox.Content = "<a href=\"javascript:void(0)\" onclick=\"window.top.location.href='" + OwnWebSettingUtils.GetHomePage() + "'\">返回主页</a>"; messageBox.IsTop = false; messageBox.IsPopup = true; if (CommonUtils.CanViewErrorStackTrace()) { messageBox.ErrorStackTrace = CommonUtils.ToHtml(filterContext.Exception.Message + "\r\n" + filterContext.Exception.StackTrace); } //判断是否异步调用 if (isAjaxRequest) { CustomJsonResult jsonResult = new CustomJsonResult(ResultType.Exception, ResultCode.Exception, messageBox.Title, messageBox); //jsonResult.JsonRequestBehavior = JsonRequestBehavior.AllowGet; filterContext.Result = jsonResult; filterContext.Result.ExecuteResult(filterContext); filterContext.HttpContext.Response.End(); } else { filterContext.Result = new ViewResult { ViewName = "MessageBox", MasterName = "_Layout", ViewData = new ViewDataDictionary { Model = messageBox } }; } filterContext.ExceptionHandled = true; log.Error("发生异常错误[编号:" + messageBox.No + "]", filterContext.Exception); }
void IExceptionFilter.OnException(ExceptionContext filterContext) { ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); bool isAjaxRequest = filterContext.RequestContext.HttpContext.Request.IsAjaxRequest(); string controller = (string)filterContext.RouteData.Values["controller"]; string action = (string)filterContext.RouteData.Values["action"]; MessageBoxModel messageBox = new MessageBoxModel(); messageBox.No = Guid.NewGuid().ToString(); messageBox.Type = MessageBoxTip.Exception; messageBox.Title = "I'm sorry,Access error"; messageBox.Content = "<a href=\"javascript:void(0)\" onclick=\"window.top.location.href='" + ManagerUtils.GetHomePage() + "'\">Go Home</a>"; if (ManagerUtils.CanViewErrorStackTrace()) { messageBox.ErrorStackTrace = CommonUtils.ToHtml(filterContext.Exception.Message + "\r\n" + filterContext.Exception.StackTrace); } //判断是否异步调用 if (isAjaxRequest) { CustomJsonResult jsonResult = new CustomJsonResult(ResultType.Exception, messageBox.No, messageBox.Title, messageBox); jsonResult.JsonRequestBehavior = JsonRequestBehavior.AllowGet; filterContext.Result = jsonResult; filterContext.Result.ExecuteResult(filterContext); filterContext.HttpContext.Response.End(); } else { string masterName = "_LayoutHome"; if (filterContext.HttpContext.Request.QueryString["dialogtitle"] != null) { masterName = "_Layout"; } filterContext.Result = new ViewResult { ViewName = "MessageBox", MasterName = masterName, ViewData = new ViewDataDictionary { Model = messageBox } }; } filterContext.ExceptionHandled = true; log.Error("An exception error occurred [number:" + messageBox.No + "]", filterContext.Exception); }
private async void OnStartup(object sender, StartupEventArgs e) { RxApp.MainThreadScheduler.Schedule(async() => { var settings = Locator.Current.GetService <SettingsViewModel>(); settings.Restore(); }); #if !DO_NOT_INCLUDE_UPDATER InstallerRunner.CleanUpInstaller(); var generalSettings = Locator.Current.GetService <IEnumerable <SettingsGroupViewModelBase> >() .OfType <GeneralSettingsGroupViewModel>() .Single(); if (!generalSettings.CheckForUpdatesOnStartup) { return; } var ghubClient = new GitHubClient(new ProductHeaderValue("Image-Sort")); var updateFetcher = new GitHubUpdateFetcher(ghubClient); (var success, var release) = await updateFetcher.TryGetLatestReleaseAsync(generalSettings.InstallPrereleaseBuilds).ConfigureAwait(true); if (success) { var messageBox = new MessageBoxModel { Caption = Text.UpdateAvailablePromptTitle, Text = Text.UpdateAvailablePromptText.Replace("{TagName}", release.TagName ?? "NO TAG INFORMATION AVAILABLE", StringComparison.OrdinalIgnoreCase), Buttons = new[] { MessageBoxButtons.Yes(Text.Update), MessageBoxButtons.No(Text.DoNotUpdate) }, Icon = AdonisUI.Controls.MessageBoxImage.Question }; if (AdonisUI.Controls.MessageBox.Show(messageBox) == AdonisUI.Controls.MessageBoxResult.Yes && updateFetcher.TryGetInstallerFromRelease(release, out var installerAsset)) { var installer = await updateFetcher.GetStreamFromAssetAsync(installerAsset).ConfigureAwait(false); InstallerRunner.RunAsync(installer).ConfigureAwait(false); } } #endif }
public override void Execute(MessageBoxReferenceViewModel contextViewModel, object parameter) { var messageBox = new MessageBoxModel { Text = CreateMessage(MessageLength), Caption = CreateMessage(CaptionLength), Icon = Icon, Buttons = Buttons, CheckBoxes = CheckBoxes, }; contextViewModel.CurrentMessageBox = messageBox; MessageBox.Show(messageBox); }
void Compose() { try { DIConfig.ComposeContainer.ComposeParts(this); } catch (CompositionException ex) { Log.WriteLogAsync(ex); MessageBoxVM = new MessageBoxModel() { Message = ErrorMessage.MakingMessageForMessageBox(ex), Caption = errCaption, }; } }
void DataLoading() { EmplProjsLogic.Login = Credentials.Login; EmplProjsLogic.Password = Credentials.Password; Title = EmployeeView.Surname + " " + EmployeeView.Name + " " + EmployeeView.MiddleName + ": Проекты"; errCaption = EmployeeView.Surname + " " + EmployeeView.Name + " " + EmployeeView.MiddleName + ": Проекты - Ошибка"; List <Project> projects = new List <Project>(); IEnumerable <EmplProjView> emplProjViews; try { projects = EmplProjsLogic.GetProjects(); } catch (Exception ex) { MessageBoxVM = new MessageBoxModel() { Message = ErrorMessage.MakingMessageForMessageBox(ex), Caption = errCaption }; Log.WriteLogAsync(ex); emplProjViews = new List <EmplProjView>(); } emplProjViews = Mapper.Map <IEnumerable <EmplProjView> >(projects); foreach (var emplProjView in emplProjViews) { if (EmployeeView.EmplProjViews.FirstOrDefault(ePV => ePV.Id == emplProjView.Id) == null) { emplProjView.IsChecked = false; } } foreach (var emplProjView in emplProjViews) { emplProjView.PropertyChanged += (s, e) => OnEmplProjViewChanged(emplProjView, e.PropertyName); EmplProjViews.Add(emplProjView); } }
private void CommandExecuted(object o) { var pboxes = (object[])o; var sb = new StringBuilder(); char[] password1 = ((PasswordBox)pboxes[0]).Password.ToArray(); char[] password2 = ((PasswordBox)pboxes[1]).Password.ToArray(); if (password1.Length == 0) { sb.Append("please enter a password").Append(Environment.NewLine); } if (!password1.SequenceEqual(password2)) { sb.Append("password and confirm do not match").Append(Environment.NewLine); } if (Path.IsNullOrEmpty()) { sb.Append("please select a path ").Append(Environment.NewLine); } if (AlgorithmRequired && SelectedAlgorithm.IsNullOrEmpty()) { sb.Append("please select an algorithm ").Append(Environment.NewLine); } Array.Clear(password1, 0, password1.Length); Array.Clear(password2, 0, password2.Length); var errors = sb.ToString(); if (!errors.IsNullOrEmpty()) { MessageBoxContent = new MessageBoxViewModel(CloseMessageBox, MessageBoxModel.Error("Error exporting to file - " + Environment.NewLine + errors)); IsMessageBoxVisible = true; return; } char[] password = ((PasswordBox)pboxes[0]).Password.ToArray(); if (AlgorithmRequired) { _action.Invoke(_entry, SelectedAlgorithm, password, Path); } else { _exportPkcs12Action.Invoke(_entry, Path, password); } }
void DataLoading() { LeadProjsLogic.Login = Credentials.Login; LeadProjsLogic.Password = Credentials.Password; Title = LeaderView.Surname + " " + LeaderView.Name + " " + LeaderView.MiddleName + ": Руководимые проекты"; errCaption = LeaderView.Surname + " " + LeaderView.Name + " " + LeaderView.MiddleName + ": Руководимые проекты - Ошибка"; List <Project> projects = new List <Project>(); IEnumerable <EmplProjView> leadProjViews; try { projects = LeadProjsLogic.GetProjects(); } catch (Exception ex) { MessageBoxVM = new MessageBoxModel() { Message = ErrorMessage.MakingMessageForMessageBox(ex), Caption = errCaption }; Log.WriteLogAsync(ex); leadProjViews = new List <EmplProjView>(); } leadProjViews = Mapper.Map <IEnumerable <EmplProjView> >(projects); foreach (var leadProjView in leadProjViews) { if (LeaderView.LeadProjViews.FirstOrDefault(lPV => lPV.Id == leadProjView.Id) == null) { leadProjView.IsChecked = false; } } foreach (var leadProjView in leadProjViews) { leadProjView.PropertyChanged += (s, e) => OnLeadProjViewChanged(leadProjView, e.PropertyName); LeadProjViews.Add(leadProjView); } }
void DataLoading() { ProjEmplsLogic.Login = Credentials.Login; ProjEmplsLogic.Password = Credentials.Password; Title = ProjectView.ProjName + ": Сотрудники"; errCaption = "Сотрудники проекта: " + ProjectView.ProjName + " - Ошибка"; List <Employee> employees = new List <Employee>(); IEnumerable <ProjEmplView> projEmplViews; try { employees = ProjEmplsLogic.GetEmployees(); } catch (Exception ex) { MessageBoxVM = new MessageBoxModel() { Message = ErrorMessage.MakingMessageForMessageBox(ex), Caption = errCaption }; Log.WriteLogAsync(ex); projEmplViews = new List <ProjEmplView>(); } projEmplViews = Mapper.Map <IEnumerable <ProjEmplView> >(employees); foreach (var projEmplView in projEmplViews) { if (ProjectView.ProjEmplViews.FirstOrDefault(pEV => pEV.Id == projEmplView.Id) == null) { projEmplView.IsChecked = false; } } foreach (var projEmplView in projEmplViews) { projEmplView.PropertyChanged += (s, e) => OnProjEmplViewChanged(projEmplView, e.PropertyName); ProjEmplViews.Add(projEmplView); } }
public ActionsView() { InitializeComponent(); this.WhenActivated(disposableRegistration => { this.BindCommand(ViewModel, vm => vm.Undo, view => view.Undo) .DisposeWith(disposableRegistration); this.BindCommand(ViewModel, vm => vm.Redo, view => view.Redo) .DisposeWith(disposableRegistration); this.OneWayBind(ViewModel, vm => vm.LastDone, view => view.Undo.ToolTip) .DisposeWith(disposableRegistration); this.OneWayBind(ViewModel, vm => vm.LastUndone, view => view.Redo.ToolTip) .DisposeWith(disposableRegistration); ViewModel.NotifyUserOfError.RegisterHandler(ic => { var messageBox = new MessageBoxModel { Caption = Text.Error, Text = ic.Input, Icon = MessageBoxImage.Error, Buttons = new[] { MessageBoxButtons.Ok(Text.OK) } }; MessageBox.Show(messageBox); ic.SetOutput(Unit.Default); }); }); }