public ActionResult Save(RabbitMQ model, int?id) { DBEntities e = COREobject.i.Context; if (ModelState.IsValid) { // Záznam ji. existuje - pouze upravujeme if (!model.Id.Equals(null)) { RabbitMQ row = e.RabbitMQs.Single(m => m.Id == model.Id); e.Entry(row).CurrentValues.SetValues(model); } else { e.RabbitMQs.Add(model); e.SaveChanges(); } e.SaveChanges(); if (model.Type == ChannelType.RECEIVE) { RabbitMQListenerService.AddListener(model); } return(RedirectToRoute("Nexus", new { @action = "Index" })); } else { return(View("~/Views/Nexus/RabbitMQ/Form.cshtml", model)); } }
public static void AppInitialize() { //// we create a new instance of our own VirtualPathProvider. //MyVirtualPathProvider providerInstance = new MyVirtualPathProvider(); //// any settings about your VirtualPathProvider may go here. // //// we get the current instance of HostingEnvironment class. We can't create a new one //// because it is not allowed to do so. An AppDomain can only have one HostingEnvironment //// instance. //HostingEnvironment hostingEnvironmentInstance = (HostingEnvironment)typeof(HostingEnvironment).InvokeMember("_theHostingEnvironment", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null); //if (hostingEnvironmentInstance == null) // return; // //// we get the MethodInfo for RegisterVirtualPathProviderInternal method which is internal //// and also static. //MethodInfo mi = typeof(HostingEnvironment).GetMethod("RegisterVirtualPathProviderInternal", BindingFlags.NonPublic | BindingFlags.Static); //if (mi == null) // return; // //// finally we invoke RegisterVirtualPathProviderInternal method with one argument which //// is the instance of our own VirtualPathProvider. //mi.Invoke(hostingEnvironmentInstance, new object[] { (VirtualPathProvider)providerInstance }); // Start Incoming e-mail listeners if any IncomingEmailListener.Refresh(); // Start TCP socket listeners if any TCPSocketListenerService.Refresh(); // Start RabbitMQ listeners if any RabbitMQListenerService.Refresh(); }