Example #1
0
 /// <summary>
 /// 分页
 /// </summary>
 /// <typeparam name="T">实体</typeparam>
 /// <param name="page">当前页索引</param>
 /// <param name="pageSize">分页大小</param>
 /// <param name="sql">SQL Script</param>
 /// <param name="isPage">是否分页(false:不分页,查询全部 ,true:分页)</param>
 /// <param name="args">参数列表</param>
 /// <returns></returns>
 public Page <T> Page(long page, long pageSize, string sql = null, List <object> args = null, bool isPage = true)
 {
     WriteDatabase.Comment = new StringExtension.SqlComment
     {
         Author   = "BASEDAL",
         FileName = "BaseDal.cs",
         ForUse   = "分页查询",
         FunName  = "Page"
     };
     if (!isPage)
     {
         IEnumerable <T> result;
         if (args == null || args.Count.Equals(0))
         {
             result = WriteDatabase.Query <T>(sql);
         }
         else
         {
             result = WriteDatabase.Query <T>(sql, args.ToArray());
         }
         return(new Page <T> {
             Items = result.ToList(), CurrentPage = page, ItemsPerPage = pageSize
         });
     }
     return(ReadDatabase.Page <T>(page, pageSize, sql, (args ?? new List <object>()).ToArray()));
 }
Example #2
0
        /// <summary>
        /// 直接查询list
        /// add by lpl
        /// 2019-1-2
        /// </summary>
        /// <returns></returns>
        public List <GongGaoMangerEntity> QueryList()
        {
            var strSql = new StringBuilder("SELECT * FROM dbo.GongWenManger WHERE 1=1");

            var args = new List <object>();

            return(WriteDatabase.Query <GongGaoMangerEntity>(strSql.ToString(), args.ToArray()).ToList());
        }
Example #3
0
        /// <summary>
        /// 直接查询list
        /// add by lpl
        /// 2019-1-2
        /// </summary>
        /// <returns></returns>
        public List <GongGaoDetialEntity> QueryList(string userid = null)
        {
            var strSql = new StringBuilder("SELECT * FROM dbo.GongGaoDetial WHERE 1=1");

            var args = new List <object>();

            if (string.IsNullOrEmpty(userid))
            {
                strSql.AppendFormat(" UserId  = '{0}'", userid);
            }

            return(WriteDatabase.Query <GongGaoDetialEntity>(strSql.ToString(), args.ToArray()).ToList());
        }
Example #4
0
        /// <summary>
        /// 直接查询list,不分页
        /// ad by lpl
        /// 2019-1-3
        /// </summary>
        /// <returns></returns>
        public List <PowerItemEntity> QueryList(PowerItemEntity powerItemEntity)
        {
            var strSql = new StringBuilder(@"SELECT Id, Item, CFZL, CFYJ, CFYJYW, WFFG, WFFGYW, (SELECT RsKey FROM dbo.ComResource WHERE ParentId = '0058' AND RsValue = LX) AS LX,LX AS LXValue  FROM dbo.PowerItem
            WHERE RowStatus = 1 ");
            var args   = new List <object>();

            if (!string.IsNullOrEmpty(powerItemEntity.LX))
            {
                strSql.AppendFormat("AND LX = '{0}'", powerItemEntity.LX);
            }



            return(WriteDatabase.Query <PowerItemEntity>(strSql.ToString(), args.ToArray()).ToList());
        }
Example #5
0
        /// <summary>
        /// 条件搜索
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="starttime"></param>
        /// <param name="endtime"></param>
        /// <returns></returns>
        public List <DocumentNotificationEntity> SearchQuery(DocumentNotificationEntity entity, string limittime = null, string jieshouGuid = null)
        {
            try
            {
                var strSql = new StringBuilder("SELECT * FROM dbo.DocumentNotification WHERE 1=1");

                //标题搜索
                if (!string.IsNullOrEmpty(entity.Title))
                {
                    strSql.AppendFormat("AND Title LIKE '%{0}%'", entity.Title);
                }

                //时间范围搜索
                if (!string.IsNullOrEmpty(limittime))
                {
                    string[] arryTime = limittime.Split('至');

                    string startTime = arryTime[0];
                    string endTime   = arryTime[1];

                    strSql.AppendFormat("AND ReleaseTime > '{0}' AND ReleaseTime < '{1}'", startTime, endTime);
                }

                //通告类型
                if (!string.IsNullOrEmpty(entity.Category))
                {
                    strSql.AppendFormat("AND Category = '{0}'", entity.Category);
                }


                if (!string.IsNullOrEmpty(jieshouGuid))
                {
                    strSql.AppendFormat("AND Id IN ({0})", jieshouGuid);
                }


                var args = new List <object>();

                return(WriteDatabase.Query <DocumentNotificationEntity>(strSql.ToString(), args.ToArray()).ToList());
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        /// <summary>
        /// 根据手机类型获取最新版本信息
        /// </summary>
        /// <returns></returns>
        public ComVersionManagementEntity GetNewVersionInfo(int mobileType)
        {
            var strsql = new StringBuilder();

            strsql.AppendFormat(
                @"SELECT TOP 1 *
                FROM ComVersionManagement WITH(NOLOCK)  Where RowStatus=1 AND MobileType={0} ORDER BY VersionNo DESC",
                mobileType);
            WriteDatabase.Comment = new StringExtension.SqlComment
            {
                Author   = "",
                FileName = "ComVersionManagementDal.cs",
                ForUse   = "根据手机类型获取最新版本信息",
                FunName  = "GetNewVersionInfo"
            };
            var dt   = WriteDatabase.Query(strsql.ToString());
            var list = ConvertListHelper <ComVersionManagementEntity> .ConvertToList(dt);

            return(list.Any() ? list[0] : new ComVersionManagementEntity());
        }
Example #7
0
        /// <summary>
        /// 数据查询
        /// </summary>
        /// <param name="search"></param>
        /// <param name="expressions"></param>
        /// <returns></returns>
        public List <DocumentNotificationEntity> GetAllResult(DocumentNotificationEntity search)
        {
            var sbWhere = new StringBuilder();

            sbWhere.Append("Where ROWSTATUS = 1 ");
            var args = new List <object>();

            if (!string.IsNullOrEmpty(search.Id))
            {
                sbWhere.Append(Database.GetFormatSql <DocumentNotificationEntity>(" and {0} = @p1 ", t => t.Id));
                args.Add(new { p1 = search.Id });
            }


            if (!string.IsNullOrEmpty(search.Title))
            {
                sbWhere.Append(Database.GetFormatSql <DocumentNotificationEntity>(" and Title like @p1 "));
                args.Add(new { p1 = "%" + search.Title + "%" });
            }

            sbWhere.Append(" ORDER BY  CreateOn");
            return(WriteDatabase.Query <DocumentNotificationEntity>(sbWhere.ToString(), args.ToArray()).ToList());
        }