示例#1
0
        /// <summary>
        /// 写入数据(一次完全操作)
        /// </summary>
        /// <param name="dog"></param>
        /// <returns></returns>
        public int WriteHandle(string p_string)
        {
            LivingDog dog = new LivingDog();

            try
            {
                dog.Grand_OpenDog(LIV_APP_CODE, 0);
                //int Result = dog.Grand_Passwd(0, "20JJSoft13");
                int Result = dog.Grand_Passwd(0, "09JJSoft12");

                byte[] oByte = System.Text.ASCIIEncoding.Default.GetBytes(p_string.ToString().Trim());
                //
                if (dog.Grand_Write(2, oByte) == LivingDog.LIV_SUCCESS)
                {
                    return(_GlodSoftDiscern.TRY_SUCCESS);
                }
                return(_GlodSoftDiscern.TRY_ERROR);
            }
            catch
            {
                return(_GlodSoftDiscern.TRY_ERROR);
            }
            finally
            {
                dog.Grand_CloseDog();
            }
        }
示例#2
0
        /// <summary>
        /// 功能 以及 合法性验证
        ///
        /// </summary>
        /// <param name="p_dog"></param>
        /// <returns></returns>
        public void ReadHandle(LivingDog p_dog)
        {
            //int Result = p_dog.Grand_Passwd(0, "20JJSoft13");
            int Result = p_dog.Grand_Passwd(0, "09JJSoft12");

            if (Result == 0)
            {
                byte[] outByte = new byte[512];
                //读取加密狗的数据
                if (p_dog.Grand_Read(2, outByte) == LivingDog.LIV_SUCCESS)
                {
                    string str   = System.Text.ASCIIEncoding.Default.GetString(outByte).Trim('\0');
                    int    index = str.IndexOf("\0");
                    if (index > 0)
                    {
                        str = str.Substring(0, index);
                    }
                    if (!this.IsEmptyHandle(str))
                    {
                        //读取数据
                        string[] data = str.Split(',');
                        this.Parent.ClientResult.Read(data);
                    }
                    this.Parent.ClientResult.IsReadHeandle = true;
                    //else
                    //{
                    //    //数据读取失败
                    //    this.Parent.ClientResult.IsReadHeandle = false;
                    //}
                }
            }
        }
示例#3
0
文件: Softdog.cs 项目: shansheng/QDJJ
        public static SoftdogProtocol ValidateLocal()
        {
            var message  = "验证不通过";
            var result   = new SoftdogProtocol();
            var pwd      = "JJSoft0912";
            var driver   = new LivingDog();
            var hardware = default(LivingDog.LIV_hardware_info);
            var status   = 0;

            try
            {
                status   = driver.Grand_OpenDog(DogCode, 0);
                hardware = driver.Grand_GetHardware_info();
                switch (hardware.RetCode)
                {
                case 0:
                    if (driver.Grand_Passwd(1, pwd) == LivingDog.LIV_SUCCESS)
                    {
                        byte[] outByte = new byte[50];
                        if (driver.Grand_Read(1, outByte) == LivingDog.LIV_SUCCESS)
                        {
                            string strs = System.Text.ASCIIEncoding.Default.GetString(outByte);
                            //3.领先版  4是专业版 5是旗舰版 6是网络版
                            if (strs[3] == '1' || strs[4] == '1' || strs[5] == '1' || strs[6] == '1')     //加密狗有效性验证
                            {
                                goto success;
                            }
                        }
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception e)
            {
                message = e.Message;
            }
            finally
            {
                driver.Grand_CloseDog();
            }

            result.Error   = true;
            result.Message = message;
            return(result);

success:
            result.Success      = true;
            result.SerialNumber = Encoding.Default.GetString(hardware.serialNumber);
            result.Error        = false;
            return(result);
        }