コード例 #1
0
        public override SiteProvisionerStepResponse Execute()
        {
            var response    = new SiteProvisionerStepResponse();
            var fileService = new FileService();
            var logFileName = GetErrorLogFileName();

            try
            {
                var siteService = new SiteService {
                    AssetDirectory = Properties.AssetDirectory
                };

                var siteTitle = GetProperty("Title");
                var siteUrl   = GetProperty("URL");

                if (string.IsNullOrEmpty(siteTitle) ||
                    string.IsNullOrEmpty(siteUrl))
                {
                    throw new Exception("The Title and URL values are required.");
                }

                var siteInfo = siteService.CreateSubsite(siteTitle, siteUrl);
                var siteId   = siteInfo.Id;

                SetSiteId(siteId);
                SetProperty("SiteUrl", siteInfo.Url);

                response.Success = true;
            }
            catch (Exception ex)
            {
                fileService.SaveSiteProvisionerErrorLogs(logFileName, ex.StackTrace, null, StepName, StepType.ToString(), Properties.AssetDirectory);
                response.Message = ex.Message;
                response.Success = false;
            }

            return(response);
        }