protected void Page_Load(object sender, System.EventArgs e) { Epoint.MisBizLogic2.Data.MisGuidRow oRow = new Epoint.MisBizLogic2.Data.MisGuidRow("RG_QYUser", Request["RowGuid"]); WatermarkImageUrl = Request.ApplicationPath + "/HTProject/Pages/Images/��ͬ����ˮӡ.jpg"; WatermarkText = new Epoint.Frame.Bizlogic.Frame_Config().GetDetail("AppDeptName").ConfigValue; Response.Clear(); string fileName = ""; #region ������������ļ��ķ�ʽ�����ڷ�������Web����Ŀ¼���洴����ʱ�ļ��� if (oRow.R_HasFilled && !Convert.IsDBNull(oRow["CardIMG"])) { if (oRow["IDNum"] != null) { fileName = oRow["IDNum"].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 + "/" + fileName + ".jpg"); //if (File.Exists(strFullFilePath)) //{ // File.Delete(strFullFilePath); //} //�������ļ�д������binaryWrite,����Ҫ�ƶ�encoding��ʽ //if (!File.Exists(strFullFilePath)) //{ objFileStream = new FileStream(strFullFilePath, FileMode.Create, FileAccess.Write); objBinaryWriter = new BinaryWriter(objFileStream); objBinaryWriter.Write((byte[])oRow["CardIMG"]); 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 + "/" + fileName + ".jpg"); } #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 }