public static GuidsConfig ToGuidsConfig(this AppConfigModel appConfig) { return(new GuidsConfig() { Guids = appConfig.Guids.ToConfig() }); }
// //==================================================================================================== /// <summary> /// coreClass constructor for a web request/response environment. coreClass is the primary object internally, created by cp. /// </summary> public CoreController(CPClass cp, string applicationName, System.Web.HttpContext httpContext) { try { this.cpParent = cp; this.cpParent.core = this; _mockNow = null; LogController.log(this, "CoreController constructor-4, enter", BaseClasses.CPLogBaseClass.LogLevel.Trace); // metaDataDictionary = new Dictionary <string, Models.Domain.ContentMetadataModel>(); tableSchemaDictionary = null; // // -- create default auth objects for non-user methods, or until auth is available session = new SessionController(this); // serverConfig = ServerConfigModel.getObject(this); serverConfig.defaultDataSourceType = ServerConfigBaseModel.DataSourceTypeEnum.sqlServer; appConfig = AppConfigModel.getObject(this, serverConfig, applicationName); if (appConfig != null) { webServer.initWebContext(httpContext); constructorInitialize(true); } LogController.log(this, "CoreController constructor-4, exit", BaseClasses.CPLogBaseClass.LogLevel.Trace); } catch (Exception ex) { LogController.logLocalOnly("CoreController constructor-4, exception [" + ex.ToString() + "]", BaseClasses.CPLogBaseClass.LogLevel.Fatal); throw; } }
public async Task AddAssets(Guid projectId, IReadOnlyCollection <string> fileDirs) { var config = await _configuration.GetConfigurationAsync(); var projects = config.Projects.ToModel().ToList(); var projectIdx = projects.FindIndex(p => p.Id == projectId); var project = projects[projectIdx]; var items = project.Items.ToList(); foreach (var item in fileDirs) { var partialPath = item.Replace(project.Path, ""); var contains = project.Items.Any(i => i.Name == Path.GetFileName(item) && i.Path == partialPath); if (contains) { continue; } items.Add(new ProjectItemModel(Guid.NewGuid(), Path.GetFileName(item), partialPath)); } var newProject = new ProjectModel(project.Id, project.Name, project.ModIndex, project.Path, project.OutputPath, items); projects[projectIdx] = newProject; var newConfig = new AppConfigModel(projects, config.DefaultProject, (HydroneerVersion)config.HydroneerVersion, config.Guids.ToModel()); await _configuration.SaveConfigurationAsync(newConfig); }
/// <summary> /// Configures the services /// </summary> /// <remarks> /// This method gets called by the runtime. Use this method to add services to the container. /// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 /// </remarks> public void ConfigureServices(IServiceCollection services) { var appConfig = new AppConfigModel(); _config.Bind(appConfig); //makes settings from appsettings.json, user-secrets etc. available in this method services.Configure <AppConfigModel>(_config); //makes AppConfigModel injectable as Microsoft.Extensions.Options.IOptions<AppConfigModel> #pragma warning disable IDE0022 // Use expression body for methods services.AddUmbraco(_env, _config) .AddBackOffice() .AddWebsite() .AddComposers() .Build(); #pragma warning restore IDE0022 // Use expression body for methods services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Backend", Version = "v1" }); }); services.AddCors(o => o.AddPolicy(name: CorsAllowedOrigins, builder => { builder.WithOrigins(appConfig.AllowedHosts.ToArray()); }) ); }
// //==================================================================================================== /// <summary> /// coreClass constructor for app, non-Internet use. coreClass is the primary object internally, created by cp. /// </summary> /// <param name="cp"></param> /// <remarks></remarks> public CoreController(CPClass cp, string applicationName, ServerConfigModel serverConfig) { try { cpParent = cp; deleteSessionOnExit = true; _mockNow = null; LogController.log(this, "CoreController constructor-2, enter", BaseClasses.CPLogBaseClass.LogLevel.Trace); // metaDataDictionary = new Dictionary <string, Models.Domain.ContentMetadataModel>(); tableSchemaDictionary = null; // // -- create default auth objects for non-user methods, or until auth is available session = new SessionController(this); // this.serverConfig = serverConfig; this.serverConfig.defaultDataSourceType = ServerConfigBaseModel.DataSourceTypeEnum.sqlServer; appConfig = AppConfigModel.getObject(this, serverConfig, applicationName); appConfig.appStatus = AppConfigModel.AppStatusEnum.ok; webServer.iisContext = null; constructorInitialize(false); LogController.log(this, "CoreController constructor-2, exit", BaseClasses.CPLogBaseClass.LogLevel.Trace); } catch (Exception ex) { LogController.logLocalOnly("CoreController constructor-2, exception [" + ex.ToString() + "]", BaseClasses.CPLogBaseClass.LogLevel.Fatal); throw; } }
public async Task SaveGuids(IReadOnlyCollection <GuidItemModel> guids) { var config = await _configuration.GetConfigurationAsync(); var newConfig = new AppConfigModel(config.Projects.ToModel(), config.DefaultProject, (HydroneerVersion)config.HydroneerVersion, guids); await _configuration.SaveConfigurationAsync(newConfig); }
public async Task SetGameVersion(HydroneerVersion hydroneerVersion) { var config = await _configuration.GetConfigurationAsync(); var newConfig = new AppConfigModel(config.Projects.ToModel(), config.DefaultProject, hydroneerVersion, config.Guids.ToModel()); await _configuration.SaveConfigurationAsync(newConfig); }
public static GeneralConfig ToGeneralConfig(this AppConfigModel appConfig) { return(new GeneralConfig() { Projects = appConfig.Projects.ToConfig(), DefaultProject = appConfig.DefaultProject, HydroneerVersion = (HydroneerVersionConfig)appConfig.HydroneerVersion }); }
public static ApplicationStore ToStore(this AppConfigModel configModel) { return(new ApplicationStore() { DefaultProject = configModel.DefaultProject, Projects = configModel.Projects.ToStore(), Guids = configModel.Guids.ToStore() }); }
public AppConfigModel Create(AppConfigModel model) { if (model == null) { throw new ArgumentNullException("model"); } _configs.InsertOne(model); return(model); }
public void SaveConfigModel(AppConfigModel model) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("update tb_app_config set logo_link = @logo_link,index_pic_link = @index_pic_link WHERE id = @id"); this.database.AddInParameter(sqlStringCommand, "logo_link", DbType.String, model.LogoLink); this.database.AddInParameter(sqlStringCommand, "index_pic_link", DbType.String, model.IndexPicLink); this.database.AddInParameter(sqlStringCommand, "id", DbType.Int32, model.Id); this.database.ExecuteNonQuery(sqlStringCommand); }
public async Task RemoveProject(Guid projectId) { var config = await _configuration.GetConfigurationAsync(); var projects = config.Projects.ToModel().Where(project => project.Id != projectId).ToList(); var newConfig = new AppConfigModel(projects, config.DefaultProject, (HydroneerVersion)config.HydroneerVersion, config.Guids.ToModel()); await _configuration.SaveConfigurationAsync(newConfig); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { AppConfigModel model = AppConfigHelper.GetAppConfig(); txtDefaultLink.Text = model.LogoLink; txtGuanggaotuLink.Text = model.IndexPicLink; } this.btnSave.Click += new EventHandler(this.btnSave_Click); this.Button1.Click += new EventHandler(this.btnSave_Click); }
public void LoadParams() { AppConfigModel appConfig = AppConfig; Subject = @"Installation Completed for " + appConfig.ClientName; Message = @"Installation completed." + Environment.NewLine + "Client Name: " + appConfig.ClientName + Environment.NewLine + "PMS Name: CHIROTOUCH" + Environment.NewLine + "Send Time: " + getTaskRunTime() + Environment.NewLine + "Keyword : " + appConfig.AccountNumber; }
public async Task AddProject(Guid id, string name, short modIndex, string assetsPath, string outputPath) { var config = await _configuration.GetConfigurationAsync(); var projects = config.Projects.ToModel().ToList(); projects.Add(new ProjectModel(id, name, modIndex, assetsPath, outputPath)); var newConfig = new AppConfigModel(projects, config.DefaultProject, (HydroneerVersion)config.HydroneerVersion, config.Guids.ToModel()); await _configuration.SaveConfigurationAsync(newConfig); }
private void butSave_Click(object sender, EventArgs e) { List <AppConfigModel> listModel = null; try { if (dgvListConfig.RowCount > 0) { listModel = new List <AppConfigModel>(); foreach (DataGridViewRow row in dgvListConfig.Rows) { var model = new AppConfigModel(); model.Id = int.Parse(row.Cells["Id"].Value.ToString()); model.DisplayName = row.Cells["DisplayName"].Value.ToString(); model.Name = row.Cells["Name"].Value.ToString(); model.Description = row.Cells["Description"].Value != null ? row.Cells["Description"].Value.ToString() : ""; model.Value = row.Cells["Value"].Value != null ? row.Cells["Value"].Value.ToString() : ""; listModel.Add(model); } } if (listModel != null && listModel.Count > 0) { var result = false; if (appId == 0) { result = BLLConfig.Instance.InsertOrUpdate(listModel, appId); Configuration _config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); _config.AppSettings.Settings["AppId"].Value = appId.ToString(); _config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings"); result = true; } else { result = BLLConfig.Instance.InsertOrUpdate(listModel, appId); } if (result) { MessageBox.Show("Lưu thông tin thành công. Hệ thống sẽ khởi động lại"); Application.Restart(); } } } catch (Exception ex) { throw ex; } }
public FormConfig() { InitializeComponent(); this.SetBaseConfigs(); _appConfig = AppConfigManager.Load(); txtDefaultDirectorySaveFiles.Text = _appConfig.DefaultDirectorySaveFiles; txtHeaderLength.Value = _appConfig.HeaderLength; txtSeparatorCSV.Text = _appConfig?.SeparadorCSV?.ToString() ?? string.Empty; cbxAction.LoadComboFromEnum <EndProcessAction>((int)_appConfig.EndProcessAction); cbxHeader.LoadComboFromEnum <HeaderAction>((int)_appConfig.HeaderAction); cbxLanguage.LoadComboFromEnum <SystemLanguage>((int)_appConfig.Language); }
void ClientSettings_Loaded(object sender, RoutedEventArgs e) { ZingitClientSettingsViewModel csViewModel = this.DataContext as ZingitClientSettingsViewModel; string installDir = App.Current.Properties["InstallDir"] as string; if (string.IsNullOrEmpty(installDir) == false) { AppConfigModel config = csViewModel.AppConfig; if (config.DecryptData(installDir) == false) { return; } config.SetClientSettings(); } }
public AppConfigModel GetConfig() { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM tb_app_config where id = 1"); AppConfigModel model = new AppConfigModel(); using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand)) { if (reader.Read()) { model.Id = int.Parse(reader["id"].ToString()); model.LogoLink = reader["logo_link"].ToString(); model.IndexPicLink = reader["index_pic_link"].ToString(); } } return(model); }
public static Task RefreshStore(AppConfigModel appConfigModel) { Store = new ApplicationStore() { Projects = appConfigModel.Projects.ToStore(), DefaultProject = appConfigModel.DefaultProject, Guids = appConfigModel.Guids.ToStore() }; if (StoreChanged != null && StoreChanged.Target != null) { StoreChanged.Invoke(); } return(Task.CompletedTask); }
public static void GenerateAppConfig() { try { AppConfig = new AppConfigModel() { MouseSensitivity = 15, ScrollWheelClicks = 1, HoldLeftMouseDelay = 1 }; SaveAppConfig(); } catch (Exception ex) { Logger.Error(ex, "Failed to generate default app config: "); } }
/// <summary> /// List of Sql servers in a network /// https://stackoverflow.com/questions/13462120/how-do-i-get-a-list-of-sql-servers-available-on-my-network /// if not working then try following /// https://msdn.microsoft.com/en-us/library/dd981032.aspx /// </summary> public void PopulateSQLServerList() { System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; IList <ServerNameEntry> list = new List <ServerNameEntry>(); AppConfigModel appConfig = AppConfigModel.Instance; DataTable table = System.Data.Sql.SqlDataSourceEnumerator.Instance.GetDataSources(); bool sqlDBConnected = false; foreach (DataRow server in table.Rows) { string serverName = server[table.Columns["ServerName"]].ToString(); ServerNameEntry serverEntry = new ServerNameEntry(serverName); list.Add(serverEntry); if (!sqlDBConnected && TestDatabaseConnection(serverName, false)) { ServerName = serverName; sqlDBConnected = true; } } _sqlServerList = new CollectionView(list); if (!sqlDBConnected) { ServerName = "(local)"; if (TestDatabaseConnection(ServerName, false)) { sqlDBConnected = true; } } if (sqlDBConnected) { MessageBox.Show("SQL server " + ServerName + " is connected."); } else { MessageBox.Show("None of the SQL server found connected with credential provided in AppConfig.\nTo test the SQL server connection, type server name in \"DB Server Name\" drop down list."); } System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; }
public async Task RemoveAssets(Guid projectId, IReadOnlyCollection <Guid> assetsId) { var config = await _configuration.GetConfigurationAsync(); var projects = config.Projects.ToModel().ToList(); var projectIdx = projects.FindIndex(p => p.Id == projectId); var project = projects[projectIdx]; var items = project.Items.Where(item => !assetsId.Contains(item.Id)).ToList(); var newProject = new ProjectModel(project.Id, project.Name, project.ModIndex, project.Path, project.OutputPath, items); projects[projectIdx] = newProject; var newConfig = new AppConfigModel(projects, config.DefaultProject, (HydroneerVersion)config.HydroneerVersion, config.Guids.ToModel()); await _configuration.SaveConfigurationAsync(newConfig); }
public async Task <IActionResult> Edit(AppConfigModel model) { if (ModelState.IsValid) { var result = await _appConfigService.Update(_mapper.Map <AppConfigModel, UpdateAppConfigRequest>(model)); if (result.IsSuccess) { TempData["Update"] = result.ToJson(); return(RedirectToAction("Index", "AppConfig")); } ModelState.AddModelError("", result.Message); } return(View(model)); }
public static AppConfigModel ReadConfig(string path) { if (!System.IO.File.Exists(path)) { return(null); } XmlSerializer serializer = XmlSerializer.FromTypes(new[] { typeof(AppConfigModel) })[0]; AppConfigModel setting = null; try { using (var reader = new System.IO.StreamReader(path)) { setting = serializer.Deserialize(reader) as AppConfigModel; } } catch (Exception ex) { } return(setting); }
private string provideConfigurationJsonForApplicationLists() { AppConfigModel model = new AppConfigModel(); model.BlacklistedApplications = new HashSet <string>(new string[] { "chrome.exe", "testme.exe", @"Program Files*\java\jre.exe", @"Windows\MicrosoftEdge.exe" }); model.WhitelistedApplications = new HashSet <string>(new string[] { "dropbox.exe", @"eclipse\java\jre.exe", @"IDrive\backup*.exe" }); return(JsonConvert.SerializeObject(model)); }
public ActionResult <ResultModel <AppConfigModel> > Create([FromForm] AppConfigModel model = null) { var rs = new ResultModel <AppConfigModel>(); if (model == null) { model = new AppConfigModel(); } try { rs.Data = _service.Create(model); } catch (Exception ex) { rs.Code = ex.HResult; rs.Message = ex.ToString(); } return(rs); }
public AppConfigModel Update(AppConfigModel model) { if (model == null) { throw new ArgumentNullException("model"); } if (string.IsNullOrEmpty(model.Id)) { throw new KeyNotFoundException("model.Id"); } var update = Builders <AppConfigModel> .Update .Set("app_version", model.AppVersion) .Set("last_login_date_in_long", model.LastLoginDateInLong) .Set("last_login_date_string", model.LastLoginDateString) .Set("strategy_listing", model.Strategies); _configs.UpdateOne(c => c.Id == model.Id, update); return(model); }
public static void UpdateConfigFile(string oldConfig, string newConfig) { XmlSerializer serializer = XmlSerializer.FromTypes(new[] { typeof(AppConfigModel) })[0]; AppConfigModel oldSetting = ReadConfig(oldConfig); if (oldSetting == null) { if (File.Exists(newConfig)) { File.Copy(newConfig, oldConfig); return; } } AppConfigModel newSetting = ReadConfig(newConfig); if (newSetting == null) { return; } foreach (var setting in newSetting.AppSettings) { var exist = oldSetting.AppSettings.Exists((s) => s.Key == setting.Key); if (!exist) { oldSetting.AppSettings.Add(setting); } } var ns = new XmlSerializerNamespaces(); //Add an empty namespace and empty value ns.Add("", ""); System.IO.MemoryStream stream = new System.IO.MemoryStream(); serializer.Serialize(stream, oldSetting, ns); string xmlstring = System.Text.Encoding.UTF8.GetString(stream.ToArray()); System.IO.File.WriteAllText(oldConfig, xmlstring); }
private void btnSave_Click(object sender, EventArgs e) { if (this.logoFile.HasFile) { this.logoFile.SaveAs(Server.MapPath("/Utility/pics/default.jpg")); } if (this.FileUpload1.HasFile) { this.FileUpload1.SaveAs(Server.MapPath("/templates/vshop/default/images/11.jpg")); } AppConfigModel model = new AppConfigModel() { Id = 1, LogoLink = this.txtDefaultLink.Text.Trim(), IndexPicLink = this.txtGuanggaotuLink.Text.Trim() }; AppConfigHelper.SaveConfigModel(model); this.ShowMsg("修改成功", true); }