| 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 FelicaLib; |
| 25 |
|
| 26 |
namespace FeliCa2Money |
| 27 |
{ |
| 28 |
class Edy : CardWithFelicaLib |
| 29 |
{ |
| 30 |
public Edy() |
| 31 |
{ |
| 32 |
org = "Edy"; |
| 33 |
cardName = "Edy"; |
| 34 |
|
| 35 |
systemCode = (int)SystemCode.Edy; |
| 36 |
serviceCode = 0x170f; |
| 37 |
needReverse = true; |
| 38 |
} |
| 39 |
|
| 40 |
public override void analyzeCardId(Felica f) |
| 41 |
{ |
| 42 |
byte[] data = f.ReadWithoutEncryption(0x110b, 0); |
| 43 |
if (data == null) |
| 44 |
{ |
| 45 |
throw new Exception("Edy������������������������������"); |
| 46 |
} |
| 47 |
|
| 48 |
accountId = ""; |
| 49 |
for (int i = 2; i < 10; i++) { |
| 50 |
accountId += data[i].ToString("X2"); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
public override bool analyzeTransaction(Transaction t, byte[] data) |
| 55 |
{ |
| 56 |
// ������ |
| 57 |
int value = read4b(data, 4); |
| 58 |
|
| 59 |
if (value == 0 && data[0] == 0) |
| 60 |
{ |
| 61 |
return false; // ��������������������������� |
| 62 |
} |
| 63 |
|
| 64 |
t.date = new DateTime(2000, 1, 1); |
| 65 |
|
| 66 |
t.date += TimeSpan.FromDays(value >> 17); |
| 67 |
t.date += TimeSpan.FromSeconds(value & 0x1fff); |
| 68 |
|
| 69 |
// ������ |
| 70 |
t.value = read4b(data, 8); |
| 71 |
|
| 72 |
// ������ |
| 73 |
t.balance = read4b(data, 12); |
| 74 |
|
| 75 |
// ������ |
| 76 |
t.id = read3b(data, 1); |
| 77 |
|
| 78 |
// ������ |
| 79 |
switch (data[0]) |
| 80 |
{ |
| 81 |
case 0x20: |
| 82 |
default: |
| 83 |
t.type = TransType.Debit; // ��������� |
| 84 |
t.desc = "������"; |
| 85 |
t.value = - t.value; |
| 86 |
|
| 87 |
// ���������"������" ���������������Money ��������������������������������������������� |
| 88 |
// ������������������������������������������������������������ |
| 89 |
t.desc += " "; |
| 90 |
t.desc += t.id.ToString(); |
| 91 |
break; |
| 92 |
|
| 93 |
case 0x02: |
| 94 |
t.type = TransType.DirectDep; |
| 95 |
t.desc = "Edy������������"; |
| 96 |
break; |
| 97 |
|
| 98 |
case 0x04: |
| 99 |
t.type = TransType.DirectDep; |
| 100 |
t.desc = "Edy���������"; |
| 101 |
break; |
| 102 |
} |
| 103 |
t.memo = ""; |
| 104 |
|
| 105 |
return true; |
| 106 |
} |
| 107 |
} |
| 108 |
} |