Esempio n. 1
0
        public static async Task <IActionResult> RunListAssets([HttpTrigger(AuthorizationLevel.Function, "get", Route =
                                                                                "jobs/{orderdirection}/{orderid}/{lineid}/assets")]
                                                               HttpRequest req,
                                                               string orderdirection,
                                                               string orderid,
                                                               string lineid)
        {
            var userContext = await FunctionHelpers.AuthAsync(req, orderdirection, orderid, lineid);

            var job    = Container.Get <JobService>();
            var result = await job.ListAssetsAsync(userContext);

            return(new OkObjectResult(result.ConvertAll(x => new { Name = Path.GetFileName(x.Uri.ToString()) })));
        }
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "jobs/{orderdirection}/{orderid}/{lineid}/JobVars")] HttpRequest req,
            string orderdirection,
            string orderid,
            string lineid
            )
        {
            var UserContext = await FunctionHelpers.AuthAsync(req, orderdirection, orderid, lineid);

            var job = Container.Get <JobService>();
            var q   = Container.Get <QueueService>();
            await job.WriteJobFileAsync(UserContext, Consts.JobVarFolderName, Consts.JobVarFileName, req.Body);

            return(new OkObjectResult(new { status = "OK" }));
        }
        public static async Task <IActionResult> RunGetJobVar(
            [HttpTrigger(AuthorizationLevel.Function, "Get", Route = "jobs/{orderdirection}/{orderid}/{lineid}/JobVars")]
            HttpRequest req,
            string orderdirection,
            string orderid,
            string lineid
            )
        {
            var UserContext = await FunctionHelpers.AuthAsync(req, orderdirection, orderid, lineid);

            var file = await Container.Get <JobService>().GetJobFileAsync(UserContext, Consts.JobVarFolderName, Consts.JobVarFileName);

            var stream = await file.OpenReadAsync();

            return(new FileStreamResult(stream, file.Properties.ContentType));
        }
Esempio n. 4
0
        public static async Task <IActionResult> RunDeleteJobAsset(
            [HttpTrigger(AuthorizationLevel.Function, "delete", Route =
                             "jobs/{orderdirection}/{orderid}/{lineid}/assets/{id}")]
            HttpRequest req,
            string orderdirection,
            string orderid,
            string lineid,
            string id
            )
        {
            var userContext = await FunctionHelpers.AuthAsync(req, orderdirection, orderid, lineid);

            var job = Container.Get <JobService>();
            await job.DeleteJobFileAsync(userContext, Consts.AssetsFolderName, id);

            return(new OkObjectResult(new { status = "OK" }));
        }
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "jobs/{orderdirection}/{orderid}/{lineid}/render/{jobname}")] HttpRequest req,
            ILogger log, string orderdirection, string orderid, string lineid, string jobname)
        {
            var userContext = await FunctionHelpers.AuthAsync(req, orderdirection, orderid, lineid);

            var job = await Container.Get <JobService>().GetOrSetLineJobAsync(userContext, true);

            if (job.JobStatus == JobStatus.inprogress.ToString())
            {
                return(new OkObjectResult(new { status = "Job is already inprogress" }));
            }
            else
            {
                job.JobStatus = JobStatus.inprogress.ToString();
                var t2 = Container.Get <QueueService>().QueueMessageAsync(Consts.RenderJobQueueName, new JobQueueMessage {
                    JobName = jobname, UserContext = userContext, LineItemJob = job
                });
                var t1 = Container.Get <TableService>().InsertOrReplaceAsync(job);
                Task.WaitAll(t1, t2);
                return(new OkObjectResult(new { status = "OK" }));
                //somehow the browser needs to be notified when the render job is done, but it shouldn't block this call. it's either web sockets or browser polling. Right now, the render job drops a message on the queue named Consts.CompletedJobQueueName, but nothing is done with it.
            }
        }