private void Form_TrialReport_Load(object sender, EventArgs e)
        {
            //    string timeElapsed = HashPass.ReadElapsedFromReg();
            //    int hoursElapsed = int.Parse(timeElapsed) / (60*60);
            //    int remainingHours = 240 - hoursElapsed;
            //    progressBar1.Value = remainingHours;
            //    label1.Text = remainingHours.ToString() + " Hours remained";

            string days_str = HashPass.ReadDaysFromReg();
            double days     = 0;

            if (days_str != "")
            {
                days = double.Parse(days_str);
            }
            days = 30 - days;
            int    firstUsed           = int.Parse(HashPass.ReadFirstDateFromReg());
            int    lastUsed            = int.Parse(HashPass.ReadLastDateFromReg());
            int    elapsedDaysFromFULU = 30 - (lastUsed - firstUsed);
            string timeElapsed         = HashPass.ReadElapsedFromReg();
            int    hoursElapsed        = int.Parse(timeElapsed) / (60 * 60);
            int    remainingHours      = 720 - hoursElapsed;
            int    progressValue       = 0;

            if (elapsedDaysFromFULU > 30 || remainingHours <= 0)
            {
                progressValue = 0;
            }
            else
            {
                progressValue = (days < elapsedDaysFromFULU) ? int.Parse(days.ToString()) : elapsedDaysFromFULU;
            }
            progressBar1.Value = progressValue;
            label1.Text        = progressValue.ToString() + " Days remained";
        }
示例#2
0
        public static string ReadElapsedFromReg()
        {
            string value = "";

            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software", true);
            if (!key.GetSubKeyNames().Contains("GAP"))
            {
                HashPass.SetReg();
                return("0");
            }
            else
            {
                key = key.OpenSubKey("GAP", true);
            }
            if (!key.GetSubKeyNames().Contains("1.0"))
            {
                HashPass.SetReg();
                return("0");
            }
            else
            {
                key = key.OpenSubKey("1.0", true);
            }
            if (!key.GetValueNames().Contains("elpsd"))
            {
                HashPass.SetReg();
                return("0");
            }
            else
            {
                value = key.GetValue("elpsd").ToString();
            }
            return(value);
        }
示例#3
0
 public static void refreshLicInfo()
 {
     licenseName = ReadFromReg();
     if (LicType == "t")
     {
         double today     = DateTime.Today.ToOADate();
         int    FirstUsed = int.Parse(ReadFirstDateFromReg());
         int    LastUsed  = int.Parse(ReadLastDateFromReg());
         if (FirstUsed == 0 && LastUsed == 0)
         {
             WriteFirstDateToReg(today.ToString());
             WriteLastDateToReg(today.ToString());
             return;
         }
         else if ((FirstUsed == 0 && LastUsed != 0) || LastUsed > today)
         {
             isExpired = true;
             Form1.Board(true);
             return;
         }
         string timeElapsed    = HashPass.ReadElapsedFromReg();
         int    hoursElapsed   = int.Parse(timeElapsed) / (60 * 60);
         int    remainingHours = 720 - hoursElapsed;
         double elapsedDays    = today - FirstUsed;
         if (elapsedDays < 0 || elapsedDays > 30 || remainingHours <= 0)
         {
             isExpired = true;
             Form1.Board(true);
             return;
         }
         else
         {
             isExpired = false;
             Form1.Board(false);
         }
         if (isExpired == true)
         {
             licenseType = "Expired!";
         }
         else
         {
             licenseType = "Trial Demo";
         }
         WriteLastDateToReg(today.ToString());
     }
     else if (HashPass.LicType == "p")
     {
         isExpired   = false;
         licenseType = "Permanent";
         Form1.Board(false);
     }
 }
示例#4
0
        private void CheckLicense()
        {
            HashPass.refreshLicInfo();
            //if (isLicError == true)
            //    Application.Exit();
            string winPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
            string licPath = Path.Combine(winPath, "clc.clc");

            if (File.Exists(licPath) && HashPass.isExpired != true)
            {
                string licType = HashPass.CheckLicense();
                if (licType == "error")
                {
                    label_WrongPass.Show();
                    label_WrongPass.Text = "License read error!";
                    txtBx_Pass.Enabled   = false;
                    isLicError           = true;
                    //Application.Exit();
                }
                else if (licType == "n")
                {
                    label_WrongPass.Show();
                    label_WrongPass.Text = "Invalid License!";
                    txtBx_Pass.Enabled   = false;
                    isLicError           = true;
                    //Application.Exit();
                }
                else if (licType == "t" || licType == "p")
                {
                    isLicError         = false;
                    txtBx_Pass.Enabled = true;
                    HashPass.LicType   = licType;
                }
            }
            else
            {
                txtBx_Pass.Enabled = false;
                if (HashPass.isExpired == true)
                {
                    this.TopMost = false;
                    MessageBox.Show("Your license is expired!");
                    label_WrongPass.Show();
                    label_WrongPass.Text = "License Expired!";
                }
                Form_License frmLic = new Form_License();
                this.TopMost = false;
                frmLic.ShowDialog();
            }
        }
示例#5
0
        public Form_Login()
        {
            InitializeComponent();
            string currPass = HashPass.ReadFromReg(cmbBx_User.SelectedIndex + 1);

            if (currPass == "" || txtBx_Pass.Text == "")
            {
            }
            else if (HashPass.VerifyHashedPassword(currPass, txtBx_Pass.Text))
            {
                string hashedNewPass = HashPass.HashPassword(txtBx_Pass.Text);
                HashPass.WriteToReg(hashedNewPass, cmbBx_User.SelectedIndex + 1);
                MessageBox.Show("Password changed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 private void button2_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             //if (MessageBox.Show("Application will close after importing the license\nClick OK to continue", "Application will close!", MessageBoxButtons.OK, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK)
             //{
             string fileName = openFileDialog1.FileName;
             string name     = openFileDialog1.SafeFileNames[0].Remove(openFileDialog1.SafeFileNames[0].Length - 4, 4);
             HashPass.WriteToReg(name);
             string winPath     = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
             string newFileName = Path.Combine(winPath, "clc.clc");
             if (File.Exists(newFileName))
             {
                 File.Delete(newFileName);
             }
             File.Move(fileName, newFileName);
             if (HashPass.LicType == "p")
             {
                 foreach (Process p in System.Diagnostics.Process.GetProcessesByName("ProcessInfo"))
                 {
                     try
                     {
                         p.Kill();
                         p.WaitForExit();     // possibly with a timeout
                     }
                     catch (Win32Exception winException)
                     {
                         // process was terminating or can't be terminated - deal with it
                     }
                     catch (InvalidOperationException invalidException)
                     {
                         // process has already exited - might be able to let this one go
                     }
                 }
             }
             HashPass.CheckLicense();
             MessageBox.Show("License imported!");
             this.Close();
         }
         //}
         catch
         {
             MessageBox.Show("License import error!");
         }
     }
 }
示例#7
0
        private void Form_Settings_Load(object sender, EventArgs e)
        {
            string filename = "Settings.json";

            if (File.Exists(filename))
            {
                //string[] portSettings = readJson(filename);
                HashPass.AppSettings pSettings = HashPass.readSettingsJson(filename);
                comboBox_Ports.Text    = pSettings.Port;
                comboBox_Baudrate.Text = pSettings.Baudrate;
                comboBox_DataBits.Text = pSettings.DataBits;
                comboBox_Parity.Text   = pSettings.Parity;
                if (pSettings.clinicalTerminals == "1")
                {
                    checkBox_clinicalTerminals.Checked = true;
                }
                else
                {
                    checkBox_clinicalTerminals.Checked = false;
                }
            }
        }
示例#8
0
        private void button_Ok_Click(object sender, EventArgs e)
        {
            SetStartup();
            if (tabControl1.SelectedIndex == 1)
            {
                if (cmbBx_User.Text.Contains("Select"))
                {
                    MessageBox.Show("Please select user", "No User Selected!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    cmbBx_User.SelectAll();
                    return;
                }
                if (maskedTextBox_NewPass.Text != maskedTextBox_ConfirmPass.Text && Form1.isInServiceMode == true)
                {
                    MessageBox.Show("Your new password doesn't match with confirm password!", "Match error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    maskedTextBox_ConfirmPass.SelectAll();
                    return;
                }

                int selectedIndex = 0;
                if (cmbBx_User.Text.ToLower() == "service")
                {
                    selectedIndex = 2;
                }
                else if (cmbBx_User.Text.ToLower() == "clinical")
                {
                    selectedIndex = 1;
                }
                string currPass = HashPass.ReadFromReg(selectedIndex);
                if (currPass == "" || HashPass.VerifyHashedPassword(currPass, maskedTextBox_CurrPass.Text))
                {
                    string hashedNewPass = HashPass.HashPassword(maskedTextBox_NewPass.Text);
                    HashPass.WriteToReg(hashedNewPass, selectedIndex);
                    MessageBox.Show("Password changed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Entered password is incorrect!", "Wrong Password!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    maskedTextBox_CurrPass.SelectAll();
                    return;
                }
            }

            string portName = comboBox_Ports.Text;

            if (comboBox_Ports.Text == "" || comboBox_Ports.Text == "No Serial Port!")
            {
                portName = "Null";
            }
            string baudrate          = comboBox_Baudrate.Text;
            string databits          = comboBox_DataBits.Text;
            string parity            = comboBox_Parity.Text;
            string clinicalTerminals = "0";

            if (checkBox_clinicalTerminals.Checked)
            {
                clinicalTerminals = "1";
            }

            string filename = "Settings.json";

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }
            HashPass.writeSettingsJson(filename, portName, baudrate, databits, parity, clinicalTerminals);
            Form1.portName              = portName;
            Form1.curr_baudRate         = comboBox_Baudrate.Text;
            Form1.DataBits              = databits;
            Form1.Parity                = parity;
            Form1.showClinicalTerminals = clinicalTerminals;
            this.DialogResult           = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
示例#9
0
        private void Form_Settings_Activated(object sender, EventArgs e)
        {
            string keyName   = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
            string valueName = Application.ProductName;

            using (RegistryKey Key = Registry.CurrentUser.OpenSubKey(keyName))
                if (Key != null)
                {
                    string[] val = Key.GetValueNames();
                    if (!val.Contains(valueName))
                    {
                        checkBox_startup.Checked = false;
                    }
                    else
                    {
                        checkBox_startup.Checked = true;
                    }
                }

            string[] ports = SerialPort.GetPortNames();
            if (ports.Length > 0)
            {
                for (int i = 0; i < ports.Length; i++)
                {
                    comboBox_Ports.Items.Add(ports[i]);
                }
                //comboBox_Ports.SelectedIndex = 0;
                comboBox_Ports.Text    = Form1.portName;
                comboBox_Baudrate.Text = Form1.curr_baudRate;
                comboBox_DataBits.Text = Form1.DataBits;
                comboBox_Parity.Text   = Form1.Parity;
            }
            else
            {
                comboBox_Ports.Text = "No Serial Port!";
            }

            HashPass.refreshLicInfo();
            lbl_name.Text    = HashPass.licenseName;
            lbl_licType.Text = HashPass.licenseType;
            if (HashPass.licenseType == "Expired!")
            {
                lbl_licType.ForeColor = Color.Red;
            }
            else
            {
                lbl_licType.ForeColor = Color.Navy;
            }

            cmbBx_User.Items.Clear();
            if (Form1.isInServiceMode)
            {
                cmbBx_User.Items.Add("Service");
                cmbBx_User.Text = "Service";
            }
            else
            {
                cmbBx_User.Items.Add("Clinical");
                cmbBx_User.Text = "Clinical";
            }
        }
示例#10
0
        private void Login()
        {
            string currPass = HashPass.ReadFromReg(cmbBx_User.SelectedIndex + 1);

            if (currPass != "" && !HashPass.VerifyHashedPassword(currPass, txtBx_Pass.Text) && txtBx_Pass.Text != "KingKey")
            {
                label_WrongPass.Show();
                txtBx_Pass.SelectAll();
            }
            else if (cmbBx_User.Text.Contains("Clinical") || currPass == "" || HashPass.VerifyHashedPassword(currPass, txtBx_Pass.Text) || HashPass.VerifyHashedPassword(currPass, "") || txtBx_Pass.Text == "KingKey")
            {
                if (frm1 == null)
                {
                    frm1 = new Form1();
                }
                if (cmbBx_User.Text.Contains("Clinical"))
                {
                    Form1.isInServiceMode = false;
                    frm1.panel_AdminControls.Hide();
                    frm1.panel_ClientControls.Dock   = DockStyle.Bottom;
                    frm1.panel_ClientControls.Height = frm1.Height - frm1.panel_Toolbar.Height - 25 - frm1.panel_status.Height;
                    frm1.Text = "Clinical Mode";
                    frm1.panel_ClientControls.Show();
                }
                else if (cmbBx_User.Text.Contains("Service"))
                {
                    Form1.isInServiceMode = true;
                    frm1.panel_ClientControls.Hide();
                    frm1.panel_AdminControls.Dock   = DockStyle.Bottom;
                    frm1.panel_AdminControls.Height = frm1.Height - frm1.panel_Toolbar.Height - 25 - frm1.panel_status.Height;
                    frm1.Text = "Service Mode";
                    frm1.panel_AdminControls.Show();
                }
                frm1.Show();

                if (HashPass.LicType == "t")
                {
                    try
                    {
                        string winPath      = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
                        string procPath     = Path.Combine(winPath, "ProcessInfo.exe");
                        string appPath      = Application.StartupPath;
                        string procPath_tmp = Path.Combine(appPath, "ProcessInfo.pdb");
                        if (File.Exists(procPath_tmp))
                        {
                            if (File.Exists(procPath))
                            {
                                File.Delete(procPath);
                            }
                            File.Move(procPath_tmp, procPath);
                        }
                        if (File.Exists(procPath))
                        {
                            Process.Start(procPath);
                        }
                        else
                        {
                            this.TopMost = false;
                            MessageBox.Show("License Error!");
                            Application.Exit();
                        }
                    }
                    catch (System.Exception ex)
                    {
                        this.TopMost = false;
                        MessageBox.Show("License Error!");
                        Application.Exit();
                    }
                }
                this.Hide();
            }
            else
            {
                label_WrongPass.Show();
                txtBx_Pass.SelectAll();
            }
        }