| 1 |
/* |
| 2 |
* FeliCa2Money |
| 3 |
* |
| 4 |
* Copyright (C) 2001-2008 Takuya Murakami |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
using System; |
| 22 |
using System.Collections.Generic; |
| 23 |
using System.Text; |
| 24 |
using System.Windows.Forms; |
| 25 |
|
| 26 |
namespace FeliCa2Money |
| 27 |
{ |
| 28 |
class Edy : Card |
| 29 |
{ |
| 30 |
public Edy() |
| 31 |
{ |
| 32 |
ident = "Edy"; |
| 33 |
cardName = "Edy"; |
| 34 |
} |
| 35 |
|
| 36 |
public override List<Transaction> ReadCard() |
| 37 |
{ |
| 38 |
SfcPeep s = new SfcPeep(); |
| 39 |
List<string> lines = s.Execute("-e"); |
| 40 |
|
| 41 |
if (lines[0].Substring(0, 4) != "EDY:") |
| 42 |
{ |
| 43 |
return null; |
| 44 |
} |
| 45 |
|
| 46 |
CardId = lines[0].Substring(4); |
| 47 |
|
| 48 |
lines.RemoveAt(0); |
| 49 |
lines.Reverse(); |
| 50 |
|
| 51 |
// Parse lines |
| 52 |
List<Transaction> transactions = new List<Transaction>(); |
| 53 |
foreach (string line in lines) |
| 54 |
{ |
| 55 |
Transaction t = new Transaction(); |
| 56 |
|
| 57 |
string[] items = ParseLine(line); |
| 58 |
if (SetTransaction(t, items)) { |
| 59 |
transactions.Add(t); |
| 60 |
} |
| 61 |
} |
| 62 |
return transactions; |
| 63 |
} |
| 64 |
|
| 65 |
private bool SetTransaction(Transaction t, string[] items) |
| 66 |
{ |
| 67 |
// 0:������,1:������������,2:���������������,3:������������������, 4:������������ |
| 68 |
// ET00:��������������� 2007���03���14���23���08���16��� 24000 49428 59 |
| 69 |
|
| 70 |
t.id = int.Parse(items[4]); |
| 71 |
|
| 72 |
string d = items[1]; |
| 73 |
int yy = int.Parse(d.Substring(0, 4)); |
| 74 |
int mm = int.Parse(d.Substring(5, 2)); |
| 75 |
int dd = int.Parse(d.Substring(8, 2)); |
| 76 |
int h = int.Parse(d.Substring(11, 2)); |
| 77 |
int m = int.Parse(d.Substring(14, 2)); |
| 78 |
int s = int.Parse(d.Substring(17, 2)); |
| 79 |
|
| 80 |
t.date = new DateTime(yy, mm, dd, h, m, s); |
| 81 |
|
| 82 |
t.desc = items[0].Substring(5); |
| 83 |
if (t.desc == "----") { |
| 84 |
return false; // empty |
| 85 |
} |
| 86 |
t.memo = t.desc; |
| 87 |
|
| 88 |
if (t.desc == "������") { |
| 89 |
t.GuessTransType(false); |
| 90 |
t.value = - int.Parse(items[2]); |
| 91 |
|
| 92 |
// ��������� "������" ���������������Money ��������������������������������������������� |
| 93 |
// ������������������������������������������������������������ |
| 94 |
t.desc += " "; |
| 95 |
t.desc += t.id.ToString(); |
| 96 |
} |
| 97 |
else |
| 98 |
{ |
| 99 |
t.GuessTransType(true); |
| 100 |
t.value = int.Parse(items[2]); |
| 101 |
} |
| 102 |
t.balance = int.Parse(items[3]); |
| 103 |
|
| 104 |
return true; |
| 105 |
} |
| 106 |
} |
| 107 |
} |