public IHttpActionResult SaveMembers(UIAccounts groupAccounts) { string mRetVal = "false"; Logger mLog = Logger.Instance(); MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditGroups", true)), AccountUtility.CurrentProfile()); if (!mSecurityInfo.MayEdit) { Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add"); mLog.Error(mError); return(this.InternalServerError(mError)); } if (HttpContext.Current.Items["EditId"] == null || HttpContext.Current.Items["EditId"].ToString().ToLowerInvariant() != groupAccounts.SeqId.ToString().ToLowerInvariant()) { Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!"); mLog.Error(mError); return(this.InternalServerError(mError)); } MAccountProfile accountProfile = AccountUtility.CurrentProfile(); MClientChoicesState mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(accountProfile.Account); MGroupRoles mProfile = new MGroupRoles(); mProfile.SecurityEntityId = SecurityEntityUtility.CurrentProfile().Id; mProfile.GroupSeqId = groupAccounts.SeqId; mProfile.Roles = String.Join(",", groupAccounts.Accounts); mProfile.AddedUpdatedBy = accountProfile.Id; GroupUtility.UpdateGroupRoles(mProfile); return(Ok(mRetVal)); }
protected void Page_Load(object sender, EventArgs e) { string rowFilter = "FUNCTION_TYPE_SEQ_ID <> 2 AND FUNCTION_TYPE_SEQ_ID <> 3"; DataView myDataView = AccountUtility.GetMenu(AccountUtility.CurrentProfile().Account, MenuType.Hierarchical).DefaultView; myDataView.Sort = "Title asc"; myDataView.RowFilter = rowFilter; dropFavorite.DataSource = myDataView; dropFavorite.DataValueField = "url"; dropFavorite.DataTextField = "Title"; dropFavorite.DataBind(); txtPreferedRecordsPerPage.Text = ClientChoicesState[MClientChoices.RecordsPerPage].ToString(); NameValuePairUtility.SetDropSelection(dropFavorite, ClientChoicesState[MClientChoices.Action].ToString()); int X = 0; for (X = 1; X <= 5; X++) { HtmlInputRadioButton button = (HtmlInputRadioButton)this.FindControl("Radio" + X); if (button.Value.Substring(0, ClientChoicesState[MClientChoices.ColorScheme].Length).ToLower(new CultureInfo("en-US", false)) == ClientChoicesState[MClientChoices.ColorScheme].ToLower(new CultureInfo("en-US", false))) { button.Checked = true; break; // TODO: might not be correct. Was : Exit For } } }
public List <Account> GetListOfAccounts() { // create list object to return var bmAccountList = new List <Account>(); // get assets from db var dbAssetList = _unitOfWork.Assets.GetAllActiveOrderedByName(); foreach (var dbAsset in dbAssetList) { // get asset type from db var dbAssetType = _unitOfWork.AssetTypes.Get(dbAsset.AssetTypeId); if (dbAssetType == null) { return(new List <Account>()); } // add additional information to asset name if (dbAssetType.Id == AssetType.IdForCreditCard) { var dbAssetSetting = _unitOfWork.AssetSettings.GetActive(dbAsset.Id, Core.Models.SettingType.IdForAccountNumber); if (dbAssetSetting != null) { dbAsset.Name = AccountUtility.FormatAccountName(dbAsset.Name, dbAssetType.Id, dbAssetSetting.Value); } } // transfer dto to bm bmAccountList.Add(new Account(dbAsset, dbAssetType)); } return(bmAccountList); }
protected void Page_Load(object sender, EventArgs e) { MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); bool flag = mAccountProfile.Status == 4; if (flag) { this.trForceChange.Visible = true; this.trNormalChange.Visible = false; this.trOldPassword.Visible = false; this.NewPassword.Focus(); } else { this.trForceChange.Visible = false; this.trNormalChange.Visible = true; this.trOldPassword.Visible = true; this.OldPassword.Focus(); } Exception mException = GWWebHelper.ExceptionError; if (mException != null) { clientMessage.Style.Add("display", ""); clientMessage.InnerHtml = mException.Message.ToString(); GWWebHelper.ExceptionError = null; } }
public IHttpActionResult GetMenuData([FromUri] int menuType) { String mAccount = AccountUtility.HttpContextUserName(); MenuType mMenuType = (MenuType)(menuType); DataTable mDataTable = AccountUtility.GetMenu(mAccount, mMenuType); return(Ok(mDataTable)); }
protected void Page_Load(object sender, EventArgs e) { String mAccount = AccountUtility.HttpContextUserName(); DataTable myDataTable = AccountUtility.GetMenu(mAccount, MenuType.Vertical); NavigationTrail.DataSource = myDataTable.DefaultView; NavigationTrail.DataBind(); }
protected void Page_Init(object sender, EventArgs e) { string mAction = GWWebHelper.GetQueryValue(Request, "action"); if (!String.IsNullOrEmpty(mAction)) { m_SecurityInfo = new MSecurityInfo(FunctionUtility.CurrentProfile(), AccountUtility.CurrentProfile()); } }
/// <summary> /// Page_s the init. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void Page_Init(Object sender, EventArgs e) { m_SecurityInfo = new MSecurityInfo(FunctionUtility.CurrentProfile(), AccountUtility.CurrentProfile()); m_ShowDeleteLink = m_SecurityInfo.MayDelete; if (!m_SecurityInfo.MayView) { this.searchResults.Columns.RemoveAt(0); } }
private void CheckAvailable(UserInfo userInfo) { var isAdmin = AccountUtility.IsAdminUser(userInfo); if (!isAdmin) { throw new Exception(String.Format("User {0} access denied", userInfo.UserId)); } }
private void InitProp(AccountRecord accountRecord) { if (accountRecord.Apps != null) { AppsAndUrls.AddRange(AccountUtility.Split(accountRecord.Apps).Select(u => new AppViewModel(u))); } if (accountRecord.Urls != null) { AppsAndUrls.AddRange(AccountUtility.Split(accountRecord.Urls).Select(u => new AppViewModel(u, true))); } }
protected void Page_Load(object sender, EventArgs e) { MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); int mSecurityId = int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId]); dropSecurityEntities.DataSource = SecurityEntityUtility.GetValidSecurityEntities(mAccountProfile.Account, mSecurityId, mAccountProfile.IsSystemAdmin); dropSecurityEntities.DataValueField = "SE_SEQ_ID"; dropSecurityEntities.DataTextField = "NAME"; dropSecurityEntities.DataBind(); NameValuePairUtility.SetDropSelection(dropSecurityEntities, mSecurityId.ToString()); }
/* * public AccountTransaction GetTransactionOptions(int? assetId) * { * var intAssetId = DataTypeUtility.GetIntegerFromString(assetId.ToString()); * * // get asset information * var dtoAsset = GetAssetFromDatabase(intAssetId); * if (dtoAsset == null) * { * throw new ArgumentNullException(); * //return new Business.Models.AssetTransaction(); * } * * // asset name with additional information * var formattedAssetName = GetAssetNameWithAccountNumber(dtoAsset); * * // transfer dto to bm * var bmAssetTransaction = new AccountTransaction(dtoAsset, formattedAssetName); * * // get sli * //bmAssetTransaction.AssetSelectList = GetAssetSelectList(intAssetId.ToString()); * //bmAssetTransaction.TransactionTypeSelectList = GetTransactionTypeSelectList(null); * //bmAssetTransaction.TransactionCategorySelectList = GetTransactionCategorySelectList(null); * * // valid asset information * return bmAssetTransaction; * } */ /* * private Core.Models.Asset GetAssetFromDatabase(int assetId) * { * return _unitOfWork.Assets.Get(assetId); * } */ private string GetAssetNameWithAccountNumber(Asset dbAsset) { var dbAssetSetting = _unitOfWork.AssetSettings.GetActive(dbAsset.Id, SettingType.IdForAccountNumber); if (dbAssetSetting == null) { return(dbAsset.Name); } return(AccountUtility.FormatAccountName(dbAsset.Name, dbAsset.AssetTypeId, dbAssetSetting.Value)); }
public async Task <IActionResult> Edit(int id) { var account = await db.Accounts.FindAsync(id); layoutVM.AccountVM = AccountUtility.MapModelToVM(account); if (account == null) { return(NotFound()); } return(View(layoutVM)); }
protected void Page_Load(object sender, EventArgs e) { string mAction = GWWebHelper.GetQueryValue(Request, "action"); if (!String.IsNullOrEmpty(mAction)) { MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); MFunctionProfile mFunctionProfile = FunctionUtility.GetProfile(mAction); MSecurityInfo mSecurityInfo = new MSecurityInfo(mFunctionProfile, mAccountProfile); SearchControl.ShowAddLink = mSecurityInfo.MayAdd; } }
public IHttpActionResult Delete([FromUri] int functionSeqID) { if (functionSeqID <= 0) { throw new ArgumentNullException("functionSeqID", " must be a positive number!"); } string mRetVal = "False"; Logger mLog = Logger.Instance(); if (HttpContext.Current.Items["EditId"] != null) { int mEditId = int.Parse(HttpContext.Current.Items["EditId"].ToString()); if (mEditId == functionSeqID) { MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditFunction", true)), AccountUtility.CurrentProfile()); if (mSecurityInfo != null) { if (mSecurityInfo.MayDelete) { try { FunctionUtility.Delete(functionSeqID); mRetVal = "True"; } catch (Exception ex) { mLog.Error(ex); throw; } } else { Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to delete"); mLog.Error(mError); return(this.InternalServerError(mError)); } } else { Exception mError = new Exception("Security Info is not in context nothing has been saved!!!!"); mLog.Error(mError); return(this.InternalServerError(mError)); } } else { Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!"); mLog.Error(mError); return(this.InternalServerError(mError)); } } return(Ok(mRetVal)); }
public void FormatAccountName_WhenProvidedValidInput_ReturnValue_Test() { // Arrange var assetName = "name"; int assetTypeId = 1; var assetSettingValue = "value"; // Act var result = AccountUtility.FormatAccountName(assetName, assetTypeId, assetSettingValue); // Assert Assert.IsInstanceOfType(result, typeof(string), "Result Type"); }
public AccountInfoViewModel(AccountRecord accountRecord) { this.accountRecord = accountRecord; if (accountRecord.Apps != null) { AppsUrls.AddRange(AccountUtility.Split(accountRecord.Apps)); } if (accountRecord.Urls != null) { AppsUrls.AddRange(AccountUtility.Split(accountRecord.Urls)); } }
protected void Page_Load(object sender, EventArgs e) { int mSecurityEntityID = SecurityEntityUtility.DefaultProfile().Id; MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); if (mAccountProfile != null) { mSecurityEntityID = int.Parse(ClientChoicesUtility.GetClientChoicesState(AccountUtility.CurrentProfile().Account)[MClientChoices.SecurityEntityId].ToString()); } MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.GetProfile(mSecurityEntityID); formStyles.Attributes["href"] = GWWebHelper.RootSite + "/Content/FormStyles/" + mSecurityEntityProfile.Style + ".css"; }
public IHttpActionResult RequestChange(string account) { string mRetVal = string.Empty; MAccountProfile mProfile = AccountUtility.GetProfile(account); MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile(); MMessageProfile mMessageProfile = MessageUtility.GetProfile("Request Password Reset UI"); mRetVal = mMessageProfile.Body; string clearTextAccount = string.Empty; Logger mLog = Logger.Instance(); if (mProfile != null) { MAccountProfile mAccountProfile = mProfile; mAccountProfile.FailedAttempts = 0; mAccountProfile.Status = 4; mAccountProfile.Password = CryptoUtility.Encrypt(GWWebHelper.GetNewGuid, mSecurityEntityProfile.EncryptionType); mAccountProfile.UpdatedBy = AccountUtility.GetProfile("anonymous").Id; mAccountProfile.UpdatedDate = DateTime.Now; clearTextAccount = CryptoUtility.Decrypt(mProfile.Password, mSecurityEntityProfile.EncryptionType); try { mMessageProfile = MessageUtility.GetProfile("RequestNewPassword"); MRequestNewPassword mRequestNewPassword = new MRequestNewPassword(mMessageProfile); mRequestNewPassword.AccountName = HttpUtility.UrlEncode(CryptoUtility.Encrypt(mProfile.Account, mSecurityEntityProfile.EncryptionType)); mRequestNewPassword.FullName = mProfile.FirstName + " " + mProfile.LastName; mRequestNewPassword.Password = HttpUtility.UrlEncode(mProfile.Password); mRequestNewPassword.Server = GWWebHelper.RootSite; mProfile = AccountUtility.Save(mProfile, false, false); NotifyUtility.SendMail(mRequestNewPassword, mProfile); mLog.Debug("Reset password for account " + clearTextAccount); } catch (SmtpException ex) { Exception myException = new Exception("Could not send e-mail." + ex.Message); mLog.Error(myException); mMessageProfile = (MMessageProfile)MessageUtility.GetProfile("PasswordSendMailError"); mRetVal = mMessageProfile.Body; } catch (Exception ex) { Exception mException = new Exception("Could not set account details." + ex.Message); mLog.Error(mException); mMessageProfile = (MMessageProfile)MessageUtility.GetProfile("ErrorAccountDetails"); mRetVal = mMessageProfile.Body; } } return(Ok(mRetVal)); }
public IHttpActionResult Save(MUIRoleProfile profile) { if (profile == null) { throw new ArgumentNullException("uiProfile", "uiProfile cannot be a null reference (Nothing in Visual Basic)!"); } string mRetVal = "false"; MRoleProfile mProfileToSave = new MRoleProfile(); MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditRoles", true)), AccountUtility.CurrentProfile()); Logger mLog = Logger.Instance(); if (HttpContext.Current.Items["EditId"] != null) { if (profile.Id == -1) { if (!mSecurityInfo.MayAdd) { Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add"); mLog.Error(mError); return(this.InternalServerError(mError)); } mProfileToSave.AddedBy = AccountUtility.CurrentProfile().Id; mProfileToSave.AddedDate = DateTime.Now; } else { if (!mSecurityInfo.MayAdd) { Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to edit"); mLog.Error(mError); return(this.InternalServerError(mError)); } if (profile.IsSystem) { mProfileToSave.IsSystem = true; } if (profile.IsSystemOnly) { mProfileToSave.IsSystemOnly = true; } mProfileToSave = RoleUtility.GetProfile(profile.Id); mProfileToSave.UpdatedBy = AccountUtility.CurrentProfile().Id; mProfileToSave.UpdatedDate = DateTime.Now; } } mProfileToSave = populateProfile(profile); RoleUtility.Save(mProfileToSave); return(Ok(mRetVal)); }
public UserAccount Get(string name, string pass) { for (var i = 0; i < accounts.Count; i++) { if (accounts[i].Name.Equals(name, StringComparison.OrdinalIgnoreCase)) { return(accounts[i]); } } var acc = new UserAccount(accounts.Count, name, AccountUtility.CalculateHash(pass), "*****@*****.**", false, AccountPrivilege.Player, DateTime.Now, 0); accounts.Add(acc); return(acc); }
public void FormatAccountName_WhenProvidedValidInputForCreditCard_ReturnValue_Test() { // Arrange var assetName = "name"; int assetTypeId = AccountUtilityObjectMother.AssetTypeIdForCreditCard; var assetSettingValue = "value"; // Act var result = AccountUtility.FormatAccountName(assetName, assetTypeId, assetSettingValue); // Assert Assert.IsInstanceOfType(result, typeof(string), "Result Type"); Assert.AreEqual("name (value)", result, "Result"); }
protected void Page_Init(Object sender, EventArgs e) { string mAction = "Search_Functions"; if (!String.IsNullOrEmpty(mAction)) { MFunctionProfile mFunctionProfile = FunctionUtility.GetProfile(mAction); m_SecurityInfo = new MSecurityInfo(mFunctionProfile, AccountUtility.CurrentProfile()); if (!m_SecurityInfo.MayEdit) { searchResults.Columns.RemoveAt(0); } m_ShowDeleteLink = m_SecurityInfo.MayDelete; } }
/// <summary> /// Keeps the MClientChoicesState in context. /// </summary> /// <param name="sender">object</param> /// <param name="eventArgs">EventArgs</param> public void AcquireRequestState(object sender, EventArgs eventArgs) { if (ConfigSettings.DBStatus.ToUpper(CultureInfo.InvariantCulture) != ConfigSettings.DBStatus.ToUpper(CultureInfo.InvariantCulture)) { return; } //if (HttpContext.Current.Session == null) return; String mAccountName = AccountUtility.HttpContextUserName(); MClientChoicesState mClientChoicesState = null; mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(mAccountName); // Add ClientChoicesState object to the context items for use // throughout the application. HttpContext.Current.Items[MClientChoices.SessionName] = mClientChoicesState; }
public MUIAccountChoices GetPreferences() { MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); MClientChoicesState mClientChoicesState = null; MUIAccountChoices mRetVal = null; if (mAccountProfile != null) { mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(mAccountProfile.Account.ToString(CultureInfo.InvariantCulture)); mRetVal = new MUIAccountChoices(mClientChoicesState); mRetVal.Environment = GWWebHelper.DisplayEnvironment; mRetVal.Version = GWWebHelper.Version; mRetVal.FrameWorkVersion = GWWebHelper.FrameworkVersion; } return(mRetVal); }
void HandleUniverseSelection(NetworkPacket m) { Account.LoginToken = AccountUtility.GenerateTransferToken(); ServiceContainer.GetService <IDatabase>().Accounts.Save(Account); /*var selectedID = */ m.ReadInt32(); var worldServer = ServiceContainer.GetService <IWorldServer>(); var outMessage = LoginHeader.L2C_UNIVERSE_SELECTED_ACK.CreatePacket(); outMessage.WriteInt32((int)PacketStatusCode.NO_ERROR); outMessage.WriteInt32(0); //selectedID outMessage.WriteString("Complete_Universe"); outMessage.WriteInt32(Account.LoginToken); outMessage.WriteByteArrayWithoutLength(IPAddress.Parse(worldServer.PublicIP).GetAddressBytes()); outMessage.WriteUint16((ushort)worldServer.Port); Connection.SendMessage(outMessage); }
/// <summary> /// Binds the data. /// </summary> /// <param name="searchCriteria">The search criteria.</param> private void bindData(MSearchCriteria searchCriteria) { DataTable mDataTable = AccountUtility.Search(searchCriteria); if (mDataTable != null && mDataTable.Rows.Count > 0) { DataView mDataView = mDataTable.DefaultView; recordsReturned.Value = mDataTable.Rows[0][0].ToString(); searchResults.DataSource = mDataTable; searchResults.DataBind(); } else { noResults.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { SearchControl.ShowAddLink = false; MDirectoryProfile mDirectoryProfile = DirectoryUtility.GetProfile(FunctionUtility.CurrentProfile().Id); String mLinks = FileUtility.GetDirectoryLinks("/", mDirectoryProfile.FunctionSeqId); directorySelector.InnerHtml = mLinks; MFunctionProfile mFunctionProfile = FunctionUtility.CurrentProfile(); MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); MSecurityInfo mSI = new MSecurityInfo(mFunctionProfile, mAccountProfile); UploadControl.Visible = mSI.MayAdd; tdNewDirectory.Visible = mSI.MayAdd; SearchControl.ShowDeleteAll = mSI.MayDelete; SearchControl.ShowSelect = mSI.MayDelete; }
protected void Page_Load(object sender, EventArgs e) { String mAction = ClientChoicesState[MClientChoices.Action]; MFunctionProfile mFunctionProfile = FunctionUtility.GetProfile(mAction); MAccountProfile mAccountProfile = AccountUtility.CurrentProfile(); MSecurityInfo mSecurityInfo = new MSecurityInfo(mFunctionProfile, mAccountProfile); if (mSecurityInfo.MayView) { String mScript = "<script type='text/javascript' language='javascript'>window.location.hash = '?Action=" + mAction + "'</script>"; Page.ClientScript.RegisterStartupScript(this.GetType(), "", mScript); } else { Response.Write("Your favorite is not available. Please ensure that you have chosen the correct " + ConfigSettings.SecurityEntityTranslation); } }
public IActionResult ListAccount() { if (HttpContext.Session.GetInt32("checkidAdmin") != null) { ViewBag.Accounts = db.Accounts.Where(x => x.RoleId == 1).ToList(); return(View("AdminListUser")); } else if (HttpContext.Session.GetInt32("checkiduser") != null) { var users = db.Accounts.Where(x => x.RoleId == 1 && x.IsBlocked == false).ToList(); layoutVM.AccountsVM = AccountUtility.MapModelsToVMs(users); return(View("ListUser", layoutVM)); } else { return(RedirectToAction("Login")); } }