Beispiel #1
0
        private async void barButtonAdd_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                if (applicationControl != null)
                {
                    await applicationControl.NewItemButtonClicked();
                }
                else
                {
                    SettingsApplication newApplication = new SettingsApplication();

                    ApplicationEditForm form = new ApplicationEditForm(newApplication, settingsManager);

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        if (await settingsManager.CreateApplicationAsync(newApplication.Name, newApplication.Description))
                        {
                            await GetApplications();
                        }
                    }
                }
            }
            catch (SettingsException ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private async Task <bool> ValidateInputAsync()
        {
            if (string.IsNullOrWhiteSpace(textName.Text))
            {
                textName.ErrorText = "Enter a Name";
                return(false);
            }
            else
            {
                if (application == null)
                {
                    application = new SettingsApplication();
                }

                if (!string.Equals(application.Name, textName.Text, StringComparison.CurrentCultureIgnoreCase) && await settingsManager.ApplicationExists(textName.Text))
                {
                    textName.ErrorText = "Application name already in use.";
                    return(false);
                }

                application.Name        = textName.Text.Trim().Replace("  ", " ");
                application.Description = textDescription.Text.Trim().Replace("  ", " ");

                return(true);
            }
        }
Beispiel #3
0
        private async void barButtonItemEdit_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                if (applicationControl == null)
                {
                    var application = gridViewApplications.GetRow(gridViewApplications.FocusedRowHandle) as SettingsApplication;

                    if (application != null)
                    {
                        SettingsApplication editApplication = new SettingsApplication();
                        editApplication.Name        = application.Name;
                        editApplication.Description = application.Description;
                        ApplicationEditForm form = new ApplicationEditForm(editApplication, settingsManager);

                        if (form.ShowDialog() == DialogResult.OK)
                        {
                            if (await settingsManager.UpdateApplicationAsync(application.Name, editApplication.Name, editApplication.Description))
                            {
                                application.Name        = editApplication.Name;
                                application.Description = editApplication.Description;
                            }
                        }
                    }
                }
                else
                {
                    await applicationControl.EditButtonClicked();
                }
            }
            catch (SettingsException ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
        private async Task LoadApplication()
        {
            application = await settingsManager.GetApplication(applicationName);

            highVersion = application.Versions.Max(v => v.Version);

            gridControlVersions.DataSource = application.Versions;
        }
        public ApplicationEditForm(SettingsApplication application, SettingsAPIClient.SettingsManager settingsManager)
        {
            InitializeComponent();
            this.settingsManager = settingsManager;
            this.application     = application;

            if (application != null)
            {
                textName.Text        = application.Name;
                textDescription.Text = application.Description;
            }
        }
        public async Task CreateApplicationMasterAsync()
        {
            settingsManager = new SettingsManager(_url, _masterKey);

            string applicationName = Util.RandomString();
            string description     = Util.RandomString();

            await settingsManager.CreateApplicationAsync(applicationName, description);

            currentApplication = await settingsManager.GetApplication(applicationName);

            Assert.AreEqual(currentApplication.Name, applicationName);
            Assert.AreEqual(currentApplication.Description, description);


            currentApplicationName = currentApplication.Name;
        }
        public async Task CreateApplicationVersionMasterAsync()
        {
            await CreateApplicationMasterAsync();

            try
            {
                bool isCreated = await settingsManager.CreateApplicationVersionAsync(currentApplicationName, 2);

                currentApplication = await settingsManager.GetApplication(currentApplicationName);

                Assert.IsTrue(isCreated);
                Assert.IsTrue(currentApplication.Versions.Count == 2);
            }
            catch (SettingsException ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        private async Task GetApplication(string applicationName)
        {
            try
            {
                OnShowProgress();

                Application = await settingsManager.GetApplication(applicationName);

                this.CurrentVersion = Application.Versions.OrderByDescending(v => v.Created).First();

                directoryBinding = new BindingList <SettingsDirectory>(Application.Directories);

                gridControlDirectories.DataSource = directoryBinding;
            }
            finally
            {
                OnHideProgress();
            }
        }
Beispiel #9
0
        public IActionResult AppSettings()
        {
            var profile = GetProfile();
            var storage = new BlogStorage("");

            var model = new SettingsApplication
            {
                Profile      = profile,
                BlogThemes   = storage.GetThemes(),
                Title        = ApplicationSettings.Title,
                Description  = ApplicationSettings.Description,
                BlogTheme    = ApplicationSettings.BlogTheme,
                ItemsPerPage = ApplicationSettings.ItemsPerPage,
                Logo         = ApplicationSettings.ProfileLogo,
                Avatar       = ApplicationSettings.ProfileAvatar,
                Image        = ApplicationSettings.ProfileImage,
                PostImage    = ApplicationSettings.PostImage,
                CustomFields = _db.CustomFields.GetCustomFields(CustomType.Application, 0).Result
            };

            return(View(_theme + "AppSettings.cshtml", model));
        }
Beispiel #10
0
        public IActionResult AppSettings(SettingsApplication model)
        {
            var storage = new BlogStorage("");

            model.BlogThemes = storage.GetThemes();
            model.Profile    = GetProfile();

            if (ModelState.IsValid)
            {
                _db.CustomFields.SetCustomField(CustomType.Application, 0, "Title", model.Title);
                ApplicationSettings.Title = model.Title;
                _db.CustomFields.SetCustomField(CustomType.Application, 0, "Description", model.Description);
                ApplicationSettings.Description = model.Description;
                _db.CustomFields.SetCustomField(CustomType.Application, 0, "ItemsPerPage", model.ItemsPerPage.ToString());
                ApplicationSettings.ItemsPerPage = model.ItemsPerPage;

                _db.CustomFields.SetCustomField(CustomType.Application, 0, "ProfileLogo", model.Logo);
                ApplicationSettings.ProfileLogo = model.Logo;
                _db.CustomFields.SetCustomField(CustomType.Application, 0, "ProfileAvatar", model.Avatar);
                ApplicationSettings.ProfileAvatar = model.Avatar;
                _db.CustomFields.SetCustomField(CustomType.Application, 0, "ProfileImage", model.Image);
                ApplicationSettings.ProfileImage = model.Image;
                _db.CustomFields.SetCustomField(CustomType.Application, 0, "PostImage", model.PostImage);
                ApplicationSettings.PostImage = model.PostImage;

                _db.CustomFields.SetCustomField(CustomType.Application, 0, "BlogTheme", model.BlogTheme);

                _db.CustomFields.SetCustomField(CustomType.Application, 0, Constants.SendGridApiKey, model.CustomFields[Constants.SendGridApiKey]);

                model.Profile.BlogTheme       = model.BlogTheme;
                ApplicationSettings.BlogTheme = model.BlogTheme;

                _db.Complete();

                ViewBag.Message = "Updated";
            }
            return(View(_theme + "AppSettings.cshtml", model));
        }