Пример #1
0
        public Form1()
        {
            InitializeComponent();
            // Set up a timer and fire the Tick event once per second (1000 ms)
            //TO DO
            //Read all the image names from the Banner folder and associate them to an array so that any new image can be added
            if (Directory.Exists(Application.StartupPath + @"\Banner\"))
            {
                objBannerList = Directory.GetFiles(Application.StartupPath + @"\Banner\", "*.png").ToList <string>();
                if (objBannerList.Count() != 0)
                {
                    _bannertimer1          = new Timer();
                    _bannertimer1.Interval = 5000;
                    _bannertimer1.Tick    += new EventHandler(_bannertimer1_Tick);
                    _bannertimer1.Start();
                }
            }
            label3.Text = "Version: " + Settings.Default.Version;
            // this.addToolStripMenuItem.Click += KnowledgeMatrix.Forms.QuestionBank.HandleLabelTextChanged;
            // if(string.IsNullOrWhiteSpace(KnowledgeMatrix.Properties.Settings.Default.OrganizationName))
            lblHeader.Text = KnowledgeMatrix.Properties.Settings.Default.Header;
            //else
            //  lblHeader.Text = KnowledgeMatrix.Properties.Settings.Default.Header + KnowledgeMatrix.Properties.Settings.Default.OrganizationName;
            lblFooter.Text = KnowledgeMatrix.Properties.Settings.Default.Footer;


            LogEntry.LogEntryInitialise();
            LogEntry.InsertEntry("Home");


            objMngNav = new ManageNavigation(panel1, panel2, questionBankToolStripMenuItem, addToolStripMenuItem, editToolStripMenuItem, deleteToolStripMenuItem, label1, panel6, lblHeader, lblFooter, label2);
            objMngNav.AddControls("MainMenu");

            //For Admin
            if (Utility.IsAdmin())
            {
                label2.Text = "ROLE: Admin";
                if (File.Exists(Application.StartupPath + @"\DemoT.s3db"))
                {
                    MessageBox.Show("Sqlite available");
                }
                else
                {
                    AdminDatabaseMgmt obj = new AdminDatabaseMgmt();
                    try
                    {
                        obj.CreateTable();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.InnerException.ToString());
                    }
                }
            }
            else
            {
                label2.Text = "ROLE: Client";
            }
        }
        private void LoadData()
        {
            AdminDatabaseMgmt obj = new AdminDatabaseMgmt();

            obj.name        = string.IsNullOrWhiteSpace(textBox1.Text) ? "%" : "%" + textBox1.Text + "%";
            obj.email       = string.IsNullOrWhiteSpace(textBox2.Text) ? "%" : "%" + textBox2.Text + "%";
            obj.IP          = string.IsNullOrWhiteSpace(textBox3.Text) ? "%" : "%" + textBox3.Text + "%";
            dbSearchUser    = obj.GetAllRegisteredUsers();
            Grid.DataSource = dbSearchUser;
        }
        private void AuditPurchase(string ProductName, string ProductType)
        {
            LicenseDetailInfo obj = new LicenseDetailInfo();

            obj.ProductName     = ProductName;
            obj.ProductType     = ProductType;
            obj.IP              = textBox1.Text;
            obj.LicenseMasterID = UserId;

            AdminDatabaseMgmt objAdmin = new AdminDatabaseMgmt();

            objAdmin.AddProductPurchase(obj);
        }
Пример #4
0
        public void GenerateLicense()
        {
            StringBuilder strLic = new StringBuilder();

            strLic.Append(name);
            strLic.Append("|");
            strLic.Append(email);
            strLic.Append("|");
            strLic.Append(LicenseKey);
            strLic.Append("|");
            systeminfo = EntropyGenerator.GetSystemInfo("");
            strLic.Append(systeminfo);
            strLic.Append("|");
            productId = Guid.NewGuid().ToString().Replace("-", "").Remove(25);
            strLic.Append(productId);



            if (string.IsNullOrWhiteSpace(IP))
            {
                IP = EntropyGenerator.GetIPForMachine();
            }

            //Include the Product Catalog along with the
            //License info
            string prodCatalog = System.IO.File.ReadAllText(Application.StartupPath + Utility.FolderType() + @"ProductsManagement\QuestionMaster.txt");

            strLic.Append("%");
            strLic.Append(prodCatalog);

            filename = FileCryptography.DoEncrypt(strLic.ToString(), filename, IP);


            //For Admin Generate Database
            AdminDatabaseMgmt obj = new AdminDatabaseMgmt();

            obj.name        = name;
            obj.email       = email;
            obj.Licensekey  = LicenseKey;
            obj.SystemInfo  = systeminfo;
            obj.ProductId   = productId;
            obj.IP          = IP;
            obj.phoneNumber = phoneNumber;
            obj.Add();
        }
        private void LoadPurchaseHistory()
        {
            AdminDatabaseMgmt obj = new AdminDatabaseMgmt();

            Grid.DataSource = obj.GetAllPurchaseUser(Convert.ToInt16(ID));
        }
Пример #6
0
        private void btnGenerateLicense_Click(object sender, EventArgs e)
        {
            isToValid = true;
            if (ValidateData())
            {
                //Validate whether record exist in the DB
                //For Admin Generate Database
                AdminDatabaseMgmt objAdmin = new AdminDatabaseMgmt();
                if (!string.IsNullOrWhiteSpace(txtIP.Text))
                {
                    objAdmin.IP = txtIP.Text;
                }
                objAdmin.name  = txtName.Text;
                objAdmin.email = txtEmail.Text;
                bool isRecordAvlbl = objAdmin.ValidateRecord();

                if (isRecordAvlbl)
                {
                    if (DialogResult.No == MessageBox.Show("The license for the combination (name, email and IP) is already created. Do you like create new one?", "License Available", MessageBoxButtons.YesNo))
                    {
                        return;
                    }
                }

                //Create License
                KnowledgeMatrix.BusinessObjects.License obj = new BusinessObjects.License();
                obj.name       = txtName.Text;
                obj.email      = txtEmail.Text;
                obj.LicenseKey = serialBox1.Text;
                if (!string.IsNullOrWhiteSpace(txtIP.Text))
                {
                    obj.IP = txtIP.Text;
                }

                if (!string.IsNullOrWhiteSpace(txtPhone.Text))
                {
                    obj.phoneNumber = txtPhone.Text;
                }

                folderBrowserDialog1.Description = @"Select the folder to save license file";
                DialogResult re = folderBrowserDialog1.ShowDialog();
                if (DialogResult.OK == re)
                {
                    obj.filename = folderBrowserDialog1.SelectedPath + @"\Data_" + txtPhone.Text + @"_" + DateTime.Now.ToShortDateString().Replace(@"/", "_") + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + "License.txt";


                    //obj.filename = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\DataLicense.txt";
                    obj.GenerateLicense();

                    //MessageBox.Show("License File is made available at" + obj.filename);

                    if (DialogResult.No == MessageBox.Show("License File is made available at " + obj.filename + " . Do you want to create one more new license ?", "License Available", MessageBoxButtons.YesNo))
                    {
                        ((System.Windows.Forms.UserControl)(this)).Text = "Done";
                        this.InvokeOnClick(this, e);
                    }
                    else
                    {
                        btnClear_Click(null, null);
                    }
                }
            }
        }