Beispiel #1
0
        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();
        }
        public ActionResult Save(IncomingEmail model)
        {
            DBEntities e = COREobject.i.Context;

            if (ModelState.IsValid)
            {
                // Záznam ji. existuje - pouze upravujeme
                if (!model.Id.Equals(null))
                {
                    IncomingEmail row = e.IncomingEmail.Single(m => m.Id == model.Id);
                    row.Name       = model.Name;
                    row.ImapServer = model.ImapServer;
                    row.ImapPort   = model.ImapPort;
                    row.UserName   = model.UserName;
                    row.Password   = model.Password;

                    e.SaveChanges();
                }
                else
                {
                    e.IncomingEmail.Add(model);
                    e.SaveChanges();
                }

                IncomingEmailListener.AddListener(model);

                return(RedirectToRoute("Hermes", new { @action = "Index" }));
            }
            else
            {
                return(View("~/Views/Hermes/Incoming/Form.cshtml", model));
            }
        }
        public ActionResult Delete(int id)
        {
            DBEntities    e   = COREobject.i.Context;
            IncomingEmail row = e.IncomingEmail.Single(m => m.Id == id);

            IncomingEmailListener.RemoveListener(row.Name);

            e.IncomingEmail.Remove(row);
            e.SaveChanges();

            return(RedirectToRoute("Hermes", new { @action = "Index" }));
        }