SigninDialog.xaml.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using MesAdaptor;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Shapes;
  15. namespace AwInitilizer
  16. {
  17. /// <summary>
  18. /// Interaction logic for SigninDialog.xaml
  19. /// </summary>
  20. public partial class SigninDialog : Window
  21. {
  22. public string UserId { get; private set; } = "";
  23. public string WorkOrder { get; private set; } = "";
  24. public SigninDialog()
  25. {
  26. InitializeComponent();
  27. SetMes();
  28. var startResult = SajetConnect.SajetTransStart();
  29. }
  30. private async void OK_Pressed(object sender, RoutedEventArgs e)
  31. {
  32. if(string.IsNullOrEmpty(uxIdBox.Text))
  33. {
  34. uxErrmsg.Visibility = Visibility.Visible;
  35. return;
  36. }
  37. string id = uxIdBox.Text;
  38. string idBackup = id;
  39. if (CheckIsMesDisableAccount())
  40. {
  41. //SajetConnect.IsEmsEnabled = false;
  42. SajetConnect.Instance = new SajectConnectTest();
  43. DialogResult = true;
  44. this.Close();
  45. return;
  46. }
  47. if (SajetConnect.SajetTransSignIn(ref id))
  48. {
  49. if (string.IsNullOrEmpty(id) || id.StartsWith("NG"))
  50. {
  51. uxErrmsg.Content = Resx.AppResources.SigninDialogEnterIDError;
  52. uxErrmsg.Visibility = Visibility.Visible;
  53. return;
  54. }
  55. UserId = idBackup;
  56. }
  57. else
  58. {
  59. if (id.StartsWith(idBackup))
  60. {
  61. //data not changed
  62. uxErrmsg.Content = Resx.AppResources.SigninDialogNoResponseError;// "ID Error";
  63. }
  64. else
  65. {
  66. uxErrmsg.Content = Resx.AppResources.SigninDialogEnterIDError;// "ID Error";
  67. }
  68. uxErrmsg.Visibility = Visibility.Visible;
  69. return;
  70. }
  71. if (!string.IsNullOrEmpty(uxWorkOrderBox.Text))
  72. {
  73. string workOrder = uxWorkOrderBox.Text;
  74. if (SajetConnect.SajetTransWoCheck(ref workOrder))
  75. {
  76. if (string.IsNullOrEmpty(workOrder) || workOrder.StartsWith("NG"))
  77. {
  78. uxErrmsg.Content = Resx.AppResources.SigninDialogEnterWOError;// "WorkOrder Error";
  79. uxErrmsg.Visibility = Visibility.Visible;
  80. return;
  81. }
  82. WorkOrder = workOrder;
  83. }
  84. else
  85. {
  86. uxErrmsg.Content = Resx.AppResources.SigninDialogEnterWOError;
  87. uxErrmsg.Visibility = Visibility.Visible;
  88. return;
  89. }
  90. }
  91. DialogResult = true;
  92. this.Close();
  93. return;
  94. }
  95. private bool CheckIsMesDisableAccount()
  96. {
  97. return uxIdBox.Text == "Admin" && uxWorkOrderBox.Text == "Admin21896826";
  98. }
  99. private void SetMes()
  100. {
  101. var mesSetting = AppSettingConfig.MES.ToLower();
  102. if (mesSetting == "php" || mesSetting == "shinewave")
  103. {
  104. SajetConnect.Instance = new SajetConnectShinewave();
  105. }
  106. else if (mesSetting == "phv" || mesSetting == "sajet")
  107. {
  108. SajetConnect.Instance = new SajectConnectSajet();
  109. }
  110. else if (mesSetting == "phv" || mesSetting == "sajet2")
  111. {
  112. SajetConnect.Instance = new SajectConnectSajet2(AppSettingConfig.MechineCode);
  113. }
  114. }
  115. }
  116. }