Пример #1
0
        public Boolean setProjectPath(SwattProject project)
        {
            if (this.conn.State == System.Data.ConnectionState.Open)
            {
                // Build apex, swatt and fem version strings
                String versionString = project.ApexVersion.ToString().Replace("_", "")
                                       + " & " + project.SwattVersion.ToString().Replace("_", "");

                // build ms access insert new scenario command
                this.queryCommand =
                    new OleDbCommand(INSERT_SCENARIO_FOR_PROJECT, this.conn);
                this.queryCommand.Parameters.Add("@p1", OleDbType.VarWChar).Value = project.Name;
                this.queryCommand.Parameters.Add("@p2", OleDbType.VarWChar).Value = project.CurrentScenario;

                var success = queryCommand.ExecuteNonQuery() > 0;

                // build ms access query command
                this.queryCommand =
                    new OleDbCommand(SET_PROJECT_PATH_QUERY, this.conn);

                this.queryCommand.Parameters.Add("@p1", OleDbType.VarChar).Value  = project.Name;
                this.queryCommand.Parameters.Add("@p2", OleDbType.VarWChar).Value = project.Location;
                this.queryCommand.Parameters.Add("@p3", OleDbType.VarWChar).Value = versionString;
                this.queryCommand.Parameters.Add("@p4", OleDbType.VarWChar).Value = project.SwattLocation;

                // execute query and return
                success = queryCommand.ExecuteNonQuery() > 0;

                return(success);
            }
            return(false);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        public Boolean fillBasins(SwattProject project, String basinName)
        {
            if (this.conn.State == System.Data.ConnectionState.Open)
            {
                // build ms access insert new scenario command
                this.queryCommand =
                    new OleDbCommand(INSERT_ALL_BASINS_FOR_PROJECT, this.conn);
                this.queryCommand.Parameters.Add("@p1", OleDbType.VarWChar).Value = project.CurrentScenario;
                this.queryCommand.Parameters.Add("@p2", OleDbType.Boolean).Value  = false;

                // execute query and return
                return(queryCommand.ExecuteNonQuery() > 0);
            }
            return(false);
        }
Пример #4
0
        public void readProject(String path)
        {
            System.Xml.Serialization.XmlSerializer reader =
                new System.Xml.Serialization.XmlSerializer(typeof(SwattProject));

            System.IO.StreamReader file = new System.IO.StreamReader(path + @"\project.xml");
            SwattProject           proj = (SwattProject)reader.Deserialize(file);

            this.Current = proj.Name;
            // TODO: Add database connection
            this.projectMapping.Add(this.Current, proj);
            this.loadSubBasins();
            CEEOTDLLManager.initializeGlobals(this);

            file.Close();
        }