private static void CreateConfigFile(string dbPath, string databaseName) { var filePath = Path.Combine(dbPath, ConfigFileName); var version = DateTime.Today.ToString(VersionFormat); var config = new ProjectConfigJson(databaseName, version, null, null); string json = JsonConvert.SerializeObject(config, Formatting.Indented); File.WriteAllText(filePath, json); }
/// <summary> /// This will finaly copy all the data you need for the server /// </summary> /// <param name="projectConfig">This is the project configuration file containing all the launchables.</param> public void SaveServerData(ProjectConfigJson projectConfig) { CopyFiles(); if (projectConfig != null) { SaveProjectConfig(projectConfig); } SaveUpdateInfo(); }
/// <summary> /// This is the event for the done button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void B_Done_Click(object sender, EventArgs e) { _projectConfigJson = new ProjectConfigJson(); foreach (ListViewItem item in LV_Executables.Items) { LaunchableJson launchableJSON = new LaunchableJson { DisplayName = item.SubItems[1].Text, Executable = item.Text }; _projectConfigJson.Launchables.Add(launchableJSON); } this.Close(); }
/// <summary> /// This will create the create the checksums and start coping the files /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void B_Create_Click(object sender, EventArgs e) { string inputFolder = TB_InputFolder.Text; string outputFolder = TB_OutputFolder.Text; DirectoryInfo inputFolderInfo = new DirectoryInfo(inputFolder); if (!inputFolderInfo.Exists) { MessageBox.Show($"The given input folder {inputFolder} is not existing", "Input folder not existing", MessageBoxButtons.OK, MessageBoxIcon.Error); } CreateDownloadableManager createDownloadable = new CreateDownloadableManager(inputFolder, outputFolder); if (!createDownloadable.CreateServerData()) { MessageBox.Show($"The was an error while processing the input folder!", "Error while creating server data", MessageBoxButtons.OK, MessageBoxIcon.Error); } CreateProjectConfig projectConfig = null; if (DialogResult.Yes == MessageBox.Show("Do you want to create the project config as well?", "Create project config", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { projectConfig = new CreateProjectConfig(inputFolder) { StartPosition = FormStartPosition.CenterParent }; projectConfig.ShowDialog(); } ProjectConfigJson dataJSON = null; if (projectConfig != null) { dataJSON = projectConfig.ProjectConfigJson; } createDownloadable.SaveServerData(dataJSON); B_Close.PerformClick(); }
/// <summary> /// This will save the project config file and add it to the update info file /// </summary> /// <param name="projectConfig"></param> private void SaveProjectConfig(ProjectConfigJson projectConfig) { string dataToSave = JsonConvert.SerializeObject(projectConfig); string fileName = _outputFolder + "\\" + "ProjectConfig.json"; using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(dataToSave); } string newFilename = fileName.Replace(_outputFolder + "\\", ""); UpdateableFile updateableFile = new UpdateableFile { Name = newFilename, Checksum = fileName.GetChecksum() }; _updateConfiguration.Files.Add(updateableFile); }
public ProjectBuilder WithConfiguration(string project, string version, params string[] priorityScripts) { _config = new ProjectConfigJson(project, version, priorityScripts, null); return(this); }