示例#1
0
        protected override void RunCore(Args args)
        {
            var environmentName = args.Arguments.Skip(1).FirstOrDefault();
            var extractions = ExtractionInstructions.Parse(args.Arguments.Skip(2).ToArray());

            if (environmentName == null)
                throw new Exception("You need to specify an environment");

            var environment = Plans.Environment(environmentName);

            using (var context = new DataContext(environment.ConnectionString))
            using (var scope = new TransactionScope())
            {
                var metabase = new ContextMetabase(context);

                foreach (var extraction in extractions)
                    extraction.Update(metabase, Plans);

                var extract = XElement.Load(ExtractFile);

                foreach (var extraction in extractions)
                    extraction.Insert(metabase, extract);

                scope.Complete();
            }
        }
示例#2
0
文件: Args.cs 项目: baralong/forklift
        public static Args Parse(string[] args)
        {
            var parsedArgs = new Args();

            var counter = 0;
            while (counter < args.Length)
            {
                var arg = args[counter];
                if (arg.StartsWith("-"))
                {
                    var name = arg.Substring(1);
                    counter += 1;
                    if (counter >= args.Length)
                        throw new Exception("No value provided for option " + name);
                    var value = args[counter];
                    parsedArgs._options.Add(name, value);
                }
                else
                {
                    parsedArgs._arguments.Add(arg);
                }
                counter += 1;
            }

            return parsedArgs;
        }
示例#3
0
        protected override void RunCore(Args args)
        {
            var environmentName = args.Arguments.Skip(1).FirstOrDefault();
            var extractions = ExtractionInstructions.Parse(args.Arguments.Skip(2).ToArray());

            if (environmentName == null)
                throw new Exception("You need to specify an environment");

            var environment = Plans.Environment(environmentName);

            using (var context = new DataContext(environment.ConnectionString))
            {
                var metabase = new ContextMetabase(context);

                foreach (var extraction in extractions)
                    extraction.Update(metabase, Plans);

                new XElement("Extract",
                             extractions.Select(x => x.Run(metabase))
                    ).Save(ExtractFile);
            }
        }