Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int start = (CurrentPage - 1) * ShowBy + 1;
        int end   = CurrentPage * ShowBy;

        RunsHelper rh = new RunsHelper(Request.QueryString, start, end);

        if (!string.IsNullOrEmpty(rh.REQUESTID))
        {
            TestRequest tr = new TestRequest(rh.REQUESTID);
            requestinfo.InnerHtml = string.Format("<strong><a href='requests.aspx?PROGABB={0}'>{0}</a>:</strong>{1}", tr.PROGABB, BSTStat.ReplaceTT(tr.TTID));
            requestinfo.Visible   = true;
        }

        object opages = DBHelper.GetValue(rh.sqlCounter);

        int pages = (int)Math.Ceiling((double)Convert.ToInt32(opages) / ShowBy);

        TTable.Attributes["pages"] = pages.ToString();

        int numOfInternalCols = 2;

        int index = start;

        using (DataTable dt = DBHelper.GetDataTable(rh.sql))
        {
            int colcount = dt.Columns.Count;

            TableHeaderRow th = new TableHeaderRow();
            th.TableSection = TableRowSection.TableHeader;
            for (int i = numOfInternalCols; i < colcount; i++)
            {
                string   captionfilter = dt.Columns[i].ToString();
                Type     t             = dt.Columns[i].DataType;
                string[] dat           = captionfilter.Split(' ');

                TableCell tc = th.Cells[th.Cells.Add(new TableHeaderCell())];
                tc.Text = dat[0];
                if (dat.Length > 1)
                {
                    tc.Attributes["filter"] = dat[1];
                    if (t == typeof(string))
                    {
                        tc.Attributes["filtertype"] = "string";
                    }
                    else if (t == typeof(int))
                    {
                        tc.Attributes["filtertype"] = "int";
                    }
                }
            }
            TTable.Rows.Add(th);

            foreach (DataRow dr in dt.Rows)
            {
                TableRow tr = new TableRow();
                tr.Attributes["runid"]     = dr[0].ToString();
                tr.Attributes["requestid"] = dr[1].ToString();
                for (int i = numOfInternalCols; i < colcount; i++)
                {
                    TableCell tc  = tr.Cells[tr.Cells.Add(new TableCell())];
                    string    txt = "";
                    if (dr[i] is DateTime)
                    {
                        txt = Convert.ToDateTime(dr[i]).ToString("dd.MM HH:mm", CultureInfo.InvariantCulture);
                        tc.Attributes["title"] = Convert.ToDateTime(dr[i]).ToString();
                    }
                    else if (dt.Columns[i].Caption == "Duration")
                    {
                        double time    = Convert.ToDouble(dr[i]);
                        double hours   = Math.Floor(time);
                        double minutes = Math.Round(60.0 * (time - hours), 0);
                        txt = hours.ToString("00") + ":" + minutes.ToString("00");
                    }
                    else
                    {
                        txt = dr[i].ToString();
                    }

                    if (dt.Columns[i].Caption == "Comment")
                    {
                        string cellval = txt.Split(new string[] { "<br>" }, StringSplitOptions.None)[0];
                        if (cellval.Length > 40)
                        {
                            cellval = cellval.Substring(0, 40) + "...";
                        }
                        else if (!string.IsNullOrEmpty(cellval) && txt.IndexOf("<br>") > -1)
                        {
                            cellval += "...";
                        }
                        tc.Text = cellval;
                        tc.Attributes["title"] = txt.Replace("<br>", "\n");
                    }
                    else
                    {
                        tc.Text = txt;
                    }

                    string colname = th.Cells[i - numOfInternalCols].Text;
                    if (colname == "Ex" && tc.Text != "0")
                    {
                        tc.CssClass = "bstexception";
                    }
                    else if (colname == "Db" && tc.Text != "0")
                    {
                        tc.CssClass = "bstdberror";
                    }
                    else if (colname == "Ou" && tc.Text != "0")
                    {
                        tc.CssClass = "bstoutputerror";
                    }
                    else if (colname == "Wr" && tc.Text != "0")
                    {
                        tc.CssClass = "bstwarning";
                    }
                    else if (colname == "Er" && tc.Text != "0")
                    {
                        tc.CssClass = "bsterror";
                    }
                    else if (colname == "Link")
                    {
                        tc.Text = "<a href='ViewLog.aspx?log=" + txt + "&RUNID=" + dr[0].ToString() + "'>Link</a>";
                    }
                    else if (colname == "Hash")
                    {
                        tc.Text = "<div class='hashspan'>" + tc.Text + "</div>";
                    }
                    else if (colname == "RR")
                    {
                        tc.ToolTip = txt;
                        tc.Text    = "<img src='images/Sign_rerun_green.png'></img>";
                        tc.Attributes["onclick"] = "rerun(this)";
                    }
                    else if (colname == "V" && !string.IsNullOrEmpty(txt))
                    {
                        tc.ToolTip = txt;
                        tc.Text    = "<img class='imgpers' src='images/persons/" + txt + ".jpg'></img>";
                    }

                    if (string.IsNullOrEmpty(tr.CssClass) && !string.IsNullOrEmpty(tc.CssClass))
                    {
                        tr.CssClass = tc.CssClass;
                    }
                }
                TTable.Rows.Add(tr);
            }
        }
    }
Example #2
0
    public string WhatBetweenVersions(string strVersionNew, string strRequest, string strVersionOld)
    {
        DataSet ds;
        string  SQL_Command_First, FirstGuid = "", SecondGuid = "";

        string SQL_Command = @"SELECT GITHASH, VersionID, ID FROM TESTREQUESTS WHERE ($WHERE = $PARAM) ORDER BY ID DESC";

        if (string.IsNullOrEmpty(strRequest))
        {
            SQL_Command_First = SQL_Command.Replace("$WHERE", "VersionID").Replace("$PARAM", strVersionNew);
        }
        else
        {
            SQL_Command_First = SQL_Command.Replace("$WHERE", "ID").Replace("$PARAM", strRequest);
        }

        ds        = CbstHelper.GetDataSet(SQL_Command_First);
        FirstGuid = ds.Tables[0].Rows[0][0].ToString();

        ds         = CbstHelper.GetDataSet(SQL_Command.Replace("$WHERE", "VersionID").Replace("$PARAM", strVersionOld));
        SecondGuid = ds.Tables[0].Rows[0][0].ToString();

        ProcessStartInfo gitInfo = new ProcessStartInfo();

        gitInfo.CreateNoWindow         = true;
        gitInfo.RedirectStandardError  = true;
        gitInfo.RedirectStandardOutput = true;
        gitInfo.UseShellExecute        = false;
        gitInfo.FileName = @"c:\Program Files (x86)\Git\bin\git.exe";
        //gitInfo.FileName = @"git.exe";


        Process gitProcess = new Process();

        gitInfo.Arguments        = "--no-pager log " + SecondGuid + ".." + FirstGuid + " --pretty=format:\"<tr><td>%ci</td><td>%s</td><td>%an</td></tr>\"";  // such as "fetch orign"
        gitInfo.WorkingDirectory = "I:\\GIT\\V8\\";
        // f:\Work_FiP_V8\
        // gitInfo.WorkingDirectory = @"f:\Work_FiP_V8\";

        gitProcess.StartInfo = gitInfo;
        gitProcess.Start();

        string stdout_str = gitProcess.StandardOutput.ReadToEnd();         // pick up STDOUT

        gitProcess.WaitForExit();
        gitProcess.Close();

        /*
         * string[] arrTT = stdout_str.Split('\n');
         * stdout_str = "";
         * for (int i = 0; i < arrTT.Count() - 1; i++)
         * {
         *       stdout_str += arrTT[i].Remove(0,8) + "<br>";
         * }
         */
        if (stdout_str.Length < 5)
        {
            return("Result is null. <br> Arguments is: <br>" + gitInfo.Arguments);
        }
        else
        {
            stdout_str = "<table border='1' Width = '100%'>" + stdout_str + "</table>";
            stdout_str = BSTStat.ReplaceTT(stdout_str);
            stdout_str = stdout_str.Replace(" +0300", "");
        }

        return(stdout_str);
    }