2025-03-27 15:05:14 +08:00

100 lines
3.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Collections;
using System.Web.Script.Serialization;
namespace SuperMap.RealEstate.HousingSecurity.API
{
/// <summary>
/// 通用操作(如:删除图片)
/// </summary>
public class docomacts : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string action = context.Request.Form["action"];
string pkiden = string.Empty;
int _pkid = 0;
string _status = string.Empty;
string _msg = string.Empty;
try
{
switch (action)
{
case "del_housepic":
pkiden = context.Request.Form["picid"];
//_pkid = Convert.ToInt32(SuperMap.RealEstate.Utility.StringHelper.Decrypt(pkiden));
int.TryParse(pkiden, out _pkid);
if (_pkid == 0)
{
throw new Exception("picid(" + pkiden + ") is error");
}
#region
ServiceModel.Transaction _Transaction = new ServiceModel.Transaction();
//标记删除
ProinstScanFile _ProinstScanFile = new ProinstScanFile(_Transaction);
_ProinstScanFile.ProinstScanFile_ID = _pkid;
_ProinstScanFile.Delete();
//ScanFile _ScanFile = new ScanFile(_Transaction);
//_ScanFile.ScanFile_ID = _pkid;//must设定主键
//_ScanFile.Delete();
_status = "ok";
_msg = "delete ok";
//逻辑删除
//_pics.Status = -4;
//更新
//if (_pics.Delete())
//{
// _status = "ok";
// _msg = "update ok";
//}
//else
//{
// _status = "failed";
// _msg = "update failed";
//}
_Transaction.AutoCommit();
#endregion
break;
default:
_status = "error";
_msg = "action(" + action + ") is not defined";
break;
}
}
catch (Exception ex)
{
_status = "error";
_msg = ex.Message;
}
Hashtable ht = new Hashtable();
ht.Add("status", _status);
ht.Add("msg", _msg);
StringBuilder buider = new StringBuilder();
JavaScriptSerializer json = new JavaScriptSerializer(new SimpleTypeResolver());
json.MaxJsonLength = Int32.MaxValue;
json.Serialize(ht, 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;
}
}
}
}