public JsonResult AddDo()
        {
            var name  = GetParam <string>("inputName");
            var value = GetParam <string>("inputExpCron");

            Request.Validation(
                new ValidationEntity {
                Key = name, Des = "触发器名称不得为空", Type = ValidationType.Required
            },
                new ValidationEntity {
                Key = value, Des = "触发器规则不得为空", Type = ValidationType.Required
            }
                );
            if (SchedulerServer.FireTimeList(value, 1).Count <= 0)
            {
                return(Tools.ReJson("触发器规则不正确"));
            }
            using (var db = new BaseModel())
            {
                db.Trigger.Add(new TriggerModel
                {
                    Name        = name,
                    UserId      = Auth.Info.Id,
                    Value       = value,
                    CreatedTime = DateTime.Now.ToLocalTime(),
                    UpdatedTime = DateTime.Now.ToLocalTime()
                });
                if (db.SaveChanges() <= 0)
                {
                    return(Tools.ReJson("添加触发器失败"));
                }
            }
            return(Tools.ReJson());
        }
Example #2
0
        public static void WebStart(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime lifetime)
        {
            SignumServer.Start(app, env, typeof(Startup).Assembly);

            AuthServer.Start(app, () => Starter.Configuration.Value.AuthTokens, "IMPORTANT SECRET FROM AtTest. CHANGE THIS STRING!!!");
            CacheServer.Start(app);
            FilesServer.Start(app);
            UserQueryServer.Start(app);
            DashboardServer.Start(app);
            WordServer.Start(app);
            ExcelServer.Start(app);
            ChartServer.Start(app);
            MapServer.Start(app);
            ToolbarServer.Start(app);
            TranslationServer.Start(app, new AlreadyTranslatedTranslator(new AzureTranslator("Your API Key for Azure Translate")));
            SchedulerServer.Start(app, lifetime);
            ProcessServer.Start(app);
            MailingServer.Start(app);
            ProfilerServer.Start(app);
            DiffLogServer.Start(app);
            PredictorServer.Start(app);
            OmniboxServer.Start(app,
                                new EntityOmniboxResultGenenerator(),
                                new DynamicQueryOmniboxResultGenerator(),
                                new ChartOmniboxResultGenerator(),
                                new DashboardOmniboxResultGenerator(DashboardLogic.Autocomplete),
                                new UserQueryOmniboxResultGenerator(UserQueryLogic.Autocomplete),
                                new UserChartOmniboxResultGenerator(UserChartLogic.Autocomplete),
                                new MapOmniboxResultGenerator(type => OperationLogic.TypeOperations(type).Any()),
                                new ReactSpecialOmniboxGenerator()
                                   //new HelpModuleOmniboxResultGenerator(),
                                ); //Omnibox

            SignumCultureSelectorFilter.GetCurrentCulture = (ctx) => GetCulture(ctx);
        }
Example #3
0
        public static void WebStart(HttpConfiguration config)
        {
            SignumServer.Start(config, typeof(Global).Assembly);
            AuthServer.Start(config, () => Starter.Configuration.Value.AuthTokens, "IMPORTANT SECRET FROM Southwind. CHANGE THIS STRING!!!");
            CacheServer.Start(config);
            FilesServer.Start(config);
            UserQueryServer.Start(config);
            DashboardServer.Start(config);
            WordServer.Start(config);
            ExcelServer.Start(config);
            ChartServer.Start(config);
            MapServer.Start(config);
            TranslationServer.Start(config, new AlreadyTranslatedTranslator(new BingTranslator()));
            SchedulerServer.Start(config);
            ProcessServer.Start(config);
            DisconnectedServer.Start(config);
            MailingServer.Start(config);
            ProfilerServer.Start(config);
            DiffLogServer.Start(config);

            OmniboxServer.Start(config,
                                new EntityOmniboxResultGenenerator(),
                                new DynamicQueryOmniboxResultGenerator(),
                                new ChartOmniboxResultGenerator(),
                                new DashboardOmniboxResultGenerator(DashboardLogic.Autocomplete),
                                new UserQueryOmniboxResultGenerator(UserQueryLogic.Autocomplete),
                                new UserChartOmniboxResultGenerator(UserChartLogic.Autocomplete),
                                new MapOmniboxResultGenerator(type => OperationLogic.TypeOperations(type).Any()),
                                new ReactSpecialOmniboxGenerator()
                                   //new HelpModuleOmniboxResultGenerator(),
                                ); //Omnibox
        }
Example #4
0
        private void PipeThreadProc()
        {
            while (true)
            {
                using (SchedulerServer server = new SchedulerServer())
                {
                    try
                    {
                        var elems = server.ParseElement();
                        File.Elements.AddRange(elems);
                        Parameters.Logger?.I(LoggerTag, $"Added new {elems.Count} element(s)");
                        foreach (var e in elems)
                        {
                            Parameters.Logger?.I(LoggerTag, $" - Name: {e.Metadata.Name}. Action Type: {e.Data.ActionType}. Command Type: {e.Data.CommandType}.");
                        }

                        throw new ArgumentNullException("askdjalsjdlaksjdlaksjd");

                        Parameters.DataChangedAction?.Invoke();
                        File.SaveToFile(Parameters.FileName);

                        Parameters.Logger?.I(LoggerTag, "Data have been saved to file");
                    }
                    catch (Exception e)
                    {
                        Parameters.OnErrorAction?.Invoke(e, "Unable to parse or get value");
                    }
                }
            }
        }
        public JsonResult TestRule()
        {
            var rule  = GetParam <string>("rule");
            var count = GetParam <int>("count", 1);
            var list  = SchedulerServer.FireTimeList(rule, count);

            return(list.Count <= 0 ? Tools.ReJson("触发器规则不正确") : Tools.ReJson(list));
        }
        public JsonResult EditDo()
        {
            var id    = GetParam <int>("inputId");
            var name  = GetParam <string>("inputName");
            var value = GetParam <string>("inputExpCron");

            Request.Validation(
                new ValidationEntity {
                Key = id, Des = "ID不可小于零", Type = ValidationType.IdInt
            },
                new ValidationEntity {
                Key = name, Des = "触发器名称不得为空", Type = ValidationType.Required
            },
                new ValidationEntity {
                Key = value, Des = "触发器规则不得为空", Type = ValidationType.Required
            }
                );
            if (SchedulerServer.FireTimeList(value, 1).Count <= 0)
            {
                return(Tools.ReJson("触发器规则不正确"));
            }

            using (var db = new BaseModel())
            {
                var result = Auth.IsAdmin
                    ? db.Trigger.FirstOrDefault(rs => rs.Id == id)
                    : db.Trigger.FirstOrDefault(rs => rs.Id == id && rs.UserId == Auth.Info.Id);
                if (result == null)
                {
                    return(Tools.ReJson("获取触发器信息失败"));
                }

                result.Name  = name;
                result.Value = value;
                db.Trigger.Update(result);
                if (db.SaveChanges() <= 0)
                {
                    return(Tools.ReJson("更新触发器信息失败"));
                }
            }

            return(Tools.ReJson());
        }
Example #7
0
        public ScheduleRunner(string scheduleConfigPath)
        {
            this.log = LogManager.GetLogger("Application");

            try
            {
                this.log.InfoFormat("Loading scheduler configuration file '{0}'...", scheduleConfigPath);
                this.schedulerServer = new SchedulerServer();
                this.schedulerServer.LoadFromXmlFile(scheduleConfigPath);
                this.log.Info("Scheduler configuration loaded");
            }
            catch (Exception ex)
            {
                this.log.ErrorFormat("Scheduler configuration failed to loaded: {0}", ex.ToString());

                if (ExceptionHelper.IsFatalException(ex))
                {
                    throw;
                }
            }
        }
Example #8
0
        static void Main()
        {
            Console.Title = "Zen Scheduler Server Host";
            Console.WriteLine("");

            log.Debug("Initializing Host...");
            var host = HostFactory.New(x =>
            {
                x.Service<SchedulerServer>(s =>
                {
                    s.ConstructUsing(builder =>
                    {
                        var server = new SchedulerServer();
                        server.Initialize();
                        return server;
                    });
                    s.WhenStarted(server =>
                        { log.Debug("Starting SchedulerServer..."); server.Start();     });
                    s.WhenStopped(server =>
                        { log.Debug("Stopping SchedulerServer..."); server.Shutdown();  });
                    s.WhenPaused(server =>
                        { log.Debug("Pausing SchedulerServer...");  server.Pause();     });
                    s.WhenContinued(server =>
                        { log.Debug("Resuming SchedulerServer..."); server.Resume();    });
                });

                x.RunAsLocalSystem();
                x.SetServiceName("ZenSchedulerServerHost");
                x.SetDisplayName("Zen Scheduler Server Host");
                x.SetDescription("The server acts as host for 1 Quartz Scheduler instance.");
            });

            log.InfoFormat("Hosting a {0}.", typeof(SchedulerServer));
            host.Run();

            log.Warn("The Host has exited.");
            System.Threading.Thread.Sleep(3000);
        }
Example #9
0
 public IndexController(SchedulerServer schedulerServer, IConfiguration configuration)
 {
     _schedulerServer = schedulerServer;
 }
 public TaskController(SchedulerServer schedulerServer, IConfiguration configuration)
 {
     _schedulerServer = schedulerServer;
     Configuration    = configuration;
 }