Example #1
0
        public async Task <List <RecordObject> > getRecordsAfterAsync(long time)
        {
            List <RecordObject> records = new List <RecordObject>();

            //try
            //{
            //    using (SqlConnection conn = new SqlConnection(sqlCon))
            //    {
            //        if (conn.State == ConnectionState.Closed)
            //        {
            //            conn.Open();


            //            using (SqlCommand command = new SqlCommand("SELECT time,operation,keyStroke,window FROM Records WHERE time > @t Order By time", conn))
            //            {
            //                //
            //                // Add new SqlParameter to the command.
            //                //
            //                command.Parameters.Add(new SqlParameter("t", time));
            //                SqlDataReader reader;
            //                //  SqlCommand command =
            //                //       new SqlCommand("SELECT time,operation,keyStroke,window " +
            //                //                      "FROM Records WHERE time>'" +
            //                //                       time +
            //                //                       "' Order By time;", conn);


            //                reader = command.ExecuteReader();

            //                if (reader.HasRows)
            //                {
            //                    while (reader.Read())
            //                    {
            //                        records.Add(new RecordObject(reader.GetInt64(0),
            //                            reader.GetString(1), reader.GetString(2), reader.GetString(3)));

            //                    }
            //                }
            //                else
            //                {
            //                    Console.WriteLine("No rows found.");
            //                }
            //            }
            //        }
            //    }
            //}
            //catch(Exception e)
            //{
            //    Console.WriteLine(e.ToString());
            //}

            records = await MongoDBUtils.RetriveRecordsAfter(time);

            return(records);
        }
Example #2
0
        public static void injectRecord(RecordObject rec)
        {
            try
            {
                BsonDocument doc = new BsonDocument
                {
                    { "Time", rec.Time },
                    { "Operation", rec.Operation },
                    { "Key", rec.KeyWord },
                    { "Window", rec.Window }
                };

                MongoDBUtils.RecordsCollection.InsertOne(doc);
            }
            catch
            {
                MongoDBUtils.Connect();
            }
        }
Example #3
0
        public void insertRecord(RecordObject record)
        {
            //using (SqlConnection conn = new SqlConnection(sqlCon))
            //{
            //    if (conn.State == ConnectionState.Closed)
            //    {
            //        conn.Open();
            //        SqlCommand command =
            //            new SqlCommand("INSERT INTO Records " +
            //                           "VALUES(" +
            //                           record.Time + ", " +
            //                           record.Operation + ", " +
            //                           record.KeyWord + ", " +
            //                           record.Window + ");",
            //                           conn);

            //        command.ExecuteReader();
            //    }
            //}

            MongoDBUtils.injectRecord(record);
        }
Example #4
0
        public DBManager()
        {
            MongoDBUtils.Connect();
            //  AppDomain.CurrentDomain.SetData("DataDirectory", Directory.GetCurrentDirectory());
            // sqlCon =

            //        "Data Source=(LocalDB)\\MSSQLLocalDB;Integrated Security=True";

            //       @"Data Source=.\SQLEXPRESS;" +
            //       @"AttachDbFilename=|DataDirectory|\EyeDenticaDB.mdf;
            //       Integrated Security=True;
            //       Connect Timeout=30;
            //       User Instance=True";
            //  conn = new SqlConnection(sqlCon);

            //  conn.ConnectionString =
            //      "Server =.\\SQLExpress; AttachDbFilename =|DataDirectory|EyeDenticaDB.mdf; Database = EyeDenticaDB; Trusted_Connection = Yes;";

            //  @"Data Source = (localdb)\v12.0;" +
            //       "User Instance=true;" +
            //       "Integrated Security=true;" +
            //      @"AttachDbFilename = C:\mf\projectTfs\EyeDentica\EyeDenticaService\EyeDenticaService\DB\EyeDenticaDB.mdf;";
        }
Example #5
0
 static MongoDBUtils()
 {
     BsonDefaults.GuidRepresentation = GuidRepresentation.Standard;
     MongoDBUtils.Connect();
 }