public void UpdateDist(BooksModels book) { BusStuff.InitServerEndpoint("ServerUI").GetAwaiter().GetResult(); Operation operation = new Operation(book, "Update"); BusStuff.Send("ServerUI", operation); }
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); } }
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(); }
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); } }
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); } }
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 } }); }
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); } }
private async void Form1_Load(object sender, EventArgs e) { await BusStuff.InitSubOneEndpoint("Subscriber1", OnMessage); }
// public static async void Init() { await BusStuff.InitSubTwoEndpoint("Subscriber2", OnMessage); }