Exemple #1
0
 public void Notification(string message)
 {
     //This code is tightly coupled.and can only be used for sending the Email and other type of Notification we need to chnage the code here
     //Email email = new Email();
     //email.SendMessage(message);
     _NotificaionHandler.SendMessage(message);
 }
Exemple #2
0
 public void ProcessOrder(ShopCartItem cart, ShoppingDetails shoppingDetails, int businessEntityID, string email)
 {
     using (var scope = new TransactionScope())
     {
         InsertAddress(shoppingDetails, businessEntityID);
         int workerID = MinSalesWorker(shoppingDetails.City);
         int orderID  = InsertPurchaseOrderHeader(cart, businessEntityID, shoppingDetails.Country);
         UpdateStatus(orderID, workerID);
         sender.SendMessage(email, "Manager assigned! Check your order page");
         scope.Complete();
     }
 }
        public void MessageQueueProcess()
        {
            MessageQueue mq            = new MessageQueue(".\\Private$\\shippingorder");
            var          msgEnumerator = mq.GetMessageEnumerator2();
            var          messages      = new List <Message>();

            while (msgEnumerator.MoveNext(new TimeSpan(0, 0, 1)))
            {
                var msg = mq.ReceiveById(msgEnumerator.Current.Id, new TimeSpan(0, 0, 1));
                messages.Add(msg);
            }
            foreach (var msg in messages)
            {
                msg.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });

                XDocument result = XDocument.Parse(msg.Body.ToString());

                var purchaseID = result.Root.Element("orderHeader").Element("purchaseId").Value;
                var email      = result.Root.Element("personData").Element("email").Value;

                orderProcessor.UpdateStatus(Convert.ToInt32(purchaseID), workerID: 0, status: 4);
                sender.SendMessage(email, "Delivered to you, visit us again!");
            }
        }
Exemple #4
0
        void Host_UserAccountActivity(object sender, UserAccountActivityEventArgs e)
        {
            if (e.Activity != UserAccountActivity.AccountActivated)
            {
                return;
            }

            _synchronizer.Lock(() =>
            {
                var failed = false;
                User user  = null;
                try
                {
                    user = _registrationRepository.FindByUserName(e.User.Username);
                    if (user == null)
                    {
                        return;
                    }

                    var pageInfo = _pageRepository.FindPage(_configuration.PageName);
                    if (pageInfo == null)
                    {
                        _logger.Error(String.Format("The attendee page '{0}' does not exist.", _configuration.PageName), "SYSTEM");
                        throw new Exception("Attendee page does not exist.");
                    }

                    PageContent pageContent;
                    try
                    {
                        pageContent = _host.GetPageContent(pageInfo);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(String.Format("The attendee page's content ('{0}') could not be loaded: {1}", _configuration.PageName, ex),
                                      "SYSTEM");
                        throw;
                    }

                    try
                    {
                        string entry      = _entryFormatter.FormatUserEntry(user, _settings, _configuration.EntryTemplate);
                        string newContent = _pageFormatter.AddEntry(pageContent.Content, entry, user, _configuration);

                        _pageRepository.Save(pageInfo, pageContent.Title, user.UserName, _configuration.Comment, newContent);

                        _logger.Info("User entry written successfully", user.UserName);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(String.Format("Could not add the user's entry to the attendee list: {0}", ex), "SYSTEM");
                        throw;
                    }
                }
                catch
                {
                    failed = true;
                }
                finally
                {
                    if (user != null)
                    {
                        string message = LoadEmailTemplate(failed);
                        message        = FillTemplate(message, user);

                        _notificationSender.SendMessage(e.User.Email, _configuration.Comment, message);
                        _notificationSender.SendMessage(_settings.ContactEmail, _configuration.Comment, message);
                    }
                }
            });
        }