Last active
August 29, 2015 14:07
-
-
Save kcuzner/49322aa592055743e921 to your computer and use it in GitHub Desktop.
UniFile decompilation showing the difference between Read and ReadRecords
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
namespace IBMU2.UODOTNET | |
{ | |
public class UniFile : UniRoot | |
{ | |
//... lots of stuff | |
/// <summary> | |
/// Reads the UniVerse record from this file. It uses the record ID established via | |
/// the <c>RecordID</c> property. | |
/// </summary> | |
/// <returns>Record Data as UniDynArray object</returns> | |
/// <exception cref="T:IBMU2.UODOTNET.UniFileException">Thrown when Read() fails.</exception> | |
public UniDynArray Read() | |
{ | |
UniRPCPMessage obj = null; | |
Monitor.Enter(this); | |
UniDynArray uniRecord; | |
try | |
{ | |
UniRoot.UniLog(UniRoot.UniTraceLevel.UO_INFO, "Enter UniFile::Read()"); | |
this.CheckEntryConditions(true, true); | |
this.m_UniRecord = null; | |
try | |
{ | |
UniRPCPacket inPacket = this.m_Session.UniRPCConnection.InPacket; | |
UniRPCPacket outPacket = this.m_Session.UniRPCConnection.OutPacket; | |
obj = outPacket.UniRPCPMessage; | |
Monitor.Enter(obj); | |
outPacket.UniRPCPMessage.WriteInteger(0, 37); | |
outPacket.UniRPCPMessage.WriteInteger(1, this.m_UniFileHandle); | |
outPacket.UniRPCPMessage.WriteInteger(2, this.FindReadLock()); | |
outPacket.UniRPCPMessage.WriteByteArray(3, this.m_Session.UniCodeStringToByteArray(this.m_UniRecordID)); | |
this.m_Session.UniRPCConnection.Call((byte)this.m_FileEncryptionType); | |
this.m_UniFileReturnCode = inPacket.UniRPCPMessage.ReadInteger(0); | |
this.m_UniFileStatus = inPacket.UniRPCPMessage.ReadInteger(1); | |
if (this.m_UniFileReturnCode == 0) | |
{ | |
byte[] pData = inPacket.UniRPCPMessage.ReadByteArray(2); | |
this.m_UniRecord = new UniDynArray(this.m_Session, pData); | |
this.Lock(); | |
this.DoReadRelease(); | |
UniRoot.UniLog(UniRoot.UniTraceLevel.UO_INFO, "Exit UniFile::Read()"); | |
uniRecord = this.m_UniRecord; | |
} | |
else | |
{ | |
int uniFileReturnCode = this.m_UniFileReturnCode; | |
if (uniFileReturnCode == 14005) | |
{ | |
string str; | |
switch (this.m_UniFileStatus) | |
{ | |
case 1: | |
str = "A bad partitioning algorithm exists for this file"; | |
break; | |
case 2: | |
str = "No such part file"; | |
break; | |
case 3: | |
str = "Record ID contains unmappable NLS characters"; | |
break; | |
case 4: | |
str = "Record data contains unmappable NLS characters"; | |
break; | |
default: | |
str = "An IO Error has occured"; | |
break; | |
} | |
string message = str + UniErrorMessage.GetErrorMessage(14005); | |
UniFileException ex = new UniFileException(message); | |
string message2 = ex.Message + " Source: " + ex.Source + " Method: UniDynArray \tRead()"; | |
UniRoot.UniLog(UniRoot.UniTraceLevel.UO_ERROR, message2); | |
throw ex; | |
} | |
string errorMessage = UniErrorMessage.GetErrorMessage(this.m_UniFileReturnCode); | |
UniFileException ex2 = new UniFileException(errorMessage); | |
string message3 = ex2.Message + " Source: " + ex2.Source + " Method: UniDynArray \tRead()"; | |
UniRoot.UniLog(UniRoot.UniTraceLevel.UO_ERROR, message3); | |
throw ex2; | |
} | |
} | |
catch (UniRPCConnectionException ex3) | |
{ | |
string message4 = ex3.Message + this.m_UniFileName; | |
UniRoot.UniLog(UniRoot.UniTraceLevel.UO_ERROR, message4); | |
this.m_Session.IsRPCError = true; | |
throw new UniFileException(message4); | |
} | |
finally | |
{ | |
Monitor.Exit(obj); | |
} | |
} | |
finally | |
{ | |
Monitor.Exit(this); | |
} | |
return uniRecord; | |
} | |
//... lots of stuff | |
private UniDataSet ReadRecordsInternal(string[] aRecordIDSet, int optionalRecordSeparator) | |
{ | |
UniRPCPMessage obj = null; | |
Monitor.Enter(this); | |
UniDataSet result; | |
try | |
{ | |
UniRoot.UniLog(UniRoot.UniTraceLevel.UO_INFO, "Enter UniFile::Read( string[] aRecordIDSet)"); | |
this.CheckEntryConditions(true, false); | |
byte[] delimitedByteArrayRecordID = this.m_Session.GetDelimitedByteArrayRecordID(aRecordIDSet, 0); | |
try | |
{ | |
UniRPCPacket inPacket = this.m_Session.UniRPCConnection.InPacket; | |
UniRPCPacket outPacket = this.m_Session.UniRPCConnection.OutPacket; | |
obj = outPacket.UniRPCPMessage; | |
Monitor.Enter(obj); | |
outPacket.UniRPCPMessage.WriteInteger(0, 76); | |
outPacket.UniRPCPMessage.WriteInteger(1, this.m_UniFileHandle); | |
outPacket.UniRPCPMessage.WriteInteger(2, this.FindReadLock()); | |
outPacket.UniRPCPMessage.WriteByteArray(3, delimitedByteArrayRecordID); | |
outPacket.UniRPCPMessage.WriteByteArray(4, this.m_Session.UniCodeStringToByteArray(string.Empty)); | |
this.m_Session.UniRPCConnection.Call((byte)this.m_FileEncryptionType); | |
this.m_UniFileReturnCode = inPacket.UniRPCPMessage.ReadInteger(0); | |
byte[] retValData = inPacket.UniRPCPMessage.ReadByteArray(1); | |
byte[] statusData = inPacket.UniRPCPMessage.ReadByteArray(2); | |
byte[] retData = inPacket.UniRPCPMessage.ReadByteArray(3); | |
UniDataSet uniDataSet; | |
if (optionalRecordSeparator == 0) | |
{ | |
uniDataSet = this.m_Session.CreateUniDataSet(aRecordIDSet, retData, statusData, retValData); | |
} | |
else | |
{ | |
uniDataSet = this.m_Session.CreateUniDataSet(aRecordIDSet, retData, statusData, retValData, optionalRecordSeparator); | |
} | |
UniRoot.UniLog(UniRoot.UniTraceLevel.UO_INFO, "Exit UniFile::Read( string[] aRecordIDSet)"); | |
result = uniDataSet; | |
} | |
catch (UniRPCConnectionException ex) | |
{ | |
string message = ex.Message + this.m_UniFileName; | |
UniRoot.UniLog(UniRoot.UniTraceLevel.UO_ERROR, message); | |
this.m_Session.IsRPCError = true; | |
throw new UniFileException(message); | |
} | |
catch (UniDataSetException ex2) | |
{ | |
string message2 = string.Concat(new object[] | |
{ | |
ex2.Message, | |
" Source: ", | |
ex2.Source, | |
" Method: ", | |
ex2.TargetSite | |
}); | |
UniRoot.UniLog(UniRoot.UniTraceLevel.UO_ERROR, message2); | |
throw new UniFileException(message2); | |
} | |
finally | |
{ | |
Monitor.Exit(obj); | |
} | |
} | |
finally | |
{ | |
Monitor.Exit(this); | |
} | |
return result; | |
} | |
//... lots of stuf | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment