public Response <SearchNotesResponse> SearchNotesByTimeSpanAndAuthorId(TokenRequest <SearchNotesByTimeSpanAndAuthorIdRequest> request) { Response <SearchNotesResponse> response = new Response <SearchNotesResponse>(); try { if (request == null || request.RequestData == null) { response.Code = -1; response.Description = "请求参数为空!"; response.ResponseData = null; } else { NoteManager manager = new NoteManager(request.Version); int totalRows = 0; ManagerResult <List <Note> > result = manager.SearchNotesByTimeSpanAndAuthorId(request.RequestData.PageSize, request.RequestData.PageIndex, request.RequestData.StartTime, request.RequestData.EndTime, request.RequestData.AuthorId, out totalRows); response.GetResultInfo(result); response.ResponseData = new SearchNotesResponse() { Notes = result.ResultData, TotalRows = totalRows }; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); response.Code = -1; } return(response); }
public async Task <ManagerResult <List <EquityGroupItem> > > GetGroupEquities(Guid equityGroupId) { ManagerResult <List <EquityGroupItem> > mgrResult = new ManagerResult <List <EquityGroupItem> >(); List <EquityGroupItem> equityGroupItems = new List <EquityGroupItem>(); try { equityGroupItems = await cache.GetOrCreateAsync <List <EquityGroupItem> >($"EQUITIES-{equityGroupId}", entry => { string sql = @" SELECT e.* FROM equities e, equity_group_items i, equity_groups g WHERE e.id = i.equity_id AND i.group_id = g.id AND g.id = @p1"; using NpgsqlConnection db = new NpgsqlConnection(connString); { return(Task.FromResult(db.Query <EquityGroupItem>(sql, new { p1 = equityGroupId }).ToList())); } }); mgrResult.Entity = equityGroupItems; } catch (Exception ex) { mgrResult.Exception = ex; } return(mgrResult); }
public Response <SysInfo> GetSysInfoByName(PublicRequest <GetSysInfoByNameRequest> request) { Response <SysInfo> response = new Response <SysInfo>(); try { if (request == null || request.RequestData == null) { response.Code = -1; response.Description = "参数为空!"; response.ResponseData = null; } else { SysInfoManager manager = new SysInfoManager(request.Version); ManagerResult <SysInfo> result = manager.GetSysInfoByName(request.RequestData.Name); response.GetResultInfo(result); response.ResponseData = result.ResultData; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); response.Code = -1; } return(response); }
public Response <List <NoteBrowsedRecord> > GetNoteBrowsedRecordsByUserId(TokenRequest <GetNoteBrowsedRecordsByUserIdRequest> request) { Response <List <NoteBrowsedRecord> > response = new Response <List <NoteBrowsedRecord> >(); try { if (request == null || request.RequestData == null) { response.Code = -1; response.Description = "请求参数为空!"; response.ResponseData = null; } else { NoteBrowsedRecordManager manager = new NoteBrowsedRecordManager(request.Version); ManagerResult <List <NoteBrowsedRecord> > result = manager.GetNoteBrowsedRecordsByNoteId(request.RequestData.UserId); response.GetResultInfo(result); response.ResponseData = result.ResultData; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); response.Code = -1; } return(response); }
public Response <Verification> AddVerification(SignedRequest <Verification> request) { Response <Verification> response = new Response <Verification>(); try { if (request == null || request.RequestData == null) { response.Code = -1; response.Description = "请求参数为空!"; response.ResponseData = null; } else { VerificationManager verificationManager = new VerificationManager(request.Version); ManagerResult <Verification> result = verificationManager.AddVerification(request.RequestData); response.GetResultInfo(result); response.ResponseData = result.ResultData; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); response.Code = -1; } return(response); }
public async Task <ManagerResult <User> > Save(User user) { ManagerResult <User> mgrResult = new ManagerResult <User>(); try { if (user.Id == Guid.Empty) { using NpgsqlConnection db = new NpgsqlConnection(connString); { await db.InsertAsync(user); } } else { using NpgsqlConnection db = new NpgsqlConnection(connString); { await db.UpdateAsync(user); } } } catch (Exception ex) { mgrResult.Exception = ex; } return(mgrResult); }
public Response <NoteComment> AddNoteComment(TokenRequest <AddNoteCommentRequest> request) { Response <NoteComment> response = new Response <NoteComment>(); try { if (request == null || request.RequestData == null) { response.Code = -1; response.Description = "请求参数为空!"; response.ResponseData = null; } else { NoteCommentManager manager = new NoteCommentManager(request.Version); ManagerResult <NoteComment> result = manager.AddNoteComment(request.RequestData.NoteComment); response.GetResultInfo(result); response.ResponseData = result.ResultData; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); response.Code = -1; } return(response); }
public ManagerResult <Verification> GenerateVerification(string phoneNumber) { ManagerResult <Verification> result = new ManagerResult <Verification>(); try { Verification newVerification = VerificationDAL.Instance.AddOrUpdateVerification(new Verification() { PhoneNumber = phoneNumber, Code = CheckCodeHelper.GenerateCheckCode(5) }); if (newVerification == null) { result.Code = 1; result.Description = "生成失败!"; result.ResultData = null; } else { result.Code = 0; result.Description = "生成成功!"; result.ResultData = newVerification; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); result.Code = -1; } return(result); }
public ManagerResult <Verification> GetVerificationByPhoneNumber(string phoneNumber) { ManagerResult <Verification> result = new ManagerResult <Verification>(); try { Verification verification = VerificationDAL.Instance.GetVerificationByPhoneNumber(phoneNumber); if (verification == null) { result.Code = 1; result.Description = "未找到符合条件的验证信息!"; } else { result.Code = 0; result.Description = "验证信息获取成功!"; result.ResultData = verification; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); result.Code = -1; } return(result); }
/// <summary> /// handles a comma-delimited list of symbols /// </summary> /// <param name="symbols"></param> /// <returns></returns> public async Task <ManagerResult <List <Equity> > > GetList(string symbols) { ManagerResult <List <Equity> > mgrResult = new ManagerResult <List <Equity> >(); List <string> symbolList = new List <string>(symbols.Split(",".ToCharArray())); try { List <Equity> equityList = await this.GetAllEquities(); var equiyMatches = from equity in equityList where symbolList.Contains(equity.Symbol) select equity; mgrResult.Entity = (List <Equity>)equiyMatches; } catch (Exception ex) { mgrResult.Exception = ex; mgrResult.Message = "EquityManager::GetList"; Log.Error("EquityManager::GetList", ex); } return(mgrResult); }
public async Task <ManagerResult <Quote> > Add(Quote quote) { ManagerResult <Quote> mgrResult = new ManagerResult <Quote>(); try { if (eqMgr.Get(quote.EquityId).Result.Entity == default(Equity)) { using (NpgsqlConnection db = new NpgsqlConnection(base.connString)) { await db.InsertAsync(quote); } } else { quote = new Quote(); } } catch (Exception ex) { mgrResult.Exception = ex; Log.Error("QuoteManager::Add", ex); } return(mgrResult); }
public async Task <ManagerResult <List <Equity> > > GetAll() { ManagerResult <List <Equity> > mgrResult = new ManagerResult <List <Equity> >(); List <Equity> equityList = new List <Equity>(); try { equityList = await cache.GetOrCreateAsync <List <Equity> >(CacheKeys.EQUITY_LIST, entry => { using (NpgsqlConnection db = new NpgsqlConnection(connString)) { return(Task.FromResult(db.Query <Equity>("SELECT * FROM equities").ToList())); } }); mgrResult.Entity = equityList; } catch (Exception ex) { mgrResult.Exception = ex; mgrResult.Message = "EquityManager::GetList"; Log.Error("EquityManager::GetList", ex); } return(mgrResult); }
public async Task <ManagerResult <bool> > Delete(Guid equityId) { ManagerResult <bool> mgrResult = new ManagerResult <bool>(); Equity equity = new Equity() { Id = equityId }; try { int count = GetEquitiesInModelsCount(equity.Id).Result.Entity; if (count == 0) { using (NpgsqlConnection db = new NpgsqlConnection(connString)) { mgrResult.Entity = await db.DeleteAsync(equity); } } else { mgrResult.Exception = new APIException(APIException.EQUITY_USED, APIException.EQUITY_USED_MESSAGE); } } catch (Exception ex) { mgrResult.Exception = ex; mgrResult.Message = "EquityManager::Save"; Log.Error("EquityManager::Delete", ex); } return(mgrResult); }
public async Task <ManagerResult <Equity> > Save(Equity equity) { ManagerResult <Equity> mgrResult = new ManagerResult <Equity>(); try { if (equity.Id == Guid.Empty) { using (NpgsqlConnection db = new NpgsqlConnection(connString)) { await db.InsertAsync(equity); } } else { using (NpgsqlConnection db = new NpgsqlConnection(connString)) { await db.UpdateAsync(equity); } } mgrResult.Entity = equity; } catch (Exception ex) { mgrResult.Exception = ex; mgrResult.Message = "EquityManager::Save"; Log.Error("EquityManager::Save", ex); } return(mgrResult); }
public ManagerResult <User> Register(User user, string pwdHashStr) { ManagerResult <User> result = new ManagerResult <User>(); try { UserEntity entity = user.ToEntity(); SHA256CrypWidthSalt crp = SHA256CrypWidthSalt.Encrypt(pwdHashStr); entity.HashCode = crp.HashString; entity.Salt = crp.Salt; result.ResultData = UserDAL.Instance.AddUser(entity); if (result.ResultData == null) { result.Code = 1; result.Description = "添加用户失败!"; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); result.Code = -1; } return(result); }
public ManagerResult <Verification> AddVerification(Verification verification) { ManagerResult <Verification> result = new ManagerResult <Verification>(); try { Verification newVerification = VerificationDAL.Instance.AddOrUpdateVerification(verification); if (newVerification == null) { result.Code = 1; result.Description = "添加失败!"; } else { result.Code = 0; result.Description = "添加成功!"; result.ResultData = verification; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); result.Code = -1; } return(result); }
public ManagerResult <bool> CheckPhoneNumberRegistered(string phoneNumber) { ManagerResult <bool> result = new ManagerResult <bool>(); try { User user = UserDAL.Instance.GetUserByPhoneNumber(phoneNumber); if (user == null) { result.ResultData = false; result.Description = "该手机号未被注册!"; result.Code = 0; } else { result.ResultData = true; result.Description = "该手机号已被注册!"; result.Code = 0; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); result.Code = -1; } return(result); }
public ManagerResult <bool> CheckSignature(string signature, string timestamp, string nonce, string appId) { ManagerResult <bool> result = new ManagerResult <bool>(); try { SignCheckResult checkResult = Signature.ValidateSignature(signature, timestamp, nonce, appId); result.Description = checkResult.Description; if (!checkResult.IsSuccess) { result.ResultData = false; result.Code = 1; } else { result.ResultData = true; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); result.Code = -1; } return(result); }
public async Task <ManagerResult <bool> > Validate(string userName, string password) { ManagerResult <bool> mgrResult = new ManagerResult <bool>(); try { using (NpgsqlConnection db = new NpgsqlConnection(connString)) { User user = await db.QueryFirstOrDefaultAsync <User>(@"SELECT * FROM users WHERE user_name = @p1 AND password = @p2 AND active = true", new { p1 = userName, p2 = password }); mgrResult.Entity = (user != default(User)); } } catch (Exception ex) { mgrResult.Exception = ex; } return(mgrResult); }
public async Task <ManagerResult <ModelEquity> > Save(ModelEquity modelEquity) { ManagerResult <ModelEquity> mgrResult = new ManagerResult <ModelEquity>(); try { using (NpgsqlConnection db = new NpgsqlConnection(connString)) { if (modelEquity.Id != default) { await db.UpdateAsync(modelEquity); } else { await db.InsertAsync(modelEquity); } } mgrResult.Entity = modelEquity; } catch (Exception ex) { mgrResult.Exception = ex; } return(mgrResult); }
public MainPageViewModel(INavigationService navigationService, LoginService loginService) { this.navigationService = navigationService; LoginService = loginService; LoginCommand = new DelegateCommand(async() => { Message = ""; ManagerResult managerResult = await LoginService.PostAsync(new LoginQueryString() { Account = Account, Password = Password, }); if (managerResult.Success == false) { Message = managerResult.Message; } else { Message = "登入驗證程序成功"; await Task.Delay(3000); await navigationService.NavigateAsync("PersonPage"); } }); #if DEBUG Account = "admin"; Password = "******"; #endif }
public async Task <ManagerResult <bool> > RemoveEquity(Guid modelEquityId) { ManagerResult <bool> mgrResult = new ManagerResult <bool>(); try { ModelEquity modelEquity = new ModelEquity() { Id = modelEquityId }; using NpgsqlConnection db = new NpgsqlConnection(connString); { mgrResult.Entity = await db.DeleteAsync(modelEquity); } } catch (Exception ex) { mgrResult.Exception = ex; mgrResult.Success = false; mgrResult.Message = ex.Message; } return(mgrResult); }
public Response <bool> CheckVerification(SignedRequest <CheckVerificationRequest> request) { Response <bool> response = new Response <bool>(); try { if (request == null || request.RequestData == null) { response.Code = -1; response.Description = "请求参数为空!"; response.ResponseData = false; } else { VerificationManager verificationManager = new VerificationManager(request.Version); ManagerResult <bool> result = verificationManager.CheckVerification(request.RequestData.PhoneNumber, request.RequestData.Code); response.GetResultInfo(result); response.ResponseData = result.ResultData; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); response.Code = -1; } return(response); }
public async Task <ManagerResult <UserModel> > GetModel(Guid modelId, int versionNumber = 0) { ManagerResult <UserModel> mgrResult = new ManagerResult <UserModel>(); try { using (NpgsqlConnection db = new NpgsqlConnection(connString)) { if (versionNumber == 0) { versionNumber = db.QuerySingleAsync <int>(@" SELECT MAX(version) FROM user_models WHERE id = @p1 ", new { p1 = modelId }).Result; } UserModel model = db.QuerySingleAsync <UserModel>(@" SELECT * FROM user_models WHERE id = @p1 and version = @p2", new { p1 = modelId, p2 = versionNumber }).Result; mgrResult.Entity = model; } } catch (Exception ex) { mgrResult.Exception = ex; } return(mgrResult); }
public async Task <ManagerResult <List <EquityGroupItem> > > GetGroupItemsList(Guid equityGroupId) { ManagerResult <List <EquityGroupItem> > mgrResult = new ManagerResult <List <EquityGroupItem> >(); List <EquityGroupItem> equityGroupItems = new List <EquityGroupItem>(); try { equityGroupItems = await cache.GetOrCreateAsync <List <EquityGroupItem> >(equityGroupId, entry => { using NpgsqlConnection db = new NpgsqlConnection(connString); { return(Task.FromResult(db.Query <EquityGroupItem>(@"SELECT * FROM equity_group_items WHERE group_id = @p1 ", new { p1 = equityGroupId }).ToList())); } }); mgrResult.Entity = equityGroupItems; } catch (Exception ex) { mgrResult.Exception = ex; } return(mgrResult); }
public Response <User> Register(SignedRequest <RegisterRequest> request) { var response = new Response <User>(); try { if (request == null || request.RequestData == null) { response.Code = -1; response.Description = "请求参数为空!"; response.ResponseData = null; } else { NoteUserManager manager = new NoteUserManager(request.Version); ManagerResult <User> result = manager.Register(request.RequestData.User, request.RequestData.PwdHashStr); response.GetResultInfo(result); response.ResponseData = result.ResultData; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); response.Code = -1; } return(response); }
public async Task <ManagerResult <EquityGroup> > Save(EquityGroup equityGroup) { ManagerResult <EquityGroup> mgrResult = new ManagerResult <EquityGroup>(); try { if (equityGroup.Id == Guid.Empty) { using NpgsqlConnection db = new NpgsqlConnection(connString); { await db.InsertAsync(equityGroup); } } else { using NpgsqlConnection db = new NpgsqlConnection(connString); { await db.UpdateAsync(equityGroup); } } mgrResult.Entity = equityGroup; } catch (Exception ex) { mgrResult.Exception = ex; } return(mgrResult); }
public Response <User> GetUserByToken(TokenRequest <GetUserByTokenRequest> request) { var response = new Response <User>(); try { if (request == null || request.RequestData == null) { response.Code = -1; response.Description = "请求参数为空!"; response.ResponseData = null; } else { NoteUserManager manager = new NoteUserManager(request.Version); ManagerResult <User> resultUser = manager.GetUserByToken(request.RequestData.Token); response.GetResultInfo(resultUser); response.ResponseData = resultUser.ResultData; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); response.Code = -1; } return(response); }
public Response <FtpConfig> GetFtpConfigByName(TokenRequest <GetFtpConfigByNameRequest> request) { Response <FtpConfig> response = new Response <FtpConfig>(); try { if (request == null || request.RequestData == null) { response.Code = -1; response.Description = "请求参数为空!"; response.ResponseData = null; } else { FtpConfigManager manager = new FtpConfigManager(request.Version); ManagerResult <FtpConfig> result = manager.GetFtpConfigByName(request.RequestData.Name); response.GetResultInfo(result); response.ResponseData = result.ResultData; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); response.Code = -1; } return(response); }
public Response <NoteBrowsedRecord> NoteGetBrowsed(TokenRequest <NoteGetBrowsedRequest> request) { Response <NoteBrowsedRecord> response = new Response <NoteBrowsedRecord>(); try { if (request == null || request.RequestData == null) { response.Code = -1; response.Description = "请求参数为空!"; response.ResponseData = null; } else { DateTime lastBrowsedTime = DateTime.Now; NoteManager manager = new NoteManager(request.Version); ManagerResult <NoteBrowsedRecord> result = manager.NoteGetBrowsed(request.RequestData.NoteId, request.RequestData.UserId); response.GetResultInfo(result); response.ResponseData = result.ResultData; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); response.Code = -1; } return(response); }