private void btnSubmit_Click(object sender, RoutedEventArgs e)
 {
     MRecon.Model.EmailConfigurationMaster emailConfig = new MRecon.Model.EmailConfigurationMaster();
     emailConfig.CreatedBy     = 1;
     emailConfig.CreatedDtTm   = DateTime.Now;
     emailConfig.EmailID       = txtEmailID.Text;
     emailConfig.IsActive      = true;
     emailConfig.IsSSLRequired = (chkSLL.IsChecked == true) ? true : false;
     emailConfig.Password      = txtEmailPassword.Password;
     emailConfig.Port          = Convert.ToInt32(txtPortNnumber.Text);
     emailConfig.ServerName    = txtServer.Text;
     db.EmailConfigurationMasters.Add(emailConfig);
     db.SaveChanges();
     if (emailConfig.EmailConfigurationID > 0)
     {
         LoginWindow login = new LoginWindow();
         login.Show();
         Application.Current.MainWindow.Close();
     }
 }
Example #2
0
        private void btnActivate_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Windows[0].Height = this.Height;
            try
            {
                // Page Event Logger
                AppUtility.PageEventLogger(PageLogID, "Activation Button", 1, "Activation Button Click", "Normal");
                txtActivationKey.SelectAll();
                string           Value = Utility.Utility.Decrypt(txtActivationKey.Selection.Text);
                LicenseViewModel licvm = Newtonsoft.Json.JsonConvert.DeserializeObject <LicenseViewModel>(Value);

                if (licvm != null)
                {
                    var _ExistReg = MainWindow._FactoryConnection.Registration().GetSingleRegistraionDetail(licvm.Key);
                    if (_ExistReg != null)
                    {
                        if (Convert.ToBoolean(licvm.IsActivated) && licvm.SystemName == System.Net.Dns.GetHostName())
                        {
                            _ExistReg.ActivationKey = licvm.ActivationKey;
                            // Page Event Logger
                            AppUtility.PageEventLogger(PageLogID, "Activation Button", 1, "Product Activated", "Normal");
                            MessageBox.Show("Your product has been activated till " + licvm.ActivationUptoDtTm);
                            AppUtility.AdminUserCreateAndRoleMapping(_ExistReg, licvm);
                            // Page Event Logger
                            AppUtility.PageEventLogger(PageLogID, "Activation Button", 1, "Moved To Super Admin Password Change", "Normal");
                            Frame MainFrame = AppUtility.FindChild <Frame>(Application.Current.MainWindow, "MainFrame");
                            MainFrame.Navigate(new System.Uri("Forms/SuperAdminPasswordChange.xaml", UriKind.RelativeOrAbsolute));
                        }
                        else if (Convert.ToBoolean(licvm.IsActivated) && (_ExistReg.LicenseCount - _ExistReg.LicenseUsed) > 0)
                        {
                            AppUtility.PageEventLogger(PageLogID, "Activation Button", 1, "Register Other Systems", "Normal");
                            bool IsRegisterd = AppUtility.AdditionSystemRegistration(_ExistReg, licvm);
                            if (IsRegisterd)
                            {
                                MessageBox.Show("This device is registered successfully");
                                LoginWindow frm = new LoginWindow();
                                this.Cursor = Cursors.Arrow;
                                frm.Show();
                                Application.Current.MainWindow.Close();
                            }
                            else
                            {
                                MessageBox.Show("Please contact the administrator.");
                            }
                        }
                        else
                        {
                            // Page Event Logger
                            AppUtility.PageEventLogger(PageLogID, "Activation Button", 1, "Mail Process Triggerred Again", "Normal");
                            MessageBox.Show("Your product has not been activated. Please send mail again");


                            LicenseViewModel licvmn = new LicenseViewModel();
                            licvmn.ServiceList = new List <Service>();
                            licvmn.ServiceList.AddRange(MainWindow._FactoryConnection.SearchTypeMasters().SearchTypeList(_ExistReg.RegistrationID));
                            licvmn.CompanyName = _ExistReg.CompanyName;
                            licvmn.EmailID     = _ExistReg.EmailID;
                            licvmn.Key         = _ExistReg.Key;
                            licvmn.MacAddress  = _ExistReg.MacAddress;
                            licvmn.MobileNo    = _ExistReg.MobileNo;
                            licvmn.Name        = _ExistReg.MobileNo;
                            licvmn.SystemCount = _ExistReg.LicenseCount;
                            licvmn.SystemName  = _ExistReg.SystemName;
                            AppUtility.SendRegistrationMail(licvmn);
                        }
                    }
                }
                else
                {
                    // Page Event Logger
                    AppUtility.PageEventLogger(PageLogID, "Activation Button", 1, "Invalid Activation Key", "Normal");
                    MessageBox.Show("Registration key is not valid. Please Try Again");
                }
            }
            catch (Exception ex)
            {
                // Page Event Logger
                AppUtility.PageEventLogger(PageLogID, "Activation Button", 1, ex.StackTrace, "Error");
                MessageBox.Show("Registration key is not valid. Please Try Again");
            }
        }