123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- using System;
- using Dapper;
- using HNWD.Pregrant.Model;
- using System.Collections.Generic;
- using System.Text;
- namespace HNWD.Pregrant.DataAccess
- {
- public class WD_ZoneInfoDataAccess : GenericDataAccess<WD_ZoneInfo>
- {
- private WD_ZoneInfo wd_ZoneInfo = null;
- public WD_ZoneInfoExt ext = new WD_ZoneInfoExt();
- public WD_ZoneInfoDataAccess(WD_ZoneInfo wd_ZoneInfo)
- {
- this.wd_ZoneInfo = wd_ZoneInfo;
- }
- private WD_ZoneInfoDataAccess()
- {
- }
- private readonly static WD_ZoneInfoDataAccess wd_ZoneInfoDataAccess = new WD_ZoneInfoDataAccess();
- private readonly static object lockobj = new object();
- public static WD_ZoneInfoDataAccess GetInstance()
- {
- lock (lockobj)
- {
- return wd_ZoneInfoDataAccess;
- }
- }
- public List<WD_ZoneInfo> Query(string PartitionNo)
- {
- string where = this.strWhere(PartitionNo);
- string strSql = " from [WD_ZoneInfo] {0} order by [ZONE_ZONEID] ";
- strSql = string.Format(strSql,where);
- strSql = strSql.Insert(0, " select {0} ");
- ext.messageDataList = this.Query(strSql, new WD_ZoneInfo());
- ext.messageDataList.ForEach(f => f.bSuccess = this.bSuccess);
- ext.messageDataList.ForEach(f => f.Code = this.Code);
- ext.messageDataList.ForEach(f => f.Message = this.Message);
- ext.messageDataList.ForEach(f => f.Rows = this.Rows);
- ext.bSuccess = this.bSuccess;
- ext.Code = this.Code;
- ext.Message = this.Message;
- ext.Rows = this.Rows;
- return ext.messageDataList;
- }
- public List<WD_ZoneInfo> QueryAll()
- {
-
- string strSql = " select {0} from [WD_ZoneInfo] ";
-
-
- ext.FileList = this.Query(strSql, new WD_ZoneInfo());
- ext.FileList.ForEach(f => f.bSuccess = this.bSuccess);
- ext.FileList.ForEach(f => f.Code = this.Code);
- ext.FileList.ForEach(f => f.Message = this.Message);
- ext.FileList.ForEach(f => f.Rows = this.Rows);
- ext.bSuccess = this.bSuccess;
- ext.Code = this.Code;
- ext.Message = this.Message;
- ext.Rows = this.Rows;
- return ext.messageDataList;
- }
-
- public void UpdateZoneStatus()
- {
- string strSql = "update [WD_ZoneInfo] SET ZONE_STATUS={0} where [ID]={1} ; update [WD_RunProfile] SET [BroadcastSaveFlag]=1";
- strSql = string.Format(strSql, wd_ZoneInfo.ZONE_STATUS, wd_ZoneInfo.ID);
- this.Execute(strSql, this.wd_ZoneInfo);
- }
- private string strWhere(string PartitionNo)
- {
- string where = string.Empty;
- if (PartitionNo == "0" || PartitionNo == "1" || PartitionNo == "2" || PartitionNo == "3" || PartitionNo == "4" || PartitionNo == "5")
- {
- where = " where [ZONE_ZONEID]=" + PartitionNo;
- }
- else
- {
- where = " where [ZONE_ZONEID] > 0 ";
- }
- return where;
- }
- public void Business(List<WD_ZoneInfo> il, List<WD_ZoneInfo> ul, List<WD_ZoneInfo> dl)
- {
- string strSql_i = " Insert into WD_ZoneInfo([ZONE_ZONEID],[ZONE_FILELIST],[ZONE_STATUS],[ZONE_CONTENT],[ZONE_WEEK],[ZONE_STARTTIME],[ZONE_ENDTIME],[ZONE_DATETIME]) VALUES ('{0}' , '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}') ";
- string strSql_u = " Update WD_ZoneInfo set ZONE_ZONEID = '{0}' , ZONE_FILELIST = '{1}' , ZONE_STATUS = '{2}' , ZONE_CONTENT = '{3}' , ZONE_WEEK = '{4}', ZONE_STARTTIME = '{5}' , ZONE_ENDTIME = '{6}' , ZONE_DATETIME = '{7}' where ID = '{8}' ";
- string strSql_d = " delete WD_ZoneInfo where ID = '{0}' ";
- string strSql_a = " update [WD_RunProfile] SET [BroadcastSaveFlag]=1 ";
- StringBuilder sb_i = new StringBuilder();
- foreach (WD_ZoneInfo wd in il)
- {
- sb_i.AppendFormat(strSql_i, wd.ZONE_ZONEID, wd.ZONE_FILELIST, wd.ZONE_STATUS, wd.ZONE_CONTENT, wd.ZONE_WEEK, wd.ZONE_STARTTIME, wd.ZONE_ENDTIME, wd.ZONE_DATETIME);
- }
- StringBuilder sb_u = new StringBuilder();
- foreach (WD_ZoneInfo wd in ul)
- {
- sb_u.AppendFormat(strSql_u, wd.ZONE_ZONEID, wd.ZONE_FILELIST, wd.ZONE_STATUS, wd.ZONE_CONTENT, wd.ZONE_WEEK, wd.ZONE_STARTTIME, wd.ZONE_ENDTIME, wd.ZONE_DATETIME, wd.ID);
- }
- StringBuilder sb_d = new StringBuilder();
- foreach (WD_ZoneInfo wd in dl)
- {
- sb_d.AppendFormat(strSql_d, wd.ID);
- }
- this.Execute(sb_i.ToString(), sb_u.ToString(), sb_d.ToString(), strSql_a);
- }
-
-
- }
- }
|