Пример #1
0
        public object AddSubscription(dynamic args)
        {
            string pluginAlias = args.pluginAlias;
            string eventAlias = args.eventAlias;
            Guid scriptId = args.scriptId;

            using (var session = Context.OpenSession())
            {
                var guid = Guid.NewGuid();

                var script = session.Load<UserScript>(scriptId);

                var subscription = new ScriptEventHandler
                {
                    Id = guid,
                    PluginAlias = pluginAlias,
                    EventAlias = eventAlias,
                    UserScript = script
                };

                session.Save(subscription);
                session.Flush();

                return guid;
            }
        }
Пример #2
0
        public object AddSubscription(HttpRequestParams request)
        {
            string eventAlias = request.GetRequiredString("eventAlias");
            Guid scriptId = request.GetRequiredGuid("scriptId");

            using (var session = Context.OpenSession())
            {
                var guid = Guid.NewGuid();

                var script = session.Load<UserScript>(scriptId);

                var subscription = new ScriptEventHandler
                {
                    Id = guid,
                    EventAlias = eventAlias,
                    UserScript = script
                };

                session.Save(subscription);
                session.Flush();

                return guid;
            }
        }