
cleaned up stored procedures and functions Added new settings to control conversion of approved data Handle file missing
85 lines
1.8 KiB
C#
85 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.IO;
|
|
|
|
namespace DataLoader
|
|
{
|
|
public class FixItems : List<FixItem>
|
|
{
|
|
public FixItems(FileInfo myFile):base()
|
|
{
|
|
if (!myFile.Exists)
|
|
return;
|
|
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; }
|
|
}
|
|
}
|
|
}
|