SendProvider.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Dapper;
  6. using System.Data;
  7. using StarTech_Model;
  8. using Startech.IDAL;
  9. namespace StarTech_DAL
  10. {
  11. public class SendProvider : BaseProvider<SMSHasSend>, ISMSHasSend
  12. {
  13. public IEnumerable<SMSHasSend> FindAll()
  14. {
  15. throw new NotImplementedException();
  16. }
  17. /// <summary>
  18. /// 查询
  19. /// </summary>
  20. /// <returns></returns>
  21. public IEnumerable<SMSHasSend> FindAll(string tablename,string strWhere, string orderby, int index, int size)
  22. {
  23. IEnumerable<SMSHasSend> result = null;
  24. StringBuilder strSql = new StringBuilder();
  25. strSql.Append("T.*,c.Describe,b.DisplayName from SMSHasSend_" + tablename + " T ");
  26. strSql.Append(" LEFT join SMSApplication as c on c.ApplicationID=T.ApplicationID");
  27. strSql.Append(" LEFT JOIN Users as b ON T.Sender=b.ID ");
  28. if (!string.IsNullOrEmpty(strWhere.Trim()))
  29. {
  30. strSql.Append(" WHERE b.DisplayName='" + strWhere + "'");
  31. }
  32. string str = BuildPageSQL(strSql.ToString(), orderby, index, size);
  33. //string str = c.GetListByPage(sql, strWhere, orderby, startIndex, endIndex);
  34. this.Q<IEnumerable<SMSHasSend>>(e => result = e.Query<SMSHasSend>(str, null));
  35. return result;
  36. }
  37. /// <summary>
  38. /// 获取数据总条数
  39. /// </summar
  40. /// <returns></returns>
  41. public int GetCount(string TableName, string UserName)
  42. {
  43. object result="";
  44. StringBuilder strSql = new StringBuilder();
  45. strSql.Append("FROM SMSHasSend_" + TableName + " as a left join Users as b on a.Sender=b.ID");
  46. if (!string.IsNullOrEmpty(UserName.Trim()))
  47. {
  48. strSql.Append(" WHERE b.DisplayName='" + UserName + "'");
  49. }
  50. string query = BuildTotalSQL(strSql.ToString());
  51. this.E(e =>result= e.ExecuteScalar(query, null));
  52. return Convert.ToInt32(result);
  53. }
  54. #region 注释的代码
  55. //public SMSHasReceived FindOne(int id)
  56. //{
  57. // throw new NotImplementedException();
  58. //}
  59. //public IEnumerable<SMSHasReceived> FindAll()
  60. //{
  61. // throw new NotImplementedException();
  62. //}
  63. //public IEnumerable<SMSHasReceived> Search(string serverID, string key)
  64. //{
  65. // throw new NotImplementedException();
  66. //}
  67. //public void Insert(SMSHasReceived value)
  68. //{
  69. // throw new NotImplementedException();
  70. //}
  71. //public void Delete(SMSHasReceived value)
  72. //{
  73. // throw new NotImplementedException();
  74. //}
  75. //public void Update(SMSHasReceived value)
  76. //{
  77. // if (value == null)
  78. // return;
  79. // this.E(e => e.Execute(SqlTexts.UPDATE_USER, value));
  80. //}
  81. //public SMSHasReceived FindOne(string serverID, string loginName)
  82. //{
  83. // SMSHasReceived result = null;
  84. // this.Q<SMSHasReceived>(e => result = e.Query<SMSHasReceived>(SqlTexts.SELECT_USER, new { ServerID = serverID, LoginName = loginName }).FirstOrDefault());
  85. // return result;
  86. //}
  87. //public SMSHasReceived FindOne(string serverID, string account, string password)
  88. //{
  89. // SMSHasReceived result = null;
  90. // this.Q<SMSHasReceived>(e => result = e.Query<SMSHasReceived>(SqlTexts.SELECT_LOGIN, new { ServerID = serverID, Account = account, Password = password }).FirstOrDefault());
  91. // return result;
  92. //}
  93. //public void Update(string serverID, string loginName, string displayName, string watchWord)
  94. //{
  95. // //if (value == null)
  96. // // return;
  97. // //this.E(e => e.Execute(SqlTexts.UPDATE_USER, value));
  98. // throw new NotImplementedException();
  99. //}
  100. //public void Update(string serverID, string loginName, string password, string oldPassword, string userIP = "")
  101. //{
  102. // const string execSQL = "ChangePassword";
  103. // DynamicParameters args = new DynamicParameters();
  104. // args.AddDynamicParams(new { LoginName = loginName, OldPassword = oldPassword, NewPassword = password, UserIP = userIP });
  105. // args.Add(name: "PasswordChanged", value: 0, direction: ParameterDirection.Output);
  106. // args.Add(name: "Cause", value: String.Empty, direction: ParameterDirection.Output);
  107. // E(e => e.Execute(sql: execSQL, param: args, commandType: CommandType.StoredProcedure));
  108. //}
  109. //public void Update(string serverID, string loginName, string headImageHashValue, int headImageType)
  110. //{
  111. // E(e => e.Execute(sql: SqlTexts.UPDATE_HEADIMAGE,
  112. // param: new
  113. // {
  114. // ServerID = serverID,
  115. // LoginName = loginName,
  116. // HeadImageHashValue = headImageHashValue,
  117. // HeadImageType = headImageType
  118. // },
  119. // commandType: CommandType.StoredProcedure));
  120. //}
  121. #endregion
  122. public string GetUserServer(string access_token, int expires_in, string redirect_uri, string clientkey)
  123. {
  124. throw new NotImplementedException();
  125. }
  126. public SMSHasSend FindOne(string id)
  127. {
  128. throw new NotImplementedException();
  129. }
  130. public void Delete(string id)
  131. {
  132. throw new NotImplementedException();
  133. }
  134. }
  135. }