using System; using System.Data; using System.Web; using System.Configuration; using System.Collections.Generic; using OT.Model; using OT.DALFactory; using OT.IDAL; namespace OT.BLL { /// /// OTB_SYS_Attachments /// public partial class OTB_SYS_Attachments { private readonly IOTB_SYS_Attachments dal = DataAccess.Create("OTB_SYS_Attachments"); private readonly string _strUseWebservice = ConfigurationManager.AppSettings["UseWebservice"].ToString(); private readonly string _strWebserviceUrl = ConfigurationManager.AppSettings["WebserviceUrl"].ToString() + "OTB_SYS_Attachments.asmx"; public OTB_SYS_Attachments() { } #region Method /// /// 是否存在該記錄 /// public bool Exists(string TargetRelationID) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.Exists(TargetRelationID); } else { string[] aryParam = new string[1]; aryParam[0] = TargetRelationID; return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_Exists", aryParam); } } /// /// 增加一條資料 /// public bool Add(OT.Model.OTB_SYS_Attachments model) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.Add(model); } else { string[] aryParam = new string[1]; aryParam[0] = Common.ObjSerialize.Serialize(model); return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_Add", aryParam); } } /// /// 更新一條資料 /// public bool Update(OT.Model.OTB_SYS_Attachments model) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.Update(model); } else { string[] aryParam = new string[1]; aryParam[0] = Common.ObjSerialize.Serialize(model); return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_Update", aryParam); } } /// /// 刪除一條資料 /// public bool Delete(string TargetRelationID) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { List List = dal.GetModelListBySourceRelationID(TargetRelationID); foreach (OT.Model.OTB_SYS_Attachments o_SYS_Attachments_Model in List) { string strFileFullName = o_SYS_Attachments_Model.FilePath; if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(strFileFullName))) { System.IO.File.Delete(HttpContext.Current.Server.MapPath(strFileFullName)); } } return dal.Delete(TargetRelationID); } else { string[] aryParam = new string[1]; aryParam[0] = TargetRelationID; return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_Delete", aryParam); } } /// /// 刪除一條資料 /// public bool DeleteList(string TargetRelationIDlist) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.DeleteList(TargetRelationIDlist); } else { string[] aryParam = new string[1]; aryParam[0] = TargetRelationIDlist; return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_DeleteList", aryParam); } } /// /// 得到一個對象實體 /// public OT.Model.OTB_SYS_Attachments GetModel(string TargetRelationID) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.GetModel(TargetRelationID); } else { string[] aryParam = new string[1]; aryParam[0] = TargetRelationID; return (OT.Model.OTB_SYS_Attachments)Common.ObjDeserialize.Deserialize(OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_GetModel", aryParam).ToString(), typeof(OT.Model.OTB_SYS_Attachments)); } } #endregion Method /// /// 得到一個對象實體集合 /// public List GetModelListBySourceRelationID(string SourceRelationID) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.GetModelListBySourceRelationID(SourceRelationID); } else { string[] aryParam = new string[1]; aryParam[0] = SourceRelationID; return (List)Common.ObjDeserialize.Deserialize(OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_GetModelListBySourceRelationID", aryParam).ToString(), typeof(List)); } } /// /// 獲得資料列表 /// public DataSet GetList(int StartRecordIndex, int EndRecordIndex, string SourceRelationID, string SortExpression) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.GetList(StartRecordIndex, EndRecordIndex, SourceRelationID, SortExpression); } else { string[] aryParam = new string[4]; aryParam[0] = StartRecordIndex.ToString(); aryParam[1] = EndRecordIndex.ToString(); aryParam[2] = SourceRelationID; aryParam[3] = SortExpression; return (DataSet)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_GetList", aryParam); } } /// /// 獲得資料總筆數 /// public int GetListCount(string SourceRelationID) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.GetListCount(SourceRelationID); } else { string[] aryParam = new string[1]; aryParam[0] = SourceRelationID; return (int)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_GetListCount", aryParam); } } /// /// 獲取園區地圖圖示名稱和坐標列表 /// public DataSet GetPlaceImgFileNameList() { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.GetPlaceImgFileNameList(); } else { string[] aryParam = new string[0]; return (DataSet)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_GetPlaceImgFileNameList", aryParam); } } /// /// 更新類別欄位 /// public bool UpdateFileType(string TargetRelationID, string FileType, string ModifyUser) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.UpdateFileType(TargetRelationID, FileType, ModifyUser); } else { string[] aryParam = new string[3]; aryParam[0] = TargetRelationID; aryParam[1] = FileType; aryParam[2] = ModifyUser; return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_UpdateFileType", aryParam); } } /// /// 更新對內公開欄位 /// public bool UpdateIsProtected(string TargetRelationID, string IsProtected, string ModifyUser) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.UpdateIsProtected(TargetRelationID, IsProtected, ModifyUser); } else { string[] aryParam = new string[3]; aryParam[0] = TargetRelationID; aryParam[1] = IsProtected; aryParam[2] = ModifyUser; return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_UpdateIsProtected", aryParam); } } /// /// 更新對外公開欄位 /// public bool UpdateIsPublic(string TargetRelationID, string IsPublic, string ModifyUser) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.UpdateIsPublic(TargetRelationID, IsPublic, ModifyUser); } else { string[] aryParam = new string[3]; aryParam[0] = TargetRelationID; aryParam[1] = IsPublic; aryParam[2] = ModifyUser; return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_UpdateIsPublic", aryParam); } } /// /// 更新對外公開欄位 /// public bool UpdateIsTitlePage(string TargetRelationID, string IsTitlePage, string ModifyUser) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.UpdateIsTitlePage(TargetRelationID, IsTitlePage, ModifyUser); } else { string[] aryParam = new string[3]; aryParam[0] = TargetRelationID; aryParam[1] = IsTitlePage; aryParam[2] = ModifyUser; return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_UpdateIsTitlePage", aryParam); } } public bool ChangeMemo(string strFileGuid, string strFileMemo, string ModifyUser) { if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false")) { return dal.ChangeMemo(strFileGuid, strFileMemo, ModifyUser); } else { string[] aryParam = new string[3]; aryParam[0] = strFileGuid; aryParam[1] = strFileMemo; aryParam[2] = ModifyUser; return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_ChangeMemo", aryParam); } } } }