コード例 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ResultGallery DataRowToModel(DataRow row, string resouces)
        {
            ResultGallery model = new ResultGallery();

            if (row != null)
            {
                if (row["Callery_ID"] != null && row["Callery_ID"].ToString() != "")
                {
                    model.id = int.Parse(row["Callery_ID"].ToString());
                }
                if (row["Callery_Customer_ID"] != null && row["Callery_Customer_ID"].ToString() != "")
                {
                    model.customerId = int.Parse(row["Callery_Customer_ID"].ToString());
                }
                if (row["Callery_Size"] != null)
                {
                    model.size = row["Callery_Size"].ToString();
                }
                if (row["Callery_Name"] != null)
                {
                    model.name = row["Callery_Name"].ToString();
                }
                if (row["Callery_ThumbnailPic"] != null)
                {
                    model.thumbPicUri = row["Callery_ThumbnailPic"].ToString();
                    model.thumbPicUrl = resouces + model.thumbPicUri;
                }
                if (row["Callery_SmallPic"] != null)
                {
                    model.smallPicUri = row["Callery_SmallPic"].ToString();
                    model.smallPicUrl = resouces + model.smallPicUri;
                }
                if (row["Callery_BigPic"] != null)
                {
                    model.bigPicUri = row["Callery_BigPic"].ToString();
                    model.bigPicUrl = resouces + model.bigPicUri;
                }
                if (row["Callery_Time"] != null && row["Callery_Time"].ToString() != "")
                {
                    model.createTime = DateTime.Parse(row["Callery_Time"].ToString());
                }
                if (row["Photo_FatherID"] != null && row["Photo_FatherID"].ToString() != "")
                {
                    model.groupId = int.Parse(row["Photo_FatherID"].ToString());
                }
            }
            return(model);
        }
コード例 #2
0
        public HotPageData <ResultGallery[]> GetPhotoList(int customerId, int groupId, string name, int page, int pageSize)
        {
            //PdMallSystemConfigModel configModel = PdMallSystemConfigProvider.Instance.GetCurrentConfig();
            //todo
            string resourceSiteAddr = "";

            string where = "";
            if (!string.IsNullOrEmpty(name))
            {
                where += " and Callery_Name like '%" + name + "%'";
            }
            //            string sql = string.Format(@"select Callery_ID,Callery_Customer_ID,Callery_Size,Callery_Name,Callery_ThumbnailPic,Callery_SmallPic,Callery_BigPic,
            //                                            Callery_Time,Callery_UpdateTime,Photo_FatherID from HQ_Gallery where Callery_Customer_ID={0} and Photo_FatherID={1} {2} order by Callery_Time desc", customerId, groupId, where);
            string sql = string.Format(@"select Callery_ID,Callery_Customer_ID,Callery_Size,Callery_Name,Callery_ThumbnailPic,Callery_SmallPic,Callery_BigPic,
                                            Callery_Time,Callery_UpdateTime,Photo_FatherID from HQ_Gallery where Callery_Customer_ID={0} and Photo_FatherID={1} {2} order by Callery_ID desc", customerId, groupId, where);
            List <ResultGallery>          list      = new List <ResultGallery>();
            HotPageData <ResultGallery[]> dataPager = null;
            HotPageData <DataTable>       pager     = base.getPageData(sql, page, pageSize);

            if (pager != null)
            {
                DataTable dt = pager.Rows;
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        ResultGallery model = DataRowToModel(row, resourceSiteAddr);
                        list.Add(model);
                    }
                }
                dataPager           = new HotPageData <ResultGallery[]>();
                dataPager.PageCount = pager.PageCount;
                dataPager.PageIndex = pager.PageIndex;
                dataPager.PageSize  = pager.PageSize;
                dataPager.Total     = pager.Total;
                dataPager.Rows      = list.Count > 0 ? list.ToArray() : null;
            }
            return(dataPager);
        }