| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.IO;
- using HySoft.BaseCallCenter.Web.WebReferenceFax;
- namespace HySoft.BaseCallCenter.Web.faxmanage
- {
- public partial class faxsendshow : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Response.Expires = -1;
- if (!Page.IsPostBack)
- {
- Response.Expires = -1;
- if (!Page.IsPostBack)
- {
- if (!string.IsNullOrEmpty(Request.QueryString["singleFlage"]))
- {
- Initialize(Request.QueryString["singleFlage"]);
- }
- }
- }
- }
- #region 信息初始化
- void Initialize(string id)
- {
- try
- {
- if (!string.IsNullOrEmpty(Request.QueryString["otype"]))
- {
- //待发查看
- if (Request.QueryString["otype"] == "SendTask")
- {
- Obj1 = new BLL.T_Fax_SendFaxTask().GetModel(Convert.ToInt32(id));
- }
- //已发查看
- else if (Request.QueryString["otype"] == "SendAlready")
- {
- Obj2 = new BLL.T_Fax_SentFax().GetModel(Convert.ToInt32(id));
- }
- }
-
-
- }
- catch (Exception ex)
- {
- Common.SysLog.WriteLog(ex);
- }
- }
- #endregion
-
- /// <summary>
- /// 显示多页tif图片
- /// </summary>
- /// <param name="fielname">文件名</param>
- /// <param name="index">显示页码</param>
- public void showMulTif(string fielname)
- {
- try
- {
- HttpContext context = HttpContext.Current;
- string bgFilePath = context.Server.MapPath(fielname);
- System.Drawing.Image imgObj = System.Drawing.Image.FromFile(bgFilePath);
- //获得第index页的图片
- Guid objGuid = (imgObj.FrameDimensionsList[0]);
- System.Drawing.Imaging.FrameDimension objDimension = new System.Drawing.Imaging.FrameDimension(objGuid);
- //总页数
- int totFrame;
- totFrame = imgObj.GetFrameCount(objDimension);
- txtnowpage.Value = "1";
- txtnowpage1.Value = "1";
- txtpath.Value = fielname;
- viewArea.Src = "faxtoimage.aspx?path=" + fielname + "&page=0";
- spanallcount.InnerHtml = totFrame.ToString();
- spanallcount1.InnerHtml = totFrame.ToString();
- if (totFrame == 1)
- {
- span2.Disabled = true;
- span4.Disabled = true;
- span1.Disabled = true;
- span3.Disabled = true;
- }
- }
- catch
- { }
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- try
- {
- HttpContext context = HttpContext.Current;
- string path = context.Server.MapPath(txtpath.Value);
- int start = path.LastIndexOf("\\") + 1;
- int end = path.Length;
- string filename = path.Substring(start, end - start).Replace("|", "");
- FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
- byte[] data = new byte[fs.Length];
- fs.Read(data, 0, data.Length);
- Response.Buffer = true;
- Response.Clear();
- Response.ClearContent();
- Response.ClearHeaders();
- Response.ContentType = "image/tiff";
- Response.Charset = "utf-8";
- Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
- Response.AddHeader("Content-Disposition", "attachment;filename=" + filename + "");
- Response.BinaryWrite(data);
- Response.Flush();
- Response.Close();
- }
- catch
- { }
- }
- #region 公共属性 待发
- private Model.T_Fax_SendFaxTask Obj1
- {
- get
- {
- return null;
- }
- set
- {
- if (value != null)
- {
- this.txtPhone.Value = value.TelNum;
- this.txtContents.Value = value.Remark;
- this.txtState.Value = value.State.ToString().Replace("0", "未发送");
- this.txtSendTime.Value = value.SendTime.ToString();
- this.txtName.Value = value.F_Name;
- string requestpath = "";
- if (value.FileState == 1)
- {
- requestpath = value.TifFilePath.Trim();
- try
- {
- //下载文件、存入到Web服务器返回路径、更新数据库WebFilePath
- byte[] file;
- WebReferenceFax.FaxService ws = new WebReferenceFax.FaxService();
- file = ws.DownloadFile(requestpath);
- if (file != null)
- {
- string _FaxFileName = "";
- string _Path = "\\FaxFile\\" + DateTime.Now.ToString("yyyyMM");
- string _SavePath = AppDomain.CurrentDomain.BaseDirectory + _Path;
- if (!Directory.Exists(_SavePath))
- {
- Directory.CreateDirectory(_SavePath);
- }
- string _xdPath = _Path + "\\" + Guid.NewGuid().ToString().Replace("-", "") + "." + requestpath.Substring(requestpath.LastIndexOf(".") + 1);
- _FaxFileName = AppDomain.CurrentDomain.BaseDirectory + _xdPath;
- using (FileStream fs = new FileStream(_FaxFileName, FileMode.Create, FileAccess.Write))
- {
- fs.Write(file, 0, file.Length);
- fs.Flush();
- fs.Close();
- }
- Model.T_Fax_SendFaxTask model = new Model.T_Fax_SendFaxTask();
- model.FaxID = value.FaxID;
- model.WebFilePath = _xdPath;
- int r = new BLL.T_Fax_SendFaxTask().UpdateWebFilePath(model);
- if (r > 0)
- {
- showMulTif(Server.UrlEncode(_xdPath.Trim()));
- }
- }
- }
- catch
- { }
- }
- else
- {
- }
- }
- }
- }
- #endregion
- #region 公共属性 已发
- private Model.T_Fax_SentFax Obj2
- {
- get
- {
- return null;
- }
- set
- {
- if (value != null)
- {
- this.txtPhone.Value = value.TelNum;
- this.txtContents.Value = value.Remark;
- this.txtState.Value = value.State.ToString().Replace("-1", "发送失败").Replace("0", "未发送").Replace("1", "正在发送").Replace("2", "发送成功");
- this.txtSendTime.Value = value.SendTime.ToString();
- this.txtName.Value = value.F_Name;
- string requestpath = "";
- if (value.FileState == 1)
- {
- requestpath = value.TifFilePath.Trim();
- try
- {
- //下载文件、存入到Web服务器返回路径、更新数据库WebFilePath
- byte[] file;
- WebReferenceFax.FaxService ws = new WebReferenceFax.FaxService();
- file = ws.DownloadFile(requestpath);
- if (file != null)
- {
- string _FaxFileName = "";
- string _Path = "\\FaxFile\\" + DateTime.Now.ToString("yyyyMM");
- string _SavePath = AppDomain.CurrentDomain.BaseDirectory + _Path;
- if (!Directory.Exists(_SavePath))
- {
- Directory.CreateDirectory(_SavePath);
- }
- string _xdPath = _Path + "\\" + Guid.NewGuid().ToString().Replace("-", "") + "." + requestpath.Substring(requestpath.LastIndexOf(".") + 1);
- _FaxFileName = AppDomain.CurrentDomain.BaseDirectory + _xdPath;
- using (FileStream fs = new FileStream(_FaxFileName, FileMode.Create, FileAccess.Write))
- {
- fs.Write(file, 0, file.Length);
- fs.Flush();
- fs.Close();
- }
- Model.T_Fax_SentFax model = new Model.T_Fax_SentFax();
- model.FaxID = value.FaxID;
- model.WebFilePath = _xdPath;
- int r = new BLL.T_Fax_SentFax().UpdateWebFilePath(model);
- if (r > 0)
- {
- showMulTif(Server.UrlEncode(_xdPath.Trim()));
- }
- }
- }
- catch
- { }
- }
- else
- {
- }
- }
- }
- }
- #endregion
- }
- }
|