static void Main(string[] args) { string configurationFilePath = Path.Combine( @"C:\Users\ovidiu.porumb\Documents\visual studio 2013\Projects\Project.Configurations.Manager", "DemoConfiguration.json"); string environmentFilePath = Path.Combine( @"C:\Users\ovidiu.porumb\Documents\visual studio 2013\Projects\Project.Configurations.Manager", "DemoEnvironments.json"); ProjectConfiguration <MyProjectConfigurationModel> .Load(configurationFilePath, environmentFilePath); MyProjectConfigurationModel myConfig = ProjectConfiguration <MyProjectConfigurationModel> .Data; Console.WriteLine("Showing the configurations..."); Console.WriteLine(); Console.WriteLine("EnvironmentName: {0}", myConfig.EnvironmentName); Console.WriteLine("DatabaseServer: {0}", myConfig.Common.DatabaseServer); Console.WriteLine("LogFolder: {0}", myConfig.Common.LogFolder); Console.WriteLine("LogFileName: {0}", myConfig.MyProjectB.LogFileName); Console.WriteLine(); Console.WriteLine("Press SPACE to exit..."); Console.ReadKey(); }
private void saveButton_Click(object sender, EventArgs e) { if (!Path.IsPathRooted(programPathTextBox.Text)) { Popup.ShowPopup(this, SystemIcons.Error, "Invalid path set.", "The current path for the program data is not valid.", PopupButtons.Ok); return; } if (programPathTextBox.Text != Settings.Default.ProgramPath) { try { var projectConfiguration = ProjectConfiguration.Load(); if (projectConfiguration != null) { foreach ( var project in projectConfiguration.Select(config => UpdateProject.LoadProject(config.Path)) .Where(project => project.Packages != null)) { foreach (var package in project.Packages) { package.LocalPackagePath = Path.Combine(programPathTextBox.Text, "Projects", project.Name, Directory.GetParent(package.LocalPackagePath).Name, Path.GetFileName(package.LocalPackagePath)); } UpdateProject.SaveProject(project.Path, project); } CopyFilesRecursively(Settings.Default.ProgramPath, programPathTextBox.Text); } } catch (Exception ex) { Popup.ShowPopup(this, SystemIcons.Error, "Error while moving the program data.", ex, PopupButtons.Ok); return; } } Settings.Default.Language = new CultureInfo( languagesComboBox.GetItemText(languagesComboBox.SelectedItem).Split('-')[1].Trim()); Settings.Default.ProgramPath = programPathTextBox.Text; Settings.Default.Save(); Settings.Default.Reload(); Close(); }
private void ProjectImportDialog_Load(object sender, EventArgs e) { Text = String.Format(Text, Program.VersionString); _sender = optionTabPage; projectFilePathTextBox.Initialize(); projectOutputPathTextBox.Initialize(); projectToImportTextBox.Initialize(); _projectConfigurations = ProjectConfiguration.Load().ToList(); if (_projectConfigurations.Any()) { projectsListBox.Items.AddRange(_projectConfigurations.Select(item => item.Name).Cast <object>().ToArray()); projectsListBox.SelectedIndex = 0; } else { shareProjectRadioButton.Enabled = false; } }
private void continueButton_Click(object sender, EventArgs e) { if (_sender == generalTabPage) { if (!ValidationManager.Validate(generalPanel)) { Popup.ShowPopup(this, SystemIcons.Error, "Missing information found.", "All fields need to have a value.", PopupButtons.Ok); return; } if (!_generalTabPassed) { _projectConfiguration = ProjectConfiguration.Load().ToList(); if (_projectConfiguration != null) { if (_projectConfiguration.Any(item => item.Name == nameTextBox.Text)) { Popup.ShowPopup(this, SystemIcons.Error, "The project is already existing.", String.Format( "The project \"{0}\" is already existing.", nameTextBox.Text), PopupButtons.Ok); return; } } else { _projectConfiguration = new List <ProjectConfiguration>(); } } if (!Uri.IsWellFormedUriString(updateUrlTextBox.Text, UriKind.Absolute)) { Popup.ShowPopup(this, SystemIcons.Error, "Invalid adress.", "The given Update-URL is invalid.", PopupButtons.Ok); return; } if (!Path.IsPathRooted(localPathTextBox.Text)) { Popup.ShowPopup(this, SystemIcons.Error, "Invalid path.", "The given local path for the project is invalid.", PopupButtons.Ok); return; } try { Path.GetFullPath(localPathTextBox.Text); } catch { Popup.ShowPopup(this, SystemIcons.Error, "Invalid path.", "The given local path for the project is invalid.", PopupButtons.Ok); return; } _sender = ftpTabPage; backButton.Enabled = true; informationCategoriesTabControl.SelectedTab = ftpTabPage; } else if (_sender == ftpTabPage) { if (!ValidationManager.Validate(ftpPanel) || String.IsNullOrEmpty(ftpPasswordTextBox.Text)) { Popup.ShowPopup(this, SystemIcons.Error, "Missing information found.", "All fields need to have a value.", PopupButtons.Ok); return; } _ftp.Host = ftpHostTextBox.Text; _ftp.Port = int.Parse(ftpPortTextBox.Text); _ftp.Username = ftpUserTextBox.Text; _ftp.Directory = ftpDirectoryTextBox.Text; var ftpPassword = new SecureString(); foreach (var c in ftpPasswordTextBox.Text) { ftpPassword.AppendChar(c); } _ftp.Password = ftpPassword; // Same instance that FtpManager will automatically dispose _ftp.UsePassiveMode = ftpModeComboBox.SelectedIndex == 0; _ftp.Protocol = (FtpSecurityProtocol)ftpProtocolComboBox.SelectedIndex; if (!backButton.Enabled) // If the back-button was disabled, enabled it again { backButton.Enabled = true; } _sender = statisticsServerTabPage; informationCategoriesTabControl.SelectedTab = statisticsServerTabPage; } else if (_sender == statisticsServerTabPage) { if (useStatisticsServerRadioButton.Checked) { if (SqlDatabaseName == null || String.IsNullOrWhiteSpace(sqlPasswordTextBox.Text)) { Popup.ShowPopup(this, SystemIcons.Error, "Missing information found.", "All fields need to have a value.", PopupButtons.Ok); return; } } _sender = proxyTabPage; informationCategoriesTabControl.SelectedTab = proxyTabPage; } else if (_sender == proxyTabPage) { if (useProxyRadioButton.Checked) { if (!ValidationManager.ValidateTabPage(proxyTabPage) && !String.IsNullOrEmpty(proxyUserTextBox.Text) && !String.IsNullOrEmpty(proxyPasswordTextBox.Text)) { Popup.ShowPopup(this, SystemIcons.Error, "Missing information found.", "All fields need to have a value.", PopupButtons.Ok); return; } } try { using (File.Create(localPathTextBox.Text)) { } _projectFileCreated = true; } catch (IOException ex) { Popup.ShowPopup(this, SystemIcons.Error, "Failed to create project file.", ex, PopupButtons.Ok); Close(); } var usePassive = ftpModeComboBox.SelectedIndex == 0; WebProxy proxy = null; string proxyUsername = null; string proxyPassword = null; if (!String.IsNullOrEmpty(proxyHostTextBox.Text)) { proxy = new WebProxy(proxyHostTextBox.Text); if (!String.IsNullOrEmpty(proxyUserTextBox.Text) && !String.IsNullOrEmpty(proxyPasswordTextBox.Text)) { proxyUsername = proxyUserTextBox.Text; if (!saveCredentialsCheckBox.Checked) { proxyPassword = Convert.ToBase64String(AesManager.Encrypt(proxyPasswordTextBox.Text, ftpPasswordTextBox.Text, ftpUserTextBox.Text)); } else { proxyPassword = Convert.ToBase64String(AesManager.Encrypt(proxyPasswordTextBox.Text, Program.AesKeyPassword, Program.AesIvPassword)); } } } string sqlPassword = null; if (useStatisticsServerRadioButton.Checked) { if (!saveCredentialsCheckBox.Checked) { sqlPassword = Convert.ToBase64String(AesManager.Encrypt(sqlPasswordTextBox.Text, ftpPasswordTextBox.Text, ftpUserTextBox.Text)); } else { sqlPassword = Convert.ToBase64String(AesManager.Encrypt(sqlPasswordTextBox.Text, Program.AesKeyPassword, Program.AesIvPassword)); } } Settings.Default.ApplicationID += 1; Settings.Default.Save(); Settings.Default.Reload(); string ftpPassword; if (!saveCredentialsCheckBox.Checked) { ftpPassword = Convert.ToBase64String(AesManager.Encrypt(ftpPasswordTextBox.Text, ftpPasswordTextBox.Text, ftpUserTextBox.Text)); } else { ftpPassword = Convert.ToBase64String(AesManager.Encrypt(ftpPasswordTextBox.Text, Program.AesKeyPassword, Program.AesIvPassword)); } // Create a new package... var project = new UpdateProject { Path = localPathTextBox.Text, Name = nameTextBox.Text, Guid = Guid.NewGuid().ToString(), ApplicationId = Settings.Default.ApplicationID, UpdateUrl = updateUrlTextBox.Text, Packages = null, SaveCredentials = saveCredentialsCheckBox.Checked, FtpHost = ftpHostTextBox.Text, FtpPort = int.Parse(ftpPortTextBox.Text), FtpUsername = ftpUserTextBox.Text, FtpPassword = ftpPassword, FtpDirectory = ftpDirectoryTextBox.Text, FtpProtocol = ftpProtocolComboBox.SelectedIndex, FtpUsePassiveMode = usePassive, FtpTransferAssemblyFilePath = _ftpAssemblyPath, Proxy = proxy, ProxyUsername = proxyUsername, ProxyPassword = proxyPassword, UseStatistics = useStatisticsServerRadioButton.Checked, SqlDatabaseName = SqlDatabaseName, SqlWebUrl = SqlWebUrl, SqlUsername = SqlUsername, SqlPassword = sqlPassword, PrivateKey = PrivateKey, PublicKey = PublicKey, Log = null }; try { UpdateProject.SaveProject(localPathTextBox.Text, project); // ... and save it } catch (IOException ex) { Popup.ShowPopup(this, SystemIcons.Error, "Error while saving the project file.", ex, PopupButtons.Ok); _mustClose = true; Reset(); } try { var projectDirectoryPath = Path.Combine(Program.Path, "Projects", nameTextBox.Text); Directory.CreateDirectory(projectDirectoryPath); } catch (Exception ex) { Popup.ShowPopup(this, SystemIcons.Error, "Error while creating the project'S directory.", ex, PopupButtons.Ok); _mustClose = true; Reset(); } try { _projectConfiguration.Add(new ProjectConfiguration(nameTextBox.Text, localPathTextBox.Text)); File.WriteAllText(Program.ProjectsConfigFilePath, Serializer.Serialize(_projectConfiguration)); _projectConfigurationEdited = true; } catch (Exception ex) { Popup.ShowPopup(this, SystemIcons.Error, "Error while editing the project confiuration file. Please choose another name for the project.", ex, PopupButtons.Ok); _mustClose = true; Reset(); } if (useStatisticsServerRadioButton.Checked) { var phpFilePath = Path.Combine(Program.Path, "Projects", nameTextBox.Text, "statistics.php"); try { File.WriteAllBytes(phpFilePath, Resources.statistics); var phpFileContent = File.ReadAllText(phpFilePath); phpFileContent = phpFileContent.Replace("_DBURL", SqlWebUrl); phpFileContent = phpFileContent.Replace("_DBUSER", SqlUsername); phpFileContent = phpFileContent.Replace("_DBNAME", SqlDatabaseName); phpFileContent = phpFileContent.Replace("_DBPASS", sqlPasswordTextBox.Text); File.WriteAllText(phpFilePath, phpFileContent); _phpFileCreated = true; } catch (Exception ex) { Popup.ShowPopup(this, SystemIcons.Error, "Failed to initialize the project-files.", ex, PopupButtons.Ok); _mustClose = true; Reset(); } } _generalTabPassed = true; InitializeProject(); } }