Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Data.SqlClient;
- namespace AspnetRegsqlHelper {
- public sealed class AspNetCommands {
- public void BuildDbConnection(CommandLineBuilder cb,SqlConnectionStringBuilder sqlConn) {
- BuildDbConnection(cb,sqlConn,null);
- }
- public static void BuildDbConnectionNoDb(CommandLineBuilder cb,SqlConnectionStringBuilder sqlConn) {
- cb.Add(AspNetParameters.ServerName,sqlConn.DataSource);
- if(sqlConn.IntegratedSecurity)
- cb.Add(AspNetParameters.UseWindowsCredintials);
- else {
- cb.Add(AspNetParameters.UserName,sqlConn.UserID);
- cb.Add(AspNetParameters.Password,sqlConn.Password);
- }
- cb.Add(AspNetParameters.DatabaseName,sqlConn.InitialCatalog);
- }
- public static void BuildDbConnection(CommandLineBuilder cb,SqlConnectionStringBuilder sqlConn,string exportFileName) {
- if(!exportFileName.IsNullOrEmptyTrim()) {
- exportFileName = exportFileName.Trim("\"".ToCharArray());
- exportFileName = "\"" + exportFileName + "\"";
- cb.Add(AspNetParameters.SQLExportFileName,exportFileName);
- }
- cb.Add(AspNetParameters.ServerName,sqlConn.DataSource);
- cb.Add(AspNetParameters.DatabaseName,sqlConn.InitialCatalog);
- if(sqlConn.IntegratedSecurity)
- cb.Add(AspNetParameters.UseWindowsCredintials);
- else {
- cb.Add(AspNetParameters.UserName,sqlConn.UserID);
- cb.Add(AspNetParameters.Password,sqlConn.Password);
- }
- }
- }
- #region AspNetParameters
- public class AspNetParameters {
- public static string HelpPrintOut { get; set; }
- public static string Wizard { get; set; }
- public static string ConnectionString { get; set; }
- public static string ServerName { get; set; }
- public static string UserName { get; set; }
- public static string Password { get; set; }
- public static string UseWindowsCredintials { get; set; }
- public static string SQLExportFileName { get; set; }
- public static string AddService { get; set; }
- public static string RemoveService { get; set; }
- public static string QuietMode { get; set; }
- public static string DatabaseName { get; set; }
- public static AspNetSQLCacheDependencyParameters SQLCacheDependency { get; set; }
- public static AspNetSessionStateParameters SessionState { get; set; }
- static AspNetParameters() {
- HelpPrintOut = "?";
- Wizard = "W";
- ConnectionString = "C";
- ServerName = "S";
- DatabaseName = "d";
- UserName = "U";
- Password = "P";
- UseWindowsCredintials = "E";
- SQLExportFileName = "sqlexportonly";
- QuietMode = "Q";
- AddService = "A";
- RemoveService = "R";
- SQLCacheDependency = new AspNetSQLCacheDependencyParameters();
- SessionState = new AspNetSessionStateParameters();
- }
- }
- public class AspNetSessionStateParameters {
- public static string DatabaseName { get; set; }
- public static string AddSupport { get; set; }
- public static string RemoveSupport { get; set; }
- public static AspNetSessionStateTypeParameters SessionState { get; set; }
- static AspNetSessionStateParameters() {
- DatabaseName = "d";
- AddSupport = "ssadd";
- RemoveSupport = "ssremove";
- SessionState = new AspNetSessionStateTypeParameters();
- }
- }
- public class AspNetSessionStateTypeParameters {
- public static string SessionStateType { get; set; }
- public static string TemporaryState { get; set; }
- public static string PersistedState { get; set; }
- public static string CustomState { get; set; }
- static AspNetSessionStateTypeParameters() {
- SessionStateType = "sstype";
- TemporaryState = "sstype t";
- PersistedState = "sstype p";
- CustomState = "sstype c";
- }
- }
- public class AspNetSQLCacheDependencyParameters {
- public static string DatabaseName { get; set; }
- public static string TableName { get; set; }
- public static string EnableDatabase { get; set; }
- public static string DisableDatabase { get; set; }
- public static string EnableTable { get; set; }
- public static string DisableTable { get; set; }
- public static string ListEnableTables { get; set; }
- static AspNetSQLCacheDependencyParameters() {
- DatabaseName = "d";
- TableName = "t";
- EnableDatabase = "ed";
- DisableDatabase = "dd";
- EnableTable = "et";
- DisableTable = "dt";
- ListEnableTables = "lt";
- }
- }
- public class AspNetServicesParameters {
- public static string All { get; set; }
- public static string Membership { get; set; }
- public static string RoleManager { get; set; }
- public static string Profile { get; set; }
- public static string WebPartsPersonalization { get; set; }
- public static string WebEvents { get; set; }
- static AspNetServicesParameters() {
- All = "all";
- Membership = "m";
- RoleManager = "r";
- Profile = "p";
- WebPartsPersonalization = "c";
- WebEvents = "w";
- }
- }
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment