Exemplo n.º 1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.Cursor = Cursors.Wait;
            //Page Logger
            PageLogID = AppUtility.PageLogger(0, 1);
            // Page Event Logger
            AppUtility.PageEventLogger(PageLogID, "Constructor", 1, "Form Load", "Normal");

            string SystemName = System.Net.Dns.GetHostName();
            string MacAddress = AppUtility.GetMachineData("MACAddress");
            //Initiliazing Frame
            var items         = _FactoryConnection.Registration().GetRegistraionDetails();
            int _licensecount = 0;

            foreach (var dd in items)
            {
                if (dd.IsActivated == true && dd.IsSentForRegistration == true && dd.IsActive == true && DateTime.Now.AddDays(-1) < dd.ActivatedTillDtTm)
                {
                    _licensecount = 1;
                    var _ExistReg = _FactoryConnection.LicenseKeys().GetLicenseDetail(dd.RegistrationID, SystemName).ToList();

                    foreach (var item in _ExistReg)
                    {
                        AppUtility.PageEventLogger(PageLogID, "Constructor", 1, "Sent To Login Page", "Normal");
                        LoginWindow frm = new LoginWindow();
                        this.Cursor = Cursors.Arrow;
                        frm.Show();
                        this.Close();
                        break;
                    }
                    // Page Event Logger
                }
                else if (dd.IsActivated == true && DateTime.Now.AddDays(-1) > dd.ActivatedTillDtTm)
                {
                    _licensecount = 0;
                    //License Deativation
                    bool done = _FactoryConnection.Registration().LicenseDeactivation(dd);
                }
                if (_licensecount == 0)
                {
                    var _Licenses = _FactoryConnection.Registration().GetALLRegistraionDetails().OrderByDescending(o => o.ActivatedTillDtTm).ToList();
                    foreach (var item in _Licenses)
                    {
                        MessageBox.Show("Your license has been exipred on " + item.ActivatedTillDtTm + ". Please register again.");
                        break;
                    }
                }
            }
            if (_licensecount == 0)
            {
                var _Licenses = _FactoryConnection.Registration().GetALLRegistraionDetails().OrderByDescending(o => o.ActivatedTillDtTm).ToList();
                foreach (var item in _Licenses)
                {
                    MessageBox.Show("Your license has been exipred on " + item.ActivatedTillDtTm + ". Please register again.");
                    break;
                }
            }
            this.Cursor = Cursors.Arrow;
        }
Exemplo n.º 2
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                RegistrationGrid.IsEnabled = false;
                //Registration details to send
                LicenseViewModel licvm = new LicenseViewModel();
                licvm.ServiceList = new List <Service>();
                licvm.ServiceList.AddRange(SearchTypeList);
                licvm.CompanyName = txtCompanyName.Text;
                licvm.EmailID     = txtEmailID.Text;
                licvm.Key         = Guid.NewGuid().ToString();
                licvm.MacAddress  = AppUtility.GetMachineData("MACAddress");
                licvm.MobileNo    = txtMobileNumber.Text;
                licvm.Name        = txtFullName.Text;
                licvm.SystemCount = Convert.ToInt32(txtLicenseCount.Text);
                licvm.SystemName  = System.Net.Dns.GetHostName();
                licvm.IsActivated = false;
                // Page Event Logger
                AppUtility.PageEventLogger(PageLogID, "Submit Button", 1, "Registration Button Click Started", "Normal");

                //Registeration of Client
                Int64 RegistrationID = MainWindow._FactoryConnection.Registration().FirstTimeRegistration(txtCompanyName.Text, Convert.ToInt32(txtLicenseCount.Text), txtEmailID.Text, licvm.Key, licvm.SystemName, licvm.MacAddress, txtFullName.Text, txtMobileNumber.Text, SearchTypeList);

                // Page Event Logger
                AppUtility.PageEventLogger(PageLogID, "Submit Button", 1, "Registration Done", "Normal");
                if (RegistrationID > 0)
                {
                    // Page Event Logger
                    AppUtility.PageEventLogger(PageLogID, "Submit Button", 1, "Mailig Process Started", "Normal");
                    AppUtility.SendRegistrationMail(licvm);
                }

                MessageBox.Show("Please send the mail.");
                Frame MainFrame1 = AppUtility.FindChild <Frame>(Application.Current.MainWindow, "MainFrame");
                MainFrame1.Navigate(new System.Uri("Forms/Activation.xaml", UriKind.RelativeOrAbsolute));
                // Page Event Logger
                AppUtility.PageEventLogger(PageLogID, "Submit Button", 1, "Registration Button Click END", "Normal");
            }
            catch (Exception ex)
            {
                // Page Event Logger
                AppUtility.PageEventLogger(PageLogID, "Submit Button", 1, ex.Message + " | " + ex.StackTrace, "Error");
                MessageBox.Show("There is some error, Please contact administrator.");
            }
            finally
            {
                RegistrationGrid.IsEnabled = true;
            }
        }
Exemplo n.º 3
0
        bool IRegistration.AdditionalSystemRegistration(Model.RegistrationMaster _Reg, ViewModel.LicenseViewModel licvm)
        {
            Int64  RegistrationID = 0;
            string MacAddress     = AppUtility.GetMachineData("MacAddress");
            string SystemName     = System.Net.Dns.GetHostName();
            var    _ExistLicense  = db.LicenseKeys.Where(w => w.RegistrationID == _Reg.RegistrationID && w.DesktopName == SystemName && w.MacAddress == MacAddress).ToList();

            if (_ExistLicense.Count == 0)
            {
                var _ExistReg = db.RegistrationMasters.Where(w => w.RegistrationID == _Reg.RegistrationID).ToList();
                foreach (var item in _ExistReg)
                {
                    RegistrationID = item.RegistrationID;
                    if (licvm.IsActivated == true)
                    {
                        item.LicenseUsed     = item.LicenseUsed + 1;
                        item.ModifiedBy      = _Reg.CreatedBy;
                        item.ModifiedDtTm    = DateTime.Now;
                        db.Entry(item).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    break;
                }
                LicenseKeys key = new LicenseKeys();
                key.CreatedBy          = _Reg.CreatedBy;
                key.CreatedDtTm        = DateTime.Now;
                key.DesktopName        = SystemName;
                key.IpAddress          = "";
                key.IsActive           = true;
                key.LicenseKeyCode     = licvm.ActivationKey;
                key.LicenseKeySequence = 1;
                key.MacAddress         = MacAddress;
                key.RegistrationDtTm   = licvm.ActivationDtTm;
                key.RegistrationID     = RegistrationID;
                key.ValidUptoDtTm      = licvm.ActivationUptoDtTm;
                db.LicenseKeys.Add(key);
                db.SaveChanges();
            }
            return(true);
        }
Exemplo n.º 4
0
        Int64 IRegistration.AdminUserCreateAndRoleMapping(RegistrationMaster _Reg, ViewModel.LicenseViewModel licvm)
        {
            Int64 RegistrationID = 0;
            //Updating R egistraionDetails
            var _ExistReg = db.RegistrationMasters.Where(w => w.RegistrationID == _Reg.RegistrationID).ToList();

            foreach (var item in _ExistReg)
            {
                RegistrationID = item.RegistrationID;
                if (licvm.IsActivated == true)
                {
                    item.IsActivated       = licvm.IsActivated;
                    item.ActivationKey     = licvm.ActivationKey;
                    item.ActivatedDtTm     = licvm.ActivationDtTm;
                    item.ActivatedTillDtTm = licvm.ActivationUptoDtTm;
                    item.LicenseCount      = licvm.SystemCount;
                    item.LicenseUsed       = 1;
                    item.ModifiedBy        = _Reg.CreatedBy;
                    item.ModifiedDtTm      = DateTime.Now;
                    db.Entry(item).State   = EntityState.Modified;
                    db.SaveChanges();
                }
                break;
            }

            foreach (var item in licvm.ServiceList)
            {
                var serviceupdate = db.RegistrationWiseSearchTypes.Where(w => w.RegistrationID == _Reg.RegistrationID && w.SearchTypeID == item.ServiceID).First();
                serviceupdate.IsActivated     = item.IsActivated;
                serviceupdate.ActivatedDtTm   = licvm.ActivationDtTm;
                db.Entry(serviceupdate).State = EntityState.Modified;
                db.SaveChanges();
            }

            //License Info Update
            string MacAddress    = AppUtility.GetMachineData("MacAddress");
            string SystemName    = System.Net.Dns.GetHostName();
            var    _ExistLicense = db.LicenseKeys.Where(w => w.RegistrationID == _Reg.RegistrationID && w.DesktopName == SystemName && w.MacAddress == MacAddress).ToList();

            if (_ExistLicense.Count == 0)
            {
                LicenseKeys key = new LicenseKeys();
                key.CreatedBy          = 1;
                key.CreatedDtTm        = DateTime.Now;
                key.DesktopName        = licvm.SystemName;
                key.IpAddress          = "";
                key.IsActive           = true;
                key.LicenseKeyCode     = licvm.ActivationKey;
                key.LicenseKeySequence = 1;
                key.MacAddress         = licvm.MacAddress;
                key.RegistrationDtTm   = licvm.ActivationDtTm;
                key.RegistrationID     = RegistrationID;
                key.ValidUptoDtTm      = licvm.ActivationUptoDtTm;
                db.LicenseKeys.Add(key);
                db.SaveChanges();
            }

            RoleMaster role       = new RoleMaster();
            var        _ExistRole = db.RoleMasters.Where(w => w.RoleName == "Super Admin").ToList();

            if (_ExistRole.Count > 0)
            {
                foreach (var item in _ExistRole)
                {
                    role = item;
                    break;
                }
            }
            else
            {
                role.CreatedBy   = 1;
                role.CreatedDtTm = DateTime.Now;
                role.IsActive    = true;
                role.RoleName    = "Super Admin";
                db.RoleMasters.Add(role);
                db.SaveChanges();
            }
            var pages = db.PageMasters.ToList();

            foreach (var page in pages)
            {
                RolePageMapping mapping       = new RolePageMapping();
                var             _Existmapping = db.RolePageMappings.Where(w => w.PageID == page.PageID && w.RoleID == role.RoleID).ToList();
                if (_Existmapping.Count == 0)
                {
                    mapping.CreatedBy   = 1;
                    mapping.CreatedDtTm = DateTime.Now;
                    mapping.IsActive    = true;
                    mapping.PageID      = page.PageID;
                    mapping.RoleID      = role.RoleID;
                    db.RolePageMappings.Add(mapping);
                    db.SaveChanges();
                }
            }
            UserMaster user       = new UserMaster();
            var        _Existuser = db.UserMasters.Where(w => w.RoleID == role.RoleID).ToList();

            if (_Existuser.Count == 0)
            {
                user.CreatedBy       = 1;
                user.CreatedDtTm     = DateTime.Now;
                user.IsActive        = true;
                user.EmailID         = _Reg.EmailID;
                user.FullName        = _Reg.Name;
                user.ManagerID       = null;
                user.MobileNo        = _Reg.MobileNo;
                user.Password        = _Reg.MobileNo;
                user.RoleID          = role.RoleID;
                user.UserName        = _Reg.MobileNo;
                user.ConfirmPassword = _Reg.MobileNo;
                db.UserMasters.Add(user);
                db.SaveChanges();
            }
            else
            {
                foreach (var item in _Existuser)
                {
                    user = item;
                    break;
                }
            }
            return(user.UserID);
        }
Exemplo n.º 5
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     RegistrationGrid.IsEnabled            = false;
     Application.Current.Windows[0].Height = this.Height;
     try
     {
         //Page Logger
         PageLogID = AppUtility.PageLogger(1, 1);
         // Page Event Logger
         AppUtility.PageEventLogger(PageLogID, "Constructor", 1, "Form Load", "Normal");
         //Getting System Info
         string SystemName = System.Net.Dns.GetHostName();
         string MacAddress = AppUtility.GetMachineData("MACAddress");
         //Validating Data
         var items = MainWindow._FactoryConnection.Registration().GetRegistraionDetails();
         SearchTypeList = MainWindow._FactoryConnection.SearchTypeMasters().SearchTypeList();
         listBoxSeachType.ItemsSource = SearchTypeList;
         string PageName = "Forms/Login.xaml";
         foreach (var dd in items)
         {
             if (dd.IsActivated == true && dd.IsSentForRegistration == true)
             {
                 // Page Event Logger
                 AppUtility.PageEventLogger(PageLogID, "Constructor", 1, "Sent To Login Page", "Normal");
                 break;
             }
             else if ((dd.IsActivated == false || dd.IsActivated == null) && dd.IsSentForRegistration == true)
             {
                 PageName = "Forms/Activation.xaml";
                 // Page Event Logger
                 AppUtility.PageEventLogger(PageLogID, "Constructor", 1, "Mail Process Triggerred Again", "Normal");
                 //Registration details to send
                 LicenseViewModel licvm = new LicenseViewModel();
                 licvm.ServiceList = new List <Service>();
                 licvm.ServiceList.AddRange(MainWindow._FactoryConnection.SearchTypeMasters().SearchTypeList(dd.RegistrationID));
                 licvm.CompanyName = dd.CompanyName;
                 licvm.EmailID     = dd.EmailID;
                 licvm.Key         = dd.Key;
                 licvm.MacAddress  = dd.MacAddress;
                 licvm.MobileNo    = dd.MobileNo;
                 licvm.Name        = dd.Name;
                 licvm.SystemCount = dd.LicenseCount;
                 licvm.SystemName  = dd.SystemName;
                 licvm.IsActivated = false;
                 AppUtility.SendRegistrationMail(licvm);
                 MessageBox.Show("Please send mail again for activation key.");
                 Frame MainFrame = AppUtility.FindChild <Frame>(Application.Current.MainWindow, "MainFrame");
                 MainFrame.Navigate(new System.Uri(PageName, UriKind.RelativeOrAbsolute));
                 break;
             }
         }
         // Page Event Logger
         AppUtility.PageEventLogger(PageLogID, "Constructor", 1, "Form Load END", "Normal");
     }
     catch (Exception ex)
     {
         // Page Event Logger
         AppUtility.PageEventLogger(PageLogID, "Submit Button", 1, ex.Message + " | " + ex.StackTrace, "Error");
         MessageBox.Show("There is some error, Please contact administrator.");
     }
     finally
     {
         RegistrationGrid.IsEnabled = true;
     }
 }