Esempio n. 1
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            CDTControl.Log log      = new CDTControl.Log();
            string         isOnline = int.Parse(rgOnline.EditValue.ToString()) == 0 ? "" : "1";

            if (rgCnnType.SelectedIndex == 0)
            {
                cpu = new CPUid(textCompanyName.Text + _ProductName + "SGDEMTOnline" + isOnline);
            }
            else if (rgCnnType.SelectedIndex == 1)
            {
                cpu = new CPUid(textCompanyName.Text + _ProductName + "SGDBPMOnline" + isOnline);
            }
            txtMaMay.Text = cpu.MaMay;
            bool kq = false;

            try
            {
                UserKey uKey = new UserKey();
                uKey.ID       = 0; uKey.UserID = tfbID.Text; uKey.companyName = textCompanyName.Text; uKey.Mamay = txtMaMay.Text;
                uKey.CDate    = DateTime.Now; uKey.DaTT = 0; uKey.IDGT = tIDGT.Text; uKey.isOnline = int.Parse(rgOnline.EditValue.ToString());
                uKey.Product  = rgCnnType.SelectedIndex == 0 ? "Phần mềm kế toán" : "Giải pháp BPM";
                uKey.Maskcode = cpu.MixString; uKey.LicenseKey = cpu.KeyString; uKey.Exdate = DateTime.Now.AddYears(int.Parse(tSonam.EditValue.ToString()));

                string ob = JsonConvert.SerializeObject(uKey);

                textEditMaskcode.Text = cpu.MixString;
                string key    = cpu.KeyString;
                string keyGet = log.logFb(ob);
                if (keyGet != "")
                {
                    UserKey returnKey1 = JsonConvert.DeserializeObject <UserKey>(keyGet);
                    textEditValue.Text           = returnKey1.LicenseKey;
                    simpleButtonRegister.Enabled = true;
                    simpleButtonRegister_Click(sender, e);
                }
                else
                {
                    // textEditValue.Text = keyGet;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            CDTControl.Log log      = new CDTControl.Log();
            string         isOnline = int.Parse(rgOnline.EditValue.ToString()) == 0 ? "" : "1";

            if (rgCnnType.SelectedIndex == 0)
            {
                cpu = new CPUid(textCompanyName.Text + _ProductName + "SGDEMTOnline" + isOnline);
            }
            else if (rgCnnType.SelectedIndex == 1)
            {
                cpu = new CPUid(textCompanyName.Text + _ProductName + "SGDBPMOnline" + isOnline);
            }
            txtMaMay.Text = cpu.MaMay;
            bool kq = false;

            try
            {
                UserKey uKey = new UserKey();
                uKey.ID       = 0; uKey.UserID = tfbID.Text; uKey.companyName = textCompanyName.Text; uKey.Mamay = txtMaMay.Text;
                uKey.CDate    = DateTime.Now; uKey.DaTT = 0; uKey.IDGT = tIDGT.Text; uKey.isOnline = int.Parse(rgOnline.EditValue.ToString());
                uKey.Product  = rgCnnType.SelectedIndex == 0 ? "Phần mềm kế toán" : "Giải pháp BPM";
                uKey.Maskcode = cpu.MixString; uKey.LicenseKey = cpu.KeyString; uKey.Exdate = DateTime.Now.AddYears(1);

                string ob = JsonConvert.SerializeObject(uKey);

                textEditMaskcode.Text = cpu.MixString;
                string key    = cpu.KeyString;
                string keyGet = log.logFb(ob);
                if (keyGet != "")
                {
                    UserKey returnKey1 = JsonConvert.DeserializeObject <UserKey>(keyGet);
                    textEditValue.Text           = returnKey1.LicenseKey;
                    simpleButtonRegister.Enabled = true;
                    //Đăng ký tên máy - Key cho server
                    if (isOnline == "1")
                    {
                        UserConnection uCon = new UserConnection();
                        uCon.ComputerName = uKey.Mamay; uCon.DatabaseName = _ProductName; uCon.LicenceKey = returnKey1.LicenseKey;
                        uCon.StructDb     = ""; uCon.TimeEx = DateTime.Now.AddYears(int.Parse(sSonam.Value.ToString()));
                        ob = JsonConvert.SerializeObject(uCon);
                        string re = RegistConnection(ob);
                        uCon = JsonConvert.DeserializeObject <UserConnection>(re);

                        if (uCon != null)
                        {
                            string Con = GetConnection(uCon.stt);
                            uCon = JsonConvert.DeserializeObject <UserConnection>(Con);


                            string StructConnection = Security.DeCode64(uCon.StructDb);
                            StructConnection += ";Database = " + Config.GetValue("ProductName").ToString();
                            Config.NewKeyValue("StructConnection", Security.EnCode64(StructConnection));
                        }
                    }
                    simpleButtonRegister_Click(sender, e);
                }
                else
                {
                    // textEditValue.Text = keyGet;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }