Exemplo n.º 1
0
    public Host[] GetHosts()
    {
        string      sql = @"
            SELECT H.[NAME]
                  ,[IP]
                  ,[MAC]
                  ,[SYSTEMINFO]
                  ,[PCPING]
	              ,[STARTED]
	              ,(SELECT P.PCNAME + ', ' AS 'data()' FROM PCS P WHERE P.HOST_ID = H.ID FOR XML PATH('')) LIST
            FROM [BST_STATISTICS].[DBO].[HOSTS] H
            WHERE INACTIVE IS NULL
            ORDER BY H.NAME
            ";
        List <Host> ms  = new List <Host>();

        using (DataSet ds = CbstHelper.GetDataSet(sql))
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Host m = new Host();
                m.Name    = dr["NAME"].ToString();
                m.IP      = dr["IP"].ToString();
                m.MAC     = dr["MAC"].ToString();
                m.Info    = dr["SYSTEMINFO"].ToString();
                m.Pcping  = dr["PCPING"] == DBNull.Value ? "" : GetTime(Convert.ToDateTime(dr["PCPING"])).ToString();
                m.Started = dr["STARTED"] == DBNull.Value ? "" : GetTime(Convert.ToDateTime(dr["STARTED"])).ToString();
                m.List    = dr["LIST"].ToString();
                ms.Add(m);
            }
        }
        return(ms.ToArray());
    }
Exemplo n.º 2
0
 string GetLastTestID(string strVersionId)
 {
     using (DataSet ds = CbstHelper.GetDataSet("SELECT TOP 1 ID FROM TESTRUNS WHERE (TEST_FIPVERSIONID = " + strVersionId + ") ORDER BY ID DESC"))
     {
         foreach (DataRow rowCur in ds.Tables[0].Rows)
         {
             return(rowCur[0].ToString());
         }
     }
     return("");
 }
Exemplo n.º 3
0
    public string GetTestRequests()
    {
        double dCDate  = Convert.ToDouble(DateTime.Now.ToOADate());
        string strDate = Application["UntestedRequestDate"] as string;

        if (string.IsNullOrEmpty(strDate))
        {
            _UpdateAppRequestInfo("0", "", 0, "");
            return("0,0");
        }
        else
        {
            double dOldDate = Convert.ToDouble(strDate);
            if (Math.Abs((dCDate - dOldDate)) > GetRepDelay())
            {
                int    iCount      = 0;
                string strTestsIDs = ",";
                // select (T1.ID) from TestRequests T1 where T1.ID not in (select distinct T2.RequestID from testruns T2  where T2.requestid is not null) AND (T1.IGNORE IS NULL OR T1.IGNORE != 1)
                using (DataSet ds = CbstHelper.GetDataSet("SELECT ID FROM TESTREQUESTS Where (UserID is null) AND (IGNORE IS NULL)"))
                {
                    foreach (DataRow rowCur in ds.Tables[0].Rows)
                    {
                        strTestsIDs += rowCur[0].ToString() + ",";
                        iCount++;
                    }
                }

                int iNotAnswerCount = 0;
                using (DataSet ds = CbstHelper.GetDataSet("select count (TestRequests.RequestDateTime) from TestRequests where RequestDateTime <= DATEADD(hour, -12, GETDATE())  AND ((TestRequests.IGNORE is Null) and (TestRequests.Tested is Null) and (TestRequests.ProgAbb != 'Admin'))"))
                {
                    foreach (DataRow rowCur in ds.Tables[0].Rows)
                    {
                        iNotAnswerCount = Convert.ToInt32(rowCur[0].ToString());
                    }
                }

                string idSchedules = "";
                using (DataSet ds = CbstHelper.GetDataSet("SELECT Schedule.ID from Schedule  ORDER BY Schedule.ID DESC"))
                {
                    foreach (DataRow rowCur in ds.Tables[0].Rows)
                    {
                        idSchedules += rowCur[0].ToString() + idSchedules != "" ? "," : "";
                    }
                }

                _UpdateAppRequestInfo(iCount.ToString(), strTestsIDs, iNotAnswerCount, idSchedules);
                return(Application["UntestedRequestCount"] as string + ", " + Application["NotAnswerRequestCount"] as string + ", " + Application["IDdSchedulesTest"] as string);
            }
            else
            {
                return(Application["UntestedRequestCount"] as string + ", " + Application["NotAnswerRequestCount"] as string + ", " + Application["IDdSchedulesTest"] as string);
            }
        }
    }
Exemplo n.º 4
0
    public string GetLastLog()
    {
        string res = "";

        using (DataSet ds = CbstHelper.GetDataSet("SELECT MAX(R.ID) M FROM BSTLOG R"))
        {
            foreach (DataRow dr1 in ds.Tables[0].Rows)
            {
                res += dr1["M"].ToString();
            }
        }
        return(res);
    }
Exemplo n.º 5
0
    public string GetLastRun()
    {
        string res = "";

        using (DataSet ds1 = CbstHelper.GetDataSet("SELECT MAX(P.LAST_UPDATED) M FROM PCS P"))
        {
            using (DataSet ds2 = CbstHelper.GetDataSet("SELECT MAX(R.ID) M FROM  TESTRUNS R"))
            {
                foreach (DataRow dr1 in ds1.Tables[0].Rows)
                {
                    foreach (DataRow dr2 in ds2.Tables[0].Rows)
                    {
                        res += dr2["m"].ToString();
                    }
                    res += dr1["m"].ToString();
                }
            }
        }
        return(res);
    }
Exemplo n.º 6
0
    public Machine[] GetMachines()
    {
        string sql = @"
             SELECT 
					 M.[PCNAME]
					,M.[CURRENT]
					,M.[STARTED]
					,M.[PCPING]
					,M.[PAUSEDBY]
					,V.[VERSION]
					,P.[USER_LOGIN]
					, (SELECT COUNT(*) FROM SCHEDULE S WHERE S.LOCKEDBY = M.ID) [TESTS]
            FROM 
	            PCS M 
            LEFT JOIN FIPVERSION V ON M.[VERSION] = V.[ID]
				LEFT JOIN [PERSONS] P ON M.[PAUSEDBY] = P.[ID]
            WHERE 
	            M.[UNUSED] = 0 
            ORDER BY 
	            M.[PCNAME]
            ";

        List <Machine> ms = new List <Machine>();

        using (DataSet ds = CbstHelper.GetDataSet(sql))
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Machine m = new Machine();
                m.Name     = dr["PCNAME"].ToString();
                m.Current  = dr["CURRENT"].ToString();
                m.Started  = dr["STARTED"] == DBNull.Value ? "" : GetTime(Convert.ToDateTime(dr["STARTED"])).ToString();
                m.Pcping   = dr["PCPING"] == DBNull.Value ? "" : GetTime(Convert.ToDateTime(dr["PCPING"])).ToString();
                m.Version  = dr["VERSION"].ToString();
                m.Pausedby = dr["USER_LOGIN"].ToString();
                m.Tests    = dr["TESTS"].ToString();
                ms.Add(m);
            }
        }
        return(ms.ToArray());
    }
Exemplo n.º 7
0
    public BackgroundWorker()
    {
        Thread obj = new Thread(() =>
        {
            Thread.Sleep(10000);
            while (true)
            {
                Thread.CurrentThread.IsBackground = true;
                using (DataSet ds = CbstHelper.GetDataSet(@"
					SELECT[ID]
					,[TO]
					,[SUBJECT]
					,[BODY]
					,[COLOR]
					FROM [EMAILS]
				"                ))
                {
                    foreach (DataRow r in ds.Tables[0].Rows)
                    {
                        try
                        {
                            string res = CbstHelper.SendEmailToBstTeam(r[1].ToString(), r[2].ToString(), r[3].ToString(), r[4].ToString());
                            Thread.Sleep(1000);
                            if (string.IsNullOrEmpty(res))
                            {
                                CbstHelper.SQLExecute("DELETE FROM [EMAILS] WHERE [ID] =" + r[0].ToString());
                            }
                        }
                        catch (Exception e)
                        {
                        }
                    }
                }
                Thread.Sleep(1000);
            }
        });

        obj.Start();
    }
Exemplo n.º 8
0
    public string StopSequence(string SEQUENCEGUID, string ThosterID)
    {
        using (DataSet ds = CbstHelper.GetDataSet(string.Format(@"
                SELECT 
	                S.[COMMAND]
	                ,R.[TTID]
	                ,P.[PCNAME]
                FROM 
	                [SCHEDULE] S 
                LEFT JOIN [PCS] P ON P.[ID] = S.[PCID]
                LEFT JOIN [TESTREQUESTS] R ON R.[ID] = S.[REQUESTID]
                WHERE 
	            S.[SEQUENCEGUID] = '{0}'
            ", SEQUENCEGUID)))
        {
            string message = "Sequence has been stopped: ";
            string machine = "";
            string ttid    = "";
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                message += dr["COMMAND"].ToString() + ",";
                machine  = dr["PCNAME"].ToString();
                ttid     = dr["TTID"].ToString();
            }

            message = message.Remove(message.Length - 1);
            CbstHelper.FeedLog(message);
            CbstHelper.FeedLog("Request has been changed: " + ttid);
            if (!string.IsNullOrEmpty(machine))
            {
                CbstHelper.FeedLog("Machine was affected: " + machine);
            }

            CbstHelper.SQLExecute("DELETE FROM SCHEDULE WHERE SEQUENCEGUID = '" + SEQUENCEGUID + "'");
            CbstHelper.SQLExecute("update PCS set ACTIONFLAG = 2 where ID = " + ThosterID);
        }
        return("OK");
    }
Exemplo n.º 9
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);
    }
Exemplo n.º 10
0
    public string RunTest(string strRequestID, string strCommandName, string strUserName, string strTestRunID)
    {
        // if it is release, we need rerun test in the last TESTREQUESTS with the same version
        string SQL_Command = "select (select max(t.id) from TESTREQUESTS t where t.versionid = x.versionid  and t.ProgAbb = x.ProgAbb) , x.ProgAbb from TESTREQUESTS x where x.id = $id";

        string ProgAbb;
        string strLastReqestID;

        using (DataSet ds = CbstHelper.GetDataSet(SQL_Command.Replace("$id", strRequestID)))
        {
            ProgAbb         = ds.Tables[0].Rows[0][1].ToString();
            strLastReqestID = ds.Tables[0].Rows[0][0].ToString();
        }
        if (ProgAbb.ToUpper() == "ADMIN")
        {
            strRequestID = strLastReqestID;
        }

        strCommandName = (strCommandName.Replace('`', '"').Replace('~', '\\'));

        // get db type from strCommandName
        string dbtype = GetParam(strCommandName, "dbtype:");

        dbtype = (dbtype == "" ? "NULL" : "'" + dbtype + "'");

        string y3dv = GetParam(strCommandName, "special:");

        y3dv = (y3dv.Contains("3DV") ? "1" : "NULL");

        // get PCName from strCommandName
        string strSQLPCName = "", sPCName = GetParam(strCommandName, "PCName:");

        if (sPCName == "")
        {
            strSQLPCName = "NULL";
        }
        else
        {
            strSQLPCName = "(select T1.ID from PCS T1 where T1.PCNAME = '" + sPCName + "')";
            if (strCommandName.IndexOf("\"PCName:") < 0)
            {
                sPCName = " PCName:" + sPCName;
            }
            else
            {
                sPCName = " \"PCName:" + sPCName + "\"";
            }
        }
        string strGuid     = Guid.NewGuid().ToString();
        string strPRIORITY = "4";

        string strSetSQL =
            @"INSERT INTO SCHEDULE (COMMAND, REQUESTID, PCID, USERID, PRIORITY, SEQUENCENUMBER, SEQUENCEGUID, DBTYPE, Y3DV) VALUES" +
            " ('" + strCommandName + "', " + strRequestID + "," + strSQLPCName + ",(select T2.ID from PERSONS T2 where T2.USER_LOGIN = '******'), " + strPRIORITY + ",2, '" + strGuid + "', " + dbtype + ", " + y3dv + ")";

        strSetSQL = strSetSQL.ToUpper();

        CbstHelper.SQLExecute(strSetSQL);

        TestRun.CommentTestRuns(strTestRunID, "Rerun");
        FeedLog("Next command has been rerun: " + strCommandName);
        return("OK");
    }