/// <summary> /// Initializes the provider. /// </summary> /// <param name="name">The friendly name of the provider.</param> /// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param> /// <exception cref="T:System.ArgumentNullException">The name of the provider is null.</exception> /// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception> /// <exception cref="T:System.InvalidOperationException">An attempt is made to call <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"/> on a provider after the provider has already been initialized.</exception> public override void Initialize(string name, NameValueCollection config) { base.Initialize(name, config); try { Error.AssertLicense("Sitecore.MSCRM", "Microsoft Dynamics CRM security provider."); this.ApplicationName = config["applicationName"]; this.ReadOnly = (String.IsNullOrEmpty(config["readOnly"]) || config["readOnly"] == "true"); var connectionStringName = config["connectionStringName"]; var connectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString; var settings = Configuration.ConfigurationSettings.Parse(connectionString); this.profileRepository = this.profileRepositoryFactory.GetRepository(settings); this.userRepository = this.userRepositoryFactory.GetRepository(settings); this.SetupCustomPropertyNames(); this.initialized = true; } catch (Exception e) { this.initialized = false; ConditionalLog.Error("The CRM provider couldn't be initialized.", e, this); } }
public UnitOfWork() { _context = new KampusContext(); Cities = new CityRepositoryBase(_context); Messages = new MessageRepositoryBase(_context); Notifications = new NotificationRepositoryBase(_context); Tasks = new TaskRepositoryBase(_context); Universities = new UniversityRepositoryBase(_context); Users = new UserRepositoryBase(_context); WallPosts = new WallPostRepositoryBase(_context); }
public DataService( UserRepositoryBase userRepository, RoleRepositoryBase roleRepository, MessageRepositoryBase messageRepository, CommentRepositoryBase commentRepository ) { _userRepository = userRepository; _roleRepository = roleRepository; _messageRepository = messageRepository; _commentRepository = commentRepository; }
protected void Page_Load(object sender, EventArgs e) { userManager = IoCContainer.ServiceLocator.Resolve <IDbManager>(); userBase = (UserRepositoryBase)IoCContainer.ServiceLocator.Resolve <IRepository <MyUserDataGrid> >(); companyBase = (CompanyRepositoryBase)IoCContainer.ServiceLocator.Resolve <IRepository <MyCompanyDetail> >(); user = this.Session["CurrentUser"] as MyUser; company = userManager.GetCompanyDetailById(user.CompanyDetails); if (!IsPostBack) { userCategories.DataSource = userManager.GetCategories().Select(c => c.Name).ToList(); userCategories.DataBind(); userCity.DataSource = userManager.GetCities(); userCity.DataBind(); userPassword.Text = user.Password; companyName.Text = company.Name; companyType.SelectedIndex = company.TypeOfCompany; companyWebSite.Text = company.WebSite; userCity.SelectedValue = user.City; userBirthay.Value = user.Birthday.ToShortDateString(); userName.Text = user.Name; userSurname.Text = user.Surname; userFathersName.Text = user.FathersName; userPhone.Text = user.Phone; foreach (ListItem i in userCategories.Items) { if (user.Categories.Contains(userManager.GetCategoryIdByName(i.Text))) { i.Selected = true; } } } }
/// <summary> /// Initializes a new instance of the <see cref="CrmMembershipProviderTest"/> class. /// </summary> public CrmMembershipProviderTest() { var cacheService = Substitute.For <ICacheService>(); this.userRepository = Substitute.For <UserRepositoryBase>(cacheService); this.profileRepository = Substitute.For <ProfileRepositoryBase>(this.userRepository, cacheService); this.userRepositoryFactory = Substitute.For <IUserRepositoryFactory>(); this.userRepositoryFactory.GetRepository(Arg.Any <ConfigurationSettings>()).Returns(this.userRepository); this.profileRepositoryFactory = Substitute.For <IProfileRepositoryFactory>(); this.profileRepositoryFactory.GetRepository(Arg.Any <ConfigurationSettings>()).Returns(this.profileRepository); var config = new NameValueCollection(); config.Add("name", "crm"); config.Add("applicationName", "CRM security provider"); config.Add("readOnly", "false"); config.Add("connectionStringName", "CRMConnString"); this.crmMembershipProvider = new CRMMembershipProvider(this.userRepositoryFactory, this.profileRepositoryFactory); this.crmMembershipProvider.Initialize(config["name"], config); this.user = new CRMUser( "*****@*****.**", Guid.NewGuid(), "*****@*****.**", null, String.Empty, true, false, DateTime.Now, DateTime.Now, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue); }
public RoleRepositoryV3(ICrmServiceV3 crmService, IMarketingListToRoleConverterV3 marketingListToRoleConverter, IContactToUserConverterV3 contactToUserConverter, UserRepositoryBase userRepository, ICacheService cacheService) : base(crmService, marketingListToRoleConverter, contactToUserConverter, userRepository, cacheService) { }
public UserService(UserRepositoryBase userRepository, CountryRepositoryBase countryRepository, CityRepositoryBase cityRepository) { _userRepository = userRepository; _countryRepository = countryRepository; _cityRepository = cityRepository; }
public UserService(UserRepositoryBase repository, IUnitOfWork unitOfWork, IMapper mapper) : base(repository, unitOfWork, mapper) { }
protected void Page_Load(object sender, EventArgs e) { userBase = (UserRepositoryBase)IoCContainer.ServiceLocator.Resolve <IRepository <MyUserDataGrid> >(); resumeBase = (ResumeRepositoryBase)IoCContainer.ServiceLocator.Resolve <IRepository <MyUserDetail> >(); userManager = IoCContainer.ServiceLocator.Resolve <IDbManager>(); userToEdit = this.Session["CurrentUser"] as MyUser; detail = userManager.GetUserDetailById(userToEdit.UserDetails); if (detail.JobExperience == -1) { exp = new MyJobExperience(); } else { exp = userManager.GetJobExpById(detail.JobExperience); } if (detail.Education == -1) { edu = new MyEducation(); } else { edu = userManager.GetEducationById(detail.Education); } if (!IsPostBack) { userCategories.DataSource = userManager.GetCategories().Select(c => c.Name).ToList(); userCategories.DataBind(); userCity.DataSource = userManager.GetCities(); userCity.DataBind(); userCity.SelectedValue = userToEdit.City; userBirthay.Value = userToEdit.Birthday.ToString("dd.mm.yyyy"); userName.Text = userToEdit.Name; userSurname.Text = userToEdit.Surname; userFathersName.Text = userToEdit.FathersName; userPhone.Text = userToEdit.Phone; txtVacancyHeader.Text = detail.Header; txtSalary.Text = detail.Salary.ToString(); txtSelfDesc.Text = detail.Description; txtCompany.Text = exp.Company; txtCityExp.Text = exp.City; txtPost.Text = exp.Post; txtStartDate.Text = exp.Start.ToShortDateString(); txtEndDate.Text = exp.End.ToShortDateString(); txtDesc.Text = exp.Desc; dropEduLevel.SelectedValue = edu.Level; txtPlace.Text = edu.Place; txtSpeciality.Text = edu.Speciality; foreach (ListItem i in userCategories.Items) { if (userToEdit.Categories.Contains(userManager.GetCategoryIdByName(i.Text))) { i.Selected = true; } } } }
public RoleRepositoryV5(IOrganizationService crmService, IMarketingListToRoleConverterV5 marketingListToRoleConverter, IContactToUserConverterV5 contactToUserConverter, UserRepositoryBase userRepository, ICacheService cacheService) : base(crmService, marketingListToRoleConverter, contactToUserConverter, userRepository, cacheService) { }
/// <summary> /// Initializes a new instance of the <see cref="ProfileRepositoryV5"/> class. /// </summary> /// <param name="organizationServiceCache"></param> /// <param name="userRepository">The user repository.</param> /// <param name="cacheService">The cache service.</param> public ProfileRepositoryV5(OrganizationServiceCacheV5 organizationServiceCache, UserRepositoryBase userRepository, ICacheService cacheService) : base(userRepository, cacheService) { Assert.ArgumentNotNull(organizationServiceCache, "organizationServiceCache"); this.organizationServiceCache = organizationServiceCache; }
/// <summary> /// Initializes a new instance of the <see cref="RoleRepositoryV3"/> class. /// </summary> /// <param name="crmService">The CRM service.</param> /// <param name="marketingListToRoleConverter">The marketing list to role converter.</param> /// <param name="contactToUserConverter">The contact to user converter.</param> /// <param name="userRepository">The user repository.</param> /// <param name="cacheService">The cache service.</param> public RoleRepositoryV3(ICrmServiceV3 crmService, IMarketingListToRoleConverterV3 marketingListToRoleConverter, IContactToUserConverterV3 contactToUserConverter, UserRepositoryBase userRepository, ICacheService cacheService) : base(userRepository, cacheService) { Assert.ArgumentNotNull(crmService, "crmService"); Assert.ArgumentNotNull(marketingListToRoleConverter, "marketingListToRoleConverter"); this.CrmService = crmService; this.MarketingListToRoleConverter = marketingListToRoleConverter; this.ContactToUserConverter = contactToUserConverter; }
/// <summary> /// Initializes the provider. /// </summary> /// <param name="name">The friendly name of the provider.</param> /// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param> /// <exception cref="T:System.ArgumentNullException">The name of the provider is null.</exception> /// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception> /// <exception cref="T:System.InvalidOperationException">An attempt is made to call <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"/> on a provider after the provider has already been initialized.</exception> public override void Initialize(string name, NameValueCollection config) { base.Initialize(name, config); try { Error.AssertLicense("Sitecore.MSCRM", "Microsoft Dynamics CRM security provider."); this.ApplicationName = config["applicationName"]; this.ReadOnly = (String.IsNullOrEmpty(config["readOnly"]) || config["readOnly"] == "true"); this.AutoCreatePasswordField = MainUtil.GetBool(config["autoCreatePasswordField"], false); this.PasswordFieldName = StringUtil.GetString((object)config["passwordFieldName"]); this.minRequiredPasswordLength = MainUtil.GetInt(config["minRequiredPasswordLength"], 7); this.minRequiredNonalphanumericCharacters = MainUtil.GetInt(config["minRequiredNonalphanumericCharacters"], 1); this.maxInvalidPasswordAttempts = MainUtil.GetInt(config["maxInvalidPasswordAttempts"], 5); this.passwordAttemptWindow = MainUtil.GetInt(config["passwordAttemptWindow"], 0); this.passwordStrengthRegularExpression = StringUtil.GetString((object)config["passwordStrengthRegularExpression"]).Trim(); this.requiresUniqueEmail = MainUtil.GetBool(config["requiresUniqueEmail"], false); this.enablePasswordReset = MainUtil.GetBool(config["enablePasswordReset"], true); this.requiresQuestionAndAnswer = MainUtil.GetBool(config["requiresQuestionAndAnswer"], false); if (this.RequiresQuestionAndAnswer) { this.PasswordQuestionFieldName = config["passwordQuestionFieldName"]; this.PasswordAnswerFieldName = config["passwordAnswerFieldName"]; } if (!String.IsNullOrEmpty(this.passwordStrengthRegularExpression)) { new Regex(this.passwordStrengthRegularExpression); } var connectionStringName = config["connectionStringName"]; var connectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString; var settings = Configuration.ConfigurationSettings.Parse(connectionString); this.userRepository = this.userRepositoryFactory.GetRepository(settings); this.profileRepository = this.profileRepositoryFactory.GetRepository(settings); this.initialized = true; } catch (Exception e) { this.initialized = false; ConditionalLog.Error("The CRM provider couldn't be initialized.", e, this); return; } try { if (!String.IsNullOrEmpty(this.PasswordFieldName)) { var passwordFieldType = this.profileRepository.GetPropertyType(this.PasswordFieldName); if (passwordFieldType != SupportedTypes.String) { this.PasswordFieldName = String.Empty; ConditionalLog.Warn("The attribute for the password storage isn't of String type. Password storage feature disabled.", this); } } } catch (ProviderException) { if ((this.userRepository is UserRepositoryV4 || this.userRepository is UserRepositoryV5) && this.AutoCreatePasswordField) { if (!this.profileRepository.CreateContactAttribute(this.PasswordFieldName, SupportedTypes.String, false)) { this.PasswordFieldName = String.Empty; ConditionalLog.Warn("The attribute for password storage couldn't be created. Password storage feature disabled.", this); } } else { this.PasswordFieldName = String.Empty; ConditionalLog.Warn("The attribute for the password storage doesn't exist. Password storage feature disabled.", this); } } }
protected void btnSave_Click(object sender, EventArgs e) { this.Validate(); int index = Convert.ToInt32(ViewState["EditedIndex"]); int id = Convert.ToInt32(ViewState["EditedId"]); RepeaterItem item = repUsers.Items[index]; MyUserDataGrid my = new MyUserDataGrid(); if (id != -1) { my = rep.GetEntityById(id) as MyUserDataGrid; } for (int i = 0; i < item.Controls.Count; i++) { TextBox t = item.Controls[i] as TextBox; if (t != null) { string propName = t.ToolTip; switch (propName) { case "Email": my.Email = t.Text; break; case "Password": if (my.Password != t.Text) { my.Password = t.Text; } break; case "Birthday": DateTime birth = new DateTime(); DateTime.TryParse(t.Text, out birth); if (my.Birthday != birth && birth != new DateTime()) { my.Birthday = birth; } break; case "Name": if (my.Name != t.Text) { my.Name = t.Text; } break; case "Surname": if (my.Surname != t.Text) { my.Surname = t.Text; } break; case "FathersName": if (my.FathersName != t.Text) { my.FathersName = t.Text; } break; case "Phone": if (my.Phone != t.Text) { my.Phone = t.Text; } break; default: break; } t.Style.Add("display", "none"); } else { DropDownList lst = item.Controls[i] as DropDownList; if (lst != null) { if (my.City != lst.SelectedValue) { my.City = lst.SelectedValue; } lst.Style.Add("display", "none"); } } } rep.Save(my); if (id == -1) { id = rep.GetAll().Max(u => u.Id); UserRepositoryBase b = rep as UserRepositoryBase; b.AddRole(id, "Admin"); } ViewState.Add("EditedId", -1); ViewState.Add("EditedIndex", -1); btnSave.Style.Add("display", "none"); btnCancel.Style.Add("display", "none"); isEditing = false; UpdateData(); }
/// <summary> /// Initializes a new instance of the <see cref="ProfileRepositoryV4"/> class. /// </summary> /// <param name="metadataService">The CRM metadata service.</param> /// <param name="crmService">The CRM service.</param> /// <param name="userRepository">The user repository.</param> /// <param name="cacheService">The cache service.</param> public ProfileRepositoryV4(IMetadataServiceV4 metadataService, ICrmServiceV4 crmService, UserRepositoryBase userRepository, ICacheService cacheService) : base(userRepository, cacheService) { Assert.ArgumentNotNull(metadataService, "metadataService"); Assert.ArgumentNotNull(crmService, "crmService"); this.CrmMetadataService = metadataService; this.CrmService = crmService; }
/// <summary> /// Initializes a new instance of the <see cref="RoleRepositoryV5"/> class. /// </summary> /// <param name="organizationServiceCache"></param> /// <param name="marketingListToRoleConverter">The marketing list to role converter.</param> /// <param name="contactToUserConverter">The contact to user converter.</param> /// <param name="userRepository">The user repository.</param> /// <param name="cacheService">The cache service.</param> public RoleRepositoryV5(OrganizationServiceCacheV5 organizationServiceCache, IMarketingListToRoleConverterV5 marketingListToRoleConverter, IContactToUserConverterV5 contactToUserConverter, UserRepositoryBase userRepository, ICacheService cacheService) : base(userRepository, cacheService) { Assert.ArgumentNotNull(organizationServiceCache, "organizationServiceCache"); Assert.ArgumentNotNull(marketingListToRoleConverter, "marketingListToRoleConverter"); this.organizationServiceCache = organizationServiceCache; this.MarketingListToRoleConverter = marketingListToRoleConverter; this.ContactToUserConverter = contactToUserConverter; }