Ejemplo 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());
    }
Ejemplo n.º 2
0
    public string DeleteBatch(string id)
    {
        Batch b = new Batch(id);

        CbstHelper.FeedLog("Batch script has been deleted: " + b.BATCH_NAME);
        Batch.DeleteBatch(id);
        return("OK");
    }
Ejemplo n.º 3
0
    public string SetBatchName(string id, string text)
    {
        Batch b = new Batch(id);

        b.BATCH_NAME = text;
        b.Store();
        CbstHelper.FeedLog("Batch script has been changed: " + b.BATCH_NAME);
        return("OK");
    }
Ejemplo n.º 4
0
    public void DelM(string machine)
    {
        BstHost h = new BstHost(machine)
        {
            INACTIVE = true
        };

        h.Store();
        CbstHelper.FeedLog("Machine was deleted: " + machine);
    }
Ejemplo n.º 5
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);
            }
        }
    }
Ejemplo n.º 6
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("");
 }
Ejemplo n.º 7
0
 public string VerifyTests(string commaSeparatedIDs)
 {
     try
     {
         CbstHelper.VerifyTestRun(commaSeparatedIDs);
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
     return("OK");
 }
Ejemplo n.º 8
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);
    }
Ejemplo n.º 9
0
 public static void IgnoreTestRun(string ids)
 {
     string[] sids = ids.Split(',');
     foreach (string id in sids)
     {
         TestRun tr = new TestRun(id)
         {
             USERID = CurrentContext.UserID.ToString(), COMMENT = "ignored", IGNORE = true.ToString()
         };
         tr.Store();
     }
     CbstHelper.FeedLog("Following tests where marked as ignored: " + ids);
 }
Ejemplo n.º 10
0
 public static void VerifyTestRun(string ids)
 {
     string[] sids = ids.Split(',');
     foreach (string id in sids)
     {
         TestRun tr = new TestRun(id)
         {
             USERID = CurrentContext.UserID.ToString(), COMMENT = "verified", VERIFIED_USER_ID = CurrentContext.UserID.ToString()
         };
         tr.Store();
     }
     CbstHelper.FeedLog("Following tests where marked as verified: " + ids);
 }
Ejemplo n.º 11
0
 public static void CommentTestRuns(string ids, string comment)
 {
     string[] sids = ids.Split(',');
     foreach (string id in sids)
     {
         TestRun tr = new TestRun(id)
         {
             USERID = CurrentContext.UserID.ToString(), COMMENT = comment
         };
         tr.Store();
     }
     CbstHelper.FeedLog("Following tests where commented: " + ids);
 }
Ejemplo n.º 12
0
    public void UpdateHost(string host, bool start, string comment)
    {
        BstHost h = new BstHost(host);

        if (start)
        {
            h.POWERON = true;
        }
        else
        {
            h.POWEROFF = true;
        }
        h.Store();
        CbstHelper.FeedLog(comment);
    }
Ejemplo n.º 13
0
    public void UpdateMachineCommand(string machine, CbstHelper.ThosterStatus com, string comment)
    {
        object o = CbstHelper.GetValue("SELECT ACTIONFLAG FROM PCS WHERE PCNAME='" + machine + "'");
        int    iThosterStatus = 0;

        if (o != DBNull.Value)
        {
            iThosterStatus = Convert.ToInt32(o);
        }
        CbstHelper.ThosterStatus ActionFlag = (CbstHelper.ThosterStatus)iThosterStatus;
        if ((ActionFlag & com) == 0)
        {
            ActionFlag |= com;
            CbstHelper.SQLExecute("DELETE FROM SCHEDULE WHERE LOCKEDBY = (SELECT P.ID FROM PCS P WHERE P.PCNAME = '" + machine + "');");
            CbstHelper.SQLExecute("UPDATE PCS SET ACTIONFLAG = " + (int)ActionFlag + " WHERE PCNAME = '" + machine + "';");
        }
        CbstHelper.FeedLog(comment);
    }
Ejemplo n.º 14
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);
    }
Ejemplo n.º 15
0
    public List <string> commitChangedFiles(string key, List <int> indexes, string comment, int runID)
    {
        if (!CurrentContext.Admin)
        {
            return(new List <string>(new string[] { "Access Denied" }));
        }

        List <string> output = ChangesContainer.Commit(key, indexes, comment, CurrentContext.GitUser);

        TestRun tr = new TestRun(runID.ToString())
        {
            USERID = CurrentContext.UserID.ToString(), COMMENT = comment
        };

        tr.AddTTID(CbstHelper.GetTTfromText(comment));
        tr.Store();

        CbstHelper.FeedLog("Etalon files have been committed to git repository: " + comment);
        return(output);
    }
Ejemplo n.º 16
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());
    }
Ejemplo n.º 17
0
 public static void PauseOnOff(int id, int idusr)
 {
     using (var db = new BST_STATISTICSEntities())
     {
         var result = db.PCS.SingleOrDefault(b => b.ID == id);
         if (result != null)
         {
             if (result.PAUSEDBY == null)
             {
                 result.PAUSEDBY = idusr;
                 CbstHelper.FeedLog(string.Format("Machine '{0}' has been paused", result.PCNAME));
             }
             else
             {
                 result.PAUSEDBY = null;
                 CbstHelper.FeedLog(string.Format("Machine '{0}' has been resumed", result.PCNAME));
             }
             db.SaveChanges();
         }
     }
 }
Ejemplo n.º 18
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();
    }
Ejemplo n.º 19
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");
    }
Ejemplo n.º 20
0
    public void ChangeState(string machine)
    {
        string update = string.Format(@"
            UPDATE PCS 
            SET 
	            PAUSEDBY = CASE WHEN PAUSEDBY IS NULL THEN (SELECT ID FROM PERSONS WHERE USER_LOGIN = '******') ELSE NULL END
            WHERE 
            PCNAME = '{1}'
        ", CurrentContext.UserLogin(), machine);

        CbstHelper.SQLExecute(update);

        object o = CbstHelper.GetValue(string.Format("SELECT PAUSEDBY FROM PCS WHERE PCNAME = '{0}'", machine));

        if (o == DBNull.Value)
        {
            CbstHelper.FeedLog(string.Format("Machine '{0}' has been resumed", machine));
        }
        else
        {
            CbstHelper.FeedLog(string.Format("Machine '{0}' has been paused", machine));
        }
    }
Ejemplo n.º 21
0
    private void ReadEvents()
    {
        if (_eventsState.Keys.Contains(_signal_requestsstate))
        {
            string requestsState = CbstHelper.GetValue(@"
						SELECT 
						(SELECT CONVERT(VARCHAR(MAX), COUNT(*)) FROM [TESTREQUESTS] WHERE IGNORE IS NULL AND TESTED IS NULL AND USERID IS NULL) + '/' +
						(SELECT CONVERT(VARCHAR(MAX), (SELECT COUNT (DISTINCT REQUESTID) FROM SCHEDULE))) + '/' +
						(SELECT CONVERT(VARCHAR(MAX), COUNT(*)) FROM [TESTREQUESTS] WHERE IGNORE IS NULL AND TESTED IS NULL AND USERID IS NOT NULL)
					"                    ).ToString();

            _eventsState[_signal_requestsstate] = requestsState;
        }
        if (_eventsState.Keys.Contains(_signal_lastrequest))
        {
            string lastrequest = CbstHelper.GetValue("SELECT TOP 1 [ID] FROM [TESTREQUESTS] ORDER BY [ID] DESC").ToString();
            _eventsState[_signal_lastrequest] = lastrequest;
        }
        if (_eventsState.Keys.Contains(_host_lastupdated))
        {
            string host_lastupdated = CbstHelper.GetValue("SELECT MAX(H.LAST_UPDATED) M FROM HOSTS H").ToString();
            _eventsState[_host_lastupdated] = host_lastupdated;
        }
    }
Ejemplo n.º 22
0
 public string AddBatch(string name)
 {
     CbstHelper.FeedLog("Batch script has been added: " + name);
     return(Batch.AddBatch(name).ToString());
 }
Ejemplo n.º 23
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");
    }
Ejemplo n.º 24
0
 public void UntestRequest(string id)
 {
     CbstHelper.UntestRequest(id);
 }
Ejemplo n.º 25
0
 public void IgnoreRequest(string id, string str1or0)
 {
     CbstHelper.IgnoreRequest(id, str1or0);
 }
Ejemplo n.º 26
0
 public void FeedLog(string str)
 {
     CbstHelper.FeedLog(str);
 }
Ejemplo n.º 27
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);
    }
Ejemplo n.º 28
0
 public string[] GetLog()
 {
     return(CbstHelper.GetLastLog().ToArray());
 }