Exemplo n.º 1
0
    public void SaveAccountData()
    {
        //GlobalLogon.Instance.AccountData = this;

        //因为有可能是临时的AccountData 所以只保存部分修改后的数据

        //将当前数据保存起来
        System.IO.MemoryStream ms = new System.IO.MemoryStream();
        System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms);

        KEY = ConstValue.FILE_END_MAGIC + 1;
        VER = ConstValue.FILE_VER;

        bw.Write(KEY);
        bw.Write(VER);
        bw.Write(TAG);
        bw.Write(AccountInfo.UID);
        bw.Write(bIsSavePassword);
        if (bIsSavePassword)
        {
            bw.Write(AccountInfo.CRC1);
            bw.Write(AccountInfo.CRC2);
            bw.Write(AccountInfo.CRC3);
        }
        else
        {
            bw.Write(0);
            bw.Write(0);
            bw.Write(0);
        }
        bw.Write(PhoneInfo.PhoneNumber);
        bw.Write(bIsSavePhonePassword);
        if (bIsSavePhonePassword)
        {
            bw.Write(PhoneInfo.phoneCRC1);
            bw.Write(PhoneInfo.phoneCRC2);
            bw.Write(PhoneInfo.phoneCRC3);
        }
        else
        {
            bw.Write(0);
            bw.Write(0);
            bw.Write(0);
        }
        RuntimeInfo.SaveLocalFile(RuntimeInfo.GetAccountFileName(), ms.ToArray());
        bw.Close();

        //string str = string.Format("账号:{0} 密码是是否为空 {1} 是否保存账号:{2} 手机账号:{3} 密码是否为空:{4} 是否保存手机账号:{5} ", AccountInfo.UID, AccountInfo.CRC1 == 0 && AccountInfo.CRC2 == 0 && AccountInfo.CRC3 == 0, bIsSavePassword, PhoneInfo.PhoneNumber, PhoneInfo.phoneCRC1 == 0 && PhoneInfo.phoneCRC2 == 0 && PhoneInfo.phoneCRC3 == 0, bIsSavePhonePassword);
        //LogMgr.Log(str);
    }
Exemplo n.º 2
0
    public void LoadAccountData()
    {
        byte[] data = RuntimeInfo.GetLocalFile(RuntimeInfo.GetAccountFileName());
        if (data == null)
        {
            Init();
            return;
        }
        System.IO.MemoryStream ms = new System.IO.MemoryStream(data);
        System.IO.BinaryReader br = new System.IO.BinaryReader(ms);
        this.KEY = br.ReadUInt32();
        if (this.KEY == ConstValue.FILE_END_MAGIC)
        {
            this.VER = br.ReadByte();
            this.TAG = br.ReadByte();

            this.AccountInfo.UID       = br.ReadString();
            this.bIsSavePassword       = true;
            this.AccountInfo.CRC1      = br.ReadUInt32();
            this.AccountInfo.CRC2      = br.ReadUInt32();
            this.AccountInfo.CRC3      = br.ReadUInt32();
            this.PhoneInfo.PhoneNumber = 0;
            this.bIsSavePhonePassword  = true;
            this.PhoneInfo.phoneCRC1   = 0;
            this.PhoneInfo.phoneCRC2   = 0;
            this.PhoneInfo.phoneCRC3   = 0;
        }
        else if (this.KEY == ConstValue.FILE_END_MAGIC + 1)
        {
            this.VER = br.ReadByte();
            this.TAG = br.ReadByte();

            this.AccountInfo.UID       = br.ReadString();
            this.bIsSavePassword       = br.ReadBoolean();
            this.AccountInfo.CRC1      = br.ReadUInt32();
            this.AccountInfo.CRC2      = br.ReadUInt32();
            this.AccountInfo.CRC3      = br.ReadUInt32();
            this.PhoneInfo.PhoneNumber = br.ReadUInt64();
            this.bIsSavePhonePassword  = br.ReadBoolean();
            this.PhoneInfo.phoneCRC1   = br.ReadUInt32();
            this.PhoneInfo.phoneCRC2   = br.ReadUInt32();
            this.PhoneInfo.phoneCRC3   = br.ReadUInt32();
        }
        ms.Close();
        br.Close();
    }