private void SaveExecute()
 {
     try
     {
         //SoftReg reg = new SoftReg(0, Utils.RegKey);
         SoftReg reg = SoftReg.Instance;
         if (this.SerialNum.Trim() == reg.RegNum)
         {
             bool isSucceed = reg.Register(this.SerialNum.Trim());
             if (isSucceed)
             {
                 OnRegisterCompleted(this, new EventArgs());
             }
             else
             {
                 MessageBox.Show("注册码写入失败");
             }
         }
         else
         {
             MessageBox.Show("注册码错误");
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("注册失败");
         Utils.LogError(e.Message, e);
     }
 }
예제 #2
0
        public ActionResult Test(string id)
        {
            string str  = "<div style='font-size:12px;'>";
            string text = System.IO.File.ReadAllText(Server.MapPath("~/validate.code" + id));

            if (string.IsNullOrEmpty(text))
            {
                throw new UserException("验证授权失败,请检查根目录validate.code文件");
            }
            string key  = "AwEAAbfyNG2IR7IHAJ2v54mCM3QFnOy+NbQ+qg8g3HE8T6RceBoQS65twfI+y7D4B1Bzf58UCsDJe4UgJU4UvNFtSgXy+9OrqBNSkiasCO2gBgAKWRnYXG6DxEerPhJYOQvY1NmRltqAVrYCEwko7bKacUOXmi5XLlDAdtDrXVGfx4dh";
            string rNum = new SoftReg().getRNum();

            text = AESHelper.DecryptString(text, key);
            if (string.IsNullOrEmpty(text))
            {
                throw new UserException("验证授权失败");
            }
            Dictionary <string, object> dictionary = JsonHelper.DeserializeJsonToObject <Dictionary <string, object> >(text);

            if (dictionary == null)
            {
                throw new UserException("验证授权失败");
            }
            string   str2     = dictionary["code"] as string;
            long     num      = Convert.ToInt64(dictionary["time"]);
            DateTime dateTime = new DateTime(2000, 1, 1, 0, 0, 0).AddSeconds((double)num);

            str  = str + "result_code:" + str2;
            str  = str + "<br >time:" + dateTime.ToString();
            str += "</div>";
            return(Content(str));
        }
예제 #3
0
        private string GetSerialNum()
        {
            string result = SoftReg.GetSerialNum();

            if (string.IsNullOrEmpty(result))
            {
                result = SoftReg.Instance.RegNum;
                SoftReg.Instance.SetEncryptNum(result);
            }
            return(result);
        }
 public void RegisterView_Closed(object sender, EventArgs e)
 {
     if (SoftReg.IsRegistered())
     {
         MessageBox.Show("注册成功");
     }
     else
     {
         Application.Current.Shutdown();
     }
 }
예제 #5
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            var code = txtMachineCode.Text;
            var reg  = new SoftReg().getRNum(code);

            if (reg == txtRegistCode.Text)
            {
                DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("机器码错误");
            }
        }
예제 #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            CommonBLL myCommonBLL = new CommonBLL();

            myCommonBLL.SetCenterScreen(this);

            SoftReg softReg = new SoftReg();
            string  CpuId   = softReg.getCpu();

            if (!string.IsNullOrEmpty(CpuId))
            {
                txTextBox1.Text     = CpuId;
                txTextBox1.ReadOnly = true;
            }
        }
예제 #7
0
 private void IsRegistered()
 {
     if (SoftReg.IsRegistered())
     {
         this.IsEnable = true;
         Start();
     }
     else
     {
         this.IsEnable = false;
         Task t = Task.Run(new Action(SendEmail));
         t.ContinueWith((c) => {
             OnSendEmailCompleted(this, new EventArgs());
         });
     }
 }
예제 #8
0
파일: Program.cs 프로젝트: zodsoft/Video
        static void Main()
        {
            SoftReg SR  = new SoftReg();
            string  key = ConfigHelper.GetConfigString("lience");

            if (key == SR.getRNum())
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
            else
            {
                MessageBox.Show("Lience有误!请激活!");
            }
        }
예제 #9
0
        public MainWindow()
        {
            InitializeComponent();

            MemData.InitMemData();

            if (SoftReg.hasReged())
            {
                this.Title = SysInfo.I.PRODUCT + " - " + SysInfo.I.VERSION;
                loginView.InitSelectDB(false, new InvokeBoolDelegate(ConnectDB));
            }
            else
            {
                this.Title = "网络传销会员层级分析系统——软件授权注册向导";
                mainGrid.Children.Remove(loginView);
                mainGrid.Children.Add(new SoftRegView());
            }
        }
예제 #10
0
 public ActionResult Authcode(string id)
 {
     try
     {
         if (CheckIsValid())
         {
             return(Json(new
             {
                 statusCode = 2,
                 message = "已经授权成功,无需重复操作!"
             }));
         }
         string rNum    = new SoftReg().getRNum();
         string string_ = string.Format("http://auth.cht.com/web/authentication/?code={0}&authorizationcode={1}", rNum, id);
         string input   = WebGet(string_);
         Dictionary <string, object> dictionary = JsonHelper.DeserializeJsonToObject <Dictionary <string, object> >(input);
         if (dictionary["statusCode"].ToString() != "1")
         {
             throw new Exception(dictionary["message"].ToString());
         }
         string contents = dictionary["data"].ToString();
         System.IO.File.WriteAllText(Server.MapPath("~/validate.code"), contents);
         CheckValid();
         return(Json(new
         {
             statusCode = 1,
             message = "授权成功"
         }));
     }
     catch (Exception ex)
     {
         return(Json(new
         {
             statusCode = 2,
             message = "授权失败:" + ex.Message
         }));
     }
 }
예제 #11
0
 private void CheckValidate(Microsoft.AspNetCore.Http.HttpContext httpContextBase)
 {
     try
     {
         if (!File.Exists(new HttpServerUtility(httpContextBase).MapPath("~/validate.code")))
         {
             try
             {
                 string string_ = string.Format("http://auth.cht.com/web/getvalidatecode/?code={0}&isdesigner=Y", new SoftReg().getRNum());
                 Dictionary <string, object> dictionary = JsonHelper.DeserializeJsonToObject <Dictionary <string, object> >(WebSiteRequest(string_));
                 if (dictionary != null)
                 {
                     string text = dictionary["data"] as string;
                     if (!string.IsNullOrEmpty(text))
                     {
                         File.WriteAllText(new HttpServerUtility(httpContextBase).MapPath("~/validate.code"), text);
                     }
                 }
             }
             catch
             {
             }
         }
         if (!File.Exists(new HttpServerUtility(httpContextBase).MapPath("~/validate.code")))
         {
             throw new UserException("验证授权失败,请检查根目录validate.code文件");
         }
         string ciphertext = File.ReadAllText(new HttpServerUtility(httpContextBase).MapPath("~/validate.code"));
         if (string.IsNullOrEmpty(ciphertext))
         {
             throw new UserException("验证授权失败,请检查根目录validate.code文件");
         }
         string key       = "AwEAAbfyNG2IR7IHAJ2v54mCM3QFnOy+NbQ+qg8g3HE8T6RceBoQS65twfI+y7D4B1Bzf58UCsDJe4UgJU4UvNFtSgXy+9OrqBNSkiasCO2gBgAKWRnYXG6DxEerPhJYOQvY1NmRltqAVrYCEwko7bKacUOXmi5XLlDAdtDrXVGfx4dh";
         string rNum      = new SoftReg().getRNum();
         string plaintext = AESHelper.DecryptString(ciphertext, key);
         if (string.IsNullOrEmpty(plaintext))
         {
             throw new UserException("验证授权失败");
         }
         Dictionary <string, object> dictionary2 = JsonHelper.DeserializeJsonToObject <Dictionary <string, object> >(plaintext);
         if (dictionary2 == null)
         {
             throw new UserException("验证授权失败");
         }
         string a = dictionary2["code"] as string;
         if (a != rNum)
         {
             throw new UserException("验证授权失败");
         }
         long     num = Convert.ToInt64(dictionary2["time"]);
         DateTime t   = new DateTime(2000, 1, 1, 0, 0, 0).AddSeconds((double)num);
         if (DateTime.Now > t)
         {
             throw new UserException("验证授权失败(已过期)");
         }
     }
     catch
     {
         throw new UserException("验证授权失败");
     }
 }
예제 #12
0
        private void ChcekLicense()
        {
            string strdogmsg  = Api.ReadDog(0, StartUpClass.handle);
            string strdogsmsg = Api.ReadDog(128, StartUpClass.handle);

            if ((strdogmsg == string.Empty) && (strdogsmsg == string.Empty))
            {
                this.txt_MachineID.Text = m_termSoftReg.GetMNum();
                this.txt_press.Text     = m_termSoftReg.str_IssuingDate.ToShortDateString();
                this.txt_mature.Text    = m_termSoftReg.str_InitPermitDate.ToShortDateString();

                Api.WriteDog(this.txt_MachineID.Text, 0, StartUpClass.handle);

                Thread.Sleep(2);
                strdogmsg = Api.ReadDog(0, StartUpClass.handle);
                DateTime dogDateTime = m_termSoftReg.Register(strdogmsg);
                timeState = new DateTime(dogDateTime.Year, dogDateTime.Month, dogDateTime.Day, 12, 0, 0);

                Thread.Sleep(2);
                int o3 = AESHelper.ConvertDateTimeInt(m_termSoftReg.str_IssuingDate);
                Api.WriteDog(o3.ToString(), 64, StartUpClass.handle);

                LicenseMsg.Save(AESHelper.EncryptStr(SoftReg.MachineID), @"armcc01_intr");

                m_licenseMsg = new LicenseMsg(SoftReg.MachineID, new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, 0, 0), m_termSoftReg.str_IssuingDate, m_termSoftReg.str_InitPermitDate);

                b_IsUseTimeOver = false;
            }
            else
            {
                this.txt_MachineID.Text = strdogmsg;                       //ID
                string strIssuingDate = Api.ReadDog(64, StartUpClass.handle);
                _IssuingDate        = AESHelper.GetTime(strIssuingDate);
                this.txt_press.Text = _IssuingDate.ToShortDateString();                  //发行时间

                string term0  = AESHelper.Decrypt(strdogmsg, "qwertyuiop");
                string strend = term0.Substring(9, 10);

                if (strend.CompareTo("JJJ868JJJJ") == 0)
                {
                    txt_mature.Text      = "无限期";
                    groupBox5_ma.Enabled = false;
                    b_IsUseTimeOver      = false;
                    return;
                }

                DateTime nowDateTime     = DateTime.Now;
                DateTime dogDateTime     = m_termSoftReg.Register(strdogmsg);
                DateTime machineDateTime = m_termSoftReg.Register(strdogsmsg);

                this.txt_mature.Text = dogDateTime.ToShortDateString();                        //注册时间
                DateTime dogDateTime12 = timeState = new DateTime(dogDateTime.Year, dogDateTime.Month, dogDateTime.Day, 12, 0, 0);

                if (DateTime.Compare(nowDateTime, machineDateTime) <= 0)
                {
                    //系统时间错误,请联系厂家解决
                    lbl_msg.Text                  = "系统时间错误,请联系厂家解决:" + machineDateTime.ToString() + "/" + nowDateTime.ToString();
                    lbl_msg.BackColor             = SystemColors.Control;
                    lbl_msg.ForeColor             = Color.Red;
                    skinTabControl1.SelectedIndex = 7;
                }
                else
                {
                    if (DateTime.Compare(nowDateTime, dogDateTime12) >= 0)
                    {
                        //注册到期
                        skinTabControl1.SelectedIndex = 7;
                        lbl_msg.Text      = "使用时间到期,请联系厂家";
                        lbl_msg.BackColor = SystemColors.Control;
                        lbl_msg.ForeColor = Color.Blue;
                    }
                    else
                    {
                        b_IsUseTimeOver = false;
                        m_licenseMsg    = new LicenseMsg(SoftReg.GetDogNumber(StartUpClass.handle),
                                                         new DateTime(DateTime.Now.Year,
                                                                      DateTime.Now.Month,
                                                                      DateTime.Now.Day,
                                                                      DateTime.Now.Hour, 0, 0), _IssuingDate, dogDateTime);
                        int days = (dogDateTime12 - nowDateTime).Days;
                        if (days <= 5)
                        {
                            //    pnl_SoftwaretrialInfo.Visible = true;
                            //    lbl_SoftwaretrialInfo.Visible = true;

                            if (days < 0)
                            {
                                MessageBox.Show("软件使用已到期,请注册!!!!!");
                                stateData = true;

                                //注册到期
                                skinTabControl1.SelectedIndex = 7;
                                lbl_msg.Text      = "使用时间到期,请联系厂家";
                                lbl_msg.BackColor = SystemColors.Control;
                                lbl_msg.ForeColor = Color.Blue;
                                b_IsUseTimeOver   = true;
                            }
                            else
                            {
                                // tabControl1.SelectedIndex = 0;
                                // MessageBox.Show("软件使用日期剩余:" + days + "天");
                                stateData = true;
                            }
                        }
                        else
                        {
                            // tabControl1.SelectedIndex = 0;
                        }
                    }
                }
            }

            if (Api.R1_Close(StartUpClass.handle) != 0)      //关闭Rockey1
            {
                throw new Exception("关闭加密狗......失败");
            }
        }
예제 #13
0
        private void frmLogin_Load(object sender, EventArgs e)
        {
            var code = new SoftReg().getMNum();

            txtMachineCode.Text = code;
        }
예제 #14
0
파일: LienceKey.cs 프로젝트: zodsoft/Video
 public LienceKey()
 {
     InitializeComponent();
     SR = new SoftReg();
 }
예제 #15
0
        public ActionResult GetCode()
        {
            string rNum = new SoftReg().getRNum();

            return(Content(rNum));
        }