Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string AttachGuid = Request.QueryString["AttachGuid"];

            if (Request.QueryString["bytedata"] != null && Request.QueryString["bytedata"] == "1")
            {
                Detail_AttachInfo att = new StorageCom().GetDetail(AttachGuid);
                Response.BinaryWrite(att.Content);
                Response.End();
            }
            else
            {
                Detail_AttachInfo att = new StorageCom().GetDetail_NoContent(AttachGuid);
                #region 采用临时文件方法
                if (att.StorageType.ToLower() == "file")//文件存储方式
                {
                    Response.Redirect(Epoint.Frame.Bizlogic.common.GetApplicationPath() + att.FilePath);
                }
                else
                {
                    string attPath = Epoint.Frame.Bizlogic.BasePage.GetApplicationPath() + "AttachStorage/";
                    Epoint.Frame.Bizlogic.common.CreatRootTempFolder();

                    if (!Directory.Exists(Server.MapPath(attPath + "/" + att.AttachGuid)))
                    {
                        Directory.CreateDirectory(Server.MapPath(attPath + "/" + att.AttachGuid));
                    }

                    string strFullFilePath = Server.MapPath(attPath + "/" + att.AttachGuid + "/" + att.AttachFileName.Replace("\"", "“"));

                    //当文件大小为0时删除文件重新生成
                    if (File.Exists(strFullFilePath) && new FileInfo(strFullFilePath).Length == 0)
                    {
                        File.Delete(strFullFilePath);
                    }
                    //二进制文件写必须用binaryWrite,不需要制定encoding方式
                    if (!File.Exists(strFullFilePath))
                    {
                        FileStream   objFileStream   = new FileStream(strFullFilePath, FileMode.OpenOrCreate, FileAccess.Write);
                        BinaryWriter objBinaryWriter = new BinaryWriter(objFileStream);
                        objBinaryWriter.Write(new StorageCom().GetContentByAttachGuid(AttachGuid));
                        objBinaryWriter.Close();
                        objFileStream.Close();
                        #region 如果是图片,则加上水印
                        #endregion
                    }
                    string AttachFileURL = attPath + att.AttachGuid + "/" + att.AttachFileName.Replace("\"", "“");
                    Response.Redirect(AttachFileURL);
                }
                #endregion
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string AttachGuid = Request.QueryString["AttachGuid"];

            if (Request.QueryString["bytedata"] != null && Request.QueryString["bytedata"] == "1")
            {
                Detail_AttachInfo att = new StorageCom().GetDetail(AttachGuid);
                Response.BinaryWrite(att.Content);
                Response.End();
            }
            else
            {
                Detail_AttachInfo att = new StorageCom().GetDetail_NoContent(AttachGuid);
                #region ������ʱ�ļ�����
                if (att.StorageType.ToLower() == "file")//�ļ��洢��ʽ
                    Response.Redirect(Epoint.Frame.Bizlogic.common.GetApplicationPath() + att.FilePath);
                else
                {

                    string attPath = Epoint.Frame.Bizlogic.BasePage.GetApplicationPath() + "AttachStorage/";
                    Epoint.Frame.Bizlogic.common.CreatRootTempFolder();

                    if (!Directory.Exists(Server.MapPath(attPath + "/" + att.AttachGuid)))
                        Directory.CreateDirectory(Server.MapPath(attPath + "/" + att.AttachGuid));

                    string strFullFilePath = Server.MapPath(attPath + "/" + att.AttachGuid + "/" + att.AttachFileName.Replace("\"", "��"));

                    //���ļ���СΪ0ʱɾ���ļ���������
                    if (File.Exists(strFullFilePath) && new FileInfo(strFullFilePath).Length == 0)
                    {
                        File.Delete(strFullFilePath);
                    }
                    //�������ļ�д������binaryWrite,����Ҫ�ƶ�encoding��ʽ
                    if (!File.Exists(strFullFilePath))
                    {
                        FileStream objFileStream = new FileStream(strFullFilePath, FileMode.OpenOrCreate, FileAccess.Write);
                        BinaryWriter objBinaryWriter = new BinaryWriter(objFileStream);
                        objBinaryWriter.Write(new StorageCom().GetContentByAttachGuid(AttachGuid));
                        objBinaryWriter.Close();
                        objFileStream.Close();
                        #region �����ͼƬ�������ˮӡ
                        #endregion
                    }
                    string AttachFileURL = attPath + att.AttachGuid + "/" + att.AttachFileName.Replace("\"", "��");
                    Response.Redirect(AttachFileURL);
                }
                #endregion
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string AttachGuid = Request.QueryString["AttachGuid"];

            if (Request.QueryString["bytedata"] != null && Request.QueryString["bytedata"] == "1")
            {
                Detail_AttachInfo att = new StorageCom().GetDetail(AttachGuid);
                Response.BinaryWrite(att.Content);
                Response.End();
            }
            else
            {
                Detail_AttachInfo att = new StorageCom().GetDetail_NoContent(AttachGuid);
                string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                #region ������ʱ�ļ�����
                if (att.StorageType.ToLower() == "file")//�ļ��洢��ʽ
                    Response.Redirect(Epoint.Frame.Bizlogic.common.GetApplicationPath() + att.FilePath);
                else
                {

                    string attPath = Epoint.Frame.Bizlogic.BasePage.GetApplicationPath() + "AttachStorage/";
                    Epoint.Frame.Bizlogic.common.CreatRootTempFolder();

                    if (!Directory.Exists(Server.MapPath(attPath + "/" + att.AttachGuid)))
                        Directory.CreateDirectory(Server.MapPath(attPath + "/" + att.AttachGuid));

                    string strFullFilePath = Server.MapPath(attPath + "/" + att.AttachGuid + "/" + att.AttachFileName.Replace("\"", "��"));

                    //���ļ���СΪ0ʱɾ���ļ���������
                    if (File.Exists(strFullFilePath) && new FileInfo(strFullFilePath).Length == 0)
                    {
                        File.Delete(strFullFilePath);
                    }
                    //�������ļ�д������binaryWrite,����Ҫ�ƶ�encoding��ʽ
                    if (!File.Exists(strFullFilePath))
                    {
                        FileStream objFileStream = new FileStream(strFullFilePath, FileMode.OpenOrCreate, FileAccess.Write);
                        BinaryWriter objBinaryWriter = new BinaryWriter(objFileStream);
                        objBinaryWriter.Write(new StorageCom().GetContentByAttachGuid(AttachGuid));
                        objBinaryWriter.Close();
                        objFileStream.Close();
                    }
                    string AttachFileURL = attPath + att.AttachGuid + "/" + att.AttachFileName.Replace("\"", "��");

                    string WatermarkImageUrl = Server.MapPath(Request.ApplicationPath + "/HTProject/Pages/Images/��ͬ��������.gif");
                    string message = "";

                    string diskName = Server.MapPath(AttachFileURL); //Request.ApplicationPath + "/AttachStorage/" + fileName + "XMBA.pdf"
                    string fileNew = Request.ApplicationPath + "/AttachStorage/" + fileName + "_2XMBA.pdf";
                    if (Request["SAdd"] == "SN")
                    {
                        WatermarkPDF_SN(diskName, Server.MapPath(fileNew), WatermarkImageUrl, 200, 500, 115, 115, out message);
                    }
                    else
                    {
                        WatermarkPDF_SW(diskName, Server.MapPath(fileNew), WatermarkImageUrl, 568, 500, 115, 115, out message);
                    }

                    Response.Redirect(fileNew);
                }
                #endregion
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string AttachGuid = Request.QueryString["AttachGuid"];

            if (Request.QueryString["bytedata"] != null && Request.QueryString["bytedata"] == "1")
            {
                Detail_AttachInfo att = new StorageCom().GetDetail(AttachGuid);
                Response.BinaryWrite(att.Content);
                Response.End();
            }
            else
            {
                Detail_AttachInfo att      = new StorageCom().GetDetail_NoContent(AttachGuid);
                string            fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                #region 采用临时文件方法
                if (att.StorageType.ToLower() == "file")//文件存储方式
                {
                    Response.Redirect(Epoint.Frame.Bizlogic.common.GetApplicationPath() + att.FilePath);
                }
                else
                {
                    string attPath = Epoint.Frame.Bizlogic.BasePage.GetApplicationPath() + "AttachStorage/";
                    Epoint.Frame.Bizlogic.common.CreatRootTempFolder();

                    if (!Directory.Exists(Server.MapPath(attPath + "/" + att.AttachGuid)))
                    {
                        Directory.CreateDirectory(Server.MapPath(attPath + "/" + att.AttachGuid));
                    }

                    string strFullFilePath = Server.MapPath(attPath + "/" + att.AttachGuid + "/" + att.AttachFileName.Replace("\"", "“"));

                    //当文件大小为0时删除文件重新生成
                    if (File.Exists(strFullFilePath) && new FileInfo(strFullFilePath).Length == 0)
                    {
                        File.Delete(strFullFilePath);
                    }
                    //二进制文件写必须用binaryWrite,不需要制定encoding方式
                    if (!File.Exists(strFullFilePath))
                    {
                        FileStream   objFileStream   = new FileStream(strFullFilePath, FileMode.OpenOrCreate, FileAccess.Write);
                        BinaryWriter objBinaryWriter = new BinaryWriter(objFileStream);
                        objBinaryWriter.Write(new StorageCom().GetContentByAttachGuid(AttachGuid));
                        objBinaryWriter.Close();
                        objFileStream.Close();
                    }
                    string AttachFileURL = attPath + att.AttachGuid + "/" + att.AttachFileName.Replace("\"", "“");

                    string WatermarkImageUrl = Server.MapPath(Request.ApplicationPath + "/HTProject/Pages/Images/合同备案公章.gif");
                    string message           = "";

                    string diskName = Server.MapPath(AttachFileURL); //Request.ApplicationPath + "/AttachStorage/" + fileName + "XMBA.pdf"
                    string fileNew  = Request.ApplicationPath + "/AttachStorage/" + fileName + "_2XMBA.pdf";
                    if (Request["SAdd"] == "SN")
                    {
                        WatermarkPDF_SN(diskName, Server.MapPath(fileNew), WatermarkImageUrl, 200, 500, 115, 115, out message);
                    }
                    else
                    {
                        WatermarkPDF_SW(diskName, Server.MapPath(fileNew), WatermarkImageUrl, 568, 500, 115, 115, out message);
                    }

                    Response.Redirect(fileNew);
                }
                #endregion
            }
        }