Esempio n. 1
0
 /// <summary>
 /// Adding two columns that were added after we
 /// deployed this batch process (if need be)
 /// </summary>
 private static void VerifyNewBatchProcessColumnsExist()
 {
     using (var dbContext = new CampusLogicContext())
     {
         try
         {
             dbContext.Database.ExecuteSqlCommand(
                 "IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RetryCount' and object_id = OBJECT_ID(N'[dbo].[BatchProcessRecord]'))" +
                 "BEGIN ALTER TABLE [dbo].[BatchProcessRecord]" +
                 "ADD [RetryCount] INT NULL" +
                 ",[RetryUpdatedDate] DATETIME NULL; END");
         }
         catch (Exception ex)
         {
             logger.Error($"There was an issue with validating and/or creating the new columns for the BatchProcessRecord table in LocalDB: {ex}");
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Verifies that the PowerFaidsRecord table exists in LocalDB and if it doesn't, creates it.
 /// </summary>
 private static void VerifyPowerFaidsRecordTableExists()
 {
     using (var dbContext = new CampusLogicContext())
     {
         try
         {
             dbContext.Database.ExecuteSqlCommand(
                 "IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PowerFaidsRecord]'))" +
                 "BEGIN CREATE TABLE[dbo].[PowerFaidsRecord]" +
                 "([Id] INT IDENTITY NOT NULL PRIMARY KEY" +
                 ",[Json] VARCHAR(MAX) NOT NULL" +
                 ",[ProcessGuid] UNIQUEIDENTIFIER NULL)" +
                 "CREATE INDEX ProcessGuid_Event ON [dbo].[PowerFaidsRecord] ([ProcessGuid]) END");
         }
         catch (Exception ex)
         {
             logger.Error($"There was an issue with validating and/or creating the PowerFaidsRecord table in LocalDB: {ex}");
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Verifies that the EventProperty table exists in LocalDB and if it doesn't, creates it.
 /// </summary>
 private static void VerifyEventPropertyTableExists()
 {
     using (var dbContext = new CampusLogicContext())
     {
         try
         {
             dbContext.Database.ExecuteSqlCommand(
                 "IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EventProperty]'))" +
                 "BEGIN CREATE TABLE[dbo].[EventProperty]" +
                 "([Id] INT NOT NULL" +
                 ",[Name] NVARCHAR(200) NOT NULL" +
                 ",[DisplayName] NVARCHAR(200) NOT NULL" +
                 ",[DisplayFormula] NVARCHAR(2000) NOT NULL" +
                 ",CONSTRAINT [PK_EventProperty] PRIMARY KEY ([Id])" +
                 ",CONSTRAINT [AK_DisplayName] UNIQUE([DisplayName])) END");
         }
         catch (Exception ex)
         {
             logger.Error($"There was an issue with validating and/or creating the EventProperty table in LocalDB: {ex}");
         }
     }
 }