using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Text;
using System.Data;
using System.Collections;
using SuperMap.RealEstate.Utility;
using SRAI = SuperMap.RealEstate.Archives.Image;
using System.Web.Script.Serialization;
namespace SuperMap.RealEstate.HousingSecurity.API
{
///
/// 提供给房源管理页,获取房屋关联的图片列表,直接返回HTML输出
/// 【数据源】
///
public class gethousepics : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
List list = new List();
StringBuilder htm = new StringBuilder();
string _CaseFileIDstr = context.Request.QueryString["CaseFileID"];
string _ScanFileIDstr = context.Request.QueryString["ScanFileID"];
long _CaseFileID = 0;
long _ScanFileID = 0;
long.TryParse(_CaseFileIDstr, out _CaseFileID);
long.TryParse(_ScanFileIDstr, out _ScanFileID);
string _MaterialIDstr = context.Request.QueryString["MaterialID"];
string _ProinstScanFileIDstr = context.Request.QueryString["ProinstScanFileID"];
long _MaterialID = 0;
long _ProinstScanFileID = 0;
long.TryParse(_MaterialIDstr, out _MaterialID);
long.TryParse(_ProinstScanFileIDstr, out _ProinstScanFileID);
try
{
if (_ScanFileID != 0)
{
#region 传入扫描件内码
ServiceModel.Transaction _Transaction = new ServiceModel.Transaction();
SRAI.Business.ScanFile _ScanFile = new SRAI.Business.ScanFile(_Transaction);
_ScanFile.ScanFile_ID = _ScanFileID;
if (_ScanFile.Select())
{
Hashtable ht = null;
ht = new Hashtable();
ht.Add("id", _ScanFile.ScanFile_ID.ToString());
ht.Add("title", _ScanFile.ScanFile_Name);
ht.Add("url", _ScanFile.ScanFile_Path);
list.Add(ht);
}
#endregion
}
else if (_CaseFileID != 0)
{
#region 传入卷内目录
using (SRAI.Business.ScanFile _pics = new SRAI.Business.ScanFile())
{
List _ScanFileCollection = _pics.FillCollection(string.Format("where {0}={1} order by scanfile_index", SRAI.Interface.TableSchema_ScanFile.CaseFile_ID, _CaseFileID));
if (_ScanFileCollection.Count > 0)
{
Hashtable ht = null;
for (int i = 0; i < _ScanFileCollection.Count; i++)
{
ht = new Hashtable();
ht.Add("id", _ScanFileCollection[i].ScanFile_ID.ToString());
ht.Add("title", _ScanFileCollection[i].ScanFile_Name);
ht.Add("url", _ScanFileCollection[i].ScanFile_Path);
//加入
list.Add(ht);
}
}
}
#endregion
}
else if (_ProinstScanFileID != 0)
{
#region 传入扫描件内码
ServiceModel.Transaction _Transaction = new ServiceModel.Transaction();
SRAI.Business.ProinstScanFile _ScanFile = new SRAI.Business.ProinstScanFile(_Transaction);
_ScanFile.ProinstScanFile_ID = _ProinstScanFileID;
if (_ScanFile.Select())
{
Hashtable ht = null;
ht = new Hashtable();
ht.Add("id", _ScanFile.ProinstScanFile_ID.ToString());
ht.Add("title", _ScanFile.ScanFile_Name);
ht.Add("url", _ScanFile.ScanFile_Path);
list.Add(ht);
}
#endregion
}
else if (_MaterialID != 0)
{
#region 流程资料目录
using (SRAI.Business.ProinstScanFile _pics = new SRAI.Business.ProinstScanFile())
{
List _ScanFileCollection = _pics.FillCollection(string.Format("where {0}={1} order by scanfile_index", SRAI.Interface.TableSchema_ProinstScanFile.Material_ID, _MaterialID));
if (_ScanFileCollection.Count > 0)
{
Hashtable ht = null;
for (int i = 0; i < _ScanFileCollection.Count; i++)
{
ht = new Hashtable();
ht.Add("id", _ScanFileCollection[i].ProinstScanFile_ID.ToString());
ht.Add("title", _ScanFileCollection[i].ScanFile_Name);
ht.Add("url", _ScanFileCollection[i].ScanFile_Path);
list.Add(ht);
}
}
}
#endregion
}
}
catch (Exception ex)
{
htm.Append("get housepics error:" + ex.Message);
}
StringBuilder buider = new StringBuilder();
JavaScriptSerializer json = new JavaScriptSerializer(new SimpleTypeResolver());
json.MaxJsonLength = Int32.MaxValue;
json.Serialize(list, buider);
//【输出】application/json;charset=utf-8
context.Response.ContentType = "application/json";
context.Response.Charset = "utf-8";
context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
context.Response.Write(buider.ToString());
}
public bool IsReusable
{
get
{
return false;
}
}
}
}