You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

302 lines
12 KiB

  1. using System;
  2. using System.Data;
  3. using System.Web;
  4. using System.Configuration;
  5. using System.Collections.Generic;
  6. using OT.Model;
  7. using OT.DALFactory;
  8. using OT.IDAL;
  9. namespace OT.BLL
  10. {
  11. /// <summary>
  12. /// OTB_SYS_Attachments
  13. /// </summary>
  14. public partial class OTB_SYS_Attachments
  15. {
  16. private readonly IOTB_SYS_Attachments dal = DataAccess.Create<IOTB_SYS_Attachments>("OTB_SYS_Attachments");
  17. private readonly string _strUseWebservice = ConfigurationManager.AppSettings["UseWebservice"].ToString();
  18. private readonly string _strWebserviceUrl = ConfigurationManager.AppSettings["WebserviceUrl"].ToString() + "OTB_SYS_Attachments.asmx";
  19. public OTB_SYS_Attachments()
  20. { }
  21. #region Method
  22. /// <summary>
  23. /// 是否存在該記錄
  24. /// </summary>
  25. public bool Exists(string TargetRelationID)
  26. {
  27. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  28. {
  29. return dal.Exists(TargetRelationID);
  30. }
  31. else
  32. {
  33. string[] aryParam = new string[1];
  34. aryParam[0] = TargetRelationID;
  35. return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_Exists", aryParam);
  36. }
  37. }
  38. /// <summary>
  39. /// 增加一條資料
  40. /// </summary>
  41. public bool Add(OT.Model.OTB_SYS_Attachments model)
  42. {
  43. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  44. {
  45. return dal.Add(model);
  46. }
  47. else
  48. {
  49. string[] aryParam = new string[1];
  50. aryParam[0] = Common.ObjSerialize.Serialize(model);
  51. return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_Add", aryParam);
  52. }
  53. }
  54. /// <summary>
  55. /// 更新一條資料
  56. /// </summary>
  57. public bool Update(OT.Model.OTB_SYS_Attachments model)
  58. {
  59. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  60. {
  61. return dal.Update(model);
  62. }
  63. else
  64. {
  65. string[] aryParam = new string[1];
  66. aryParam[0] = Common.ObjSerialize.Serialize(model);
  67. return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_Update", aryParam);
  68. }
  69. }
  70. /// <summary>
  71. /// 刪除一條資料
  72. /// </summary>
  73. public bool Delete(string TargetRelationID)
  74. {
  75. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  76. {
  77. List<OT.Model.OTB_SYS_Attachments> List = dal.GetModelListBySourceRelationID(TargetRelationID);
  78. foreach (OT.Model.OTB_SYS_Attachments o_SYS_Attachments_Model in List)
  79. {
  80. string strFileFullName = o_SYS_Attachments_Model.FilePath;
  81. if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(strFileFullName)))
  82. {
  83. System.IO.File.Delete(HttpContext.Current.Server.MapPath(strFileFullName));
  84. }
  85. }
  86. return dal.Delete(TargetRelationID);
  87. }
  88. else
  89. {
  90. string[] aryParam = new string[1];
  91. aryParam[0] = TargetRelationID;
  92. return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_Delete", aryParam);
  93. }
  94. }
  95. /// <summary>
  96. /// 刪除一條資料
  97. /// </summary>
  98. public bool DeleteList(string TargetRelationIDlist)
  99. {
  100. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  101. {
  102. return dal.DeleteList(TargetRelationIDlist);
  103. }
  104. else
  105. {
  106. string[] aryParam = new string[1];
  107. aryParam[0] = TargetRelationIDlist;
  108. return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_DeleteList", aryParam);
  109. }
  110. }
  111. /// <summary>
  112. /// 得到一個對象實體
  113. /// </summary>
  114. public OT.Model.OTB_SYS_Attachments GetModel(string TargetRelationID)
  115. {
  116. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  117. {
  118. return dal.GetModel(TargetRelationID);
  119. }
  120. else
  121. {
  122. string[] aryParam = new string[1];
  123. aryParam[0] = TargetRelationID;
  124. 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));
  125. }
  126. }
  127. #endregion Method
  128. /// <summary>
  129. /// 得到一個對象實體集合
  130. /// </summary>
  131. public List<OT.Model.OTB_SYS_Attachments> GetModelListBySourceRelationID(string SourceRelationID)
  132. {
  133. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  134. {
  135. return dal.GetModelListBySourceRelationID(SourceRelationID);
  136. }
  137. else
  138. {
  139. string[] aryParam = new string[1];
  140. aryParam[0] = SourceRelationID;
  141. return (List<OT.Model.OTB_SYS_Attachments>)Common.ObjDeserialize.Deserialize(OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_GetModelListBySourceRelationID", aryParam).ToString(), typeof(List<OT.Model.OTB_SYS_Attachments>));
  142. }
  143. }
  144. /// <summary>
  145. /// 獲得資料列表
  146. /// </summary>
  147. public DataSet GetList(int StartRecordIndex, int EndRecordIndex, string SourceRelationID, string SortExpression)
  148. {
  149. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  150. {
  151. return dal.GetList(StartRecordIndex, EndRecordIndex, SourceRelationID, SortExpression);
  152. }
  153. else
  154. {
  155. string[] aryParam = new string[4];
  156. aryParam[0] = StartRecordIndex.ToString();
  157. aryParam[1] = EndRecordIndex.ToString();
  158. aryParam[2] = SourceRelationID;
  159. aryParam[3] = SortExpression;
  160. return (DataSet)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_GetList", aryParam);
  161. }
  162. }
  163. /// <summary>
  164. /// 獲得資料總筆數
  165. /// </summary>
  166. public int GetListCount(string SourceRelationID)
  167. {
  168. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  169. {
  170. return dal.GetListCount(SourceRelationID);
  171. }
  172. else
  173. {
  174. string[] aryParam = new string[1];
  175. aryParam[0] = SourceRelationID;
  176. return (int)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_GetListCount", aryParam);
  177. }
  178. }
  179. /// <summary>
  180. /// 獲取園區地圖圖示名稱和坐標列表
  181. /// </summary>
  182. public DataSet GetPlaceImgFileNameList()
  183. {
  184. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  185. {
  186. return dal.GetPlaceImgFileNameList();
  187. }
  188. else
  189. {
  190. string[] aryParam = new string[0];
  191. return (DataSet)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_GetPlaceImgFileNameList", aryParam);
  192. }
  193. }
  194. /// <summary>
  195. /// 更新類別欄位
  196. /// </summary>
  197. public bool UpdateFileType(string TargetRelationID, string FileType, string ModifyUser)
  198. {
  199. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  200. {
  201. return dal.UpdateFileType(TargetRelationID, FileType, ModifyUser);
  202. }
  203. else
  204. {
  205. string[] aryParam = new string[3];
  206. aryParam[0] = TargetRelationID;
  207. aryParam[1] = FileType;
  208. aryParam[2] = ModifyUser;
  209. return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_UpdateFileType", aryParam);
  210. }
  211. }
  212. /// <summary>
  213. /// 更新對內公開欄位
  214. /// </summary>
  215. public bool UpdateIsProtected(string TargetRelationID, string IsProtected, string ModifyUser)
  216. {
  217. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  218. {
  219. return dal.UpdateIsProtected(TargetRelationID, IsProtected, ModifyUser);
  220. }
  221. else
  222. {
  223. string[] aryParam = new string[3];
  224. aryParam[0] = TargetRelationID;
  225. aryParam[1] = IsProtected;
  226. aryParam[2] = ModifyUser;
  227. return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_UpdateIsProtected", aryParam);
  228. }
  229. }
  230. /// <summary>
  231. /// 更新對外公開欄位
  232. /// </summary>
  233. public bool UpdateIsPublic(string TargetRelationID, string IsPublic, string ModifyUser)
  234. {
  235. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  236. {
  237. return dal.UpdateIsPublic(TargetRelationID, IsPublic, ModifyUser);
  238. }
  239. else
  240. {
  241. string[] aryParam = new string[3];
  242. aryParam[0] = TargetRelationID;
  243. aryParam[1] = IsPublic;
  244. aryParam[2] = ModifyUser;
  245. return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_UpdateIsPublic", aryParam);
  246. }
  247. }
  248. /// <summary>
  249. /// 更新對外公開欄位
  250. /// </summary>
  251. public bool UpdateIsTitlePage(string TargetRelationID, string IsTitlePage, string ModifyUser)
  252. {
  253. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  254. {
  255. return dal.UpdateIsTitlePage(TargetRelationID, IsTitlePage, ModifyUser);
  256. }
  257. else
  258. {
  259. string[] aryParam = new string[3];
  260. aryParam[0] = TargetRelationID;
  261. aryParam[1] = IsTitlePage;
  262. aryParam[2] = ModifyUser;
  263. return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_UpdateIsTitlePage", aryParam);
  264. }
  265. }
  266. public bool ChangeMemo(string strFileGuid, string strFileMemo, string ModifyUser)
  267. {
  268. if (string.IsNullOrEmpty(_strUseWebservice) || _strUseWebservice.ToLower().Equals("false"))
  269. {
  270. return dal.ChangeMemo(strFileGuid, strFileMemo, ModifyUser);
  271. }
  272. else
  273. {
  274. string[] aryParam = new string[3];
  275. aryParam[0] = strFileGuid;
  276. aryParam[1] = strFileMemo;
  277. aryParam[2] = ModifyUser;
  278. return (bool)OT.BLL.Common.WebServiceHelper.InvokeWebService(_strWebserviceUrl, "WS_ChangeMemo", aryParam);
  279. }
  280. }
  281. }
  282. }