示例#1
0
        /// <summary>
        /// 打开SQL Server数据库
        /// </summary>
        /// <param name="filePath"></param>
        private void SelectSQL(string filePath)
        {
            DBlink mylink = new DBlink();

            TableList = mylink.SQLconection(filePath);
            if (TableList == null)
            {
                MessageBox.Show("数据库打开失败", "操作提示");
            }
            else
            {
                cmbTableList.IsEnabled = true;
                txtDBPath.Text         = filePath;
                lblDBType.Content      = DBType;
                cmbTableList.Items.Clear();
                for (int i = 0; i < TableList.Length; i++)
                {
                    cmbTableList.Items.Add(TableList[i]);
                }

                cmbTableList.SelectedIndex = 0;

                MessageBox.Show("数据库打开成功", "操作提示");
            }
        }
        private void btnStartLab_Click(object sender, RoutedEventArgs e)
        {
            if (cmbType.SelectedIndex >= 0)
            {
                try
                {
                    switch (cmbType.SelectedIndex)
                    {
                    case 0:
                        Add(int.Parse(txtlblPrompt1.Text), int.Parse(txtlblPrompt2.Text));
                        break;

                    case 2:
                        Upd(cmbField.Text, int.Parse(txtlblPrompt2.Text), txtlblPrompt3.Text);
                        break;

                    case 1:
                        Del(int.Parse(txtlblPrompt1.Text), int.Parse(txtlblPrompt2.Text));
                        break;
                    }

                    DBlink myLink = new DBlink();
                    dgvDB.ItemsSource = myLink.Read(TableName, DBType).DefaultView;
                }
                catch
                {
                    MessageBox.Show("参数错误!", "操作提示");
                }
            }
            else
            {
                MessageBox.Show("请您先选择实验类型!", "操作提示");
            }
        }
 public ViewForm(string TableName, string DBType)
 {
     InitializeComponent();
     this.TableName = TableName;
     this.DBType = DBType;
     lbTitle.Content = TableName;
     DBlink mylink = new DBlink();
     dgvDBView.ItemsSource = mylink.Read(TableName, DBType).DefaultView;
 }
        public ViewForm(string TableName, string DBType)
        {
            InitializeComponent();
            this.TableName  = TableName;
            this.DBType     = DBType;
            lbTitle.Content = TableName;
            DBlink mylink = new DBlink();

            dgvDBView.ItemsSource = mylink.Read(TableName, DBType).DefaultView;
        }
示例#5
0
        /// <summary>
        /// 选择数据表并获取数据量信息
        /// </summary>
        private void cmbTableList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbTableList.SelectedIndex >= 0)
            {
                int i;
                TableName = cmbTableList.Items[cmbTableList.SelectedIndex].ToString();
                DBlink mylink = new DBlink();
                DBInfo           = mylink.GetDBinfo(DBType, TableName);
                lblDBNum.Content = (int)DBInfo[0][0] + "行 " + (int)DBInfo[1][0] + "列 ";

                picDBInfo = new ArrayList[3] {
                    new ArrayList(), new ArrayList(), new ArrayList()
                };
                picDBInfo[0].Add(DBInfo[0][0]);
                picDBInfo[1].Add(DBInfo[3][0]);
                for (i = 0; i < DBInfo[4].Count; i++)
                {
                    picDBInfo[2].Add(DBInfo[4][i]);
                }
                if ((int)DBInfo[0][0] < 100)
                {
                    markLvl             = 0;
                    lblMarkType.Content = "数据量过小,不能注册零水印!";
                    grpStep2.IsEnabled  = false;
                    grpStep3.IsEnabled  = false;
                }
                else
                {
                    markLvl = 1;
                    markBit = (int)DBInfo[0][0] / 100 * 32;
                    //零水印位数控制
                    if (markBit > 1024)
                    {
                        markBit = 1024;
                    }

                    lblMarkType.Content = "可以注册零水印,水印为" + markBit + "位!";
                    grpStep2.IsEnabled  = true;
                    grpStep3.IsEnabled  = false;
                }

                if ((int)DBInfo[0][0] < 1500)
                {
                    lblPicInfo.Content = "数据量过小,不能注册图像水印!";
                }
                else
                {
                    markLvl            = 2;
                    lblPicInfo.Content = "可以加入图像,规格请参考帮助!";
                    grpStep2.IsEnabled = true;
                    grpStep3.IsEnabled = true;
                }
            }
        }
        private void Del(int from, int to)
        {
            DBlink myLink = new DBlink();

            try
            {
                myLink.DelAttack(TableName, from, to, DBType);
            }
            catch
            {
            }
        }
        private void Upd(string field, int id, string value)
        {
            DBlink myLink = new DBlink();

            try
            {
                myLink.UpdAttack(TableName, field, value, id, DBType);
            }
            catch
            {
            }
        }
示例#8
0
        /// <summary>
        /// 获取数据库信息
        /// </summary>
        /// <param name="markBit">水印位</param>
        /// <param name="markLocate1">水印位置</param>
        /// <param name="TableName">表名</param>
        /// <param name="DBType">数据库类型</param>
        /// <param name="field">字段名</param>
        /// <returns>读取的数据信息</returns>
        public string[] getDataInfo(int markBit, ArrayList[] markLocate1, string TableName, string DBType, ArrayList field)
        {
            string[] mydataInfo = new string[markBit];
            int      i;

            for (i = 0; i < markBit; i++)
            {
                DBlink myLink = new DBlink();
                mydataInfo[i] = myLink.getData((int)markLocate1[0][i], (int)markLocate1[1][i], TableName, DBType, field);
            }

            return(mydataInfo);
        }
示例#9
0
        private void cmbTableList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbTableList.SelectedIndex >= 0)
            {
                int i;
                TableName = cmbTableList.Items[cmbTableList.SelectedIndex].ToString();
                DBlink mylink = new DBlink();
                DBInfo           = mylink.GetDBinfo(DBType, TableName);
                lblDBNum.Content = (int)DBInfo[0][0] + "行 " + (int)DBInfo[1][0] + "列 ";

                picDBInfo[0].Add(sourceDBInfo[0][0]);
                for (i = 0; i < (int)picDBInfo[1][0]; i++)
                {
                    picDBInfo[2].Add(DBInfo[4][i]);
                }
                if ((int)sourceDBInfo[0][0] * (int)sourceDBInfo[1][0] < 100)
                {
                    markLvl             = 0;
                    lblMarkType.Content = "您的数据库没有注册水印!";
                    grpStep2.IsEnabled  = false;
                    grpStep3.IsEnabled  = false;
                }
                else
                {
                    markLvl = 1;
                    markBit = (int)sourceDBInfo[0][0] / 100 * 32;

                    if (markBit > 1024)
                    {
                        markBit = 1024;
                    }

                    lblMarkType.Content = "您的数据库注册了零水印" + markBit + "位!";
                    grpStep2.IsEnabled  = true;
                    grpStep3.IsEnabled  = false;
                }

                if ((int)sourceDBInfo[0][0] * (int)sourceDBInfo[1][0] < 1500)
                {
                    lblPicInfo.Content = "您的数据库没有注册图像水印!";
                }
                else
                {
                    markLvl            = 2;
                    lblPicInfo.Content = "您的数据库注册了图像水印!";
                    grpStep2.IsEnabled = true;
                    grpStep3.IsEnabled = true;
                }
            }
        }
        /// <summary>
        /// 打开SQL Server数据库
        /// </summary>
        /// <param name="filePath"></param>
        private void SelectSQL()
        {
            DBlink mylink = new DBlink();

            TableList = mylink.SQLconection(txtDBPath.Text);
            if (TableList == null)
            {
                MessageBox.Show("数据库打开失败", "操作提示");
            }
            else
            {
                dgvDB.ItemsSource = mylink.Read(TableName, DBType).DefaultView;
            }
        }
示例#11
0
        public void DelMarkAdapter(string TableName, string DBType, ArrayList[] DBInfo)
        {
            int    i;
            int    j;
            DBlink mylink = new DBlink();

            for (i = 0; i < (int)DBInfo[0][0]; i++)
            {
                for (j = 0; j < (int)DBInfo[1][0]; j++)
                {
                    mylink.DelOldMark(i, j, TableName, DBType, DBInfo[2]);
                }
            }
        }
示例#12
0
        /*
         * /// <summary>
         * /// 重载加入图片水印
         * /// </summary>
         * /// <param name="picLen"></param>
         * /// <param name="bufPic"></param>
         * /// <param name="Hamming">循环冗余检验</param>
         * /// <param name="markLocate2"></param>
         * /// <param name="TableName"></param>
         * /// <param name="DBType"></param>
         * /// <param name="field"></param>
         * public void PicMark(int picLen, byte[] bufPic, string Hamming, ArrayList[] markLocate2, byte picX, byte picY, string TableName, string DBType, ArrayList field)
         * {
         *  int i;
         *  string mark = "";
         *  string head;
         *  string tail;
         *  int picMarkBit;
         *  picMarkBit = (picLen - 62) * 8 + picX / 4 * 3 * picY;
         *
         *  for (i = 62; i < picLen; i++)
         *  {
         *      string binary = System.Convert.ToString(bufPic[i], 2);
         *      while (binary.Length < 8)
         *      {
         *          binary = binary.Insert(0, "0");
         *      }
         *      head = binary.Substring(0, 4);
         *      tail = binary.Substring(4, 4);
         *      mark = mark + head + Hamming.Substring((i - 62) * 2 * 3, 3) + tail + Hamming.Substring(((i - 62) * 2 + 1) * 3, 3);
         *  }
         *
         *  for (i = 0; i < picMarkBit; i++)
         *  {
         *      DBlink myLink = new DBlink();
         *      myLink.AddPicInfo(mark[i], (int)markLocate2[0][i], (int)markLocate2[1][i], TableName, DBType, field);
         *  }
         * }
         */
        public byte[] GetPic(int picLen, byte picOffset1, byte picOffset2, byte picX, byte picY, ArrayList[] markLocate2, string TableName, string DBType, ArrayList field)
        {
            int    i;
            string temp;
            int    picMarkBit;

            byte[] myPic = new byte[picLen];
            string mark  = "";
            int    count = 0;
            int    key   = 62;

            byte[] head = { 66, 77, picOffset1, picOffset2, 0, 0, 0, 0,   0,   0,  62,   0, 0, 0, 40, 0, 0, 0, picX, 0, 0, 0, picY,
                            0,   0,          0,          1, 0, 1, 0, 0,   0,   0,   0,   0, 0, 0,  0, 0, 0, 0,    0, 0, 0, 0,    0,2, 0, 0,
                            0,   2,          0,          0, 0, 0, 0, 0, 255, 255, 255, 255, 255 };


            picMarkBit = (picLen - 62) * 8;

            for (i = 0; i < picMarkBit; i++)
            {
                DBlink myLink = new DBlink();
                temp = myLink.GetPicInfo((int)markLocate2[0][i], (int)markLocate2[1][i], TableName, DBType, field);

                if ((int)temp[temp.Length - 1] == 8204)
                {
                    mark += 0;
                }
                else
                {
                    mark += 1;
                }

                count++;
                if (count == 8)
                {
                    count      = 0;
                    myPic[key] = System.Convert.ToByte(mark, 2);
                    mark       = "";
                    key++;
                }
            }
            for (i = 0; i < 62; i++)
            {
                myPic[i] = head[i];
            }

            return(myPic);
        }
示例#13
0
        /// <summary>
        /// 加入图片水印
        /// </summary>
        /// <param name="bufPic">图片信息</param>
        /// <param name="markBit">水印位</param>
        /// <param name="markLocate2">水印位置</param>
        /// <param name="TableName">数据表名</param>
        /// <param name="DBType">数据库类型</param>
        /// <param name="field">字段名</param>
        public void PicMark(int picLen, byte[] bufPic, ArrayList[] markLocate2, string TableName, string DBType, ArrayList field)
        {
            int    i;
            string mark = "";
            int    picMarkBit;

            picMarkBit = (picLen - 62) * 8;

            for (i = 62; i < picLen; i++)
            {
                string binary = System.Convert.ToString(bufPic[i], 2);
                while (binary.Length < 8)
                {
                    binary = binary.Insert(0, "0");
                }
                mark += binary;
            }

            for (i = 0; i < picMarkBit; i++)
            {
                DBlink myLink = new DBlink();
                myLink.AddPicInfo(mark[i], (int)markLocate2[0][i], (int)markLocate2[1][i], TableName, DBType, field);
            }
        }
        public void DelMarkAdapter(string TableName, string DBType, ArrayList[] DBInfo)
        {
            int i;
            int j;
            DBlink mylink = new DBlink();

            for (i = 0; i < (int)DBInfo[0][0]; i++)
                for (j = 0; j < (int)DBInfo[1][0]; j++)
                    mylink.DelOldMark(i, j, TableName, DBType, DBInfo[2]);

        }
        /// <summary>
        /// 加入图片水印
        /// </summary>
        /// <param name="bufPic">图片信息</param>
        /// <param name="markBit">水印位</param>
        /// <param name="markLocate2">水印位置</param>
        /// <param name="TableName">数据表名</param>
        /// <param name="DBType">数据库类型</param>
        /// <param name="field">字段名</param>
        public void PicMark(int picLen, byte[] bufPic, ArrayList[] markLocate2, string TableName, string DBType, ArrayList field)
        {
            int i;
            string mark = "";
            int picMarkBit;
            picMarkBit = (picLen - 62) * 8;

            for (i = 62; i < picLen; i++)
            {
                string binary = System.Convert.ToString(bufPic[i], 2);
                while (binary.Length < 8)
                {
                    binary = binary.Insert(0, "0");
                }
                mark += binary;
            }

            for (i = 0; i < picMarkBit; i++)
            {
                DBlink myLink = new DBlink();
                myLink.AddPicInfo(mark[i], (int)markLocate2[0][i], (int)markLocate2[1][i], TableName, DBType, field);
            }
        }
        /*
       /// <summary>
        /// 重载加入图片水印
       /// </summary>
       /// <param name="picLen"></param>
       /// <param name="bufPic"></param>
        /// <param name="Hamming">循环冗余检验</param>
       /// <param name="markLocate2"></param>
       /// <param name="TableName"></param>
       /// <param name="DBType"></param>
       /// <param name="field"></param>
        public void PicMark(int picLen, byte[] bufPic, string Hamming, ArrayList[] markLocate2, byte picX, byte picY, string TableName, string DBType, ArrayList field)
        {
            int i;
            string mark = "";
            string head;
            string tail;
            int picMarkBit;
            picMarkBit = (picLen - 62) * 8 + picX / 4 * 3 * picY;

            for (i = 62; i < picLen; i++)
            {
                string binary = System.Convert.ToString(bufPic[i], 2);
                while (binary.Length < 8)
                {
                    binary = binary.Insert(0, "0");
                }
                head = binary.Substring(0, 4);
                tail = binary.Substring(4, 4);
                mark = mark + head + Hamming.Substring((i - 62) * 2 * 3, 3) + tail + Hamming.Substring(((i - 62) * 2 + 1) * 3, 3);
            }

            for (i = 0; i < picMarkBit; i++)
            {
                DBlink myLink = new DBlink();
                myLink.AddPicInfo(mark[i], (int)markLocate2[0][i], (int)markLocate2[1][i], TableName, DBType, field);
            }
        }
*/
        public byte[] GetPic(int picLen, byte picOffset1, byte picOffset2, byte picX, byte picY, ArrayList[] markLocate2, string TableName, string DBType, ArrayList field)
        {
            int i;
            string temp;
            int picMarkBit;
            byte[] myPic = new byte[picLen];
            string mark = "";
            int count = 0;
            int key = 62;
            byte[] head = {66,77,picOffset1,picOffset2,0,0,0,0,0,0,62,0,0,0,40,0,0,0,picX,0,0,0,picY,
                              0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
                              0,2,0,0,0,0,0,0,255,255,255,255,255};


            picMarkBit = (picLen - 62) * 8;

            for (i = 0; i < picMarkBit; i++)
            {
                DBlink myLink = new DBlink();
                temp = myLink.GetPicInfo((int)markLocate2[0][i], (int)markLocate2[1][i], TableName, DBType, field);

                if ((int)temp[temp.Length - 1] == 8204)
                    mark += 0;
                else
                    mark += 1;

                count++;
                if (count == 8)
                {
                    count = 0;
                    myPic[key] = System.Convert.ToByte(mark, 2);
                    mark = "";
                    key++;
                }
            }
            for (i = 0; i < 62; i++)
            {
                myPic[i] = head[i];
            }

            return myPic;
        }
        private void cmbTableList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbTableList.SelectedIndex >= 0)
            {
                int i;
                TableName = cmbTableList.Items[cmbTableList.SelectedIndex].ToString();
                DBlink mylink = new DBlink();
                DBInfo = mylink.GetDBinfo(DBType, TableName);
                lblDBNum.Content = (int)DBInfo[0][0] + "行 " + (int)DBInfo[1][0] + "列 ";
              
                picDBInfo[0].Add(sourceDBInfo[0][0]);
                for (i = 0; i < (int)picDBInfo[1][0]; i++)
                    picDBInfo[2].Add(DBInfo[4][i]);
                if ((int)sourceDBInfo[0][0] * (int)sourceDBInfo[1][0] < 100)
                {
                    markLvl = 0;
                    lblMarkType.Content = "您的数据库没有注册水印!";
                    grpStep2.IsEnabled = false;
                    grpStep3.IsEnabled = false;
                }
                else
                {
                    markLvl = 1;
                    markBit = (int)sourceDBInfo[0][0] / 100 * 32;

                    if (markBit > 1024)
                        markBit = 1024;

                    lblMarkType.Content = "您的数据库注册了零水印" + markBit + "位!";
                    grpStep2.IsEnabled = true;
                    grpStep3.IsEnabled = false;
                }

                if ((int)sourceDBInfo[0][0] * (int)sourceDBInfo[1][0] < 1500)
                {
                    lblPicInfo.Content = "您的数据库没有注册图像水印!";
                }
                else
                {
                    markLvl = 2;
                    lblPicInfo.Content = "您的数据库注册了图像水印!";
                    grpStep2.IsEnabled = true;
                    grpStep3.IsEnabled = true;
                }
            }
        }
示例#18
0
        /// <summary>
        /// 打开SQL Server数据库
        /// </summary>
        /// <param name="filePath"></param>
        private void SelectSQL(string filePath)
        {
  
            DBlink mylink = new DBlink();
            TableList = mylink.SQLconection(filePath);
            if (TableList == null)
            {
                MessageBox.Show("数据库打开失败", "操作提示");
            }
            else
            {        
                cmbTableList.IsEnabled = true;
                txtDBPath.Text = filePath;
                lblDBType.Content = DBType;
                cmbTableList.Items.Clear();
                for (int i = 0; i < TableList.Length; i++)
                {
                    cmbTableList.Items.Add(TableList[i]);
                }

                cmbTableList.SelectedIndex = 0;

                MessageBox.Show("数据库打开成功", "操作提示");
            }
        }
 private void Del(int from, int to)
 {
     DBlink myLink = new DBlink();
     try
     {
         myLink.DelAttack(TableName, from, to, DBType);
     }
     catch
     {
     }
 }
        private void btnStartLab_Click(object sender, RoutedEventArgs e)
        {
            if (cmbType.SelectedIndex >= 0)
            {
                try
                {
                    switch (cmbType.SelectedIndex)
                    {
                        case 0:
                            Add(int.Parse(txtlblPrompt1.Text), int.Parse(txtlblPrompt2.Text));
                            break;
                        case 2:
                            Upd(cmbField.Text, int.Parse(txtlblPrompt2.Text), txtlblPrompt3.Text );
                            break;
                        case 1:
                            Del(int.Parse(txtlblPrompt1.Text), int.Parse(txtlblPrompt2.Text));
                            break;
                    }

                    DBlink myLink = new DBlink();
                    dgvDB.ItemsSource = myLink.Read(TableName, DBType).DefaultView;
                }
                catch
                {
                    MessageBox.Show("参数错误!", "操作提示");
                }
            }
            else
            {
                MessageBox.Show("请您先选择实验类型!", "操作提示");
            }
        }
 /// <summary>
 /// 打开SQL Server数据库
 /// </summary>
 /// <param name="filePath"></param>
 private void SelectSQL()
 {
     DBlink mylink = new DBlink();
     TableList = mylink.SQLconection(txtDBPath.Text);
     if (TableList == null)
     {
         MessageBox.Show("数据库打开失败", "操作提示");
     }
     else
     {
         dgvDB.ItemsSource = mylink.Read(TableName, DBType).DefaultView;
        
     }
 }
        /// <summary>
        /// 获取数据库信息
        /// </summary>
        /// <param name="markBit">水印位</param>
        /// <param name="markLocate1">水印位置</param>
        /// <param name="TableName">表名</param>
        /// <param name="DBType">数据库类型</param>
        /// <param name="field">字段名</param>
        /// <returns>读取的数据信息</returns>
        public string[] getDataInfo(int markBit, ArrayList[] markLocate1, string TableName, string DBType, ArrayList field)
        {
            string[] mydataInfo = new string[markBit];
            int i;

            for (i = 0; i < markBit; i++)
            {
                DBlink myLink = new DBlink();
                mydataInfo[i] = myLink.getData((int)markLocate1[0][i], (int)markLocate1[1][i], TableName, DBType, field);
            }

            return mydataInfo;
        }
        private void btnRefresh_Click(object sender, RoutedEventArgs e)
        {
            DBlink myLink = new DBlink();

            dgvDBView.ItemsSource = myLink.Read(TableName, DBType).DefaultView;
        }
 private void btnRefresh_Click(object sender, RoutedEventArgs e)
 {
     DBlink myLink = new DBlink();
     dgvDBView.ItemsSource = myLink.Read(TableName, DBType).DefaultView;
 }
 private void Upd(string field, int id, string value)
 {
     DBlink myLink = new DBlink();
     try
     {
         myLink.UpdAttack(TableName, field, value, id, DBType);
     }
     catch
     {
     }
 }
示例#26
0
        /// <summary>
        /// 选择数据表并获取数据量信息
        /// </summary>
        private void cmbTableList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbTableList.SelectedIndex >= 0)
            {
                int i;
                TableName = cmbTableList.Items[cmbTableList.SelectedIndex].ToString();
                DBlink mylink = new DBlink();
                DBInfo = mylink.GetDBinfo(DBType, TableName);
                lblDBNum.Content = (int)DBInfo[0][0] + "行 " + (int)DBInfo[1][0] + "列 ";

                picDBInfo = new ArrayList[3] { new ArrayList(), new ArrayList(), new ArrayList() };
                picDBInfo[0].Add(DBInfo[0][0]);
                picDBInfo[1].Add(DBInfo[3][0]);
                for (i = 0; i < DBInfo[4].Count; i++)
                    picDBInfo[2].Add(DBInfo[4][i]);
                    if ((int)DBInfo[0][0] < 100)
                    {
                        markLvl = 0;
                        lblMarkType.Content = "数据量过小,不能注册零水印!";
                        grpStep2.IsEnabled = false;
                        grpStep3.IsEnabled = false;
                    }
                    else
                    {
                        markLvl = 1;
                        markBit = (int)DBInfo[0][0] / 100 * 32;
                        //零水印位数控制
                        if (markBit > 1024)
                            markBit = 1024;

                        lblMarkType.Content = "可以注册零水印,水印为" + markBit + "位!";
                        grpStep2.IsEnabled = true;
                        grpStep3.IsEnabled = false;
                    }

                if ((int)DBInfo[0][0] < 1500)
                {
                    lblPicInfo.Content = "数据量过小,不能注册图像水印!";
                }
                else
                {
                    markLvl = 2;
                    lblPicInfo.Content = "可以加入图像,规格请参考帮助!";
                    grpStep2.IsEnabled = true;
                    grpStep3.IsEnabled = true;
                }
            }
        }