public DataBaseCollection(CremaHost cremaHost, string address, string dataBase, ServiceInfo serviceInfo) { this.cremaHost = cremaHost; this.userContext = cremaHost.UserContext; this.serviceDispatcher = new CremaDispatcher(this); var metaData = this.serviceDispatcher.Invoke(() => { this.service = DataBaseCollectionServiceFactory.CreateServiceClient(address, serviceInfo, this); this.service.Open(); if (this.service is ICommunicationObject service) { service.Faulted += Service_Faulted; } ResultBase <DataBaseCollectionMetaData> result; result = dataBase == null ? this.service.Subscribe(cremaHost.AuthenticationToken) : this.service.SubscribeDataBase(cremaHost.AuthenticationToken, dataBase); result.Validate(); #if !DEBUG this.timer = new Timer(30000); this.timer.Elapsed += Timer_Elapsed; this.timer.Start(); #endif return(result.Value); }); this.Initialize(metaData); this.CremaHost.AddService(this); }
public DataBaseContext(CremaHost cremaHost) { this.CremaHost = cremaHost; this.Dispatcher = new CremaDispatcher(this); this.taskEvent = new TaskResetEvent <Guid>(this.Dispatcher); this.callbackEvent = new IndexedDispatcher(this); }
public DomainContext(CremaHost cremaHost) { this.CremaHost = cremaHost; this.CremaHost.Debug(Resources.Message_DomainContextInitialize); this.Dispatcher = new CremaDispatcher(this); this.BasePath = cremaHost.GetPath(CremaPath.Domains); this.CremaHost.Debug(Resources.Message_DomainContextIsCreated); }
public DomainContext(CremaHost cremaHost) { this.CremaHost = cremaHost; this.Dispatcher = new CremaDispatcher(this); this.creationEvent = new TaskResetEvent <Guid>(this.Dispatcher); this.deletionEvent = new TaskResetEvent <Guid>(this.Dispatcher); this.callbackEvent = new IndexedDispatcher(this); }
private UserServiceFactory(string address, ServiceInfo serviceInfo, IUserServiceCallback userServiceCallback) { this.binding = CremaHost.CreateBinding(serviceInfo); this.endPointAddress = new EndpointAddress($"net.tcp://{address}:{serviceInfo.Port}/UserService"); this.instanceContext = new InstanceContext(userServiceCallback ?? (this)); if (Environment.OSVersion.Platform != PlatformID.Unix) { this.instanceContext.SynchronizationContext = SynchronizationContext.Current; } }
public UserContext(CremaHost cremaHost, string address, ServiceInfo serviceInfo, string userID, SecureString password) { this.cremaHost = cremaHost; this.serviceDispatcher = new CremaDispatcher(this); var metaData = this.serviceDispatcher.Invoke(() => { this.service = UserServiceFactory.CreateServiceClient(address, serviceInfo, this); this.service.Open(); if (this.service is ICommunicationObject service) { service.Faulted += Service_Faulted; } var version = AppUtility.ProductVersion; try { var result = this.service.Subscribe(userID, UserContext.Encrypt(userID, password), $"{version}", $"{Environment.OSVersion.Platform}", $"{CultureInfo.CurrentCulture}"); result.Validate(); #if !DEBUG this.timer = new Timer(30000); this.timer.Elapsed += Timer_Elapsed; this.timer.Start(); #endif return(result.Value); } catch { if (Environment.OSVersion.Platform == PlatformID.Win32NT) { this.service.Close(); } else { this.service.Abort(); } this.serviceDispatcher.Dispose(); this.serviceDispatcher = null; throw; } }); this.authenticationToken = metaData.AuthenticationToken; this.Initialize(metaData); this.Items.MessageReceived += Users_MessageReceived; this.Items.MessageReceived2 += Users_MessageReceived2; this.Items.UsersLoggedIn += Users_UsersLoggedIn; this.Items.UsersLoggedOut += Users_UsersLoggedOut; this.Items.UsersKicked += Users_UsersKicked; this.Items.UsersBanChanged += Users_UsersBanChanged; this.cremaHost.AddService(this); }
public static DataBaseCollectionServiceClient CreateServiceClient(string address, ServiceInfo serviceInfo, IDataBaseCollectionServiceCallback callback) { var binding = CremaHost.CreateBinding(serviceInfo); var endPointAddress = new EndpointAddress($"net.tcp://{address}:{serviceInfo.Port}/DataBaseCollectionService"); var instanceContext = new InstanceContext(callback ?? empty); if (Environment.OSVersion.Platform != PlatformID.Unix) { instanceContext.SynchronizationContext = SynchronizationContext.Current; } return(new DataBaseCollectionServiceClient(instanceContext, binding, endPointAddress)); }
public DataBaseCollection(CremaHost cremaHost) { this.cremaHost = cremaHost; this.cachePath = DirectoryUtility.Prepare(this.cremaHost.WorkingPath, DataBaseString); this.repository = cremaHost.Repository; var revision = this.repository.Revision; var caches = this.cremaHost.NoCache == true ? new Dictionary <string, DataBaseSerializationInfo>() : this.ReadCaches(); foreach (var item in GetDataBases()) { var dataBasePath = item.Value; var dataBaseName = item.Key; var dataBase = CreateDataBase(); dataBase.Initialize(); this.AddBase(dataBaseName, dataBase); DataBase CreateDataBase() { if (caches.ContainsKey(dataBaseName) == false) { return(new DataBase(this.cremaHost, dataBasePath, dataBaseName)); } return(new DataBase(this.cremaHost, dataBasePath, dataBaseName, caches[dataBaseName])); } } IEnumerable <KeyValuePair <string, string> > GetDataBases() { yield return(new KeyValuePair <string, string>(DataBase.defaultName, this.cremaHost.TrunkPath)); if (Directory.Exists(this.cremaHost.TagsPath) == true) { foreach (var item in Directory.GetDirectories(this.cremaHost.TagsPath)) { var dataBaseName = Path.GetFileName(item); yield return(new KeyValuePair <string, string>(dataBaseName, item)); } } if (Directory.Exists(this.cremaHost.BranchesPath) == true) { foreach (var item in Directory.GetDirectories(this.cremaHost.BranchesPath)) { var dataBaseName = Path.GetFileName(item); yield return(new KeyValuePair <string, string>(dataBaseName, item)); } } } }
public DomainContext(CremaHost cremaHost, UserContext userContext) { this.cremaHost = cremaHost; this.cremaHost.Debug(Resources.Message_DomainContextInitialize); this.userContext = userContext; this.basePath = DirectoryUtility.Prepare(cremaHost.WorkingPath, nameof(Domain).ToLower()); this.cremaHost.Opened += CremaHost_Opened; this.cremaHost.Debug(Resources.Message_DomainContextIsCreated); foreach (var item in this.cremaHost.DataBases) { var categoryName = CategoryName.Create(item.Name); var category = this.Categories.AddNew(categoryName); category.DataBase = item; } }
public UserContext(CremaHost cremaHost) { this.cremaHost = cremaHost; this.cremaHost.Debug(Resources.Message_UserContextInitialize); this.userFilePath = GenerateUsersFilePath(cremaHost.RepositoryPath); this.repository = new RepositoryHost(cremaHost.Repository, cremaHost.RepositoryDispatcher, this.userFilePath); this.dispatcher = new CremaDispatcher(this); this.dispatcher.Invoke(() => { this.Items.MessageReceived += Users_MessageReceived; this.Items.UsersLoggedIn += Users_UsersLoggedIn; this.Items.UsersLoggedOut += Users_UsersLoggedOut; this.Items.UsersKicked += Users_UsersKicked; this.Items.UsersBanChanged += Users_UsersBanChanged; }); this.cremaHost.Debug(Resources.Message_UserContextIsCreated); }
public UserContext(CremaHost cremaHost) { this.CremaHost = cremaHost; this.CremaHost.Debug(Resources.Message_UserContextInitialize); this.remotePath = cremaHost.GetPath(CremaPath.RepositoryUsers); this.BasePath = cremaHost.GetPath(CremaPath.Users); this.Serializer = cremaHost.Serializer; this.Repository = new UserRepositoryHost(this, this.CremaHost.RepositoryProvider.CreateInstance(new RepositorySettings() { RemotePath = this.remotePath, RepositoryName = string.Empty, BasePath = this.BasePath, LogService = this.CremaHost })); this.Dispatcher = new CremaDispatcher(this); this.CremaHost.Debug(Resources.Message_UserContextIsCreated); }
public DomainContext(CremaHost cremaHost, string address, ServiceInfo serviceInfo) { this.cremaHost = cremaHost; this.userContext = cremaHost.UserContext; this.serviceDispatcher = new CremaDispatcher(this); var metaData = this.serviceDispatcher.Invoke(() => { var binding = CremaHost.CreateBinding(serviceInfo); var endPointAddress = new EndpointAddress($"net.tcp://{address}:{serviceInfo.Port}/DomainService"); var instanceContext = new InstanceContext(this); if (Environment.OSVersion.Platform != PlatformID.Unix) { instanceContext.SynchronizationContext = System.Threading.SynchronizationContext.Current; } this.service = new DomainServiceClient(instanceContext, binding, endPointAddress); this.service.Open(); if (this.service is ICommunicationObject service) { service.Faulted += Service_Faulted; } var result = this.service.Subscribe(this.cremaHost.AuthenticationToken); result.Validate(); #if !DEBUG this.timer = new Timer(30000); this.timer.Elapsed += Timer_Elapsed; this.timer.Start(); #endif return(result.Value); }); this.Initialize(metaData); this.cremaHost.DataBases.ItemsCreated += DataBases_ItemsCreated; this.cremaHost.DataBases.ItemsRenamed += DataBases_ItemsRenamed; this.cremaHost.DataBases.ItemsDeleted += DataBases_ItemDeleted; this.cremaHost.AddService(this); }
public void Dispose() { CremaHost?.Dispose(); ServerHost?.Dispose(); }