protected void Page_Load(object sender, System.EventArgs e) { WatermarkImageUrl = Request.ApplicationPath + "/HTProject/Pages/Images/合同备案水印.jpg"; WatermarkText = new Epoint.Frame.Bizlogic.Frame_Config().GetDetail("AppDeptName").ConfigValue; Response.Clear(); //string ProcessType = Request.QueryString["ProcessType"]; string FlipType = Request.QueryString["FlipType"]; //通过人员的Guid,获取个人签名的AttachGuid Epoint.Frame.Bizlogic.AttachStorageInfo.StorageCom StorgCom = new Epoint.Frame.Bizlogic.AttachStorageInfo.StorageCom(); string CliGuid = Request["RYGuid"] + "RY_GRQM"; DataView dvAttch = StorgCom.Select(CliGuid); dvAttch.Sort = " Row_ID DESC "; string AttachGuid = ""; if (dvAttch.Count > 0) { AttachGuid = dvAttch[0]["AttachGuid"].ToString(); } else { //如果没有签名,就加载个默认的提示 Response.Redirect(Request.ApplicationPath + "/HTProject/Pages/Images/WQM.gif");//////////////////////////////////////////////// return; } //string AttachGuid = Request.QueryString["AttachGuid"]; string Attach_ConnectionStringName = Request.QueryString["ConnName"]; string Attach_ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["EpointMis_ConnectionString"].ConnectionString; if (Attach_ConnectionStringName != null && Attach_ConnectionStringName != "") { string strCon = new HTProject_Bizlogic.AttachManage.DB_Frame_Attach().GetAttach_ConnectionString(Attach_ConnectionStringName); if (strCon != "") { Attach_ConnectionString = strCon; } } Epoint.MisBizLogic2.Data.CommonDataRow oRow = new Epoint.MisBizLogic2.Data.CommonDataRow("Frame_AttachStorage", "AttachGuid", AttachGuid, Attach_ConnectionString); string fileName = ""; #region 如果采用生成文件的方式,会在服务器的Web程序目录下面创建临时文件, if (oRow.R_HasFilled && !Convert.IsDBNull(oRow["Content"])) { if (oRow["AttachFileName"] != null) { fileName = oRow["AttachFileName"].ToString(); } else { fileName = Guid.NewGuid().ToString(); } //替换开始 FileStream objFileStream; BinaryWriter objBinaryWriter; string attPath = Request.ApplicationPath + "/AttachStorage/"; if (!Directory.Exists(Server.MapPath(attPath + "/" + AttachGuid))) { Directory.CreateDirectory(Server.MapPath(attPath + "/" + AttachGuid)); } string strFullFilePath = Server.MapPath(attPath + "/" + AttachGuid + "/" + fileName); //二进制文件写必须用binaryWrite,不需要制定encoding方式 if (!File.Exists(strFullFilePath)) { objFileStream = new FileStream(strFullFilePath, FileMode.OpenOrCreate, FileAccess.Write); objBinaryWriter = new BinaryWriter(objFileStream); objBinaryWriter.Write((byte[])oRow["Content"]); objBinaryWriter.Close(); objFileStream.Close(); } #region 图片翻转 //翻转后的文件名 string fileNameR = ""; int site = fileName.IndexOf('.'); fileNameR = fileName.Substring(0, site) + "_R" + fileName.Substring(site, fileName.Length - site); string strFullFilePathR = Server.MapPath(attPath + "/" + AttachGuid + "/" + fileNameR); Bitmap image = new Bitmap(strFullFilePath); if (FlipType == "0") { image.RotateFlip(RotateFlipType.RotateNoneFlipNone); } else if (FlipType == "1") { image.RotateFlip(RotateFlipType.Rotate90FlipNone); } else if (FlipType == "2") { image.RotateFlip(RotateFlipType.Rotate180FlipNone); } else if (FlipType == "3") { image.RotateFlip(RotateFlipType.Rotate270FlipNone); } else { image.RotateFlip(RotateFlipType.RotateNoneFlipNone); } image.Save(strFullFilePathR); objFileStream = new FileStream(strFullFilePathR, FileMode.OpenOrCreate, FileAccess.Read); BinaryReader br = new BinaryReader(objFileStream); byte[] imagebytes = br.ReadBytes(Convert.ToInt32(objFileStream.Length)); objFileStream.Close(); image.Dispose(); ////翻转后存入数据库 //if (ProcessType.Equals("Save")) //{ // //保存到数据库 // new ZLJDMis.BizLogic.AttachManage.DB_Frame_Attach().UpdateAttachContent(AttachGuid, imagebytes); // //修改默认生成的图片 // File.Delete(strFullFilePath); // strFullFilePath = Server.MapPath(attPath + "/" + AttachGuid + "/" + fileName); // Bitmap imageDB = new Bitmap(strFullFilePathR); // imageDB.Save(strFullFilePath); // imageDB.Dispose(); //} #endregion MakeThumbnail_And_AddWaterMark(strFullFilePathR); Response.Redirect(attPath + "/" + AttachGuid + "/" + fileNameR); } #endregion }
protected void Page_Load(object sender, System.EventArgs e) { WatermarkImageUrl = Request.ApplicationPath + "/HTProject/Pages/Images/��ͬ����ˮӡ.jpg"; WatermarkText = new Epoint.Frame.Bizlogic.Frame_Config().GetDetail("AppDeptName").ConfigValue; Response.Clear(); //string ProcessType = Request.QueryString["ProcessType"]; string FlipType = Request.QueryString["FlipType"]; //ͨ����Ա��Guid����ȡ����ǩ����AttachGuid Epoint.Frame.Bizlogic.AttachStorageInfo.StorageCom StorgCom = new Epoint.Frame.Bizlogic.AttachStorageInfo.StorageCom(); string CliGuid = Request["RYGuid"] + "RY_GRQM"; DataView dvAttch = StorgCom.Select(CliGuid); dvAttch.Sort = " Row_ID DESC "; string AttachGuid = ""; if (dvAttch.Count > 0) { AttachGuid = dvAttch[0]["AttachGuid"].ToString(); } else { //���û��ǩ�����ͼ��ظ�Ĭ�ϵ���ʾ Response.Redirect(Request.ApplicationPath + "/HTProject/Pages/Images/WQM.gif");//////////////////////////////////////////////// return; } //string AttachGuid = Request.QueryString["AttachGuid"]; string Attach_ConnectionStringName = Request.QueryString["ConnName"]; string Attach_ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["EpointMis_ConnectionString"].ConnectionString; if (Attach_ConnectionStringName != null && Attach_ConnectionStringName != "") { string strCon = new HTProject_Bizlogic.AttachManage.DB_Frame_Attach().GetAttach_ConnectionString(Attach_ConnectionStringName); if (strCon != "") { Attach_ConnectionString = strCon; } } Epoint.MisBizLogic2.Data.CommonDataRow oRow = new Epoint.MisBizLogic2.Data.CommonDataRow("Frame_AttachStorage", "AttachGuid", AttachGuid, Attach_ConnectionString); string fileName = ""; #region ������������ļ��ķ�ʽ�����ڷ�������Web����Ŀ¼���洴����ʱ�ļ��� if (oRow.R_HasFilled && !Convert.IsDBNull(oRow["Content"])) { if (oRow["AttachFileName"] != null) { fileName = oRow["AttachFileName"].ToString(); } else { fileName = Guid.NewGuid().ToString(); } //�滻��ʼ FileStream objFileStream; BinaryWriter objBinaryWriter; string attPath = Request.ApplicationPath + "/AttachStorage/"; if (!Directory.Exists(Server.MapPath(attPath + "/" + AttachGuid))) { Directory.CreateDirectory(Server.MapPath(attPath + "/" + AttachGuid)); } string strFullFilePath = Server.MapPath(attPath + "/" + AttachGuid + "/" + fileName); //�������ļ�д������binaryWrite,����Ҫ�ƶ�encoding��ʽ if (!File.Exists(strFullFilePath)) { objFileStream = new FileStream(strFullFilePath, FileMode.OpenOrCreate, FileAccess.Write); objBinaryWriter = new BinaryWriter(objFileStream); objBinaryWriter.Write((byte[])oRow["Content"]); objBinaryWriter.Close(); objFileStream.Close(); } #region ͼƬ��ת //��ת����ļ��� string fileNameR = ""; int site = fileName.IndexOf('.'); fileNameR = fileName.Substring(0, site) + "_R" + fileName.Substring(site, fileName.Length - site); string strFullFilePathR = Server.MapPath(attPath + "/" + AttachGuid + "/" + fileNameR); Bitmap image = new Bitmap(strFullFilePath); if (FlipType == "0") { image.RotateFlip(RotateFlipType.RotateNoneFlipNone); } else if (FlipType == "1") { image.RotateFlip(RotateFlipType.Rotate90FlipNone); } else if (FlipType == "2") { image.RotateFlip(RotateFlipType.Rotate180FlipNone); } else if (FlipType == "3") { image.RotateFlip(RotateFlipType.Rotate270FlipNone); } else { image.RotateFlip(RotateFlipType.RotateNoneFlipNone); } image.Save(strFullFilePathR); objFileStream = new FileStream(strFullFilePathR, FileMode.OpenOrCreate, FileAccess.Read); BinaryReader br = new BinaryReader(objFileStream); byte[] imagebytes = br.ReadBytes(Convert.ToInt32(objFileStream.Length)); objFileStream.Close(); image.Dispose(); ////��ת��������ݿ� //if (ProcessType.Equals("Save")) //{ // //���浽���ݿ� // new ZLJDMis.BizLogic.AttachManage.DB_Frame_Attach().UpdateAttachContent(AttachGuid, imagebytes); // //��Ĭ�����ɵ�ͼƬ // File.Delete(strFullFilePath); // strFullFilePath = Server.MapPath(attPath + "/" + AttachGuid + "/" + fileName); // Bitmap imageDB = new Bitmap(strFullFilePathR); // imageDB.Save(strFullFilePath); // imageDB.Dispose(); //} #endregion MakeThumbnail_And_AddWaterMark(strFullFilePathR); Response.Redirect(attPath + "/" + AttachGuid + "/" + fileNameR); } #endregion }