コード例 #1
0
        public async Task Dispatch(DashboardContext context)
        {
            if (!"POST".Equals(context.Request.Method, StringComparison.InvariantCultureIgnoreCase))
            {
                context.Response.StatusCode = 405;
                return;
            }

            try
            {
                var key = context.Request.GetQuery(StandbyKey.IdField);

                var standbyJob = Map.JobCollection[key];

                var cron     = (await context.Request.GetFormValuesAsync("recurring_cron")).LastOrDefault();
                var timeZone = Options.RecurringTimeZone ?? TimeZoneInfo.Local;

                var parameters = await StandbyHelper.CreateParameters(context, standbyJob.Method);

                context.GetRecurringJobManager().AddOrUpdate(standbyJob.RecurringJobId, new Job(standbyJob.Method, parameters), cron, timeZone);
                context.Response.StatusCode = 200;
            }
            catch (Exception e)
            {
                context.Response.StatusCode = 500;
                await context.Response.WriteAsync(e.Message);
            }
        }
コード例 #2
0
        public async Task Dispatch(DashboardContext context)
        {
            if (!"POST".Equals(context.Request.Method, StringComparison.InvariantCultureIgnoreCase))
            {
                context.Response.StatusCode = 405;
                return;
            }

            try
            {
                var infoKey = context.Request.GetQuery(StandbyKey.IdField);

                var standbyJob = Map.JobCollection[infoKey];

                var parameters = await StandbyHelper.CreateParameters(context, standbyJob.Method);

                var queuedState = new EnqueuedState();

                if (standbyJob.UseQueue)
                {
                    var queueString = (await context.Request.GetFormValuesAsync("equeued_state")).LastOrDefault();
                    queuedState.Queue = queueString;
                }

                var jobId = context.GetBackgroundJobClient().Create(new Job(standbyJob.Method, parameters), queuedState);

                context.Response.StatusCode = 200;
                await context.Response.WriteAsync(jobId);
            }
            catch (Exception e)
            {
                context.Response.StatusCode = 500;
                await context.Response.WriteAsync(e.Message);
            }
        }