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); } } }
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); } } }
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); } }