public RepositoryHost(IRepository repository, CremaDispatcher dispatcher, string path) { this.repository = repository; this.dispatcher = dispatcher; this.path = path; this.revision = this.repository.GetRevision(path); }
public CremaHost(CremaSettings settings, [ImportMany] IEnumerable <IRepositoryProvider> repoProviders) { CremaLog.Debug("crema instance created."); this.settings = settings; this.basePath = settings.BasePath; this.repositoryPath = Path.Combine(settings.BasePath, settings.RepositoryName); this.trunkPath = Path.Combine(this.repositoryPath, trunkString); this.tagsPath = Path.Combine(this.repositoryPath, tagsString); this.branchesPath = Path.Combine(this.repositoryPath, branchesString); this.workingPath = Path.Combine(this.basePath, workingString); this.repositoryProvider = repoProviders.First(item => item.Name == this.settings.RepositoryModule); this.repositoryProvider.ValidateRepository(this.basePath, this.repositoryPath); this.log = new LogService(this.GetType().FullName, this.WorkingPath) { Name = "repository", Verbose = settings.Verbose }; CremaLog.Debug("crema log service initialized."); CremaLog.Debug($"available tags : {string.Join(", ", TagInfoUtility.Names)}"); if (settings.MultiThreading == true) { this.dispatcher = new CremaDispatcher(this); } else { this.dispatcher = new CremaDispatcher(this, System.Windows.Threading.Dispatcher.CurrentDispatcher); } this.repositoryDispatcher = new CremaDispatcher(this.repositoryProvider); CremaLog.Debug("crema dispatcher initialized."); }
public RuntimeServiceItem(IDataBase dataBase, CremaDispatcher dispatcher, Authentication authentication) : base(dataBase) { this.dispatcher = dispatcher; this.authentication = authentication; this.logService = dataBase.GetService(typeof(ILogService)) as ILogService; }
protected Domain(DomainInfo domainInfo, CremaDispatcher dispatcher) { this.dispatcher = dispatcher; this.Initialize(domainInfo); ; this.Name = domainInfo.DomainID.ToString(); this.users = new DomainUserCollection(this); }
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 TypeDomain(DomainInfo domainInfo, CremaDispatcher dispatcher) : base(domainInfo, dispatcher) { if (domainInfo.ItemType == nameof(NewTypeTemplate)) { this.IsNew = true; } }
protected DataServiceBase(ICremaHost cremaHost, Guid pluginID, string name) { this.cremaHost = cremaHost; this.pluginID = pluginID; this.name = name ?? throw new ArgumentNullException(nameof(name)); this.dispatcher = new CremaDispatcher(this); this.cremaHost.Closing += CremaHost_Closing; }
public void Dispose(Authentication authentication, bool isCanceled) { var container = this.Container; this.Dispose(); this.dispatcher = null; this.OnDeleted(new DomainDeletedEventArgs(authentication, this, isCanceled)); container.InvokeDomainDeletedEvent(authentication, this, isCanceled); }
public CremaEventListenerContext(CremaEventListenerHost[] eventListener) { this.eventListeners = eventListener.ToDictionary(item => item.EventName); this.dispatcher = new CremaDispatcher(this); foreach (var item in eventListener) { item.Dispatcher = this.dispatcher; } }
public RuntimeService(ICremaHost cremaHost, [ImportMany] IEnumerable <Runtime.Serialization.IDataSerializer> serializers) { this.cremaHost = cremaHost; this.serializers = serializers; this.dispatcher = new CremaDispatcher(this); this.cremaHost.Opened += CremaHost_Opened; this.cremaHost.Closed += CremaHost_Closed; this.cremaHost.Disposed += (s, e) => this.dispatcher.Dispose(); }
public void Initialize(Authentication authentication) { this.dispatcher = new CremaDispatcher(this); this.authentication = authentication; foreach (var item in this.cremaHost.DataBases) { var serviceItem = new DataFindServiceItem(item, this.dispatcher, authentication); this.items.Add(item.ID, serviceItem); } }
public void Delete(Authentication authentication, bool isCanceled) { this.dispatcher.VerifyAccess(); this.CremaHost.DebugMethod(authentication, this, nameof(Delete), this); var container = this.Container; var result = this.Service.DeleteDomain(this.ID, isCanceled); this.Sign(authentication, result); this.Dispose(); this.dispatcher = null; this.OnDeleted(new DomainDeletedEventArgs(authentication, this, isCanceled)); container.InvokeDomainDeletedEvent(authentication, this, isCanceled); }
public void Dispose(Authentication authentication, bool isCanceled) { this.dispatcher.VerifyAccess(); var container = this.Container; this.dispatcher.Dispose(); this.dispatcher = null; this.domainLogger?.Dispose(true); this.domainLogger = null; this.Dispose(); this.OnDeleted(new DomainDeletedEventArgs(authentication, this, isCanceled)); container.InvokeDomainDeletedEvent(authentication, this, isCanceled); }
public DataBaseEventListenerContext(ICremaHost cremaHost, DataBaseEventListenerHost[] eventListener) { this.cremaHost = cremaHost; this.listenerHosts = eventListener.ToDictionary(item => item.EventName); this.dispatcher = new CremaDispatcher(this); foreach (var item in eventListener) { item.Dispatcher = this.dispatcher; } this.cremaHost.Dispatcher.Invoke(() => this.cremaHost.DataBases.ItemsLoaded += DataBases_ItemsLoaded); this.cremaHost.Dispatcher.Invoke(() => this.cremaHost.DataBases.ItemsUnloaded += DataBases_ItemsUnloaded); }
public void Dispose() { if (this.dataBases != null) { throw new InvalidOperationException(Resources.Exception_NotClosed); } this.repositoryDispatcher.Dispose(); this.repositoryDispatcher = null; this.dispatcher.Dispose(); this.dispatcher = null; this.OnDisposed(EventArgs.Empty); CremaLog.Release(); }
void IDomainServiceCallback.OnServiceClosed(SignatureDate signatureDate, CloseInfo closeInfo) { this.service.Abort(); this.service = null; this.timer?.Dispose(); this.timer = null; this.serviceDispatcher.Dispose(); this.serviceDispatcher = null; this.InvokeAsync(() => { this.cremaHost.RemoveService(this); }, nameof(IDomainServiceCallback.OnServiceClosed)); }
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 void Dispose() { this.ValidateDispose(); if (Environment.ExitCode != 0 && this.IsOpened == true) { this.Close(CloseInfo.Empty); } this.dispatcher.Dispose(false); this.dispatcher = null; this.OnDisposed(EventArgs.Empty); CremaLog.Info("Crema disposed."); }
public void Delete(Authentication authentication, bool isCanceled) { this.dispatcher.VerifyAccess(); this.CremaHost.DebugMethod(authentication, this, nameof(Delete), base.DomainInfo.ItemPath, base.DomainInfo.ItemType, isCanceled); this.ValidateDelete(authentication, isCanceled); this.Sign(authentication, true); var container = this.Container; this.dispatcher.Dispose(); this.dispatcher = null; this.domainLogger?.Dispose(true); this.domainLogger = null; this.users.Clear(); this.Dispose(); this.OnDeleted(new DomainDeletedEventArgs(authentication, this, isCanceled)); container.InvokeDomainDeletedEvent(authentication, this, isCanceled); }
public void Dispose(DomainContext domainContext) { try { this.dispatcher.VerifyAccess(); this.dispatcher.Dispose(); this.dispatcher = null; this.domainLogger?.Dispose(false); this.domainLogger = null; this.Dispose(); } catch (Exception e) { this.CremaHost.Error(e); throw; } }
public void Dispose(bool disposing) { this.dispatcher.VerifyAccess(); var container = this.Container; this.dispatcher.Dispose(); this.dispatcher = null; this.domainLogger?.Dispose(false); this.domainLogger = null; this.Dispose(); if (disposing == false) { container.InvokeDomainDeletedEvent(Authentication.System, this, false); } }
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); }
private void Service_Faulted(object sender, EventArgs e) { this.serviceDispatcher.Invoke(() => { try { this.service.Abort(); this.service = null; } catch { } this.timer?.Dispose(); this.timer = null; this.serviceDispatcher.Dispose(); this.serviceDispatcher = null; }); this.InvokeAsync(() => { this.cremaHost.RemoveService(this, new CloseInfo(CloseReason.Faulted, "서버와의 연결이 끊어졌습니다.")); }, nameof(Service_Faulted)); }
private void Service_Faulted(object sender, EventArgs e) { this.serviceDispatcher.Invoke(() => { try { this.service.Abort(); this.service = null; } catch { } this.timer?.Dispose(); this.timer = null; this.serviceDispatcher.Dispose(); this.serviceDispatcher = null; }); this.InvokeAsync(() => { this.cremaHost.RemoveService(this); }, nameof(Service_Faulted)); }
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 Close(CloseInfo closeInfo) { this.serviceDispatcher?.Invoke(() => { this.timer?.Dispose(); this.timer = null; if (this.service != null) { try { if (closeInfo.Reason != CloseReason.NoResponding) { this.service.Unsubscribe(); if (Environment.OSVersion.Platform == PlatformID.Win32NT) { this.service.Close(); } else { this.service.Abort(); } } else { this.service.Abort(); } } catch { this.service.Abort(); } this.service = null; } this.serviceDispatcher.Dispose(); this.serviceDispatcher = null; }); }
static CremaService() { dispatcher = new CremaDispatcher(typeof(CremaServiceItemHost)); }
public CremaHost() { this.dispatcher = new CremaDispatcher(this); CremaLog.Debug($"available tags : {string.Join(",", TagInfoUtility.Names)}"); CremaLog.Debug("Crema created."); }
public TableContentDomain(DomainInfo domainInfo, CremaDispatcher dispatcher) : base(domainInfo, dispatcher) { }
protected abstract T CreateItem(IDataBase dataBase, CremaDispatcher Dispatcher, Authentication authentication);