예제 #1
0
        /// <summary>
        /// 通过作品类别ID获取作品类别
        /// </summary>
        /// <param name="worksTypeId">作品类别ID</param>
        /// <returns></returns>
        public WorksType GetWorksTypeById(string worksTypeId)
        {
            long      lWorksTypeId    = long.Parse(worksTypeId);
            WorksType worksTypeEntity = db.WorksType.SingleOrDefault(w => w.WorksTypeID == lWorksTypeId);

            return(worksTypeEntity);
        }
예제 #2
0
        /// <summary>
        /// 初始化作品信息显示控件
        /// </summary>
        /// <param name="userId">当前用户ID</param>
        /// <param name="worksId">当前作品ID</param>
        private void InitControl(long userId, long worksId)
        {
            if (worksId != 0)
            {
                using (ChannelFactory <IServiceWorks> channelFactory = new ChannelFactory <IServiceWorks>("ServiceWorks"))
                {
                    IServiceWorks proxy = channelFactory.CreateChannel();

                    //getall
                    VAWcfService.Works works = proxy.GetWorksSubmitById(worksId.ToString());
                    LbWorksName.Text         = works.WorksName;
                    LbWorksCode.Text         = works.WorksCode;
                    LbInstallationGuide.Text = works.InstallationGuide;
                    LbComment.Text           = works.Comment;
                    LbSubmitProfile.Text     = works.SubmitProfile;


                    //LblDemoUrl.Text = works.DemoURL;
                    //VAWcfService.WorksType worksType=proxy.


                    DivDesignIdeas.Controls.Clear();
                    DivDesignIdeas.InnerText = works.DesignIdeas;

                    DivKeyPoints.InnerText = works.KeyPoints;
                    DivScore.InnerText     = works.Score.ToString();

                    if (works.WorksTypeID != null)
                    {
                        VAWcfService.WorksType worksType = proxy.GetWorksTypeById(works.WorksTypeID.ToString());
                        LbWorksType.Text = worksType.WorksTypeName.ToString();
                    }

                    //作品附件

                    ShowDocuments(proxy, worksId);
                    //ShowMedias(proxy, worksId, 3);
                    ShowMedias(proxy, worksId, 4);
                    ShowImages(proxy, worksId);
                    ShowOthers(proxy, worksId);


                    //上下文导航
                    List <VAWcfService.Works> worksList = proxy.GetWorks();
                    int currentIndex = worksList.FindIndex(w => w.WorksID == worksId);
                    //string worksNavhtml = "";
                    if (currentIndex == 0)//第一条
                    {
                        LeftLayer.InnerHtml  = "<a class='nvWorksLnk' href='WorksShow.aspx?wid=" + worksList[worksList.Count - 1].WorksID + "' title='上一作品:" + worksList[worksList.Count - 1].WorksName + "'><img src='images//Prev.png' alt=''/></a>";
                        RightLayer.InnerHtml = "<a class='nvWorksLnk' href='WorksShow.aspx?wid=" + worksList[currentIndex + 1].WorksID + "'  title='下一作品:" + worksList[currentIndex + 1].WorksName + "'><img src='images/Next.png' alt=''/></a>";

                        lnkPre.Text         = "上一作品:" + worksList[worksList.Count - 1].WorksName;
                        lnkPre.NavigateUrl  = "WorksShow.aspx?wid=" + worksList[worksList.Count - 1].WorksID;
                        lnkNext.Text        = "下一作品:" + worksList[currentIndex + 1].WorksName;
                        lnkNext.NavigateUrl = "WorksShow.aspx?wid=" + worksList[currentIndex + 1].WorksID;
                    }
                    else if (currentIndex == worksList.Count - 1)//
                    {
                        LeftLayer.InnerHtml  = "<a class='nvWorksLnk' href='WorksShow.aspx?wid=" + worksList[currentIndex - 1].WorksID + "' title='上一作品:" + worksList[currentIndex - 1].WorksName + "'><img src='images/Prev.png' alt=''/></a>";
                        RightLayer.InnerHtml = "<a class='nvWorksLnk' href='WorksShow.aspx?wid=" + worksList[0].WorksID + "' title='下一作品:" + worksList[0].WorksName + "'><img src='images/Next.png' alt=''/></a>";

                        lnkPre.Text         = "上一作品:" + worksList[currentIndex - 1].WorksName;
                        lnkPre.NavigateUrl  = "WorksShow.aspx?wid=" + worksList[currentIndex - 1].WorksID;
                        lnkNext.Text        = "下一作品:" + worksList[0].WorksName;
                        lnkNext.NavigateUrl = "WorksShow.aspx?wid=" + worksList[0].WorksID;
                    }
                    else//
                    {
                        LeftLayer.InnerHtml  = "<a class='nvWorksLnk' href='WorksShow.aspx?wid=" + worksList[currentIndex - 1].WorksID + "' title='上一作品:" + worksList[currentIndex - 1].WorksName + "'><img src='images/Prev.png' alt=''/></a>";
                        RightLayer.InnerHtml = "<a class='nvWorksLnk' href='WorksShow.aspx?wid=" + worksList[currentIndex + 1].WorksID + "' title='下一作品:" + worksList[currentIndex + 1].WorksName + "'><img src='images/Next.png' alt=''/></a>";

                        lnkPre.Text         = "上一作品:" + worksList[currentIndex - 1].WorksName;
                        lnkPre.NavigateUrl  = "WorksShow.aspx?wid=" + worksList[currentIndex - 1].WorksID;
                        lnkNext.Text        = "下一作品:" + worksList[currentIndex + 1].WorksName;
                        lnkNext.NavigateUrl = "WorksShow.aspx?wid=" + worksList[currentIndex + 1].WorksID;
                    }
                    //WorksNavDiv.InnerHtml = worksNavhtml;
                    //if (em.WorksTypeID != null)
                    //{
                    //    LbWorksType.Text = GetWorksTypeName((int)em.WorksTypeID);
                    //}
                }
                if (userId != 0)
                {
                    using (ChannelFactory <IServiceUser> cfUser = new ChannelFactory <IServiceUser>("ServiceUser"))
                    {
                        IServiceUser user = cfUser.CreateChannel();
                        if (user == null)
                        {
                            throw new ArgumentNullException(nameof(user));
                        }
                        Favorites favWorks =
                            user.GetUserFavorites(userId.ToString())
                            .FirstOrDefault(f => f.DomainID == 5 & f.ItemID == worksId);
                        if (favWorks != null)
                        {
                            BtnFav.Visible   = false;
                            BtnUnFav.Visible = true;
                        }
                        else
                        {
                            BtnFav.Visible   = true;
                            BtnUnFav.Visible = false;
                        }
                    }
                }
            }
            else
            {
                LeftLayer.Visible  = false;
                RightLayer.Visible = false;
            }
        }
예제 #3
0
        /// <summary>
        /// 生成列表页面
        /// </summary>
        /// <param name="worksList">作品列表数据源</param>
        /// <param name="pageSize">每页条目数</param>
        /// <param name="pageNum">当前页数</param>
        private void GenericList(List <CSMyWorks> worksList, long pageSize, long pageNum)
        {
            long worksCount = worksList.Count;

            if (worksCount > pageSize)
            {
                if (0 == pageNum)//最后一页
                {
                    pageSize = worksCount - pageSize * (pageNum - 1);
                }
                worksList = worksList.Skip((int)(pageSize * (pageNum - 1))).Take((int)pageSize).ToList();
            }


            if (worksList.Count > 0)
            {
                HtmlContainerControl ulControl = new HtmlGenericControl("ul");
                foreach (var works in worksList)
                {
                    HtmlContainerControl liControl = new HtmlGenericControl("li");

                    //if ()
                    //{

                    //}
                    //为具有删除权限的用户,添加删除作品按钮
                    //ImageButton iBtnDel = new ImageButton
                    //{
                    //    ImageUrl = "./images/delete.png",
                    //    ToolTip = "删除作品",
                    //    Width = 24,
                    //    CommandArgument = works.WorksID.ToString(),
                    //    CommandName = "ItemDel" + works.WorksID,
                    //    ID = "btnDel" + works.WorksID,
                    //    OnClientClick = "javascript:return confirm('确定删除本作品吗?');"
                    //};
                    //iBtnDel.Click += IBtnDel_Click; ;
                    //iBtnDel.Attributes.Add("class", "btnDel");
                    //liControl.Controls.Add(iBtnDel);

                    StringBuilder liBuilder = new StringBuilder();
                    //填充作品信息
                    liBuilder.AppendLine("<a class='cbp-vm-image' href='WorksShow.aspx?wid=" + works.WorksID + "' target='_blank' title='" + works.WorksName + "'><img src='images/works.png'></a>");
                    liBuilder.AppendLine("<h3 class='cbp-vm-title'><a href='WorksShow.aspx?wid=" + works.WorksID + "' target='_blank'>" + works.WorksName + "</a></h3>");

                    using (ChannelFactory <IServiceWorks> channelFactory = new ChannelFactory <IServiceWorks>("ServiceWorks"))
                    {
                        IServiceWorks proxy = channelFactory.CreateChannel();
                        if (works.PeriodID != null)
                        {
                            Periods period = proxy.GetPeriodsById(works.PeriodID.ToString()).FirstOrDefault();
                            if (period?.CourseID != null)
                            {
                                liBuilder.AppendLine("<div class='cbp-vm-price'>" + period.PeriodTitle + "</div>");//作品所属期次
                                string courseId = period.CourseID.ToString();
                                Course course   = proxy.GetCourseById(courseId).FirstOrDefault();
                                if (course != null)
                                {
                                    string courseUrl = "http://va.neu.edu.cn" + course.Url;
                                    liBuilder.AppendLine("<div class='cbp-vm-price'><a href='" + courseUrl + "' target='_blank'>" + course.CourseName + "</a></div>");//作品所属网站
                                }
                            }
                        }

                        if (works.WorksTypeID != null)
                        {
                            VAWcfService.WorksType worksType = proxy.GetWorksTypeById(works.WorksTypeID.ToString());
                            liBuilder.AppendLine("<div class='cbp-vm-price'>" + worksType.WorksTypeName + "</div>");//作品类别
                        }
                    }
                    liBuilder.AppendLine("<div class='cbp-vm-price'>" + $"{works.Created:d}" + "</div>");
                    string desc = Bll.Common.NoHtml(works.DesignIdeas);
                    if (desc.Length > 45)
                    {
                        desc = desc.Substring(0, 45) + "...";
                    }
                    liBuilder.AppendLine("<br/><div class='cbp-vm-details'><a href='WorksShow.aspx?wid=" + works.WorksID + "' target='_blank'>" + desc + "</a></div> ");//作品介绍

                    liControl.Controls.Add(new LiteralControl(liBuilder.ToString()));
                    //liBuilder.AppendLine("</li>");
                    ulControl.Controls.Add(liControl);
                }

                //liBuilder.AppendLine("</ul>");
                worksListDiv.Controls.Clear();
                worksListDiv.Controls.Add(ulControl);
            }

            //worksListDiv.InnerHtml = liBuilder.ToString();
        }