BinaryReader br = new BinaryReader(new FileStream(dwg.FullName, FileMode.Open, FileAccess.Read));
char[] _versionId = br.ReadChars(6);
string versionId = "";
foreach(char ch in _versionId)
{
versionId += ch;
}
if (!versionId.Equals("AC1015", StringComparison.InvariantCultureIgnoreCase))
{
continue;
}
// six bytes of 0 (in R14, 5 0’s and the ACADMAINTVER variable) and a byte of 1
br.ReadBytes(7);
//Image seeker
int imageSeeker = br.ReadInt32();
// Unknown section
br.ReadBytes(2);
// Dwgcodepage
br.ReadBytes(2);
int objectmapSeeker = 0;
int count = br.ReadInt32();
for (int i = 0; i < count; i++)
{
byte recnum = br.ReadByte();
int seeker = br.ReadInt32();
int size = br.ReadInt32();
switch (recnum)
{
case 0:
//System.Diagnostics.Debug.Print("Header variables")
break;
case 1:
//System.Diagnostics.Debug.Print("Class section")
break;
case 2:
//System.Diagnostics.Debug.Print("Object map")
objectmapSeeker = seeker;
break;
case 3:
//'System.Diagnostics.Debug.Print("Unknown")
break;
case 4:
//'System.Diagnostics.Debug.Print("R14DATA")
break;
case 5:
//System.Diagnostics.Debug.Print("R14REC5")
break;
default:
continue;
}
}
br.BaseStream.Seek(imageSeeker, SeekOrigin.Begin);
byte[] mask = new byte[] { 87, 71, 80, 82, 79, 80, 83, 32, 67, 79, 79, 75, 73, 69 };
while (br.BaseStream.Position < objectmapSeeker)
{
// Search DWGPROPS COOKIE
byte d = br.ReadByte();
if (d != 68)
{
break;
}
byte[] test = br.ReadBytes(mask.Length);
bool temp = false;
for (int i = 0; i < mask.Length; i++)
{
if (test[i] != mask[i])
{
br.BaseStream.Seek(-mask.Length, SeekOrigin.Current);
temp = true;
break;
}
}
if (temp)
{
break;
}
//------------------------------------------------------------
// Predefined properties, in this order:
// title, subject, author, comments, keywords,
// lastSavedBy, revisionNumber
// DXF codes : 2, 3, 4, 6, 7, 8, 9
for (int i = 0; i < 7; i++)
{
short code = br.ReadInt16(); // DXF code
short len = br.ReadInt16(); // String lenght
br.ReadByte(); // ?
byte[] bytes = br.ReadBytes(len);
string value = Encoding.ASCII.GetString(bytes);
System.Diagnostics.Debug.Print(value);
}
//------------------------------------------------------------
// 10 custom properties in the format:
// <name=value>
// DXF codes : 300, 301, 302, 303, 304, 305, 306, 307, 308, 309
for (int i = 0; i < 10; i++)
{
short code = br.ReadInt16(); // DXF code
short len = br.ReadInt16(); // String lenght
br.ReadByte(); // ?
byte[] bytes = br.ReadBytes(len);
string value = Encoding.ASCII.GetString(bytes);
//Dim pairs() As String = value.Split(New Char() {"="c})
System.Diagnostics.Debug.Print(value);
}
// Total editing time, Create date time and Modified
// date time in the format:
// <Julian day number>.<Decimal fraction of a day>
// DXF codes: 40, 41 ,42
for (int i = 0; i < 3; i++)
{
short code = br.ReadInt16(); // DXF code
double value = br.ReadDouble(); // Value
System.Diagnostics.Debug.Print(value.ToString());
}
//------------------------------------------------------------
// hyperlinkBase
// DXF code: 1
short c = br.ReadInt16(); // DXF code
short l = br.ReadInt16(); // String lenght
br.ReadByte(); // ? Unknow
byte[] b = br.ReadBytes(l);
string v = Encoding.ASCII.GetString(b);
System.Diagnostics.Debug.Print(v);
//------------------------------------------------------------
}
KeyValuePair <string, string> TempHashSym;
if (Guids.TryGetValue(guid, out TempHashSym) || NameDates.ContainsKey(nameDate))
{
FilesArray.Remove(guid);
FileStatus = "Unchange";
if (TempHashSym.Value != string.Empty)
{
CurrentHashSym = TempHashSym.Value;
}
else
{
CurrentHashSym = Guids[NameDates[nameDate]].Value;
}
Log.Error(dwg.FullName + " Сохранена предыдущая версия из базы ");
result.Unchange.Add(dwg.FullName, new FilesState.FileInform(dwg.FullName, tempFullName, CurrentHashSym, directory));
}
else
{
continue;
}