123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- using Common.system;
-
- using System;
- using System.IO;
- using System.Text;
- using System.Windows;
-
- using XHWK.Model;
- using XHWK.WKTool.DAL;
-
- namespace XHWK.WKTool
- {
-
-
-
-
-
- public partial class ProductVerification : Window
- {
- private readonly Interface registerController = new Interface();
- private int serverReturnCode = 0;
-
- public ProductVerification()
- {
- InitializeComponent();
- WindowStartupLocation = WindowStartupLocation.CenterScreen;
- Topmost = true;
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeActivationDecryptServering, InvokeActivationDecryptServerCompate);
- }
-
-
-
-
- private object InvokeActivationDecryptServering()
- {
- return APP.ServerMsg;
- }
-
-
-
-
-
- public void InvokeActivationDecryptServerCompate(object obj)
- {
-
- try
- {
- APP.Signature = System.IO.File.ReadAllText(APP.dataPath + "signature.txt", Encoding.Default);
- string decrypt = DataProvider.TripleDESDecrypt(APP.Signature, APP.secretKey);
- decrypt = decrypt.Replace("\u0001", "").Replace("\u0007", "").Trim();
- Model_Signatures msgBean = JsonHelper.JsonToObj<Model_Signatures>(decrypt);
- long currentTimeTimestamp = DataProvider.TimestampTotalSeconds();
- if (msgBean.endtime > currentTimeTimestamp)
- {
- if (File.Exists(APP.dataPath + "signatureTime.txt"))
- {
- string signatureTime = System.IO.File.ReadAllText(APP.dataPath + "signatureTime.txt", Encoding.Default);
- string currentTime = DateTime.Now.ToLongDateString().ToString();
- if (signatureTime != currentTime)
- {
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeActivationAddHistoryServering, InvokeActivationAddHistoryServerCompate);
- }
- }
- Dispatcher.Invoke(new Action(() =>
- {
- Hide();
- CreateAMicroLessonWindow win = new CreateAMicroLessonWindow();
- win.Show();
- Close();
- }));
- }
- else
- {
- Dispatcher.Invoke(new Action(() =>
- {
- Hide();
- KeyVerification wins = new KeyVerification
- {
- Topmost = true
- };
- wins.ShowDialog();
- Close();
- }));
- }
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("ProductVerification(解析失败)" + ex.Message, ex);
- Dispatcher.Invoke(new Action(() =>
- {
- Hide();
- KeyVerification wins = new KeyVerification
- {
- Topmost = true
- };
- wins.ShowDialog();
- Close();
- }));
- }
-
- }
-
-
-
-
- private object InvokeActivationAddHistoryServering()
- {
- serverReturnCode = registerController.ActivationAddHistory();
- return APP.ServerMsg;
- }
-
-
-
-
-
- public void InvokeActivationAddHistoryServerCompate(object obj)
- {
- if (!Directory.Exists(APP.dataPath))
- {
- Directory.CreateDirectory(APP.dataPath);
- }
- string ApplicationData = APP.dataPath + "signatureTime.txt";
- string currentTime = DateTime.Now.ToLongDateString().ToString();
- System.IO.File.WriteAllText(ApplicationData, currentTime, Encoding.Default);
- }
-
-
-
-
-
-
- private void close_click(object sender, RoutedEventArgs e)
- {
- closeAction();
- }
-
-
-
- private void closeAction()
- {
- Dispatcher.Invoke(new Action(() =>
- {
- System.Environment.Exit(0);
- }));
- }
-
- ~ProductVerification()
- {
- Console.WriteLine("{0}被销毁", this);
- Dispose(false);
- }
- public void Dispose()
- {
- Console.WriteLine("{0}被手动销毁", this);
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private bool disposed;
- protected void Dispose(bool disposing)
- {
- Console.WriteLine("{0}被自动销毁", this);
- if (!disposed)
- {
- if (disposing)
- {
-
-
- }
-
-
- }
- disposed = true;
- }
- }
- }
|