protected void btnLogSub_Click(object sender, EventArgs e) { MembershipManager mgr = new MembershipManager(); mgr.LogSubtopicPageView(Guid.Parse("93e4c02c-3d3d-4ccd-95a3-180bb513e543"), Guid.NewGuid(), new Guid()); mgr.LogSubtopicPageView(Guid.Parse("93e4c02c-3d3d-4ccd-95a3-180bb513e543"), Guid.NewGuid(), new Guid()); }
protected override void Initialize(RequestContext requestContext) { base.Initialize(requestContext); if (User.Identity.IsAuthenticated) { CurrentUser = new MembershipManager().GetCurrentAccount(User.Identity.Name); ViewBag.CurrentUser = CurrentUser; if (CurrentUser == null || CurrentUser.CrmUser == null) { Response.Redirect("~/Account/Login?returnurl=" + Request.RawUrl); return; } if (requestContext.HttpContext.Request.HttpMethod == "GET") { var controllername = requestContext.RouteData.Values["controller"].ToString().ToLower(); var currentController = controllername; if (Session["CurrentController"] == null || Session["CurrentController"].ToString() != currentController) { controllername = string.Format("'{0}'", controllername); var currentUrl = string.Format("/{0}", controllername); if (!string.IsNullOrEmpty(OtherControllers)) { controllername += "," + OtherControllers; } var myAllActions = new MembershipManager().GetUserMenus(CurrentUser.CrmUser.Id, controllername); Session["CurrentUrl"] = currentUrl; Session["MyAllActions"] = myAllActions.ToLower(); } } } else { Response.Redirect("~/Account/Login?returnurl=" + Request.RawUrl); } }
public NodeToCSHeartbeatTask(NodeContext context, MembershipManager manager, IConnectionRestoration connectionRestoration, ClusterConfigurationManager clusterConfigMgr) { this._context = context; this._clusterConfigMgr = clusterConfigMgr; ShardConfiguration sConfig = null; if (_clusterConfigMgr != null) { sConfig = _clusterConfigMgr.GetShardConfiguration(_context.LocalShardName); if (_clusterConfigMgr.LatestConfiguration != null && _clusterConfigMgr.LatestConfiguration.Deployment != null) { _heartbeatInterval = 1000 * _clusterConfigMgr.LatestConfiguration.Deployment.HeartbeatInterval; } } if (sConfig != null && sConfig.Servers != null) { _node = sConfig.Servers.GetServerNode(_context.LocalAddress.IpAddress.ToString()); } this._membershipManager = manager; this._connectionRestoration = connectionRestoration; _running = false; _startSignal = new System.Threading.ManualResetEvent(false); }
protected string GenerateLogonId(string firstName, string lastName) { string logonId = string.Empty; // Check the txtUserId field first. If not null, then don't generate a new one. if (string.IsNullOrEmpty(txtUserId.Text)) { // Auto generate a userid. logonId = firstName.Replace(" ", string.Empty) + lastName.Replace(" ", string.Empty); if (logonId.Length > 18) { logonId = logonId.Substring(0, 18); } } else { logonId = txtUserId.Text; } int iterator = 1; string originalLogonId = logonId; const int circuitBreaker = 100; while (MembershipManager.GetUserByName(logonId) != null && circuitBreaker > iterator) { logonId = originalLogonId + iterator.ToString(); ++iterator; } return(logonId); }
void btnSubmit_Click(object sender, EventArgs e) { pnlResults.Update(); MembershipManager mm = new MembershipManager(); if (!string.IsNullOrEmpty(txtEmail.Text)) { var member = mm.GetMember(txtEmail.Text); if (member != null) { bool hasChildren = member.Children.Any(); pnlChildren.Visible = hasChildren; if (hasChildren) { ddlChildren.DataSource = member.Children; ddlChildren.DataTextField = "Nickname"; ddlChildren.DataValueField = "ChildId"; ddlChildren.DataBind(); } if (member.Interests.Any()) { rptInterests.DataSource = member.Interests; rptInterests.DataBind(); } } } }
/// <summary> /// this method removes user of task /// </summary> /// <param name="task"></param> /// <param name="userId"></param> /// <param name="alert"></param> private void RemoveUserOfTask(Task task, Int32 userId, Alert alert) { alert = alert ?? new Alert(); if (alert.AlertId == 0) { // // Send Alert to Creator Task // var manager = new MembershipManager(this); alert.UserId = task.CreatorUserId; alert.Description = alert.Description ?? String.Format( "<b>{0}</b> concluiu sua parte na tarefa " + CreateTaskHtmlLink(task) + "!", manager.GetUser(userId).Profile.AbreviatedName); new AlertManager(this).InsertAlert(alert); } foreach (Task childTask in task.Tasks) { RemoveUserOfTask(childTask, userId, alert); } DbContext.TaskUsers.DeleteAllOnSubmit( DbContext.TaskUsers.Where(taskUser => taskUser.TaskId == task.TaskId && taskUser.UserId == userId)); DbContext.SubmitChanges(); }
private void CreateBorrowedItem(int resourceId, int membershipId) { var resource = ResourceManager.GetResource(resourceId); var member = MembershipManager.GetMembership(membershipId); BorrowingManager.AddEntryToBorrowedItemsHistory(resource, member); }
public void LoadState(string userName) { //if user is not open to connections - don't show anything //if other user is not open to connection - don't show anything //if user has sent pending request, show "request sent" //if user has pending request from another user, show "accept / decline" buttons //if user has connected, show "view activity" this.Visible = false; if (!String.IsNullOrEmpty(userName)) { UserName = userName.Trim(); Text = DictionaryConstants.ConnectBtnText; try { if (CurrentMember != null && CurrentMember.ScreenName != null) { //Check if same user if (!CurrentMember.ScreenName.Equals(userName) && MembershipManager.isOpenToConnect(userName) && MembershipManager.isOpenToConnect(CurrentMember.ScreenName)) { //Check friendship Status = TelligentService.IsFriend(CurrentMember.ScreenName, UserName); this.Visible = true; //Set Text Appropriately switch (Status) { case Constants.TelligentFriendStatus.NotSpecified: break; case Constants.TelligentFriendStatus.Pending: Text = DictionaryConstants.RequestSent; break; case Constants.TelligentFriendStatus.Approved: Text = DictionaryConstants.ViewActivity; break; case Constants.TelligentFriendStatus.Recieved: Text = DictionaryConstants.RequestRecieved; break; default: this.Visible = false; break; } } } else { this.Text = DictionaryConstants.ConnectBtnText; } } catch (Exception ex) { Sitecore.Diagnostics.Error.LogError("Error in LoadState function.\nError:\n" + ex.Message); } } }
private void UsersSelected(PriceList pl) { ltUsers.Clear(); //usuario de la lista de precios ArrayList users = PermissionManager.GetUsersForEntity(pl, pl.ID.ToString(), PermissionAction.Create) as ArrayList; //usuarios del sitio IList <UserMember> lstUsers = MembershipManager.ListBySite(); bool wasAdded = false; foreach (UserMember u in lstUsers) { if (pl != null) { foreach (string um in users) { wasAdded = false; if (um == u.Email) { wasAdded = true; ltUsers.AddDestinationItem(new ListItem(u.UserName, u.ID.ToString())); break; } } if (!wasAdded) { ltUsers.AddItem(new ListItem(u.UserName, u.ID.ToString())); } } else { ltUsers.AddItem(new ListItem(u.UserName, u.ID.ToString())); } } }
private void GetMember() { string screenName = Sitecore.Web.WebUtil.GetUrlName(0); // Verify user exists in telligent var telligentUser = TelligentService.GetUser(screenName); if (telligentUser == null || telligentUser.Username != screenName) { // TODO: display error? Sitecore.Diagnostics.Log.Info(String.Format("View Profile - Could not find user in telligent: {0}", screenName), this); Response.Redirect(MainsectionItem.GetHomeItem().GetUrl()); return; } // Check member account MembershipManager mm = new MembershipManager(); _profileMember = mm.GetMemberByScreenName(screenName); if (_profileMember == null) { // TODO: display error? Sitecore.Diagnostics.Log.Info(String.Format("View Profile - Could not find member with screen name: {0}", screenName), this); Response.Redirect(MainsectionItem.GetHomeItem().GetUrl()); return; } }
public JsonResult ChangePassword(string oldpwd, string newpwd) { var isOk = false; try { var currentUser = new MembershipManager().GetCurrentAccount(User.Identity.Name); if (currentUser != null && currentUser.CrmUser != null) { var user = currentUser.CrmUser; if (!string.IsNullOrEmpty(user.Id)) { isOk = new MembershipManager().ChangePassword(user.Id, oldpwd, newpwd); } } } catch (Exception ex) { isOk = false; } var result = new StatusModel <DBNull> { rtState = isOk ? 1 : -1, rtData = null, rtObj = null, rtMsrg = isOk ? "密码修改成功!" : "修改失败,请确认旧密码是否正确!" }; return(Json(result, JsonRequestBehavior.AllowGet)); }
protected void Page_Load(object sender, EventArgs e) { //var un = string.Empty; if (!string.IsNullOrEmpty(Request.QueryString["un"])) { un = Request.QueryString["un"]; } else { un = "*****@*****.**"; } ////litRoles.Text = MembershipManager.isOpenToConnect(un).ToString(); var membershipManager = new MembershipManager(); //var sb = new StringBuilder(); //var output = @"Method: {0}:{1}</br>"; var member = membershipManager.GetMember(un); //var memberId = member.MemberId; //sb.Append(string.Format(output, "membershipManager.GetMemberByScreenName(un).Email", membershipManager.GetMemberByScreenName(un).Email)); //sb.Append(string.Format(output, "membershipManager.GetMember(memberId).Email", membershipManager.GetMember(memberId).Email)); //sb.Append(string.Format(output, "membershipManager.GetMember('[email protected]').Email", membershipManager.GetMember("[email protected]").Email)); ////sb.Append(string.Format(output, "membershipManager.GetMember('[email protected]').Email", membershipManager.GetMembers().FirstOrDefault(x => x.Email == "[email protected]").Email)); //sb.Append(string.Format(output, "membershipManager.GetMembers().FirstOrDefault(x => x.MemberId == memberId).Email", membershipManager.GetMembers().FirstOrDefault(x => x.MemberId == memberId).Email)); //sb.Append(string.Format(output, "membershipManager.GetUser(memberId).Email", membershipManager.GetUser(memberId).Email)); //litRoles.Text = sb.ToString(); litEmail.Text = member.Email; }
public LocalShardSendHeartbeatTask(NodeContext nodeContext, IShard shard, MembershipManager membershipManager, ClusterConfigurationManager clusterConfigMgr) { this._nodeContext = nodeContext; this._clusterConfigMgr = clusterConfigMgr; ShardConfiguration config = _clusterConfigMgr.GetShardConfiguration(_nodeContext.LocalShardName);//_nodeContext.ConfigurationSession.GetDatabaseClusterConfiguration(_nodeContext.ClusterName).Deployment.GetShardConfiguration(_nodeContext.LocalShardName); if (config == null) { if (LoggerManager.Instance.ShardLogger != null && LoggerManager.Instance.ShardLogger.IsErrorEnabled) { LoggerManager.Instance.ShardLogger.Error("LocalShardSendHeartTask", "shard configuration is null"); } throw new Alachisoft.NosDB.Common.Exceptions.DatabaseException(" shard configuration is null"); } if (config.NodeHeartbeatInterval > 0) { this._poolingThreshold = (config.NodeHeartbeatInterval) * 1000; } this._shard = shard; this._membershipManager = membershipManager; _running = false; _startSignal = new System.Threading.ManualResetEvent(false); }
protected void uxSave_Click(object sender, EventArgs e) { uxMessage.Text = ""; CurrentMember.AdvocacyAlerts = ux_advocacy_alerts.Checked; CurrentMember.ContentReminders = ux_content_reminders.Checked; CurrentMember.EventReminders = ux_event_reminders.Checked; CurrentMember.NotificationsDigest = ux_notifications_digest.Checked; CurrentMember.ObservationLogReminders = ux_observation_log_reminders.Checked; CurrentMember.PrivateMessageAlerts = ux_private_message_alerts.Checked; CurrentMember.SupportPlanReminders = ux_support_plan_reminders.Checked; CurrentMember.allowNewsletter = ux_weekly_personalized_newsletter.Checked; CurrentMember.Subscribed_DailyDigest = ux_digest_email_daily.Checked; CurrentMember.Subscribed_WeeklyDigest = ux_digest_email_weekly.Checked; MembershipManager mgr = new MembershipManager(); try { mgr.UpdateMemberAlertPrefernces(CurrentMember); } catch (Exception ex) { uxMessage.Text = ex.Message; } uxMessage.Text += DictionaryConstants.MyAccount_PreferencesSavedLabel; }
protected void Page_Load(object sender, EventArgs e) { string urlCurrent = HttpContext.Current.Request.Url.AbsolutePath; string urlChangePassword = Navigation.User_ChangePassword().GetServerUrl(true); string urlChangePasswordFilename = urlChangePassword.Substring(urlChangePassword.LastIndexOf("/") + 1); if (Page.User.Identity.IsAuthenticated && !urlCurrent.Contains(urlChangePasswordFilename)) { User currentUser = MembershipManager.GetUserByName(Page.User.Identity.Name); LoginName loginName = HeadLoginView.FindControl("HeadLoginName") as LoginName; if (loginName != null) { loginName.FormatString = Utilities.GetDisplayUserFirstName(currentUser.Name); } if (currentUser.PasswordChangeRequired) { Response.Redirect(Navigation.User_ChangePassword().GetServerUrl(true)); } } // Retrieve the client version number, add it to lblVersionNumber. string fileName = Path.Combine(Server.MapPath("~"), "Version.txt"); if (File.Exists(fileName)) { lblVersionNumber.Text = File.ReadAllText(fileName); } Page.Title = "BusiBlocks - " + Page.Title; DisplayAnyFeedback(); }
/// <summary> /// MM_s the user authenticated. /// </summary> /// <param name="userDto">The user dto.</param> void mm_UserAuthenticated(UserDTO userDto) { #if DEBUG //AppMenuView ap = this.Parent; //DashboardMainPage dp = ap.Parent; //dp.UserStats.ItemsSource = applicationViewModel.LoggedInUser; // ((DashboardMainPage)(AppMenuView(this.Parent))).UserStats.ItemsSource = applicationViewModel.LoggedInUser; // ((DashboardMainPage)(AppMenuView(this.Parent))).UserStats.ItemsSource = applicationViewModel.LoggedInUser; #endif mm.UserAuthenticated -= new MembershipManager.UserAuthenticatedHandler(mm_UserAuthenticated); // bool UserShouldResetPassword = (bool)sender; UserDTO dto = userDto as UserDTO; if (dto.ShouldResetPassword) { ResetPwd resetpwd = new ResetPwd(); resetpwd.Show(); } // Reset passwod if neccessary but always load the authenticated user mm = new MembershipManager(); mm.LoadUser(dto.UserName); mm.UserLoaded += new System.EventHandler(mm_UserLoaded); mm.UserNotAuthenticated += new System.EventHandler(mm_UserNotAuthenticated); }
public override void DeletePerson(string personId) { // If person regions exist. if (IsPersonInPersonRegion(personId)) { throw new SchemaIntegrityException("Unable to delete. Person exists in a Region"); } // If person persontypes exist. if (IsPersonInPersonType(personId)) { throw new SchemaIntegrityException("Unable to delete. Person exists in a PersonType"); } // If person personsite exist. if (IsPersonInPersonSite(personId)) { throw new SchemaIntegrityException("Unable to delete. Person exists at a Site"); } using (var transaction = new TransactionScope(_configuration)) { var ptDS = new PersonDataStore(transaction); Person person = ptDS.FindByKey(personId); User user = MembershipManager.GetUserByPerson(person); System.Web.Security.Membership.DeleteUser(user.Name); person.Deleted = true; ptDS.Update(person); transaction.Commit(); } }
protected void btnAgree_Click(object sender, EventArgs e) { CurrentMember.AgreedToSignUpTerms = true; var membershipManager = new MembershipManager(); membershipManager.UpdateMember(CurrentMember); BaseReply reply = ExactTargetService.InvokeWelcomeToUnderstood(new InvokeWelcomeToUnderstoodRequest { PreferredLanguage = CurrentMember.PreferredLanguage, ToEmail = CurrentUser.Email, FirstName = CurrentMember.FirstName, RequestUrl = Request.Url }); //string url = MembershipHelper.GetNextStepURL(1); // send them to My Account, not into CMP string url = MyAccountItem.GetMyAccountPage().GetUrl(); // NOTE: temorarily commented out to prevent 404 redirect //if (Session[Constants.SessionPreviousUrl] != null) //{ // url = Session[Constants.SessionPreviousUrl].ToString(); //} //redirect based on interrupt this.ReturnRedirect(); //if no sign-up interrupt was set, redirect as normal Response.Redirect(url); }
public static bool IsApprover(string username, string ItemId) { bool isApprover = false; if (username == "admin") { isApprover = true; } else { string userId = MembershipManager.GetUserByName(username).Id; IList <Approver> approvers = ApproverManager.GetApproversByItem(ItemId); foreach (Approver approver in approvers) { if ((!string.IsNullOrEmpty(approver.UserId)) && (approver.UserId == userId)) { isApprover = true; } if (string.IsNullOrEmpty(approver.UserId)) { if (!string.IsNullOrEmpty(approver.CategoryId)) { if (SecurityHelper.CanUserEdit(username, approver.CategoryId)) { isApprover = true; } } } } } return(isApprover); }
private MailMessage CreateMessageFromTemplate(FeedbackForm form) { MailMessage message = new MailMessage(); var xmlDocument = new XmlDocument(); string xmlFile = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/MailTemplate_Feedback.xml"); xmlDocument.Load(xmlFile); XmlNodeList blockNodes = xmlDocument.GetElementsByTagName("body"); foreach (XmlNode node in blockNodes) { message.Body = node.InnerText; } User user = MembershipManager.GetUserByName(form.UserId); Person person = PersonManager.GetPersonByUserId(user.Id); message.From = new MailAddress((!string.IsNullOrEmpty(person.Email)) ? person.Email : "*****@*****.**"); message.To.Add(new MailAddress("*****@*****.**")); message.Subject = form.Type + "-" + form.Subject; message.Body = ReplaceTokens(message.Body, form, user, person); return(message); }
private void VoteNeutral() { MembershipManager mmgr = new MembershipManager(); try { //mmgr.LogMemberHelpfulVote bool success = mmgr.ClearHelpfulVote(CurrentMember.MemberId, context.ID.ToGuid(), Constants.UserActivity_Values.FoundHelpful_True, Constants.UserActivity_Types.FoundHelpfulVote); success = mmgr.ClearHelpfulVote(CurrentMember.MemberId, context.ID.ToGuid(), Constants.UserActivity_Values.FoundHelpful_False, Constants.UserActivity_Types.FoundHelpfulVote); if (success) { btnNo.Attributes.Add("class", "helpful-no"); btnYes.Attributes.Add("class", "helpful-yes"); Response.Redirect(Request.RawUrl); } } catch { } }
public string GetSiteAccessDetails() { Person queryPerson = PersonManager.GetAllPersons().FirstOrDefault <Person>(x => x.Id.Equals(Id)); IList <SiteAccessDetail> sites = new List <SiteAccessDetail>(); JavaScriptSerializer serializer = new JavaScriptSerializer(); if (queryPerson != null) { User user1 = MembershipManager.GetUserByPerson(queryPerson); MembershipUser membershipUser = Membership.GetUser(user1.Name); if (!string.IsNullOrEmpty(membershipUser.UserName)) { IList <Site> userSites = SiteManager.GetSitesByUser(membershipUser.UserName, false); foreach (Site site in userSites) { PersonSite PS = PersonManager.GetPersonSiteByPersonAndSite(queryPerson, site, false); sites.Add(new SiteAccessDetail() { PersonId = PS.Person.Id, LocationId = site.Id, IsAdmin = PS.IsAdministrator, IsManager = PS.IsManager, IsPrimary = PS.IsDefault, IsView = PS.IsAssigned, Name = site.Name }); } } } return(serializer.Serialize(sites)); }
protected void uxSave_Click(object sender, EventArgs e) { var guid = Guid.Empty.ToString(); if (!string.IsNullOrEmpty(Request.QueryString["guid"])) { guid = Request.QueryString["guid"].ToString(); } ResetPasswordTicket ResetTicket = new ResetPasswordTicket(guid); string password = string.Empty; // TODO: Add validation that passwords match if (uxPassword.Text == uxPasswordConfirm.Text && !string.IsNullOrEmpty(uxPasswordConfirm.Text)) { ResetTicket.CompleteTicket(Request.UserHostAddress); password = uxPassword.Text; ResetYourPasswordItem context = (ResetYourPasswordItem)Sitecore.Context.Item; var membershipManager = new MembershipManager(); var reset = membershipManager.ResetPassword(Guid.Parse(ResetTicket.UserID), password); uxMessage.Text = context.PasswordUpdatedText; var member = membershipManager.GetMember(Guid.Parse(ResetTicket.UserID)); var user = membershipManager.GetUser(Guid.Parse(ResetTicket.UserID), false); ExactTargetService.InvokeEM23PasswordResetConfirmation(new InvokeEM23PasswordResetConfirmationRequest { PreferredLanguage = member.PreferredLanguage, EmailAddress = user.Email, ReportChangedPasswordLink = "#", ToEmail = user.Email, UserPassword = "******", RequestUrl = Request.Url }); } }
public string GetRegionAccessDetails() { Person queryPerson = PersonManager.GetAllPersons().FirstOrDefault <Person>(x => x.Id.Equals(Id)); IList <PersonRegionAccessDetail> regions = new List <PersonRegionAccessDetail>(); JavaScriptSerializer serializer = new JavaScriptSerializer(); if (queryPerson != null) { User user1 = MembershipManager.GetUserByPerson(queryPerson); MembershipUser membershipUser = Membership.GetUser(user1.Name); if (!string.IsNullOrEmpty(membershipUser.UserName)) { IList <Region> userRegions = SiteManager.GetAllRegions(); foreach (Region region in userRegions) { PersonRegion PR = PersonManager.GetPersonRegionByPersonAndRegion(queryPerson, region); if (PR != null) { regions.Add(new PersonRegionAccessDetail() { PersonId = PR.Person.Id, LocationId = region.Id, IsView = PR.IsView, IsAdmin = PR.IsAdministrator, IsManager = PR.IsManager, Name = region.Name }); } } } } return(serializer.Serialize(regions)); }
public LocalShardCheckHeartbeatTask(IShard shard, NodeContext context, MembershipManager membershipManager, ClusterConfigurationManager clusterConfigMgr) { this._shard = shard; this._context = context; this._clusterConfigMgr = clusterConfigMgr; _localShardHeartbeatReporter = new LocalShardHeartbeatReporting(_context.LocalAddress); this._membershipManager = membershipManager; this._membershipManager.HeartbeatReport = _localShardHeartbeatReporter; ShardConfiguration sConfig = null; if (_clusterConfigMgr != null) { sConfig = _clusterConfigMgr.GetShardConfiguration(context.LocalShardName); } if (sConfig != null && sConfig.NodeHeartbeatInterval > 0) { this._poolingThreshold = (sConfig.NodeHeartbeatInterval * 2) * 1000; } _running = false; _startSignal = new ManualResetEvent(false); //with the initialization of the heartbeat receiver, we start the send heart beat task. _sendHearbeatTask = new LocalShardSendHeartbeatTask(context, shard, _membershipManager, clusterConfigMgr); }
private void LoadUser() { User user = MembershipManager.GetUser(Convert.ToInt32(Page.ViewState["UserId"])); // load the profile data ucProfile.ProfileEntity = ProfileManager.GetProfileByUser(Convert.ToInt32(Page.ViewState["UserId"])); chkHasChangePassword.Checked = user.HasChangePassword; var representantUser = RepresentantManager.GetRepresentantUser(Convert.ToInt32(Page.ViewState["UserId"])); if (representantUser != null) { cboRepresentant.SelectedValue = Convert.ToString(representantUser.RepresentantId); } chkIsActiveCheckBox.Checked = user.IsActive; chkIsLockedOut.Checked = user.IsLockedOut; txtUserName.Text = user.UserName; txtPassword.ValidationGroup = "dummy"; txtConfirmPassword.ValidationGroup = "dummy"; Deposit deposit = CompanyManager.GetCurrentDeposit(Convert.ToInt32(Page.ViewState["UserId"]), Company.CompanyId); if (deposit != null) { cboDeposit.SelectedValue = deposit.DepositId.ToString(); } }
public Family RandomFamily(ReportManager manager) { Member member = RandomMemberFromData(manager); MembershipManager membership = new MembershipManager(manager.ConnectionString); return(membership.GetFamily(member)); }
protected void lbUnsave_Click(object sender, EventArgs e) { if (IsUserLoggedIn) { MembershipManager mmgr = new MembershipManager(); try { bool success = mmgr.LogMemberActivity_AsDeleted(CurrentMember.MemberId, context.ID.ToGuid(), Constants.UserActivity_Values.Favorited, Constants.UserActivity_Types.ContentRelated); if (success) { lbSave.CssClass = "icon icon-save"; lbSave.Click += lbSave_Click; lbSave.Click -= lbUnsave_Click; } } catch { } } else { this.ProfileRedirect(UnderstoodDotOrg.Common.Constants.UserPermission.RegisteredUser); } }
protected void btnActivityInsert_Click(object sender, EventArgs e) { // *** to log a user making a reminder request: // txtActivityValue.Text = UnderstoodDotOrg.Common.Constants.UserActivity_Values.SetReminder ; // txtActivityType.Text = UnderstoodDotOrg.Common.Constants.UserActivity_Types.ContentRelated.ToString(); // *** to log a user browsing to a convio luminate hosted page: // string targetUrl = "http://www.somethinghostedonconvio.com/myarticle.php"; // txtActivityValue.Text = targetUrl; // txtActivityType.Text = UnderstoodDotOrg.Common.Constants.UserActivity_Types.Advocacy_Page.ToString(); MembershipManager mmgr = new MembershipManager(); try { bool success = mmgr.LogMemberActivity(Guid.Parse(txtMemberGuid.Text), Guid.Parse(txtContentId.Text), txtActivityValue.Text, int.Parse(txtActivityType.Text)); lblSuccess.Text = success.ToString(); } catch (Exception ex) { lblSuccess.Text = "Exception! " + ex.Message; } }
private void UpdateBorrowedItemReturn(int resourceId, int membershipId) { var resource = ResourceManager.GetResource(resourceId); var member = MembershipManager.GetMembership(membershipId); BorrowingManager.ReturnItem(resource, member); }
public override InfoControl.Web.Auditing.Event LogErrorInDatabase(Exception ex) { var eventEntity = base.LogErrorInDatabase(ex); HttpContext context = HttpContext.Current; if (context != null && context.Session != null) using (var customerManager = new CustomerManager(null)) using (var companyManager = new CompanyManager(null)) using (var membershipManager = new MembershipManager(null)) { Company hostCompany = companyManager.GetHostCompany(); Company company = companyManager.GetCompanyByContext(context); Customer customer = customerManager.GetCustomerByLegalEntityProfile(hostCompany.CompanyId, company.LegalEntityProfileId); if (customer != null) { var customerCall = new CustomerCall(); customerCall.EventId = eventEntity.EventId; customerCall.Subject = (ex.Message.Length > 100 ? ex.Message.Substring(0, 90) + " ..." : ex.Message); customerCall.CallNumber = Util.GenerateUniqueID(); customerCall.CompanyId = hostCompany.CompanyId; customerCall.CustomerId = customer.CustomerId; customerCall.OpenedDate = customerCall.ModifiedDate = DateTime.Now.Date; customerCall.Description = String.Empty; customerCall.CustomerCallTypeId = CustomerCallType.ERROR; customerCall.CustomerCallStatusId = CustomerCallStatus.New; customerCall.Rating = 5; customerCall.CallNumberAssociated = context.Request.RawUrl; customerCall.Sector = Convert.ToString(context.Session["_lastPageTitle"]); if (context.User != null) if (context.User.Identity != null) if (context.User.Identity.IsAuthenticated) { User user = membershipManager.GetUserByEmail(context.User.Identity.Name); if (user != null) customerCall.UserId = user.UserId; } customerManager.InsertCustomerCall(customerCall, null, null, null); } } return eventEntity; }
public AzureService() { var url = new Uri(Keys.AzureDomain); var store = new MobileServiceSQLiteStore($"{url.Host}.db"); store.DefineTable<Athlete>(); store.DefineTable<League>(); store.DefineTable<Membership>(); store.DefineTable<Challenge>(); store.DefineTable<GameResult>(); Client.SyncContext.InitializeAsync(store); LeagueManager = new LeagueManager(); MembershipManager = new MembershipManager(); AthleteManager = new AthleteManager(); ChallengeManager = new ChallengeManager(); GameResultManager = new GameResultManager(); }
public InsertCompanyStatus InsertUser(int companyId, User user, Profile profile, int? depositId) { // // If ProfileId equal 0 then the profile no exists in bd // var pManager = new ProfileManager(this); if (profile.ProfileId == 0) pManager.Insert(profile); // //method to insert a new user // var provider = Membership.Provider as VivinaMembershipProvider; MembershipCreateStatus status; var membershipManager = new MembershipManager(this); user.ProfileId = profile.ProfileId; membershipManager.Insert(user, out status, provider.RequiresValidEmail); // //verify if the status of the inclusion is ok // if (status != MembershipCreateStatus.Success) { DataManager.Rollback(); switch (status) { case MembershipCreateStatus.InvalidPassword: return InsertCompanyStatus.InvalidPassword; case MembershipCreateStatus.DuplicateEmail: return InsertCompanyStatus.DuplicatedAdminEmail; } } // // Associate the User with company // AssociateUser(companyId, user.UserId, depositId, true); // // Insert a Employee // var humanResourcesManager = new HumanResourcesManager(this); var employee = new Employee(); employee.IsActive = true; employee.ProfileId = profile.ProfileId; employee.CompanyId = companyId; humanResourcesManager.InsertEmployee(employee, new List<EmployeeAdditionalInformation>()); return InsertCompanyStatus.Success; }
protected void btnSave_Click(object sender, EventArgs e) { Customer customer = new Customer(); // Clone the original customer for the linq track changes if (originalCustomer != null) { customer.CopyPropertiesFrom(originalCustomer); } customer.BlockSalesInDebit = true; if (Company.MatrixId.HasValue) customer.CompanyId = Company.MatrixId.Value; else customer.CompanyId = Company.CompanyId; customer.BankId = null; if (!String.IsNullOrEmpty(cboBank.SelectedValue)) customer.BankId = Convert.ToInt32(cboBank.SelectedValue); customer.Agency = null; if (!String.IsNullOrEmpty(txtAgency.Text)) customer.Agency = txtAgency.Text; customer.AccountNumber = null; if (!String.IsNullOrEmpty(txtAccountNumber.Text)) customer.AccountNumber = txtAccountNumber.Text; customer.AccountCreatedDate = null; if (!String.IsNullOrEmpty(txtAccountCreatedDate.Text)) customer.AccountCreatedDate = Convert.ToDateTime(txtAccountCreatedDate.Text); ///vendor if (!String.IsNullOrEmpty(cboVendors.SelectedValue)) customer.SalesPersonId = Convert.ToInt32(cboVendors.SelectedValue); if (Page.ViewState["SalesPersonId"] != null) customer.SalesPersonId = Convert.ToInt32(Page.ViewState["SalesPersonId"]); if (ucVendorComission.CurrencyValue.HasValue) customer.SalesPersonCommission = ucVendorComission.CurrencyValue; if (!String.IsNullOrEmpty(cboSupplementalVendor.SelectedValue)) customer.SupplementalSalesPersonId = Convert.ToInt32(cboSupplementalVendor.SelectedValue); if (Page.ViewState["supplementalSalesPersonId"] != null) customer.SupplementalSalesPersonId = Convert.ToInt32(Page.ViewState["supplementalSalesPersonId"]); if (ucSupplementalVendorComission.CurrencyValue.HasValue) customer.SupplementalSalesPersonCommission = ucSupplementalVendorComission.CurrencyValue; customer.RepresentantId = null; if (!String.IsNullOrEmpty(cboRepresentant.SelectedValue)) customer.RepresentantId = Convert.ToInt32(cboRepresentant.SelectedValue); customer.CreditLimit = ucCurrFieldCreditLimit.CurrencyValue; customer.CustomerTypeId = null; if (!String.IsNullOrEmpty(cboCustomerType.SelectedValue)) customer.CustomerTypeId = Convert.ToInt32(cboCustomerType.SelectedValue); //fill field ranking customer.Ranking = rtnRanking.CurrentRating; if (ucProfile.ProfileEntity != null) { if (String.IsNullOrEmpty(ucProfile.ProfileEntity.Phone.Trim('-', '_', '(', ')')) && String.IsNullOrEmpty(ucProfile.ProfileEntity.CellPhone.Trim('-', '_', '(', ')')) && String.IsNullOrEmpty(ucProfile.ProfileEntity.HomePhone.Trim('-', '_', '(', ')'))) { ShowError("Ao menos um telefone deve ser preenchido!"); return; } // Add the entity to Insert if (ucProfile.ProfileEntity.ProfileId == 0) customer.Profile = ucProfile.ProfileEntity; } else { // Add the entity to Insert customer.LegalEntityProfileId = ucProfile.CompanyProfileEntity.LegalEntityProfileId; if (ucProfile.CompanyProfileEntity.LegalEntityProfileId == 0) customer.LegalEntityProfile = ucProfile.CompanyProfileEntity; } // //Insert // if (Page.ViewState["CustomerId"] == null && Page.ViewState["ProfileExists"] != "0") { membershipManager = new MembershipManager(this); companyManager = new CompanyManager(this); if (!String.IsNullOrEmpty(txtUserName.Text)) { customer.CreatedByUser = User.Identity.UserName; status = customerManager.Insert(customer, FillUser()); ShowMessage(status); chkRemoveUser.Visible = (status == MembershipCreateStatus.Success); lblPassword.Visible = txtPassword.Visible = !(status == MembershipCreateStatus.Success); if (status == MembershipCreateStatus.Success) Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "location='Customer.aspx?CustomerId=" + customer.CustomerId + "';", true); return; } customer.CreatedByUser = User.Identity.UserName; customerManager.Insert(customer); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "location='Customer.aspx?CustomerId=" + customer.CustomerId + "';", true); } // Update else { membershipManager = new MembershipManager(this); customerManager = new CustomerManager(this); var user = FillUser(); customer.ModifiedByUser = User.Identity.UserName; // //Delete the user account of customer // if (chkRemoveUser.Checked) { customer.User = null; lblMessage.Text = String.Empty; chkRemoveUser.Checked = false; chkRemoveUser.Visible = false; txtUserName.Text = String.Empty; lblPassword.Visible = txtPassword.Visible = true; customerManager.Update(originalCustomer, customer); return; } if (originalCustomer.UserId.HasValue) { if (originalCustomer.User.UserName != txtUserName.Text) { if (customerManager.GetCustomerByUserName(Company.CompanyId, txtUserName.Text) != null) { lblMessage.Text = "Já existe um cliente com esse usuário nesta empresa!"; return; } customerManager.UpdateUserNameOfCustomer(originalCustomer, txtUserName.Text); return; } } if (!String.IsNullOrEmpty(txtUserName.Text) && !originalCustomer.UserId.HasValue) { if (customerManager.GetCustomerByUserName(Company.CompanyId, txtUserName.Text) != null) { lblMessage.Text = "Já existe um cliente com esse usuário nesta empresa!"; return; } membershipManager.Insert(user, out status, true); if (status == MembershipCreateStatus.Success) { customer.UserId = user.UserId; customerManager.Update(originalCustomer, customer); chkRemoveUser.Visible = true; txtPassword.Visible = false; lblPassword.Visible = false; } } customerManager.Update(originalCustomer, customer); // // In case of cnpj/cpf already exists in another category but the same cnpj/cpf is not yet a customer // the data will be loaded and save as update not insert, then this code redirects correctly to finalize // the register. // if (Page.ViewState["CustomerId"] == null) Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "location='Customer.aspx?CustomerId=" + customer.CustomerId + "';", true); } }
public MembershipController(MembershipManager manager) { this._manager = manager; }
void context_PostAcquireRequestState(object sender, EventArgs e) { HttpApplication application = sender as HttpApplication; HttpContext context = application.Context; MembershipManager membershipManager = new MembershipManager(null); AccessControlPrincipal principal = null; DataEntities.User user = null; System.Security.Principal.IIdentity identity = null; if (IsValid) { context.Trace.Warn("Role Module Begin"); #region Cookies if ((!Roles.CookieRequireSSL || context.Request.IsSecureConnection)) { if (Roles.CacheRolesInCookie) { HttpCookie cookie = context.Request.Cookies[Roles.CookieName]; if (cookie != null && cookie.Value != null) { if (!string.IsNullOrEmpty(Roles.CookiePath) && (Roles.CookiePath != "/")) cookie.Path = Roles.CookiePath; if (Roles.CookieProtectionValue == CookieProtection.Encryption) cookie.Value = cookie.Value.Decrypt().Decompress(); cookie.Domain = Roles.Domain; context.User = HttpUtility.UrlDecode(cookie.Value).Deserialize<AccessControlPrincipal>(); } else { Roles.DeleteCookie(); } } else { Roles.DeleteCookie(); } } else { Roles.DeleteCookie(); } #endregion identity = context.User.Identity; principal = new AccessControlPrincipal(user, identity); if (context.Session != null && context.Session[context.Session.SessionID] != null && identity.IsAuthenticated) principal = context.Session[context.Session.SessionID] as AccessControlPrincipal; if (String.IsNullOrEmpty(principal.Name) && !String.IsNullOrEmpty(identity.Name)) { user = membershipManager.GetUserByName(identity.Name); if (user != null) { bool timeoutExpired = DateTime.Now.Subtract(user.LastActivityDate).Minutes > System.Web.Security.Membership.UserIsOnlineTimeWindow; user.LastActivityDate = DateTime.Now; user.IsOnline = !timeoutExpired; membershipManager.DbContext.SubmitChanges(); membershipManager.DataManager.Commit(); } principal = new AccessControlPrincipal(user, identity); } if (context.Application["Session_End"] == null) context.Application["Session_End"] = new EventHandler(OnSessionEnd); // // Cache the user in session to dont query database // if (context.Session != null && identity.IsAuthenticated) context.Session[context.Session.SessionID] = principal; System.Threading.Thread.CurrentPrincipal = principal; context.User = principal; context.Trace.Warn("Role Module End"); } }
/// <summary> /// This method delete a user /// </summary> /// <param name="newUser"></param> public void DeleteUser(User newUser) { var membershipManager = new MembershipManager(this); newUser = membershipManager.GetUser(newUser.UserId); membershipManager.Delete(newUser); }
/// <summary> /// This method updates an user /// </summary> /// <param name="userId">Can't be null</param> /// <param name="companyId">Can't be null</param> /// <param name="depositId"></param> /// <param name="user">Can't be null</param> public void UpdateUser(int userId, int companyId, int? depositId, User user) { // // Save User // var mManager = new MembershipManager(this); User original_user = mManager.GetUser(userId); mManager.Update(original_user, user); // // Deposit // ChangeDeposit(companyId, userId, depositId); // // Associate the User with company // if (GetCompanyUser(companyId, userId) == null) AssociateUser(companyId, userId, depositId, true); }
/// <summary> /// This method insert an customer and an user atached /// this method return true when customer and user inserted /// </summary> public MembershipCreateStatus Insert(Customer customer, User user) { MembershipCreateStatus status; var companyManager = new CompanyManager(this); var membershipManager = new MembershipManager(this); membershipManager.Insert(user, out status, true); // // creates an new user // if (status == MembershipCreateStatus.Success) { customer.UserId = user.UserId; customer.CreatedDate = customer.ModifiedDate = DateTime.Now; Insert(customer); return MembershipCreateStatus.Success; } return status; }
/// <summary> /// This method creates an user for an existing customer /// </summary> public MembershipCreateStatus InsertUserForCustomer(Customer originalCustomer, User user) { var membershipManager = new MembershipManager(this); MembershipCreateStatus status; membershipManager.Insert(user, out status, true); if (status == MembershipCreateStatus.Success) { originalCustomer.UserId = user.UserId; DbContext.SubmitChanges(); return MembershipCreateStatus.Success; } return status; }
void OnSessionEnd(object sender, EventArgs e) { HttpApplication application = sender as HttpApplication; System.Web.SessionState.HttpSessionState session = application.Session; using (MembershipManager membershipManager = new MembershipManager(null)) { AccessControlPrincipal principal = session[session.SessionID] as AccessControlPrincipal; if (principal != null && principal.Identity != null) membershipManager.Logoff(principal); } session.RemoveAll(); }
/// <summary> /// This method inserts a user /// </summary> /// <param name="companyId">Can't be null</param> /// <param name="user">Can't be null. This entity can't be attached in db</param> /// <param name="depositId">can be null</param> /// <returns>a status based on InsertCompanyStatus</returns> public InsertCompanyStatus InsertUser(int companyId, int? depositId, int? representantId, User user, Profile profile) { var membershipManager = new MembershipManager(this); // //method to insert a new user // var provider = Membership.Provider as VivinaMembershipProvider; MembershipCreateStatus status; membershipManager.Insert(user, out status, provider.RequiresValidEmail); // //verifies if the status of the inclusion is ok // if (status != MembershipCreateStatus.Success) { DataManager.Rollback(); switch (status) { case MembershipCreateStatus.InvalidPassword: return InsertCompanyStatus.InvalidPassword; case MembershipCreateStatus.DuplicateEmail: return InsertCompanyStatus.DuplicatedAdminEmail; } } if (profile.ProfileId == 0) new ProfileManager(this).Insert(profile); AttachProfileEntityToUser(companyId, user.UserId, profile.ProfileId); if (representantId.HasValue) AddRepresentantToUser(companyId, user.UserId, Convert.ToInt32(representantId)); // // Associate the User with company // if (!IsCompanyUser(companyId, user.UserId)) AssociateUser(companyId, user.UserId, depositId, true); return InsertCompanyStatus.Success; }
public MembershipController(MembershipManager manager, IMembershipProvider provider) { this._manager = manager; this._provider = provider; }
/// <summary> /// M�todo usado para criar a primeira companhia, utilizado na tela de registro /// </summary> /// <param name="newCompany"></param> /// <param name="newUser"></param> /// <param name="newProfile"></param> /// <returns></returns> public InsertCompanyStatus InsertMatrixCompany(Company newCompany, User newUser, Profile profile) { // // Insert the profile // var pManager = new ProfileManager(this); // Profile profile = pManager.GetProfile(newProfile.CPF) ?? newProfile; //if (profile.ProfileId == 0) pManager.Insert(profile); //else //{ // profile.Name = newProfile.Name; // profile.Email = newProfile.Email; // profile.PostalCode = newProfile.PostalCode; // //profile.Address = newProfile.Address; // profile.AddressComp = newProfile.AddressComp; // profile.AddressNumber = newProfile.AddressNumber; // profile.Phone = newProfile.Phone; // DbContext.SubmitChanges(); //} // //Insert Admin user // Int32 UserId; //newUser.ProfileId DataClasses.User original_User = GetUserByUserName(newUser.Email); if (original_User != null) { UserId = original_User.UserId; } else { MembershipCreateStatus status; var membershipManager = new MembershipManager(this); newUser.ProfileId = profile.ProfileId; membershipManager.Insert( newUser, out status, (Membership.Provider as VivinaMembershipProvider).RequiresValidEmail); // //verify if the status of the inclusion are ok // if (status != MembershipCreateStatus.Success) { DataManager.Rollback(); switch (status) { case MembershipCreateStatus.DuplicateUserName: return InsertCompanyStatus.DuplicatedUserName; case MembershipCreateStatus.InvalidPassword: return InsertCompanyStatus.InvalidPassword; case MembershipCreateStatus.DuplicateEmail: return InsertCompanyStatus.DuplicatedAdminEmail; default: return InsertCompanyStatus.InvalidUser; } } UserId = newUser.UserId; } if (newCompany.LegalEntityProfile.IsLiberalProfessional) newCompany.LegalEntityProfile.CompanyName = newCompany.LegalEntityProfile.FantasyName = profile.Name; var insertCompanyStatus = InsertCompany(newCompany, UserId, 0); newCompany.ReferenceCompanyId = newCompany.CompanyId; newCompany.MatrixId = newCompany.CompanyId; DbContext.SubmitChanges(); return insertCompanyStatus; }