From d38f7afeab24247d69bf0f1de6cf52e9e1352e34 Mon Sep 17 00:00:00 2001 From: Kathy Date: Tue, 24 Aug 2010 13:39:50 +0000 Subject: [PATCH] --- PROMS/DataLoader/FixItem.cs | 82 +++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 PROMS/DataLoader/FixItem.cs diff --git a/PROMS/DataLoader/FixItem.cs b/PROMS/DataLoader/FixItem.cs new file mode 100644 index 00000000..271544fd --- /dev/null +++ b/PROMS/DataLoader/FixItem.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; + +namespace DataLoader +{ + public class FixItems : List + { + public FixItems(FileInfo myFile):base() + { + FileStream fs = myFile.OpenRead(); + int len = (int) myFile.Length; + byte [] buffer = new byte[len]; + fs.Read(buffer, 0, len); + int offset = 0; + while(offset < len) + { + int lFixItem = (int)(buffer[offset]); + Add(new FixItem(buffer,offset)); + offset += lFixItem + 1; + } + } + } + public class FixItem + { + public FixItem(byte[] buffer, int offset) + { + int lFixItem = (int)(buffer[offset]); + _Section = (char)(buffer[offset + 1]); + _Step = (int)(buffer[offset + 2]); + string str = System.Text.Encoding.GetEncoding(1251).GetString(buffer, offset + 3, lFixItem - 2); + if (str.Contains(" ")) + { + int index = str.IndexOf(" "); + string [] parts = str.Substring(index + 1).Split("\\".ToCharArray()); + _Sequence = str.Substring(0, index); + if (parts.Length > 0) _Rev = parts[0]; + if (parts.Length > 1) _RevDate = parts[1]; + if (parts.Length > 2) _ReviewDate = parts[2]; + } + else + _Sequence = str; + } + private char _Section; + public char Section + { + get { return _Section; } + set { _Section = value; } + } + private int _Step; + public int Step + { + get { return _Step; } + set { _Step = value; } + } + private string _Sequence; + public string Sequence + { + get { return _Sequence; } + set { _Sequence = value; } + } + private string _Rev; + public string Rev + { + get { return _Rev; } + set { _Rev = value; } + } + private string _RevDate; + public string RevDate + { + get { return _RevDate; } + set { _RevDate = value; } + } + private string _ReviewDate; + public string ReviewDate + { + get { return _ReviewDate; } + set { _ReviewDate = value; } + } + } +}