Beispiel #1
0
 /// <summary>
 /// Cleans the temp table.
 /// </summary>
 public void CleanTempTable()
 {
     try
     {
         using (var dataContext = new PCSDataContext(Utils.Instance.ConnectionString))
         {
             // get list of table need to be clean up by current user
             var strSql  = new StringBuilder();
             var listCmd = string.Format(
                 "SELECT name FROM dbo.sysobjects WHERE xtype = 'U' AND name LIKE 'PRO_IssueMaterialDetail{0}%' AND crdate >= '2010-01-01'",
                 SystemProperty.UserName);
             var tableNames = dataContext.ExecuteQuery <string>(listCmd);
             foreach (var tableName in tableNames)
             {
                 strSql.AppendLine(string.Format("DROP TABLE {0};", tableName));
             }
             if (strSql.Length > 0)
             {
                 dataContext.ExecuteCommand(strSql.ToString());
             }
         }
     }
     catch (Exception ex)
     {
         _logger.Info(string.Format("Could not delete temp table: {0}", ex.Message), ex);
     }
 }