12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using AwInitilizer.DLL;
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- namespace AwInitilizer
- {
- /// <summary>
- /// Interaction logic for App.xaml
- /// </summary>
- public partial class App : Application
- {
- public App():base()
- {
- DispatcherUnhandledException += App_DispatcherUnhandledException;
- }
- protected override void OnActivated(EventArgs e)
- {
- base.OnActivated(e);
- SetUiLanguage();
- SetMes();
- var startResult = SajetConnect.SajetTransStart();
- }
- private void SetUiLanguage()
- {
- var langSetting = AwInitilizer.Properties.Settings.Default.Language;
- if (langSetting.ToLower() == "zh-chs")
- {
- Cultures.CulturesHelper.Instance.ChangeCulture(System.Globalization.CultureInfo.GetCultureInfo("zh-CHS"));
- }
- else
- {
- Cultures.CulturesHelper.Instance.ChangeCulture(System.Globalization.CultureInfo.GetCultureInfo("en-US"));
- }
- }
- private void SetMes()
- {
- var mesSetting = AwInitilizer.Properties.Settings.Default.MES.ToLower();
- if (mesSetting == "php" || mesSetting == "shinewave")
- {
- }
- else if (mesSetting == "phv" || mesSetting == "sajet")
- {
- }
- }
- private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
- {
- var fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
- var msg = e.Exception.Message + "\n"+ e.Exception.StackTrace;
- File.WriteAllText(fileName,msg);
- MessageBox.Show($"App crashed,Please report error and send back {fileName}");
- Application.Current.Shutdown();
- }
- protected override void OnExit(ExitEventArgs e)
- {
- base.OnExit(e);
- var stopResult = SajetConnect.SajetTransClose();
- Environment.Exit(0);
- }
- }
- }
|