Esempio n. 1
0
 private void CreateDatabase()
 {
     try
     {
         string userDomainName = Environment.UserDomainName;
         this.databaseServerName = userDomainName.Substring(0, userDomainName.IndexOf("dom", StringComparison.InvariantCultureIgnoreCase));
         string connectionString = string.Format("Server={0};Trusted_Connection=Yes;", this.databaseServerName);
         using (SqlConnection sqlConnection = new SqlConnection(connectionString))
         {
             using (DataContext dataContext = new DataContext(sqlConnection))
             {
                 Table <TempDatabase.SysDatabaseTable>      table  = dataContext.GetTable <TempDatabase.SysDatabaseTable>();
                 IQueryable <TempDatabase.SysDatabaseTable> source = from db in table
                                                                     where db.Name == "ComplianceJobTempDB"
                                                                     select db;
                 int num = source.Count <TempDatabase.SysDatabaseTable>();
                 if (num <= 0)
                 {
                     using (TempDatabase.ComplianceJobStore complianceJobStore = new TempDatabase.ComplianceJobStore(sqlConnection))
                     {
                         complianceJobStore.CreateDatabase();
                     }
                 }
             }
         }
     }
     catch (SqlException ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
 internal void InsertIntoTable <TTable, TData>(TData data) where TTable : TempDatabase.IComplianceTable <TData>, new()
 {
     try
     {
         using (SqlConnection sqlConnection = new SqlConnection(this.GetConnectionString()))
         {
             using (TempDatabase.ComplianceJobStore complianceJobStore = new TempDatabase.ComplianceJobStore(sqlConnection))
             {
                 TTable ttable = (default(TTable) == null) ? Activator.CreateInstance <TTable>() : default(TTable);
                 ttable.SetRowData(data);
                 ttable.InsertRow(complianceJobStore);
                 complianceJobStore.SubmitChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
 public void InsertRow(TempDatabase.ComplianceJobStore store)
 {
     store.Tasks.InsertOnSubmit(this);
 }