public override void OnNotify(string notification, NotificationArgs args) { if (Global.IsIntegrationActive && Connector.IsWebServiceConnectionAvailable()) { //Used to load the cart and apply the discount after the user logged-in and has not empty cart var myArgs = (Dynamicweb.Notifications.Standard.User.OnExtranetLoginArgs)args; var order = Dynamicweb.Ecommerce.Common.Context.Cart; if (myArgs.User != null) { UrlHandler.Instance.ClearCachedUrl(); Dynamicweb.Ecommerce.Integration.ErpResponseCache.ClearAllCaches(); PrepareProductInfoProvider.ClearUserCache(); //check if user has updates CheckUser(myArgs.User); } if (order != null && order.IsCart && EnabledAndActive()) { if (Global.EnableCartCommunication(order.Complete)) { OrderHandler.UpdateOrder(order, LiveIntegrationSubmitType.LiveOrderOrCart); } else { CheckOrderPrices(order, "OnExtranetLogin"); } } } }
public override void OnNotify(string notification, NotificationArgs args) { Log("Subscriber: " + notification); switch (notification.ToLower()) { case "dna.ecommerce.liveintegration.notifications.liveintegration.onbeforerenderorderxml": var localArgs = (LiveIntegration.Orders.OnBeforeRenderOrderXmlArgs)args; Log(" Order ID: " + localArgs.Order.Id); Log(" Render settings: " + localArgs.RenderSettings.Beautify); break; case "dna.ecommerce.liveintegration.notifications.liveintegration.onafterrenderorderxml": var localAfterArgs = (LiveIntegration.Orders.OnAfterRenderOrderXmlArgs)args; Log(" Order ID: " + localAfterArgs.Order.Id); Log(" Number of nodes:" + localAfterArgs.Document.ChildNodes.Count); break; case "dna.ecommerce.liveintegration.notifications.liveintegration.onbeforerenderorderlinexml": var localBeforeLineArgs = (LiveIntegration.OrderLines.OnBeforeRenderOrderLineXmlArgs)args; Log(" Order Line ID: " + localBeforeLineArgs.OrderLine.Id); break; case "dna.ecommerce.liveintegration.notifications.liveintegration.onafterrenderorderlinexml": var localAfterLineArgs = (LiveIntegration.OrderLines.OnAfterRenderOrderLineXmlArgs)args; Log(" Order Line ID: " + localAfterLineArgs.OrderLine.Id); Log(" Number of nodes:" + localAfterLineArgs.OrderLineNode.ChildNodes.Count); break; } base.OnNotify(notification, args); }
public override void OnNotify(string notification, NotificationArgs args) { if (args == null || !(args is Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.CheckoutDoneOrderIsCompleteArgs) || !Global.IsIntegrationActive || !Connector.IsWebServiceConnectionAvailable()) { return; } var myArgs = (Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.CheckoutDoneOrderIsCompleteArgs)args; // context not defined with (Authorize.net) checkout handler if (Global.IntegrationEnabledFor(myArgs.Order.ShopId) && Global.EnableCartCommunication(myArgs.Order.Complete)) { var result = OrderHandler.UpdateOrder(myArgs.Order, LiveIntegrationSubmitType.LiveOrderOrCart); // clear cached prices to update stock if order is completed with success if (result.HasValue && result.Value) { base.SetProductInformation(myArgs.Order); } } }
public override void OnNotify(string notification, NotificationArgs args) { if (args == null || !(args is Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.DecreasedArgs) || !EnabledAndActive()) { return; } var myArgs = (Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.DecreasedArgs)args; base.UpdateOrder(myArgs?.Cart, "Line.Decreased"); //if (myArgs.Cart != null) //{ // if (Global.EnableCartCommunication(myArgs.Cart.Complete)) // { // OrderHandler.UpdateOrder(myArgs.Cart, LiveIntegrationSubmitType.LiveOrderOrCart); // } // else // { // CheckOrderPrices(myArgs.Cart, "Line.Decreased"); // } //} }
protected virtual void OnNotification(NotificationArgs e) { if (Notification != null) { Notification(this, e); } }
public override void OnNotify(string notification, NotificationArgs args) { if (args == null || !(args is Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.IncreasedArgs) || !EnabledAndActive()) { return; } var myArgs = (Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.IncreasedArgs)args; if (!base.CantCheckPrice) { SetProductInformation(myArgs.IncreasedLine.Product); } if (myArgs.Cart != null) { if (Global.EnableCartCommunication(myArgs.Cart.Complete)) { OrderHandler.UpdateOrder(myArgs.Cart, LiveIntegrationSubmitType.LiveOrderOrCart); } else { CheckOrderPrices(myArgs.Cart, "Line.Increased"); } } }
public override void OnNotify(string notification, NotificationArgs args) { if (args == null || !(args is UserNotificationArgs) || _isSaving || !Global.IsIntegrationActive || !Connector.IsWebServiceConnectionAvailable() || !Global.IsUserSynchEnabled) { return; } var userArgs = (UserNotificationArgs)args; var user = userArgs.Subject; try { lock (Lock) { _isSaving = true; Logger.Instance.Log(ErrorLevel.DebugInfo, "UserSavedObserver: Call ERP! ExternalId = " + user.ExternalID); user.SynchronizeUsingLiveIntegration(false); user.Save(); Logger.Instance.Log(ErrorLevel.DebugInfo, "UserSavedObserver: After save! ExternalId = " + user.ExternalID); _isSaving = false; } } catch (System.Exception anyError) { Logger.Instance.Log(ErrorLevel.DebugInfo, string.Format("Error sync the user: {0}", anyError)); } }
public void SetUp() { List <Note> notes = new List <Note> { new Note { Name = "TestNote1", Description = "TestDescription1" }, new Note { Name = "TestNote2", Description = "TestDescription2" } }; var stubDataProvider = new Mock <IDataProvider>(); stubDataProvider.SetupAllProperties(); stubDataProvider.Setup(dp => dp.Notes).Returns(notes); stubDataProvider.Setup(dp => dp.GetCollection <Note>()).Returns(notes); mockNotificationCenter = new Mock <INotificationCenter>(); mockNotificationCenter.Setup(nc => nc.PostNotification(It.IsAny <NotificationName>(), It.IsAny <NotificationArgs>())) .Callback <NotificationName, NotificationArgs>((nName, nArgs) => notificationArgs = nArgs); notificationCenter = mockNotificationCenter.Object; notesVM = new NotesViewModel(stubDataProvider.Object, notificationCenter); }
// begin-snippet: argument_models_notify_with_model public void Notify( NotificationArgs notificationArgs, DryRunOptions dryRunOptions, VerbosityOptions verbosityOptions) { // send notification }
public override void OnNotify(string notification, NotificationArgs args) { const string NotificationName = "Cart.Loaded"; var myArgs = args as Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.LoadedArgs; if (myArgs?.Cart == null || myArgs.Cart.OrderLines.Count <= 0 || !EnabledAndActive()) { return; } if (Global.EnableCartCommunication(myArgs.Cart.Complete)) { // load cart when "Keep cart in context after checkout step" is on // if order is completed and exported to the ERP no need to update again if (myArgs.Cart.Complete && (myArgs.Cart.IsExported || !string.IsNullOrEmpty(myArgs.Cart.IntegrationOrderId))) { return; } OrderHandler.UpdateOrder(myArgs.Cart, LiveIntegrationSubmitType.LiveOrderOrCart); } else { CheckOrderPrices(myArgs.Cart, NotificationName); } }
private MailMessage GenerateMessage(int reviewId, Event evt) { MailMessage message; try { var session = _reviewRepository.Get(reviewId); var account = _accountRepository.GetByName(session.Reviewer); var args = new NotificationArgs { BaseUrl = ConfigurationManager.AppSettings["WebUrl"], DisplayName = account.ScreenName, Recipient = account.EmailAddress, SessionId = reviewId.ToString(), SessionName = session.Title }; message = _generator.Generate(evt.EventType, args); evt.Recevied = true; } catch (Exception ex) { string test = ex.Message; throw; } return(message); }
public Notification(Component componentSender, NotificationName notificationName, NotificationArgs extraArgs = null, Component componentReciever = null) { sender = componentSender; reciever = componentReciever; name = notificationName; args = extraArgs; }
private void StartRepoDownload() { string repoLocation; NotificationArgs notificationArgs; Database db = new Database(); List <App> apps = db.GetApps(); int counter = 0; int groupSize = Convert.ToInt32(Math.Ceiling(apps.Count() / 3.0)); var result = apps.GroupBy(s => counter++ / groupSize).Select(g => g.ToArray()).ToList();//directories.GroupBy(x => counter++ / groupSize); int threadCount = result.Count() + 1; Parallel.For(0, threadCount, i => { var dataSet = result.ElementAtOrDefault(i); if (dataSet != null) { Console.WriteLine("Processing dataset: " + i + "; Count: " + dataSet.Count()); foreach (var app in dataSet) { repoLocation = string.Format(@"{0}\{1}", downloadDirectory, app.Name); if (Directory.Exists(repoLocation)) { //TODO: Replace this with a Git pull and update the database continue; } try { notificationArgs = new NotificationArgs("Started - Clone " + app.Name, DateTime.Now, NotificationType.INFORMATION); OnMessageIssued(notificationArgs); CloneOptions options = new CloneOptions(); options.BranchName = "master"; options.Checkout = true; Repository.Clone(app.Source, repoLocation, options); lock (locker) { db.UpsertAppDonwload(app.Id, DateTime.Now); } notificationArgs = new NotificationArgs("Completed - Clone " + app.Name, DateTime.Now, NotificationType.SUCCESS); OnMessageIssued(notificationArgs); } catch (Exception error) { LogFailure(string.Format("Failed - Clone {0} ; {1}", app.Name, error.Message)); notificationArgs = new NotificationArgs("Failed - Clone " + app.Name, DateTime.Now, NotificationType.FAILURE); OnMessageIssued(notificationArgs); continue; } } } }); }
protected override void ItemPropertyChanged(NotificationArgs changeArgs) { m_totalWorkScheduled = -1; m_totalWorkCompleted = -1; m_totalWorkRemaining = -1; NotifyPropertyChanged(() => TotalWorkScheduled); NotifyPropertyChanged(() => TotalWorkCompleted); NotifyPropertyChanged(() => TotalWorkRemaining); }
protected override void ItemPropertyChanged(NotificationArgs changeArgs) { ItemProperty changedProperty = changeArgs.ChangedProperty; switch (changeArgs.ChangeSource) { case HierarchicalChangeSource.ParentItem: break; } }
private void service_OnNotificationEvent(object sender, NotificationArgs e) { Console.WriteLine("Get message form " + e.From); foreach (ApplicatoinService service in services) { if (sender != service) { service.OnNotification(e.From, e.Key, e.Content); } } }
public override void OnNotify(string notification, NotificationArgs args) { var orderPassedArgs = (Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.OrderIsPassedToCheckoutHandlerArgs)args; if (orderPassedArgs == null) { return; } //undone check if order makes payment before order completed (and check queue flag) }
private static void Process_NotificationIssued(object sender, NotificationArgs e) { lock (locker) { using (StreamWriter w = File.AppendText("log.txt")) { var text = string.Format("{0};{1};{2}", e.Type, e.Message, e.Timestamp); w.WriteLine(text); Console.WriteLine(text); } } }
public override void OnNotify(string notification, NotificationArgs args) { if (CantCheckPrice) { return; } var myArgs = (Dynamicweb.Ecommerce.Notifications.Ecommerce.Product.BeforeRenderArgs)args; // Set product info if (!string.IsNullOrEmpty(myArgs.Product?.Number)) { SetProductInformation(myArgs.Product); } }
void plugin_OnNotificationEvent(object sender, NotificationArgs e) { string newAddress = this.uri; if (this.uri.Contains('?')) { newAddress = string.Format(MultipleUriFormat, this.uri, e.Content.ToLower()); } else { newAddress = string.Format(AppUriFormat, this.uri, e.Key.ToLower(), e.Content.ToLower()); } wall.SetAddress(newAddress); this.RequestPresentation(); }
public void NotificationGenerator_Generates_Succesfully() { var generator = new NotificationGenerator(); var args = new NotificationArgs { BaseUrl = ConfigurationManager.AppSettings["WebUrl"], DisplayName = "Matt Schwartz", Recipient = "*****@*****.**", SessionId = "2434", SessionName = "Email Session Test" }; Assert.DoesNotThrow(() => generator.Generate(EventType.ReviewSessionReleased, args)); Assert.DoesNotThrow(() => generator.Generate(EventType.ReviewerAssigned, args)); Assert.DoesNotThrow(() => generator.Generate(EventType.QuestionnaireCompleted, args)); }
public override void OnNotify(string notification, NotificationArgs args) { if (CantCheckPrice) { return; } var myArgs = (Dynamicweb.Ecommerce.Notifications.Ecommerce.ProductList.BeforeSortArgs)args; var products = myArgs.Products.Where(p => !string.IsNullOrEmpty(p.Number)).ToList(); // Set product info if (products.Any()) { SetProductInformation(products); } }
/// <summary> /// Unsubscribes the specified handler by removing their handler from our collection. /// </summary> /// <typeparam name="T">The message Type you want to unsubscribe from</typeparam> /// <param name="subscription">The subscription to unsubscribe.</param> private void Unsubscribe(NotificationArgs args) { // If the key doesn't exist or has an empty collection we just return. // We will leave the key in there for future subscriptions to use. if (!listeners.ContainsKey(args.MessageType) || listeners[args.MessageType].Count == 0) { return; } // Remove the subscription from the collection associated with the key. List <ISubscription> subscribers = listeners[args.MessageType]; lock (subscribers) { subscribers.Remove(args.Subscription); } args.Subscription.Unsubscribing -= this.Unsubscribe; }
public void CloneRepository() { NotificationArgs notificationArgs = new NotificationArgs("Started - Clone F-Droid Repositroy", DateTime.Now, NotificationType.INFORMATION); OnMessageIssued(notificationArgs); CloneOptions options = new CloneOptions(); options.BranchName = "master"; options.Checkout = true; string repo = Repository.Clone(repositoryPath, downloadDirectory, options); notificationArgs = new NotificationArgs("Completed - Clone F-Droid Repositroy", DateTime.Now, NotificationType.SUCCESS); OnMessageIssued(notificationArgs); notificationArgs = new NotificationArgs("Started - Analyzing Metadata Files", DateTime.Now, NotificationType.INFORMATION); OnMessageIssued(notificationArgs); SourceFileParser sp = new SourceFileParser(downloadDirectory + @"\metadata"); List <App> apps = sp.ParseFiles(); notificationArgs = new NotificationArgs("Completed - Analyzing Metadata Files", DateTime.Now, NotificationType.SUCCESS); OnMessageIssued(notificationArgs); notificationArgs = new NotificationArgs("Started - Saving To Database", DateTime.Now, NotificationType.INFORMATION); OnMessageIssued(notificationArgs); Database db = new Database(); db.BatchInsertApps(apps); notificationArgs = new NotificationArgs("Completed - Saving To Database", DateTime.Now, NotificationType.SUCCESS); OnMessageIssued(notificationArgs); }
protected override void ItemPropertyChanged(NotificationArgs changeArgs) { switch (changeArgs.ChangeSource) { // Notification received if any child OffTimeItem changes case HierarchicalChangeSource.ChildItem: m_totalOffDays = null; m_currentTrainHoursRemaining = -1; NotifyPropertyChanged(() => TotalOffDays); NotifyPropertyChanged(() => CurrentTrainHoursRemaining); break; // Notification received if any owned WorkItem changes case HierarchicalChangeSource.OwnedItem: //if (changeArgs.ChangedProperty.PublicPropName == WorkItem.SubstatusPropName || // changeArgs.ChangedProperty.PublicPropName == WorkItem.EstimatePropName || // changeArgs.ChangedProperty.PublicPropName == WorkItem.CompletedPropName) //{ //} m_notStartedWorkItems = null; m_inProgressWorkItems = null; m_completedWorkItems = null; m_totalWorkRemaining = -1; m_totalWorkCompleted = -1; m_currentTrainWorkRemaining = -1; NotifyPropertyChanged(() => NotStartedWorkItems); NotifyPropertyChanged(() => InProgressWorkItems); NotifyPropertyChanged(() => CompletedWorkItems); NotifyPropertyChanged(() => TotalWorkRemaining); NotifyPropertyChanged(() => TotalWorkCompleted); NotifyPropertyChanged(() => CurrentTrainWorkRemaining); m_backlogItems = null; NotifyPropertyChanged(() => BacklogItems); break; } }
public void UpdateRepository() { NotificationArgs notificationArgs = new NotificationArgs("Started - Update F-Droid Repositroy", DateTime.Now, NotificationType.INFORMATION); OnMessageIssued(notificationArgs); using (var repo = new Repository(downloadDirectory)) { PullOptions options = new PullOptions(); options.FetchOptions = new FetchOptions(); options.FetchOptions.CredentialsProvider = new CredentialsHandler( (url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = "******", Password = "******" }); Commands.Pull(repo, new Signature("xxx", "xxx", new DateTimeOffset(DateTime.Now)), options); } notificationArgs = new NotificationArgs("Completed - Update F-Droid Repositroy", DateTime.Now, NotificationType.INFORMATION); OnMessageIssued(notificationArgs); }
public void PostNotification(NotificationName notificationName, NotificationArgs args) { PostNotification(null, notificationName, args, null); }
public void PostNotification(Component sender, NotificationName notificationName, NotificationArgs args) { PostNotification(new Notification(sender, notificationName, args)); }
public void PostNotification(Component sender, NotificationName notificationName, NotificationArgs args, Component reciever) { PostNotification(new Notification(sender, notificationName, args, reciever)); }
protected virtual void OnNotification(NotificationArgs e) { if(Notification != null) Notification(this, e); }
public void PostNotification(NotificationName name, NotificationArgs args = null) { PostNotification(new Notification(name, args)); }