2012-05-15 4 views
0

code.google에서 코드를 다운로드하고 마지막 버전 v0.5.2을 가져옵니다.
bcd 형식의 필드를 bcd 형식의 N-6 (bit._003_proc_code)으로 설정했습니다. 예) 용
:
* 필드 정의 :
DefaultTemplate = 새로운 템플릿 {{ Bit._002_PAN, FieldDescriptor.BcdVar (2, 19, Formatters.Ascii)}, { Bit._003_PROC_CODE, FieldDescriptor.BcdFixed (3)}, {Bit._004_TRAN_AMOUNT, FieldDescriptor.BcdFixed (6)}, .............. }OpenISO8583.Net BCD 수정 형식의 언팩 오류

사용 : 내가 메시지를 압축을 풀 때

Iso8583 msg =new Iso8584(); 
msg[3]="000000"; 

, 난 단지 메시지 3에서 "0000"얻을 수 있습니다.
이것은 버그 또는 정의 오류입니다.

답변

0

John Oxley의 의견을 기다리면서 코딩 오류 일뿐입니다. 이제 나는 그것이 버그라고 생각한다.

BcdFixed 정의에 문제가있어서이 문제를 해결하기 위해 새로운 고정 길이 BCD 포맷터를 작성했습니다. 여기

내가 무슨 짓을 :

  1. 내가 FixedLengthFormatter 클래스의 변형입니다 FixedLengthBcdFormatter라는 클래스를 만들었습니다.

    /// /// 고정 필드 형식화 /// 공용 클래스 FixedLengthBcdFormatter : ILengthFormatter { 개인 읽기 전용의 INT의 _packedLength; private 읽기 전용 int _unPackedLength;

    ///<summary> 
    /// Fixed length field formatter 
    ///</summary> 
    ///<param name = "unPackedLength">The unpacked length of the field.</param> 
    public FixedLengthBcdFormatter(int unPackedLength) 
    { 
        _unPackedLength = unPackedLength; 
        double len = _unPackedLength; 
        _packedLength = (int)Math.Ceiling(len/2); 
    } 
    
    #region ILengthFormatter Members 
    
    /// <summary> 
    /// Get the length of the packed length indicator. For fixed length fields this is 0 
    /// </summary> 
    public int LengthOfLengthIndicator 
    { 
        get { return 0; } 
    } 
    
    /// <summary> 
    /// The maximum length of the field displayed as a string for descriptors 
    /// </summary> 
    public string MaxLength 
    { 
        get { return _unPackedLength.ToString(); } 
    } 
    
    /// <summary> 
    /// Descriptor for the length formatter used in ToString methods 
    /// </summary> 
    public string Description 
    { 
        get { return "FixedBcd"; } 
    } 
    
    /// <summary> 
    /// Get the length of the field 
    /// </summary> 
    /// <param name = "msg">Byte array of message data</param> 
    /// <param name = "offset">offset to start parsing</param> 
    /// <returns>The length of the field</returns> 
    public int GetLengthOfField(byte[] msg, int offset) 
    { 
        return _unPackedLength; 
    } 
    
    /// <summary> 
    /// Pack the length header into the message 
    /// </summary> 
    /// <param name = "msg">Byte array of the message</param> 
    /// <param name = "length">The length to pack into the message</param> 
    /// <param name = "offset">Offset to start the packing</param> 
    /// <returns>offset for the start of the field</returns> 
    public int Pack(byte[] msg, int length, int offset) 
    { 
        return offset; 
    } 
    
    /// <summary> 
    /// Check the length of the field is valid 
    /// </summary> 
    /// <param name = "packedLength">the packed length of the field</param> 
    /// <returns>true if valid, false otherwise</returns> 
    public bool IsValidLength(int packedLength) 
    { 
        return packedLength == _packedLength; 
    } 
    
    #endregion 
    

  2. }
  3. 는 FieldDescription 클래스/BcdFixed 선언

    /// /// 고정 BCD를 수정. /// /// /// 길이입니다. /// /// /// 공공 정적 IFieldDescriptor BcdFixed (INT unpackedLength) { 복귀 만들기 (새 FixedLengthBcdFormatter (unpackedLength), FieldValidators.N, Formatters.Bcd, NULL); }

  4. 그런 다음 포맷터 선언을 변경하여 압축 해제 길이를 매개 변수로 제공하십시오. 내가 기존 코드에 대해 뭔가를 알고하지 않았기 때문에

    Bit._003_PROC_CODE, FieldDescriptor.BcdFixed (6)}, 다시

는이 모든 불필요한되었을 수도 있지만, 나를 위해 노력하고 있습니다.

이 정보가 도움이되기를 바랍니다.