Example #1
0
        private List <string> GetBillList(string strBillPath)
        {
            List <string> list = new List <string>();

            string[] strArray = File.ReadAllLines(strBillPath, ToolUtil.GetEncoding());
            for (int i = 0; i < strArray.Length; i++)
            {
                if (!(!(strArray[i].Trim() != "") || strArray[i].Trim().StartsWith(this.strRemark)))
                {
                    list.Add(strArray[i]);
                }
            }
            if (list.Count <= 0)
            {
                throw new Exception("不是作废销售单据");
            }
            string str = list[0];

            if (!str.Substring(0, str.IndexOf(this.strSplitter)).Equals(this.strBeginFlag))
            {
                throw new Exception("不是作废销售单据");
            }
            list.RemoveAt(0);
            return(list);
        }
Example #2
0
 public void EncryptXML(List <Fpxx> fpList, string Path)
 {
     try
     {
         if ((fpList != null) && (fpList.Count != 0))
         {
             XmlDocument document = this.FpzjDaoChuCreateXml(fpList);
             if (document == null)
             {
                 this.loger.Error("[EncryptXML异常]构造的XMLDocument对象为空");
             }
             else
             {
                 Encryptor encryptor = (Encryptor)Activator.CreateInstance(System.Type.GetTypeFromCLSID(new Guid("C0A6B38B-16A7-4374-BB51-0084087910CD")));
                 string    outerXml  = document.OuterXml;
                 outerXml = encryptor.CryptEncrypt(ref outerXml);
                 using (StreamWriter writer = new StreamWriter(Path, false, ToolUtil.GetEncoding()))
                 {
                     writer.Write(outerXml);
                 }
                 fpList = null;
             }
         }
     }
     catch (Exception exception)
     {
         this.loger.Error(exception.Message);
     }
 }
Example #3
0
        internal static string GetSafeStringWithoutTrim(string text, int length)
        {
            text = text;
            int      byteCount = ToolUtil.GetByteCount(text);
            Encoding encoding  = ToolUtil.GetEncoding();

            byte[] bytes = encoding.GetBytes(text);
            if (bytes.GetLength(0) <= length)
            {
                return(text);
            }
            byte num3  = bytes[length - 1];
            int  index = length - 1;

            while ((bytes[index] >= 0xa1) && (bytes[index] <= 0xfe))
            {
                index--;
                if (index < 0)
                {
                    break;
                }
            }
            if (((length - index) % 2) == 0)
            {
                length--;
            }
            return(encoding.GetString(bytes, 0, length));
        }
Example #4
0
        public string ExportData(string pathFile, string separator, DataTable khTable = null)
        {
            DataTable exportData;
            string    path = pathFile.Remove(pathFile.LastIndexOf(@"\"));

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            if (khTable == null)
            {
                exportData = this.bmkhDAL.GetExportData();
            }
            else
            {
                exportData = khTable;
            }
            if (exportData.Rows.Count == 0)
            {
                return("没有客户");
            }
            StringBuilder builder = new StringBuilder();

            using (StreamWriter writer = new StreamWriter(pathFile, false, ToolUtil.GetEncoding()))
            {
                writer.WriteLine("{客户编码}[分隔符]\"" + separator + "\"");
                writer.WriteLine("// 每行格式 :");
                string str2 = "// 编码,名称,简码,税号,地址电话,银行账号,邮件地址,备注,身份证校验";
                writer.WriteLine(str2.Replace(",", separator));
                for (int i = 0; i < exportData.Rows.Count; i++)
                {
                    builder.Remove(0, builder.Length);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["BM"].ToString(), separator));
                    builder.Append(separator);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["MC"].ToString(), separator));
                    builder.Append(separator);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["JM"].ToString(), separator));
                    if (exportData.Rows[i]["WJ"].ToString() == "1")
                    {
                        builder.Append(separator);
                        builder.Append(exportData.Rows[i]["SH"]);
                        builder.Append(separator);
                        string item = exportData.Rows[i]["DZDH"].ToString().Replace("\r\n", "#|#");
                        builder.Append(GetSafeData.ExportItem(item, separator));
                        builder.Append(separator);
                        string str4 = exportData.Rows[i]["YHZH"].ToString().Replace("\r\n", "#|#");
                        builder.Append(GetSafeData.ExportItem(str4, separator));
                        builder.Append(separator);
                        builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["YJDZ"].ToString(), separator));
                        builder.Append(separator);
                        builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["BZ"].ToString(), separator));
                        builder.Append(separator);
                        builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["SFZJY"].ToString(), separator));
                    }
                    builder.Replace(",,", ",\"\",");
                    writer.WriteLine(builder.ToString());
                }
            }
            return("0");
        }
Example #5
0
        private static string GetAQJRDZ()
        {
            string path = Path.Combine(PropertyUtil.GetValue("MAIN_PATH"), "Bin", "AQJRDZ.txt");

            if (!File.Exists(path))
            {
                return(GetAQJRAddrFromConfigFile());
            }
            try
            {
                FileStream   stream = new FileStream(path, FileMode.Open, FileAccess.Read);
                StreamReader reader = new StreamReader(stream, ToolUtil.GetEncoding());
                reader.BaseStream.Seek(0L, SeekOrigin.Begin);
                string str2 = reader.ReadLine();
                reader.Close();
                stream.Close();
                string aQJRAddrFromConfigFile = "";
                if (((str2 == null) || (str2 == "")) || ((str2.IndexOf("127.0.0.1") > -1) || (str2.ToLower().IndexOf("localhost") > -1)))
                {
                    aQJRAddrFromConfigFile = GetAQJRAddrFromConfigFile();
                    if ((aQJRAddrFromConfigFile != null) && (aQJRAddrFromConfigFile != ""))
                    {
                        str2 = aQJRAddrFromConfigFile;
                    }
                }
                return(str2);
            }
            catch (Exception)
            {
                return("");
            }
        }
Example #6
0
 private bool GetBillList(string strBillPath, ref List <string> strBillList, ref string _strCause)
 {
     try
     {
         string[] strArray = File.ReadAllLines(strBillPath, ToolUtil.GetEncoding());
         for (int i = 0; i < strArray.Length; i++)
         {
             if (!(!(strArray[i].Trim() != "") || strArray[i].Trim().StartsWith(this.strRemark)))
             {
                 strBillList.Add(strArray[i].Trim().Trim(new char[1]));
             }
         }
         if (strBillList.Count > 0)
         {
             string str = strBillList[0];
             if (!str.Substring(0, str.IndexOf(this.strSplitter)).Equals(this.strBeginFlag))
             {
                 _strCause = "不是作废单据文本文件";
                 return(false);
             }
             strBillList.RemoveAt(0);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         throw new Exception("不是作废单据文本文件");
     }
     return(true);
 }
Example #7
0
        public string SaveTxt(string pathFile, ImportResult IResult)
        {
            string path = pathFile.Remove(pathFile.LastIndexOf(@"\"));

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            DataTable dtResult = IResult.DtResult;
            string    str2     = ",";

            if (dtResult.Rows.Count <= 0)
            {
                return("没有客户");
            }
            StringBuilder builder = new StringBuilder();

            using (StreamWriter writer = new StreamWriter(pathFile, false, ToolUtil.GetEncoding()))
            {
                writer.WriteLine(" 报告种类:编码导入");
                writer.WriteLine(" 来源于:文本文件");
                writer.WriteLine("");
                writer.WriteLine("传入结果(按记录条数统计):");
                writer.WriteLine("正确传入:" + IResult.Correct.ToString());
                writer.WriteLine("无效记录:" + IResult.Invalid.ToString());
                writer.WriteLine("重复记录:" + IResult.Duplicated.ToString());
                writer.WriteLine("传入失败:" + IResult.Failed.ToString());
                writer.WriteLine("总计:" + IResult.Total.ToString());
                writer.WriteLine("");
                writer.WriteLine("详细资料:");
                writer.WriteLine(" 表名,字段1名称,编码,字段2名称,名称,传入结果,原因:");
                writer.WriteLine("");
                for (int i = 0; i < dtResult.Rows.Count; i++)
                {
                    builder.Remove(0, builder.Length);
                    builder.Append(" ");
                    builder.Append(IResult.ImportTable);
                    builder.Append(str2);
                    builder.Append("编码");
                    builder.Append(str2);
                    builder.Append("\"");
                    builder.Append(dtResult.Rows[i]["Code"]);
                    builder.Append("\"");
                    builder.Append(str2);
                    builder.Append("名称");
                    builder.Append(str2);
                    builder.Append("\"");
                    builder.Append(dtResult.Rows[i]["Name"]);
                    builder.Append("\"");
                    builder.Append(str2);
                    builder.Append(dtResult.Rows[i]["Result"]);
                    builder.Append(str2);
                    builder.Append(dtResult.Rows[i]["Reason"]);
                    builder.Append(str2);
                    writer.WriteLine(builder.ToString());
                }
            }
            return("0");
        }
Example #8
0
        public string ExportData(string pathFile, string separator, DataTable khTable = null)
        {
            string path = pathFile.Remove(pathFile.LastIndexOf(@"\"));

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            DataTable exportData = this.bmfyxmDAL.GetExportData();

            if (exportData.Rows.Count == 0)
            {
                return("没有费用项目");
            }
            StringBuilder builder = new StringBuilder();

            using (StreamWriter writer = new StreamWriter(pathFile, false, ToolUtil.GetEncoding()))
            {
                writer.WriteLine("{费用项目编码}[分隔符]\"" + separator + "\"");
                writer.WriteLine("// 每行格式 :");
                string str2 = "";
                if (Flbm.IsYM())
                {
                    str2 = "// 编码~~名称~~简码~~商品分类~~是否享受优惠政策~~税收分类名称~~优惠政策类型~~编码版本号";
                }
                else
                {
                    str2 = "// 编码~~名称~~简码";
                }
                writer.WriteLine(str2.Replace(",", separator));
                string maxBMBBBH = new SPFLService().GetMaxBMBBBH();
                for (int i = 0; i < exportData.Rows.Count; i++)
                {
                    builder.Remove(0, builder.Length);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["BM"].ToString(), separator));
                    builder.Append(separator);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["MC"].ToString(), separator));
                    builder.Append(separator);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["JM"].ToString(), separator));
                    if (Flbm.IsYM())
                    {
                        builder.Append(separator);
                        builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["SPFL"].ToString(), separator));
                        builder.Append(separator);
                        builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["YHZC"].ToString(), separator));
                        builder.Append(separator);
                        builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["SPFLMC"].ToString(), separator));
                        builder.Append(separator);
                        builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["YHZCMC"].ToString(), separator));
                        builder.Append(separator);
                        builder.Append(GetSafeData.ExportItem(maxBMBBBH, separator));
                    }
                    builder.Replace(",,", ",\"\",");
                    writer.WriteLine(builder.ToString());
                }
            }
            return("0");
        }
Example #9
0
 public WebClient()
 {
     this.encoding_0            = ToolUtil.GetEncoding();
     this.string_0              = "";
     this.int_0                 = 0x3b88;
     this.ilog_0                = LogUtil.GetLogger <Aisino.Framework.Plugin.Core.Http.WebClient>();
     this.webHeaderCollection_0 = new WebHeaderCollection();
     this.webHeaderCollection_1 = new WebHeaderCollection();
 }
Example #10
0
        public string ExportGoodsTax(string pathFile, string separator)
        {
            string path = pathFile.Remove(pathFile.LastIndexOf(@"\"));

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            DataTable exportData = this.bmkhDAL.GetExportData();

            if (exportData.Rows.Count == 0)
            {
                return("没有商品税目");
            }
            StringBuilder builder = new StringBuilder();

            using (StreamWriter writer = new StreamWriter(pathFile, false, ToolUtil.GetEncoding()))
            {
                writer.WriteLine("{商品税目编码}[分隔符]\"" + separator + "\"");
                writer.WriteLine("// 每行格式 :");
                string str2 = "// 税种,编码,名称,税率,征收率,数量计税,计税单位,税额,非核定标志";
                writer.WriteLine(str2.Replace(",", separator));
                for (int i = 0; i < exportData.Rows.Count; i++)
                {
                    builder.Remove(0, builder.Length);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["SZ"].ToString(), separator));
                    builder.Append(separator);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["BM"].ToString(), separator));
                    builder.Append(separator);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["MC"].ToString(), separator));
                    builder.Append(separator);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["SLV"].ToString(), separator));
                    builder.Append(separator);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["ZSL"].ToString(), separator));
                    builder.Append(separator);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["SLJS"].ToString(), separator));
                    builder.Append(separator);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["JSDW"].ToString(), separator));
                    builder.Append(separator);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["SE"].ToString(), separator));
                    builder.Append(separator);
                    builder.Append(GetSafeData.ExportItem(exportData.Rows[i]["FHDBZ"].ToString(), separator));
                    builder.Append(separator);
                    builder.Replace(",,", ",\"\",");
                    writer.WriteLine(builder.ToString());
                }
            }
            return("0");
        }
Example #11
0
        public static void Create()
        {
            string path = GetXmlcfg.IniConfig.Remove(GetXmlcfg.IniConfig.LastIndexOf(@"\"));

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string[] contents = new string[] {
                "[File]", "File1Path=", "File2Path=", "TableInFile1=Sheet1", "TableInFile2=Sheet1", "[FieldCon]", "FileNumber=1", "DanJuHaoMa=1.1", "GouFangMingCheng=1.2", "GouFangShuiHao=1.3", "GouFangDiZhiDianHua=0.0", "GouFangYinHangZhangHao=0.0", "BeiZhu=0.0", "FuHeRen=0.0", "ShouKuanRen=0.0", "QingDanHangShangPinMingCheng=0.0",
                "DanJuRiQi=0.0", "XiaoFangYinHangZhangHao=0.0", "XiaoFangDiZhiDianHua=0.0", "HuoWuMingCheng=1.4", "JiLiangDanWei=0.0", "GuiGe=0.0", "ShuLiang=1.8", "BuHanShuiJinE=1.5", "ShuiLv=1.6", "ShangPinShuiMu=0.0", "ZheKouJinE=1.7", "ShuiE=0.0", "ZheKouShuiE=0.0", "ZheKouLv=0.0", "DanJia=0.0", "DefaultFuHeRen=",
                "DefaultShouKuanRen=", "DefaultShuiLv=11", "[TableCon]", "MainTableField=1", "AssistantTableField=1", "MainTableIgnoreRow=1", "AssistantTableIgnoreRow=1"
            };
            File.WriteAllLines(GetXmlcfg.IniConfig, contents, ToolUtil.GetEncoding());
        }
Example #12
0
 public static bool SendMail(string string_3, string string_4, string[] string_5, string string_6, string string_7, string string_8, string string_9, string string_10, int int_1, string[] string_11, out string string_12)
 {
     try
     {
         MailMessage message = new MailMessage {
             From = new MailAddress(string_3, string_4)
         };
         foreach (string str2 in string_5)
         {
             message.To.Add(str2);
         }
         message.SubjectEncoding = Encoding.GetEncoding("UTF-8");
         message.Subject         = string_2 + string_6;
         message.BodyEncoding    = ToolUtil.GetEncoding();
         message.Priority        = MailPriority.High;
         message.Body            = Convert.ToBase64String(AES_Crypt.Encrypt(ToolUtil.GetBytes(string_7), byte_0, byte_1));
         message.IsBodyHtml      = false;
         if ((string_11 != null) && (string_11.Length > 0))
         {
             foreach (string str in string_11)
             {
                 message.Attachments.Add(new Attachment(str));
             }
         }
         SmtpClient client = new SmtpClient(string_10, int_1)
         {
             UseDefaultCredentials = true,
             DeliveryMethod        = SmtpDeliveryMethod.Network
         };
         if (string_8 != null)
         {
             client.Credentials = new NetworkCredential(string_8, string_9);
         }
         client.Timeout = 0x2710;
         client.Send(message);
         client.Dispose();
         string_12 = "OK";
         return(true);
     }
     catch (Exception exception)
     {
         string_12 = exception.Message;
         return(false);
     }
 }
Example #13
0
        private void CreateXlsTemplate()
        {
            string path = this.FilePath.Remove(this.FilePath.LastIndexOf(@"\"));

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string[] contents = new string[] {
                "<?xml version=\"1.0\" encoding=\"GBK\"?>", "<?mso-application progid=\"Excel.Sheet\"?>", "<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"", "xmlns:o=\"urn:schemas-microsoft-com:office:office\"", "xmlns:x=\"urn:schemas-microsoft-com:office:excel\"", "xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"", "xmlns:html=\" http://www.w3.org/TR/REC-html40  \">", "<DocumentProperties xmlns=\"urn:schemas-microsoft-com:office:office\">", " <Author>开票系统</Author>", "<LastAuthor>开票系统</LastAuthor>", "<Created>2011-09-20T02:55:54Z</Created>", " <LastSaved>2011-09-20T06:07:13Z</LastSaved>", "<Company>Microsoft</Company>", " <Version>11.9999</Version>", " </DocumentProperties>", " <ExcelWorkbook xmlns=\"urn:schemas-microsoft-com:office:excel\">",
                " <WindowHeight>11370</WindowHeight>", " <WindowWidth>17115</WindowWidth>", " <WindowTopX>0</WindowTopX>", " <WindowTopY>60</WindowTopY>", " <ProtectStructure>False</ProtectStructure>", " <ProtectWindows>False</ProtectWindows>", "</ExcelWorkbook>", "<Styles>", " <Style ss:ID=\"Default\" ss:Name=\"Normal\">", " <Alignment ss:Vertical=\"Center\"/>", " <Borders/>", " <Font ss:FontName=\"宋体\" x:CharSet=\"134\" ss:Size=\"12\"/>", " <Interior/>", " <NumberFormat/>", " <Protection/>", "</Style>",
                "<Style ss:ID=\"s21\">", "<Font ss:FontName=\"宋体\" x:CharSet=\"134\" ss:Bold=\"1\"/>", "</Style>", "<Style ss:ID=\"s22\">", " <Font ss:FontName=\"Georgia\" x:Family=\"Roman\" ss:Size=\"14\" ss:Bold=\"1\"/>", "</Style>", "<Style ss:ID=\"s23\">", "<Alignment ss:Horizontal=\"Right\" ss:Vertical=\"Center\"/>", "</Style>", " </Styles>", "<Worksheet ss:Name=\"Sheet1\">", "<Table ss:ExpandedColumnCount=\"0\" ss:ExpandedRowCount=\"0\" x:FullColumns=\"1\"  ", " x:FullRows=\"1\" ss:DefaultColumnWidth=\"54\" ss:DefaultRowHeight=\"14.25\"/>", "<WorksheetOptions xmlns=\"urn:schemas-microsoft-com:office:excel\">", " <Unsynced/>", " <Print>",
                " <ValidPrinterInfo/>", " <PaperSizeIndex>9</PaperSizeIndex>", " <HorizontalResolution>600</HorizontalResolution>", "<VerticalResolution>600</VerticalResolution>", "</Print>", "<Selected/>", " <Panes>", " <Pane>", " <Number>3</Number>", " <ActiveRow>0</ActiveRow>", " <ActiveCol>0</ActiveCol>", "</Pane>", " </Panes>", " <ProtectObjects>False</ProtectObjects>", " <ProtectScenarios>False</ProtectScenarios>", "</WorksheetOptions>",
                "</Worksheet>", "<Worksheet ss:Name=\"Sheet2\">", "<Table ss:ExpandedColumnCount=\"0\" ss:ExpandedRowCount=\"0\" x:FullColumns=\"1\"  ", " x:FullRows=\"1\" ss:DefaultColumnWidth=\"54\" ss:DefaultRowHeight=\"14.25\"/>", "<WorksheetOptions xmlns=\"urn:schemas-microsoft-com:office:excel\">", " <Unsynced/>", " <ProtectObjects>False</ProtectObjects>", " <ProtectScenarios>False</ProtectScenarios>", "</WorksheetOptions>", "</Worksheet>", "<Worksheet ss:Name=\"Sheet3\">", "<Table ss:ExpandedColumnCount=\"0\" ss:ExpandedRowCount=\"0\" x:FullColumns=\"1\"  ", " x:FullRows=\"1\" ss:DefaultColumnWidth=\"54\" ss:DefaultRowHeight=\"14.25\"/>", " <WorksheetOptions xmlns=\"urn:schemas-microsoft-com:office:excel\">", " <Unsynced/>", " <ProtectObjects>False</ProtectObjects>",
                " <ProtectScenarios>False</ProtectScenarios>", "</WorksheetOptions>", "</Worksheet>", "</Workbook>"
            };
            File.WriteAllLines(this.FilePath, contents, ToolUtil.GetEncoding());
        }
Example #14
0
        public static void Create()
        {
            string path = ConfigFile.GetIniConfigPath.Remove(ConfigFile.GetIniConfigPath.LastIndexOf(@"\"));

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string[] contents = new string[] {
                "[File]", "File1Path=", "File2Path=", "TableInFile1=Sheet1", "TableInFile2=Sheet1", "[FieldCon]", "FileNumber=1", "IsSeted=0", "Invtype=Common", "DanJuHaoMa=1.1", "GouFangMingCheng=0.0", "GouFangShuiHao=0.0", "GouFangDiZhiDianHua=0.0", "GouFangYinHangZhangHao=0.0", "BeiZhu=0.0", "FuHeRen=0.0",
                "ShouKuanRen=0.0", "QingDanHangShangPinMingCheng=0.0", "DanJuRiQi=0.0", "XiaoFangYinHangZhangHao=0.0", "XiaoFangDiZhiDianHua=0.0", "HuoWuMingCheng=0.0", "JiLiangDanWei=0.0", "GuiGe=0.0", "ShuLiang=0.0", "BuHanShuiJinE=0.0", "ShuiLv=0.0", "ShangPinShuiMu=0.0", "ZheKouJinE=0.0", "ShuiE=0.0", "ZheKouShuiE=0.0", "ZheKouLv=0.0",
                "DanJia=0.0", "DefaultFuHeRen=", "DefaultShouKuanRen=", "DefaultShuiLv=11", "ShenFenZhengJiaoYan=0.0", "HaiYangShiYou=0.0", "JiaGeFangShi=0.0", "ShouPiaoFangMC=0.0", "ShouPiaoFangSH=0.0", "ShouHuoRenMC=0.0", "ShouHuoRenSH=0.0", "FaHuoRenMC=0.0", "FaHuoRenSH=0.0", "ShuiLv-HY=0.0", "QiYouDaoDa=0.0", "CheChongCheHao=0.0",
                "CheChuanDunWei=0.0", "YunShuHuoWuXX=0.0", "BeiZhu-HY=0.0", "FuHeRen-HY=0.0", "ShouKuanRen-HY=0.0", "DanJuRiQi-HY=0.0", "HuoWuMingCheng-HY=0.0", "JinE-HY=0.0", "GouHuoDanWei=0.0", "ShenFenZhengHaoMa=0.0", "JinE-JDC=0.0", "ShuiLv-JDC=0.0", "CheLiangLeiXing=0.0", "ChangPaiXingHao=0.0", "ChanDi=0.0", "ShengChanChangJiaMC=0.0",
                "HeGeZhengHao=0.0", "JinKouZhengMingShuHao=0.0", "ShangJianDanHao=0.0", "FaDongJiHaoMa=0.0", "CheLiangShiBieDM=0.0", "DianHua=0.0", "ZhangHao=0.0", "DiZhi=0.0", "KaiHuYinHang=0.0", "DunWei=0.0", "XianChengRenShu=0.0", "DanJuRiQi-JDC=0.0", "BeiZhu-JDC=0.0", "NaShuiRenShiBieHao=0.0", "XiaoFangMingCheng=0.0", "XiaoFangShuiHao=0.0",
                "NongChanPinBiaoZhi=0.0", "[TableCon]", "MainTableField=1", "AssistantTableField=1", "MainTableIgnoreRow=1", "AssistantTableIgnoreRow=1"
            };
            File.WriteAllLines(ConfigFile.GetIniConfigPath, contents, ToolUtil.GetEncoding());
        }
Example #15
0
        private static bool SetAQJRDZ(string addrStr)
        {
            string path = Path.Combine(PropertyUtil.GetValue("MAIN_PATH"), "Bin", "AQJRDZ.txt");

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            try
            {
                FileStream   stream = new FileStream(path, FileMode.Create, FileAccess.Write);
                StreamWriter writer = new StreamWriter(stream, ToolUtil.GetEncoding());
                writer.BaseStream.Seek(0L, SeekOrigin.Begin);
                writer.WriteLine(addrStr);
                writer.Close();
                stream.Close();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #16
0
        private string GetAQJRDZ()
        {
            string path = Path.Combine(PropertyUtil.GetValue("MAIN_PATH"), "Bin", "AQJRDZ.txt");

            if (!File.Exists(path))
            {
                return("");
            }
            try
            {
                FileStream   stream = new FileStream(path, FileMode.Open, FileAccess.Read);
                StreamReader reader = new StreamReader(stream, ToolUtil.GetEncoding());
                reader.BaseStream.Seek(0L, SeekOrigin.Begin);
                string str2 = reader.ReadLine();
                reader.Close();
                stream.Close();
                return(str2);
            }
            catch (Exception)
            {
                return("");
            }
        }
Example #17
0
 public static string UTF8ToGB2312(string str)
 {
     try
     {
         Encoding srcEncoding = Encoding.GetEncoding(0xfde9);
         Encoding encoding    = ToolUtil.GetEncoding();
         byte[]   bytes       = srcEncoding.GetBytes(str);
         byte[]   buffer2     = Encoding.Convert(srcEncoding, encoding, bytes);
         return(encoding.GetString(buffer2));
     }
     catch (BaseException exception)
     {
         _Loger.Error(exception.Message);
         ExceptionHandler.HandleError(exception);
         return(string.Empty);
     }
     catch (Exception exception2)
     {
         _Loger.Error(exception2.Message);
         ExceptionHandler.HandleError(exception2);
         return(string.Empty);
     }
 }
        private void SetUrl(string url)
        {
            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            if (response.StatusCode == HttpStatusCode.OK)
            {
                Stream   responseStream = response.GetResponseStream();
                Encoding encoding       = Encoding.UTF8;
                if (response.CharacterSet.ToLower() == "gb2312")
                {
                    encoding = ToolUtil.GetEncoding();
                }
                Match match = Regex.Match(new StreamReader(responseStream, encoding).ReadToEnd(), @"<title>[\w|\W]+?</title>");
                this.Name  = match.Value.Substring(7, match.Value.Length - 15);
                this.Image = Resources.net;
            }
            else
            {
                this.Name  = request.Headers[HttpRequestHeader.Host];
                this.Image = null;
            }
        }
Example #19
0
        public void SaveSelectToTxt(DataGridViewSelectedRowCollection selectRows, string Path, DateTime StartDt, DateTime EndDt, bool IsWenjian)
        {
            try
            {
                if ((selectRows == null) || (selectRows.Count == 0))
                {
                    MessageManager.ShowMsgBox("FPCX-000039");
                    return;
                }
                List <Fpxx> fpList = new List <Fpxx>();
                if (IsWenjian)
                {
                    using (StreamWriter writer = new StreamWriter(Path + ".txt", false, ToolUtil.GetEncoding()))
                    {
                        writer.WriteLine("//发票主体明细信息");
                        writer.WriteLine("//" + StartDt.ToString("yyyyMMdd") + "~~" + EndDt.ToString("yyyyMMdd"));
                        int num = 0;
                        foreach (DataGridViewRow row in selectRows)
                        {
                            num++;
                            if (row.Cells["FPDM"].Value != null)
                            {
                                string fPZL = row.Cells["FPZL"].Value.ToString();
                                string fPDM = row.Cells["FPDM"].Value.ToString();
                                string data = row.Cells["FPHM"].Value.ToString();
                                Fpxx   item = this.xxfpChaXunBll.GetModel(fPZL, fPDM, Aisino.Fwkp.Fpkj.Common.Tool.ObjectToInt(data), "");
                                if (item != null)
                                {
                                    writer.WriteLine("//发票" + num.ToString());
                                    string str4 = item.fpdm + "~~" + ShareMethods.FPHMTo8Wei(item.fphm) + "~~" + item.kpjh.ToString() + "~~" + item.gfmc + "~~" + item.gfsh + "~~" + item.xfsh + "~~" + Aisino.Fwkp.Fpkj.Common.Tool.ObjectToDateTime(item.kprq).ToString("yyyy-MM-dd") + "~~" + item.je + "~~" + item.se + "~~" + ToolUtil.GetString(Convert.FromBase64String(item.bz)) + "~~" + (item.zfbz ? "1" : "0");
                                    writer.WriteLine(str4);
                                    fpList.Add(item);
                                }
                                else
                                {
                                    this.loger.Error("[SaveToTxt函数]:代码:" + fPDM + ", 发票号码:" + data + "在数据库库没有查到");
                                }
                            }
                        }
                        goto Label_03EC;
                    }
                }
                foreach (DataGridViewRow row2 in selectRows)
                {
                    string str5  = row2.Cells["FPZL"].Value.ToString();
                    string str6  = row2.Cells["FPDM"].Value.ToString();
                    string str7  = row2.Cells["FPHM"].Value.ToString();
                    Fpxx   fpxx2 = this.xxfpChaXunBll.GetModel(str5, str6, Aisino.Fwkp.Fpkj.Common.Tool.ObjectToInt(str7), "");
                    if (fpxx2 != null)
                    {
                        fpList.Add(fpxx2);
                    }
                    else
                    {
                        this.loger.Error("[SaveToTxt函数]:代码:" + str6 + ", 发票号码:" + str7 + "在数据库库没有查到");
                    }
                }
Label_03EC:
                if (fpList.Count > 0)
                {
                    this.EncryptXML(fpList, Path + ".Dat");
                }
                fpList = null;
            }
            catch (Exception exception)
            {
                this.loger.Error(exception.Message);
            }
        }
Example #20
0
        public strBiao JieXiShuXing()
        {
            strBiao biao = new strBiao();

            string[]      strArray = File.ReadAllLines(this.path, ToolUtil.GetEncoding());
            List <string> list     = new List <string>();

            for (int i = 0; i < strArray.Length; i++)
            {
                if (!((strArray[i].Trim().Trim(new char[1]).Length == 0) || strArray[i].Trim().StartsWith("//")))
                {
                    list.Add(strArray[i]);
                }
            }
            int num2 = 0;

            if (list.Count < 2)
            {
                throw new CustomException("001");
            }
            string row = list[num2];

            if (row.Contains("~~"))
            {
                if (!row.Substring(0, row.IndexOf(this.SplitStr)).Equals(this.BeginStr))
                {
                    throw new CustomException("001");
                }
            }
            else if (row.Contains(" ") | row.Contains(","))
            {
                this.SplitStr = " ";
            }
            if (this.SplitStr.Equals("~~"))
            {
                biao.str = this.StringSplit(row);
            }
            else
            {
                num2 = -1;
            }
            while (true)
            {
                bool flag = true;
                num2++;
                if (num2 >= list.Count)
                {
                    return(biao);
                }
                row = list[num2];
                strDanju item = new strDanju {
                    str = this.StringSplit(row)
                };
                int result = 0;
                if (item.str.Count > 1)
                {
                    if (!int.TryParse(item.str[1], out result))
                    {
                        base.errorResolver.AddError("单据商品行数有错误", item.str[0], 1, false);
                    }
                    else
                    {
                        base.errorResolver.ImportTotal++;
                        while (0 < result--)
                        {
                            num2++;
                            int lineNum = int.Parse(item.str[1]) - result;
                            if (num2 < list.Count)
                            {
                                strMingxi mingxi = new strMingxi {
                                    str = this.StringSplit(list[num2])
                                };
                                item.mingxi.Add(mingxi);
                            }
                            else
                            {
                                base.errorResolver.AddError("缺少商品行", item.str[0], lineNum, false);
                                flag = false;
                            }
                        }
                        if (flag)
                        {
                            biao.danju.Add(item);
                        }
                        else
                        {
                            base.errorResolver.AbandonCount++;
                        }
                    }
                }
                else
                {
                    base.errorResolver.AddError("单据仅有单据号", item.str[0], 1, false);
                }
            }
        }
Example #21
0
        public ImportResult ImportData(string codeFile)
        {
            ImportResult result2;

            try
            {
                string[] strArray = File.ReadAllLines(codeFile, ToolUtil.GetEncoding());
                if (strArray.Length == 0)
                {
                    throw new CustomException("此文件没有内容");
                }
                string str   = "";
                int    index = 0;
                bool   flag  = true;
                while (flag)
                {
                    if (strArray[index].StartsWith("{费用项目编码}"))
                    {
                        string str2 = strArray[index];
                        if (!str2.Contains("\""))
                        {
                            throw new CustomException("此文件首行费用项目编码没有指定分隔符,分隔符使用双引号标注");
                        }
                        str  = str2.Substring(str2.IndexOf("\"")).Trim().Trim(new char[] { '"' });
                        flag = false;
                        index++;
                    }
                    else
                    {
                        index++;
                        if (index == strArray.Length)
                        {
                            throw new CustomException("此文件不符合费用项目编码文本格式");
                        }
                    }
                }
                ImportResult     result = new ImportResult();
                Stack <lastBMJG> stack  = new Stack <lastBMJG>();
                string           str4   = this.TuiJianBM("");
                string           str5   = "";
                bool             flag2  = false;
                for (int i = index; i < strArray.Length; i++)
                {
                    BMFYXMModel model;
                    string      lineText = strArray[i].Trim();
                    if (((lineText.Length == 0) || lineText.StartsWith("//")) || !lineText.Contains(str))
                    {
                        continue;
                    }
                    string[] strArray2 = GetSafeData.Split(lineText, str);
                    if (strArray2.Length < 3)
                    {
                        throw new CustomException("文本首行指定的分隔符与实际分隔符不一致,\n格式不正确等原因导致不能导入此文件!");
                    }
                    model = new BMFYXMModel {
                        BM = strArray2[0],
                        MC = strArray2[1],
                        JM = strArray2[2],
                    };
                    model.KJM = CommonFunc.GenerateKJM(model.MC);
                    string     str7 = "";
                    string     str8 = "";
                    ResultType none = ResultType.None;
                    while (true)
                    {
                        if (stack.Count <= 0)
                        {
                            break;
                        }
                        flag2 = false;
                        if (model.BM.Length > stack.Peek().BM.Length)
                        {
                            if (!model.BM.StartsWith(stack.Peek().BM))
                            {
                                goto Label_02B0;
                            }
                            model.SJBM = stack.Peek().BM;
                            model.WJ   = 1;
                            if (stack.Peek().Result == ResultType.Invalid)
                            {
                                str7 = "无效";
                                str8 = "上级编码无效";
                                none = ResultType.Invalid;
                                result.Invalid++;
                            }
                            else if (stack.Peek().Result == ResultType.Failed)
                            {
                                str7 = "失败";
                                str8 = "上级编码失败";
                                none = ResultType.Failed;
                                result.Failed++;
                            }
                            else
                            {
                                if (stack.Peek().Result != ResultType.Duplicated)
                                {
                                    goto Label_02B0;
                                }
                                str5 = this.TuiJianBM(stack.Peek().BM);
                                if (model.BM.Length == str5.Length)
                                {
                                    goto Label_02B0;
                                }
                                str7 = "无效";
                                str8 = "编码长度必须与原有同级编码长度一致";
                                result.Invalid++;
                                none = ResultType.Invalid;
                            }
                            goto Label_03B0;
                        }
                        stack.Pop();
                    }
                    flag2 = true;
Label_02B0:
                    if ((flag2 && (str4 != "001")) && (model.BM.Length != str4.Length))
                    {
                        str7 = "无效";
                        str8 = "编码长度必须与原有同级编码长度一致";
                        result.Invalid++;
                        none = ResultType.Invalid;
                    }
                    else if (this.bmfyxmDAL.ExistExpense(model))
                    {
                        if (str7.Length == 0)
                        {
                            str7 = "重复";
                            result.Duplicated++;
                        }
                        if (str8.Length == 0)
                        {
                            str8 = "编码重复";
                            none = ResultType.Duplicated;
                        }
                        else
                        {
                            str8 = str8 + "且编码重复";
                            none = ResultType.Invalid;
                        }
                    }
                    else
                    {
                        StringUtils.GetSpellCode(model.MC);
                        if (this.bmfyxmDAL.AddExpense(model) == "0")
                        {
                            str7 = "正确传入";
                            result.Correct++;
                            none = ResultType.Correct;
                        }
                        else
                        {
                            str7 = "失败";
                            result.Failed++;
                            none = ResultType.Failed;
                        }
                    }
                    Label_03B0 :;
                    result.DtResult.Rows.Add(new object[] { model.BM, model.MC, str7, str8 });
                    stack.Push(new lastBMJG(model.BM, none));
                }
                result.ImportTable = "费用项目编码.DB";
                result2            = result;
            }
            catch
            {
                throw;
            }
            return(result2);
        }
Example #22
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (this.nonSetCheck || (this.outputMX != this.chkFPDetail.Checked))
     {
         PropertyUtil.SetValue("Aisino.Fwkp.Bsgl.StubFPOutput.IsCheckedFPMX", this.chkFPDetail.Checked.ToString());
     }
     if (this.txtFilePath.Text.Trim() == "")
     {
         MessageManager.ShowMsgBox("INP-251206");
         this.txtFilePath.Select();
     }
     else
     {
         FPDetailDAL     ldal         = new FPDetailDAL();
         List <FPDetail> fPDetailList = ldal.GetFPDetailList(this.dtpStart.Value, this.dtpEnd.Value);
         if (this.chkFPDetail.Checked)
         {
             foreach (FPDetail detail in fPDetailList)
             {
                 if (detail != null)
                 {
                     detail.GoodsList.AddRange(ldal.GetGoodsList(detail.FPType.ToString(), detail.FPDM, detail.FPHM));
                 }
             }
         }
         base.TaxCardInstance.get_TaxCode();
         string str      = "JK_" + base.TaxCardInstance.get_TaxCode() + DateTime.Now.ToString("yyyyMMdd") + "_KP.XML";
         string filename = Path.Combine(this.txtFilePath.Text.Trim(), str);
         try
         {
             XmlTextWriter writer = new XmlTextWriter(filename, ToolUtil.GetEncoding())
             {
                 Formatting = Formatting.Indented
             };
             writer.WriteStartDocument();
             writer.WriteStartElement("FPSJJK");
             this.WriteBaseInfo(writer, fPDetailList.Count);
             writer.WriteStartElement("JK_FWSKKP_NSR_FPXX");
             if (fPDetailList.Count > 0)
             {
                 string text = "【发票头信息】\r\n发票种类(0:专用发票 1:废旧物资发票 2:普通发票)\r\n发票代码\r\n发票号码\r\n开票日期(格式:YYYYMMDD)\r\n购方纳税人识别号\r\n购方名称\r\n购方地址电话\r\n购方银行帐号\r\n合计金额\r\n合计税额\r\n税率\r\n作废标志(0:未作废 1:作废)\r\n开票人\r\n销方纳税人识别号\r\n销方名称\r\n销方地址电话\r\n销方银行帐号\r\n备注\r\n";
                 string str4 = "【发票明细信息】\r\n商品名称\r\n规格型号\r\n计量单位\r\n数量\r\n单价\r\n金额\r\n税额\r\n";
                 writer.WriteComment(text);
                 writer.WriteComment(str4);
             }
             foreach (FPDetail detail2 in fPDetailList)
             {
                 writer.WriteStartElement("JK_FWSKKP_FPXX");
                 WriteFPBTXX(writer, detail2);
                 WriteFPMX(writer, detail2);
                 writer.WriteEndElement();
             }
             writer.WriteEndElement();
             writer.WriteEndElement();
             writer.WriteEndDocument();
             writer.Flush();
             writer.Close();
             MessageManager.ShowMsgBox("INP-251411", "提示", new string[] { str });
         }
         catch (Exception exception)
         {
             MessageManager.ShowMsgBox("INP-251412");
             this.loger.Error(exception.Message, exception);
             return;
         }
         base.Close();
     }
 }
Example #23
0
        public ImportResult ImportData(string codeFile)
        {
            ImportResult result2;

            try
            {
                string[] strArray = File.ReadAllLines(codeFile, ToolUtil.GetEncoding());
                if (strArray.Length == 0)
                {
                    throw new CustomException("此文件没有内容");
                }
                string str   = "";
                int    index = 0;
                bool   flag  = true;
                while (flag)
                {
                    if (strArray[index].StartsWith("{销货单位编码}") || strArray[index].StartsWith("{发货人编码}"))
                    {
                        string str2 = strArray[index];
                        if (!str2.Contains("\""))
                        {
                            throw new CustomException("此文件首行销货单位编码没有指定分隔符,分隔符使用双引号标注");
                        }
                        str  = str2.Substring(str2.IndexOf("\"")).Trim().Trim(new char[] { '"' });
                        flag = false;
                        index++;
                    }
                    else
                    {
                        index++;
                        if (index == strArray.Length)
                        {
                            throw new CustomException("此文件不符合销货单位编码文本格式");
                        }
                    }
                }
                ImportResult     result = new ImportResult();
                Stack <lastBMJG> stack  = new Stack <lastBMJG>();
                string           str4   = this.TuiJianBM("");
                string           str5   = "";
                bool             flag2  = false;
                for (int i = index; i < strArray.Length; i++)
                {
                    BMXHDWModel model;
                    string      lineText = strArray[i].Trim();
                    if (((lineText.Length == 0) || lineText.StartsWith("//")) || !lineText.Contains(str))
                    {
                        continue;
                    }
                    string[] strArray2 = GetSafeData.Split(lineText, str);
                    if (strArray2.Length < 3)
                    {
                        throw new CustomException("文本首行指定的分隔符与实际分隔符不一致,\n格式不正确等原因导致不能导入此文件!");
                    }
                    model = new BMXHDWModel {
                        BM = strArray2[0],
                        MC = strArray2[1],
                        JM = strArray2[2],
                    };
                    model.KJM = CommonFunc.GenerateKJM(model.MC);
                    string     str7 = "";
                    string     str8 = "";
                    ResultType none = ResultType.None;
                    if (strArray2.Length > 3)
                    {
                        if (strArray2.Length < 7)
                        {
                            continue;
                        }
                        model.SH = strArray2[3].ToUpper();
                        model.WJ = 1;
                        string str9 = "";
                        if (str == "~~")
                        {
                            str9 = strArray2[4].Replace(",", "\r\n").Replace("#|#", "\r\n");
                        }
                        else if (str == " ")
                        {
                            str9 = strArray2[4].Replace("#|#", "\r\n");
                        }
                        else
                        {
                            str9 = strArray2[4];
                        }
                        model.DZDH = str9;
                        string str10 = "";
                        if (str == "~~")
                        {
                            str10 = strArray2[5].Replace(",", "\r\n").Replace("#|#", "\r\n");
                        }
                        else if (str == " ")
                        {
                            str10 = strArray2[5].Replace("#|#", "\r\n");
                        }
                        else
                        {
                            str10 = strArray2[5];
                        }
                        model.YHZH = str10;
                        string str11 = "";
                        if (str == "~~")
                        {
                            str11 = strArray2[6].Replace(",", "\r\n").Replace("#|#", "\r\n");
                        }
                        else if (str == " ")
                        {
                            str11 = strArray2[6].Replace("#|#", "\r\n");
                        }
                        else
                        {
                            str11 = strArray2[6];
                        }
                        model.YZBM = str11;
                    }
                    while (stack.Count > 0)
                    {
                        flag2 = false;
                        if (model.BM.Length > stack.Peek().BM.Length)
                        {
                            if (!model.BM.StartsWith(stack.Peek().BM))
                            {
                                goto Label_0430;
                            }
                            model.SJBM = stack.Peek().BM;
                            if (stack.Peek().Result == ResultType.Invalid)
                            {
                                str7 = "无效";
                                str8 = "上级编码无效";
                                none = ResultType.Invalid;
                                result.Invalid++;
                            }
                            else if (stack.Peek().Result == ResultType.Failed)
                            {
                                str7 = "失败";
                                str8 = "上级编码失败";
                                none = ResultType.Failed;
                                result.Failed++;
                            }
                            else
                            {
                                if (stack.Peek().Result != ResultType.Duplicated)
                                {
                                    goto Label_0430;
                                }
                                str5 = this.TuiJianBM(stack.Peek().BM);
                                if (model.BM.Length == str5.Length)
                                {
                                    goto Label_0430;
                                }
                                str7 = "无效";
                                str8 = "编码长度必须与原有同级编码长度一致";
                                result.Invalid++;
                                none = ResultType.Invalid;
                            }
                            goto Label_06AF;
                        }
                        stack.Pop();
                    }
                    flag2 = true;
Label_0430:
                    if ((flag2 && (str4 != "001")) && (model.BM.Length != str4.Length))
                    {
                        str7 = "无效";
                        str8 = "编码长度必须与原有同级编码长度一致";
                        result.Invalid++;
                        none = ResultType.Invalid;
                    }
                    else if ("0" != this.CheckCustomer(model))
                    {
                        str7 = "无效";
                        str8 = "编码或名称为空";
                        result.Invalid++;
                        none = ResultType.Invalid;
                    }
                    else if (!Regex.IsMatch(model.BM, "^[0-9a-z]{1,16}$"))
                    {
                        str7 = "无效";
                        str8 = "编码需小于16位,且仅由数字和小写字母组成";
                        result.Invalid++;
                        none = ResultType.Invalid;
                    }
                    if (this.bmsfhrDAL.ExistCusMC(model.BM, model.MC, model.SJBM))
                    {
                        str7 = "失败";
                        str8 = "同级同族已存在同名销货单位" + model.SH;
                        result.Failed++;
                        none = ResultType.Failed;
                    }
                    else if (this.bmsfhrDAL.ExistCustomer(model))
                    {
                        if (str7.Length == 0)
                        {
                            str7 = "重复";
                            result.Duplicated++;
                        }
                        if (str8.Length == 0)
                        {
                            str8 = "编码重复";
                            none = ResultType.Duplicated;
                        }
                        else
                        {
                            str8 = str8 + "且编码重复";
                            none = ResultType.Invalid;
                        }
                    }
                    else if (((model.SH != null) && (model.SH.Length != 0)) && (((model.SH.Length < 6) || (model.SH.Length > 20)) || (((model.WJ == 1) && (model.SH.Length != 0)) && ("0000" != this.jyCustomer.CheckTaxCode(model.SH, (FPLX)12)))))
                    {
                        str7 = "失败";
                        str8 = "销货单位税号错误" + model.SH;
                        result.Failed++;
                        none = ResultType.Failed;
                    }
                    else
                    {
                        string[] spellCode = StringUtils.GetSpellCode(model.MC);
                        for (int j = 0; j < spellCode.Length; j++)
                        {
                            string text1 = spellCode[j];
                        }
                        if (this.bmsfhrDAL.AddCustomer(model) == "0")
                        {
                            str7 = "正确传入";
                            result.Correct++;
                            none = ResultType.Correct;
                        }
                        else
                        {
                            str7 = "失败";
                            result.Failed++;
                            none = ResultType.Failed;
                        }
                    }
                    Label_06AF :;
                    result.DtResult.Rows.Add(new object[] { model.BM, model.MC, str7, str8 });
                    stack.Push(new lastBMJG(model.BM, none));
                }
                result.ImportTable = "销货单位编码.DB";
                result2            = result;
            }
            catch
            {
                throw;
            }
            return(result2);
        }
Example #24
0
        public ImportResult ImportData(string codeFile)
        {
            ImportResult result2;

            try
            {
                string[] strArray = File.ReadAllLines(codeFile, ToolUtil.GetEncoding());
                if (strArray.Length == 0)
                {
                    throw new CustomException("此文件没有内容");
                }
                string str   = "";
                int    index = 0;
                bool   flag  = true;
                while (flag)
                {
                    if (strArray[index].StartsWith("{车辆编码}"))
                    {
                        string str2 = strArray[index];
                        if (!str2.Contains("\""))
                        {
                            throw new CustomException("此文件首行车辆编码没有指定分隔符,分隔符使用双引号标注");
                        }
                        str  = str2.Substring(str2.IndexOf("\"")).Trim().Trim(new char[] { '"' });
                        flag = false;
                        index++;
                    }
                    else
                    {
                        index++;
                        if (index == strArray.Length)
                        {
                            throw new CustomException("此文件不符合车辆编码文本格式");
                        }
                    }
                }
                ImportResult     result = new ImportResult();
                Stack <lastBMJG> stack  = new Stack <lastBMJG>();
                string           str4   = this.TuiJianBM("");
                string           str5   = "";
                bool             flag2  = false;
                for (int i = index; i < strArray.Length; i++)
                {
                    BMCLModel model;
                    string    lineText = strArray[i].Trim();
                    if (((lineText.Length == 0) || lineText.StartsWith("//")) || !lineText.Contains(str))
                    {
                        continue;
                    }
                    string[] strArray2 = GetSafeData.Split(lineText, str);
                    if (strArray2.Length < 3)
                    {
                        throw new CustomException("文本首行指定的分隔符与实际分隔符不一致,\n格式不正确等原因导致不能导入此文件!");
                    }
                    model = new BMCLModel {
                        BM = strArray2[0],
                        MC = strArray2[1],
                        JM = strArray2[2],
                    };
                    model.KJM = CommonFunc.GenerateKJM(model.MC);
                    string     str7 = "";
                    string     str8 = "";
                    ResultType none = ResultType.None;
                    if (strArray2.Length > 3)
                    {
                        if (strArray2.Length < 6)
                        {
                            throw new CustomException(string.Format("第{0}行数据不全", i));
                        }
                        model.WJ = 1;
                        string str9 = "";
                        if (str == "~~")
                        {
                            str9 = strArray2[3].Replace(",", "\r\n").Replace("#|#", "\r\n");
                        }
                        else if (str == " ")
                        {
                            str9 = strArray2[3].Replace("#|#", "\r\n");
                        }
                        else
                        {
                            str9 = strArray2[3];
                        }
                        model.CPXH = str9;
                        string str10 = "";
                        if (str == "~~")
                        {
                            str10 = strArray2[4].Replace(",", "\r\n").Replace("#|#", "\r\n");
                        }
                        else if (str == " ")
                        {
                            str10 = strArray2[4].Replace("#|#", "\r\n");
                        }
                        else
                        {
                            str10 = strArray2[4];
                        }
                        model.CD = str10;
                        string str11 = "";
                        if (str == "~~")
                        {
                            str11 = strArray2[5].Replace(",", "\r\n").Replace("#|#", "\r\n");
                        }
                        else if (str == " ")
                        {
                            str11 = strArray2[5].Replace("#|#", "\r\n");
                        }
                        else
                        {
                            str11 = strArray2[5];
                        }
                        model.SCCJMC = str11;
                        if (Flbm.IsYM() && (strArray2.Length > 6))
                        {
                            DAL.BMSPFLManager manager = new DAL.BMSPFLManager();
                            string            bm      = "";
                            if (str == "~~")
                            {
                                bm = strArray2[6].Replace(",", "\r\n").Replace("#|#", "\r\n");
                            }
                            else if (str == " ")
                            {
                                bm = strArray2[6].Replace("#|#", "\r\n");
                            }
                            else
                            {
                                bm = strArray2[6];
                            }
                            if (strArray2.Length > 7)
                            {
                                string str13 = "";
                                if (str == "~~")
                                {
                                    str13 = strArray2[7].Replace(",", "\r\n").Replace("#|#", "\r\n");
                                }
                                else if (str == " ")
                                {
                                    str13 = strArray2[7].Replace("#|#", "\r\n");
                                }
                                else
                                {
                                    str13 = strArray2[7];
                                }
                                if (manager.CanUseThisSPFLBM(bm, false, false))
                                {
                                    model.SPFL   = bm;
                                    model.SPFLMC = manager.GetSPFLMCBYBM(bm);
                                    if (manager.CanUseThisYHZC(bm))
                                    {
                                        if ((str13.Trim() == "是") || (str13.Trim() == "否"))
                                        {
                                            model.YHZC = str13;
                                            if (model.YHZC == "否")
                                            {
                                                model.YHZCMC = "";
                                            }
                                        }
                                        else
                                        {
                                            model.YHZC   = "否";
                                            model.YHZCMC = "";
                                        }
                                        if (strArray2.Length > 9)
                                        {
                                            bool flag3 = false;
                                            if (str13.Trim() == "是")
                                            {
                                                object[] objArray = ServiceFactory.InvokePubService("Aisino.Fwkp.Bmgl.GetSLV_BY_BM", new object[] { model.SPFL });
                                                if ((objArray != null) && (objArray.Length > 0))
                                                {
                                                    string[] strArray3 = (objArray[0] as DataTable).Rows[0]["ZZSTSGL"].ToString().Split(new char[] { ',', '、', ';', ',', ';' });
                                                    if (strArray3.Length > 0)
                                                    {
                                                        foreach (string str14 in strArray3)
                                                        {
                                                            if (strArray2[9].Trim() == str14)
                                                            {
                                                                model.YHZC = "是";
                                                                string str15 = "";
                                                                if (str == "~~")
                                                                {
                                                                    str15 = strArray2[9].Replace(",", "\r\n").Replace("#|#", "\r\n");
                                                                }
                                                                else if (str == " ")
                                                                {
                                                                    str15 = strArray2[9].Replace("#|#", "\r\n");
                                                                }
                                                                else
                                                                {
                                                                    str15 = strArray2[9];
                                                                }
                                                                model.YHZCMC = str15;
                                                                flag3        = true;
                                                            }
                                                            if (!Flbm.IsDK() && strArray2[9].Trim().Contains("1.5%"))
                                                            {
                                                                model.YHZC   = "否";
                                                                model.YHZCMC = "";
                                                            }
                                                        }
                                                    }
                                                }
                                                if (!flag3)
                                                {
                                                    model.YHZC   = "否";
                                                    model.YHZCMC = "";
                                                }
                                            }
                                            else if (str13.Trim() == "否")
                                            {
                                                model.YHZC   = "否";
                                                model.YHZCMC = "";
                                            }
                                            else
                                            {
                                                model.YHZC   = "否";
                                                model.YHZCMC = "";
                                            }
                                        }
                                    }
                                    else
                                    {
                                        model.YHZC   = "否";
                                        model.YHZCMC = "";
                                    }
                                }
                            }
                        }
                    }
                    while (stack.Count > 0)
                    {
                        flag2 = false;
                        if (model.BM.Length > stack.Peek().BM.Length)
                        {
                            if (!model.BM.StartsWith(stack.Peek().BM))
                            {
                                goto Label_07AE;
                            }
                            model.SJBM = stack.Peek().BM;
                            if (stack.Peek().Result == ResultType.Invalid)
                            {
                                str7 = "无效";
                                str8 = "上级编码无效";
                                none = ResultType.Invalid;
                                result.Invalid++;
                            }
                            else if (stack.Peek().Result == ResultType.Failed)
                            {
                                str7 = "失败";
                                str8 = "上级编码失败";
                                none = ResultType.Failed;
                                result.Failed++;
                            }
                            else
                            {
                                if (stack.Peek().Result != ResultType.Duplicated)
                                {
                                    goto Label_07AE;
                                }
                                str5 = this.TuiJianBM(stack.Peek().BM);
                                if (model.BM.Length == str5.Length)
                                {
                                    goto Label_07AE;
                                }
                                str7 = "无效";
                                str8 = "编码长度必须与原有同级编码长度一致";
                                result.Invalid++;
                                none = ResultType.Invalid;
                            }
                            goto Label_0940;
                        }
                        stack.Pop();
                    }
                    flag2 = true;
Label_07AE:
                    if ((flag2 && (str4 != "001")) && (model.BM.Length != str4.Length))
                    {
                        str7 = "无效";
                        str8 = "编码长度必须与原有同级编码长度一致";
                        result.Invalid++;
                        none = ResultType.Invalid;
                    }
                    else if ("0" != this.CheckCustomer(model))
                    {
                        str7 = "无效";
                        str8 = "编码或名称为空";
                        result.Invalid++;
                        none = ResultType.Invalid;
                    }
                    else if (!Regex.IsMatch(model.BM, "^[0-9a-z]{1,16}$"))
                    {
                        str7 = "无效";
                        str8 = "编码需小于16位,且仅由数字和小写字母组成";
                        result.Invalid++;
                        none = ResultType.Invalid;
                    }
                    else if (this.bmclDAL.ExistCustomer(model))
                    {
                        if (str7.Length == 0)
                        {
                            str7 = "重复";
                            result.Duplicated++;
                        }
                        if (str8.Length == 0)
                        {
                            str8 = "编码重复";
                            none = ResultType.Duplicated;
                        }
                        else
                        {
                            str8 = str8 + "且编码重复";
                            none = ResultType.Invalid;
                        }
                    }
                    else
                    {
                        string[] spellCode = StringUtils.GetSpellCode(model.MC);
                        for (int j = 0; j < spellCode.Length; j++)
                        {
                            string text1 = spellCode[j];
                        }
                        if (this.bmclDAL.AddCustomer(model) == "0")
                        {
                            str7 = "正确传入";
                            result.Correct++;
                            none = ResultType.Correct;
                        }
                        else
                        {
                            str7 = "失败";
                            result.Failed++;
                            none = ResultType.Failed;
                        }
                    }
                    Label_0940 :;
                    result.DtResult.Rows.Add(new object[] { model.BM, model.MC, str7, str8 });
                    stack.Push(new lastBMJG(model.BM, none));
                }
                result.ImportTable = "车辆编码.DB";
                result2            = result;
            }
            catch
            {
                throw;
            }
            return(result2);
        }
Example #25
0
        public ImportResult ImportDistrict(string codeFile)
        {
            ImportResult result2;

            try
            {
                string[] strArray = File.ReadAllLines(codeFile, ToolUtil.GetEncoding());
                if (strArray.Length == 0)
                {
                    throw new CustomException("此文件没有内容");
                }
                string str   = "";
                int    index = 0;
                bool   flag  = true;
                while (flag)
                {
                    if (strArray[index].StartsWith("{行政区编码}"))
                    {
                        string str2 = strArray[index];
                        if (!str2.Contains("\""))
                        {
                            throw new CustomException("此文件首行行政区编码没有指定分隔符,分隔符使用双引号标注");
                        }
                        str  = str2.Substring(str2.IndexOf("\"")).Trim().Trim(new char[] { '"' });
                        flag = false;
                        index++;
                    }
                    else
                    {
                        index++;
                        if (index == strArray.Length)
                        {
                            throw new CustomException("此文件不符合行政区编码文本格式");
                        }
                    }
                }
                ImportResult     result = new ImportResult();
                Stack <lastBMJG> stack  = new Stack <lastBMJG>();
                this.TuiJianBM("");
                for (int i = index; i < strArray.Length; i++)
                {
                    string lineText = strArray[i].Trim();
                    if (((lineText.Length != 0) && !lineText.StartsWith("//")) && lineText.Contains(str))
                    {
                        string[] strArray2 = GetSafeData.Split(lineText, str);
                        if (strArray2.Length < 3)
                        {
                            throw new CustomException("文本首行指定的分隔符与实际分隔符不一致,\n格式不正确等原因导致不能导入此文件!");
                        }
                        string      str5      = "";
                        string      str6      = "";
                        ResultType  none      = ResultType.None;
                        BMXZQYModel xzqEntity = new BMXZQYModel {
                            BM = strArray2[0],
                            MC = strArray2[1]
                        };
                        if (this.bmkhDAL.ExistDistrict(xzqEntity))
                        {
                            if (str5.Length == 0)
                            {
                                str5 = "重复";
                                result.Duplicated++;
                            }
                            if (str6.Length == 0)
                            {
                                str6 = "编码重复";
                                none = ResultType.Duplicated;
                            }
                            else
                            {
                                str6 = str6 + "且编码重复";
                                none = ResultType.Invalid;
                            }
                        }
                        else if (this.bmkhDAL.AddDistrict(xzqEntity) == "0")
                        {
                            str5 = "正确传入";
                            result.Correct++;
                            none = ResultType.Correct;
                        }
                        else
                        {
                            str5 = "失败";
                            result.Failed++;
                            none = ResultType.Failed;
                        }
                        result.DtResult.Rows.Add(new object[] { xzqEntity.BM, xzqEntity.MC, str5, str6 });
                        stack.Push(new lastBMJG(xzqEntity.BM, none));
                    }
                }
                result.ImportTable = "XZQBM";
                result2            = result;
            }
            catch
            {
                throw;
            }
            return(result2);
        }
Example #26
0
 public bool Connect(string string_3, string string_4, out string string_5)
 {
     try
     {
         bool flag2;
         this.tcpClient_0     = new TcpClient(this.string_0, this.int_0);
         this.networkStream_0 = this.tcpClient_0.GetStream();
         this.streamReader_0  = new StreamReader(this.tcpClient_0.GetStream(), ToolUtil.GetEncoding());
         string_5             = this.streamReader_0.ReadLine();
         if (string_3 == null)
         {
             return(string_5.StartsWith("+OK"));
         }
         this.string_1 = "USER " + ((string_3 == null) ? "" : string_3) + "\r\n";
         this.method_0(this.string_1);
         string_5      = this.streamReader_0.ReadLine();
         this.string_1 = "PASS " + string_4 + "\r\n";
         this.method_0(this.string_1);
         string_5 = this.streamReader_0.ReadLine();
         if (!(flag2 = string_5.StartsWith("+OK")))
         {
             this.networkStream_0.Close();
             this.streamReader_0.Close();
             this.networkStream_0 = null;
             this.streamReader_0  = null;
         }
         return(flag2);
     }
     catch (Exception exception)
     {
         string_5 = exception.Message;
         return(false);
     }
 }
Example #27
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     foreach (string str in this.djFiles)
     {
         this.mFileName = str.Substring(str.LastIndexOf('\\') + 1);
         string bfFile = Path.Combine(this.bfPath, this.mFileName);
         int    length = this.mFileName.Length;
         string str3   = this.mFileName.Substring(0, length - 4) + "_开票结果.TXT";
         this.hxFileNamexml = this.mFileName.Substring(0, length - 4) + "_开票结果.xml";
         List <string> list = this.djHelper.QueryYkdj(this.mFileName);
         if ((int)(int)this.fplx == 0x33)
         {
             doc = new XmlDocument();
             XmlDeclaration newChild = doc.CreateXmlDeclaration("1.0", "GBK", null);
             doc.AppendChild(newChild);
             bus = doc.CreateElement("business");
             doc.AppendChild(bus);
         }
         else
         {
             writer = new StreamWriter(new FileStream(Path.Combine(this.hxPath, str3), FileMode.Append, FileAccess.Write, FileShare.ReadWrite), ToolUtil.GetEncoding());
         }
         List <Djfp> list2 = this.ParseDjFile(str);
         success = true;
         for (int i = 0; (i < list2.Count) && success; i++)
         {
             jqbh       = "";
             fp_dm      = "";
             fp_hm      = "";
             kprq       = "";
             fp_mw      = "";
             jym        = "";
             ewm        = "";
             bz         = "";
             returncode = "0000";
             returnmsg  = "";
             Djfp dj = list2[i];
             this.mDjh = dj.Djh;
             this.backgroundWorker1.ReportProgress(0, null);
             bool flag = false;
             if (list.Contains(this.mDjh))
             {
                 flag = false;
                 object[] args = new object[] { base.TaxCardInstance.TaxClock.ToString("yyyy-MM-dd HH:mm:ss"), this.mDjh, 0, "该单据已成功填开过发票,不可重复开具!" };
                 KpResult   = string.Format("[{0}] 单据号:{1},开具结果:{2},开具失败原因:{3}", args);
                 returncode = "0001";
                 returnmsg  = "该单据已成功填开过发票,不可重复开具!";
                 this.backgroundWorker1.ReportProgress(15, null);
             }
             else if (((int)(int)this.fplx == 0x33) && dj.Fpxx.isRed)
             {
                 string str4 = this.CheckDZRed(dj);
                 if (str4 != "")
                 {
                     flag = false;
                     object[] objArray2 = new object[] { base.TaxCardInstance.TaxClock.ToString("yyyy-MM-dd HH:mm:ss"), this.mDjh, 0, str4 };
                     KpResult   = string.Format("[{0}] 单据号:{1},开具结果:{2},开具失败原因:{3}", objArray2);
                     returncode = "0001";
                     returnmsg  = str4;
                     this.backgroundWorker1.ReportProgress(15, null);
                 }
                 else
                 {
                     this.TKfpxx(dj);
                     if (this.SuccessKp())
                     {
                         list.Add(this.mDjh);
                     }
                     flag = true;
                 }
             }
             else
             {
                 this.TKfpxx(dj);
                 if (this.SuccessKp())
                 {
                     list.Add(this.mDjh);
                 }
                 flag = true;
             }
             if ((int)this.fplx == 0x33)
             {
                 XmlNode node = doc.CreateElement("RESPONSE_COMMON_FPKJ");
                 bus.AppendChild(node);
                 XmlElement element = doc.CreateElement("FPQQLSH");
                 if ((this.mDjh != null) && (this.mDjh != ""))
                 {
                     element.InnerText = this.mDjh;
                 }
                 node.AppendChild(element);
                 XmlElement element2 = doc.CreateElement("JQBH");
                 if ((jqbh != null) && (jqbh != ""))
                 {
                     element2.InnerText = jqbh;
                 }
                 node.AppendChild(element2);
                 XmlElement element3 = doc.CreateElement("FP_DM");
                 if ((fp_dm != null) && (fp_dm != ""))
                 {
                     element3.InnerText = fp_dm;
                 }
                 node.AppendChild(element3);
                 XmlElement element4 = doc.CreateElement("FP_HM");
                 if ((fp_hm != null) && (fp_hm != ""))
                 {
                     element4.InnerText = fp_hm;
                 }
                 node.AppendChild(element4);
                 XmlElement element5 = doc.CreateElement("KPRQ");
                 if ((kprq != "") && (kprq != null))
                 {
                     DateTime time2 = Convert.ToDateTime(kprq);
                     kprq = string.Format("{0:yyyyMMddHHmmss}", time2);
                     element5.InnerText = kprq;
                 }
                 node.AppendChild(element5);
                 XmlElement element6 = doc.CreateElement("FP_MW");
                 if ((fp_mw != null) && (fp_mw != ""))
                 {
                     element6.InnerText = fp_mw;
                 }
                 node.AppendChild(element6);
                 XmlElement element7 = doc.CreateElement("JYM");
                 if ((jym != null) && (jym != ""))
                 {
                     element7.InnerText = jym;
                 }
                 node.AppendChild(element7);
                 XmlElement element8 = doc.CreateElement("EWM");
                 if ((ewm != null) && (ewm != ""))
                 {
                     element8.InnerText = ewm;
                 }
                 node.AppendChild(element8);
                 XmlElement element9 = doc.CreateElement("BZ");
                 if ((bz != null) && (bz != ""))
                 {
                     element9.InnerText = bz;
                 }
                 node.AppendChild(element9);
                 XmlElement element10 = doc.CreateElement("RETURNCODE");
                 element10.InnerText = returncode;
                 node.AppendChild(element10);
                 XmlElement element11 = doc.CreateElement("RETURNMSG");
                 element11.InnerText = KpResult;
                 node.AppendChild(element11);
             }
             else
             {
                 writer.WriteLine(KpResult);
             }
             Thread.Sleep(500);
             if (ErrorExist)
             {
                 this.CloseFile(str, bfFile);
                 break;
             }
             if (this.backgroundWorker1.CancellationPending)
             {
                 this.CloseFile(str, bfFile);
                 this.interrupted = true;
                 e.Cancel         = true;
                 break;
             }
             if (flag && (i != (list2.Count - 1)))
             {
                 Thread.Sleep(0x2710);
             }
             Thread.Sleep(500);
         }
         if ((int)this.fplx == 0x33)
         {
             doc.Save(this.hxPath + @"\" + this.hxFileNamexml);
         }
         else
         {
             writer.Close();
             writer.Dispose();
         }
         File.Copy(str, bfFile, true);
         File.Delete(str);
         Thread.Sleep(200);
     }
 }
        private bool checkCaPassword(string password, string CA)
        {
            bool flag = true;

            if ((CA.Length == 0) || (password.Length == 0))
            {
                return(false);
            }
            try
            {
                string path             = PropertyUtil.GetValue("MAIN_PATH") + @"\bin\CAConsole.exe";
                string str2             = PropertyUtil.GetValue("MAIN_PATH") + @"\bin\server.pfx";
                string currentDirectory = Directory.GetCurrentDirectory();
                Directory.SetCurrentDirectory(PropertyUtil.GetValue("MAIN_PATH") + @"\bin\");
                this.loger.Info("GetCurrentDirectory :" + currentDirectory);
                this.loger.Info("m_strPfxPath :" + str2);
                if (File.Exists("caResult.dat"))
                {
                    File.Delete("caResult.dat");
                }
                if (File.Exists(path))
                {
                    Process process = new Process {
                        StartInfo = { FileName = path, Arguments = password, UseShellExecute = true, WindowStyle = ProcessWindowStyle.Hidden }
                    };
                    process.Start();
                    process.WaitForExit();
                    Thread.Sleep(0x3e8);
                    if (process.HasExited)
                    {
                        if (File.Exists("caResult.dat"))
                        {
                            StreamReader reader = new StreamReader(File.Open("caResult.dat", FileMode.Open), ToolUtil.GetEncoding());
                            string       str4   = "";
                            while ((str4 = reader.ReadLine()) != null)
                            {
                                this.loger.Info(" caResult.dat Line :" + str4);
                                if (str4.IndexOf("return=0") == -1)
                                {
                                    flag = false;
                                }
                            }
                        }
                        else
                        {
                            string[] textArray1 = new string[] { "caResult.dat文件未找到" };
                            MessageManager.ShowMsgBox("SWDK-0061", textArray1);
                            flag = false;
                        }
                    }
                    else if (!process.HasExited)
                    {
                        process.Kill();
                        flag = false;
                    }
                }
                Directory.SetCurrentDirectory(currentDirectory);
            }
            catch (Exception exception)
            {
                this.loger.Error("校验证书密码发生异常:" + exception.ToString());
                string[] textArray2 = new string[] { exception.ToString() };
                MessageManager.ShowMsgBox("SWDK-0061", textArray2);
                return(false);
            }
            DigitalEnvelop.DigEnvClose();
            return(flag);
        }
Example #29
0
        public ImportResult ImportGoodsTax(string codeFile)
        {
            ImportResult result2;

            try
            {
                string[] strArray = File.ReadAllLines(codeFile, ToolUtil.GetEncoding());
                if (strArray.Length == 0)
                {
                    throw new CustomException("此文件没有内容");
                }
                string str   = "";
                int    index = 0;
                bool   flag  = true;
                while (flag)
                {
                    if (strArray[index].StartsWith("{商品税目编码}"))
                    {
                        string str2 = strArray[index];
                        if (!str2.Contains("\""))
                        {
                            throw new CustomException("此文件首行商品税目编码没有指定分隔符,分隔符使用双引号标注");
                        }
                        str  = str2.Substring(str2.IndexOf("\"")).Trim().Trim(new char[] { '"' });
                        flag = false;
                        index++;
                    }
                    else
                    {
                        index++;
                        if (index == strArray.Length)
                        {
                            throw new CustomException("此文件不符合商品税目编码文本格式");
                        }
                    }
                }
                ImportResult     result = new ImportResult();
                Stack <lastBMJG> stack  = new Stack <lastBMJG>();
                this.TuiJianBM("");
                for (int i = index; i < strArray.Length; i++)
                {
                    string lineText = strArray[i].Trim();
                    if (((lineText.Length != 0) && !lineText.StartsWith("//")) && lineText.Contains(str))
                    {
                        string[] strArray2 = GetSafeData.Split(lineText, str);
                        if (strArray2.Length < 3)
                        {
                            throw new CustomException("文本首行指定的分隔符与实际分隔符不一致,\n格式不正确等原因导致不能导入此文件!");
                        }
                        string      str5       = "";
                        string      str6       = "";
                        ResultType  none       = ResultType.None;
                        BMSPSMModel spsmEntity = new BMSPSMModel {
                            SZ = strArray2[0],
                            BM = strArray2[1],
                            MC = strArray2[2]
                        };
                        double num3 = 0.0;
                        if (!double.TryParse(strArray2[3], out num3))
                        {
                            throw new CustomException(string.Format("第{0}行数据格式不正确", i));
                        }
                        spsmEntity.SLV = num3;
                        if (!double.TryParse(strArray2[4], out num3))
                        {
                            throw new CustomException(string.Format("第{0}行数据格式不正确", i));
                        }
                        spsmEntity.ZSL  = num3;
                        spsmEntity.SLJS = (strArray2[5] == "false") ? byte.Parse("0") : byte.Parse("1");
                        spsmEntity.JSDW = strArray2[6];
                        double num4 = 0.0;
                        if (!double.TryParse(strArray2[7], out num4))
                        {
                            throw new CustomException(string.Format("第{0}行数据格式不正确", i));
                        }
                        spsmEntity.SE = num4;
                        bool flag3 = false;
                        if (!bool.TryParse(strArray2[8], out flag3))
                        {
                            throw new CustomException(string.Format("第{0}行数据格式不正确", i));
                        }
                        spsmEntity.FHDBZ = flag3;
                        if (this.bmkhDAL.ExistGoodsTax(spsmEntity))
                        {
                            if (str5.Length == 0)
                            {
                                str5 = "重复";
                                result.Duplicated++;
                            }
                            if (str6.Length == 0)
                            {
                                str6 = "编码重复";
                                none = ResultType.Duplicated;
                            }
                            else
                            {
                                str6 = str6 + "且编码重复";
                                none = ResultType.Invalid;
                            }
                        }
                        else if (this.bmkhDAL.AddGoodsTax(spsmEntity) == "0")
                        {
                            str5 = "正确传入";
                            result.Correct++;
                            none = ResultType.Correct;
                        }
                        else
                        {
                            str5 = "失败";
                            result.Failed++;
                            none = ResultType.Failed;
                        }
                        result.DtResult.Rows.Add(new object[] { spsmEntity.BM, spsmEntity.MC, str5, str6 });
                        stack.Push(new lastBMJG(spsmEntity.BM, none));
                    }
                }
                result.ImportTable = "SPSMBM.DB";
                result2            = result;
            }
            catch
            {
                throw;
            }
            return(result2);
        }
Example #30
0
        public ImportResult ImportData(string codeFile)
        {
            ImportResult result2;

            try
            {
                string[] array = File.ReadAllLines(codeFile, ToolUtil.GetEncoding());
                if (array.Length == 0)
                {
                    throw new CustomException("此文件没有内容");
                }
                string str   = "";
                int    index = 0;
                bool   flag  = true;
                while (flag)
                {
                    if (array[index].StartsWith("{客户编码}"))
                    {
                        string str2 = array[index];
                        if (!str2.Contains("\""))
                        {
                            throw new CustomException("此文件首行客户编码没有指定分隔符,分隔符使用双引号标注");
                        }
                        str  = str2.Substring(str2.IndexOf("\"")).Trim().Trim(new char[] { '"' });
                        flag = false;
                        index++;
                    }
                    else
                    {
                        index++;
                        if (index == array.Length)
                        {
                            throw new CustomException("此文件不符合客户编码文本格式");
                        }
                    }
                }
                if (TaxCardFactory.CreateTaxCard().SoftVersion == "FWKP_V2.0_Svr_Client")
                {
                    Array.Sort <string>(array, index, array.Length - index);
                }
                ImportResult     result = new ImportResult();
                Stack <lastBMJG> stack  = new Stack <lastBMJG>();
                string           str4   = this.TuiJianBM("");
                string           str5   = "";
                bool             flag2  = false;
                for (int i = index; i < array.Length; i++)
                {
                    string lineText = array[i].Trim();
                    if (((lineText.Length == 0) || lineText.StartsWith("//")) || !lineText.Contains(str))
                    {
                        continue;
                    }
                    string[] strArray2 = GetSafeData.Split(lineText, str);
                    if (strArray2.Length < 3)
                    {
                        throw new CustomException("文本首行指定的分隔符与实际分隔符不一致,\n格式不正确等原因导致不能导入此文件!");
                    }
                    BMKHModel customer = new BMKHModel {
                        BM = strArray2[0],
                        MC = strArray2[1],
                        JM = strArray2[2]
                    };
                    string     str7 = "";
                    string     str8 = "";
                    ResultType none = ResultType.None;
                    customer.KJM = CommonFunc.GenerateKJM(customer.MC);
                    if (strArray2.Length > 3)
                    {
                        if (strArray2.Length < 7)
                        {
                            continue;
                        }
                        customer.SH = strArray2[3].ToUpper();
                        customer.WJ = 1;
                        string str9 = "";
                        if (str == "~~")
                        {
                            str9 = strArray2[4].Replace(",", "\r\n").Replace("#|#", "\r\n");
                        }
                        else if (str == " ")
                        {
                            str9 = strArray2[4].Replace("#|#", "\r\n");
                        }
                        else
                        {
                            str9 = strArray2[4];
                        }
                        customer.DZDH = str9;
                        string str10 = "";
                        if (str == "~~")
                        {
                            str10 = strArray2[5].Replace(",", "\r\n").Replace("#|#", "\r\n");
                        }
                        else if (str == " ")
                        {
                            str10 = strArray2[5].Replace("#|#", "\r\n");
                        }
                        else
                        {
                            str10 = strArray2[5];
                        }
                        customer.YHZH = str10;
                        customer.YJDZ = strArray2[6];
                        customer.BZ   = strArray2[7];
                    }
                    while (stack.Count > 0)
                    {
                        flag2 = false;
                        if (customer.BM.Length > stack.Peek().BM.Length)
                        {
                            if (!customer.BM.StartsWith(stack.Peek().BM))
                            {
                                goto Label_03EA;
                            }
                            customer.SJBM = stack.Peek().BM;
                            if (stack.Peek().Result == ResultType.Invalid)
                            {
                                str7 = "无效";
                                str8 = "上级编码无效";
                                none = ResultType.Invalid;
                                result.Invalid++;
                            }
                            else if (stack.Peek().Result == ResultType.Failed)
                            {
                                str7 = "失败";
                                str8 = "上级编码失败";
                                none = ResultType.Failed;
                                result.Failed++;
                            }
                            else
                            {
                                if (stack.Peek().Result != ResultType.Duplicated)
                                {
                                    goto Label_03EA;
                                }
                                str5 = this.TuiJianBM(stack.Peek().BM);
                                if (customer.BM.Length == str5.Length)
                                {
                                    goto Label_03EA;
                                }
                                str7 = "无效";
                                str8 = "编码长度必须与原有同级编码长度一致";
                                result.Invalid++;
                                none = ResultType.Invalid;
                            }
                            goto Label_068B;
                        }
                        stack.Pop();
                    }
                    flag2 = true;
Label_03EA:
                    if ((flag2 && (str4 != "001")) && (customer.BM.Length != str4.Length))
                    {
                        str7 = "无效";
                        str8 = "编码长度必须与原有同级编码长度一致";
                        result.Invalid++;
                        none = ResultType.Invalid;
                    }
                    else if ("0" != this.CheckCustomer(customer))
                    {
                        str7 = "无效";
                        str8 = "编码或名称为空";
                        result.Invalid++;
                        none = ResultType.Invalid;
                    }
                    else if (!Regex.IsMatch(customer.BM, "^[0-9a-z]{1,16}$"))
                    {
                        str7 = "无效";
                        str8 = "编码需小于16位,且仅由数字和小写字母组成";
                        result.Invalid++;
                        none = ResultType.Invalid;
                    }
                    else if (this.bmkhDAL.ExistCustomer(customer))
                    {
                        if (str7.Length == 0)
                        {
                            str7 = "重复";
                            result.Duplicated++;
                        }
                        if (str8.Length == 0)
                        {
                            str8 = "编码重复";
                            none = ResultType.Duplicated;
                        }
                        else
                        {
                            str8 = str8 + "且编码重复";
                            none = ResultType.Invalid;
                        }
                    }
                    else if (((customer.SH != null) && (customer.SH.Length != 0)) && (((customer.SH.Length < 6) || (customer.SH.Length > 20)) || (((customer.WJ == 1) && (customer.SH.Length != 0)) && ("0000" != this.jyCustomer.CheckTaxCode(customer.SH, 0)))))
                    {
                        str7 = "失败";
                        str8 = "客户税号错误" + customer.SH;
                        result.Failed++;
                        none = ResultType.Failed;
                    }
                    else if (this.bmkhDAL.ExistCusMC(customer.BM, customer.MC, customer.SJBM))
                    {
                        str7 = "失败";
                        str8 = "客户名称与其同级单位名称重复" + customer.SH;
                        result.Failed++;
                        none = ResultType.Failed;
                    }
                    else
                    {
                        foreach (string str11 in StringUtils.GetSpellCode(customer.MC))
                        {
                            customer.KJM = customer.KJM + str11;
                        }
                        if (this.bmkhDAL.AddCustomer(customer) == "0")
                        {
                            str7 = "正确传入";
                            result.Correct++;
                            none = ResultType.Correct;
                        }
                        else
                        {
                            str7 = "失败";
                            result.Failed++;
                            none = ResultType.Failed;
                        }
                    }
                    Label_068B :;
                    result.DtResult.Rows.Add(new object[] { customer.BM, customer.MC, str7, str8 });
                    stack.Push(new lastBMJG(customer.BM, none));
                }
                result.ImportTable = "客户编码.DB";
                result2            = result;
            }
            catch
            {
                throw;
            }
            return(result2);
        }