public override void Initialize(WebConfig wc) { GetDefaults(); values = defaults; // get the default provider XmlElement e = wc.GetProviderSection(sectionName); if (e != null) { string mode = e.GetAttribute("mode"); if (String.Compare(mode, "custom", true) == 0) DefaultProvider = e.GetAttribute("customProvider"); } e = wc.GetProviderElement(sectionName); if (e != null) { values.ProviderName = e.GetAttribute("name"); if (e.HasAttribute("connectionStringName")) values.ConnectionStringName = e.GetAttribute("connectionStringName"); if (e.HasAttribute("description")) values.AppDescription = e.GetAttribute("description"); if (e.HasAttribute("applicationName")) values.AppName = e.GetAttribute("applicationName"); if (e.HasAttribute("writeExceptionsToEventLog")) values.WriteExceptionToLog = GetBoolValue(e.GetAttribute("writeExceptionsToEventLog"), false); if (e.HasAttribute("autogenerateschema")) values.AutoGenSchema = GetBoolValue(e.GetAttribute("autogenerateschema"), false); } values.ConnectionString = wc.GetConnectionString(values.ConnectionStringName); Enabled = OriginallyEnabled = DefaultProvider != null && (DefaultProvider == values.ProviderName || DefaultProvider == defaults.ProviderName); }
public override void Initialize(WebConfig wc) { base.Initialize(wc); values = defaults; XmlElement e = wc.GetProviderElement(sectionName); if (e == null) return; //GetOptionalParameter(e, "description"); if (e.HasAttribute("enablePasswordRetrieval")) values.EnablePasswordRetrieval = Convert.ToBoolean(e.GetAttribute("enablePasswordRetrieval")); if (e.HasAttribute("enablePasswordReset")) values.EnablePasswordReset = Convert.ToBoolean(e.GetAttribute("enablePasswordReset")); if (e.HasAttribute("requiresQuestionAndAnswer")) values.RequiresQA = Convert.ToBoolean(e.GetAttribute("requiresQuestionAndAnswer")); if (e.HasAttribute("requiresUniqueEmail")) values.RequiresUniqueEmail = Convert.ToBoolean(e.GetAttribute("requiresUniqueEmail")); if (e.HasAttribute("passwordFormat")) values.PasswordFormat = (MembershipPasswordFormat)Enum.Parse(typeof(MembershipPasswordFormat), e.GetAttribute("passwordFormat")); if (e.HasAttribute("passwordStrengthRegularExpression")) values.PasswordStrengthRegEx = e.GetAttribute("passwordStrengthRegularExpression"); if (e.HasAttribute("maxInvalidPasswordAttempts")) values.MaxInvalidPasswordAttempts = Convert.ToInt32(e.GetAttribute("maxInvalidPasswordAttempts")); if (e.HasAttribute("minRequiredPasswordLength")) values.MinRequiredPasswordLength = Convert.ToInt32(e.GetAttribute("minRequiredPasswordLength")); if (e.HasAttribute("minRequiredNonalphanumericCharacters")) values.MinRequiredNonAlphaNumericCharacters = Convert.ToInt32(e.GetAttribute("minRequiredNonalphanumericCharacters")); if (e.HasAttribute("passwordAttemptWindow")) values.PasswordAttemptWindow = Convert.ToInt32(e.GetAttribute("passwordAttemptWindow")); }
private void LoadInitialState() { WebConfig wc = new WebConfig(webConfigFileName); LoadInitialMembershipState(); LoadInitialRoleState(); LoadInitialProfileState(); LoadInitialSessionState(); foreach (WizardPage page in pages) page.ProviderConfig.Initialize(wc); }
private void Finish() { WebConfig w = new WebConfig(webConfigFileName); pages[0].ProviderConfig.Save(w); pages[1].ProviderConfig.Save(w); pages[2].ProviderConfig.Save(w); pages[3].ProviderConfig.Save(w); w.Save(); Close(); }
public virtual void Initialize(WebConfig wc) { // first load up the defaults GetDefaults(); values = defaults; // get the default provider XmlElement e = wc.GetProviderSection(sectionName); if (e != null) DefaultProvider = e.GetAttribute("defaultProvider"); e = wc.GetProviderElement(sectionName); if (e != null) { values.ProviderName = e.GetAttribute("name"); if (e.HasAttribute("connectionStringName")) values.ConnectionStringName = e.GetAttribute("connectionStringName"); if (e.HasAttribute("description")) values.AppDescription = e.GetAttribute("description"); if (e.HasAttribute("applicationName")) values.AppName = e.GetAttribute("applicationName"); if (e.HasAttribute("writeExceptionsToEventLog")) values.WriteExceptionToLog = GetBoolValue(e.GetAttribute("writeExceptionsToEventLog"), false); if (e.HasAttribute("autogenerateschema")) values.AutoGenSchema = GetBoolValue(e.GetAttribute("autogenerateschema"), false); } values.ConnectionString = wc.GetConnectionString(values.ConnectionStringName); Enabled = OriginallyEnabled = DefaultProvider != null && (DefaultProvider == values.ProviderName || DefaultProvider == defaults.ProviderName); }
public virtual void Save(WebConfig wc) { if (OriginallyEnabled) wc.RemoveProvider(sectionName, defaults.ProviderName, values.ProviderName); if (!Enabled) return; // we need to save our connection strings even if we are using the default // provider definition wc.SaveConnectionString(defaults.ConnectionStringName, values.ConnectionStringName, values.ConnectionString); // we do this so our equality comparison that follows can work defaults.ConnectionString = values.ConnectionString; // we are enabled so we want to set our defaultProvider attribute wc.SetDefaultProvider(sectionName, values.ProviderName); if (defaults.Equals(values)) return; // our defaults do not equal our new values so we need to redefine our provider XmlElement provider = wc.AddProvider(sectionName, defaults.ProviderName, values.ProviderName); SaveProvider(provider); }
public override void Save(WebConfig wc) { if (OriginallyEnabled) { XmlElement e = wc.GetProviderSection(sectionName); e.ParentNode.RemoveChild(e); } if (!Enabled) return; // we need to save our connection strings even if we are using the default // provider definition wc.SaveConnectionString(defaults.ConnectionStringName, values.ConnectionStringName, values.ConnectionString); // we do this so our equality comparison that follows can work defaults.ConnectionString = values.ConnectionString; XmlElement provider = wc.AddProvider(sectionName, null, values.ProviderName); SaveProvider(provider); // we are enabled so we want to set our defaultProvider attribute XmlElement sessionNode = (XmlElement)provider.ParentNode.ParentNode; sessionNode.SetAttribute("mode", "Custom"); sessionNode.SetAttribute("cookieless", "true"); sessionNode.SetAttribute("regenerateExpiredSessionId", "true"); sessionNode.SetAttribute("customProvider", values.ProviderName); }
public virtual void Initialize(WebConfig wc) { // first load up the defaults GetDefaults(); values = defaults; if (string.IsNullOrEmpty(values.ProviderName)) { NotInstalled = true; } // get the default provider XmlElement e = wc.GetProviderSection(sectionName); if (e != null) { //OrininallyEnabled property should be true just when the current provider is already configured as default string currentProvider = e.GetAttribute("defaultProvider"); if (!currentProvider.Equals(typeName, StringComparison.InvariantCultureIgnoreCase)) { DefaultProvider = typeName; OriginallyEnabled = false; } else { DefaultProvider = currentProvider; OriginallyEnabled = true; } } e = wc.GetProviderElement(sectionName); if (e != null) { //use the ProviderName configured just when is the current Provider, because this will cause conflicts when two providers are in the same section with a different name if (e.HasAttribute("name")) { string providerName = e.GetAttribute("name"); values.ProviderName = !OriginallyEnabled ? typeName : providerName; } if (e.HasAttribute("connectionStringName")) { values.ConnectionStringName = e.GetAttribute("connectionStringName"); } if (e.HasAttribute("description")) { values.AppDescription = e.GetAttribute("description"); } if (e.HasAttribute("applicationName")) { values.AppName = e.GetAttribute("applicationName"); } if (e.HasAttribute("writeExceptionsToEventLog")) { values.WriteExceptionToLog = GetBoolValue(e.GetAttribute("writeExceptionsToEventLog"), false); } if (e.HasAttribute("autogenerateschema")) { values.AutoGenSchema = GetBoolValue(e.GetAttribute("autogenerateschema"), false); } if (e.HasAttribute("enableExpireCallback")) { values.EnableExpireCallback = GetBoolValue(e.GetAttribute("enableExpireCallback"), false); } } values.ConnectionString = wc.GetConnectionString(values.ConnectionStringName); //enable the provider by default just when it was already configured as default Enabled = OriginallyEnabled; //Enabled = OriginallyEnabled = DefaultProvider != null && (DefaultProvider == values.ProviderName || DefaultProvider == defaults.ProviderName); }
public override void Initialize(WebConfig wc) { GetDefaults(); values = defaults; if (string.IsNullOrEmpty(values.ProviderName)) { NotInstalled = true; } //Personalization provider needs membership enabled XmlElement membership = wc.GetProviderSection("membership"); if (membership == null || membership.Attributes["defaultProvider"] == null || !membership.Attributes["defaultProvider"].Value.Equals("MySQLMembershipProvider", StringComparison.InvariantCultureIgnoreCase)) { _membershipEnabled = false; return; } else { _membershipEnabled = true; } // get the default provider XmlElement e = wc.GetProviderSection(sectionName); if (e == null || e.FirstChild == null) { return; } var personalizationNode = e.FirstChild as XmlElement; // move to the <personalization> element if (personalizationNode == null || personalizationNode.FirstChild == null) { return; } string defaultProvider = personalizationNode.GetAttribute("defaultProvider"); Enabled = OriginallyEnabled = defaultProvider != null && (defaultProvider == values.ProviderName || defaultProvider == defaults.ProviderName); e = wc.GetProviderElement(sectionName); if (e != null) { values.ProviderName = e.GetAttribute("name"); if (e.HasAttribute("connectionStringName")) { values.ConnectionStringName = e.GetAttribute("connectionStringName"); } if (e.HasAttribute("description")) { values.AppDescription = e.GetAttribute("description"); } if (e.HasAttribute("applicationName")) { values.AppName = e.GetAttribute("applicationName"); } if (e.HasAttribute("writeExceptionsToEventLog")) { values.WriteExceptionToLog = GetBoolValue(e.GetAttribute("writeExceptionsToEventLog"), false); } if (e.HasAttribute("autogenerateschema")) { values.AutoGenSchema = GetBoolValue(e.GetAttribute("autogenerateschema"), false); } } values.ConnectionString = wc.GetConnectionString(values.ConnectionStringName); }
public override void Initialize(WebConfig wc) { base.Initialize(wc); XmlElement e = wc.GetProviderSection(sectionName); if (e != null) { string currentProvider = e.GetAttribute("defaultProvider"); if (!currentProvider.Equals(typeName, StringComparison.InvariantCultureIgnoreCase)) { base.DefaultProvider = typeName; OriginallyEnabled = false; } else { base.DefaultProvider = currentProvider; OriginallyEnabled = true; } } e = wc.GetProviderElement(sectionName); if (e != null) { if (e.HasAttribute("name")) { string providerName = e.GetAttribute("name"); base.values.ProviderName = !OriginallyEnabled ? typeName : providerName; } if (e.HasAttribute("connectionStringName")) { string connStrName = e.GetAttribute("connectionStringName"); base.values.ConnectionStringName = !OriginallyEnabled ? "LocalMySqlServer" : connStrName; } if (e.HasAttribute("description")) { base.values.AppDescription = e.GetAttribute("description"); } if (e.HasAttribute("applicationName")) { base.values.AppName = e.GetAttribute("applicationName"); } } base.values.ConnectionString = wc.GetConnectionString(base.values.ConnectionStringName); NotInstalled = !_mySqlSimpleMembershipFound; Enabled = OriginallyEnabled; values = defaults; e = wc.GetProviderElement(sectionName); if (e == null) { return; } if (e.HasAttribute("userTableName")) { values.UserTableName = e.GetAttribute("userTableName"); } if (e.HasAttribute("userIdColumn")) { values.UserIdColumn = e.GetAttribute("userIdColumn"); } if (e.HasAttribute("userNameColumn")) { values.UserNameColumn = e.GetAttribute("userNameColumn"); } if (e.HasAttribute("autoGenerateTables")) { values.AutoGenerateTables = Convert.ToBoolean(e.GetAttribute("autoGenerateTables")); } }
public override void ProjectFinishedGenerating(Project project) { if (project != null) { VSProject vsProj = project.Object as VSProject; var tables = new List <string>(); Settings.Default.MVCWizardConnection = WizardForm.ServerExplorerConnectionSelected; Settings.Default.Save(); if (_generalPane != null) { _generalPane.Activate(); } SendToGeneralOutputWindow("Starting project generation..."); //Updating project references try { vsProj.References.Add("MySql.Data"); } catch { var infoResult = InfoDialog.ShowDialog( InfoDialogProperties.GetOkCancelDialogProperties( InfoDialog.InfoType.Warning, Resources.MySqlDataProviderPackage_ConnectorNetNotFoundError, @"To use it you must download and install the MySQL Connector/Net package from http://dev.mysql.com/downloads/connector/net/", Resources.MySqlDataProviderPackage_ClickOkOrCancel)); if (infoResult.DialogResult == DialogResult.OK) { ProcessStartInfo browserInfo = new ProcessStartInfo("http://dev.mysql.com/downloads/connector/net/"); System.Diagnostics.Process.Start(browserInfo); } } double version = double.Parse(WizardForm.Wizard.GetVisualStudioVersion()); if (version >= 12.0) { References refs = vsProj.References; foreach (Reference item in refs) { switch (item.Name) { case "System.Web.Razor": if (item.Version.Equals("1.0.0.0")) { vsProj.References.Find("System.Web.Razor").Remove(); } break; case "System.Web.WebPages": vsProj.References.Find("System.Web.WebPages").Remove(); break; case "System.Web.Mvc": vsProj.References.Find("System.Web.Mvc").Remove(); break; case "System.Web.Helpers": vsProj.References.Find("System.Web.Helpers").Remove(); break; } } vsProj.References.Add("System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"); vsProj.References.Add("System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"); vsProj.References.Add("System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"); vsProj.References.Add("System.Web.Razor"); #if NET_40_OR_GREATER vsProj.Project.Save(); #endif } AddNugetPackage(vsProj, JQUERY_PKG_NAME, JQUERY_VERSION, false); var packagesPath = Path.Combine(Path.GetDirectoryName(ProjectPath), @"Packages\jQuery." + JQUERY_VERSION + @"\Content\Scripts"); CopyPackageToProject(vsProj, ProjectPath, packagesPath, "Scripts"); if (WizardForm.SelectedTables != null && WizardForm.DEVersion != DataEntityVersion.None) { WizardForm.SelectedTables.ForEach(t => tables.Add(t.Name)); SendToGeneralOutputWindow("Generating Entity Framework model..."); if (tables.Count > 0) { if (WizardForm.DEVersion == DataEntityVersion.EntityFramework5) { CurrentEntityFrameworkVersion = ENTITY_FRAMEWORK_VERSION_5; } else if (WizardForm.DEVersion == DataEntityVersion.EntityFramework6) { CurrentEntityFrameworkVersion = ENTITY_FRAMEWORK_VERSION_6; } AddNugetPackage(vsProj, ENTITY_FRAMEWORK_PCK_NAME, CurrentEntityFrameworkVersion, true); string modelPath = Path.Combine(ProjectPath, "Models"); GenerateEntityFrameworkModel(project, vsProj, new MySqlConnection(WizardForm.ConnectionStringForModel), WizardForm.ModelName, tables, modelPath); GenerateMVCItems(vsProj); if (WizardForm.DEVersion == DataEntityVersion.EntityFramework6) { project.DTE.SuppressUI = true; project.Properties.Item("TargetFrameworkMoniker").Value = ".NETFramework,Version=v4.5"; } } } else { string indexPath = Language == LanguageGenerator.CSharp ? (string)(FindProjectItem(FindProjectItem(FindProjectItem(vsProj.Project.ProjectItems, "Views").ProjectItems, "Home").ProjectItems, "Index.cshtml").Properties.Item("FullPath").Value) : (string)(FindProjectItem(FindProjectItem(FindProjectItem(vsProj.Project.ProjectItems, "Views").ProjectItems, "Home").ProjectItems, "Index.vbhtml").Properties.Item("FullPath").Value); string contents = File.ReadAllText(indexPath); contents = contents.Replace("$catalogList$", String.Empty); File.WriteAllText(indexPath, contents); } var webConfig = new MySql.Data.VisualStudio.WebConfig.WebConfig(ProjectPath + @"\web.config"); SendToGeneralOutputWindow("Starting provider configuration..."); try { try { string configPath = ProjectPath + @"\web.config"; if (WizardForm.CreateAdministratorUser) { SendToGeneralOutputWindow("Creating administrator user..."); using (AppConfig.Load(configPath)) { var configFile = new FileInfo(configPath); var vdm = new VirtualDirectoryMapping(configFile.DirectoryName, true, configFile.Name); var wcfm = new WebConfigurationFileMap(); wcfm.VirtualDirectories.Add("/", vdm); System.Configuration.Configuration config = WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "/"); try { if (!WizardForm.IncludeSensitiveInformation) { ConnectionStringsSection connectionStringsection = config.GetSection("connectionStrings") as ConnectionStringsSection; if (connectionStringsection != null) { connectionStringsection.ConnectionStrings[WizardForm.ConnectionStringNameForAspNetTables].ConnectionString = _fullconnectionstring; config.Save(); } } } catch { } MembershipSection section = (MembershipSection)config.GetSection("system.web/membership"); ProviderSettingsCollection settings = section.Providers; NameValueCollection membershipParams = settings[section.DefaultProvider].Parameters; var provider = new MySQLMembershipProvider(); provider.Initialize(section.DefaultProvider, membershipParams); //create the user MembershipCreateStatus status; if (!WizardForm.RequireQuestionAndAnswer) { provider.CreateUser(WizardForm.AdminName, WizardForm.AdminPassword, "*****@*****.**", null, null, true, null, out status); } else { provider.CreateUser(WizardForm.AdminName, WizardForm.AdminPassword, "*****@*****.**", WizardForm.UserQuestion, WizardForm.UserAnswer, true, null, out status); } } } // add creation of providers tables if (WizardForm.IncludeProfilesProvider) { var profileConfig = new ProfileConfig(); profileConfig.Initialize(webConfig); profileConfig.Enabled = true; profileConfig.DefaultProvider = "MySQLProfileProvider"; var options = new Options(); options.AppName = @"\"; options.AutoGenSchema = true; options.ConnectionStringName = WizardForm.ConnectionStringNameForAspNetTables; options.ConnectionString = WizardForm.ConnectionStringForAspNetTables; options.EnableExpireCallback = false; options.ProviderName = "MySQLProfileProvider"; options.WriteExceptionToLog = WizardForm.WriteExceptionsToLog; profileConfig.GenericOptions = options; profileConfig.DefaultProvider = "MySQLProfileProvider"; profileConfig.Save(webConfig); } if (WizardForm.IncludeRoleProvider) { var roleConfig = new RoleConfig(); roleConfig.Initialize(webConfig); roleConfig.Enabled = true; roleConfig.DefaultProvider = "MySQLRoleProvider"; var options = new Options(); options.AppName = @"\"; options.AutoGenSchema = true; options.ConnectionStringName = WizardForm.ConnectionStringNameForAspNetTables; options.ConnectionString = WizardForm.ConnectionStringForAspNetTables; options.EnableExpireCallback = false; options.ProviderName = "MySQLRoleProvider"; options.WriteExceptionToLog = WizardForm.WriteExceptionsToLog; roleConfig.GenericOptions = options; roleConfig.DefaultProvider = "MySQLRoleProvider"; roleConfig.Save(webConfig); } webConfig.Save(); } catch (Exception ex) { MySqlSourceTrace.WriteAppErrorToLog(ex, null, Resources.WebWizard_UserCreationError, true); } } catch (Exception ex) { MySqlSourceTrace.WriteAppErrorToLog(ex, true); } } SendToGeneralOutputWindow("Finished project generation."); WizardForm.Dispose(); }