public FrmMain() { InitializeComponent(); FilesFound = new List <ResultDetail>(); //this.panelCleanerComponents.Controls.Add(new UCCleaner()); this.labelClientInfo.Text = ApplicationSettings.SystemInformation; this.panelCleanerComponents.HorizontalScroll.Maximum = 0; this.panelCleanerComponents.AutoScroll = false; this.panelCleanerComponents.VerticalScroll.Visible = false; this.panelCleanerComponents.AutoScroll = true; this.progressBar1.Width = this.panelProgress.Width - 100; this.backgroundWorkerSearch.WorkerReportsProgress = true; this.backgroundWorkerSearch.WorkerSupportsCancellation = true; SelectedItem = ApplicationItem.Cleaner; this.ucResult.Visible = false; try { IsSubValid = OptionsAdvanceSetting.IsSubscriptionValid(this); IsSubscriptionExists = true; } catch (Exception ex) { OptionsAdvanceSetting.StartTrialPeriod(); } }
private void CheckSubscriptionRequest() { DataTable dt = OptionsAdvanceSetting.GetRequestUserInfo(); if (dt != null && dt.Rows.Count > 0) { this.groupBoxRequest.Visible = false; } DataTable subscriptionInfo = OptionsAdvanceSetting.GetSubscriptionInfo(); if (subscriptionInfo != null && subscriptionInfo.Rows.Count > 0) { this.groupBoxSubscripton.Hide(); this.labelActivated.Show(); } }
private void FrmMain_Shown(object sender, EventArgs e) { if (IsSubscriptionExists && !IsSubValid) { this.Controls.Find("labelProductActivation", true)[0].Visible = true; this.Controls.Find("labelTrialPeriodLeft", true)[0].Visible = false; (this.Controls.Find("labelProductActivation", true)[0] as Label).Text = "Subscription Expired"; var messageBox = new SubscriptionMessage(this); Overlay.ShowOverlay(this, messageBox);//this: parent form messageBox.ShowDialog(); } else if (!IsSubscriptionExists) { OptionsAdvanceSetting.ReloadSettings(); string startDate = OptionsAdvanceSetting.GetTrialPeriodStartDate; if (!string.IsNullOrEmpty(startDate)) { DateTime startFrom = Convert.ToDateTime(startDate); DateTime endDate = startFrom.AddDays(7); // TimeSpan trialPeriod = endDate.Subtract(DateTime.Now); //this.labelTrialPeriodLeft.Text = "[" + trialPeriod.Days + " Days Left]"; this.labelTrialPeriodLeft.Text = "[0 Days Left]"; //if (trialPeriod.Days == 0) { TrialExpired form = new TrialExpired(this); Overlay.ShowOverlay(this, form);//this: parent form form.ShowDialog(); } } } }
private void buttonSave_Click(object sender, EventArgs e) { bool isValid = false; if ( (!string.IsNullOrEmpty(this.textBoxFirstName.Text)) && (!string.IsNullOrEmpty(this.textBoxEmail.Text)) && (!string.IsNullOrEmpty(this.textBoxLastName.Text)) ) { try { string email = new MailAddress(this.textBoxEmail.Text).Address; isValid = true; } catch (Exception ex) { errorProvider1.SetError(textBoxEmail, "Please provide valid email address"); isValid = false; ; } } if (this.textBoxFirstName.Text.Trim().Length < 1) { errorProvider1.SetError(textBoxFirstName, "Please enter First Name"); } if (this.textBoxLastName.Text.Trim().Length < 1) { errorProvider1.SetError(textBoxLastName, "Please enter Last Name"); } if (this.textBoxEmail.Text.Trim().Length < 1) { errorProvider1.SetError(textBoxEmail, "Please enter Email Address"); } if (isValid) { OptionsAdvanceSetting.AddSubscriptionRequest(this.textBoxFirstName.Text, this.textBoxLastName.Text, this.textBoxEmail.Text, Helper.GetMacId()); string fullName = this.textBoxFirstName.Text + " " + this.textBoxLastName.Text; string subscriptionUrl = CleanerApplicationSettings.SubscriptionURL + "api/subscription/action.php?page_key=create"; var client = new RestClient(subscriptionUrl); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("accept", "application/json"); request.AddParameter("FullName", fullName); request.AddParameter("EmailAddress", this.textBoxEmail.Text); request.AddParameter("MacId", Helper.GetMacId()); try { IRestResponse response = client.Execute(request); if (response.IsSuccessful) { string jsonResult = response.Content; jsonResult = jsonResult.TrimStart('\"'); jsonResult = jsonResult.TrimEnd('\"'); jsonResult = jsonResult.Replace("\\", ""); this.groupBoxRequest.Hide(); MessageBox.Show("Request sent successfully. You will receive activation code email shortly."); } } catch (Exception ex) { MessageBox.Show("Application failed to connect to Subscription service, please try later on."); } } }