using MesAdaptor; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace AwInitilizer { /// /// Interaction logic for SigninDialog.xaml /// public partial class SigninDialog : Window { public string UserId { get; private set; } = ""; public string WorkOrder { get; private set; } = ""; public SigninDialog() { InitializeComponent(); SetMes(); var startResult = SajetConnect.SajetTransStart(); } private async void OK_Pressed(object sender, RoutedEventArgs e) { if(string.IsNullOrEmpty(uxIdBox.Text)) { uxErrmsg.Visibility = Visibility.Visible; return; } string id = uxIdBox.Text; string idBackup = id; if (CheckIsMesDisableAccount()) { //SajetConnect.IsEmsEnabled = false; SajetConnect.Instance = new SajectConnectTest(); DialogResult = true; this.Close(); return; } if (SajetConnect.SajetTransSignIn(ref id)) { if (string.IsNullOrEmpty(id) || id.StartsWith("NG")) { uxErrmsg.Content = Resx.AppResources.SigninDialogEnterIDError; uxErrmsg.Visibility = Visibility.Visible; return; } UserId = idBackup; } else { if (id.StartsWith(idBackup)) { //data not changed uxErrmsg.Content = Resx.AppResources.SigninDialogNoResponseError;// "ID Error"; } else { uxErrmsg.Content = Resx.AppResources.SigninDialogEnterIDError;// "ID Error"; } uxErrmsg.Visibility = Visibility.Visible; return; } if (!string.IsNullOrEmpty(uxWorkOrderBox.Text)) { string workOrder = uxWorkOrderBox.Text; if (SajetConnect.SajetTransWoCheck(ref workOrder)) { if (string.IsNullOrEmpty(workOrder) || workOrder.StartsWith("NG")) { uxErrmsg.Content = Resx.AppResources.SigninDialogEnterWOError;// "WorkOrder Error"; uxErrmsg.Visibility = Visibility.Visible; return; } WorkOrder = workOrder; } else { uxErrmsg.Content = Resx.AppResources.SigninDialogEnterWOError; uxErrmsg.Visibility = Visibility.Visible; return; } } DialogResult = true; this.Close(); return; } private bool CheckIsMesDisableAccount() { return uxIdBox.Text == "Admin" && uxWorkOrderBox.Text == "Admin21896826"; } private void SetMes() { var mesSetting = AppSettingConfig.MES.ToLower(); if (mesSetting == "php" || mesSetting == "shinewave") { SajetConnect.Instance = new SajetConnectShinewave(); } else if (mesSetting == "phv" || mesSetting == "sajet") { SajetConnect.Instance = new SajectConnectSajet(); } else if (mesSetting == "phv" || mesSetting == "sajet2") { SajetConnect.Instance = new SajectConnectSajet2(AppSettingConfig.MechineCode); } } } }