상속: JobTaskBase
예제 #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();
        }
예제 #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);
            }
        }
예제 #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;
        }