public RavenFileSystem(InMemoryRavenConfiguration systemConfiguration, string name, TransportState receivedTransportState = null) { ExtensionsState = new AtomicDictionary <object>(); Name = name; this.systemConfiguration = systemConfiguration; systemConfiguration.Container.SatisfyImportsOnce(this); transportState = receivedTransportState ?? new TransportState(); storage = CreateTransactionalStorage(systemConfiguration); sigGenerator = new SigGenerator(); fileLockManager = new FileLockManager(); BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024); conflictDetector = new ConflictDetector(); conflictResolver = new ConflictResolver(storage, new CompositionContainer(systemConfiguration.Catalog)); notificationPublisher = new NotificationPublisher(transportState); synchronizationTask = new SynchronizationTask(storage, sigGenerator, notificationPublisher, systemConfiguration); metricsCounters = new MetricsCountersManager(); search = new IndexStorage(name, systemConfiguration); conflictArtifactManager = new ConflictArtifactManager(storage, search); storageOperationsTask = new StorageOperationsTask(storage, DeleteTriggers, search, notificationPublisher); AppDomain.CurrentDomain.ProcessExit += ShouldDispose; AppDomain.CurrentDomain.DomainUnload += ShouldDispose; }
public virtual int removeStoreManager(User session, Store s, String oldManager) { User session2 = UserManager.getInstance().getUser(oldManager); if (session == null) { return(-1);//-1 if user Not Login } if (s == null) { return(-3);//-3 if illegal store id } if (oldManager == null) { return(-6);// -6 old manager name doesn't exsist } StoreRole sr = StoreManagement.getInstance().getStoreRole(s, session2); if (sr != null && !(sr is StoreManager)) { return(-7); } if (StoreManagement.getInstance().removeStoreRole(s.getStoreId(), oldManager)) { NotificationPublisher.getInstance().removeAllNotificationSubscriptionsOfAStoreRole(this); return(0); } return(-5);//-5 database eror }
public RavenFileSystem(InMemoryRavenConfiguration systemConfiguration, string name, TransportState recievedTransportState = null) { this.Name = name; this.systemConfiguration = systemConfiguration; var storageType = systemConfiguration.FileSystem.DefaultStorageTypeName; storage = CreateTransactionalStorage(storageType, systemConfiguration); search = new IndexStorage(systemConfiguration.FileSystem.IndexStoragePath, systemConfiguration.Settings); sigGenerator = new SigGenerator(); var replicationHiLo = new SynchronizationHiLo(storage); var sequenceActions = new SequenceActions(storage); transportState = recievedTransportState ?? new TransportState(); notificationPublisher = new NotificationPublisher(transportState); fileLockManager = new FileLockManager(); storage.Initialize(); search.Initialize(); var uuidGenerator = new UuidGenerator(sequenceActions); historian = new Historian(storage, replicationHiLo, uuidGenerator); BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024); conflictArtifactManager = new ConflictArtifactManager(storage, search); conflictDetector = new ConflictDetector(); conflictResolver = new ConflictResolver(storage, new CompositionContainer(systemConfiguration.Catalog)); synchronizationTask = new SynchronizationTask(storage, sigGenerator, notificationPublisher, systemConfiguration); storageOperationsTask = new StorageOperationsTask(storage, search, notificationPublisher); metricsCounters = new MetricsCountersManager(); AppDomain.CurrentDomain.ProcessExit += ShouldDispose; AppDomain.CurrentDomain.DomainUnload += ShouldDispose; }
public ArticleController(ArticleAppService articleAppService, CommentManager commentManager, NotificationPublisher notificationPublisher, NotificationSubscriptionManager notificationSubscriptionManager) { _articleAppService = articleAppService; _commentManager = commentManager; _notificationPublisher = notificationPublisher; _notificationSubscriptionManager = notificationSubscriptionManager; }
public virtual Boolean addStoreOwner(User session, Store s, String newOwnerUserName) { User newOwner = UserManager.getInstance().getUser(newOwnerUserName); if (newOwner == null || s == null || session == null) { return(false); } StoreRole sr = StoreManagement.getInstance().getStoreRole(s, newOwner); if (sr != null && (sr is StoreOwner)) { return(false); } if (sr != null && (sr is StoreManager)) { removeStoreManager(session, s, newOwnerUserName); } if (sr != null && (sr is Customer)) { StoreManagement.getInstance().removeStoreRole(s.getStoreId(), newOwner.getUserName()); } StoreRole owner = new StoreOwner(newOwner, s, session.userName); Boolean ans = StoreManagement.getInstance().addStoreRole(owner, s.getStoreId(), newOwner.getUserName()); if (ans) { NotificationPublisher.getInstance().signToCategory(this, NotificationPublisher.NotificationCategories.Purchase); NotificationPublisher.getInstance().signToCategory(this, NotificationPublisher.NotificationCategories.RaffleSale); NotificationPublisher.getInstance().signToCategory(this, NotificationPublisher.NotificationCategories.Store); } return(ans); }
public ProblemController(ProblemAppService problemAppService, ArticleController articleController, NotificationSubscriptionManager notificationSubscriptionManager, NotificationPublisher notificationPublisher) { _problemAppService = problemAppService; _articleController = articleController; _notificationSubscriptionManager = notificationSubscriptionManager; _notificationPublisher = notificationPublisher; }
public NotificationPublisher_Tests() { _store = Substitute.For <INotificationStore>(); _backgroundJobManager = Substitute.For <IBackgroundJobManager>(); _publisher = new NotificationPublisher(_store, _backgroundJobManager, Substitute.For <INotificationDistributer>()); _publisher.UnitOfWorkManager = Substitute.For <IUnitOfWorkManager>(); _publisher.UnitOfWorkManager.Current.Returns(Substitute.For <IActiveUnitOfWork>()); }
public NotificationPublisherTests() { store = Substitute.For <INotificationStore>(); backgroundJobManager = Substitute.For <IBackgroundJobManager>(); publisher = new NotificationPublisher(store, backgroundJobManager, Substitute.For <INotificationDistributer>(), SequentialGuidGenerator.Instance); publisher.UnitOfWorkManager = Substitute.For <IUnitOfWorkManager>(); publisher.UnitOfWorkManager.Current.Returns(Substitute.For <IActiveUnitOfWork>()); }
public NotificationPublisher_Tests() { _store = Substitute.For <INotificationStore>(); _backgroundJobManager = Substitute.For <IBackgroundJobManager>(); _publisher = new NotificationPublisher(_store, _backgroundJobManager, Substitute.For <INotificationConfiguration>(), SequentialGuidGenerator.Instance, LocalIocManager); _publisher.UnitOfWorkManager = Substitute.For <IUnitOfWorkManager>(); _publisher.UnitOfWorkManager.Current.Returns(Substitute.For <IActiveUnitOfWork>()); }
public void DeployFailed() { DeployStatus = DeployStatus.DeployFailed; Version.DeployFailed = true; VersionUtil.UpdateVersionLog(DataDirectory, Version); NotificationPublisher.PublishNotifications(new DeployFailedEvent(Name, Version)); }
public void sendMessageTORaffleWinner(int saleId) { Sale s = SalesManager.getInstance().getSale(saleId); ProductInStore p = ProductManager.getInstance().getProductInStore(s.ProductInStoreId); LinkedList <RaffleSale> relevant = new LinkedList <RaffleSale>(); double realPrice = p.price; double acc = 0; foreach (RaffleSale rs in raffleSales) { if (rs.SaleId == saleId) { acc += rs.Offer; relevant.AddLast(rs); } } if (acc == realPrice) { int index = 1; Random rand = new Random(); int winner = rand.Next(1, (int)realPrice); RaffleSale winnerS = null; foreach (RaffleSale r in relevant) { if (winner <= r.Offer + index && winner >= index) { string message = r.UserName + " WON THE RAFFLE SALE ON PRODUCT: " + getProductNameFromSaleId(r.SaleId); NotificationPublisher.getInstance().publish(NotificationPublisher.NotificationCategories.RaffleSale, message, p.getStore().storeId); StoreRole sR = StoreRole.getStoreRole(p.getStore(), UserManager.getInstance().getUser(r.UserName)); NotificationPublisher.getInstance().removeAllNotificationSubscriptionsOfAStoreRole(sR); //NotificationManager.getInstance().notifyUser(r.UserName, message); winnerS = r; break; } else { index += (int)r.Offer; } } if (winnerS != null) { RSDB.Remove(winnerS); raffleSales.Remove(winnerS); relevant.Remove(winnerS); } foreach (RaffleSale r in relevant) { string message = r.UserName + " LOST THE RAFFLE SALE ON PRODUCT: " + getProductNameFromSaleId(r.SaleId); NotificationPublisher.getInstance().publish(NotificationPublisher.NotificationCategories.RaffleSale, message, p.getStore().storeId); StoreRole sR = StoreRole.getStoreRole(p.getStore(), UserManager.getInstance().getUser(r.UserName)); NotificationPublisher.getInstance().removeAllNotificationSubscriptionsOfAStoreRole(sR); //NotificationManager.getInstance().notifyUser(r.UserName, message); RSDB.Remove(winnerS); raffleSales.Remove(r); } } }
public RavenFileSystem(InMemoryRavenConfiguration config, string name, TransportState receivedTransportState = null) { ExtensionsState = new AtomicDictionary <object>(); Name = name; ResourceName = string.Concat(Constants.FileSystem.UrlPrefix, "/", name); configuration = config; try { ValidateStorage(); configuration.Container.SatisfyImportsOnce(this); transportState = receivedTransportState ?? new TransportState(); storage = CreateTransactionalStorage(configuration); sigGenerator = new SigGenerator(); fileLockManager = new FileLockManager(); BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024); conflictDetector = new ConflictDetector(); conflictResolver = new ConflictResolver(storage, new CompositionContainer(configuration.Catalog)); notificationPublisher = new NotificationPublisher(transportState); synchronizationTask = new SynchronizationTask(storage, sigGenerator, notificationPublisher, configuration); metricsCounters = new MetricsCountersManager(); search = new IndexStorage(name, configuration); conflictArtifactManager = new ConflictArtifactManager(storage, search); TimerManager = new ResourceTimerManager(); Tasks = new TaskActions(this, Log); Files = new FileActions(this, Log); Synchronizations = new SynchronizationActions(this, Log); AppDomain.CurrentDomain.ProcessExit += ShouldDispose; AppDomain.CurrentDomain.DomainUnload += ShouldDispose; } catch (Exception e) { Log.ErrorException(string.Format("Could not create file system '{0}'", Name ?? "unknown name"), e); try { Dispose(); } catch (Exception ex) { Log.FatalException("Failed to dispose when already getting an error in file system ctor", ex); } throw; } }
public void DeployCompleted() { DeployStatus = DeployStatus.NA; VersionUtil.UpdateVersionLog(DataDirectory, Version); var unitInfo = GetUnitInfo(); NotificationPublisher.PublishNotifications((new DeployCompletedEvent(Name, Version, unitInfo.Status))); }
public SynchronizationTask(ITransactionalStorage storage, SigGenerator sigGenerator, NotificationPublisher publisher, RavenConfiguration systemConfiguration) { this.storage = storage; this.publisher = publisher; this.systemConfiguration = systemConfiguration; context = new SynchronizationTaskContext(); synchronizationQueue = new SynchronizationQueue(); synchronizationStrategy = new SynchronizationStrategy(storage, sigGenerator, systemConfiguration); }
public Boolean addRaffleSale(int saleId, String userName, double offer, String dueDate) { RaffleSale toAdd = new RaffleSale(saleId, userName, offer, dueDate); ProductInStore pis = ProductManager.getInstance().getProductInStore(SalesManager.getInstance().getSale(saleId).ProductInStoreId); StoreRole sR = StoreRole.getStoreRole(pis.store, UserManager.getInstance().getUser(userName)); NotificationPublisher.getInstance().signToCategory(sR, NotificationPublisher.NotificationCategories.RaffleSale); RSDB.Add(toAdd); raffleSales.AddLast(toAdd); return(true); }
public virtual int createStore(String storeName, User session) { Store newStore = StoreManagement.getInstance().addStore(storeName, session); StoreRole sR = new StoreOwner(session, newStore, session.getUserName()); StoreManagement.getInstance().addStoreRole(sR, newStore.getStoreId(), session.getUserName()); NotificationPublisher.getInstance().signToCategory(sR, NotificationPublisher.NotificationCategories.Purchase); NotificationPublisher.getInstance().signToCategory(sR, NotificationPublisher.NotificationCategories.RaffleSale); NotificationPublisher.getInstance().signToCategory(sR, NotificationPublisher.NotificationCategories.Store); return(newStore.getStoreId()); }
public UserController(UserAppService userAppService, FileAppService fileAppService, UserManager userManager, UserTypeAppService userTypeAppService, ProblemAppService problemAppService, CertificateAppService certificateAppService, ArticleAppService articleAppService, NotificationPublisher notificationPublisher) { _userAppService = userAppService; _fileAppService = fileAppService; _userManager = userManager; _userTypeAppService = userTypeAppService; _problemAppService = problemAppService; _certificateAppService = certificateAppService; _articleAppService = articleAppService; _notificationPublisher = notificationPublisher; }
public SynchronizationTask(ITransactionalStorage storage, SigGenerator sigGenerator, NotificationPublisher publisher, InMemoryRavenConfiguration systemConfiguration) { this.storage = storage; this.publisher = publisher; this.systemConfiguration = systemConfiguration; synchronizationQueue = new SynchronizationQueue(); synchronizationStrategy = new SynchronizationStrategy(storage, sigGenerator); LastSuccessfulSynchronizationTime = DateTime.MinValue; InitializeTimer(); }
public PushNotificationService( NotificationPublisher pushNotificationPublisher, RetryPolicySettings retryPolicySettings, ILogFactory logFactory) { _pushNotificationPublisher = pushNotificationPublisher; _log = logFactory.CreateLog(this); _retryPolicy = Policy .Handle <Exception>() .WaitAndRetryAsync( retryPolicySettings.DefaultAttempts, attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)), (ex, timespan) => _log.Error(ex, "Publish confirmations to callback with retry")); }
public NotificationPublisher_Tests() { _backgroundJobManager = GetRequiredService <IBackgroundJobManager>(); _currentTenant = GetRequiredService <ICurrentTenant>(); _notificationDistributer = GetRequiredService <INotificationDistributer>(); _guidGenerator = GetRequiredService <IGuidGenerator>(); _clock = GetRequiredService <IClock>(); _notificationPublisher = new NotificationPublisher( _currentTenant, _backgroundJobManager, _notificationDistributer, _guidGenerator, _clock ); }
public RavenFileSystem(InMemoryRavenConfiguration systemConfiguration, TransportState transportState, string name) { this.Name = name; this.systemConfiguration = systemConfiguration; var storageType = systemConfiguration.DefaultFileSystemStorageTypeName; if (string.Equals(InMemoryRavenConfiguration.VoronTypeName, storageType, StringComparison.OrdinalIgnoreCase) == false) { if (Directory.Exists(systemConfiguration.FileSystemDataDirectory) && Directory.EnumerateFileSystemEntries(systemConfiguration.FileSystemDataDirectory).Any()) { throw new InvalidOperationException( string.Format( "We do not allow to run on a storage engine other then Voron, while we are in the early pre-release phase of RavenDB 3.0. You are currently running on {0}", storageType)); } Trace.WriteLine("Forcing filesystem to run on Voron - pre release behavior only, mind " + Path.GetFileName(Path.GetDirectoryName(systemConfiguration.FileSystemDataDirectory))); storageType = InMemoryRavenConfiguration.VoronTypeName; } storage = CreateTransactionalStorage(storageType, systemConfiguration); search = new IndexStorage(systemConfiguration.FileSystemIndexStoragePath, systemConfiguration.Settings); sigGenerator = new SigGenerator(); var replicationHiLo = new SynchronizationHiLo(storage); var sequenceActions = new SequenceActions(storage); this.transportState = transportState; notificationPublisher = new NotificationPublisher(transportState); fileLockManager = new FileLockManager(); storage.Initialize(); search.Initialize(); var uuidGenerator = new UuidGenerator(sequenceActions); historian = new Historian(storage, replicationHiLo, uuidGenerator); BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024); conflictArtifactManager = new ConflictArtifactManager(storage, search); conflictDetector = new ConflictDetector(); conflictResolver = new ConflictResolver(); synchronizationTask = new SynchronizationTask(storage, sigGenerator, notificationPublisher, systemConfiguration); storageOperationsTask = new StorageOperationsTask(storage, search, notificationPublisher); metricsCounters = new MetricsCountersManager(); AppDomain.CurrentDomain.ProcessExit += ShouldDispose; AppDomain.CurrentDomain.DomainUnload += ShouldDispose; }
public async void SendGridTest() { var config = NotificationConfigBuilder.Build(); var sgc = new NotificationConfiguration { APIKey = config.APIKey }; var sendgrid = new Email { Subject = "*****@*****.**", To = new System.Collections.Generic.List <string> { "*****@*****.**" }, Content = "Hello world" }; var publisher = new NotificationPublisher <SendGridNotificationAgent <Notification.Concerns.Notification> >(sgc); var obj = publisher.Publish(sendgrid); }
public void ProcessMessage(ISendSMSCommand command, string connectionAddress) { Console.WriteLine($"MTN PROVIDER ---> send {command.Text} to {command.To}"); try { var result = _messager.Post <MTNMessage, int>("http://localhost:50508/sendsms", new MTNMessage() { ApiKey = Guid.NewGuid().ToString(), Text = command.Text, To = command.To }).Result; } catch (Exception ex) { throw; } NotificationPublisher.DispatchConfirmationMessage(command.ProviderId, command.CorrellationId, connectionAddress); }
public void StartingDeploy(AsimovVersion newVersion, string logFileName, AsimovUser user, ParameterValues parameters) { DeployStatus = DeployStatus.Deploying; Version = new DeployedVersion() { DeployTimestamp = DateTime.Now, VersionId = newVersion.Id, VersionNumber = newVersion.Number, VersionBranch = newVersion.Branch, VersionTimestamp = newVersion.Timestamp, VersionCommit = newVersion.Commit, LogFileName = logFileName, UserId = user.UserId, UserName = user.UserName, DeployFailed = false, Parameters = parameters.GetInternalDictionary() }; NotificationPublisher.PublishNotifications(new DeployStartedEvent(Name, Version)); }
private void CheckFinishedRaffelSales(object source, ElapsedEventArgs e) { LinkedList <RaffleSale> raffleSalesToRemove = new LinkedList <RaffleSale>(); foreach (RaffleSale rs in raffleSales) { if (DateTime.Now.CompareTo(DateTime.Parse(rs.DueDate)) > 0) { string message = "the Raffle sale " + rs.SaleId + " has been canceled"; NotificationPublisher.getInstance().publish(NotificationPublisher.NotificationCategories.RaffleSale, message, rs.SaleId); //NotificationManager.getInstance().notifyUser(rs.UserName, message); raffleSalesToRemove.AddLast(rs); } } foreach (RaffleSale rs in raffleSalesToRemove) { RSDB.Remove(rs); raffleSales.Remove(rs); } }
public void removeUserFromNotifications(string notification, int storeId) { Store store = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(store, this); switch (notification) { case "Store": NotificationPublisher.getInstance().removeFromCategory(sR, NotificationPublisher.NotificationCategories.Store); break; case "Purchase": NotificationPublisher.getInstance().removeFromCategory(sR, NotificationPublisher.NotificationCategories.Purchase); break; case "RaffleSale": NotificationPublisher.getInstance().removeFromCategory(sR, NotificationPublisher.NotificationCategories.RaffleSale); break; default: break; } }
public async void Test1() { var config = NotificationConfigBuilder.Build(); var args = new NotificationConfiguration { Host = config.Host, Port = config.Port, UserName = config.UserName, Password = config.Password }; var smtp = new Email { Subject = "*****@*****.**", To = new System.Collections.Generic.List <string> { "*****@*****.**" }, Content = "Hello world" }; var publisher = new NotificationPublisher <SMTPNotificationAgent <Notification.Concerns.Notification> >(args); var obj = publisher.Publish(smtp); // await obj.SendAsync( }
public virtual int removeStoreOwner(User session, Store s, String ownerToDelete) { User oldOwner = UserManager.getInstance().getUser(ownerToDelete); StoreRole sR2 = StoreRole.getStoreRole(s, oldOwner); if (ownerToDelete == user.getUserName()) { return(-10);//-10 can't remove himself } if (!(sR2 is StoreOwner)) { return(-11);//-11 not a owner } if (s.getStoreCreator().getUserName().Equals(ownerToDelete)) { return(-12);//-12 if dealet creator } if (StoreManagement.getInstance().removeStoreRole(s.getStoreId(), ownerToDelete)) { NotificationPublisher.getInstance().removeAllNotificationSubscriptionsOfAStoreRole(this); return(0); } return(-9);//-9 database eror }
public HomeController(NotificationPublisher notificationPublisher) { _notificationPublisher = notificationPublisher; }
public NotificationPublisherTests() { publisher = new NotificationPublisher(eventRepository, logbookEntryRepository, notificationRepository); }