/*CONSTRUCTOR*/ #region Default constructor public HomeController(ThemeConverter tConverter, ThemeDictionary dictionary, IWebHostEnvironment environment, UserColorDataModel dataModel, IConfiguration config, ColorStringConverter cConverter, HelperModel hModel) { this.environment = environment; this.tConverter = tConverter; this.dictionary = dictionary; this.dataModel = dataModel; this.config = config; this.cConverter = cConverter; this.hModel = hModel; }
protected void Install_Click(object sender, EventArgs e) { bool success = false; try { switch (_catalogType) { case CatalogType.Plugins: case CatalogType.Widgets: string fileName = Item.FileName; if (fileName.EndsWith(".zip")) { fileName = fileName.Replace(".zip", ".dll"); } if (!fileName.EndsWith(".dll")) { fileName = fileName + ".dll"; } new WebClient().DownloadFile(Item.DownloadUrl, Path.Combine(Server.MapPath("~/bin"), fileName)); break; case CatalogType.Themes: string themeFilename = Path.Combine(Server.MapPath("~/files/themes"), Item.FileName); new WebClient().DownloadFile(Item.DownloadUrl, themeFilename); UTF8Encoding utf = new UTF8Encoding(); string encodedFile = utf.GetString(File.ReadAllBytes(themeFilename)); ThemeConverter.ToDisk(encodedFile, Server.MapPath("~/files/themes/"), true, Item.Name); File.Delete(themeFilename); break; } success = true; } catch { } if (success) { InstallButton.Enabled = false; CancelButton.Enabled = false; Message.Type = StatusType.Success; Message.Text = string.Format("This {0} has been successfully installed.", _itemTypeName); } else { InstallButton.Text = "Try Again"; Message.Type = StatusType.Error; Message.Text = string.Format("An error has occurred during the downloading of this {0}.", _itemTypeName); } }