public Install ( string tenant ) : Frapid.WebsiteBuilder.Models.Themes.ThemeInfo | ||
tenant | string | |
return | Frapid.WebsiteBuilder.Models.Themes.ThemeInfo |
public ThemeInfo Install(string tenant)
{
try
{
if (this.PostedFile == null)
{
this.Download();
}
else
{
this.Upload();
}
this.ExtractTheme();
bool isValid = this.Validate();
if (!isValid)
{
throw new ThemeInstallException("The uploaded archive is not a valid frapid theme!");
}
this.CopyTheme(tenant);
return this.ThemeInfo;
}
finally
{
if (Directory.Exists(this.ArchivePath.Replace(".zip", "")))
{
Directory.Delete(this.ArchivePath.Replace(".zip", ""), true);
}
if (File.Exists(this.ArchivePath))
{
File.Delete(this.ArchivePath);
}
}
}
}
private ActionResult Upload(ThemeUploader uploader) { try { uploader.Install(); } catch (ThemeUploadException ex) { return this.AjaxFail(ex.Message, HttpStatusCode.BadRequest); } catch (ThemeInstallException ex) { return this.AjaxFail(ex.Message, HttpStatusCode.BadRequest); } return Json(new {success = true}, JsonRequestBehavior.AllowGet); }