andrew4582

AspNetCommands

Mar 19th, 2012
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.58 KB | None | 0 0
  1. using System;
  2. using System.Data.SqlClient;
  3.  
  4.  
  5. namespace AspnetRegsqlHelper {
  6.  
  7.     public sealed class AspNetCommands {
  8.        
  9.         public void BuildDbConnection(CommandLineBuilder cb,SqlConnectionStringBuilder sqlConn) {
  10.             BuildDbConnection(cb,sqlConn,null);
  11.         }
  12.         public static void BuildDbConnectionNoDb(CommandLineBuilder cb,SqlConnectionStringBuilder sqlConn) {
  13.             cb.Add(AspNetParameters.ServerName,sqlConn.DataSource);
  14.             if(sqlConn.IntegratedSecurity)
  15.                 cb.Add(AspNetParameters.UseWindowsCredintials);
  16.             else {
  17.                 cb.Add(AspNetParameters.UserName,sqlConn.UserID);
  18.                 cb.Add(AspNetParameters.Password,sqlConn.Password);
  19.             }
  20.             cb.Add(AspNetParameters.DatabaseName,sqlConn.InitialCatalog);
  21.         }
  22.         public static void BuildDbConnection(CommandLineBuilder cb,SqlConnectionStringBuilder sqlConn,string exportFileName) {
  23.             if(!exportFileName.IsNullOrEmptyTrim()) {
  24.                 exportFileName = exportFileName.Trim("\"".ToCharArray());
  25.                 exportFileName = "\"" + exportFileName + "\"";
  26.                 cb.Add(AspNetParameters.SQLExportFileName,exportFileName);
  27.             }
  28.             cb.Add(AspNetParameters.ServerName,sqlConn.DataSource);
  29.             cb.Add(AspNetParameters.DatabaseName,sqlConn.InitialCatalog);
  30.             if(sqlConn.IntegratedSecurity)
  31.                 cb.Add(AspNetParameters.UseWindowsCredintials);
  32.             else {
  33.                 cb.Add(AspNetParameters.UserName,sqlConn.UserID);
  34.                 cb.Add(AspNetParameters.Password,sqlConn.Password);
  35.             }
  36.         }
  37.     }
  38.  
  39.     #region AspNetParameters
  40.     public class AspNetParameters {
  41.         public static string HelpPrintOut { get; set; }
  42.         public static string Wizard { get; set; }
  43.         public static string ConnectionString { get; set; }
  44.         public static string ServerName { get; set; }
  45.         public static string UserName { get; set; }
  46.         public static string Password { get; set; }
  47.         public static string UseWindowsCredintials { get; set; }
  48.         public static string SQLExportFileName { get; set; }
  49.         public static string AddService { get; set; }
  50.         public static string RemoveService { get; set; }
  51.         public static string QuietMode { get; set; }
  52.         public static string DatabaseName { get; set; }
  53.         public static AspNetSQLCacheDependencyParameters SQLCacheDependency { get; set; }
  54.         public static AspNetSessionStateParameters SessionState { get; set; }
  55.         static AspNetParameters() {
  56.             HelpPrintOut = "?";
  57.             Wizard = "W";
  58.             ConnectionString = "C";
  59.             ServerName = "S";
  60.             DatabaseName = "d";
  61.             UserName = "U";
  62.             Password = "P";
  63.             UseWindowsCredintials = "E";
  64.             SQLExportFileName = "sqlexportonly";
  65.             QuietMode = "Q";
  66.             AddService = "A";
  67.             RemoveService = "R";
  68.             SQLCacheDependency = new AspNetSQLCacheDependencyParameters();
  69.             SessionState = new AspNetSessionStateParameters();
  70.         }
  71.     }
  72.     public class AspNetSessionStateParameters {
  73.         public static string DatabaseName { get; set; }
  74.         public static string AddSupport { get; set; }
  75.         public static string RemoveSupport { get; set; }
  76.         public static AspNetSessionStateTypeParameters SessionState { get; set; }
  77.         static AspNetSessionStateParameters() {
  78.             DatabaseName = "d";
  79.             AddSupport = "ssadd";
  80.             RemoveSupport = "ssremove";
  81.             SessionState = new AspNetSessionStateTypeParameters();
  82.         }
  83.     }
  84.     public class AspNetSessionStateTypeParameters {
  85.         public static string SessionStateType { get; set; }
  86.         public static string TemporaryState { get; set; }
  87.         public static string PersistedState { get; set; }
  88.         public static string CustomState { get; set; }
  89.         static AspNetSessionStateTypeParameters() {
  90.             SessionStateType = "sstype";
  91.             TemporaryState = "sstype t";
  92.             PersistedState = "sstype p";
  93.             CustomState = "sstype c";
  94.         }
  95.     }
  96.     public class AspNetSQLCacheDependencyParameters {
  97.         public static string DatabaseName { get; set; }
  98.         public static string TableName { get; set; }
  99.         public static string EnableDatabase { get; set; }
  100.         public static string DisableDatabase { get; set; }
  101.         public static string EnableTable { get; set; }
  102.         public static string DisableTable { get; set; }
  103.         public static string ListEnableTables { get; set; }
  104.         static AspNetSQLCacheDependencyParameters() {
  105.             DatabaseName = "d";
  106.             TableName = "t";
  107.             EnableDatabase = "ed";
  108.             DisableDatabase = "dd";
  109.             EnableTable = "et";
  110.             DisableTable = "dt";
  111.             ListEnableTables = "lt";
  112.         }
  113.     }
  114.     public class AspNetServicesParameters {
  115.         public static string All { get; set; }
  116.         public static string Membership { get; set; }
  117.         public static string RoleManager { get; set; }
  118.         public static string Profile { get; set; }
  119.         public static string WebPartsPersonalization { get; set; }
  120.         public static string WebEvents { get; set; }
  121.         static AspNetServicesParameters() {
  122.             All = "all";
  123.             Membership = "m";
  124.             RoleManager = "r";
  125.             Profile = "p";
  126.             WebPartsPersonalization = "c";
  127.             WebEvents = "w";
  128.         }
  129.     }
  130.     #endregion
  131. }
Advertisement
Add Comment
Please, Sign In to add comment