public IActionResult CreatePrimaryCheckingDeposit([FromBody] TransactionDTO transaction) { try { if (BankAccountValidation.VerifyInputForDeposit(_logger, transaction) == false) { return(BadRequest("The deposit type is not known")); } //note: wrapping the uow into a using block to approximate true data access against a DB, per best practices using (IUnitOfWork uow = new UnitOfWork()) { var acctFactory = new AccountFactory(); var primaryChecking = acctFactory.CreateInstance(AccountTypeEnum.PrimaryChecking); IAccountManager acctMgr = new AccountManager(primaryChecking, uow); var transactionEntity = Mapper.Map <Transaction>(transaction); acctMgr.RecordDepositOrWithdrawal(transactionEntity); return(StatusCode(201)); } } catch (Exception ex) { _logger.LogCritical($"Exception thrown in the AccountController. Message details: {ex.Message}"); return(StatusCode(500, "An error was detected in the Account Controller. View message log for details.")); } }
public override void InitControl() { hfValue.Value = lblValue.Text = (Value ?? "").ToString(); IAccountHelper accountHelper = AccountFactory.CreateInstance(); Account account = accountHelper.GetAccount(hfValue.Value, null); if (account == null) { ltlText.Text = ""; } else { string data = Control.Params[We7.Model.Core.UI.Constants.DATA]; if (!string.IsNullOrEmpty(data) && data == "admin") { //ShopPlugin.AdvanceUser DataTable dt = ModelDBHelper.Create("ShopPlugin.AdvanceUser").Query(new Criteria(CriteriaType.Equals, "UserID", hfValue.Value), new List <Order>() { new Order("ID", OrderMode.Desc) }, 0, 0); if (dt != null && dt.Rows.Count > 0) { ltlText.Text = "<a href='/admin/AddIns/ModelEditor.aspx?notiframe=1&model=ShopPlugin.AdvanceUser&ID=" + dt.Rows[0]["ID"].ToString() + "'>" + account.LoginName + "</a>"; } else { ltlText.Text = "<a href='/admin/Permissions/AccountEdit.aspx?id=" + account.ID + "'>" + account.LoginName + "</a>"; } } else { ltlText.Text = account.LoginName; } } }
public IActionResult GetSecondaryCheckingTransactionHistory(DateTime?fromDt, DateTime?toDt) { try { if (BankAccountValidation.VerifyInputFromDate(_logger, fromDt.Value) == false) { return(BadRequest("The To Date input value is not valid")); } toDt = BankAccountValidation.VerifyInputToDate(_logger, toDt.Value); //note: wrapping the uow into a using block to approximate true data access against a DB, per best practices using (IUnitOfWork uow = new UnitOfWork()) { var acctFactory = new AccountFactory(); var secondaryChecking = acctFactory.CreateInstance(AccountTypeEnum.SecondaryChecking); IAccountManager acctMgr = new AccountManager(secondaryChecking, uow); var ledger = acctMgr.ViewLedgerByDateRange(fromDt.Value, toDt.Value); var results = Mapper.Map <IEnumerable <TransactionDTO> >(ledger); return(Ok(results)); } } catch (Exception ex) { _logger.LogCritical($"Exception thrown in the AccountController. Message details: {ex.Message}"); return(StatusCode(500, "An error was detected in the Account Controller. View message log for details.")); } }
public string GetText(object dataItem, We7.Model.Core.ColumnInfo columnInfo) { string v = ModelControlField.GetValue(dataItem, columnInfo.Name); Department depart = AccountFactory.CreateInstance().GetDepartment(v, new string[] { "Name" }); return(depart != null ? depart.Name : String.Empty); }
private string GetDepartmentSN(string departID) { IAccountHelper helper = AccountFactory.CreateInstance(); Department depart = helper.GetDepartment(departID, null); return(depart != null ? depart.Number : String.Empty); }
void Signout() { if (Request["Authenticator"] == null) { IAccountHelper AccountHelper = AccountFactory.CreateInstance(); string result = AccountHelper.SignOut(); IsSignIn = false; } }
public TestBase() { _acctFactory = new AccountFactory(); _primaryChecking = _acctFactory.CreateInstance(AccountTypeEnum.PrimaryChecking); _primaryChecking.Ledger = new List <Transaction>(); _uow = new UnitOfWork(); _acctMgr = new AccountManager(_primaryChecking, _uow); }
/// <summary> /// 根据部门ID取得部门名称 /// </summary> /// <param name="arg"></param> /// <returns></returns> public static string GetDepartName(object arg) { string departId = arg as string; return(!String.IsNullOrEmpty(departId) ? CacheRecord.Create(typeof(AccountLocalHelper)).GetInstance <string>("Name$" + departId, () => { Department depart = AccountFactory.CreateInstance().GetDepartment(departId, null); return depart != null ? depart.Name : String.Empty; }) : String.Empty); }
/// <summary> /// 取得部门名称 /// </summary> /// <param name="fieldValue"></param> /// <returns></returns> protected string GetDepartName(object fieldValue) { if (fieldValue != null) { IAccountHelper helper = AccountFactory.CreateInstance(); Department depart = helper.GetDepartment(fieldValue.ToString(), new string[] { "Name" }); return(depart != null ? depart.Name : String.Empty); } return(String.Empty); }
/// <summary> /// 验证用户 /// </summary> void Authenticate() { if (String.Compare(LoginName, SiteConfigs.GetConfig().AdministratorName, false) == 0) { if (CDHelper.AdminPasswordIsValid(Password)) { Security.SetAccountID(We7Helper.EmptyGUID); UserName = SiteConfigs.GetConfig().AdministratorName; IsSignIn = true; } else { IsSignIn = false; Message = "密码错误"; } } else { if (Request["Authenticator"] != null && Request["accountID"] != null) { SSORequest ssoRequest = SSORequest.GetRequest(HttpContext.Current); string actID = ssoRequest.AccountID; if (Authentication.ValidateEACToken(ssoRequest) && !string.IsNullOrEmpty(actID) && We7Helper.IsGUID(actID)) { Security.SetAccountID(actID, IsPersist); UserName = ssoRequest.UserName; IsSignIn = true; } else if (Request["message"] != null) { Message = Request["message"]; IsSignIn = false; return; } } else { IAccountHelper AccountHelper = AccountFactory.CreateInstance(); string[] result = AccountHelper.Login(LoginName, Password); if (result[0] == "false") { Message = result[1]; IsSignIn = false; } else { IsSignIn = true; UserName = AccountHelper.GetAccount(result[1], new string[] { "LoginName" }).LoginName; Response.Redirect(ReturnUrl); } } } }
public string GetNameByUserID(string userid) { if (userid == We7Helper.EmptyGUID) { return(SiteConfigs.GetConfig().AdministratorName); } else { Account act = AccountFactory.CreateInstance().GetAccount(userid, null); return(act != null?String.Format("{0}{1}{2}", act.FirstName, act.MiddleName, act.LastName) : String.Empty); } }
void bttnSubmit_Click(object sender, EventArgs e) { Account.LastName = txtRealName.Text.Trim(); Account.Description = txtIntro.Text.Trim(); Account.Sex = rdMale.Checked ? "1" : "0"; DateTime dt; DateTime.TryParse(txtBirthday.Text.Trim(), out dt); Account.Birthday = dt; AccountFactory.CreateInstance().UpdateAccount(Account, new string[] { "LastName", "Description", "Sex", "Birthday" }); Page.RegisterStartupScript("success", "<script>alert('修改成功!');</script>"); }
/// <summary> /// 验证用户 /// </summary> void Authenticate() { if (Request["Authenticator"] != null && Request["accountID"] != null) { SSORequest ssoRequest = SSORequest.GetRequest(HttpContext.Current); string actID = ssoRequest.AccountID; if (Authentication.ValidateEACToken(ssoRequest) && !string.IsNullOrEmpty(actID) && We7Helper.IsGUID(actID)) { Security.SetAccountID(actID); } else if (Request["message"] != null) { Message = Request["message"]; return; } } else { Session["$ActionFrom"] = Request.UrlReferrer.PathAndQuery; Session["$_ActionID"] = _ActionID; IAccountHelper AccountHelper = AccountFactory.CreateInstance(); string loginName = Name; //邮箱格式 if (Name.IndexOf('@') > -1) { Account account = AccountHelper.GetAccountByEmail(Name); if (account != null) { loginName = account.LoginName; } } string[] result = AccountHelper.Login(loginName, Password); if (result[0] == "false") { Message = result[1]; return; } else { Author = result[1]; } } if (!string.IsNullOrEmpty(ReturnUrl)) { Response.Redirect(ReturnUrl); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (Request["Authenticator"] == null) { IAccountHelper AccountHelper = AccountFactory.CreateInstance(); string result = AccountHelper.SignOut(); } //退出时是否跳转对应页面 if (!string.IsNullOrEmpty(Request.Params["returnurl"])) { Response.Redirect(Request.Params["returnurl"]); } Response.Redirect("/"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Account act = AccountFactory.CreateInstance().GetAccount(Security.CurrentAccountID, null); if (act != null && !String.IsNullOrEmpty(act.Photo)) { imgPhoto.ImageUrl = act.Photo; } else { imgPhoto.ImageUrl = "/ModelUI/skin/images/nopic.gif"; } } bttnUpload.Click += new EventHandler(bttnUpload_Click); }
void bttnSubmit_Click(object sender, EventArgs e) { Account.Department = txtAddress.Text.Trim(); Account.Mobile = txtMobile.Text.Trim(); if (!String.IsNullOrEmpty(txtPrePhone.Text) && !String.IsNullOrEmpty(txtPrePhone.Text.Trim())) { Account.Tel = txtPrePhone.Text.Trim() + "-" + txtPhone.Text.Trim(); } else { Account.Tel = txtPhone.Text.Trim(); } Account.QQ = txtQQ.Text.Trim(); AccountFactory.CreateInstance().UpdateAccount(Account, new string[] { "Department", "Mobile", "Tel", "QQ" }); ScriptManager.RegisterStartupScript(Page, this.GetType(), "success", "alert('修改成功!')", true); }
void bttnUpload_Click(object sender, EventArgs e) { string message = string.Empty; if (!fuPhoto.HasFile) { message = "上传图片不能为空"; } else { string ext = Path.GetExtension(fuPhoto.FileName); if (!string.IsNullOrEmpty(ext)) { ext = ext.ToLower(); if (ext == ".jpg" || ext == ".png" || ext == ".gif") { string fileName = GetImageUrl(fuPhoto.FileName); string filePath = Server.MapPath(fileName); FileInfo fi = new FileInfo(filePath); if (!fi.Directory.Exists) { fi.Directory.Create(); } fuPhoto.SaveAs(Server.MapPath(fileName)); string thumbfileName = GetThumbUrl(fileName); string thumbPath = Server.MapPath(thumbfileName); ImageUtils.MakeThumbnail(filePath, thumbPath, 120, 120, "HW"); imgPhoto.ImageUrl = thumbfileName; IAccountHelper helper = AccountFactory.CreateInstance(); Account act = helper.GetAccount(Security.CurrentAccountID, null); act.Photo = thumbfileName; helper.UpdateAccount(act, new string[] { "Photo" }); message = "上传成功"; } else { message = "上传文件格式不对"; } } else { message = "上传文件格式不对"; } } ScriptManager.RegisterStartupScript(Page, Page.GetType(), "message", "alert('" + message + "')", true); }
/// <summary> /// 验证用户 /// </summary> void Authenticate() { IAccountHelper AccountHelper = AccountFactory.CreateInstance(); Account act = AccountHelper.GetAccountByLoginName(Name); if (act == null) { Message = "该用户不存在!"; return; } if (!AccountHelper.IsValidPassword(act, Password)) { Message = "密码不正确!"; return; } Security.SetAccountID(act.ID); }
void Signin() { string name = Request["UserName"]; string password = Request["Password"]; if (String.Compare(name, SiteConfigs.GetConfig().AdministratorName, true) == 0 && CDHelper.AdminPasswordIsValid(password)) { Security.SetAccountID(We7Helper.EmptyGUID); } else { IAccountHelper helper = AccountFactory.CreateInstance(); Account account = helper.GetAccountByLoginName(name); if (account != null && helper.IsValidPassword(account, password)) { Security.SetAccountID(account.ID); } } }
public override void Execute() { if (IsSignin) { if (Request["Authenticator"] == null) { Session["$ActionFrom"] = Request.UrlReferrer.PathAndQuery; Session["$_ActionID"] = _ActionID; IAccountHelper AccountHelper = AccountFactory.CreateInstance(); string result = AccountHelper.SignOut(); } } else { if (CheckValidateCode()) { Authenticate(); } } }
public string GetText(object dataItem, ColumnInfo columnInfo) { string v = ModelControlField.GetValue(dataItem, columnInfo.Name); IAccountHelper accountHelper = AccountFactory.CreateInstance(); Account account = accountHelper.GetAccount(v, null); if (account == null) { return(""); } else { if (v == We7Helper.EmptyGUID) { return("admin"); } return("<a href='" + GetUrl(columnInfo) + v + "'>" + account.LoginName + "</a>"); } //return }
public string[] Login(string username, string password) { IAccountHelper AccountHelper = AccountFactory.CreateInstance(); return(AccountHelper.Login(username, password)); }
/// <summary> /// 添加评论 /// </summary> protected void SubmitComment() { try { SiteSettingHelper CDHelper = HelperFactory.GetHelper <SiteSettingHelper>(); IAccountHelper AccountHelper = AccountFactory.CreateInstance(); CommentsHelper CommentsHelper = HelperFactory.GetHelper <CommentsHelper>(); Comments cm = new Comments(); DateTime Createdtime = DateTime.Now; if (ArticleIDByRedirect != "") { cm.ArticleID = ArticleIDByRedirect; } else { cm.ArticleID = ArticleID; } if (CDHelper.Config.IsAuditComment) { cm.State = 0; } else { cm.State = 1; } if (IsSignin) { string actID = CurrentAccount; if (We7Helper.IsEmptyID(actID)) { cm.Author = "系统管理员"; } else { Account act = AccountHelper.GetAccount(CurrentAccount, new string[] { "FirstName", "LastName", "LoginName" }); cm.Author = String.Format("{0} {1}({2})", act.LastName, act.FirstName, act.LoginName); } cm.AccountID = actID; } else { cm.Author = Author; cm.AccountID = ""; } cm.Content = Content; cm.Created = Createdtime; cm.ID = We7Helper.CreateNewID(); cm.ArticleName = Title; CommentsHelper.AddComments(cm); Message = CDHelper.Config.IsAuditComment ? "评论发表成功,等待系统审核!" : "发表成功!"; Content = ""; } catch (Exception ex) { Message = ex.Message; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Cache.SetNoStore(); context.Response.Clear(); string action = context.Request["action"]; string msg = "success"; if (!String.IsNullOrEmpty(action)) { IAccountHelper helper = AccountFactory.CreateInstance(); string key = context.Request["value"]; action = action.Trim().ToLower(); Account act = null; if (action == "user") { act = helper.GetAccountByLoginName(key); if (act != null) { context.Response.Write("当前用户已存在"); return; } } if (action == "email") { act = helper.GetAccountByEmail(key); if (act != null) { context.Response.Write("当前Email已被注册"); return; } } if (action == "validate") { act = helper.GetAccount(context.Request["AccountID"], null); if (act == null) { context.Response.Write("验证帐号不存在,请重新申请帐号!"); } else { act.EmailValidate = 1; act.State = 1; helper.UpdateAccount(act, new string[] { "EmailValidate", "State" }); } } if (action == "submit") { Account newAccout = new Account(); newAccout.LoginName = context.Request["name"]; newAccout.Password = context.Request["pwd"]; if (SiteConfigs.GetConfig().IsPasswordHashed) { newAccout.Password = Security.Encrypt(newAccout.Password); } newAccout.Email = context.Request["email"]; newAccout.UserType = 1; newAccout.Created = DateTime.Now; try { helper.AddAccount(newAccout); if (SendEmail(newAccout, context.Request)) { msg += ":email"; } } catch (Exception ex) { context.Response.Write(ex.Message); return; } } } context.Response.Write(msg); }
public string Signout() { IAccountHelper AccountHelper = AccountFactory.CreateInstance(); return(AccountHelper.SignOut()); }