FoxB
February 22nd, 2012, 10:25
private bool ParseSiteCode(string pSiteCode)
{
bool flag;
try
{
if (pSiteCode.Length < 1)
{
return false;
}
string str = "";
int num2 = pSiteCode.Length - 1;
for (int i = 0; i <= num2; i++)
{
string sLeft = pSiteCode.Substring(i, 1).ToUpper();
if (((StringType.StrCmp(sLeft, "A", false) >= 0) & (StringType.StrCmp(sLeft, "F", false) <= 0)) | ((StringType.StrCmp(sLeft, "0", false) >= 0) & (StringType.StrCmp(sLeft, "9", false) <= 0)))
{
str = str + sLeft;
}
}
pSiteCode = str;
if (!this.ValidateSiteCode(pSiteCode))
{
throw new ApplicationException("Site Code is not a valid site code"

;
}
pSiteCode = new dlxEncryptionTools().UnScrambleString(dlxConversionTools.GetBitStringFromHexString(pSiteCode.Substri ng(0, pSiteCode.Length - 4)), 3);
this.mstrMachineHashCode = pSiteCode.Substring(0, 0x15) + "000";
this.mstrMachineHashCode = dlxConversionTools.GetHexStringFromBitString(this.mstrMachineHashCode);
string str3 = pSiteCode.Substring(0x15, 13);
this.mdtePrevAuthorizationDate = DateAndTime.DateAdd(DateInterval.Day, (double) dlxConversionTools.GetIntegerFromBitString(str3), new DateTime(0x8c6bdabf8998000L));
this.mintExeID = dlxConversionTools.GetIntegerFromBitString(pSiteCode.Substring(0x22, 8));
this.mintDateExceptionCount = dlxConversionTools.GetIntegerFromBitString(pSiteCode.Substring(0x2a, 8));
this.mbytMajor = (byte) dlxConversionTools.GetIntegerFromBitString("00" + pSiteCode.Substring(50, 6));
this.mbytMinor = (byte) dlxConversionTools.GetIntegerFromBitString(pSiteCode.Substring(0x38, 8));
this.mbytRevision = (byte) dlxConversionTools.GetIntegerFromBitString(pSiteCode.Substring(0x40, 8));
return true;
}
catch (Exception exception1)
{
ProjectData.SetProjectError(exception1);
Exception innerException = exception1;
throw new ApplicationException("Exception while parsing site Code; '" + pSiteCode + "'", innerException);
ProjectData.ClearProjectError();
}
return flag;
}
private bool ValidateSiteCode(string pSiteCode)
{
if (pSiteCode.Length <= 5)
{
throw new ArgumentException("String is not a valid Site Code"

;
}
string sLeft = pSiteCode.Substring(pSiteCode.Length - 4);
object obj2 = pSiteCode.Substring(0, pSiteCode.Length - 4);
return (StringType.StrCmp(sLeft, this.GetHash(StringType.FromObject(obj2), 4, ""

, false) == 0);
}