示例#1
0
        /// <summary>
        ///     检查记住的用户。
        /// </summary>
        private void CheckRememberUser(bool autoLogin = true)
        {
            try
            {
                var userDataFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, GlobalUser.DATAFOLDER,
                                                "user.dat");

                if (File.Exists(userDataFile))
                {
                    using (var streamReader = new StreamReader(userDataFile))
                    {
                        var userEncoded = streamReader.ReadToEnd();
                        if (!string.IsNullOrEmpty(userEncoded))
                        {
                            var userData =
                                Base64Provider.AESDecrypt(userEncoded, Base64Provider.KEY, Base64Provider.IV);
                            var userDataModel = userData.FromJsonTo <UserDataModel>();
                            if (!string.IsNullOrEmpty(userDataModel?.Phone))
                            {
                                GlobalUser.USER          = userDataModel?.Data;
                                GlobalUser.USER.Mobile   = PhoneNum = userDataModel?.Phone;
                                GlobalUser.USER.Password = Pwd = userDataModel?.Password;
                                GlobalUser.USER.UserZy   = userDataModel?.UserZy == null
                                    ? new List <TaskInfo>()
                                    : userDataModel?.UserZy;
                                GlobalUser.USER.UnFirstOpen = userDataModel.UnFirstOpen;

                                if (!string.IsNullOrEmpty(userDataModel?.AccessToken))
                                {
                                    GlobalUser.CLASSINFO = userDataModel?.ClassData;
                                    GlobalUser.STUDYCARD = userDataModel?.StudyCard;
                                    GlobalUser.GRADEINFO = userDataModel?.GradeData;

                                    GlobalUser.USER.Expire_status = GlobalUser.STUDYCARD.expire_status;


                                    var windows = Application.Current.Windows;
                                    //GlobalUser.LoginWin = new Window();
                                    //foreach (Window window in windows)
                                    //    if (window.Name == "ml")
                                    //        GlobalUser.LoginWin = window;
                                    GlobalUser.AutoLoggedIn = true;
                                    checkOK = true;
                                    if (autoLogin)
                                    {
                                        LoggedIn(GlobalUser.LoginWin);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log4NetHelper.Error("读取用户信息异常:", e);
            }
        }
示例#2
0
        /// <summary>
        /// 检查记住的用户。
        /// </summary>
        private void CheckRememberUser()
        {
            try
            {
                string userDataFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, GlobalUser.DATAFOLDER, $"user.dat");

                if (File.Exists(userDataFile))
                {
                    using (StreamReader streamReader = new StreamReader(userDataFile))
                    {
                        string userEncoded = streamReader.ReadToEnd();
                        if (!String.IsNullOrEmpty(userEncoded))
                        {
                            string        userData      = Base64Provider.AESDecrypt(userEncoded, Base64Provider.KEY, Base64Provider.IV);
                            UserDataModel userDataModel = userData.FromJsonTo <UserDataModel>();
                            if (!String.IsNullOrEmpty(userDataModel?.Phone))
                            {
                                PhoneNum = userDataModel?.Phone;
                                if (!String.IsNullOrEmpty(userDataModel?.AccessToken))
                                {
                                    GlobalUser.USER = userDataModel?.Data;

                                    var windows  = Application.Current.Windows;
                                    var loginWin = new Window();
                                    foreach (Window window in windows)
                                    {
                                        if (window.Name == "ml")
                                        {
                                            loginWin = window as Window;
                                        }
                                    }
                                    GlobalUser.AutoLoggedIn = true;
                                    checkOK = true;
                                    LoggedIn(loginWin);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log4NetHelper.Error("读取用户信息异常:", e);
            }
        }
示例#3
0
        /// <summary>
        /// 读取 错误评分你记录
        /// </summary>
        /// <param name="user"></param>
        /// <param name="paperid"></param>
        /// <param name="attendid"></param>
        public static void GetErrorScoreSource(string user, string paperid, string attendid)
        {
            var    filePath  = Path.Combine(GlobalUser.AUDIODATAFOLDER, $"{user}_{paperid.Split(new[] { "#" }, StringSplitOptions.RemoveEmptyEntries)[0]}_{attendid}");
            string errjson_e = "";

            if (!File.Exists(filePath))
            {
                return;
            }

            using (StreamReader sr = new StreamReader(filePath))
            {
                while (!sr.EndOfStream)
                {
                    errjson_e = sr.ReadToEnd();
                }
            }

            var errjson = Base64Provider.AESDecrypt(errjson_e);

            Dictionary <string, dynamic> dic = JsonHelper.FromJson <Dictionary <string, dynamic> >(errjson);

            if (dic.Count > 0)
            {
                ErrScoreInfo = new Dictionary <string, ExamScoreNavigateMessage>();

                foreach (var key in dic.Keys)
                {
                    var val = dic[key];

                    ExamScoreNavigateMessage enm = new ExamScoreNavigateMessage(JsonHelper.FromJson <SubmitRecordModel>(val.AnswerModel.ToString()),
                                                                                val.WaveFileName.ToString(),
                                                                                Enum.Parse(typeof(Framework.Engine.EngineQsType), val.QsType.ToString()),
                                                                                val.EType.ToString(),
                                                                                val.QType.ToString()
                                                                                );
                    enm.SubmitNum = Int32.Parse(val.SubmitNum.ToString());

                    ErrScoreInfo.Add(key, enm);
                }
            }
        }