c#读取个人签名到内存

发布时间:2020-03-21 23:31:22 作者:flybear006
来源:网络 阅读:464
//<summary>
         //<newpara>方法功能:读取个人签名到内存</newpara>
         //</summary>
         //<param name="vMarkName"></param>
         //<param name="vPassWord"></param>
         //<returns></returns>
        private byte[] LoadMarkImage(string szSql)
        {
            //bool mResult = false;
            byte[] m_bytFileBody = null;
            System.IO.MemoryStream oStream = null;
            System.IO.BinaryWriter oWriter = null;
            try
            {
                //string szSelectCmd = "SELECT c.MarkBody FROM OA_ESignature c where c.CO='XF01' and c.UserId='" + userid + "'";
                //if (m_oDbHelper == null)
                //{
                //    m_oDbHelper = new DbHelper();
                //}
                //m_oDbHelper.OpenDbResource();
                 
                DbCommand mCommand = m_oDbHelper.CreateDbCommand();
                mCommand.CommandType = CommandType.Text;
                mCommand.CommandText = szSql;
                IDataReader oReader = mCommand.ExecuteReader(System.Data.CommandBehavior.SequentialAccess);
               // LogCentral.CurrentLogger.LogInfo();
                if (oReader.Read())
                {
                    if (!oReader.IsDBNull(0))
                    {
                        int bufferSize = 500;                         // Size of the BLOB buffer.
                        byte[] outbyte = new byte[bufferSize];        // The BLOB byte[] buffer to be filled by GetBytes.
                        long retval;                                  // The bytes returned from GetBytes.
                        long startIndex = 0;                          // The starting position in the BLOB output.
                        // Get ACL By BLOB ColumnType
                        oStream = new System.IO.MemoryStream();
                        oWriter = new System.IO.BinaryWriter(oStream, System.Text.Encoding.UTF8);
                        startIndex = 0;
                        retval = oReader.GetBytes(0, startIndex, outbyte, 0, bufferSize); //ItemACL
                        // Continue reading and writing while there are bytes beyond the size of the buffer.
                        while (retval == bufferSize)
                        {
                            oWriter.Write(outbyte);
                            oWriter.Flush();
                            startIndex += bufferSize;
                            retval = oReader.GetBytes(0, startIndex, outbyte, 0, bufferSize); //ItemACL
                        }
                        // Write the remaining buffer.
                        oWriter.Write(outbyte, 0, (int)retval);
                    }
                    //m_szFileType = oReader.GetString(1).ToString();
                   // mResult = true;
                }
                //else
                //{
                //    mResult = false;
                //}
                oReader.Close();
                oReader = null;
                m_bytFileBody = oStream.GetBuffer();
                //LogCentral.CurrentLogger.LogInfo("m_bytFileBody:" + m_bytFileBody.ToString());
                LogCentral.CurrentLogger.LogInfo("m_bytFileBody:" + m_bytFileBody.Length);
            }
            catch (Exception e)
            {
                LogCentral.CurrentLogger.LogInfo(e.ToString());
                //mResult = false;
            }
            finally
            {
                //m_oDbHelper.CloseDbResource();
                try
                {
                    if (oWriter != null)
                    {
                        oWriter.Flush();
                        oWriter.Close();
                    }
                }
                catch { }
                try
                {
                    if (oStream != null)
                        oStream.Close();
                }
                catch { }
            }
            return m_bytFileBody;
        }


推荐阅读:
  1. C# 读取excel文件到DATAVIEW
  2. 从XML中如何读取数据到内存

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

sqlserver 数据库 读取 图

上一篇:os.system和os.popen的区别

下一篇:git 关联不同项目,以便比较

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》