Exemplo n.º 1
0
        public ActionResult SiteCollectionsBatch(SiteCollectionsBatchViewModel model, HttpPostedFileBase batchFile)
        {
            switch (model.Step)
            {
            case BatchStep.BatchStartup:
                ModelState.Clear();
                break;

            case BatchStep.BatchFileUploaded:
                if (!ModelState.IsValid)
                {
                    model.Step = BatchStep.BatchStartup;
                }
                else
                {
                    try
                    {
                        XmlSerializer xs = new XmlSerializer(typeof(batches));
                        model.Sites     = (batches)xs.Deserialize(batchFile.InputStream);
                        model.SitesJson = JsonConvert.SerializeObject(model.Sites);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Invalid batch file!", ex);
                    }
                }
                break;

            case BatchStep.BatchScheduled:
                if (!String.IsNullOrEmpty(model.SitesJson))
                {
                    // Create the asynchronous job
                    var job = new SiteCollectionsBatchJob
                    {
                        Owner      = ClaimsPrincipal.Current.Identity.Name,
                        Title      = "Site Collections Batch",
                        BatchSites = model.SitesJson,
                    };

                    // Enqueue the job for execution
                    model.JobId = ProvisioningRepositoryFactory.Current.EnqueueProvisioningJob(job);
                }
                break;

            default:
                break;
            }

            return(PartialView(model.Step.ToString(), model));
        }
Exemplo n.º 2
0
        public ActionResult SiteCollectionsBatch()
        {
            var model = new SiteCollectionsBatchViewModel();

            return(View(model));
        }