public StoreUserRelationship() { Id = -1; UserId = 0; StoreId = 0; AccessMode = StoreAccessMode.Manager; }
public bool AddUserToStore(long storeId, long userId, StoreAccessMode mode) { bool result = false; StoreUserRelationship existing = AdminUsersXStores.FindByUserIdAndStoreId(userId, storeId); if (existing != null) { return(true); } StoreUserRelationship rel = new StoreUserRelationship(); rel.UserId = userId; rel.StoreId = storeId; rel.AccessMode = mode; result = AdminUsersXStores.Create(rel); return(result); }
public bool AddUserToStoreByEmail(long storeId, string email, StoreAccessMode mode) { UserAccount u = AdminUsers.FindByEmail(email); if (u == null) { u = new UserAccount(); u.Email = email; string password = Utilities.PasswordGenerator.GeneratePassword(); u.HashedPassword = password; AdminUsers.Create(u); } if (AddUserToStore(storeId, u.Id, mode)) { Store s = Stores.FindById(storeId); Utilities.MailServices.SendAccountInformation(u, s); return(true); } return(false); }
public bool AddUserToStore(long storeId, long userId, StoreAccessMode mode) { bool result = false; StoreUserRelationship existing = AdminUsersXStores.FindByUserIdAndStoreId(userId, storeId); if (existing != null) return true; StoreUserRelationship rel = new StoreUserRelationship(); rel.UserId = userId; rel.StoreId = storeId; rel.AccessMode = mode; result = AdminUsersXStores.Create(rel); return result; }
public bool AddUserToStoreByEmail(long storeId, string email, StoreAccessMode mode) { UserAccount u = AdminUsers.FindByEmail(email); if (u == null) { u = new UserAccount(); u.Email = email; string password = Utilities.PasswordGenerator.GeneratePassword(); u.HashedPassword = password; AdminUsers.Create(u); } if (AddUserToStore(storeId, u.Id, mode)) { Store s = Stores.FindById(storeId); Utilities.MailServices.SendAccountInformation(u, s); return true; } return false; }
private static string GetClosestServer(string storeName, StoreAccessMode accessMode) { var ravenStore = RavenConfig.Stores.SelectByName(storeName); if (ravenStore != null) { return ravenStore.GetClosestReplica( Environment.MachineName, accessMode == StoreAccessMode.ReadWrite); } return null; }
private static DocumentStore CreateDocumentStore(string storeName, StoreAccessMode accessMode) { string serverName = GetClosestServer(storeName, accessMode); var documentStore = CreateDocumentStore(storeName, serverName); if (accessMode == StoreAccessMode.ReadOnly) { documentStore.RegisterListener((IDocumentStoreListener)new ReadOnlyListener()); documentStore.RegisterListener((IDocumentDeleteListener)new ReadOnlyListener()); } return documentStore; }
public static BrnklyDocumentStore Register( IUnityContainer container, string name, StoreAccessMode accessMode = StoreAccessMode.ReadOnly) { CodeContract.ArgumentNotNull("container", container); CodeContract.ArgumentNotNullOrWhitespace("name", name); var existingStore = AllStores.SingleOrDefault( store => store.Name.Equals(name, StringComparison.OrdinalIgnoreCase) && store.AccessMode == accessMode); if (existingStore != null) { return existingStore; } var newStore = new BrnklyDocumentStore(name, accessMode); AllStores.Add(newStore); container.RegisterInstance<IDocumentStore>(newStore.nameWithAccessMode, newStore); newStore.UpdateInnerStore(); return newStore; }
public BrnklyDocumentStore(string name, StoreAccessMode accessMode = StoreAccessMode.ReadOnly) { CodeContract.ArgumentNotNullOrWhitespace("name", name); StoreName.ValidateName(name); this.IsInitialized = false; this.Name = name; this.AccessMode = accessMode; this.nameWithAccessMode = (this.AccessMode == StoreAccessMode.ReadOnly) ? this.Name : this.Name + ".ReadWrite"; this.innerStore = CreateDocumentStore(this.Name, this.AccessMode); }