Inheritance: JobTaskBase
Esempio n. 1
0
        public void SqlJobTaskShouldExecuteSqlStatements()
        {
            var conn = new SqlConnection {ConnectionString = Settings.Default.ConnectionString};
            conn.Open();

            var sqlJobTask = new SqlJobTask("test", "select 'executing'") {Connection = conn};
            sqlJobTask.Execute();

            conn.Close();
        }
Esempio n. 2
0
        private void AddSqlJobTasksFromResourcesIfAny()
        {
            var allResourceNames = GetType().Assembly.GetManifestResourceNames();
            Array.Sort(allResourceNames);

            IEnumerable<string> sqlResourceNames = GetSqlFileNames(allResourceNames);

            foreach (var resourceName in sqlResourceNames)
            {
                var sqlJobTask = new SqlJobTask(resourceName, GetSqlScript(resourceName))
                                     {UndoSql = GetUndoSqlScriptIfFound(allResourceNames, resourceName)};

                JobTasks.Add(sqlJobTask);
            }
        }
Esempio n. 3
0
        private void ApplyParameters(SqlJobTask sqlCmd)
        {
            var sqlParameters = new Dictionary<string, object>();
            foreach (var parameter in Parameters)
            {
                if (CurlyParameterPattern.IsMatch(parameter.Key))
                {
                    sqlCmd.Sql = sqlCmd.Sql.Replace(parameter.Key, parameter.Value.ToString());
                    sqlCmd.UndoSql = sqlCmd.UndoSql.Replace(parameter.Key, parameter.Value.ToString());
                }
                else
                    sqlParameters.Add(parameter.Key, parameter.Value);
            }

            sqlCmd.Parameters = sqlParameters;
        }