Ejemplo n.º 1
0
        public ProfileViewModel(ILog log, ProfilesViewModel profilesVM, ProfileInfo profileInfo)
        {
            _log = log;

            ProfilesVM  = profilesVM;
            ProfileInfo = profileInfo;

            Sql = new Binding <string>(() => ProfileInfo.GetSqlAsync().Result); // TODO: Make nicer

            RunProfileCommand = new RelayCommand(async param => await RunProfileAsync(), param => !ProfilesVM.ProjectVM.IsReadOnly.Value);
            SaveToFileCommand = new RelayCommand(param => SaveToFile());
        }
Ejemplo n.º 2
0
        public ProjectViewModel(ILog log, RootViewModel root, ProjectConfiguration configProject)
        {
            _log = log;

            RootVM = root;

            DatabaseTypes = new ObservableCollection <DatabaseTypeViewModel>(DatabaseTypeViewModel.GetDatabaseTypes());

            Id = configProject.Id;

            IsNew                  = new Binding <bool>();
            IsInitialized          = new Binding <bool>();
            IsReadOnly             = new Binding <bool>(configProject.IsReadOnly);
            IsLoadedOnStart        = new Binding <bool>(configProject.IsLoadedOnStart);
            IsInProgress           = new Binding <bool>();
            IsNodeExpanded.Value   = configProject.IsExpanded;
            PendingMigrationsCount = new Binding <int>();
            HasPendingMigrations   = new Binding <bool>();
            MigrationsCount        = new Binding <int>();
            ProfilesCount          = new Binding <int>();

            Name                 = new Binding <string>(configProject.Name);
            ConnectionString     = new Binding <string>(configProject.ConnectionString);
            PathToMigrationsFile = new Binding <string>(configProject.DllPath);

            DatabaseType = new Binding <DatabaseTypeViewModel>();
            if (configProject.DatabaseType.HasValue)
            {
                DatabaseType.Value = DatabaseTypes.FirstOrDefault(d => d.Value == configProject.DatabaseType);
            }

            Tags = new Binding <string>();
            if (configProject.Tags != null)
            {
                Tags.Value = string.Join(" ", configProject.Tags);
            }

            Profile = new Binding <string>(configProject.Profile);

            FullUpdateCommand     = new RelayCommand(async param => await FullUpdateAsync(), param => !IsReadOnly.Value && IsInitialized.Value);
            MigrationsOnlyCommand = new RelayCommand(async param => await RunMigrationsAsync(), param => !IsReadOnly.Value && IsInitialized.Value);
            ProfilesOnlyCommand   = new RelayCommand(async param => await RunProfilesAsync(), param => !IsReadOnly.Value && IsInitialized.Value);

            BrowsePathToMigrationsFileCommand = new RelayCommand(param => BrowsePathToMigrationsDll());
            InitializeProjectCommand          = new RelayCommand(async param => await InitializeAsync());
            CloneProjectCommand     = new RelayCommand(param => Clone());
            RecreateDatabaseCommand = new RelayCommand(async param => await RecreateDatabaseAsync(), param => !IsReadOnly.Value && IsInitialized.Value);
            DeleteProjectCommand    = new RelayCommand(async param => await DeleteAsync(), param => !IsReadOnly.Value);

            ProjectInfo = new ProjectInfo(null, null, null, RootVM.OutputVM);

            // Migrations
            MigrationsVM = new MigrationsViewModel(_log, this);
            MigrationsVM.IsNodeExpanded.Value = configProject.IsMigrationsExpanded;
            Add(MigrationsVM);

            // Profiles
            ProfilesVM = new ProfilesViewModel(_log, this);
            ProfilesVM.IsNodeExpanded.Value = configProject.IsProfilesExpanded;
            Add(ProfilesVM);
        }