public static void RegisterApplicationDispatcherUnhandledExceptionHandler(this ExceptionlessClient client) {
            if (client == null)
                throw new ArgumentNullException(nameof(client));

            if (System.Windows.Application.Current == null)
                return;
            
            if (_onApplicationDispatcherUnhandledException == null)
                _onApplicationDispatcherUnhandledException = (sender, args) => {
                    var contextData = new ContextData();
                    contextData.MarkAsUnhandledError();
                    contextData.SetSubmissionMethod("DispatcherUnhandledException");

                    args.Exception.ToExceptionless(contextData, client).Submit();

                    // process queue immediately since the app is about to exit.
                    client.ProcessQueue();
                };

            try {
                System.Windows.Application.Current.DispatcherUnhandledException -= _onApplicationDispatcherUnhandledException;
                System.Windows.Application.Current.DispatcherUnhandledException += _onApplicationDispatcherUnhandledException;
            } catch (Exception ex) {
                client.Configuration.Resolver.GetLog().Error(typeof(ExceptionlessClientExtensions), ex, "An error occurred while wiring up to the application dispatcher exception event.");
            }
        }
        public static void UnregisterApplicationDispatcherUnhandledExceptionHandler(this ExceptionlessClient client) {
            if (_onApplicationDispatcherUnhandledException == null)
                return;

            if (System.Windows.Application.Current != null)
                System.Windows.Application.Current.DispatcherUnhandledException -= _onApplicationDispatcherUnhandledException;
            
            _onApplicationDispatcherUnhandledException = null;
        }
Example #3
0
        public App()
        {
            DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);

            xeus2.Properties.Resources.Culture = new CultureInfo("en-US");

            //Console.WriteLine("RCL: {0}", (RenderCapability.Tier >> 16));

            NotificationPopup.Instance.Initialize(new InfoPopup());

            Database.OpenDatabase();
        }
Example #4
0
        public static void UnregisterApplicationDispatcherUnhandledExceptionHandler(this ExceptionlessClient client)
        {
            if (_onApplicationDispatcherUnhandledException == null)
            {
                return;
            }

            if (System.Windows.Application.Current != null)
            {
                System.Windows.Application.Current.DispatcherUnhandledException -= _onApplicationDispatcherUnhandledException;
            }

            _onApplicationDispatcherUnhandledException = null;
        }
Example #5
0
        protected override void OnStartup(StartupEventArgs e)
        {
            AppHelper.Startup();
            try
            {
                AppHelper.CopyFilesToDocumentFolder();
            }
            catch { }

            var startupProjectPath = string.Empty;

            AppHelper.ParseArguments(e.Args, ref startupProjectPath, string.Empty);

            base.OnStartup(e);

            DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(app_DispatcherUnhandledException);
            AppHelper.Started(startupProjectPath);
        }
Example #6
0
        protected override void OnStartup(StartupEventArgs e)
        {
            IUnityContainer container = new UnityContainer();

            container.RegisterType <IBuildingService, BuildingService>();
            container.RegisterType <ISuiteService, SuiteService>();

            var buildingsViewModel = container.Resolve <BuildingViewModel>();
            var window             = new MainWindow {
                DataContext = buildingsViewModel
            };

            window.Show();

            Current.DispatcherUnhandledException       += new DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException);
            DispatcherUnhandledException               += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
        }
        private async void Application_Startup(object sender, StartupEventArgs e)
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            notifyIcon         = new();
            notifyIcon.Visible = true;
            notifyIcon.Click  += NotifyIcon_Click;

            InitWindow_ = new InitWindow();
            InitWindow_.Show();

            IMinecraft_QQ.ShowMessageCall = new IMinecraft_QQ.ShowMessage((string data) =>
            {
                MessageBox.Show(data);
            });
            IMinecraft_QQ.ServerConfigCall = new IMinecraft_QQ.ServerConfig((string key, string value) =>
            {
                MainWindow_?.ServerConfig(key, value);
            });
            IMinecraft_QQ.LogCall = new IMinecraft_QQ.Log((string data) =>
            {
                MainWindow_?.AddLog(data);
            });
            await IMinecraft_QQ.Start();

            IMinecraft_QQ.GuiCall = new IMinecraft_QQ.Gui((GuiFun fun) =>
            {
                Dispatcher.Invoke(() =>
                {
                    switch (fun)
                    {
                    case GuiFun.ServerList:
                        MainWindow_?.InitServerList();
                        break;

                    case GuiFun.PlayerList:
                        MainWindow_?.InitPlayerList();
                        break;
                    }
                });
            });
        }
Example #8
0
        protected override void OnStartup(StartupEventArgs e)
        {
            // run bootstrapper
            Bootstrapper bootstrapper = new Bootstrapper();
            bootstrapper.Run();

            // set shut down mode
            ShutdownMode = ShutdownMode.OnExplicitShutdown;
            MainContext = (DispatcherSynchronizationContext)DispatcherSynchronizationContext.Current;

            MainWindow.Closing += (sender, args) =>
                MainContext.Send(o => Shutdown(), null);

            // handle exceptions
            DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
            
            base.OnStartup(e);

            MainWindow.Show();
        }
Example #9
0
        protected override void OnStartup(StartupEventArgs e)
        {
            // run bootstrapper
            Bootstrapper bootstrapper = new Bootstrapper();

            bootstrapper.Run();

            // set shut down mode
            ShutdownMode = ShutdownMode.OnExplicitShutdown;
            MainContext  = (DispatcherSynchronizationContext)DispatcherSynchronizationContext.Current;

            MainWindow.Closing += (sender, args) =>
                                  MainContext.Send(o => Shutdown(), null);

            // handle exceptions
            DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);

            base.OnStartup(e);

            MainWindow.Show();
        }
        public static void RegisterApplicationDispatcherUnhandledExceptionHandler(this ExceptionlessClient client) {
            if (System.Windows.Application.Current == null)
                return;
            
            if (_onApplicationDispatcherUnhandledException == null)
                _onApplicationDispatcherUnhandledException = (sender, args) => {
                    var contextData = new ContextData();
                    contextData.MarkAsUnhandledError();
                    contextData.SetSubmissionMethod("DispatcherUnhandledException");

                    args.Exception.ToExceptionless(contextData, client).Submit();
                    args.Handled = true;
                };

            try {
                System.Windows.Application.Current.DispatcherUnhandledException -= _onApplicationDispatcherUnhandledException;
                System.Windows.Application.Current.DispatcherUnhandledException += _onApplicationDispatcherUnhandledException;
            } catch (Exception ex) {
                client.Configuration.Resolver.GetLog().Error(typeof(ExceptionlessClientExtensions), ex, "An error occurred while wiring up to the application dispatcher exception event.");
            }
        }
        protected override void OnStartup(StartupEventArgs e)
        {
            // ManualResetEvent acts as a block. It waits for a signal to be set.
            _resetSplashCreated = new ManualResetEvent(false);

            // Create a new thread for the splash screen to run on
            Thread _splashThread = new Thread(ShowSplash);

            _splashThread.SetApartmentState(ApartmentState.STA);
            _splashThread.IsBackground = true;
            _splashThread.Name         = "Splash Screen";
            _splashThread.Start();

            // Wait for the blocker to be signaled before continuing. This is essentially the same as: while(ResetSplashCreated.NotSet) {}
            SplashSyncEvent.WaitOne();

            //Now that the splash screen is shown let's continue

            //Register this method for displaying unhandled exception in the appropriate window
            DispatcherUnhandledException +=
                new DispatcherUnhandledExceptionEventHandler(
                    DispatcherUnhandledExceptionHandler);

            //Inits the database
            _dbOp.Init();

            base.OnStartup(e);

            //Closes the splash screen since everything is done
            App._splashScreen.LoadComplete();
            _isStartingUp = false;
            SplashSyncEvent.Reset();
            //Will wait once more until the splash window is really closed
            SplashSyncEvent.WaitOne();
            SplashSyncEvent.Close();
        }
Example #12
0
 public void App_Startup(object sender, StartupEventArgs e)
 {
     DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
 }
Example #13
0
 public void App_Startup(object sender, StartupEventArgs e)
 {
     DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
 }//event
Example #14
0
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
 }
Example #15
0
 protected override void OnStartup(StartupEventArgs e)
 {
     Current.DispatcherUnhandledException       += new DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException);
     DispatcherUnhandledException               += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
     AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
 }
Example #16
0
 private void SetupLogger()
 {
     log4net.Config.XmlConfigurator.Configure();
     DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
 }
Example #17
0
        protected override void OnStartup(StartupEventArgs e)
        {
            ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "乘法云链", out bool createNew);

            if (!createNew)
            {
                MessageBox.Show("已有一个程序实例运行");
                Current.Shutdown();
                Environment.Exit(0);
            }

            base.OnStartup(e);

            //控制台信息展示
            ConsoleManager.Show();

            Console.ReadKey();

            // 注册Application_Error(全局捕捉异常)
            DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);

            //初始化日志
            LogUtils.InitLog4Net();

            //隐藏工具类
            Taskbar.HideTask(true);

            //开启启动
            BootUpHelper.GetInstance().SetMeAutoStart();

            //加载系统配置文件
            //Console.ReadKey();
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load($"{ApplicationState.GetProjectRootPath()}/MyProject.xml");
            XmlNode root   = xmlDoc.SelectSingleNode("config");          //指向根节点
            XmlNode device = root.SelectSingleNode("device");            //指向设备节点

            ApplicationState.SetUserInfo(new User());
            //设置初始化goodsInfo
            ApplicationState.SetInitGoodsInfo(new HashSet <CommodityEps>());

            ApplicationState.SetEquipName(device.SelectSingleNode("equip_name").InnerText);
            ApplicationState.SetEquipId(device.SelectSingleNode("equip_id").InnerText);

            ApplicationState.SetHouseName(device.SelectSingleNode("house_name").InnerText);
            ApplicationState.SetHouseId(device.SelectSingleNode("house_id").InnerText);

            ApplicationState.SetMCabName(device.SelectSingleNode("mcab_name").InnerText);
            ApplicationState.SetMCabId(device.SelectSingleNode("mcab_id").InnerText);
#if DUALCAB
            ApplicationState.SetSCabName(device.SelectSingleNode("scab_name").InnerText);
            ApplicationState.SetSCabId(device.SelectSingleNode("scab_id").InnerText);
#endif
            ApplicationState.SetMLockerCOM(device.SelectSingleNode("mlocker_com").InnerText);         //"COM2"
            ApplicationState.SetSLockerCOM(device.SelectSingleNode("slocker_com").InnerText);         //"COM5"

            ApplicationState.SetMRfidCOM(device.SelectSingleNode("mrfid_com").InnerText);             //"COM1"
            ApplicationState.SetSRfidCOM(device.SelectSingleNode("srfid_com").InnerText);             //"COM4"

            ApplicationState.SetMVeinCOM(device.SelectSingleNode("mvein_com").InnerText);             //"COM9"

            LogUtils.Debug("App config initial...");

            #region 处理开机(即应用启动时)需要对比库存变化上传的逻辑

            //获取当前机柜所有商品数据
            HashSet <CommodityEps> currentCommodityEps = RfidHelper.GetEpcDataJson(out bool isGetSuccess);

            //判断是否是初次使用本地库存上次,如果是则不上传
            bool isInitLocalCommodityEpsInfo = CommodityCodeBll.GetInstance().isInitLocalCommodityEpsInfo();

            if (isGetSuccess && !isInitLocalCommodityEpsInfo)
            {
                //获取数据库记录的以前所有商品数据
                HashSet <CommodityEps> lastCommodityEps = CommodityCodeBll.GetInstance().GetLastLocalCommodityEpsInfo();

                //比对
                List <CommodityCode> commodityCodeList = CommodityCodeBll.GetInstance().GetCompareSimpleCommodity(lastCommodityEps, currentCommodityEps);

                //有不同的情况,则需要处理上传逻辑
                if (commodityCodeList != null && commodityCodeList.Count > 0)
                {
                    //根据商品码集合获取完整商品属性集合(已对比后结果)
                    var bdCommodityCodeList = CommodityCodeBll.GetInstance().GetCommodityCode(commodityCodeList);

                    var checkbdCommodityCodeList = HttpHelper.GetInstance().ResultCheck(bdCommodityCodeList, out bool isSuccess);

                    if (isSuccess)
                    {
                        //按照类似无单一般领用的方式(故障领用)
                        var bdBasePostData = ConsumingBll.GetInstance().SubmitConsumingChangeWithoutOrder(bdCommodityCodeList, ConsumingOrderType.故障领用);

                        //校验是否含有数据
                        HttpHelper.GetInstance().ResultCheck(bdBasePostData, out bool isSuccess1);
                        if (!isSuccess1)
                        {
                            LogUtils.Error("提交故障领用结果失败!" + bdBasePostData.message);
                        }
                        else
                        {
                            LogUtils.Info("提交故障领用结果成功!" + bdBasePostData.message);
                        }
                    }
                    else
                    {
                        LogUtils.Info("提交故障领用结果成功!");
                    }
                }
            }

            #endregion
        }
Example #18
0
 public App()
 {
     DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
     TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
     Startup += new StartupEventHandler(App_Startup);
 }
Example #19
0
 public App()
 {
     AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
     DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
 }
Example #20
0
 public App()
 {
     DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
 }
Example #21
0
 public App()
 {
     DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
     AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
 }
Example #22
0
 public App()
 {
     DispatcherUnhandledException          += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
     TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
     Startup += new StartupEventHandler(App_Startup);
 }
Example #23
0
 public App()
 {
     DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
 }