Esempio n. 1
0
        public Dictionary <string, List <string> > GetMigrationNames(FindMigrationSubtypeParams commandParams)
        {
            var items = new Dictionary <string, List <string> >();

            var result = runMigratorProcess(commandParams);

            if (!string.IsNullOrEmpty(result.error))
            {
#pragma warning disable VSTHRD110 // Observe result of async calls
                _messageBoxService.ShowErrorMessage(result.error);
#pragma warning restore VSTHRD110 // Observe result of async calls
            }

            if (result.exitCode == ExitCode.Success && !string.IsNullOrWhiteSpace(result.output))
            {
                var groups = result.output.Split('|').Where(n => !string.IsNullOrEmpty(n));
                foreach (var group in groups)
                {
                    var names = group.Split(';').Where(n => !string.IsNullOrEmpty(n));
                    if (names != null && names.Count() > 1)
                    {
                        items[names.First()] = names.Skip(1).ToList();
                    }
                }
            }
            else if (result.exitCode == ExitCode.Exception && !string.IsNullOrWhiteSpace(result.output))
            {
#pragma warning disable VSTHRD110 // Observe result of async calls
                _messageBoxService.ShowErrorMessage(result.output);
#pragma warning restore VSTHRD110 // Observe result of async calls
            }

            return(items);
        }
Esempio n. 2
0
        static int Main(string[] args)
        {
            if (args == null || args.Length == 0)
            {
                return(ExitCode.InvalidArguments);
            }

            try
            {
                if (args[0] == CommandType.AddMigration)
                {
                    var commandParams = AddMigrationParams.FromArgumentsArray(args);
                    return(new AddMigrationExecutor().Run(commandParams));
                }
                else if (args[0] == CommandType.ScriptMigration)
                {
                    var commandParams = ScriptMigrationParams.FromArgumentsArray(args);
                    return(new ScriptMigrationExecutor().Run(commandParams));
                }
                else if (args[0] == CommandType.FindDbContextSubtypes)
                {
                    var commandParams = FindDbContextSubtypeParams.FromArgumentsArray(args);
                    var types         = TypeFinder.GetDbContextTypeFullNamesFromAssebly(commandParams.AssemblyFileName);
                    return(writeResult(types));
                }
                else if (args[0] == CommandType.FindMigrationSubtypes)
                {
                    var commandParams = FindMigrationSubtypeParams.FromArgumentsArray(args);
                    var types         = TypeFinder.GetMigrationByDbContextFromAssebly(commandParams.AssemblyFileName);
                    return(writeResult(types));
                }
            }
            catch (InvalidOperationException)
            {
                return(ExitCode.CanNotFindDbContext);
            }
            catch (FileNotFoundException e)
            {
                LogException(e);
                return(ExitCode.CanNotFindFile);
            }
            catch (ArgumentException e)
            {
                LogException(e);
                return(ExitCode.InvalidArguments);
            }
            catch (Exception e)
            {
                LogException(e);
                return(ExitCode.Exception);
            }

            return(ExitCode.InvalidCommand);
        }