Exemplo n.º 1
0
        public static List <UIComment> Comments(Data.Sql.IObjectEntity <Comment> entity, int start, int limit, String model)
        {
            var proposals = new List <Proposal>();

            var comments  = new List <Comment>();
            var forcomdss = new List <Comment>();
            var ids       = new List <Guid>();
            var user      = UMC.Security.Identity.Current;

            entity.Where.And().Greater(new Comment {
                Visible = -1
            });

            entity.Query(start, limit, g =>
            {
                comments.Add(g);
                ids.Add(g.Id.Value);
            });
            if (ids.Count > 0)
            {
                entity.Where.Reset().And().In(new Comment {
                    for_id = ids[0]
                }, ids.ToArray());
                entity.Order.Clear();
                entity.Order.Asc(new Comment {
                    CommentDate = DateTime.MaxValue
                });
                entity.Query(dr => forcomdss.Add(dr));

                Utility.CMS.ObjectEntity <Proposal>().Where.And()
                .Equal(new Proposal {
                    user_id = user.Id
                })
                .And().In(new Proposal {
                    ref_id = ids[0]
                }, ids.ToArray())
                .Entities.Query(dr => proposals.Add(dr));
            }
            var pics = new List <UMC.Data.Entities.Picture>();

            if (ids.Count > 0)
            {
                CMS.ObjectEntity <Data.Entities.Picture>().Where.And().In(new Data.Entities.Picture {
                    group_id = ids[0]
                }, ids.ToArray())
                .Entities.Order.Asc(new Data.Entities.Picture {
                    Seq = 0
                }).Entities.Query(g => pics.Add(g));
            }

            var webr  = UMC.Data.WebResource.Instance();
            var cells = new List <UIComment>();

            foreach (var cm in comments)
            {
                var replys = forcomdss.FindAll(g => g.for_id == cm.Id);
                cells.Add(Comment(cm, replys, pics, webr, model));
            }
            return(cells);
        }
Exemplo n.º 2
0
        public static void Search(UISection ui, Data.Sql.IObjectEntity <Subject> subEntity, String model, String cmd, int start, int limit, bool isblock)
        {
            var subs    = new List <Subject>();
            var cateids = new List <Guid>();
            var ids     = new List <Guid>();
            var itemIds = new List <Guid>();

            var search = UMC.Data.Reflection.CreateInstance <Subject>();

            search.DataJSON  = null;
            search.Content   = null;
            search.ConfigXml = null;
            subEntity.Query(search, start, limit, dr =>
            {
                subs.Add(dr);
                if (dr.project_id.HasValue)
                {
                    cateids.Add(dr.project_id ?? Guid.Empty);
                }
                ids.Add(dr.Id.Value);
                if (dr.project_item_id.HasValue)
                {
                    itemIds.Add(dr.project_item_id.Value);
                }
            });
            var cates  = new List <Project>();
            var pitems = new List <Data.Entities.ProjectItem>();


            if (itemIds.Count > 0)
            {
                Utility.CMS.ObjectEntity <ProjectItem>().Where.And().In(new ProjectItem
                {
                    Id = itemIds[0]
                }, itemIds.ToArray())
                .Entities.Query(dr => pitems.Add(dr));
            }
            if (cateids.Count > 0)
            {
                Utility.CMS.ObjectEntity <Project>().Where.And().In(new Project {
                    Id = cateids[0]
                }, cateids.ToArray())
                .Entities.Query(dr => cates.Add(dr));
            }
            var pics = new List <UMC.Data.Entities.Picture>();

            if (ids.Count > 0)
            {
                Utility.CMS.ObjectEntity <Data.Entities.Picture>().Where.And().In(new Data.Entities.Picture
                {
                    group_id = ids[0]
                }, ids.ToArray()).Entities.Order.Asc(new Data.Entities.Picture {
                    Seq = 0
                }).Entities.Query(g => pics.Add(g));
            }
            ;
            var items = ui;
            var webr  = UMC.Data.WebResource.Instance();


            foreach (var sub in subs)
            {
                if (sub.Visible == 0)
                {
                    continue;
                }
                var ims = new List <UMC.Data.Entities.Picture>();
                pics.RemoveAll(g =>
                {
                    if (g.group_id == sub.Id)
                    {
                        ims.Add(g);
                        return(true);
                    }
                    return(false);
                });
                var imgs = new List <String>();

                if (ims.Count > 0)
                {
                    switch (ims.Count)
                    {
                    case 2:
                    case 1:

                        imgs.Add(webr.ResolveUrl(sub.Id.Value, 1, "0") + "!cms" + ((sub.IsPicture ?? false) ? "1" : "3") + "?_ts=" + UMC.Data.Utility.TimeSpan(ims[0].UploadDate.Value));

                        break;

                    default:
                        for (var i = 0; i < 3; i++)
                        {
                            imgs.Add(webr.ResolveUrl(sub.Id.Value, ims[i].Seq ?? 0, "0") + "!cms3?_ts=" + UMC.Data.Utility.TimeSpan(ims[i].UploadDate.Value));
                        }
                        break;
                    }
                }
                var click = new Web.UIClick(sub.Id.ToString()).Send(model, cmd);
                var data  = new UMC.Web.WebMeta().Put("title", sub.Title).Put("reply", (sub.Reply ?? 0).ToString()).Put("look", (sub.Look ?? 0).ToString());


                var cate  = cates.Find(g => g.Id == sub.project_id);
                var pitem = pitems.Find(g => g.Id == sub.project_item_id);
                data.Put("pname", cate == null ? "草稿" : cate.Caption);
                if (sub.project_id == sub.user_id)
                {
                    data.Put("iname", "");
                }
                else
                {
                    data.Put("iname", pitem == null ? "" : pitem.Caption);
                }
                data.Put("time", Utility.GetDate(sub.ReleaseDate));
                if (cate != null && pitem != null)
                {
                    data.Put("spa", new WebMeta().Put("id", sub.Id).Put("path", String.Format("{0}/{1}/{2}", cate.Code, pitem.Code, sub.Code)));
                }
                else
                {
                    data.Put("sub-id", Utility.Guid(sub.Id.Value));//.Put("path", String.Format("{0}/{1}/{2}", cate.Code, pitem.Code, sub.Code)));
                }
                data.Put("desc", sub.Description);
                UICell cell;
                switch (imgs.Count)
                {
                case 0:
                    cell = new UICMS(click, data);
                    break;

                default:
                    cell = (sub.IsPicture ?? false) ? new UICMS(click, data, imgs[0], true) : (ims.Count > 2 ? new UICMS(click, data, imgs[0], imgs[1], imgs[2]) : new UICMS(click, data, imgs[0]));


                    break;
                }
                cell.Format.Put("left", "{pname} {iname} {time}");
                cell.Style.Name("licon", new UIStyle().Size(12).Font("wdk")).Name("ricon", new UIStyle().Size(12).Font("wdk"));
                cell.Style.Name("pname").Color(0x777);
                cell.Style.Name("iname").Color(0x777);
                if (isblock)
                {
                    cell.Style.Name("block").Size(12).Color(0xaaa).Font("wdk").Click(UIClick.Click(new UIClick("Id", sub.Id.ToString(), "Type", "Block").Send(model, "TipOff")));
                    data.Put("block", "\uea0d");

                    cell.Format.Put("right", "\uF06E{1:licon} {look}   \uF0E6{1:ricon} {reply}  {2:block}");
                }
                else
                {
                    cell.Format.Put("right", "\uF06E{1:licon} {look}   \uF0E6{1:ricon} {reply}");
                }
                items.Add(cell);
            }
            ui.Total = subEntity.Count();;
        }