Ejemplo n.º 1
0
        public void OnUsersDataReaderEventStatus(string fname, FileDataType dtype, FileTaskStatus status, object data)
        {
            //检查是否当前文件

            {
                switch (status)
                {
                case FileTaskStatus.Progressing:
                {
                    break;
                }

                case FileTaskStatus.Success:
                {
                    {
                        JObject   jdata      = data as JObject;
                        int       vercode    = JsonHelper.GetInteger(jdata, ClientConfig.KEY_DATA_VERSION_CODE);
                        UsersData _usersData = new UsersData(jdata, vercode);

                        //对旧数据整体迁移加密之后回存;
                        if (vercode != ClientConfig.DataVersionCode)
                        {
                            fname = string.Format("{0}/{1}.txt", Application.dataPath + filePath, "userinfo");
                            if (File.Exists(fname))
                            {
                                File.Delete(fname);
                            }

                            fname = string.Format("{0}/{1}.ts", Application.dataPath + filePath, "userinfo");


                            FileManager.Instance.AsyncWriteEncryptZipJsonObject(fname, _usersData.Serialize(ClientConfig.DataVersionCode), null);
                        }
                        Debug.LogError("_usersData:" + _usersData.CurrentUserID);
                        //ApplicationUI.Instance.closeWindowObject(WINDOWOBJECT_TYPE.PROGRESSWINDOW, SHOW_EFFECT.NONE, true);
                    }

                    break;
                }

                case FileTaskStatus.Failed:
                {
                    //*_*ApplicationUI.Instance.closeWindowObject(WINDOWOBJECT_TYPE.PROGRESSWINDOW, SHOW_EFFECT.NONE, true);
                    //*_*PromptManager.Instance.ShowPrompt(5019, null, null, null);
                    break;
                }
                }
            }
        }
Ejemplo n.º 2
0
        void OnGUI()
        {
            if (GUILayout.Button("保存json数据"))
            {
                usersData = new UsersData();
                UserInfo userInfo = new UserInfo();

                userInfo.userBaseInfo.firstName = "Coach";
                userInfo.userBaseInfo.email     = "*****@*****.**";
                userInfo.userBaseInfo.coachID   = userInfo.userBaseInfo.email;


                usersData.DefalutUserID = userInfo.userBaseInfo.email;

                userInfo.userBaseInfo.userType = UserType.Coach;
                usersData.userList.Add(userInfo);
                usersData.CurrentUserID      = userInfo.userBaseInfo.email;
                usersData.CurrentApplyUserID = userInfo.userBaseInfo.email;


                UserInfo studentInfo = new UserInfo();
                studentInfo.userBaseInfo.firstName = "Demo";
                studentInfo.userBaseInfo.email     = "*****@*****.**";
                studentInfo.userBaseInfo.coachID   = userInfo.userBaseInfo.email;


                usersData.DefalutUserID = studentInfo.userBaseInfo.email;

                studentInfo.userBaseInfo.userType = UserType.Student;
                usersData.userList.Add(studentInfo);

                usersData.CurrentUserID      = studentInfo.userBaseInfo.email;
                usersData.CurrentApplyUserID = studentInfo.userBaseInfo.email;

                SaveUserData();
            }
            if (GUILayout.Button("读取json文件"))
            {
                UsersData usersData = ReadUsersData();
                Debug.LogError("usersData.CurrentUserID: " + usersData.CurrentUserID);
            }

            if (GUILayout.Button("异步读取json"))
            {
                AsyncReadUsersData(OnUsersDataReaderEventStatus);
            }
        }