/// <summary>
        /// Returns, for this Detail Designator and the supplied Target Idea, the Detail Content stored or generated by default (from the Initializer).
        /// </summary>
        public override ContainedDetail GetFinalContent(Idea TargetIdea)
        {
            if (TargetIdea == null)
            {
                return(null);
            }

            var Detail = TargetIdea.Details.Where(det => det.Designation.IsEqual(this)).FirstOrDefault();

            if (Detail == null)
            {
                this.EditEngine.Pause();

                var Link = new InternalLink(TargetIdea, ((DetailDesignator)this).Assign(true));
                Link.TargetProperty = this.Initializer as MModelPropertyDefinitor;
                if (Link.TargetProperty != null && Link.TargetProperty.Read(TargetIdea) != null)
                {
                    Detail = Link;
                }

                this.EditEngine.Resume();
            }

            return(Detail);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 添加内部链接
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void LinkAdd(InternalLink entity)
 {
     entity.IL_CrtTime = DateTime.Now;
     Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent();
     if (org != null)
     {
         entity.Org_ID   = org.Org_ID;
         entity.Org_Name = org.Org_Name;
     }
     Gateway.Default.Save <InternalLink>(entity);
 }
Exemplo n.º 3
0
        public DetailLinkEditor(string Title, Link InitialTarget, Assignment <DetailDesignator> /*L*/ Designator, Idea TargetIdea)
            : this()
        {
            this.Title.Text    = Title;
            this.InitialTarget = InitialTarget;
            this.Designator    = Designator;

            var DefaultTarget = ((LinkDetailDesignator)Designator.Value).Initializer;

            if (this.InitialTarget == null)
            {
                var PropLink = new InternalLink(TargetIdea, Designator);

                if (DefaultTarget != null && DefaultTarget is MModelPropertyDefinitor)
                {
                    var PropDef = DefaultTarget.CreateCopy(ECloneOperationScope.Deep, null) as MModelPropertyDefinitor;
                    PropLink.TargetProperty = PropDef;
                }

                this.InitialTarget = PropLink;
            }

            if (this.InitialTarget is ResourceLink)
            {
                this.LinkTargetForResource = InitialTarget as ResourceLink;

                this.LinkTargetForInternal = new InternalLink(TargetIdea, Designator);
                // IMPORTANT: The related designator is shared, therefore it updated when SelectedLinkTarget is getted.

                this.Location.Editor.Text = (LinkTargetForResource == null ? "" : LinkTargetForResource.TargetLocation);

                this.TabLinkExternal.IsSelected = true;
            }
            else
            {
                this.LinkTargetForInternal = this.InitialTarget as InternalLink;

                this.LinkTargetForResource = new ResourceLink(TargetIdea, Designator);
                // IMPORTANT: The related designator is shared, therefore is updated when SelectedLinkTarget is getted.

                if (this.AvailableProperties.Contains(this.LinkTargetForInternal.TargetProperty))
                {
                    this.ComboPropertySelector.SelectedItem = this.LinkTargetForInternal.TargetProperty;
                }
                else
                {
                    this.ComboPropertySelector.SelectedItem = this.AvailableProperties.FirstOrDefault();
                }

                this.TabLinkInternal.IsSelected = true;
            }
        }
Exemplo n.º 4
0
        public IActionResult Spider(int page = 1)
        {
            int paresh = (page - 1) * 6;
            //تعداد کل ردیف ها
            int totalCount = _iuw.NewsSpiderRepositoryUW.Get().Count();

            ViewBag.PageID = page;
            double remain = totalCount % 6;

            if (remain == 0)
            {
                ViewBag.PageCount = totalCount / 6;
            }
            else
            {
                ViewBag.PageCount = (totalCount / 6) + 1;
            }


            string       url          = "https://www.us-cert.gov/ncas/current-activity";
            HtmlWeb      HWeb         = new HtmlWeb();
            HtmlDocument HDoc         = HWeb.Load(url);
            var          HtmlMainPage = HDoc.DocumentNode;

            HDoc.LoadHtml(HtmlMainPage.InnerHtml);

            if (HtmlMainPage.HasChildNodes)
            {
                var tagA = HDoc.DocumentNode.SelectNodes("//a");
                foreach (var item in tagA)
                {
                    string urlA = item.Attributes["href"] != null ? item.Attributes["href"].Value : null;

                    if (urlA != null)
                    {
                        string Url = EditUrl(item.Attributes["href"].Value, url);
                        if (Url != null)
                        {
                            var rr = "https://www.us-cert.gov/ncas/current-activity";

                            var qMainLink = _iuw.MainLinkRepositoryUW.Get(a => a.Url.Equals(rr)).SingleOrDefault();


                            var qq = _iuw.InternalLinkRepositoryUW.Get(q => q.IntrnalUrl.Equals(Url)).Count();
                            if (qq == 0)
                            {
                                InternalLink modeli = new InternalLink();

                                modeli.IntrnalUrl   = Url;
                                modeli.MainlinkID   = qMainLink.MainLinkId;
                                modeli.SpiderDate   = DateTime.Now;
                                modeli.SpiderStatus = true;

                                _iuw.InternalLinkRepositoryUW.Create(modeli);
                                _iuw.Save();

                                HtmlDocument HEditDoc = new HtmlDocument();
                                HtmlWeb      HWebq    = new HtmlWeb();

                                var PageHtml = HWebq.Load(Url);

                                if (PageHtml != null)
                                {
                                    string EditHtml = PageHtml.DocumentNode.InnerHtml;
                                    HEditDoc.LoadHtml(EditHtml);

                                    if (HEditDoc.DocumentNode.HasChildNodes)
                                    {
                                        var qXpathContet = HEditDoc.DocumentNode.SelectSingleNode(qMainLink.XpathContent) != null?HEditDoc.DocumentNode.SelectSingleNode(qMainLink.XpathContent).InnerHtml : null;

                                        if (qXpathContet != null && qXpathContet != "")
                                        {
                                            string     content   = HEditDoc.DocumentNode.SelectSingleNode(qMainLink.XpathContent).InnerHtml;
                                            string     tittle    = HEditDoc.DocumentNode.SelectSingleNode(qMainLink.XpathTitle).InnerText;
                                            NewsSpider modelnews = new NewsSpider();


                                            modelnews.Content       = content;
                                            modelnews.IntrnalLinkID = modeli.InternalLinkId;
                                            modelnews.NewsDate      = DateTime.Now;
                                            modelnews.Status        = true;
                                            modelnews.Titel         = tittle;
                                            _iuw.NewsSpiderRepositoryUW.Create(modelnews);
                                            _iuw.Save();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            var model = _iuw.NewsSpiderRepositoryUW.Get();

            return(View(model));
        }
Exemplo n.º 5
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void LinkSave(InternalLink entity)
 {
     Gateway.Default.Save <InternalLink>(entity);
 }