Esempio n. 1
0
        public BitInfo Clone()
        {
            BitInfo info = new BitInfo();

            info.gps信息 = this.gps信息;
            info.人物    = this.人物;
            info.位深度   = this.位深度;
            info.作者    = this.作者;
            info.关键词   = this.关键词;
            info.分类    = this.分类;
            info.图片大小  = this.图片大小;
            info.图片宽   = this.图片宽;
            info.图片格式  = this.图片格式;
            info.图片高   = this.图片高;
            info.垂直分辨率 = this.垂直分辨率;
            info.摘要    = this.摘要;
            info.文件名称  = this.文件名称;
            info.时间    = this.时间;
            info.机构    = this.机构;
            info.标引人   = this.标引人;
            info.标引时间  = this.标引时间;
            info.标题    = this.标题;
            info.水平分辨率 = this.水平分辨率;
            info.评级    = this.评级;
            info.路径    = this.路径;
            return(info);
        }
Esempio n. 2
0
        private BitInfo GetBitInfo(string bitPath)
        {
            BitInfo bitinfo = null;

            SqliteHelper.SqliteHelper mysql = new SqliteHelper.SqliteHelper();
            if (!mysql.DBConnect(_localDBname))
            {
                throw new Exception("连接数据库失败");
            }

            string    sql   = "select * from u_picture where u_picture.picture_file='" + bitPath + "';";
            DataTable bitDt = mysql.DBReadTable(sql);

            mysql.DBDisConnect();

            if (bitDt == null)
            {
                throw new Exception("查询数据库失败");
            }
            else if (bitDt.Rows.Count == 0)
            {
                bitinfo = new BitInfo();
                GetBitmapInfo(bitPath, bitinfo);
            }
            else if (bitDt.Rows.Count == 1)
            {
                BitInfo[] bitinfos = DataTableConvert.TableToT <BitInfo>(bitDt);
                bitinfo = bitinfos[0];
            }
            else
            {
                throw new Exception("数据库数据有误,存在多条相同的记录");
            }
            return(bitinfo);
        }
Esempio n. 3
0
        private string InsertDB(string bitPath, BitInfo info, SqliteHelper.SqliteHelper mysql)
        {
            string    sql = "select * from u_picture where u_picture.picture_file='" + bitPath + "';";
            DataTable dt  = mysql.DBReadTable(sql);

            if (dt == null)
            {
                return("连接数据库失败");
            }
            else if (dt.Rows.Count == 0)
            {
                sql = "insert into u_picture(picture_name,picture_file,picture_title,picture_time,picture_author,picture_level,picture_info,picture_key,picture_person,picture_org,picture_type,picture_marker,picture_marktime,picture_width,picture_height,picture_hr,picture_vr,picture_bit,picture_gps,picture_size,picture_format)values('" + info.文件名称 + "','" + bitPath + "','" + info.标题 + "','" + info.时间 + "','" + info.作者 + "','" + info.评级 + "','" + info.摘要 + "','" + info.关键词 + "','" + info.人物 + "','" + info.机构 + "','" + info.分类 + "','" + info.标引人 + "','" + info.标引时间 + "','" + info.图片宽 + "','" + info.图片高 + "','" + info.水平分辨率 + "','" + info.垂直分辨率 + "','" + info.位深度 + "','" + info.gps信息 + "','" + info.图片大小 + "','" + info.图片格式 + "');";
                int res = mysql.DBUpdateInsert(sql);
                if (res == -1)
                {
                    return("写入数据失败");
                }
            }
            else if (dt.Rows.Count == 1)
            {
                sql = "update u_picture set picture_name='" + info.文件名称 + "',picture_title='" + info.标题 + "',picture_time='" + info.时间 + "',picture_author='" + info.作者 + "',picture_level='" + info.评级 + "',picture_info='" + info.摘要 + "',picture_key='" + info.关键词 + "', picture_person='" + info.人物 + "',picture_org='" + info.机构 + "',picture_type='" + info.分类 + "',picture_marker='" + info.标引人 + "',picture_marktime='" + info.标引时间 + "',picture_width='" + info.图片宽 + "',picture_height='" + info.图片高 + "',picture_hr='" + info.水平分辨率 + "',picture_vr='" + info.垂直分辨率 + "',picture_bit='" + info.位深度 + "',picture_gps='" + info.gps信息 + "',picture_size='" + info.图片大小 + "',picture_format='" + info.图片格式 + "' where id='" + dt.Rows[0]["id"].ToString() + "';";
                int res = mysql.DBUpdateInsert(sql);
                if (res != 1)
                {
                    return("写入数据库失败");
                }
            }
            else
            {
                return("数据库数据有误,存在多条相同的记录");
            }
            return(string.Empty);
        }
Esempio n. 4
0
        private void GetBitmapInfo(string path, BitInfo bitinfo)
        {
            bitinfo.路径 = path;
            if (File.Exists(path))
            {
                FileStream fs = new FileStream(path, FileMode.OpenOrCreate);
                bitinfo.图片大小 = fs.Length.ToString() + "byte";

                Bitmap bit = new Bitmap(fs);
                bitinfo.图片宽   = bit.Width.ToString();
                bitinfo.图片高   = bit.Height.ToString();
                bitinfo.图片格式  = Path.GetExtension(path).Substring(1);
                bitinfo.垂直分辨率 = bit.VerticalResolution.ToString();
                bitinfo.水平分辨率 = bit.HorizontalResolution.ToString();
                bitinfo.位深度   = GetBitDepth(bit.PixelFormat).ToString();
                bitinfo.gps信息 = fnGPS(bit);
                bit.Dispose();
                bit = null;
                fs.Close();
                fs.Dispose();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 设置显示图片信息
        /// </summary>
        /// <param name="bitpaths"></param>
        public void SetBitContent(string[] bitpaths)
        {
            if (_pathArray != null && _pathArray[0].Equals(bitpaths[0]))
            {
                _pathArray = bitpaths;
                return;
            }
            //第一次进来时加载配置文件
            if (_pathArray == null)
            {
                SetComboArray();
            }

            BitInfo info = GetBitInfo(bitpaths[0]);

            if (this.pg_context.SelectedObject != null)
            {
                this.pg_context.SelectedObject = null;
            }
            this.pg_context.Refresh();
            this.pg_context.SelectedObject = info;
            _pathArray = bitpaths;
        }
Esempio n. 6
0
        /// <summary>
        /// 上传
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUpload_MouseUp(object sender, MouseEventArgs e)
        {
            //未选中图片时点击上传
            if (_pathArray == null)
            {
                return;
            }
            SqliteHelper.SqliteHelper mysql = new SqliteHelper.SqliteHelper();
            try
            {
                btnUpload.Enabled = false;

                if (_pathArray.Length == 1)
                {
                    BitInfo bitinfo = this.pg_context.SelectedObject as BitInfo;
                    if (!mysql.DBConnect(_localDBname))
                    {
                        throw new Exception("连接数据库失败");
                    }
                    string res = InsertDB(_pathArray[0], bitinfo, mysql);
                }
                else if (_pathArray.Length > 1)
                {
                    BitInfo   bitinfo      = this.pg_context.SelectedObject as BitInfo;
                    BitInfo[] bitInfoArray = new BitInfo[_pathArray.Length];
                    for (int i = 0; i < _pathArray.Length; i++)
                    {
                        bitInfoArray[i] = bitinfo.Clone();
                        GetBitmapInfo(_pathArray[i], bitInfoArray[i]);
                    }

                    if (!mysql.DBConnect(_localDBname))
                    {
                        throw new Exception("连接数据库失败");
                    }
                    string res = string.Empty;
                    for (int i = 0; i < _pathArray.Length; i++)
                    {
                        res = InsertDB(_pathArray[0], bitInfoArray[i], mysql);
                        if (!string.IsNullOrEmpty(res))
                        {
                            throw new Exception(res);
                        }
                    }
                }
                else
                {
                    throw new Exception("数据库数据有误,存在多条相同的记录");
                }
                MessageBox.Show("上传成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                btnUpload.Enabled = true;
                mysql.DBDisConnect();
            }
        }