public void createProject(String name, String scenario, String location, String swattLocation, SwattProject.ProjectVersion apexVersion, SwattProject.ProjectVersion swattVersion) { // create project and add it to the store. this.Current = name; var project = new SwattProject(); project.Name = this.Current; project.Location = location + @"\" + project.Name; project.CurrentScenario = scenario; project.SwattLocation = swattLocation; project.ApexVersion = apexVersion; project.SwattVersion = swattVersion; // TODO: Add database connection projectMapping.Add(this.Current, project); try { // insert project into project path table if (!dbManager.setProjectPath(project)) { throw new ProjectException("Couldn't update project path in database"); } //this.readFigFile(); this.writeProject(project.Location); CEEOTDLLManager.initializeGlobals(this); } catch (Exception ex) { throw new ProjectException("Couldn't update project path in database" + ex.Message); } }
public bool createNewProject() { SwattProject.ProjectVersion apexVersion = 0, swattVersion = 0; // get project name and location string name = proj_name_txt.Text; if (name == "") { MessageBox.Show("Project name cannot be empty!", "Project Creation Error"); return(false); } string location = proj_loc_txt.Text; if (location == "") { MessageBox.Show("Project location cannot be empty!", "Project Creation Error"); return(false); } string scenario = scn_name_txt.Text; if (scenario == "") { MessageBox.Show("Project scenario cannot be empty!", "Project Creation Error"); return(false); } string swattLocation = swatt_loc_txt.Text; if (swattLocation == "") { MessageBox.Show("Swatt file(s) location cannot be empty!", "Project Creation Error"); return(false); } // select apex version if (apex_version_0406.IsChecked == true) { apexVersion = SwattProject.ProjectVersion.APEX_0604; } else if (apex_version_0406.IsChecked == true) { apexVersion = SwattProject.ProjectVersion.APEX_0806; } // select swatt version if (swatt_version_2005.IsChecked == true) { swattVersion = SwattProject.ProjectVersion.SWATT_2005; } else if (swatt_version_2009.IsChecked == true) { swattVersion = SwattProject.ProjectVersion.SWATT_2009; } else if (swatt_version_2012.IsChecked == true) { swattVersion = SwattProject.ProjectVersion.SWATT_2012; } try { // create project directory. System.IO.Directory.CreateDirectory(location + "//" + name); System.IO.Directory.CreateDirectory(location + "//" + name + "//" + "APEX"); // copy apex files to apex folder from ceeot installation. var filenames = System.IO.Directory.GetFiles("resources/apex"); foreach (var filename in filenames) { int lastSlashIdx = filename.LastIndexOf(@"\"); string fname = filename.Substring(lastSlashIdx + 1, filename.Length - lastSlashIdx - 1); System.IO.File.Copy(filename, location + @"\" + name + @"\APEX\" + fname, true); } // check if file.cio exists in swat directory var swattFileNames = System.IO.Directory.GetFiles(swattLocation); foreach (var file in swattFileNames) { Console.WriteLine(file); if (swattLocation + "\\file.cio" == file) { // create project with project manager this.projectManager.createProject(name, scenario, location, swattLocation, apexVersion, swattVersion); this.projectManager.loadSubBasins(); return(true); } } } catch (UnauthorizedAccessException) { MessageBox.Show("You don't have permissions to create a project in that directory", "Project Creation Error"); } return(false); }