Exemple #1
0
    public static List <ExhibitionTest> SelectTempExhibitionTest(bool dbconOpened)
    {
        openIfNeeded(dbconOpened);

        dbcmd.CommandText = "SELECT * FROM " + tableExhibitionTest + " ORDER BY personID";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        SqliteDataReader reader = dbcmd.ExecuteReader();

        List <ExhibitionTest> l = new List <ExhibitionTest>();

        while (reader.Read())
        {
            ExhibitionTest et = new ExhibitionTest(
                Convert.ToInt32(reader[0]),                                         //schoolID
                Convert.ToInt32(reader[1]),                                         //groupID
                Convert.ToInt32(reader[2]),                                         //personID
                (ExhibitionTest.testTypes)Enum.Parse(
                    typeof(ExhibitionTest.testTypes), reader[3].ToString()),        //testType
                Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())) //result
                );

            l.Add(et);
        }

        reader.Close();
        closeIfNeeded(dbconOpened);

        return(l);
    }
Exemple #2
0
    //table created with:
    //CREATE TABLE exhibitionTest(dt TIMESTAMP DEFAULT CURRENT_TIMESTAMP, schoolID INT NOT NULL, groupID INT NOT NULL, personID INT NOT NULL, testType CHAR(10), result DOUBLE);
    public bool UploadExhibitionTest(ExhibitionTest et)
    {
        // Create a request using a URL that can receive a post.
        if (!createWebRequest(requestType.GENERIC, "/uploadExhibitionTestData"))
        {
            return(false);
        }

        // Set the Method property of the request to POST.
        request.Method = "POST";

        // Set the ContentType property of the WebRequest.
        request.ContentType = "application/json; Charset=UTF-8";         //but this is not enough, see this line:
        //exerciseName = Util.RemoveAccents(exerciseName);

        // Creates the json object
        JsonObject json = new JsonObject();

        json.Add("schoolID", et.schoolID);
        json.Add("groupID", et.groupID);
        json.Add("personID", et.personID);
        json.Add("testType", et.testType.ToString());
        json.Add("result", et.resultToJson);

        // Converts it to a String
        String js = json.ToString();

        // Writes the json object into the request dataStream
        Stream dataStream;

        if (!getWebRequestStream(request, out dataStream, "Could not upload exhibition test data (A)."))
        {
            return(false);
        }

        dataStream.Write(Encoding.UTF8.GetBytes(js), 0, js.Length);

        dataStream.Close();

        // Get the response.
        WebResponse response;

        if (!getWebResponse(request, out response, "Could not upload exhibition test data (B)."))
        {
            return(false);
        }

        // Display the status (will be 202, CREATED)
        Console.WriteLine(((HttpWebResponse)response).StatusDescription);

        // Clean up the streams.
        dataStream.Close();
        response.Close();

        this.ResultMessage = "Exhibition test data sent.";
        return(true);
    }
Exemple #3
0
    /*
     * EXHIBITION //right now does not upload to server when connection returns
     */

    public static void UploadExhibitionTest(ExhibitionTest et)
    {
        Json js = new Json();

        if (!js.UploadExhibitionTest(et))
        {
            LogB.Error(js.ResultMessage);
            SqliteJson.InsertTempExhibitionTest(false, et);             //insert only if could'nt be uploaded
        }
    }
Exemple #4
0
    public static void InsertTempExhibitionTest(bool dbconOpened, ExhibitionTest et)
    {
        openIfNeeded(dbconOpened);

        dbcmd.CommandText = "INSERT INTO " + tableExhibitionTest +
                            " (schoolID, groupID, personID, testType, result) VALUES (" +
                            et.ToSQLTempInsertString() + ")";
        LogB.SQL(dbcmd.CommandText.ToString());

        dbcmd.ExecuteNonQuery();

        closeIfNeeded(dbconOpened);
    }
Exemple #5
0
    public static void DeleteTempExhibitionTest(bool dbconOpened, ExhibitionTest et, SqliteCommand mycmd)
    {
        openIfNeeded(dbconOpened);

        mycmd.CommandText = "Delete FROM " + tableExhibitionTest + " WHERE " +
                            "schoolID = " + et.schoolID + " AND " +
                            "groupID = " + et.groupID + " AND " +
                            "personID = " + et.personID + " AND " +
                            "testType = \"" + et.testType.ToString() + "\" AND " +
                            "result = " + et.resultToJson;
        //LogB.SQL(mycmd.CommandText.ToString());
        mycmd.ExecuteNonQuery();

        closeIfNeeded(dbconOpened);
    }
Exemple #6
0
 public static void DeleteTempExhibitionTest(bool dbconOpened, ExhibitionTest et)
 {
     DeleteTempExhibitionTest(dbconOpened, et, dbcmd);
 }