public static void onNewMessage(byte[] body, string listenerName)
        {
            var               core     = COREobject.i;
            DBEntities        context  = core.Context;
            TCPSocketListener listener = context.TCPListeners.Where(l => l.Name == listenerName).FirstOrDefault();

            if (listener != null)
            {
                Block block = GetBlockWithWF(context, listener.ApplicationId, listener.BlockName.RemoveDiacritics());

                if (block != null)
                {
                    core.Application = listener.Application;

                    try {
                        PersonaAppRole role = context.AppRoles.FirstOrDefault(r => r.Name == "System" && r.ApplicationId == listener.ApplicationId);
                        core.User = context.Users.FirstOrDefault(u => u.Users_Roles.Any(r => r.RoleName == role.Name && r.ApplicationId == role.ApplicationId));
                    }
                    catch (Exception e) {
                        OmniusInfo.Log($"Chyba při zpracování socketu: {listenerName} ({e})", OmniusLogSource.Nexus, null, null);
                    }

                    OmniusInfo.Log($"Začátek zpracování socketu: {listener.Name} / Blok {listener.BlockName} / Button {listener.WorkflowName}", OmniusLogSource.Nexus, listener.Application, core.User);

                    FormCollection fc = new FormCollection();
                    Dictionary <string, object> vars = new Dictionary <string, object>();
                    vars.Add("__SocketRequestBody__", body);

                    var runResult = new Modules.Tapestry.Tapestry(core).run(block, listener.WorkflowName, -1, fc, 0, null, vars);

                    OmniusInfo.Log($"Konec zpraconání mailu: {listener.Name} / Blok {listener.BlockName} / Button {listener.WorkflowName}", OmniusLogSource.Hermes, listener.Application, core.User);
                }
            }
        }
Exemplo n.º 2
0
        public ActionResult Save(TCPSocketListener model, int?id)
        {
            DBEntities e = COREobject.i.Context;

            if (ModelState.IsValid)
            {
                // Záznam ji. existuje - pouze upravujeme
                if (!model.Id.Equals(null))
                {
                    TCPSocketListener row = e.TCPListeners.Single(m => m.Id == model.Id);
                    row.ApplicationId = model.ApplicationId;
                    row.BlockName     = model.BlockName;
                    row.WorkflowName  = model.WorkflowName;
                    row.Name          = model.Name;
                    row.Port          = model.Port;
                    row.BufferSize    = model.BufferSize;

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

                TCPSocketListenerService.AddListener(model);

                return(RedirectToRoute("Nexus", new { @action = "Index" }));
            }
            else
            {
                return(View("~/Views/Nexus/TCPSocket/Form.cshtml", model));
            }
        }
Exemplo n.º 3
0
        public ActionResult Delete(int?id)
        {
            DBEntities        e   = COREobject.i.Context;
            TCPSocketListener row = e.TCPListeners.Single(l => l.Id == id);

            if (row == null)
            {
                throw new Exception("Došlo k neoèekávané chybì");
            }

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

            return(RedirectToRoute("Nexus", new { @action = "Index" }));
        }
        public static void AddListener(TCPSocketListener model)
        {
            if (listeners.ContainsKey(model.Name))
            {
                listeners[model.Name].Dispose();
                listeners.Remove(model.Name);
            }

            ReactiveListener server = new ReactiveListener(model.Port);

            server.Connections.Subscribe(socket => new Observer(socket, model.Name, model.BufferSize));

            server.Start();

            listeners.Add(model.Name, server);
        }
Exemplo n.º 5
0
        public ActionResult Edit(int?id)
        {
            DBEntities        e     = COREobject.i.Context;
            TCPSocketListener model = e.TCPListeners.Single(l => l.Id == id);

            List <SelectListItem> appList = new List <SelectListItem>();

            foreach (Application a in e.Applications.OrderBy(a => a.Name))
            {
                appList.Add(new SelectListItem()
                {
                    Value = a.Id.ToString(), Text = a.Name, Selected = model.ApplicationId == a.Id
                });
            }

            ViewData["ApplicationList"] = appList;

            return(View("~/Views/Nexus/TCPSocket/Form.cshtml", model));
        }