public void AddEntryToTransaction(Transaction trans, TAccount debit, TAccount credit, decimal?debitAmount = null, decimal?creditAmount = null) { if (credit == null && debit == null) { "Transaction.Record.Account.Missing".AddErrorMessage(Context); return; } if (credit != null && debit != null) { "Transaction.Record.Account.OnlyOneAccountPerEntry".AddErrorMessage(Context); return; } if (credit != null && !creditAmount.HasValue) { "Transaction.Record.CreditAmount.Missing".AddErrorMessage(Context); return; } if (debit != null && !debitAmount.HasValue) { "Transaction.Record.DebitAmount.Missing".AddErrorMessage(Context); return; } var entry = new TAccount_Entry { Type = credit != null ? TAccount_EntryType.Credit : TAccount_EntryType.Debit, Account = credit != null ? credit : debit, Amount = credit != null ? creditAmount.Value : debitAmount.Value }; trans.Entries.Add(entry); }
public static bool DbDelete(this TAccount entity, DbSession session) { var query = session.GetDbQueryBuilder(); query.DeleteBuilder.ComponentWhere.Add(new ComponentValueOfWhere(TAccountProperties.AccountId, entity.AccountId, LocateType.Equal)); return(session.GetQueryOperator().Delete <TAccount>(query)); }
public static Report <CreateStatus> CreateAccount(TAccount account) { return(TransactionHelper.HandleTransactionEvent(DbConfigs.DbNameOfAccount, (session) => { return account.Create(session); })); }
public async override Task <bool> Initialize() { if (isInitialized) { return(true); } if (Template.SimulateAccount != null) { TAccount simulatedAccount = await Template.SimulateAccount.Load <TAccount>(); Template.AssignPropertiesFrom(simulatedAccount); } this.TimeFrame = Template.TimeFrame; this.StartDate = Template.StartDate; this.EndDate = Template.EndDate; if (await base.Initialize().ConfigureAwait(false) == false) { return(false); } Equity = Balance = Template.StartingBalance; isInitialized = true; return(true); }
/// <summary> /// 未查询到数据时返回 null /// </summary> public static TAccount DbSelect(this TAccount entity, DbSession session, params PDMDbProperty[] fields) { var query = session.GetDbQueryBuilder(); SelectBuilder builder = new SelectBuilder(); if (fields.Count() == 0) { builder.ComponentSelect.Add(TAccountProperties.AccountId); builder.ComponentSelect.Add(TAccountProperties.AccountName); builder.ComponentSelect.Add(TAccountProperties.Phone); builder.ComponentSelect.Add(TAccountProperties.Email); builder.ComponentSelect.Add(TAccountProperties.Password); builder.ComponentSelect.Add(TAccountProperties.CreatedOn); builder.ComponentSelect.Add(TAccountProperties.LastEditedOn); } else { builder.ComponentSelect.Add(TAccountProperties.AccountId); foreach (var field in fields) { builder.ComponentSelect.Add(field); } } builder.ComponentWhere.Add(new ComponentValueOfWhere(TAccountProperties.AccountId, entity.AccountId, LocateType.Equal)); query.SelectBuilders.Add(builder); return(session.GetQueryOperator().Select <TAccount>(query)); }
/// <summary> /// 未查询到数据时返回 null /// </summary> public static TAccount DbSelect(this TAccount entity, DbSession session, SelectBuilder select) { var query = session.GetDbQueryBuilder(); query.SelectBuilder = select; return(session.GetQueryOperator().Select <TAccount>(query)); }
/// <summary> /// 载入道具返回 /// </summary> /// <param name="dbi"></param> private void loadBack(DbAccessItem dbi) { if (dbi.Result.ErrCode != 0) { SvLogger.Error("DB Access Fail : Op=Load Account, ErrMsg={0}, Data={1}.", dbi.Result.ErrMsg, dbi.SpName); } else { DataTable dt = dbi.OutDs.Tables[0]; foreach (DataRow dr in dt.Rows) { TAccount t = new TAccount(); t.account = HTBaseFunc.NullToStr(dr["LoginName"]); t.token = HTBaseFunc.NullToStr(dr["Token"]); t.showName = HTBaseFunc.NullToStr(dr["ShowName"]); t.power = HTBaseFunc.NullToInt(dr["Power"]); t.createTime = HTBaseFunc.NullToDateTime(dr["CreateTime"]).ToString("yyyy-MM-dd HH:mm:ss"); Account acc = new Account(t); m_dataDic[acc.m_Data.account] = acc; } DataLoadManager.Instance.AddLoadSuccTableCount(); } OnLoadDataFromDBFinish(dbi.Result.ErrCode == 0); }
public TAccount CreateTAccount() { var t = new TAccount(); "TAccount.Created.Ok".AddOkMessage(Context); Context.TAccounts.Add(t); return(t); }
static async void TestInsertAsync() { var rpository = Game.Scene.GetComponent <AccountRpository>(); var account = new TAccount { FCreateTime = DateTime.Now, FAccountName = "Sam", }; await rpository.DBContext.InsertAsync(account); }
public IActionResult UpdateUser(TAccount tAccount) { var result = ValidateTAccount(tAccount); if (!result.IsSucceed) { return(MyJson(result)); } result = AccountService.UpdateUser(tAccount, null); return(MyJson(result)); }
public override LoginResponeMessage VerifyLogin(LoginRequestMessage request, TAccount account) { var result = new LoginResponeMessage { LoginResult = LoginResutlCode.UnKnown }; if (request.Password == account.FPassword) { result.LoginResult = LoginResutlCode.Success; SetRespose(result, account); } return(result); }
public void SetRespose(LoginResponeMessage response, TAccount account) { response.AccountId = Game.Scene.GetComponent <ActorComponentStorage>().GetActor(account.Id).Id; response.FType = account.FType; response.FAccountName = account.FAccountName; response.FVIPLevel = account.FVIPLevel; response.FWXOpenId = account.FWXOpenId; response.FWXHeadImgurl = account.FWXHeadImgurl; response.FNikeNmae = account.FNikeNmae; response.FEmail = account.FEmail; response.FPhoneNumber = account.FPhoneNumber; response.FBalance = account.FBalance; }
/// <summary> /// 对象转化 /// </summary> /// <param name="account">Account</param> /// <returns>TAccount</returns> public static TAccount ToTAccount(this Account account) { var tAccount = new TAccount { Id = account.Key, AccountName = account.AccountName, AccountNo = account.AccountNO, Mail = account.Mail, Mobile = account.Mobile, CreateTime = account.CreateTime }; return(tAccount); }
public async static Task <TAccount> Add() { var rpository = Game.Scene.GetComponent <AccountRpository>(); var account = new TAccount { FAccountName = "Sam" + new Random().Next(100000), }; account.SetCreator("Admin"); account.SetUpdater("Admin"); await rpository.DBContext.InsertAsync(account); return(account); }
public IActionResult Edit(TAccount product) { int year = product.AccYear; if (ModelState.IsValid) { try{ _dbContext.TAccount.Update(product); _dbContext.SaveChanges(); var model = _dbContext.TAccount.FromSqlRaw("exec TUpdate @year ", new SqlParameter("year", year)).ToList <TAccount>().First(); } catch {} } return(RedirectToAction("LstCnt", new{ @year = year })); }
public ActionResult UpdateUser(TAccount tAccount) { var result = ValidateTAccount(tAccount); if (!result.IsSucceed) { return(new MyJsonResult { Data = result }); } result = AccountService.UpdateUser(tAccount, null); return(new MyJsonResult { Data = result }); }
/// <summary> /// 对象转化 /// </summary> /// <param name="mAccount">MAccount</param> /// <returns>TAccount</returns> public static TAccount ToTAccount(this MAccount mAccount) { var account = new TAccount { Id = mAccount.Id, AccountName = mAccount.AccountName, AccountNo = mAccount.AccountNo, Mail = mAccount.Mail, Mobile = mAccount.Mobile, CreateTime = mAccount.CreateTime, IsAdmin = mAccount.IsAdmin, Status = mAccount.Status }; return(account); }
static async void TestInsertManyAsync() { var rpository = Game.Scene.GetComponent <AccountRpository>(); var inserts = new List <TAccount>(); for (var i = 0; i < 10; i++) { var account = new TAccount { FCreateTime = DateTime.Now, FAccountName = $"SamAsync{i}", }; inserts.Add(account); } await rpository.DBContext.InsertManyAsync(inserts); }
public async Task <CreateAdminOutput> CreateAdmin(CreateAdminInput dto) { var output = new CreateAdminOutput { Result = dto.Result }; if (await this.AccountRpository.ExistedAsync(dto.Model.UserName)) { output.Result.ResultCode = (int)AccountResultCode.UserNameExisted; output.Result.Message = "该用户名存在"; return(output); } var account = new TAccount { Name = dto.Model.UserName, Password = dto.Model.Password, Type = dto.Model.AccountType, Emai = dto.Model.Email, }; account.SetCreator(1); account.SetUpdater(1); await this.AccountRpository.AddAsync(account); var amax = await this.AdminRpository.GetMaxJobNumber(); var cmax = await this.CustomerRpository.GetMaxJobNumber(); var admin = new TAdmin { AccountId = account.Id, JobNumber = JobNumberUtils.GetJobNumber(amax, cmax), }; admin.SetCreator(1); admin.SetUpdater(1); await this.AdminRpository.AddAsync(admin); if (!await this.SaveChangesAsync()) { output.Result.Message = "数据保存失败"; return(output); } output.Result.ResultCode = (int)ResultCode.Successful; return(output); }
/// <summary> /// 存在相应对象时返回true,缺少对象时返回false /// </summary> public static bool DbLoad(this TAccount entity, DbSession session, params PDMDbProperty[] fields) { var result = entity.DbSelect(session, fields); if (result == null) { return(false); } if (fields.Count() == 0) { entity.AccountName = result.AccountName; entity.Phone = result.Phone; entity.Email = result.Email; entity.Password = result.Password; entity.CreatedOn = result.CreatedOn; entity.LastEditedOn = result.LastEditedOn; } else { if (fields.Contains(TAccountProperties.AccountName)) { entity.AccountName = result.AccountName; } if (fields.Contains(TAccountProperties.Phone)) { entity.Phone = result.Phone; } if (fields.Contains(TAccountProperties.Email)) { entity.Email = result.Email; } if (fields.Contains(TAccountProperties.Password)) { entity.Password = result.Password; } if (fields.Contains(TAccountProperties.CreatedOn)) { entity.CreatedOn = result.CreatedOn; } if (fields.Contains(TAccountProperties.LastEditedOn)) { entity.LastEditedOn = result.LastEditedOn; } } return(true); }
public static bool DbUpdate(this TAccount entity, DbSession session, params PDMDbProperty[] fields) { var query = session.GetDbQueryBuilder(); UpdateBuilder builder = new UpdateBuilder(); builder.ComponentWhere.Add(new ComponentValueOfWhere(TAccountProperties.AccountId, entity.AccountId, LocateType.Equal)); if (fields == null || fields.Length == 0) { builder.ComponentSet.Add(new ComponentValueOfSet(TAccountProperties.AccountName, entity.AccountName)); builder.ComponentSet.Add(new ComponentValueOfSet(TAccountProperties.Phone, entity.Phone)); builder.ComponentSet.Add(new ComponentValueOfSet(TAccountProperties.Email, entity.Email)); builder.ComponentSet.Add(new ComponentValueOfSet(TAccountProperties.Password, entity.Password)); builder.ComponentSet.Add(new ComponentValueOfSet(TAccountProperties.CreatedOn, entity.CreatedOn)); builder.ComponentSet.Add(new ComponentValueOfSet(TAccountProperties.LastEditedOn, entity.LastEditedOn)); } else { if (fields.Contains(TAccountProperties.AccountName)) { builder.ComponentSet.Add(new ComponentValueOfSet(TAccountProperties.AccountName, entity.AccountName)); } if (fields.Contains(TAccountProperties.Phone)) { builder.ComponentSet.Add(new ComponentValueOfSet(TAccountProperties.Phone, entity.Phone)); } if (fields.Contains(TAccountProperties.Email)) { builder.ComponentSet.Add(new ComponentValueOfSet(TAccountProperties.Email, entity.Email)); } if (fields.Contains(TAccountProperties.Password)) { builder.ComponentSet.Add(new ComponentValueOfSet(TAccountProperties.Password, entity.Password)); } if (fields.Contains(TAccountProperties.CreatedOn)) { builder.ComponentSet.Add(new ComponentValueOfSet(TAccountProperties.CreatedOn, entity.CreatedOn)); } if (fields.Contains(TAccountProperties.LastEditedOn)) { builder.ComponentSet.Add(new ComponentValueOfSet(TAccountProperties.LastEditedOn, entity.LastEditedOn)); } } query.UpdateBuilders.Add(builder); return(session.GetQueryOperator().Update <TAccount>(query)); }
public async Task <ResponseModel> AddAdminAccount(AddAdminDto dto) { if (await this.DbContext.TAccount.FindAsync(new { Name = dto.Model.UserName }) != null) { dto.Result.ResultCode = (int)AccountResultCode.UserNameExisted; dto.Result.Message = "该用户名存在"; return(dto.Result); } //插入TAccount var account = new TAccount { Name = dto.Model.UserName, Password = dto.Model.Password, Type = dto.Model.AccountType, Emai = dto.Model.Email, }; account.SetCreator(1); account.SetUpdater(1); await this.DbContext.AddOneAsync(account); var amax = await this.GetAdminMaxJobNumber(); var cmax = await this.GetCustomerMaxJobNumber(); //插入TAdmin var admin = new TAdmin { AccountId = account.Id, JobNumber = JobNumberUtils.GetJobNumber(amax, cmax), }; admin.SetCreator(1); admin.SetUpdater(1); await this.DbContext.AddOneAsync(admin); if (await this.DbContext.SaveChangesAsync() <= 0) { dto.Result.Message = "数据保存失败"; return(dto.Result); } dto.Result.ResultCode = (int)ResultCode.Successful; return(dto.Result); }
public async void TestInsertMany() { Game.Scene.AddComponent <MongoConfig>(); var rpository = Game.Scene.GetComponent <AccountRpository>(); List <TAccount> accounts = new List <TAccount>(); for (var i = 0; i < 100; i++) { var account = new TAccount { FAccountName = "SAM" + i, FType = AccountType.CustomerService, FEmail = "*****@*****.**", }; account.SetCreator("TestInsertMany"); accounts.Add(account); } rpository.DBContext.InsertMany(accounts); }
public static bool DbInsert(this TAccount entity, DbSession session) { var query = session.GetDbQueryBuilder(); InsertBuilder builder = new InsertBuilder(); builder.ComponentInsert.Add(new ComponentValueOfInsert(TAccountProperties.AccountId, entity.AccountId)); if (entity.AccountName == null) { throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.AccountName)); } if (entity.AccountName.Length > 20) { throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.AccountName), entity.AccountName.Length, 20)); } builder.ComponentInsert.Add(new ComponentValueOfInsert(TAccountProperties.AccountName, entity.AccountName)); if (entity.Phone.HasValue) { builder.ComponentInsert.Add(new ComponentValueOfInsert(TAccountProperties.Phone, entity.Phone.Value)); } if (entity.Email.HasValue) { builder.ComponentInsert.Add(new ComponentValueOfInsert(TAccountProperties.Email, entity.Email.Value)); } if (entity.Password == null) { throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.Password)); } if (entity.Password.Length > 20) { throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.Password), entity.Password.Length, 20)); } builder.ComponentInsert.Add(new ComponentValueOfInsert(TAccountProperties.Password, entity.Password)); builder.ComponentInsert.Add(new ComponentValueOfInsert(TAccountProperties.CreatedOn, entity.CreatedOn)); if (entity.LastEditedOn.HasValue) { builder.ComponentInsert.Add(new ComponentValueOfInsert(TAccountProperties.LastEditedOn, entity.LastEditedOn.Value)); } query.InsertBuilders.Add(builder); return(session.GetQueryOperator().Insert <TAccount>(query)); }
public static Report <CreateStatus> Create(this TAccount tAccount, DbSession session) { var result = new Report <CreateStatus>((data) => { return(new ReportData(data == CreateStatus.Success ? ReportStatus.Success : ReportStatus.Failure)); }); //检测 if (string.IsNullOrEmpty(tAccount.AccountName)) { result.Data = CreateStatus.Empty_AccountName; result.ReportData.Message = "用户名不可为空"; return(result); } if (string.IsNullOrEmpty(tAccount.Password)) { result.Data = CreateStatus.Empty_Password; result.ReportData.Message = "密码不可为空"; return(result); } //最新值 tAccount.AccountId = Guid.NewGuid(); tAccount.CreatedOn = DateTime.Now; tAccount.LastEditedOn = DateTime.Now; //处理 if (tAccount.DbInsert(session)) { result.Data = CreateStatus.Success; result.ReportData.Message = "创建成功"; return(result); } else { result.Data = CreateStatus.Failure; result.ReportData.Message = "创建失败"; return(result); } }
public IActionResult UpdateUser(TAccount tAccount) { var result = AccountService.UpdateUser(tAccount, null); return(Json(result)); }
/// <summary> /// 验证用户信息 /// </summary> /// <param name="tAccount">用户信息</param> /// <returns>角色</returns> private static Result ValidateTAccount(TAccount tAccount) { throw new NotImplementedException(); }
public static void AddActor(TAccount account) { Game.Scene.GetComponent <ActorComponentStorage>().AddActor <PlayerComponent, TAccount>(account); }
public override LoginResponeMessage VerifyLogin(LoginRequestMessage request, TAccount account) { throw new NotImplementedException(); }
public abstract LoginResponeMessage VerifyLogin(LoginRequestMessage request, TAccount account);