Example #1
0
        /// <summary>
        /// 检测软件是否授权
        /// </summary>
        public static void CheckSoftAuthorize()
        {
            SoftAuthorize m_softAuthorize = new SoftAuthorize();

            //方式一
            m_softAuthorize.FileSavePath = Application.StartupPath + @"\Authorize.sys"; //存储激活码文件,存储加密
            m_softAuthorize.LoadByFile();

            // 检测激活码是否正确,没有文件,或激活码错误都算作激活失败
            if (!m_softAuthorize.IsAuthorizeSuccess(AuthorizeEncrypted))
            {
                //显示注册窗口
                using (FormAuthorize form = new FormAuthorize(m_softAuthorize, "请填写注册码!", AuthorizeEncrypted))
                {
                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        //授权失败,退出应用程序
                        Application.Exit();
                    }
                }
            }

            //方式二 :直接进行判断授权码
            //if (!m_softAuthorize.CheckAuthorize("4408B6C4F17EF79B0210F997771C1E5FBA75748F5DD9DD3C59B9E69FCE05DAF5", AuthorizeEncrypted))
            //{
            //    //授权失败!
            //    Application.Exit();
            //}
        }
Example #2
0
 private void button3_Click(object sender, EventArgs e)
 {
     // 检测激活码是否正确,没有文件,或激活码错误都算作激活失败
     if (!softAuthorize.IsAuthorizeSuccess(AuthorizeEncrypted))
     {
         // 显示注册窗口
         using (
             FormAuthorize form = new FormAuthorize(softAuthorize, "请联系华天世纪激光科技有限公司获取激活码!", AuthorizeEncrypted))
         {
             if (form.ShowDialog() != DialogResult.OK)
             {
                 // 授权失败,退出
                 MessageBox.Show("授权失败!");
             }
             else
             {
                 MessageBox.Show("授权成功!");
             }
         }
     }
     else
     {
         MessageBox.Show("授权成功!");
     }
 }
Example #3
0
        /// <summary>
        /// 检测软件是否授权
        /// </summary>
        private void CheckSoftAuthorize()
        {
            m_softAuthorize = new SoftAuthorize();

            //方式一
            m_softAuthorize.FileSavePath = Application.StartupPath + @"\Authorize.sys"; //存储激活码文件,存储加密
            m_softAuthorize.LoadByFile();

            // 检测激活码是否正确,没有文件,或激活码错误都算作激活失败
            if (!m_softAuthorize.IsAuthorizeSuccess(AuthorizeEncrypted))
            {
                File.SetAttributes(m_softAuthorize.FileSavePath, FileAttributes.ReadOnly);

                using (FormAuthorize form = new FormAuthorize(m_softAuthorize, "请联系华天世纪激光科技公司获取注册码!", AuthorizeEncrypted))
                {
                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        Close();
                    }
                }
            }

            //方式二 :直接进行判断授权码
            //if (!m_softAuthorize.CheckAuthorize("CC2A56387E05A1953ABCE666892B916617CA21808A35ABE1B7592DF20DB44CF6", AuthorizeEncrypted))
            //{
            //    Close();
            //}
        }
Example #4
0
        /// <summary>
        /// 初始化授权码校验
        /// </summary>
        /// <returns></returns>
        public virtual bool InitAuthorize()
        {
            // 检测激活码是否正确,没有文件,或激活码错误都算作激活失败
            JsonResponse response = authorize.CheckLocalAuthorize();

            if (!response.ValidateResponses())
            {
                // 显示注册窗口
                using (FormAuthorize form =
                           new FormAuthorize(
                               "请根据机器码联系管理员获取注册码", authorize))
                {
                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        // 授权失败,退出
                        return(false);
                    }
                }
            }
            return(true);
        }
Example #5
0
 private static SoftAuthorize softAuthorize = null;//授权
 /// <summary>
 /// 授权验证
 /// </summary>
 /// <returns></returns>
 public static bool Authorize(string prompt)
 {
     //授权
     if (string.IsNullOrEmpty(prompt))
     {
         prompt = "Please contact the supplier for registration code";
     }
     softAuthorize = new SoftAuthorize();
     softAuthorize.FileSavePath = Application.StartupPath + @"\Authorize.txt"; // 设置存储激活码的文件,该存储是加密的
     softAuthorize.LoadByFile();
     // 检测激活码是否正确,没有文件,或激活码错误都算作激活失败
     if (!softAuthorize.IsAuthorizeSuccess(AuthorizeEncrypted))
     {
         // 显示注册窗口
         using (FormAuthorize form =
                    new FormAuthorize(
                        softAuthorize,
                        prompt,
                        AuthorizeEncrypted))
         {
             if (form.ShowDialog() != DialogResult.OK)
             {
                 // 授权失败,退出
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
     }
     else
     {
         return(true);
     }
 }
Example #6
0
 /// <summary>
 /// 新增永久激活用户
 /// </summary>
 /// <param name="softAuthorize"></param>
 public void AppActivate(SoftAuthorize softAuthorize)
 {
     if (Check_RegCode())
     {
         // 显示注册窗口
         if (!IsOpenADW)
         {
             ADW_RegCode = "";
         }
         using (FormAuthorize form =
                    new FormAuthorize(
                        softAuthorize,
                        ADW_RegCode,
                        AuthorizeEncrypted))
         {
             if (form.ShowDialog() != DialogResult.OK)
             {
                 // 授权失败,退出
                 //Mesbox("授权失败!  ");
             }
             else
             {
                 try
                 {
                     //创建Httphelper对象
                     http = new HttpHelper();
                     //创建Httphelper参数对象
                     item = new HttpItem()
                     {
                         URL          = "http://47.98.156.83/panoramicAppLogin/reg_app.php?action=submit_regcode&machine_code=" + softAuthorize.GetMachineCodeString() + "&reg_code=" + AuthorizeEncrypted(softAuthorize.GetMachineCodeString()), //URL     必需项
                         Method       = "post",                                                                                                                                                                                                   //URL     可选项 默认为Get
                         ContentType  = "application/x-www-form-urlencoded",                                                                                                                                                                      //返回类型    可选项有默认值
                         PostDataType = PostDataType.String
                     };
                     ////请求的返回值对象
                     result  = http.GetHtml(item);
                     GetData = result.Html.Trim();
                     if (GetData.Equals("400") || GetData.Equals("激活失败"))
                     {
                         return;
                     }
                     else
                     {
                         Main.appisReg = false;
                         MessageBox.Show("授权成功! 重新打开应用", "提示");
                         ReLoign();
                     }
                 }
                 catch (Exception ex)
                 {
                     Main.appisReg = true;
                     MessageBox.Show("网络连接失败! ", "提示");
                 }
             }
         }
     }
     else
     {
         Main.appisReg = false;
     }
 }