Exemple #1
0
        public void UpdateDist(BooksModels book)
        {
            BusStuff.InitServerEndpoint("ServerUI").GetAwaiter().GetResult();
            Operation operation = new Operation(book, "Update");

            BusStuff.Send("ServerUI", operation);
        }
Exemple #2
0
 public static Task OnMessage(MessageContext context, IDispatchMessages dispatcher)
 {
     try {
         var fromAddress = new MailAddress("*****@*****.**", "Subscriber2");
         var toAddress   = new MailAddress("*****@*****.**", "To Admin");
         var message     = BusStuff.Deserialize(context.Body);
         subject = message.OperationType;
         body    = message.ToString();
         var smtp = new SmtpClient
         {
             Host                  = "smtp.gmail.com",
             Port                  = 587,
             EnableSsl             = true,
             DeliveryMethod        = SmtpDeliveryMethod.Network,
             UseDefaultCredentials = false,
             Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
         };
         using (var msg = new MailMessage(fromAddress, toAddress)
         {
             Subject = subject,
             Body = body
         })
         {
             smtp.Send(msg);
             BusStuff.LogCall("Emailed: " + msg.Body);
         }
         return(Task.CompletedTask);
     }
     catch (Exception e)
     {
         BusStuff.LogCall(e.Message + Environment.NewLine + "Failed for " + subject + " : " + body);
         return(Task.CompletedTask);
     }
 }
Exemple #3
0
 static void Main(string[] args)
 {
     BusStuff.InitServerEndpoint(endpointName).GetAwaiter().GetResult();
     //BusUsage.Send(endpointName);
     Console.WriteLine("Press Enter to exit...");
     Console.ReadLine();
     //AsyncMain().GetAwaiter().GetResult();
     // BusUsage.Stop().GetAwaiter().GetResult();
 }
Exemple #4
0
        public static Task OnMessage(MessageContext context, IDispatchMessages dispatcher)
        {
            try
            {
                var b       = context.Body;
                var message = BusStuff.Deserialize(context.Body);
                operation = message.OperationType;
                body      = message.ToString();
                switch (message.OperationType)
                {
                case "Create":
                {
                    using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Suppress))
                    {
                        unit.Books.Create(message.body);
                        unit.Save();
                        messagesQueue.Add(message);
                    }
                    break;
                }

                case "Delete":
                {
                    using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Suppress))
                    {
                        unit.Books.Delete(message.body.Id);
                        unit.Save();
                        messagesQueue.Add(message);
                    }
                    break;
                }

                case "Update":
                {
                    using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Suppress))
                    {
                        unit.Books.Update(message.body);
                        unit.Save();
                        messagesQueue.Add(message);
                    }
                    break;
                }
                }

                return(Task.CompletedTask);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
                BusStuff.LogCall("Operation " + operation + " for " + body + " failed");
                return(Task.CompletedTask);
            }
        }
Exemple #5
0
        public void DeleteDist(int?id)
        {
            BooksModels book = db.Books.Find(id);

            if (book != null)
            {
                BusStuff.InitServerEndpoint("ServerUI").GetAwaiter().GetResult();
                Operation operation = new Operation(book, "Delete");
                BusStuff.Send("ServerUI", operation);
                //BusStuff.SendDelete("ServerUI", operation);
            }
        }
Exemple #6
0
        public void UpdateDist(BooksModels book)
        {
            BusStuff.InitServerEndpoint("ServerUI").GetAwaiter().GetResult();
            Operation operation = new Operation(book, "Update");

            BusStuff.Send("ServerUI", operation);
            TrackEvent("BRIUpdate item", new Dictionary <string, string>
            {
                { "Operation", "Title" },
                { "Update", book.title }
            });
        }
Exemple #7
0
        public void DeleteDist(int?id)
        {
            BooksModels book = db.Books.Find(id);

            if (book != null)
            {
                BusStuff.InitServerEndpoint("ServerUI").GetAwaiter().GetResult();
                Operation operation = new Operation(book, "Delete");
                BusStuff.Send("ServerUI", operation);
                TrackEvent("BRIDelete item", new Dictionary <string, string>
                {
                    { "Operation", "Title" },
                    { "Delete", book.title }
                });
                //BusStuff.SendDelete("ServerUI", operation);
            }
        }
Exemple #8
0
 private async void Form1_Load(object sender, EventArgs e)
 {
     await BusStuff.InitSubOneEndpoint("Subscriber1", OnMessage);
 }
Exemple #9
0
 //
 public static async void Init()
 {
     await BusStuff.InitSubTwoEndpoint("Subscriber2", OnMessage);
 }