Ach处理在文件中添加特殊字符

时间:2018-12-04 05:49:04

标签: .net model-view-controller choetl

  

我必须生成ACH文件(我的代码在下面)。每当银行处理此事时。它在文件前面添加了一些特殊字符。无法弄清

生成具有NACHA格式的ACH文件的正确方法是什么,以便可以毫无故障地对其进行处理

try
            {
                //Set this flag to fix the issue
                ChoETLFrxBootstrap.IsSandboxEnvironment = false;
                ChoNACHAConfiguration config = new ChoNACHAConfiguration();
                config.DestinationBankRoutingNumber = "xxxxxxxxxx";                
                config.OriginatingCompanyId = "xxxxxxxxxx";
                config.DestinationBankName = ("SOME Bank").ToUpper();
                config.OriginatingCompanyName = ("Organisation Name").ToUpper();
                config.ReferenceCode = ("mgmt").ToUpper();
                config.BlockingFactor = 10;
                var unitowners = Achbll.GetUnitOwnerPaymentList(Dt).ToList();
                var FileName = "ACH_" + ((DateTime.Now.ToString("dd-MM-yyy hh:mm:ss")).Replace(" ", "_").Replace(":", "_")) + ".txt";
                var backpath = "~/CondoDocuments/DocumentLibrary/AchFiles/" + FileName;
                var path = Server.MapPath(backpath); //HttpRuntime.AppDomainAppPath + backpath;

                using (var fs = System.IO.File.Create(path))
                {
                    fs.Close();
                    fs.Dispose();
                }

                using (var nachaWriter = new ChoNACHAWriter(path, config))
                {
                    using (var bw2 = nachaWriter.CreateBatch(200, "PPD", "DIR DEBIT", DateTime.Now, DateTime.Now.AddDays(1), null, null, '1', null, null))
                    {
                        foreach (var owner in unitowners)
                        {
                            if (!string.IsNullOrEmpty(owner.AccountNo) && !string.IsNullOrEmpty(owner.BankRoutingCode))
                            {

                                var UA = Cipher.decrypt(owner.AccountNo);
                                var BR = Cipher.decrypt(owner.BankRoutingCode);
                                var Name = owner.UnitOwnerName.Split(' ');
                                if (Name.Length > 1)
                                {
                                    using (var entry = bw2.CreateDebitEntryDetail(27, BR.ToString(), UA.ToString(), 5, " 18H00A " + owner.UnitNo.ToString(), (Name[1] + ", " + Name[0]).ToUpper().ToString()))
                                    {
                                        //entry.CheckDigit = '0';
                                    }
                                }
                                else
                                {
                                    using (var entry = bw2.CreateDebitEntryDetail(
                                                                                    27,
                                                                                    BR.ToString(),
                                                                                    UA.ToString(),
                                                                                    new decimal(5.25),
                                                                                    " 18H00B " + owner.UnitNo.ToString(),
                                                                                    (Name[0]).ToUpper().ToString()))

                                    {
                                        //entry.CheckDigit = '0';
                                    }
                                }
                            }
                        }
                    }
                }

                AchFiles obj = new AchFiles
                {
                    FileName = FileName,
                    Path = "../CondoDocuments/DocumentLibrary/AchFiles/" + FileName
                };

                Achbll.AddAchFiles(obj);

            }
            catch (System.Exception ex)
            {

            }
  

我正在附加处理后的数据的屏幕截图   enter image description here

0 个答案:

没有答案