public void SetAccountState(Account account) { Account a = AccountList.FirstOrDefault(x => x.UserName == account.UserName); if (a != null) { a.IsWorking = account.IsWorking; a.IsFinished = account.IsFinished; } LocalDataHandler.SetData("data.db", "accounts", allList); }
public ActionResult Index(LoginViewModel user) { //#if DEBUG // user.USR_ID = "admin"; // user.USR_PW = "00000"; //#endif string errMsg = ""; var userLogin = AccountList.FirstOrDefault(x => x.Acc == user.USR_ID && x.Psw == user.USR_PW); //var model = _LoginService.GetGroup(user.USR_ID, user.USR_PW); //if (!(user.USR_ID == "admin" && user.USR_PW == "00000")) //{ // errMsg = "帳號或密碼錯誤"; //} if (userLogin == null) { errMsg = "帳號或密碼錯誤"; } if (!string.IsNullOrWhiteSpace(errMsg))//錯誤訊息 { TempData["LoginMsg"] = new List <string>() { errMsg }; return(View()); } //設立登入者 var info = new SettingUserInfo() { Info = new SettingUserInfo.DataStruct() { Id = userLogin.Acc, Name = userLogin.Psw, Permission = userLogin.Permission, LanguageType = user.Lang_TP //PermissionsList = model.Data.Permissions, //AllPermissionsList = model.Data.AllPermissions } }; return(RedirectToAction("Index", "Home")); }
IAccount GetAccount(string currency) { var account = AccountList.FirstOrDefault(v => v.CurrentCurrency == currency); if (account == null) { if (!IsUnlimited) { return(null); } else { account = new Account() { CurrentCurrency = currency, IsUnlimited = true, Quantity = 0 } }; } return(account); }
public bool ProcessMoney(Money money) { var m = AccountList.FirstOrDefault(v => v.CurrentCurrency == money.FxCode); if (m == null) { m = new Account() { CurrentCurrency = money.FxCode, Quantity = money.Number }; AccountList.Add(m); } else { if (!m.IsValidModify(money)) { return(false); } m.ObtainMoney(money); } return(true); }
private void OnSearchComplete(object sender, UploadDataCompletedEventArgs e) { if (e.Error == null) { JsonNerbyuser resusers = new JsonNerbyuser(); var str = Encoding.UTF8.GetString(e.Result); //转byte为字符串 resusers = JsonConvert.DeserializeObject <JsonNerbyuser>(str); //反序列化 if (resusers.resultCode == 1) { List <DownLoadFile> files = new List <DownLoadFile>(); if (resusers.data.Count > 0) { for (int i = 0; i < resusers.data.Count; i++) { AccountList.Add(resusers.data[i]); //这里需要把特殊账号 排除出来。 string localpath = Applicate.LocalConfigData.GetDisplayAvatorPath(resusers.data[i].userId); if (!File.Exists(localpath))//添加需要下载的头像 { files.Add(new DownLoadFile { Jid = resusers.data[i].userId, Name = resusers.data[i].nickname, Token = resusers.data[i].userId, ShouldDeleteWhileFileExists = true, LocalUrl = localpath, Type = DownLoadFileType.Image }); } } HttpDownloader.Download(files, (item) => { switch (item.State) { case DownloadState.Successed: var tmp = AccountList.FirstOrDefault(a => a.userId == item.Jid); if (tmp != null) { App.Current.Dispatcher.Invoke(() => { tmp.userId = item.Jid; //下载完成后刷新头像 }); } break; case DownloadState.Error: break; default: break; } }); } else { pageNum--; } } } else { SnackBar.Enqueue("错误:" + e.Error.Message); } ShowLoadingProgressBar(false);//禁用按钮并显示 }