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

130 lines
5.6 KiB
C#

using System;
using System.Data;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using SuperMap.RealEstate.ServiceModel;
using Newtonsoft.Json.Linq;
using HZQR.Common;
using StorageBusiness = SuperMap.RealEstate.HighWay.Storage.Business;
namespace SuperMap.RealEstate.HighWay.Handler.CommonInterface
{
public class BusinessHelper
{
#region ->
public static string DeleteFile(ServiceModel.Transaction _Transaction)
{
string reString = "";
JObject info = new JObject();
try
{
string ImageID = Pub.Request("ImageID");
string UploadType = Pub.Request("UploadType");
string FilePath = "~/UploadImageDir/CompactFile";
switch (UploadType)
{
case "proinst_upload":
case "upload_files":
case "compact_upload":
FilePath = "~/UploadImageDir/CompactFile";
break;
case "Mnangement_upload":
FilePath = "~/UploadImageDir/Mnangement";
break;
case "Commodity_upload":
FilePath = "~/UploadImageDir/Commodity";
break;
case "Publicity_upload":
FilePath = "~/UploadImageDir";
break;
case "Document_upload":
FilePath = "~/UploadImageDir/Document";
break;
}
switch (UploadType)
{
case "proinst_upload":
case "Mnangement_upload":
case "Commodity_upload":
case "Document_upload":
Running.Business.ATTACHMENT _ATTACHMENT = new Running.Business.ATTACHMENT(_Transaction);
_ATTACHMENT.ATTACHMENT_ID_Encrypt = ImageID;
if (_ATTACHMENT.Select())
{
if (!string.IsNullOrEmpty(_ATTACHMENT.PRESONNAME) && !string.IsNullOrEmpty(_ATTACHMENT.ATTACHMENT_DESC))
{
string DirectoryPath = HttpContext.Current.Server.MapPath(FilePath + _ATTACHMENT.PRESONNAME);
if (Directory.Exists(DirectoryPath) && File.Exists(DirectoryPath + "\\" + _ATTACHMENT.ATTACHMENT_DESC))
{
File.Delete(DirectoryPath + "\\" + _ATTACHMENT.ATTACHMENT_DESC);
}
}
_ATTACHMENT.Delete();
}
break;
case "compact_upload":
StorageBusiness.COMPACTFILE _COMPACTFILE = new StorageBusiness.COMPACTFILE(_Transaction);
_COMPACTFILE.COMPACTFILE_ID_Encrypt = ImageID;
if (_COMPACTFILE.Select())
{
if (!string.IsNullOrEmpty(_COMPACTFILE.COMPACTFILE_DESC) && !string.IsNullOrEmpty(_COMPACTFILE.COMPACTFILE_NAME))
{
string DirectoryPath = HttpContext.Current.Server.MapPath(FilePath + _COMPACTFILE.COMPACTFILE_DESC);
if (Directory.Exists(DirectoryPath) && File.Exists(DirectoryPath + "\\" + _COMPACTFILE.COMPACTFILE_NAME))
{
File.Delete(DirectoryPath + "\\" + _COMPACTFILE.COMPACTFILE_NAME);
}
}
_COMPACTFILE.Delete();
}
break;
case "upload_files":
case "Publicity_upload":
StorageBusiness.IMAGE _IMAGE = new StorageBusiness.IMAGE(_Transaction);
_IMAGE.Image_ID_Encrypt = ImageID;
if (_IMAGE.Select())
{
if (!string.IsNullOrEmpty(_IMAGE.IMAGE_PATH) && !string.IsNullOrEmpty(_IMAGE.IMAGE_DESC))
{
string DirectoryPath = HttpContext.Current.Server.MapPath(FilePath + _IMAGE.IMAGE_PATH);
if (Directory.Exists(DirectoryPath) && File.Exists(DirectoryPath + "\\" + _IMAGE.IMAGE_DESC))
{
File.Delete(DirectoryPath + "\\" + _IMAGE.IMAGE_DESC);
}
}
_IMAGE.Delete();
}
break;
}
_Transaction.Commit();
info["Result_Code"] = 100;
info["Result_Desc"] = "删除成功!";
}
catch (Exception ex)
{
_Transaction.Rollback();
ex = ex ?? ex.InnerException;
info["Result_Code"] = 999;
info["Result_Desc"] = "删除失败" + ex.Message;
SuperMap.RealEstate.Utility.ErrorLogHelper.Write(ex, "DeleteFile", "DeleteFile");
}
finally
{
if (_Transaction.IsOpen)
{
_Transaction.Dispose();
_Transaction.Release();
}
}
reString = info.ToString();
return reString;
}
#endregion
}
}