protected void btnSave_Click(object sender, EventArgs e) { bool enabled; IProviderV30 prov = GetCurrentProvider(out enabled); Log.LogEntry("Configuration change requested for Provider " + prov.Information.Name, EntryType.General, SessionFacade.CurrentUsername); string error; if (ProviderLoader.TryChangeConfiguration(prov.GetType().Name, txtConfigurationString.Text, out error)) { lblResult.CssClass = "resultok"; lblResult.Text = Properties.Messages.ProviderConfigurationSaved; ResetEditor(); rptProviders.DataBind(); } else { lblResult.CssClass = "resulterror"; lblResult.Text = Properties.Messages.ProviderRejectedConfiguration + (string.IsNullOrEmpty(error) ? "" : (": " + error)); } }
/// <summary> /// Try to setup a provider. /// </summary> /// <typeparam name="T">The type of the provider, which must implement <b>IProvider</b>.</typeparam> /// <param name="provider">The provider to setup.</param> /// <param name="configuration">The configuration string.</param> public static void SetUp <T>(Type provider, string configuration) where T : class, IProviderV40 { try { T providerInstance = ProviderLoader.CreateInstance <T>(Assembly.GetAssembly(provider), provider); providerInstance.SetUp(Host.Instance, configuration); // Verify constraints VerifyConstraints <T>(providerInstance); Log.LogEntry("Provider " + provider.FullName + " loaded.", EntryType.General, Log.SystemUsername, null); // Dispose the provider providerInstance.Dispose(); } catch (InvalidConfigurationException) { Log.LogEntry("Unable to load provider " + provider.FullName + " (configuration rejected).", EntryType.Error, Log.SystemUsername, null); // Throw InvalidConfigurationException in order to disable plugin throw; } catch { Log.LogEntry("Unable to load provider " + provider.FullName + " (unknown error).", EntryType.Error, Log.SystemUsername, null); throw; // Exception is rethrown because it's not a normal condition } }
/// <summary> /// Performs all needed startup operations. /// </summary> public static void Startup() { // Load Host Host.Instance = new Host(); // Load config ISettingsStorageProviderV30 ssp = ProviderLoader.LoadSettingsStorageProvider(WebConfigurationManager.AppSettings["SettingsStorageProvider"]); ssp.Init(Host.Instance, GetSettingsStorageProviderConfiguration()); Collectors.SettingsProvider = ssp; Settings.CanOverridePublicDirectory = false; if (!(ssp is SettingsStorageProvider)) { // Update DLLs from public\Plugins UpdateDllsIntoSettingsProvider(ssp, ProviderLoader.SettingsStorageProviderAssemblyName); } if (ssp.IsFirstApplicationStart()) { if (ssp.GetMetaDataItem(MetaDataItem.AccountActivationMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.AccountActivationMessage, null, Defaults.AccountActivationMessageContent); } if (ssp.GetMetaDataItem(MetaDataItem.EditNotice, null) == "") { ssp.SetMetaDataItem(MetaDataItem.EditNotice, null, Defaults.EditNoticeContent); } if (ssp.GetMetaDataItem(MetaDataItem.Footer, null) == "") { ssp.SetMetaDataItem(MetaDataItem.Footer, null, Defaults.FooterContent); } if (ssp.GetMetaDataItem(MetaDataItem.Header, null) == "") { ssp.SetMetaDataItem(MetaDataItem.Header, null, Defaults.HeaderContent); } if (ssp.GetMetaDataItem(MetaDataItem.PasswordResetProcedureMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.PasswordResetProcedureMessage, null, Defaults.PasswordResetProcedureMessageContent); } if (ssp.GetMetaDataItem(MetaDataItem.Sidebar, null) == "") { ssp.SetMetaDataItem(MetaDataItem.Sidebar, null, Defaults.SidebarContent); } if (ssp.GetMetaDataItem(MetaDataItem.PageChangeMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.PageChangeMessage, null, Defaults.PageChangeMessage); } if (ssp.GetMetaDataItem(MetaDataItem.DiscussionChangeMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.DiscussionChangeMessage, null, Defaults.DiscussionChangeMessage); } if (ssp.GetMetaDataItem(MetaDataItem.ApproveDraftMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.ApproveDraftMessage, null, Defaults.ApproveDraftMessage); } } MimeTypes.Init(); // Load Providers Collectors.FileNames = new System.Collections.Generic.Dictionary <string, string>(10); Collectors.UsersProviderCollector = new ProviderCollector <IUsersStorageProviderV30>(); Collectors.PagesProviderCollector = new ProviderCollector <IPagesStorageProviderV30>(); Collectors.FilesProviderCollector = new ProviderCollector <IFilesStorageProviderV30>(); Collectors.FormatterProviderCollector = new ProviderCollector <IFormatterProviderV30>(); Collectors.CacheProviderCollector = new ProviderCollector <ICacheProviderV30>(); Collectors.DisabledUsersProviderCollector = new ProviderCollector <IUsersStorageProviderV30>(); Collectors.DisabledPagesProviderCollector = new ProviderCollector <IPagesStorageProviderV30>(); Collectors.DisabledFilesProviderCollector = new ProviderCollector <IFilesStorageProviderV30>(); Collectors.DisabledFormatterProviderCollector = new ProviderCollector <IFormatterProviderV30>(); Collectors.DisabledCacheProviderCollector = new ProviderCollector <ICacheProviderV30>(); // Load built-in providers var providers = new IProviderV30[] { new FilesStorageProvider(), new UsersStorageProvider(), new Footnotes() }; foreach (var provider in providers) { var isDisabled = ProviderLoader.IsDisabled(provider.GetType().FullName); if (!isDisabled) { provider.Init(Host.Instance, ""); Log.LogEntry("Provider " + provider.Information.Name + " loaded (Enabled)", EntryType.General, Log.SystemUsername); } else { Log.LogEntry("Provider " + provider.Information.Name + " loaded (Disabled)", EntryType.General, Log.SystemUsername); } if (provider is IUsersStorageProviderV30) { (isDisabled ? Collectors.DisabledUsersProviderCollector : Collectors.UsersProviderCollector).AddProvider(provider as IUsersStorageProviderV30); } else if (provider is IPagesStorageProviderV30) { (isDisabled ? Collectors.DisabledPagesProviderCollector : Collectors.PagesProviderCollector).AddProvider(provider as IPagesStorageProviderV30); } else if (provider is IFilesStorageProviderV30) { (isDisabled ? Collectors.DisabledFilesProviderCollector : Collectors.FilesProviderCollector).AddProvider(provider as IFilesStorageProviderV30); } else if (provider is IFormatterProviderV30) { (isDisabled ? Collectors.DisabledFormatterProviderCollector : Collectors.FormatterProviderCollector).AddProvider(provider as IFormatterProviderV30); } else if (provider is ICacheProviderV30) { (isDisabled ? Collectors.DisabledCacheProviderCollector : Collectors.CacheProviderCollector).AddProvider(provider as ICacheProviderV30); } } // Load Users (pages storage providers might need access to users/groups data for upgrading from 2.0 to 3.0) ProviderLoader.FullLoad(true, false, false, false, false); //Users.Instance = new Users(); bool groupsCreated = VerifyAndCreateDefaultGroups(); PagesStorageProvider p = new PagesStorageProvider(); if (!ProviderLoader.IsDisabled(p.GetType().FullName)) { p.Init(Host.Instance, ""); Collectors.PagesProviderCollector.AddProvider(p); Log.LogEntry("Provider " + p.Information.Name + " loaded (Enabled)", EntryType.General, Log.SystemUsername); } else { Collectors.DisabledPagesProviderCollector.AddProvider(p); Log.LogEntry("Provider " + p.Information.Name + " loaded (Disabled)", EntryType.General, Log.SystemUsername); } CacheProvider c = new CacheProvider(); if (!ProviderLoader.IsDisabled(c.GetType().FullName)) { c.Init(Host.Instance, ""); Collectors.CacheProviderCollector.AddProvider(c); Log.LogEntry("Provider " + c.Information.Name + " loaded (Enabled)", EntryType.General, Log.SystemUsername); } else { Collectors.DisabledCacheProviderCollector.AddProvider(c); Log.LogEntry("Provider " + c.Information.Name + " loaded (Disabled)", EntryType.General, Log.SystemUsername); } // Load all other providers ProviderLoader.FullLoad(false, true, true, true, true); if (groupsCreated) { // It is necessary to set default permissions for file management UserGroup administratorsGroup = Users.FindUserGroup(Settings.AdministratorsGroup); UserGroup anonymousGroup = Users.FindUserGroup(Settings.AnonymousGroup); UserGroup usersGroup = Users.FindUserGroup(Settings.UsersGroup); SetAdministratorsGroupDefaultPermissions(administratorsGroup); SetUsersGroupDefaultPermissions(usersGroup); SetAnonymousGroupDefaultPermissions(anonymousGroup); } // Init cache //Cache.Instance = new Cache(Collectors.CacheProviderCollector.GetProvider(Settings.DefaultCacheProvider)); if (Collectors.CacheProviderCollector.GetProvider(Settings.DefaultCacheProvider) == null) { Log.LogEntry("Default Cache Provider was not loaded, backing to integrated provider", EntryType.Error, Log.SystemUsername); Settings.DefaultCacheProvider = typeof(CacheProvider).FullName; Collectors.TryEnable(Settings.DefaultCacheProvider); } // Create the Main Page, if needed if (Pages.FindPage(Settings.DefaultPage) == null) { CreateMainPage(); } Log.LogEntry("ScrewTurn Wiki is ready", EntryType.General, Log.SystemUsername); System.Threading.ThreadPool.QueueUserWorkItem(state => { using (((WindowsIdentity)state).Impersonate()) { if ((DateTime.Now - Settings.LastPageIndexing).TotalDays > 7) { Settings.LastPageIndexing = DateTime.Now; System.Threading.Thread.Sleep(10000); using (MemoryStream ms = new MemoryStream()) { using (StreamWriter wr = new System.IO.StreamWriter(ms)) { System.Web.HttpContext.Current = new System.Web.HttpContext(new System.Web.Hosting.SimpleWorkerRequest("", "", wr)); foreach (var provider in Collectors.PagesProviderCollector.AllProviders) { if (!provider.ReadOnly) { Log.LogEntry("Starting automatic rebuilding index for provider: " + provider.Information.Name, EntryType.General, Log.SystemUsername); provider.RebuildIndex(); Log.LogEntry("Finished automatic rebuilding index for provider: " + provider.Information.Name, EntryType.General, Log.SystemUsername); } } } } Pages.RebuildPageLinks(Pages.GetPages(null)); foreach (ScrewTurn.Wiki.PluginFramework.NamespaceInfo nspace in Pages.GetNamespaces()) { Pages.RebuildPageLinks(Pages.GetPages(nspace)); } } } }, WindowsIdentity.GetCurrent()); }
/// <summary> /// Performs all needed startup operations. /// </summary> public static void Startup() { // Load Host Host.Instance = new Host(); // Load config ISettingsStorageProviderV30 ssp = ProviderLoader.LoadSettingsStorageProvider(WebConfigurationManager.AppSettings["SettingsStorageProvider"]); ssp.Init(Host.Instance, GetSettingsStorageProviderConfiguration()); Collectors.SettingsProvider = ssp; if (!(ssp is SettingsStorageProvider)) { // Update DLLs from public\Plugins UpdateDllsIntoSettingsProvider(ssp, ProviderLoader.SettingsStorageProviderAssemblyName); } if (ssp.IsFirstApplicationStart()) { if (ssp.GetMetaDataItem(MetaDataItem.AccountActivationMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.AccountActivationMessage, null, Defaults.AccountActivationMessageContent); } if (ssp.GetMetaDataItem(MetaDataItem.EditNotice, null) == "") { ssp.SetMetaDataItem(MetaDataItem.EditNotice, null, Defaults.EditNoticeContent); } if (ssp.GetMetaDataItem(MetaDataItem.Footer, null) == "") { ssp.SetMetaDataItem(MetaDataItem.Footer, null, Defaults.FooterContent); } if (ssp.GetMetaDataItem(MetaDataItem.Header, null) == "") { ssp.SetMetaDataItem(MetaDataItem.Header, null, Defaults.HeaderContent); } if (ssp.GetMetaDataItem(MetaDataItem.PasswordResetProcedureMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.PasswordResetProcedureMessage, null, Defaults.PasswordResetProcedureMessageContent); } if (ssp.GetMetaDataItem(MetaDataItem.Sidebar, null) == "") { ssp.SetMetaDataItem(MetaDataItem.Sidebar, null, Defaults.SidebarContent); } if (ssp.GetMetaDataItem(MetaDataItem.PageChangeMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.PageChangeMessage, null, Defaults.PageChangeMessage); } if (ssp.GetMetaDataItem(MetaDataItem.DiscussionChangeMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.DiscussionChangeMessage, null, Defaults.DiscussionChangeMessage); } if (ssp.GetMetaDataItem(MetaDataItem.ApproveDraftMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.ApproveDraftMessage, null, Defaults.ApproveDraftMessage); } } // Load config IIndexDirectoryProviderV30 idp = ProviderLoader.LoadIndexDirectoryProvider(WebConfigurationManager.AppSettings["IndexDirectoryProvider"]); idp.Init(Host.Instance, GetSettingsStorageProviderConfiguration()); Collectors.IndexDirectoryProvider = idp; MimeTypes.Init(); // Load Providers Collectors.FileNames = new System.Collections.Generic.Dictionary <string, string>(10); Collectors.UsersProviderCollector = new ProviderCollector <IUsersStorageProviderV30>(); Collectors.PagesProviderCollector = new ProviderCollector <IPagesStorageProviderV30>(); Collectors.FilesProviderCollector = new ProviderCollector <IFilesStorageProviderV30>(); Collectors.FormatterProviderCollector = new ProviderCollector <IFormatterProviderV30>(); Collectors.CacheProviderCollector = new ProviderCollector <ICacheProviderV30>(); Collectors.DisabledUsersProviderCollector = new ProviderCollector <IUsersStorageProviderV30>(); Collectors.DisabledPagesProviderCollector = new ProviderCollector <IPagesStorageProviderV30>(); Collectors.DisabledFilesProviderCollector = new ProviderCollector <IFilesStorageProviderV30>(); Collectors.DisabledFormatterProviderCollector = new ProviderCollector <IFormatterProviderV30>(); Collectors.DisabledCacheProviderCollector = new ProviderCollector <ICacheProviderV30>(); // Load built-in providers // Files storage providers have to be loaded BEFORE users storage providers in order to properly set permissions FilesStorageProvider f = new FilesStorageProvider(); if (!ProviderLoader.IsDisabled(f.GetType().FullName)) { f.Init(Host.Instance, ""); Collectors.FilesProviderCollector.AddProvider(f); Log.LogEntry("Provider " + f.Information.Name + " loaded (Enabled)", EntryType.General, Log.SystemUsername); } else { Collectors.DisabledFilesProviderCollector.AddProvider(f); Log.LogEntry("Provider " + f.Information.Name + " loaded (Disabled)", EntryType.General, Log.SystemUsername); } UsersStorageProvider u = new UsersStorageProvider(); if (!ProviderLoader.IsDisabled(u.GetType().FullName)) { u.Init(Host.Instance, ""); Collectors.UsersProviderCollector.AddProvider(u); Log.LogEntry("Provider " + u.Information.Name + " loaded (Enabled)", EntryType.General, Log.SystemUsername); } else { Collectors.DisabledUsersProviderCollector.AddProvider(u); Log.LogEntry("Provider " + u.Information.Name + " loaded (Disabled)", EntryType.General, Log.SystemUsername); } // Load Users (pages storage providers might need access to users/groups data for upgrading from 2.0 to 3.0) ProviderLoader.FullLoad(true, false, false, false, false); //Users.Instance = new Users(); bool groupsCreated = VerifyAndCreateDefaultGroups(); PagesStorageProvider p = new PagesStorageProvider(); if (!ProviderLoader.IsDisabled(p.GetType().FullName)) { p.Init(Host.Instance, ""); Collectors.PagesProviderCollector.AddProvider(p); Log.LogEntry("Provider " + p.Information.Name + " loaded (Enabled)", EntryType.General, Log.SystemUsername); } else { Collectors.DisabledPagesProviderCollector.AddProvider(p); Log.LogEntry("Provider " + p.Information.Name + " loaded (Disabled)", EntryType.General, Log.SystemUsername); } CacheProvider c = new CacheProvider(); if (!ProviderLoader.IsDisabled(c.GetType().FullName)) { c.Init(Host.Instance, ""); Collectors.CacheProviderCollector.AddProvider(c); Log.LogEntry("Provider " + c.Information.Name + " loaded (Enabled)", EntryType.General, Log.SystemUsername); } else { Collectors.DisabledCacheProviderCollector.AddProvider(c); Log.LogEntry("Provider " + c.Information.Name + " loaded (Disabled)", EntryType.General, Log.SystemUsername); } // Load all other providers ProviderLoader.FullLoad(false, true, true, true, true); if (groupsCreated) { // It is necessary to set default permissions for file management UserGroup administratorsGroup = Users.FindUserGroup(Settings.AdministratorsGroup); UserGroup anonymousGroup = Users.FindUserGroup(Settings.AnonymousGroup); UserGroup usersGroup = Users.FindUserGroup(Settings.UsersGroup); SetAdministratorsGroupDefaultPermissions(administratorsGroup); SetUsersGroupDefaultPermissions(usersGroup); SetAnonymousGroupDefaultPermissions(anonymousGroup); } // Init cache //Cache.Instance = new Cache(Collectors.CacheProviderCollector.GetProvider(Settings.DefaultCacheProvider)); if (Collectors.CacheProviderCollector.GetProvider(Settings.DefaultCacheProvider) == null) { Log.LogEntry("Default Cache Provider was not loaded, backing to integrated provider", EntryType.Error, Log.SystemUsername); Settings.DefaultCacheProvider = typeof(CacheProvider).FullName; Collectors.TryEnable(Settings.DefaultCacheProvider); } // Create the Main Page, if needed if (Pages.FindPage(Settings.DefaultPage) == null) { CreateMainPage(); } Log.LogEntry("ScrewTurn Wiki is ready", EntryType.General, Log.SystemUsername); System.Threading.ThreadPool.QueueUserWorkItem(ignored => { SearchClass.RebuildIndex(); }); }
/// <summary> /// Performs all needed startup operations. /// </summary> public static void Startup() { // Load Host Host.Instance = new Host(); // Initialize MimeTypes MimeTypes.Init(); GlobalSettings.CanOverridePublicDirectory = false; // Initialize Collectors Collectors.InitCollectors(); Collectors.FileNames = new Dictionary <string, string>(10); // Load Global Config IGlobalSettingsStorageProviderV60 globalSettingsStorageProvider = ProviderLoader.LoadGlobalSettingsStorageProvider(ApplicationSettings.Instance.GlobalSettingsStorageProvider); Collectors.AddGlobalSettingsStorageProvider(globalSettingsStorageProvider.GetType(), Assembly.GetAssembly(globalSettingsStorageProvider.GetType())); globalSettingsStorageProvider.SetUp(Host.Instance, GetGlobalSettingsStorageProviderConfiguration()); globalSettingsStorageProvider.Dispose(); // Add StorageProviders, from WebConfig, to Collectors and Setup them ProviderLoader.LoadStorageProviders <ISettingsStorageProviderV60>(new List <StorageProvider>() { ApplicationSettings.Instance.SettingProvider }); ProviderLoader.LoadStorageProviders <IFilesStorageProviderV60>(ApplicationSettings.Instance.FilesProviders); ProviderLoader.LoadStorageProviders <IThemesStorageProviderV60>(ApplicationSettings.Instance.ThemesProviders); ProviderLoader.LoadStorageProviders <IUsersStorageProviderV60>(ApplicationSettings.Instance.UsersProviders); ProviderLoader.LoadStorageProviders <IPagesStorageProviderV60>(ApplicationSettings.Instance.PagesProviders); ProviderLoader.LoadStorageProviders <IIndexDirectoryProviderV60>(new List <StorageProvider>() { ApplicationSettings.Instance.IndexDirectoryProvider }); ProviderLoader.LoadAllFormatterProviders(); foreach (Configuration.Wiki wiki in Collectors.CollectorsBox.GlobalSettingsProvider.GetAllWikis()) { ISettingsStorageProviderV60 ssp = Collectors.CollectorsBox.GetSettingsProvider(wiki.WikiName); if (ssp.IsFirstApplicationStart()) { if (ssp.GetMetaDataItem(MetaDataItem.AccountActivationMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.AccountActivationMessage, null, Defaults.AccountActivationMessageContent); } if (ssp.GetMetaDataItem(MetaDataItem.EditNotice, null) == "") { ssp.SetMetaDataItem(MetaDataItem.EditNotice, null, Defaults.EditNoticeContent); } if (ssp.GetMetaDataItem(MetaDataItem.Footer, null) == "") { ssp.SetMetaDataItem(MetaDataItem.Footer, null, Defaults.FooterContent); } if (ssp.GetMetaDataItem(MetaDataItem.Header, null) == "") { ssp.SetMetaDataItem(MetaDataItem.Header, null, Defaults.HeaderContent); } if (ssp.GetMetaDataItem(MetaDataItem.PasswordResetProcedureMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.PasswordResetProcedureMessage, null, Defaults.PasswordResetProcedureMessageContent); } if (ssp.GetMetaDataItem(MetaDataItem.Sidebar, null) == "") { ssp.SetMetaDataItem(MetaDataItem.Sidebar, null, Defaults.SidebarContent); } if (ssp.GetMetaDataItem(MetaDataItem.PageChangeMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.PageChangeMessage, null, Defaults.PageChangeMessage); } if (ssp.GetMetaDataItem(MetaDataItem.DiscussionChangeMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.DiscussionChangeMessage, null, Defaults.DiscussionChangeMessage); } if (ssp.GetMetaDataItem(MetaDataItem.ApproveDraftMessage, null) == "") { ssp.SetMetaDataItem(MetaDataItem.ApproveDraftMessage, null, Defaults.ApproveDraftMessage); } } bool groupsCreated = VerifyAndCreateDefaultGroups(wiki.WikiName); if (groupsCreated) { // It is necessary to set default permissions for file management UserGroup administratorsGroup = Users.FindUserGroup(wiki.WikiName, Settings.GetAdministratorsGroup(wiki.WikiName)); UserGroup anonymousGroup = Users.FindUserGroup(wiki.WikiName, Settings.GetAnonymousGroup(wiki.WikiName)); UserGroup usersGroup = Users.FindUserGroup(wiki.WikiName, Settings.GetUsersGroup(wiki.WikiName)); SetAdministratorsGroupDefaultPermissions(wiki.WikiName, administratorsGroup); SetUsersGroupDefaultPermissions(wiki.WikiName, usersGroup); SetAnonymousGroupDefaultPermissions(wiki.WikiName, anonymousGroup); } // Create the Main Page, if needed if (Pages.FindPage(wiki.WikiName, Settings.GetDefaultPage(wiki.WikiName)) == null) { CreateMainPage(wiki.WikiName); } Log.LogEntry("Wiki " + wiki.WikiName + " is ready", EntryType.General, Log.SystemUsername, null); //Pages.RebuildPageLinks(Pages.GetPages(wiki.WikiName, null)); //foreach(ScrewTurn.Wiki.PluginFramework.NamespaceInfo nspace in Pages.GetNamespaces(wiki.WikiName)) { // Pages.RebuildPageLinks(Pages.GetPages(wiki.WikiName, nspace)); //} } Log.LogEntry("ScrewTurn Wiki is ready", EntryType.General, Log.SystemUsername, null); }
protected void rptProviders_ItemCommand(object sender, CommandEventArgs e) { txtCurrentProvider.Value = e.CommandArgument as string; if (e.CommandName == "Select") { bool enabled; IProviderV30 provider = GetCurrentProvider(out enabled); pnlProviderDetails.Visible = true; lblProviderName.Text = provider.Information.Name + " (" + provider.Information.Version + ")"; string dll = provider.GetType().Assembly.FullName; lblProviderDll.Text = dll.Substring(0, dll.IndexOf(",")) + ".dll"; txtConfigurationString.Text = ProviderLoader.LoadConfiguration(provider.GetType().FullName); if (provider.ConfigHelpHtml != null) { lblProviderConfigHelp.Text = provider.ConfigHelpHtml; } else { lblProviderConfigHelp.Text = Properties.Messages.NoConfigurationRequired; } lblResult.CssClass = ""; lblResult.Text = ""; rptProviders.DataBind(); } else if (e.CommandName == "Disable") { bool enabled; IProviderV30 prov = GetCurrentProvider(out enabled); Log.LogEntry("Deactivation requested for Provider " + prov.Information.Name, EntryType.General, SessionFacade.CurrentUsername); ProviderLoader.SaveStatus(txtCurrentProvider.Value, false); lblResult.CssClass = "resultok"; lblResult.Text = Properties.Messages.ProviderDisabled; ResetEditor(); rptProviders.DataBind(); } else if (e.CommandName == "Enable") { bool enabled; IProviderV30 prov = GetCurrentProvider(out enabled); Log.LogEntry("Activation requested for provider provider " + prov.Information.Name, EntryType.General, SessionFacade.CurrentUsername); try { //ProviderLoader.SetUp<IFormatterProviderV30>(prov.GetType(), Settings.Provider.GetPluginConfiguration(prov.GetType().FullName)); ProviderLoader.SaveStatus(txtCurrentProvider.Value, true); lblResult.CssClass = "resultok"; lblResult.Text = Properties.Messages.ProviderEnabled; } catch (InvalidConfigurationException) { ProviderLoader.SaveStatus(txtCurrentProvider.Value, false); lblResult.CssClass = "resulterror"; lblResult.Text = Properties.Messages.ProviderRejectedConfiguration; } ResetEditor(); rptProviders.DataBind(); } }
public void ProcessRequest(HttpContext context) { string targetFolder = HttpContext.Current.Server.MapPath("uploadfiles"); if (!Directory.Exists(targetFolder)) { Directory.CreateDirectory(targetFolder); } HttpRequest request = context.Request; HttpFileCollection uploadedFiles = context.Request.Files; if (uploadedFiles != null && uploadedFiles.Count > 0) { for (int i = 0; i < uploadedFiles.Count; i++) { string fileName = uploadedFiles[i].FileName; int indx = fileName.LastIndexOf("\\"); if (indx > -1) { fileName = fileName.Substring(indx + 1); } uploadedFiles[i].SaveAs(targetFolder + "\\" + fileName); //string file = upDll.FileName; string ext = System.IO.Path.GetExtension(fileName); if (ext != null) { ext = ext.ToLowerInvariant(); } if (ext != ".dll") { //lblUploadResult.CssClass = "resulterror"; //lblUploadResult.Text = Properties.Messages.VoidOrInvalidFile; return; } Log.LogEntry("Provider DLL upload requested " + fileName, EntryType.General, SessionFacade.CurrentUsername); string[] asms = Settings.Provider.ListPluginAssemblies(); if (Array.Find <string>(asms, delegate(string v) { if (v.Equals(fileName)) { return(true); } else { return(false); } }) != null) { // DLL already exists //lblUploadResult.CssClass = "resulterror"; //lblUploadResult.Text = Properties.Messages.DllAlreadyExists; return; } else { BinaryReader b = new BinaryReader(uploadedFiles[i].InputStream); byte[] binData = b.ReadBytes(uploadedFiles[i].ContentLength); Stream stream = uploadedFiles[i].InputStream; stream.Position = 0; byte[] fileData = null; using (var binaryReader = new BinaryReader(uploadedFiles[i].InputStream)) { fileData = binaryReader.ReadBytes(uploadedFiles[i].ContentLength); Settings.Provider.StorePluginAssembly(fileName, fileData); } int count = ProviderLoader.LoadFromAuto(fileName); //lblUploadResult.CssClass = "resultok"; //lblUploadResult.Text = Properties.Messages.LoadedProviders.Replace("###", count.ToString()); //upDll.Attributes.Add("value", ""); //PerformPostProviderChangeActions(); Content.InvalidateAllPages(); Content.ClearPseudoCache(); //LoadDlls(); //populate the dropdownlist //ResetEditor(); // reset the upload control //rptProviders.DataBind(); //LoadSourceProviders(); } } } }