using System; using System.Collections.Generic; using System.Text; using System.Data; using WeiSha.Common; using Song.Entities; using WeiSha.Data; using Song.ServiceInterfaces; namespace Song.ServiceImpls { public class NoticeCom :INotice { #region INotice 成员 public void Add(Notice entity) { entity.No_CrtTime = DateTime.Now; Song.Entities.Organization org = Business.Do().OrganCurrent(); if (org != null) { entity.Org_ID = org.Org_ID; entity.Org_Name = org.Org_Name; } Gateway.Default.Save(entity); } public void Save(Notice entity) { Gateway.Default.Save(entity); } public void Delete(Notice entity) { Gateway.Default.Delete(entity); } public void Delete(int identify) { Gateway.Default.Delete(Notice._.No_Id == identify); } public void Delete(string name) { Gateway.Default.Delete(Notice._.No_Ttl == name); } public Notice NoticeSingle(int identify) { return Gateway.Default.From().Where(Notice._.No_Id == identify).ToFirst(); } public Notice NoticeSingle(string ttl) { return Gateway.Default.From().Where(Notice._.No_Ttl == ttl).ToFirst(); } /// /// 当前公告的上一条公告 /// /// /// public Notice NoticePrev(int identify, int orgid) { WhereClip wc = new WhereClip(); if (orgid > 0) wc &= Notice._.Org_ID == orgid; wc &= Notice._.No_IsShow == true; wc &= Notice._.No_StartTime < DateTime.Now; Song.Entities.Notice no = this.NoticeSingle(identify); return Gateway.Default.From().OrderBy(Notice._.No_StartTime.Asc) .Where(wc && Notice._.No_StartTime > no.No_StartTime).ToFirst(); } /// /// 当前公告的下一条公告 /// /// /// public Notice NoticeNext(int identify,int orgid) { WhereClip wc = new WhereClip(); if (orgid > 0) wc &= Notice._.Org_ID == orgid; wc &= Notice._.No_IsShow == true; wc &= Notice._.No_StartTime < DateTime.Now; Song.Entities.Notice no = this.NoticeSingle(identify); return Gateway.Default.From().OrderBy(Notice._.No_StartTime.Desc) .Where(wc && Notice._.No_StartTime < no.No_StartTime).ToFirst(); } public Notice[] GetAll() { return Gateway.Default.From().OrderBy(Notice._.No_StartTime.Desc).ToArray(); } public Notice[] GetAll(int orgid, bool? isShow) { WhereClip wc = new WhereClip(); if (orgid > 0) wc &= Notice._.Org_ID == orgid; if (isShow != null) wc &= Notice._.No_IsShow == (bool)isShow; return Gateway.Default.From().Where(wc).OrderBy(Notice._.No_IsTop.Asc && Notice._.No_StartTime.Desc).ToArray(); } public Notice[] GetCount(int orgid, bool? isShow, int count) { WhereClip wc = new WhereClip(); wc.And(Notice._.No_StartTime < DateTime.Now); if (orgid > 0) wc &= Notice._.Org_ID == orgid; if (isShow != null) wc &= Notice._.No_IsShow == (bool)isShow; return Gateway.Default.From().Where(wc).OrderBy(Notice._.No_IsTop.Asc && Notice._.No_StartTime.Desc).ToArray(count); } /// /// 取具体的数量 /// /// /// /// public int OfCount(int orgid, bool? isShow) { WhereClip wc = new WhereClip(); if (orgid > 0) wc.And(Notice._.Org_ID == orgid); if (isShow != null) wc.And(Notice._.No_IsShow == isShow); return Gateway.Default.Count(wc); } public Notice[] GetPager(int orgid, int size, int index, out int countSum) { WhereClip wc = new WhereClip(); if (orgid > 0) wc &= Notice._.Org_ID == orgid; countSum = Gateway.Default.Count(wc); return Gateway.Default.From().Where(wc).OrderBy(Notice._.No_IsTop.Asc && Notice._.No_StartTime.Desc).ToArray(size, (index - 1) * size); } /// /// 分页获取所有的公告; /// /// 是否显示 /// 查询字符 /// /// /// /// public Notice[] GetPager(int orgid, bool? isShow, string searTxt, int size, int index, out int countSum) { WhereClip wc = new WhereClip(); if (orgid > 0) wc &= Notice._.Org_ID == orgid; if (isShow != null) wc &= Notice._.No_IsShow == (bool)isShow; if (!string.IsNullOrWhiteSpace(searTxt)) wc.And(Notice._.No_Ttl.Like("%" + searTxt + "%")); countSum = Gateway.Default.Count(wc); return Gateway.Default.From().Where(wc).OrderBy(Notice._.No_IsTop.Asc && Notice._.No_StartTime.Desc).ToArray(size, (index - 1) * size); } #endregion } }