예제 #1
0
 public void Delete( TestProject project )
 {
     var sql = "DELETE FROM results WHERE Project = :PROJ";
     using (var conn = Connect())
     using (var cmd = new SqliteCommand(conn))
     {
         cmd.Parameters.Add(new SqliteParameter(":PROJ", project.Project));
         cmd.CommandText = sql;
         cmd.ExecuteNonQuery();
     }
 }
예제 #2
0
        public List<string> GetBuilds(TestProject project, TestGroup grp, DateTime? since, DateTime? until)
        {
            var rv = new List<string>();
            using (var conn = Connect())
            {
                if ((project == null) && (grp == null) && (since == null) && (until == null))
                {
                    rv = GetDistinct(conn, "BuildId");
                } else {

                    using ( var cmd = new SqliteCommand( conn ) )
                    {
                        List<string> constraints = new List<string>();
                        if ( project != null ){
                            constraints.Add( "Project = :PROJ" );
                            cmd.Parameters.Add( new SqliteParameter(":PROJ", project.Project ));
                        }

                        if ( grp != null ){
                            constraints.Add( "TestGroup = :GRP" );
                            cmd.Parameters.Add( new SqliteParameter(":GRP", grp.Name) );
                        }
                        string conds = "";
                        if ( constraints.Count > 0 )
                            conds = " WHERE " + string.Join(" AND ", constraints.ToArray() );

                        cmd.CommandText = string.Format("SELECT BuildId, Timestamp FROM results {0}", conds);

                        using ( var sth = cmd.ExecuteReader() ){

                            while ( sth.Read() ){
                                var buildid = sth.GetString(0);
                                var buildtime = sth.GetDateTime(1);
                                if ( ( since == null ) || ( buildtime > since.Value ) ){
                                    if ( ( until == null ) || ( buildtime <= until.Value ) ){
                                        rv.Add( buildid );
                                    }
                                }
                            }
                        }
                    }
                }
                rv = new List<string>( rv.Distinct() );
            }
            return rv;
        }
예제 #3
0
파일: Main.cs 프로젝트: inorton/testvault
        public void SubmitResult( HttpListenerContext ctx )
        {
            var req = ctx.Request;
            var args = QueryDictionary(ctx.Request);

            var resp = ctx.Response;
            resp.StatusCode = 500;

            var sb = new StringBuilder();

            try {
                TestResult tr;
                if ( req.HttpMethod.ToUpper().Equals("POST") ) {
                    var xsc = new XmlSerializer(typeof(TestResult));
                    tr = (TestResult)xsc.Deserialize(req.InputStream);
                } else {
                    var project = new TestProject()
                    {
                        Project = args["project"],
                        DataStore = DataStore
                    };
                    var pgroup = new TestGroup() {
                        Project = project, Name = args["group"] };
                    var build = args["buildid"];
                    var name = args["name"];
                    var date = DateTime.Now;
                    var outc = args["outcome"];
                    var sess = args["session"];
                    var outcome = (TestOutcome)Enum.Parse(typeof(TestOutcome), outc);

                    tr = new TestResult(){
                        Group = pgroup,
                        Time = date,
                        BuildID = build,
                        Name = name,
                        Outcome = outcome,
                        TestSession = sess,
                    };

                    if ( args.ContainsKey("desc") ){
                        tr.Description = args["desc"];
                    }
                    if ( args.ContainsKey("note") ){
                        tr.Notes = args["note"];
                    }
                    if ( args.ContainsKey("personal") )
                    {
                        bool pers = false;
                        bool.TryParse( args["personal"], out pers );
                        tr.IsPersonal = pers;
                    }
                }

                DataStore.Save(tr);

                sb.AppendFormat("OK");
                resp.StatusCode = 200;
            } catch ( KeyNotFoundException e ){
                sb.AppendFormat("one or more test params not specified \n: {0}", e.ToString());
            }

            var buf = Encoding.UTF8.GetBytes(sb.ToString());

            resp.OutputStream.Write(buf, 0, buf.Length);
            resp.OutputStream.Close();
        }
예제 #4
0
        public List<TestProject> GetProjects()
        {
            var rv = new List<TestProject>();
            using (var conn = Connect())
            {
                var projects = GetDistinct( conn, "Project" );
                foreach ( var p in projects )
                {
                    var proj = new TestProject();
                    proj.DataStore = this;
                    proj.Project = p;
                    rv.Add(proj);
                }
            }

            return rv;
        }
예제 #5
0
        public List<TestGroup> GetGroups(TestProject project)
        {
            var rv = new List<TestGroup>();
            using (var conn = Connect())
            {
                using ( var cmd = new SqliteCommand( conn ) ){
                    cmd.CommandText = @"SELECT DISTINCT TestGroup FROM results WHERE Project = :PROJ ORDER BY Timestamp DESC";
                    cmd.Parameters.Add( new SqliteParameter( ":PROJ", project.Project ) );
                    using ( var sth = cmd.ExecuteReader() ){
                        while ( sth.Read() ){
                            var g = new TestGroup();
                            g.Project = project;
                            g.Name = sth.GetString(0);
                            rv.Add(g);
                        }
                    }
                }
            }

            return rv;
        }