Exemple #1
0
        public bool Load()
        {
            try
            {
                if (DosUtils.FileExistFast(mFilename))
                {
                    string contents = DosUtils.FileRead(mFilename);
                    if (contents.Length > 0)
                    {
                        contents = MOG_Encryption.Decrypt(contents);

                        string[] parts = contents.Split("$".ToCharArray());

                        if (parts.Length >= 5)
                        {
                            Int64 savedChecksum = Int64.Parse(parts[0]);
                            mMacAddress         = parts[1];
                            mInstallDate        = DateTime.Parse(parts[2]);
                            mExpireDate         = DateTime.Parse(parts[3]);
                            mClientLicenseCount = Int32.Parse(parts[4]);
                            if (parts.Length >= 6)
                            {
                                mDisabledFeatureList = parts[5];
                            }

                            //generate a new checksum and compare it with the one we saved out
                            contents = contents.Substring(parts[0].Length + 1);
                            Int64 checksum = 0;
                            for (int i = 0; i < contents.Length; i++)
                            {
                                checksum += Convert.ToInt64(Char.GetNumericValue(contents[i]));
                            }

                            if (savedChecksum == checksum)
                            {
                                mIsLoaded = true;
                            }
                        }
                    }
                }
            }
            catch
            {
                mIsLoaded = false;
            }

            return(mIsLoaded);
        }