private static void SaveSessionOnFireBase(string schoolCode, DateTime sessionStartTime, DateTime sessionEndTime) { try { string machineName = MacAddressHelper.GetMacAddress();// Environment.MachineName; SessionInfoFB info = new SessionInfoFB(); //info.machineName = Environment.MachineName; info.sessionstarttime = sessionStartTime; info.sessionendtime = sessionEndTime; string jsonString = JsonHelper.ParseObjectToJSON <SessionInfoFB>(info); string url = string.Format("clientanalytic-data/{0}/{1}/sessions/", schoolCode, machineName); //string url = string.Format("clientanalytic-data/{0}/session", schoolCode); FirebaseHelper.PostData(jsonString, url); } catch (Exception e) { if (e.Message.Contains("A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond")) { throw e; } else { Console.Out.WriteLine("-----------------"); Console.Out.WriteLine(e.Message); } } }
protected override void OnKeyDown(KeyEventArgs e) { char c = (char)e.KeyCode; switch (e.KeyCode) { case Keys.NumPad7: c = '7'; break; case Keys.NumPad8: c = '8'; break; case Keys.NumPad9: c = '9'; break; } if (c.IsLetterOrDigit() && !MacAddressHelper.IsAllowed(c)) { if (e.Modifiers == Keys.None || c != 'C' && c != 'X' && c != 'V') { e.Handled = true; e.SuppressKeyPress = true; return; } } base.OnKeyDown(e); }
private void SaveWatchedVideoCountOnFireBase(string videoName, int watchCount) { try { videoName = videoName.Remove(videoName.LastIndexOf(".")); string machineName = MacAddressHelper.GetMacAddress(); // Environment.MachineName //List<WatchCountInfoFB> watchCountInfoList = new List<WatchCountInfoFB>(); //WatchCountInfoFB info = new WatchCountInfoFB(); //info.machinename = Environment.MachineName; //info.videoname = videoName; //info.videowatchcount = watchCount; //watchCountInfoList.Add(info); //string jsonString = JsonHelper.ParseObjectToJSON<List<WatchCountInfoFB>>(watchCountInfoList); string jsonString = watchCount.ToString(); string url = string.Format("clientanalytic-data/{0}/{1}/videowatchcount/{2}/Count", ClientInfoObject.SchoolId, machineName, videoName); FirebaseHelper.PostData(jsonString, url); } catch (Exception ex) { if (ex.Message.Contains("A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond")) { Console.Out.WriteLine("-----------------"); Console.Out.WriteLine(ex.Message); } } }
protected override void OnKeyPress(KeyPressEventArgs e) { if (!MacAddressHelper.IsAllowed(e.KeyChar)) { return; } base.OnKeyPress(e); }
//http://v.bidsneo.com/hub/index.html#id=sfmm4t&p=%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E //http://118.31.16.221:8012/eagle/swagger-ui.html //https://www.teambition.com/project/5f1652f562b591d38266aa07/tasks/scrum/5f1652f6911fa600218f9b7f public App() { Process[] pOrange = Process.GetProcessesByName("HY.Main"); if (pOrange.Length > 1) { Current.Shutdown(0); } Task.Run(() => { while (true) { Process[] Fiddler = Process.GetProcessesByName("Fiddler"); Process[] Wireshark = Process.GetProcessesByName("Wireshark"); if (Fiddler.Length > 0 || Wireshark.Length > 0) { Current.Dispatcher.Invoke(new Action(() => { Current.Shutdown(0); })); } Thread.Sleep(3000); } }); var MacAddress = MacAddressHelper.GetMacByIpConfig() ?? MacAddressHelper.GetMacByWmi().FirstOrDefault() ?? "unknown"; if (string.IsNullOrEmpty(MacAddress)) { MessageBox.Show("网络连接失败,请您连接网络,稍后重新运行"); Current.Shutdown(); return; } CheckLicence(); DispatcherUnhandledException += (sender, args) => { WriteErrorLog(args.Exception.Message); }; //Task线程未捕获异常处理事件 TaskScheduler.UnobservedTaskException += (sender, args) => { WriteErrorLog(args.Exception.Message); }; // AppDomain.CurrentDomain.UnhandledException += (sender, args) => { if (args.IsTerminating) { System.Windows.MessageBox.Show("我们很抱歉,当前应用程序遇到一些问题,公共语言运行时已经终止,请重新启动程序,如果还遇到此情况,请联系我们。 ", "应用程序即将终止", MessageBoxButton.OK, MessageBoxImage.Error); } }; }
private void frmLogin_Load(object sender, EventArgs e) { try { label11.Location = new System.Drawing.Point(panel4.Width / 2 - 150, 11); label2.Location = new System.Drawing.Point(panel4.Width / 2 - 75, 15); this.progressBar1.Visible = true; this.progressBar1.Enabled = true; this.progressBar1.Value = 10; //ClientHelper.GetClientThumbanailPath(); _clientInfoFilePath = ClientHelper.GetClientInfoFilePath(); if (!File.Exists(_clientInfoFilePath)) { MessageBox.Show("Invalid Configuration", "Configuration Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } this.progressBar1.Value = 30; CommonAppStateDataHelper.ClientInfoObject = Cryptograph.DecryptObject <ClientInfo>(_clientInfoFilePath); _clientInfo = CommonAppStateDataHelper.ClientInfoObject; this.progressBar1.Value = 70; if (_clientInfo != null) { lblSessionYears.Text = ClientHelper.GetSessionString(_clientInfo.SessionString); lblSchoolWelcome.Text = ClientHelper.GetWelcomeString(_clientInfo.SchoolName, _clientInfo.SchoolCity, _clientInfo.SchoolId); lblExpireDate.Text = ClientHelper.GetExpiryDateString(_clientInfo.SessionEndDate); _currentMacAddress = MacAddressHelper.GetMacAddress(); //_currentMacAddress = "B82A72A780B7"; _firebaseRegInfo = GetFirebaseRegistrationInformation(); string errorMessage = ""; bool deleteVideos = false; bool skipLoginScreen = false; // Check license session duraion LicenseValidationState licenseState = ValidateLicenseNew(_firebaseRegInfo, _clientInfo, _currentMacAddress, out errorMessage, out deleteVideos, out skipLoginScreen); TextFileLogger.Log("License State" + licenseState.ToString()); if (licenseState != LicenseValidationState.Valid) { OnAfterLicesseValidation(errorMessage, deleteVideos, licenseState); } _showLoginForm = !skipLoginScreen; this.progressBar1.Value = 100; //// update mac address in local client info file //if (licenseState == LicenseValidationState.Valid) //{ // this.progressBar1.Value = 90; // //if (string.IsNullOrEmpty(CommonAppStateDataHelper.ClientInfoObject.MacAddress)) // //{ // // _showLoginForm = true; // //} // //else // //{ // // _showLoginForm = false; // //} //} //else //{ // this.progressBar1.Value = 100; // Application.Exit(); //} } else { throw new Exception("Invalid client info configuration."); } } catch (Exception ex) { ExceptionHandler.HandleException(ex); MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }