市长热线演示版

faxsendshow.aspx.cs 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.IO;
  8. using HySoft.BaseCallCenter.Web.WebReferenceFax;
  9. namespace HySoft.BaseCallCenter.Web.faxmanage
  10. {
  11. public partial class faxsendshow : System.Web.UI.Page
  12. {
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. Response.Expires = -1;
  16. if (!Page.IsPostBack)
  17. {
  18. Response.Expires = -1;
  19. if (!Page.IsPostBack)
  20. {
  21. if (!string.IsNullOrEmpty(Request.QueryString["singleFlage"]))
  22. {
  23. Initialize(Request.QueryString["singleFlage"]);
  24. }
  25. }
  26. }
  27. }
  28. #region 信息初始化
  29. void Initialize(string id)
  30. {
  31. try
  32. {
  33. if (!string.IsNullOrEmpty(Request.QueryString["otype"]))
  34. {
  35. //待发查看
  36. if (Request.QueryString["otype"] == "SendTask")
  37. {
  38. Obj1 = new BLL.T_Fax_SendFaxTask().GetModel(Convert.ToInt32(id));
  39. }
  40. //已发查看
  41. else if (Request.QueryString["otype"] == "SendAlready")
  42. {
  43. Obj2 = new BLL.T_Fax_SentFax().GetModel(Convert.ToInt32(id));
  44. }
  45. }
  46. }
  47. catch (Exception ex)
  48. {
  49. Common.SysLog.WriteLog(ex);
  50. }
  51. }
  52. #endregion
  53. /// <summary>
  54. /// 显示多页tif图片
  55. /// </summary>
  56. /// <param name="fielname">文件名</param>
  57. /// <param name="index">显示页码</param>
  58. public void showMulTif(string fielname)
  59. {
  60. try
  61. {
  62. HttpContext context = HttpContext.Current;
  63. string bgFilePath = context.Server.MapPath(fielname);
  64. System.Drawing.Image imgObj = System.Drawing.Image.FromFile(bgFilePath);
  65. //获得第index页的图片
  66. Guid objGuid = (imgObj.FrameDimensionsList[0]);
  67. System.Drawing.Imaging.FrameDimension objDimension = new System.Drawing.Imaging.FrameDimension(objGuid);
  68. //总页数
  69. int totFrame;
  70. totFrame = imgObj.GetFrameCount(objDimension);
  71. txtnowpage.Value = "1";
  72. txtnowpage1.Value = "1";
  73. txtpath.Value = fielname;
  74. viewArea.Src = "faxtoimage.aspx?path=" + fielname + "&page=0";
  75. spanallcount.InnerHtml = totFrame.ToString();
  76. spanallcount1.InnerHtml = totFrame.ToString();
  77. if (totFrame == 1)
  78. {
  79. span2.Disabled = true;
  80. span4.Disabled = true;
  81. span1.Disabled = true;
  82. span3.Disabled = true;
  83. }
  84. }
  85. catch
  86. { }
  87. }
  88. protected void Button1_Click(object sender, EventArgs e)
  89. {
  90. try
  91. {
  92. HttpContext context = HttpContext.Current;
  93. string path = context.Server.MapPath(txtpath.Value);
  94. int start = path.LastIndexOf("\\") + 1;
  95. int end = path.Length;
  96. string filename = path.Substring(start, end - start).Replace("|", "");
  97. FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
  98. byte[] data = new byte[fs.Length];
  99. fs.Read(data, 0, data.Length);
  100. Response.Buffer = true;
  101. Response.Clear();
  102. Response.ClearContent();
  103. Response.ClearHeaders();
  104. Response.ContentType = "image/tiff";
  105. Response.Charset = "utf-8";
  106. Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
  107. Response.AddHeader("Content-Disposition", "attachment;filename=" + filename + "");
  108. Response.BinaryWrite(data);
  109. Response.Flush();
  110. Response.Close();
  111. }
  112. catch
  113. { }
  114. }
  115. #region 公共属性 待发
  116. private Model.T_Fax_SendFaxTask Obj1
  117. {
  118. get
  119. {
  120. return null;
  121. }
  122. set
  123. {
  124. if (value != null)
  125. {
  126. this.txtPhone.Value = value.TelNum;
  127. this.txtContents.Value = value.Remark;
  128. this.txtState.Value = value.State.ToString().Replace("0", "未发送");
  129. this.txtSendTime.Value = value.SendTime.ToString();
  130. this.txtName.Value = value.F_Name;
  131. string requestpath = "";
  132. if (value.FileState == 1)
  133. {
  134. requestpath = value.TifFilePath.Trim();
  135. try
  136. {
  137. //下载文件、存入到Web服务器返回路径、更新数据库WebFilePath
  138. byte[] file;
  139. WebReferenceFax.FaxService ws = new WebReferenceFax.FaxService();
  140. file = ws.DownloadFile(requestpath);
  141. if (file != null)
  142. {
  143. string _FaxFileName = "";
  144. string _Path = "\\FaxFile\\" + DateTime.Now.ToString("yyyyMM");
  145. string _SavePath = AppDomain.CurrentDomain.BaseDirectory + _Path;
  146. if (!Directory.Exists(_SavePath))
  147. {
  148. Directory.CreateDirectory(_SavePath);
  149. }
  150. string _xdPath = _Path + "\\" + Guid.NewGuid().ToString().Replace("-", "") + "." + requestpath.Substring(requestpath.LastIndexOf(".") + 1);
  151. _FaxFileName = AppDomain.CurrentDomain.BaseDirectory + _xdPath;
  152. using (FileStream fs = new FileStream(_FaxFileName, FileMode.Create, FileAccess.Write))
  153. {
  154. fs.Write(file, 0, file.Length);
  155. fs.Flush();
  156. fs.Close();
  157. }
  158. Model.T_Fax_SendFaxTask model = new Model.T_Fax_SendFaxTask();
  159. model.FaxID = value.FaxID;
  160. model.WebFilePath = _xdPath;
  161. int r = new BLL.T_Fax_SendFaxTask().UpdateWebFilePath(model);
  162. if (r > 0)
  163. {
  164. showMulTif(Server.UrlEncode(_xdPath.Trim()));
  165. }
  166. }
  167. }
  168. catch
  169. { }
  170. }
  171. else
  172. {
  173. }
  174. }
  175. }
  176. }
  177. #endregion
  178. #region 公共属性 已发
  179. private Model.T_Fax_SentFax Obj2
  180. {
  181. get
  182. {
  183. return null;
  184. }
  185. set
  186. {
  187. if (value != null)
  188. {
  189. this.txtPhone.Value = value.TelNum;
  190. this.txtContents.Value = value.Remark;
  191. this.txtState.Value = value.State.ToString().Replace("-1", "发送失败").Replace("0", "未发送").Replace("1", "正在发送").Replace("2", "发送成功");
  192. this.txtSendTime.Value = value.SendTime.ToString();
  193. this.txtName.Value = value.F_Name;
  194. string requestpath = "";
  195. if (value.FileState == 1)
  196. {
  197. requestpath = value.TifFilePath.Trim();
  198. try
  199. {
  200. //下载文件、存入到Web服务器返回路径、更新数据库WebFilePath
  201. byte[] file;
  202. WebReferenceFax.FaxService ws = new WebReferenceFax.FaxService();
  203. file = ws.DownloadFile(requestpath);
  204. if (file != null)
  205. {
  206. string _FaxFileName = "";
  207. string _Path = "\\FaxFile\\" + DateTime.Now.ToString("yyyyMM");
  208. string _SavePath = AppDomain.CurrentDomain.BaseDirectory + _Path;
  209. if (!Directory.Exists(_SavePath))
  210. {
  211. Directory.CreateDirectory(_SavePath);
  212. }
  213. string _xdPath = _Path + "\\" + Guid.NewGuid().ToString().Replace("-", "") + "." + requestpath.Substring(requestpath.LastIndexOf(".") + 1);
  214. _FaxFileName = AppDomain.CurrentDomain.BaseDirectory + _xdPath;
  215. using (FileStream fs = new FileStream(_FaxFileName, FileMode.Create, FileAccess.Write))
  216. {
  217. fs.Write(file, 0, file.Length);
  218. fs.Flush();
  219. fs.Close();
  220. }
  221. Model.T_Fax_SentFax model = new Model.T_Fax_SentFax();
  222. model.FaxID = value.FaxID;
  223. model.WebFilePath = _xdPath;
  224. int r = new BLL.T_Fax_SentFax().UpdateWebFilePath(model);
  225. if (r > 0)
  226. {
  227. showMulTif(Server.UrlEncode(_xdPath.Trim()));
  228. }
  229. }
  230. }
  231. catch
  232. { }
  233. }
  234. else
  235. {
  236. }
  237. }
  238. }
  239. }
  240. #endregion
  241. }
  242. }