Esempio n. 1
0
        /// <summary>
        /// 创建或修改用户本地信息
        /// </summary>
        /// <param name="path"></param>
        /// <param name="userLocalInfo"></param>
        public static void createOrModifyUserLocalInfo(UserLocalInfo userLocalInfo)
        {
            if (!Directory.Exists(PATH_USER + "/" + userLocalInfo.UserId))
            {
                Directory.CreateDirectory(PATH_USER + "/" + userLocalInfo.UserId);
            }
            if (!Directory.Exists(PATH_USER + "/" + userLocalInfo.UserId + "/" + NAME_FOLDER_SYNC))
            {
                Directory.CreateDirectory(PATH_USER + "/" + userLocalInfo.UserId + "/" + NAME_FOLDER_SYNC);
            }
            UserLocalInfo user_localInfo = userLocalInfo;
            /* 设置起始默认同步目录 */
            UserLocalInfo temp = getUserLocalInfo(userLocalInfo.UserId);

            if (temp == null)
            {
                user_localInfo.SyncPath = PATH_USER + "/" + user_localInfo.UserId + "/" + NAME_FOLDER_SYNC;
            }
            else if (temp.SyncPath == null || (!Directory.Exists(temp.SyncPath)))
            {
                user_localInfo.SyncPath = Path.GetFullPath(PATH_USER + "/" + user_localInfo.UserId + "/" + NAME_FOLDER_SYNC);
            }
            StreamWriter infoWriter = new StreamWriter(PATH_USER + "/" + userLocalInfo.UserId + "/" + NAME_USER_INFO,
                                                       false, Encoding.Default);

            infoWriter.Write(Int32Dec64Convert.encryptSerialToBase64Code(JsonHelper.getSerializeString(user_localInfo), PASSWORD_USER_FILE_ENCRYPTION, 0x400));
            infoWriter.Close();
        }
Esempio n. 2
0
        /// <summary>
        /// 获取用户本地信息
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static UserLocalInfo getUserLocalInfo(string userID)
        {
            if (!File.Exists(PATH_USER + "/" + userID + "/" + NAME_USER_INFO))
            {
                return(null);
            }
            StreamReader infoReader = new StreamReader(PATH_USER + "/" + userID + "/" + NAME_USER_INFO, Encoding.Default);
            string       serial     = infoReader.ReadToEnd();

            infoReader.Close();
            serial = Int32Dec64Convert.discryptBase64CodeToSerial(serial, PASSWORD_USER_FILE_ENCRYPTION);
            return(JsonHelper.getDeserializeObject <UserLocalInfo>(serial));
        }