Ejemplo n.º 1
0
        public FirstRunWindow(FirstRunViewModel vm)
        {
            InitializeComponent();

            _vm = vm;
            this.DataContext = _vm;
        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

            _vm = new MainWindowViewModel();

            bool openFirstRunWindow = false;

            try
            {
                if (!string.IsNullOrEmpty(Options.CurrentUserOptions.DatabaseFileName))
                {
                    OpenDatabase(Options.CurrentUserOptions.DatabaseFileName, false, true);
                }
                else
                {
                    openFirstRunWindow = true;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                MessageBox.Show("There was a problem opening the database. It may have been moved or deleted.\n\n" +
                                "Please use Open Database to find an existing database, or use New Database to create a new one.",
                                "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            DatabaseGrid.SetFilter(this.FilterListView);
            StateChanged += MainWindowStateChangeRaised;

            this.DataContext = _vm;

            // Sort by ID code when the window first opens
            if (_vm.DarwinDatabase != null)
            {
                DatabaseGrid.Sort("IDCode", ListSortDirection.Ascending);
            }

            Loaded += delegate
            {
                SelectFirstFin();
            };

            if (openFirstRunWindow)
            {
                ContentRendered += delegate
                {
                    var firstRunVM     = new FirstRunViewModel();
                    var firstRunWindow = new FirstRunWindow(firstRunVM);
                    firstRunWindow.Owner = this;
                    firstRunWindow.ShowDialog();
                };
            }
        }
Ejemplo n.º 3
0
        public async Task SkipIntroFeedsFirstRunVM()
        {
            var dumbScreen = new dummyScreen();
            var x          = new FirstRunViewModel(dumbScreen);

            x.SkipDefaultCategories.Execute(null);

            // Make sure that we make it to the proper place
            await TestUtils.SpinWaitAreEqual(typeof(StartPageViewModel), () => dumbScreen.CurrentVM == null?null : dumbScreen.CurrentVM.GetType(), 1000);

            // Make sure no categories have been loaded up.
            Assert.AreEqual(0, CategoryDB.LoadCategories().Count);

            // Make sure nothign got cached.
            var keys = await Blobs.LocalStorage.GetAllKeys();

            Assert.AreEqual(0, keys.Count());
        }
Ejemplo n.º 4
0
        public async Task WantSampleFeedsFirstRunVM()
        {
            // Say yes.
            var dumbScreen = new dummyScreen();
            var x          = new FirstRunViewModel(dumbScreen);

            x.AddDefaultCategories.Execute(null);

            // Make sure that we make it to the proper place
            await TestUtils.SpinWaitAreEqual(typeof(StartPageViewModel), () => dumbScreen.CurrentVM == null?null : dumbScreen.CurrentVM.GetType(), 1000);

            // Make sure no categories have been loaded up.
            Assert.AreNotEqual(1, CategoryDB.LoadCategories().Count);

            // Next, check that the cache db has these guys in there already.
            var keys = await Blobs.LocalStorage.GetAllKeys();

            Assert.AreNotEqual(0, keys.Count());
        }
Ejemplo n.º 5
0
        public ActionResult FirstRun()
        {
            var model = new FirstRunViewModel();

            var checker = new SystemStatusChecker();

            model.SystemStatus = checker.GetSystemStatus();

            // See if there are no connection strings.
            if (WebConfigurationManager.ConnectionStrings.Count == 0)
            {
                model.HasNoConnectionStrings = true;
            }

            // See if the DefaultConnection is empty.
            var defaultConnectionString = WebConfigurationManager.ConnectionStrings["DefaultConnection"];

            if (defaultConnectionString == null)
            {
                model.HasNoConnectionStrings = true;
            }

            return(View(model));
        }
Ejemplo n.º 6
0
        public FirstRunPage()
        {
            InitializeComponent();

            BindingContext = new FirstRunViewModel(Navigation);
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> FirstRun(FirstRunViewModel model)
        {
            // Don't allow this to be run if it has already been run successfully.
            string isConfiguredPath = HttpContext.Server.MapPath(SetupController.IsConfiguredMarkerPath);

            if (System.IO.File.Exists(isConfiguredPath))
            {
                throw new HttpException(404, "Not found");
            }

            var checker = new SystemStatusChecker();

            using (var db = ApplicationDbContext.Create())
            {
                try
                {
                    // Create the database if needed.
                    if (!db.Database.Exists())
                    {
                        db.Database.Create();
                    }
                }
                catch (Exception ex)
                {
                    model.Message      = ex.Message;
                    model.SystemStatus = checker.GetSystemStatus();
                    return(View(model));
                }

                try
                {
                    // Set the site-wide settings.
                    // Boo lookup instead of add-or-update.
                    var settingsRow = db.Settings.Where(x => x.Name == AdminController.SiteSettingsName).FirstOrDefault();
                    if (settingsRow == null)
                    {
                        settingsRow      = new Setting();
                        settingsRow.Name = AdminController.SiteSettingsName;
                        db.Settings.Add(settingsRow);
                    }

                    var settings = new SiteSettings();
                    settings.SiteName = model.SiteName;

                    settingsRow.Value = JsonConvert.SerializeObject(settings);

                    // Create the organization, if it does not already exist.
                    var org = db.Organizations.Where(x => x.Name == model.OrganizationName).FirstOrDefault();
                    if (org == null)
                    {
                        string host = Request.Headers["Host"];
                        org = new Organization()
                        {
                            Id       = Guid.NewGuid(),
                            Name     = model.OrganizationName,
                            AgencyID = model.AgencyId,
                            Hostname = host
                        };

                        db.Organizations.Add(org);
                    }

                    // Create the user.
                    var userManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>();
                    var user        = await UserController.CreateUser(model.UserName, model.Password, model.FirstName, model.LastName,
                                                                      true,
                                                                      org,
                                                                      userManager,
                                                                      ModelState,
                                                                      db);

                    if (user == null)
                    {
                        model.Message      = "The user could not be created. Please try again.";
                        model.SystemStatus = checker.GetSystemStatus();
                        return(View(model));
                    }

                    db.SaveChanges();

                    // Indicate that setup has been run.
                    System.IO.File.WriteAllText(isConfiguredPath, DateTime.UtcNow.ToString());

                    return(RedirectToAction("Index", "Admin"));
                }
                catch (Exception ex)
                {
                    model.Message      = ex.Message;
                    model.SystemStatus = checker.GetSystemStatus();
                    return(View(model));
                }
            }
        }
Ejemplo n.º 8
0
 public FirstRunPage()
 {
     InitializeComponent();
     BindingContext = _viewModel = App.Current.Services.GetService <FirstRunViewModel>();
 }
 public FirstRun()
 {
     InitializeComponent();
     DataContext = new FirstRunViewModel();
 }
Ejemplo n.º 10
0
 public void CTorFirstRunVM()
 {
     var x = new FirstRunViewModel(null);
 }