Example #1
0
 public static bool MakeExportedRegFile(string string_0, TaxCard taxCard_1)
 {
     try
     {
         if (taxCard_1.TaxMode == CTaxCardMode.tcmHave)
         {
             RegFileInfo regFileInfo = GetRegFileInfo(string_0, taxCard_1);
             if ((regFileInfo != null) && regFileInfo.CheckedOk)
             {
                 byte[] buffer = new byte[0x10];
                 for (int i = 0; i < buffer.Length; i++)
                 {
                     buffer[i] = (byte)i;
                 }
                 return(Xihaa.MakeTransFile(regFileInfo.FileName, buffer) == 0);
             }
         }
         return(false);
     }
     catch (Exception exception)
     {
         ilog_0.Error(exception.Message);
         return(false);
     }
 }
Example #2
0
        private static RegFileInfo smethod_3(string string_0, TaxCard taxCard_1)
        {
            DateTime time;

            if (taxCard_1 == null)
            {
                taxCard_1 = taxCard_0;
            }
            else
            {
                taxCard_0 = taxCard_1;
            }
            string taxCode = taxCard_1.TaxCode;

            if (((taxCard_1.TaxCode.Length > 15) && (SetupOrgCode != null)) && (SetupOrgCode.Length > 0))
            {
                taxCode = taxCode + SetupOrgCode;
            }
            string b = taxCard_1.TaxCode;

            if ((taxCard_1.CorpCode != null) && (taxCard_1.CorpCode.Length >= 15))
            {
                b = taxCard_1.TaxCode.Substring(0, 6) + taxCard_1.CorpCode.Substring(6, 9);
            }
            qwe qwe = new qwe();

            taxCard_1.GetCardClock(out time, 0);
            if (Xihaa.abc(string_0, taxCode, (ushort)taxCard_1.Machine, time.ToString("yyyyMMdd"), ref qwe) == 0)
            {
                RegFileInfo info = new RegFileInfo(string_0, qwe, new FileInfo(string_0).LastWriteTime);
                string      a    = new string(info.FileContent.TaxCode);
                string      str2 = a;
                if (a.StartsWith("50"))
                {
                    a = "91" + a.Substring(2);
                }
                if (((!string.Equals(str2, taxCard_1.CompressCode) && !string.Equals(a, taxCard_1.CompressCode)) && (!string.Equals(a, b) && !string.Equals(a, taxCard_1.CorpCode))) && !string.Equals(a, taxCard_1.TaxCode))
                {
                    ilog_0.DebugFormat("文件原始税号={0},压缩税号={1};变换后税号1={2},变换后税号2={3};CorpCode税号={4},TaxCode税号={5};", new object[] { str2, taxCard_1.CompressCode, a, b, taxCard_1.CorpCode, taxCard_1.TaxCode });
                    info.ErrCode = "910103";
                    return(info);
                }
                if (taxCard_1.Machine != info.FileContent.BranchNo)
                {
                    ilog_0.DebugFormat("开票机号={0},文件开票机号={1}", taxCard_1.Machine, info.FileContent.BranchNo);
                    info.ErrCode = "910104";
                    return(info);
                }
                info.ErrCode = "0000";
                return(info);
            }
            return(new RegFileInfo(string_0, qwe, new FileInfo(string_0).LastWriteTime)
            {
                ErrCode = "910101"
            });
        }
Example #3
0
 public static bool PreMakeInvoice()
 {
     try
     {
         if (taxCard_0.TaxMode != CTaxCardMode.tcmHave)
         {
             return(true);
         }
         byte[] buffer  = new byte[0x10];
         byte[] buffer2 = null;
         ilog_0.Debug("[注册] 调用9Bit接口开始");
         taxCard_0.Get9BitHashTaxCode(out buffer2, 0);
         ilog_0.Debug("[注册] 调用9Bit接口结束");
         if (buffer2 == null)
         {
             ilog_0.Error("调用接口返回的Hash税号为空");
             return(false);
         }
         Xihaa.GenProKey(buffer, buffer2);
         if (buffer.Length < 0x10)
         {
             ilog_0.Error("调用接口返回的过程密钥为空");
             return(false);
         }
         ilog_0.Debug("[注册] 调用Pre接口开始");
         string str = taxCard_0.PreMakeInvoice(buffer, 0);
         ilog_0.DebugFormat("[注册] 调用Pre接口结束,返回值={0}", str);
         if (ToolUtil.GetReturnErrCode(str) == 0)
         {
             return(true);
         }
         ilog_0.Error("调用开票初始化接口失败,错误号=" + errCode);
         return(false);
     }
     catch (Exception exception)
     {
         ilog_0.Error(exception.Message);
         return(false);
     }
 }
Example #4
0
        private static byte[] smethod_11(RegFileInfo regFileInfo_0, byte[] array_0, TaxCard taxCard_1)
        {
            DateTime time;

            errCode = "0000";
            if (taxCard_1 == null)
            {
                taxCard_1 = taxCard_0;
            }
            else
            {
                taxCard_0 = taxCard_1;
            }
            if (array_0.Length != 0x10)
            {
                throw new ArgumentException("验证注册码时,传入的参数不正确");
            }
            byte[] destinationArray = new byte[0x40];
            byte[] bytes            = BitConverter.GetBytes(regFileInfo_0.FileContent.SoftwareType);
            Array.Copy(bytes, 0, destinationArray, 0, bytes.Length);
            byte[] sourceArray = Encoding.ASCII.GetBytes(regFileInfo_0.FileContent.SoftwareID);
            Array.Copy(sourceArray, 0, destinationArray, 2, sourceArray.Length);
            byte[] buffer4 = BitConverter.GetBytes(regFileInfo_0.FileContent.SerialNo);
            Array.Copy(buffer4, 0, destinationArray, 8, buffer4.Length);
            byte[] array = BitConverter.GetBytes(Convert.ToInt32(new string(regFileInfo_0.FileContent.StopDate), 0x10));
            Array.Reverse(array);
            Array.Copy(array, 0, destinationArray, 12, array.Length);
            if (regFileInfo_0.FileContent.SoftwareType == 1)
            {
                destinationArray[0x10] = 1;
            }
            else
            {
                destinationArray[0x10] = 0;
            }
            Array.Copy(regFileInfo_0.FileContent.Verify, 0, destinationArray, 0x18, regFileInfo_0.FileContent.Verify.Length);
            Array.Copy(array_0, 0, destinationArray, 40, array_0.Length);
            byte num = 0;

            for (int i = 0; i < 0x3f; i++)
            {
                num = (byte)(num + destinationArray[i]);
            }
            destinationArray[0x3f] = num;
            TextRegHead head = new TextRegHead {
                Tax_Mw_No = new byte[15]
            };
            string compressCode = taxCard_1.CompressCode;

            if ((regFileInfo_0.FileContent.SoftwareType > 0xff) && compressCode.StartsWith("91"))
            {
                compressCode = "50" + compressCode.Substring(2, compressCode.Length - 2);
            }
            for (int j = 0; j < compressCode.Length; j++)
            {
                if (j >= 15)
                {
                    break;
                }
                head.Tax_Mw_No[j] = (byte)compressCode[j];
            }
            head.Date = new byte[4];
            taxCard_1.GetCardClock(out time, 0);
            byte[] buffer6 = BitConverter.GetBytes(Convert.ToInt32(time.ToString("yyyyMMdd"), 0x10));
            Array.Reverse(buffer6);
            Array.Copy(buffer6, head.Date, 4);
            head.MachinNo = regFileInfo_0.FileContent.BranchNo;
            head.buf      = new byte[0x18];
            Array.Copy(destinationArray, head.buf, 0x18);
            byte[] buffer7 = new byte[0x10];
            byte[] buffer8 = new byte[0x10];
            Xihaa.GenTextRegKey(buffer7, buffer8, ref head);
            Array.Copy(buffer7, 0, destinationArray, 0x18, 0x10);
            byte[] buffer9 = new byte[0x10];
            for (int k = 0; k < 0x10; k++)
            {
                buffer9[k] = (byte)(array_0[k] ^ regFileInfo_0.FileContent.Transfer[k]);
            }
            byte[] buffer10 = new byte[0x10];
            for (int m = 0; m < 0x10; m++)
            {
                buffer10[m] = (byte)(buffer9[m] ^ buffer8[m]);
            }
            Array.Copy(buffer10, 0, destinationArray, 40, 0x10);
            num = 0;
            for (int n = 0; n < 0x3f; n++)
            {
                num = (byte)(num + destinationArray[n]);
            }
            destinationArray[0x3f] = num;
            byte[] buffer11 = null;
            ilog_0.Debug("[注册] 调用校验接口开始");
            string str2 = taxCard_1.CheckRegCode(destinationArray, out buffer11, 0);

            ilog_0.DebugFormat("[注册] 调用校验接口结束,返回值={0}", str2);
            if (ToolUtil.GetReturnErrCode(str2) == 0)
            {
                for (int num9 = 0; num9 < 0x10; num9++)
                {
                    if ((array_0[num9] ^ regFileInfo_0.FileContent.Transfer[num9]) != buffer11[num9])
                    {
                        ilog_0.Debug("验证注册文件失败,第" + num9.ToString() + "位校验失败");
                    }
                }
                ilog_0.Debug("注册文件验证成功");
                return(buffer11);
            }
            ilog_0.Error("注册文件校验失败:接口错误号=" + taxCard_1.ErrCode);
            errCode = taxCard_1.ErrCode;
            return(null);
        }