예제 #1
0
        static public reportTable addNewReport(DateTime reportDate, bool staticallyAnalyzed, bool dynamicallyAnalyzed, int apkInfoID, int userID)
        {
            databaseLayer.myConnection.Open();
            try
            {
                SqlCommand   myCommand        = new SqlCommand("insert into report (reportDate,staticallyAnalyzed,dynamicallyAnalyzed,apkInfoID,userAccountID) OUTPUT INSERTED.reportID values (@a,@b,@c,@d,@e)", databaseLayer.myConnection);
                SqlParameter forthParamater   = new SqlParameter("@a", reportDate);
                SqlParameter fifthParamater   = new SqlParameter("@b", staticallyAnalyzed);
                SqlParameter sixthParamater   = new SqlParameter("@c", dynamicallyAnalyzed);
                SqlParameter seventhParamater = new SqlParameter("@d", apkInfoID);
                SqlParameter eighthParamater  = new SqlParameter("@e", userID);

                myCommand.Parameters.Add(forthParamater);
                myCommand.Parameters.Add(fifthParamater);
                myCommand.Parameters.Add(sixthParamater);
                myCommand.Parameters.Add(seventhParamater);
                myCommand.Parameters.Add(eighthParamater);

                Int32       id     = (Int32)myCommand.ExecuteScalar();
                reportTable report = new reportTable(id, userID, reportDate, staticallyAnalyzed, dynamicallyAnalyzed, apkInfoID);
                databaseLayer.myConnection.Close();
                return(report);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                databaseLayer.myConnection.Close();
                return(null);
            }
        }
예제 #2
0
 public List <reportTable> getAllReportsThatContainThisAPK(int ID)
 {
     try
     {
         databaseLayer.myConnection.Open();
         SqlCommand   myCommand       = new SqlCommand("Select * from report where apkInfoID=@y", databaseLayer.myConnection);
         SqlParameter secondParamater = new SqlParameter("@y", ID);
         myCommand.Parameters.Add(secondParamater);
         SqlDataReader      reader  = myCommand.ExecuteReader();
         List <reportTable> reports = new List <reportTable>();
         while (reader.Read())
         {
             Int32       Id   = (Int32)reader[0];
             DateTime    date = (DateTime)reader[1];
             bool        staticallyAnalyzed  = (bool)reader[2];
             bool        dynamicallyAnalyzed = (bool)reader[3];
             Int32       apkInfoID           = (Int32)reader[4];
             Int32       userID = (Int32)reader[5];
             reportTable report = new reportTable(Id, userID, date, staticallyAnalyzed, dynamicallyAnalyzed, apkInfoID);
             reports.Add(report);
         }
         reader.Dispose();
         databaseLayer.myConnection.Close();
         return(reports);
     }
     catch (System.InvalidOperationException)
     {
         databaseLayer.myConnection.Close();
         return(null);
     }
 }
예제 #3
0
 static public reportTable findReportByID(int reportID)
 {
     try
     {
         if (databaseLayer.myConnection.State == ConnectionState.Closed)
         {
             databaseLayer.myConnection.Open();
         }
         SqlCommand   myCommand       = new SqlCommand("Select * from  report where reportID=@y", databaseLayer.myConnection);
         SqlParameter secondParamater = new SqlParameter("@y", reportID);
         myCommand.Parameters.Add(secondParamater);
         SqlDataReader reader = myCommand.ExecuteReader();
         if (reader.Read())
         {
             Int32       Id                  = (Int32)reader[0];
             DateTime    reportDate          = (DateTime)reader[1];
             bool        staticallyAnalyzed  = (bool)reader[2];
             bool        dynamicallyAnalyzed = (bool)reader[3];
             Int32       apkInfoID           = (Int32)reader[4];
             Int32       userAccountID       = (Int32)reader[5];
             reportTable rep                 = new reportTable(Id, userAccountID, reportDate, staticallyAnalyzed, dynamicallyAnalyzed, apkInfoID);
             reader.Dispose();
             databaseLayer.myConnection.Close();
             return(rep);
         }
         else
         {
             databaseLayer.myConnection.Close();
             return(null);
         }
     }
     catch (System.InvalidOperationException)
     {
         databaseLayer.myConnection.Close();
         return(null);
     }
 }