阅读并评估文本文件 [英] Read and evaluate a text file

查看:85
本文介绍了阅读并评估文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开展一个项目,为客户做简单的在线授权。这要求最终用户在网络表单中输入买方编号,卖方编号和销售金额(描述是可选的)。然后将该信息与存储在逗号分隔的文本文件中的信息进行比较。我们需要:

1.检查买家的号码 - 是否有效(是否存在于文本文件中)



2.检查卖家的号码 - 是否有效(是否存在于文本文件中)



3.检查买家的可用余额 - ( (交易余额+信用额度) - 待定)交易 - 如果该金额>>销售金额,则我们授权交易;如果没有,那么我们否认交易



4.如果交易被授权,我们会生成一个授权号码 - 前3位是一年中的日期+ 100,最后3位是从500开始的序号,到699,每天重置最后3位



5.无论哪种方式,我们写出单独的固定数字由会计系统处理的长度文本文件



以下是文件的详细信息。我需要一些新手帮助,用C#/ ASP.NET做最好的方法。我的想法是每次单击授权按钮时将整个文件读入某种数组,然后以某种方式搜索数组以获取我们需要比较的信息。然后,根据信息和比较,我会写固定长度的文本文件。



建议和帮助非常感谢。



这是DW48843C.DAT(传入文件)的布局) - 这是一个以逗号分隔的文件。

标签 - DW48843C.DAT



I am working on a project to do simple online authorizations for a customer. This requires that the end user enter in a buyer number, a seller number, and the amount of the sale (a description is OPTIONAL) in a web form. This information is then going to be compared to information that is stored in a comma delimited text file. We need to:
1. Check the buyer''s number - valid or not (does it exist in the text file)

2. Check the seller''s number - valid or not (does it exist in the text file)

3. Check the buyer''s available balance - ((trade balance + credit line) - pending) transactions - if that amount is >= the amount of sale, then we authorize the transaction; if not, then we deny the transaction

4. If the transaction is authorized, we generate an authorization number - First 3 digits are the day of the year + 100, the last 3 digits are a sequential number starting at 500, going to 699, resetting these last 3 each day

5. Either way, we write out to a separate fixed length text file that is processed by the "accounting" system

Below are the details of the files. I need some "newbie" assistance in the best approach to do this with C# / ASP.NET. My thoughts were to read the entire file into an array of some sort each time the "Authorization" button was clicked, and then somehow search the array for the information we need to compare. Then, based on the information and comparisons, I would write the fixed length text file.

Suggestions and help are GREATLY appreciated.

Here is the layout for DW48843C.DAT (incoming file) – it is a comma delimited file.
Label – DW48843C.DAT

11920,"Advanced Roofing Systems, Inc ","0","0","2321",978.06,.00,.00,778.30,"1",3113.20," ","                          ",.00," "," "
11935,"Advertising Accents, Inc.     ","0","0","4628",7928.79,530.00,.00,76.39," ",.00," ","1-313-937-3636            ",.00,"B"," "



客户编号(或借记卡编号)

客户名称

无限制代码

无授权码

客户端PIN码(借记卡默认为9898)

当前交易余额(如果借记卡可用余额) )

信用额度

等待授权购买

到期现金费用

临时无费用授权码(D 如果是借记卡)

费用限制金额

Te mp没有状态授权代码

传真号码(借记卡到期日期)

等待授权销售

客户评级代码

无销售代码



需要使用标签DW488439.D创建固定长度的ASCII文件以下是此文件包含的示例:




Client number (or debit card number)
Client name
No restrictions code
No authorizations code
Client PIN (default is 9898 for a debit card)
Current trade balance (available balance if debit card)
Credit line
Pending authorization purchases
Cash fees due
Temp no authorization code for fees ("D" if debit card)
Fee restricted amount
Temp no authorization code for status
Fax number (expiration date if debit card)
Pending authorization sales
Client rating code
No sales code

A fixed length ASCII file would need to be created with a label of DW488439.D The following is a sample of what this file would contain:

1234567890123456789012345678901234567890123456789012314567890
         1         2         3         4         5          6    
000000 0474300 04594 00/00/00 08-18-2012 000004283 2012  1
302327 1982800 12620 11/25/12 08-18-2012 000027900 2012
302329 1153600 18268 11/25/12 08-18-2012 000021200 2012
302331 6394800 64718 11/25/12 08-18-2012 000040000 2012



1-6 - 授权号码(如果拒绝则为零)

8-12 - 买家帐号

13-14 - 可选卡号(如果不使用则为零)

8-14 - 完整买家卡号(如果使用)或借记卡卡号

16-20 - 卖家账号

22-29 - 到期日期(如果拒绝则为零)

31-40 - 发行日期

42-50 - 没有小数的美元金额

52-54 - 年

57-57 - 1 =谢绝(否则为空白)

61-90 - 可选说明(上面示例中未显示)



我们要做的是在DW48843C.DAT文件中读取并用它作为我们的比较。如果授权是好的,我们然后生成一个授权号码 - 前3位数字是一年中的日期+100,然后是从500开始的序号。最后三位数字每天都是RESET。因此,例如,12/17/2012将具有从450(第350 + 100天)开始的授权号,如450501.我们需要找到一种方法来跟踪上次为授权生成的号码。我们会将此信息写入DW488439.D(这是用于Internet授权的文件)。 TWOL常驻计划定期轮询DW488431.D和DW488439.D文件,以使DW48843C.DAT文件保持最新,并使TradeWorks余额保持最新。


1– 6 – authorization number (zeros if declined)
8-12 – buyer account number
13-14 – optional card number (zeros if not used)
8-14 – full buyer card number (if used) or debit card number
16-20 – seller account number
22-29 – expiration date (zeros if declined)
31-40 – issued date
42-50 – dollar amount without decimal
52-54 – year
57-57 – 1 = declined (otherwise blank)
61-90 – optional description (not shown in above sample)

What it appears we have to do is read in the DW48843C.DAT file and use that as our comparison. If the authorization is good, we then generate an authorization number – first 3 digits are the day of the year + 100, followed by a sequential number starting at 500. The last three digits are RESET every day. So, for example, 12/17/2012 would have authorization numbers starting with 450 (day 350+100), like 450501. We would need to have to find a way to track what number was last generated for authorizations. We would write this information to DW488439.D (this is the file that is used for Internet authorizations). The TWOL resident program polls for the DW488431.D and DW488439.D files on a regular basis to keep the DW48843C.DAT file up to date, as well as keeping TradeWorks balances up to date.

推荐答案

要阅读CSV文件,我使用过快速CSV阅读器 [ ^ ]这里在CodeProject上取得了巨大的成功。将数据写回来应该很容易。
To read the CSV file I''ve used A Fast CSV Reader[^] here on CodeProject with great success. Writing the data back out should be easy.


这篇关于阅读并评估文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆