/// <summary>
        /// 调取文件
        /// </summary>
        /// <param name="FileID">文件ID</param>
        /// <returns>文件文件流</returns>
        public byte[] LoadFile(string FileID)
        {
            byte[] objResult = null;
            string strSQL    = "select FILE_BODY from T_RPT_FILE where id='{0}'";

            strSQL = String.Format(strSQL, FileID);

            objConnection = new SqlConnection(strConnection);
            objCommand    = new SqlCommand(strSQL, objConnection);

            try
            {
                objConnection.Open();
                objReader = objCommand.ExecuteReader();

                if (objReader.Read())
                {
                    objResult = objReader.GetSqlBinary(0).Value;
                }
            }
            catch (Exception ex)
            {
                Tips.Append(ex.Message);
            }
            finally
            {
                objConnection.Close();
                objConnection.Dispose();
                objCommand.Dispose();
                objReader.Dispose();
            }

            return(objResult);
        }
        /// <summary>
        /// 保存文件
        /// 1、如果存在,覆盖原文件;
        /// 2、如果不存在,插入该文件;
        /// </summary>
        /// <param name="template">文件对象</param>
        /// <returns>是否成功</returns>
        public bool SaveFile(TRptFileVo file)
        {
            string strSQL    = String.Empty;
            bool   bolResult = false;

            //bool bolContract = false;

            if (ExistThisFile(file.ID))
            {
                strSQL = " {0} WHERE ID = '{1}' ";
                strSQL = string.Format(strSQL, SqlHelper.BuildUpdateExpress(file, TRptFileVo.T_RPT_FILE_TABLE), file.ID);
            }
            else
            {
                //设置序列号
                if (String.IsNullOrEmpty(file.ID))
                {
                    file.ID = base.GetSerialNumber("Rpt_Id");
                }

                strSQL = SqlHelper.BuildInsertExpress(file, TRptFileVo.T_RPT_FILE_TABLE);
            }

            //FileBody是Image数据类型,在此进行特别处理
            if (!String.IsNullOrEmpty(strSQL))
            {
                string NewFiled = "@" + TRptFileVo.FILE_BODY_FIELD;
                strSQL = strSQL.Replace("'System.Byte[]'", NewFiled);

                objConnection = new SqlConnection(base.strConnection);
                objCommand    = new SqlCommand(strSQL, objConnection);

                objCommand.Parameters.Add(new SqlParameter(NewFiled, SqlDbType.Image));
                objCommand.Parameters[NewFiled].Value = file.FILE_BODY;

                try
                {
                    objConnection.Open();
                    bolResult = objCommand.ExecuteNonQuery() > 0 ? true : false;
                    //bolContract = (file.CONTRACT_ID.Trim().Length > 0) ? UpdateContractInfo(file.CONTRACT_ID, file.ID) : true;
                }
                catch (Exception ex)
                {
                    Tips.Append(ex.Message);
                }
                finally
                {
                    objConnection.Close();
                    objConnection.Dispose();
                    objCommand.Dispose();
                }
            }

            //return bolResult && bolContract;
            return(bolResult);
        }
        /// <summary>
        /// 调取指定文档的所有印章
        /// </summary>
        /// <param name="FileID">文件ID</param>
        /// <returns>印章对象</returns>
        public TRptFileSignatureVo LoadSignature(string FileID)
        {
            string strSQL = " select mark_name,add_user,add_time,add_ip,mark_guid from T_RPT_FILE_SIGNATURE where file_id='{0}' ";

            strSQL = String.Format(strSQL, FileID);
            StringBuilder objMarkName = new StringBuilder();
            StringBuilder objAddUser  = new StringBuilder();
            StringBuilder objAddTime  = new StringBuilder();
            StringBuilder objAddIP    = new StringBuilder();
            StringBuilder objMarkGuid = new StringBuilder();

            objConnection = new SqlConnection(strConnection);
            objCommand    = new SqlCommand(strSQL, objConnection);

            TRptFileSignatureVo signature = new TRptFileSignatureVo();

            try
            {
                objConnection.Open();
                objReader = objCommand.ExecuteReader();

                while (objReader.Read())
                {
                    objMarkName.Append(objReader[TRptFileSignatureVo.MARK_NAME_FIELD] + "\r\n");
                    objAddUser.Append(objReader[TRptFileSignatureVo.ADD_USER_FIELD] + "\r\n");
                    objAddTime.Append(objReader.GetDateTime(2).ToString("yyyy-MM-dd HH:mm:ss") + "\r\n");
                    objAddIP.Append(objReader[TRptFileSignatureVo.ADD_IP_FIELD] + "\r\n");
                    objMarkGuid.Append(objReader[TRptFileSignatureVo.MARK_GUID_FIELD] + "\r\n");
                }
            }
            catch (Exception ex)
            {
                Tips.Append(ex.Message);
            }
            finally
            {
                signature.MARK_NAME = objMarkName.ToString();
                signature.ADD_USER  = objAddUser.ToString();
                signature.ADD_TIME  = objAddTime.ToString();
                signature.ADD_IP    = objAddIP.ToString();
                signature.MARK_GUID = objMarkGuid.ToString();

                objConnection.Close();
                objConnection.Dispose();
                objCommand.Dispose();
                objReader.Dispose();
            }

            return(signature);
        }
Exemple #4
0
        /// <summary>
        /// 保存模板文件
        /// 1、如果存在,覆盖原模板;
        /// 2、如果不存在,插入该模板;
        /// </summary>
        /// <param name="template">模板对象</param>
        /// <returns>是否成功</returns>
        public bool SaveTemplate(TRptTemplateVo template)
        {
            string strSQL    = String.Empty;
            bool   bolResult = false;

            if (ExistThisTemplate(template.ID))
            {
                strSQL = " {0} WHERE ID = '{1}' ";
                strSQL = string.Format(strSQL, SqlHelper.BuildUpdateExpress(template, TRptTemplateVo.T_RPT_TEMPLATE_TABLE), template.ID);
            }
            else
            {
                //设置序列号
                template.ID = base.GetSerialNumber("Template_Id");
                strSQL      = SqlHelper.BuildInsertExpress(template, TRptTemplateVo.T_RPT_TEMPLATE_TABLE);
            }

            //FileBody是Image数据类型,在此进行特别处理
            if (!String.IsNullOrEmpty(strSQL))
            {
                string NewFiled = "@" + TRptTemplateVo.FILE_BODY_FIELD;
                strSQL = strSQL.Replace("'System.Byte[]'", NewFiled);

                objConnection = new SqlConnection(base.strConnection);
                objCommand    = new SqlCommand(strSQL, objConnection);

                objCommand.Parameters.Add(new SqlParameter(NewFiled, SqlDbType.Image));
                objCommand.Parameters[NewFiled].Value = template.FILE_BODY;

                try
                {
                    objConnection.Open();
                    bolResult = objCommand.ExecuteNonQuery() > 0 ? true : false;
                }
                catch (Exception ex)
                {
                    Tips.Append(ex.Message);
                }
                finally
                {
                    objCommand.Dispose();
                }
            }

            return(bolResult);
        }
        /// <summary>
        /// 调取所有的印章
        /// </summary>
        /// <param name="MarkList">印章列表</param>
        /// <returns>是否成功</returns>
        public bool LoadMarkList(out string MarkList)
        {
            bool          bolResult = false;
            string        strSQL    = " select mark_name from T_RPT_SIGNATURE ";
            StringBuilder objMark   = new StringBuilder();

            objConnection = new SqlConnection(strConnection);
            objCommand    = new SqlCommand(strSQL, objConnection);

            try
            {
                objConnection.Open();
                objReader = objCommand.ExecuteReader();

                while (objReader.Read())
                {
                    objMark.Append(objReader["mark_name"] + "\r\n");
                }
            }
            catch (Exception ex)
            {
                Tips.Append(ex.Message);
            }
            finally
            {
                if (objMark.Length > 0)
                {
                    //转化值对象
                    MarkList  = objMark.ToString();
                    bolResult = true;
                }
                else
                {
                    MarkList = String.Empty;
                }

                objConnection.Close();
                objConnection.Dispose();
                objCommand.Dispose();
                objReader.Dispose();
            }

            return(bolResult);
        }
        /// <summary>
        /// 根据用户名和密码调取印章
        /// </summary>
        /// <param name="UserName">用户名</param>
        /// <param name="PassWord">密码</param>
        /// <param name="Mark_Body">文件流</param>
        /// <param name="Mark_Type">文件类型</param>
        /// <returns>是否成功</returns>
        public bool LoadMarkImage(string UserName, string PassWord, out byte[] Mark_Body, out string Mark_Type)
        {
            bool bolResult = false;

            Mark_Body = null;
            Mark_Type = String.Empty;
            string strSQL = " select mark_body,mark_type from T_RPT_SIGNATURE where user_name='{0}' and pass_word='{1}' ";

            strSQL        = String.Format(strSQL, UserName, PassWord);
            objConnection = new SqlConnection(strConnection);
            objCommand    = new SqlCommand(strSQL, objConnection);

            try
            {
                objConnection.Open();
                objReader = objCommand.ExecuteReader();

                if (objReader.Read())
                {
                    Mark_Body = objReader.GetSqlBinary(0).Value;
                    Mark_Type = objReader.GetString(1).ToString();

                    bolResult = true;
                }
            }
            catch (Exception ex)
            {
                Tips.Append(ex.Message);
            }
            finally
            {
                objConnection.Close();
                objConnection.Dispose();
                objCommand.Dispose();
                objReader.Dispose();
            }

            return(bolResult);
        }
        /// <summary>
        /// 列出所有的标签
        /// </summary>
        /// <param name="MarkName">标签名称</param>
        /// <param name="MarkDesc">标签描述</param>
        /// <returns></returns>
        public void ListBookMarks(out string MarkName, out string MarkDesc)
        {
            string        strSQL  = " select mark_name,mark_desc from T_RPT_MARK ";
            StringBuilder objName = new StringBuilder();
            StringBuilder objDesc = new StringBuilder();

            objConnection = new SqlConnection(strConnection);
            objCommand    = new SqlCommand(strSQL, objConnection);

            try
            {
                objConnection.Open();
                objReader = objCommand.ExecuteReader();

                while (objReader.Read())
                {
                    objName.Append(objReader["mark_name"] + "\r\n");
                    objDesc.Append(objReader["mark_desc"] + "\r\n");
                }
            }
            catch (Exception ex)
            {
                Tips.Append(ex.Message);
            }
            finally
            {
                //转化值对象
                MarkName = objName.ToString();
                MarkDesc = objDesc.ToString();

                objConnection.Close();
                objConnection.Dispose();
                objCommand.Dispose();
                objReader.Dispose();
            }
        }