Example #1
0
        // USBメモリ情報をDBへ挿入する
        public void DoInsertUsbLog(Dictionary<string, string> usbInfo, Dictionary<string, string> connUsbInfo, int alertMark)
        {
            Mos mos           = new Mos();
            string pcName     = mos.GetPcName();
            string pcUserName = mos.GetPcUserName();

            SqlString sqlInsertUsbLog =
                @"INSERT t_log( log_time,  pc_name,  pc_user_name,  usb_vendor_name,  usb_serial_no,  action,  action_status,  alert_mark)
                VALUES        (@log_time, @pc_name, @pc_user_name, @usb_vendor_name, @usb_serial_no, @action, @action_status, @alert_mark)";
            MySqlCommand commInsertUsbLog = new MySqlCommand((string)sqlInsertUsbLog, myConn);
            commInsertUsbLog.Parameters.AddWithValue("@log_time"       , DateTime.Now            );
            commInsertUsbLog.Parameters.AddWithValue("@pc_name"        , pcName                  );
            commInsertUsbLog.Parameters.AddWithValue("@pc_user_name"   , pcUserName              );
            commInsertUsbLog.Parameters.AddWithValue("@usb_vendor_name", usbInfo["usbVendorName"]);
            commInsertUsbLog.Parameters.AddWithValue("@usb_serial_no"  , usbInfo["usbSerialNo"]  );
            commInsertUsbLog.Parameters.AddWithValue("@action"         , "USBメモリの接続"        );
            commInsertUsbLog.Parameters.AddWithValue("@action_status"  , "成功"                   );
            commInsertUsbLog.Parameters.AddWithValue("@alert_mark"     , alertMark               );

            try {
                myConn.Open();
                commInsertUsbLog.ExecuteNonQuery();
                myConn.Close();

                connUsbInfo["usbVendorName"] = usbInfo["usbVendorName"];
                connUsbInfo["usvSerialNo"]   = usbInfo["usbSerialNo"];
            } catch (MySqlException e) {
            }

            // 表示している情報を最新に更新
            SelectUsbLog();
        }
Example #2
0
        // USBポートを監視し、USBメモリの接続が認められればDBへの挿入処理を呼び出す
        public void insertUsbLog(object source, TM.ElapsedEventArgs e)
        {
            //public void insertUsbLog() {
            for (int i = 0; i > gridActionLog.RowCount; i++) {
                gridActionLog.Rows.RemoveAt(i);
            }

            Mos mos = new Mos();
            // USBメモリ情報を取得
            Dictionary<string, string> usbInfo = mos.GetUsbInformation();

            // ホワイトリストと突き合わせた結果の警告値を取得
            int alertMark = CheckWhitelist(usbInfo);

            if (alertMark == 1 && connNgUsb == 0) {
                connNgUsb = 1;

                MessageBox.Show(
                    "ホワイトリストに登録されていないUSBメモリの接続を確認しました。直ちに使用を中止し、接続を解除してください。",
                    "USB LOGGER"
                );
            } else if (alertMark == 1 && connNgUsb == 1) {
            }

            if (usbInfo.Equals(null)) {
                connUsbInfo.Clear();
            }

            if (connUsbInfo["usbSerialNo"] != usbInfo["usbSerialNo"]) {
                connUsbInfo.Clear();

                DoInsertUsbLog(usbInfo, connUsbInfo, alertMark);
            }
        }