public static string GetAddedOrModifiedUser(object AddedBy, object ModifiedBy) { // bizActiveDirectory.GetUserFullName(biz.GetSetting("ActiveDirectory.LDAP"), bizUser.GetCurrentUserName().ToString().Replace(biz.GetSetting("Security.DomainName"), "")) bizSetting biz = new bizSetting(); if (ModifiedBy != null) { return(((string)ModifiedBy).Replace(biz.GetSetting("Security.DomainName"), "").Replace(biz.GetSetting("Security.DomainNameSmi"), "")); } if (AddedBy != null) { return(((string)AddedBy).Replace(biz.GetSetting("Security.DomainName"), "").Replace(biz.GetSetting("Security.DomainNameSmi"), "")); } return(""); }
private void SetControls() { ((Main)Master).HeaderTitle = "Add Client"; bizSetting bizS = new bizSetting(); ((Main)Master).HeaderDetails = "Client to be added by " + bizActiveDirectory.GetUserFullName(bizS.GetSetting(bizUser.GetCurrentUserNameWithoutDomain())) + " (Now)"; //executive bizClient biz = new bizClient(); bizUser.enGageUser user = (bizUser.enGageUser)Session["USER"]; bizUser.enGageUser exec = bizUser.GetAccountExecutive(user.SMIUserName); this.ucMessanger1.ProcessMessages(biz.MSGS, false); this.lblAccountExecutive.Text = "<b>" + exec.DisplayName + "</b>" + ", " + exec.Branch + " (" + exec.Region + ")"; //defaults this.ddlFlagged.SelectedValue = "false"; if (Request.QueryString["name"] != null) { txtClientName.Text = HttpUtility.UrlDecode(Request.QueryString["name"]); } }
protected void AuthenticateUser() { if (Session["USER"] != null) { return; } bizSetting biz = new bizSetting(); var u = bizUser.GetCurrentUserNameWithoutDomain(); bizUser.enGageUser user = bizUser.GetCurrentUser(u); if (user == null) { Response.Redirect("~/NotAuthorised.aspx", false); return; } //check if it's in one of the correct domains string userName = bizUser.GetCurrentUserName().ToUpper(); if (userName.Contains(biz.GetSetting("Security.DomainName")) || userName.Contains(biz.GetSetting("Security.DomainNameSmi"))) { //ok to proceed } else { Response.Redirect("~/NotAuthorised.aspx", false); return; } if (Session["USER"] == null) { System.Security.Principal.WindowsPrincipal wp = null; wp = bizUser.GetCurrentAuthinticatedUserPrincipal(); //(System.Security.Principal.WindowsPrincipal)HttpContext.Current.User; string username = wp.Identity.Name; var groups = GetGroupNames(username); // ======================================================================= //check user roles/groups string ExecutiveGroup = biz.GetSetting("Security.ADExecutiveGroup"); string ExecutiveGroupSmi = biz.GetSetting("Security.ADExecutiveGroupSmi"); if (groups.Contains(ExecutiveGroupSmi)) { user.Role = (int)Enums.enUserRole.Executive; } //try //{ // if (wp.IsInRole(ExecutiveGroup) || wp.IsInRole(ExecutiveGroupSmi)) // { // user.Role = (int)Enums.enUserRole.Executive; // } //} //catch //{ // //do nothing //} // ======================================================================= string BranchGroup = biz.GetSetting("Security.ADBranchGroup"); string BranchGroupSmi = biz.GetSetting("Security.ADBranchGroupSmi"); if (groups.Contains(BranchGroupSmi)) { user.Role = (int)Enums.enUserRole.Branch; } //try //{ // if (wp.IsInRole(BranchGroup) || wp.IsInRole(BranchGroupSmi)) // { // user.Role = (int)Enums.enUserRole.Branch; // } //} //catch //{ // //do nothing //} // ======================================================================= string RegionGroup = biz.GetSetting("Security.ADRegionGroup"); string RegionGroupSmi = biz.GetSetting("Security.ADRegionGroupSmi"); if (groups.Contains(RegionGroupSmi)) { user.Role = (int)Enums.enUserRole.Region; } //try //{ // if (wp.IsInRole(RegionGroup) || wp.IsInRole(RegionGroupSmi)) // { // user.Role = (int)Enums.enUserRole.Region; // } //} //catch //{ // //do nothing //} // ======================================================================= string CompanyGroup = biz.GetSetting("Security.ADCompanyGroup"); string CompanyGroupSmi = biz.GetSetting("Security.ADCompanyGroupSmi"); if (groups.Contains(CompanyGroupSmi)) { user.Role = (int)Enums.enUserRole.Company; } //try //{ // if (wp.IsInRole(CompanyGroup) || wp.IsInRole(CompanyGroupSmi)) // { // user.Role = (int)Enums.enUserRole.Company; // } //} //catch //{ // //do nothing //} // ======================================================================= string AdminGroup = biz.GetSetting("Security.ADAdminGroup"); string AdminGroupSmi = biz.GetSetting("Security.ADAdminGroupSmi"); if (groups.Contains(AdminGroupSmi)) { user.Role = (int)Enums.enUserRole.Administrator; } //try //{ // if (wp.IsInRole(AdminGroup) || wp.IsInRole(AdminGroupSmi)) // { // user.Role = (int)Enums.enUserRole.Administrator; // } //} //catch //{ // //do nothing //} if (user.Role == null) { Response.Redirect("~/NotAuthorised.aspx", false); return; } Session.Add("USER", user); } }
private void SetHeaderAndFooter() { bizSetting biz = new bizSetting(); this.lblVersion.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); this.lblReleased.Text = String.Format("{0:dd MMMM yyyy}", System.IO.File.GetLastWriteTime(System.Reflection.Assembly.GetExecutingAssembly().Location)); bizUser.enGageUser currentUser = (bizUser.enGageUser)Session["USER"]; var env = Cache.Get("env") as string; if (String.IsNullOrEmpty(env)) { this.Environment = biz.GetSetting("Application.Environment"); Cache.Insert("env", Environment); } if (this.Environment == "Production") { if (this.GetCurrentPageName().ToLower() == "northsydneyreport.aspx" || this.GetCurrentPageName().ToLower() == "dashboardtotals.aspx" || this.GetCurrentPageName().ToLower() == "dashboard.aspx" || this.GetCurrentPageName().ToLower() == "tallyboard.aspx" ) { this.header.Attributes["class"] = "header"; this.footer.Attributes["class"] = "footer"; } else { this.header.Attributes["class"] = "header"; this.footer.Attributes["class"] = "footer"; } // this.lblHeaderLine1.CssClass = "header-line1-alt"; // this.lblHeaderLine2.CssClass = "header-line2-alt"; this.lblHeaderLine1.Text = this.lblHeaderLine1.Text.Replace("???", "<span class='header-line1-name' runat='server'>" + currentUser.DisplayName + "</span>"); } else { this.lblEnvironment.Text = this.Environment; this.lblHeaderLine1.Text = this.lblHeaderLine1.Text.Replace("???", "<span class='header-line1-name-alt' runat='server'>" + currentUser.DisplayName + "</span>"); if (this.GetCurrentPageName().ToLower() == "northsydneyreport.aspx" || this.GetCurrentPageName().ToLower() == "dashboardtotals.aspx" || this.GetCurrentPageName().ToLower() == "dashboard.aspx" || this.GetCurrentPageName().ToLower() == "tallyboard.aspx" ) { this.header.Attributes["class"] = "header-wide-alt"; this.footer.Attributes["class"] = "footer-wide-alt"; } else { this.header.Attributes["class"] = "header-alt"; this.footer.Attributes["class"] = "footer-alt"; } this.lblHeaderLine1.CssClass = "header-line1-alt"; this.lblHeaderLine2.CssClass = "header-line2-alt"; enGageDataContext db = new enGageDataContext(); this.lblDatabase.Text = "database " + db.Connection.Database + " on " + db.Connection.DataSource + " server"; } }
private void LoadClients() { bizMessage bizM = new bizMessage(); bizSetting bizS = new bizSetting(); int MaxRecords = int.Parse(bizS.GetSetting("FindClient.MaxRecords")); bizClient biz = new bizClient(); this.ucMessanger1.ClearMessages(); if (Request.QueryString["gr"] == "ba") { int?records = 0; List <sp_engage_search_clientResult> clients = biz.FindClientInBA(Request.QueryString["sc"] , Request.QueryString["f1"] , char.Parse(Request.QueryString["f2"]) , MaxRecords , ref records); this.ucMessanger1.ProcessMessages(biz.MSGS, true); if (clients == null) { return; } this.grvClientsBA.DataSource = clients; this.grvClientsBA.DataBind(); this.lblResultCount.Text = clients.Count.ToString(); } else { int?records = 0; List <sp_web_FindClientByFieldResult> clients = biz.FindClientByField(Request.QueryString["sc"] , Request.QueryString["f1"] , char.Parse(Request.QueryString["f2"]) , Request.QueryString["gr"] , MaxRecords , ref records); this.ucMessanger1.ProcessMessages(biz.MSGS, true); if (clients == null) { return; } foreach (sp_web_FindClientByFieldResult c in clients) { if (c.AccountExecutiveID != "") { using (Timeline.Capture("bizUser.GetAccountExecutive", "AD")) { var u = bizUser.GetSMIAccountExecutiveIdBOAMPSUserName(c.AccountExecutiveID); bizUser.enGageUser exec = bizUser.GetAccountExecutive(u); if (exec != null) { c.DisplayName = exec.DisplayName; } else { c.DisplayName = c.AccountExecutiveID; } } } } this.grvClients.DataSource = clients; this.grvClients.DataBind(); this.lblResultCount.Text = clients.Count.ToString(); } this.lblSearch.Text = Request.QueryString["sc"]; this.btnBack.PostBackUrl = "FindClient.aspx?" + "sc=" + Request.QueryString["sc"] + "&" + "f1=" + Request.QueryString["f1"] + "&" + "f2=" + Request.QueryString["f2"]; }
private void LoadClients() { bizMessage biz = new bizMessage(); this.ucMessanger1.ClearMessages(); this.txtSearchCriteria.CssClass = "control"; //this.ucMessanger1.UnmarkControls(); // todo: doesn't work this.grvClientsClientName.Visible = false; this.grvClientsAddress.Visible = false; this.grvClientsIndustry.Visible = false; if (this.txtSearchCriteria.Text == "") { this.ucMessanger1.ProcessMessage(biz.GetMessageText("EmptyField"), Enums.enMsgType.Err, "SearchCriteria", typeof(TextBox), false); return; } bizSetting bizS = new bizSetting(); int MaxRecords = int.Parse(bizS.GetSetting("FindClient.MaxRecords")); bizClient bizC = new bizClient(); int? records = 0; List <sp_web_FindClientByFieldResult> clients = bizC.FindClientByField(this.txtSearchCriteria.Text , this.ddlClient.SelectedValue , char.Parse(this.ddlMatch.SelectedValue) , null , MaxRecords , ref records); this.ucMessanger1.ProcessMessages(bizC.MSGS, true); if (clients == null) { return; } // get all users in AD var allusersResult = bizUser.GetUsersAccountExecutives(clients.Select <sp_web_FindClientByFieldResult, string>(x => x.AccountExecutiveID).Distinct().ToList()); // change all clients clients.ForEach( x => { if (x.AccountExecutiveID != "" && allusersResult.ContainsKey(x.AccountExecutiveID)) { bizUser.enGageUser exec = allusersResult[x.AccountExecutiveID]; //bizUser.GetAccountExecutive(x.AccountExecutiveID); if (exec != null) { x.DisplayName = exec.DisplayName; } else { x.DisplayName = x.AccountExecutiveID; } } } ); List <sp_web_FindClientByFieldResult> cn = clients.Where(c => c.Match == "client").ToList(); List <sp_web_FindClientByFieldResult> add = clients.Where(c => c.Match == "address").ToList(); List <sp_web_FindClientByFieldResult> ind = clients.Where(c => c.Match == "industry").ToList(); if (records == 0) { this.btnAdd.Visible = true; this.tdHeaderCN.Visible = false; this.tdFooterCN.Visible = false; this.tdHeaderAD.Visible = false; this.tdFooterAD.Visible = false; this.tdHeaderIND.Visible = false; this.tdFooterIND.Visible = false; this.ucMessanger1.ProcessMessage("enGage: " + biz.GetMessageText("NoClientsFound"), Enums.enMsgType.Warn, "", null, false); // change the new postpack url btnAdd.PostBackUrl += "?name=" + HttpUtility.UrlEncode(this.txtSearchCriteria.Text); return; } if (records > 0 && records <= MaxRecords) { this.btnAdd.Visible = true; /*foreach (sp_web_FindClientByFieldResult c in cn) * { * if (c.AccountExecutiveID != "") * { * bizUser.enGageUser exec = bizUser.GetAccountExecutive(c.AccountExecutiveID); * if (exec != null) * c.DisplayName = exec.DisplayName; * else * c.DisplayName = c.AccountExecutiveID; * } * } * foreach (sp_web_FindClientByFieldResult c in add) * { * if (c.AccountExecutiveID != "") * { * bizUser.enGageUser exec = bizUser.GetAccountExecutive(c.AccountExecutiveID); * if (exec != null) * c.DisplayName = exec.DisplayName; * else * c.DisplayName = c.AccountExecutiveID; * } * } * foreach (sp_web_FindClientByFieldResult c in ind) * { * if (c.AccountExecutiveID != "") * { * bizUser.enGageUser exec = bizUser.GetAccountExecutive(c.AccountExecutiveID); * if (exec != null) * c.DisplayName = exec.DisplayName; * else * c.DisplayName = c.AccountExecutiveID; * } * }*/ if (cn.Count == 0) { this.tdHeaderCN.Visible = false; this.grvClientsClientName.Visible = false; this.tdFooterCN.Visible = false; } else { this.lblResultCountCN.Text = cn.Count.ToString(); this.lblSearchCN.Text = this.txtSearchCriteria.Text; this.tdHeaderCN.Visible = true; this.grvClientsClientName.DataSource = cn; this.grvClientsClientName.DataBind(); this.grvClientsClientName.Visible = true; this.tdFooterCN.Visible = true; this.lnkCN.Enabled = true; if (cn.Count <= this.grvClientsClientName.PageSize) { this.lnkCN.Enabled = false; } } if (add.Count == 0) { this.tdHeaderAD.Visible = false; this.grvClientsAddress.Visible = false; this.tdFooterAD.Visible = false; } else { this.lblResultCountAD.Text = add.Count.ToString(); this.lblSearchAD.Text = this.txtSearchCriteria.Text; this.tdHeaderAD.Visible = true; this.grvClientsAddress.DataSource = add; this.grvClientsAddress.DataBind(); this.grvClientsAddress.Visible = true; this.tdFooterAD.Visible = true; this.lnkAD.Enabled = true; if (add.Count <= this.grvClientsAddress.PageSize) { this.lnkAD.Enabled = false; } } if (ind.Count == 0) { this.tdHeaderIND.Visible = false; this.grvClientsIndustry.Visible = false; this.tdFooterIND.Visible = false; } else { this.lblResultCountIND.Text = ind.Count.ToString(); this.lblSearchIND.Text = this.txtSearchCriteria.Text; this.tdHeaderIND.Visible = true; this.grvClientsIndustry.DataSource = ind; this.grvClientsIndustry.DataBind(); this.grvClientsIndustry.Visible = true; this.tdFooterIND.Visible = true; this.lnkIND.Enabled = true; if (ind.Count <= this.grvClientsIndustry.PageSize) { this.lnkIND.Enabled = false; } } if (records == MaxRecords) { this.ucMessanger1.ProcessMessage("enGage: " + biz.GetMessageText("MaxClientsReached"), Enums.enMsgType.Warn, "", null, false); } return; } if (records > MaxRecords) { this.btnAdd.Visible = false; this.tdHeaderCN.Visible = false; this.tdFooterCN.Visible = false; this.tdHeaderAD.Visible = false; this.tdFooterAD.Visible = false; this.tdHeaderIND.Visible = false; this.tdFooterIND.Visible = false; this.ucMessanger1.ProcessMessage("enGage: " + biz.GetMessageText("TooManyClientsFound"), Enums.enMsgType.Warn, "", null, false); return; } }
private void LoadClientsBA() { bizMessage bizM = new bizMessage(); //this.ucMessanger1.ClearMessages(); if (this.txtSearchCriteria.Text == "") { this.ucMessanger1.ProcessMessage(bizM.GetMessageText("EmptyField"), Enums.enMsgType.Err, "SearchCriteria", typeof(TextBox), false); return; } bizSetting bizS = new bizSetting(); int MaxRecords = int.Parse(bizS.GetSetting("FindClient.MaxRecords")); bizClient biz = new bizClient(); int? records = 0; List <sp_engage_search_clientResult> clients = biz.FindClientInBA(this.txtSearchCriteria.Text , this.ddlClient.SelectedValue , char.Parse(this.ddlMatch.SelectedValue) , MaxRecords , ref records); this.ucMessanger1.ProcessMessages(biz.MSGS, false); if (clients == null) { return; } if (records == 0) { this.btnAdd.Visible = true; this.tdHeaderBA.Visible = false; this.grvClientsBA.Visible = false; this.tdFooterBA.Visible = false; this.ucMessanger1.ProcessMessage("iBAIS: " + bizM.GetMessageText("NoClientsFound"), Enums.enMsgType.Warn, "", null, false); } if (records > 0 && records <= MaxRecords) { this.btnAdd.Visible = true; this.lblResultCountBA.Text = clients.Count.ToString(); this.lblSearchBA.Text = this.txtSearchCriteria.Text; this.tdHeaderBA.Visible = true; this.grvClientsBA.DataSource = clients; this.grvClientsBA.DataBind(); this.grvClientsBA.Visible = true; this.tdFooterBA.Visible = true; this.lnkBA.Enabled = true; if (clients.Count <= this.grvClientsBA.PageSize) { this.lnkBA.Enabled = false; } if (records == MaxRecords) { this.ucMessanger1.ProcessMessage("iBAIS: " + bizM.GetMessageText("MaxClientsReached"), Enums.enMsgType.Warn, "", null, false); } } if (records > MaxRecords) { this.btnAdd.Visible = false; this.tdHeaderBA.Visible = false; this.grvClientsBA.Visible = false; this.tdFooterBA.Visible = false; this.ucMessanger1.ProcessMessage("iBAIS: " + bizM.GetMessageText("TooManyClientsFound"), Enums.enMsgType.Warn, "", null, false); } }