| 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 |
ident = "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 |
cardId = ""; |
| 49 |
for (int i = 2; i < 10; i++) { |
| 50 |
cardId += data[i].ToString("X2"); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
public override bool analyzeTransaction(Transaction t, byte[] data) |
| 55 |
{ |
| 56 |
// ������ |
| 57 |
int value = (data[4] << 24) + (data[5] << 16) + (data[6] << 8) + data[7]; |
| 58 |
|
| 59 |
t.date = new DateTime(2000, 1, 1); |
| 60 |
|
| 61 |
t.date += TimeSpan.FromDays(value >> 17); |
| 62 |
t.date += TimeSpan.FromSeconds(value & 0x1fff); |
| 63 |
|
| 64 |
// ������ |
| 65 |
t.value = (data[8] << 24) + (data[9] << 16) + (data[10] << 8) + data[11]; |
| 66 |
|
| 67 |
// ������ |
| 68 |
t.balance = (data[12] << 24) + (data[13] << 16) + (data[14] << 8) + data[15]; |
| 69 |
|
| 70 |
// ������ |
| 71 |
t.id = (data[1] << 16) + (data[2] << 8) + data[3]; |
| 72 |
|
| 73 |
// ������ |
| 74 |
switch (data[0]) |
| 75 |
{ |
| 76 |
case 0x20: |
| 77 |
default: |
| 78 |
t.type = TransType.Debit; // ��������� |
| 79 |
t.desc = "������"; |
| 80 |
t.value = - t.value; |
| 81 |
|
| 82 |
// ���������"������" ���������������Money ��������������������������������������������� |
| 83 |
// ������������������������������������������������������������ |
| 84 |
t.desc += " "; |
| 85 |
t.desc += t.id.ToString(); |
| 86 |
break; |
| 87 |
|
| 88 |
case 0x02: |
| 89 |
t.type = TransType.DirectDep; |
| 90 |
t.desc = "Edy������������"; |
| 91 |
break; |
| 92 |
|
| 93 |
case 0x04: |
| 94 |
t.type = TransType.DirectDep; |
| 95 |
t.desc = "Edy���������"; |
| 96 |
break; |
| 97 |
} |
| 98 |
t.memo = ""; |
| 99 |
|
| 100 |
return true; |
| 101 |
} |
| 102 |
} |
| 103 |
} |