Пример #1
0
        public async Task <IActionResult> Delete(int id)
        {
            string   webRootPath = _hostingEnvironment.WebRootPath;
            LinkItem linkItem    = await _db.LinkItem.Where(m => m.Id == id).FirstOrDefaultAsync();

            if (linkItem == null)
            {
                return(NotFound());
            }

            var uploads = Path.Combine(webRootPath, "Images-link");

            string extension = string.Empty;

            if (linkItem.Image != null)
            {
                extension = linkItem.Image.Substring(linkItem.Image.LastIndexOf("."));
            }

            var imagePath = Path.Combine(uploads, linkItem.Id + extension);

            if (System.IO.File.Exists(imagePath))
            {
                System.IO.File.Delete(imagePath);
            }

            _db.LinkItem.Remove(linkItem);

            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Пример #2
0
        protected override bool OnMotionNotifyEvent(Gdk.EventMotion ev)
        {
            SelectItem(null);

            Gdk.Point pt = new Gdk.Point((int)ev.X, (int)ev.Y);

            if (prelight_item != null)
            {
                if (prelight_item.Bounds.Contains(pt))
                {
                    return(true);
                }
                else
                {
                    LinkItem item = prelight_item;
                    prelight_item = null;
                    QueueDrawArea(item.Bounds.X, item.Bounds.Y, item.Bounds.Width, item.Bounds.Height);
                }
            }

            foreach (Item item in items)
            {
                if (item is LinkItem && item.Bounds.Contains(pt))
                {
                    prelight_item = item as LinkItem;
                    QueueDrawArea(item.Bounds.X, item.Bounds.Y, item.Bounds.Width, item.Bounds.Height);
                    break;
                }
            }

            return(true);
        }
Пример #3
0
        /// <summary>
        /// Retrieveing  documents list from remote location
        /// </summary>
        /// <param name="externalURL"></param>
        public static LinkItemCollection GetExternalLinks(string externalURL)
        {
            ExternalDocStub externalLinksObj = new Helpers.ExternalDocStub();

            using (StreamReader sr = new StreamReader(HostingEnvironment.MapPath(externalURL)))
            {
                externalLinksObj = JsonConvert.DeserializeObject <ExternalDocStub>(sr.ReadToEnd());
            }


            List <LinkItem> listItem = new List <LinkItem>();

            foreach (var asset in externalLinksObj.Assets)
            {
                LinkItem lnkItem = new LinkItem();
                lnkItem.Title = asset.Title;
                lnkItem.Text  = asset.PreviewURL;
                lnkItem.Href  = asset.URL;
                listItem.Add(lnkItem);
            }

            LinkItemCollection itemCollection = new LinkItemCollection(listItem);

            return(itemCollection);
        }
Пример #4
0
        public async Task InitializeAsync_DataIsValid_PropertiesAreSetFromData()
        {
            // Arrange
            var model    = new LinkItemViewModel(null, new Mock <ILinkItemRepository>().Object, null, null, null);
            var linkItem = new LinkItem
            {
                ID            = 1,
                Info          = "some info",
                Link          = "http://link.com",
                Name          = "some name",
                Rank          = 6,
                LastUpdatedOn = DateTime.Now.AddDays(-5)
            };

            // Act
            await model.InitializeAsync(linkItem);

            // Assert
            Assert.Equal(linkItem.ID, model.Id);
            Assert.Equal(linkItem.Info, model.Info);
            Assert.Equal(linkItem.Link, model.Link);
            Assert.Equal(linkItem.Name, model.Name);
            Assert.Equal(linkItem.Rank, model.Rank);
            Assert.Equal(linkItem.LastUpdatedOn, model.LastUpdatedOn);
        }
        public virtual List <LinkItem> GetPageBreadcrumbs(PageData currentPage)
        {
            List <LinkItem> linkItems = new List <LinkItem>();

            var parents = ContentLoader.GetAncestors(currentPage.ContentLink)
                          .Reverse()
                          .Cast <PageData>()
                          .Where(p => p.ContentLink != PageReference.RootPage);

            if (parents != null)
            {
                foreach (var parent in parents)
                {
                    var linkItem = new LinkItem
                    {
                        Href     = parent.ContentLink.GetFriendlyUrl(),
                        Title    = parent.Name,
                        LinkText = parent.Name,
                        Active   = true
                    };
                    linkItems.Add(linkItem);
                }
            }

            linkItems.Add(new LinkItem
            {
                Href     = currentPage.ContentLink.GetFriendlyUrl(),
                Title    = currentPage.Name,
                LinkText = currentPage.Name,
                Active   = false
            });

            return(linkItems);
        }
Пример #6
0
        public static void AddEntry(WorldClient client, string[] args)
        {
            if (args.Length < 2 || args.Length > 4)
            {
                if (args.Length != 1)
                {
                    client.Character.ReplyError("Invalid command.");
                }

                client.Character.Reply("Create an entry for a link between two maps. Related cmds: .exits, .addlink");
                client.Character.Reply("NOTE: Place your character on the cell where you'll want to spawn using the linked exit.");
                client.Character.Reply("» .entries add $ElementId [$ElementType=70 $SkillId=84]");
                client.Character.Reply(" - <b>$ElementId</b> ⇒ The element id (see .elements)");
                client.Character.Reply(" - <b>$ElementType</b> ⇒ The ElementType value. Ex: 70: door, 284: stair... see 'Interactives' table for more");
                client.Character.Reply(" - <b>$SkillId</b> ⇒ The SkillId. Enter=84, Use=114");

                return;
            }

            int    spawnCellId = client.Character.CellId;
            int    elementId   = int.Parse(args[1]);
            int    elementType = 70;
            ushort skillId     = 84;

            if (args.Length > 3)
            {
                elementType = int.Parse(args[2]);
                skillId     = ushort.Parse(args[3]);
            }

            var entry = LinkItem.InitEntry(client.Character.Map.Id, elementId, elementType, skillId, spawnCellId);

            client.Character.Reply("Temporary entry created:");
            client.Character.Reply(entry);
        }
Пример #7
0
        public void AddItemTestMultipleExecute()
        {
            int linkCompleted = 0;
            var linkItem      = new LinkItem();

            linkItem.Action = delegate(TimeEngine.ThreadContext threadContext)
            {
                linkCompleted++;
                threadContext.AddValue(linkItem.Link, 0);
            };
            int listCompleted = 0;
            var listItem      = new ListItem();

            listItem.Action = delegate(TimeEngine.ThreadContext threadContext)
            {
                listCompleted++;
                threadContext.AddValue(listItem, 0);
            };
            using (var timeEngine = new TimeEngine())
            {
                timeEngine.AddValue(linkItem.Link, 0);
                timeEngine.AddValue(listItem, 0);
                timeEngine.EvaluateFrame(100);
            }
            Assert.GreaterOrEqual(linkCompleted, 2);
            Assert.GreaterOrEqual(listCompleted, 2);
        }
Пример #8
0
        public static ContentReference GetContentReference(this LinkItem linkItem)
        {
            string extension;
            var    guid = PermanentLinkUtility.GetGuid(new UrlBuilder(linkItem.GetMappedHref()), out extension);

            return(PermanentLinkUtility.FindContentReference(guid));
        }
Пример #9
0
        public static List <string> NumberExtractor2(string file)
        {
            List <string> list = new List <string>();

            MatchCollection m1 = Regex.Matches(file, @"(<a.*?>.*?</a>)",
                                               RegexOptions.Singleline);

            foreach (Match m in m1)
            {
                string   value = m.Groups[1].Value;
                LinkItem i     = new LinkItem();

                Match m2 = Regex.Match(value, @"href=\""(.*?)\""",
                                       RegexOptions.Singleline);
                if (m2.Success)
                {
                    i.Href = m2.Groups[1].Value;
                }
                string t = Regex.Replace(value, @"\s*<.*?>\s*", "",
                                         RegexOptions.Singleline);
                i.Text = t;
                if (i.Text == "You can do it there")
                {
                    list.Add("http://www.samair.ru" + i.Href);
                }
            }
            return(list);
        }
Пример #10
0
            public static List <LinkItem> Find(string file)
            {
                List <LinkItem> list = new List <LinkItem>();

                MatchCollection m1 = Regex.Matches(file, @"(<a.*?>.*?</a>)",
                                                   RegexOptions.Singleline);


                foreach (Match m in m1)
                {
                    string   value = m.Groups[1].Value;
                    LinkItem i     = new LinkItem();

                    Match m2 = Regex.Match(value, @"href=\""(.*?)\""",
                                           RegexOptions.Singleline);
                    if (m2.Success)
                    {
                        i.Href = m2.Groups[1].Value;
                    }

                    string t = Regex.Replace(value, @"\s*<.*?>\s*", "",
                                             RegexOptions.Singleline);
                    i.Text = t;

                    list.Add(i);
                }
                return(list);
            }
Пример #11
0
        async private void DeleteLinkItem()
        {
            var flag = await ResourcesProvider.DisplayAlert(
                AppResources.DeleteDialogTitle,
                AppResources.DeleteDialogQuestion,
                AppResources.DeleteDialogYesAnswer,
                AppResources.DeleteDialogNoAnswer);

            if (!flag)
            {
                return;
            }

            var linkItem = new LinkItem()
            {
                Info          = this.Info,
                Link          = this.Link,
                Name          = this.Name,
                ID            = this.Id,
                Rank          = this.Rank,
                LastUpdatedOn = this.LastUpdatedOn
            };

            await Database.DeleteItemAsync(linkItem);

            await NavigationService.NavigateToAsync <StartPageViewModel>();
        }
Пример #12
0
        protected virtual void AddMyAccountMenu(CommerceHomePage homePage, CommerceHeaderViewModel viewModel)
        {
            if (HttpContext.Current != null && !HttpContext.Current.Request.IsAuthenticated)
            {
                viewModel.UserLinks = new LinkItemCollection();
                return;
            }

            var menuItems = new LinkItemCollection();
            var filter    = new FilterContentForVisitor();
            var contact   = _customerService.GetCurrentContact();

            if (contact != null && contact.FoundationOrganization != null)
            {
                var orgLink = new LinkItem
                {
                    Href  = _urlResolver.GetUrl(homePage.OrganizationMainPage),
                    Text  = _localizationService.GetString("My Organization", "My Organization"),
                    Title = _localizationService.GetString("My Organization", "My Organization")
                };
                //orgLink.Attributes.Add("css", "fa-sign-out");
                menuItems.Add(orgLink);
            }

            foreach (var linkItem in homePage.MyAccountCommerceMenu ?? new LinkItemCollection())
            {
                if (!UrlResolver.Current.TryToPermanent(linkItem.Href, out var linkUrl))
                {
                    continue;
                }

                if (linkUrl.IsNullOrEmpty())
                {
                    continue;
                }

                var urlBuilder = new UrlBuilder(linkUrl);
                var content    = _urlResolver.Route(urlBuilder);
                if (content == null || filter.ShouldFilter(content))
                {
                    continue;
                }

                linkItem.Title = linkItem.Text;
                menuItems.Add(linkItem);
            }

            var signoutText = _localizationService.GetString("/Header/Account/SignOut", "Sign Out");
            var link        = new LinkItem
            {
                Href  = "/publicapi/signout",
                Text  = signoutText,
                Title = signoutText
            };

            link.Attributes.Add("css", "fa-sign-out");
            menuItems.Add(link);

            viewModel.UserLinks.AddRange(menuItems);
        }
Пример #13
0
        public async Task AddBookmarkAsync(string key, Item item)
        {
            var linkItem = new LinkItem()
            {
                Name = item.Name, AltName = item.AltName, Link = item.Id
            };
            var items = await GetBookmarkCollectionAsync(key);

            if (items == null)
            {
                items = new List <Item>();
            }
            items.Add(linkItem);
            await SaveBookmarksAsync(key, items);

            if (Repository.BookmarkCollectionNames.IndexOf(key) >= 0)
            {
                Repository.BookmarkCollectionIndex = Repository.BookmarkCollectionNames.IndexOf(key);
            }
            else
            {
                Repository.BookmarkCollectionNames.Insert(Repository.BookmarkCollectionNames.Count - 1, key);
                Repository.BookmarkCollectionIndex = Repository.BookmarkCollectionNames.IndexOf(key);
            }
            await LoadBookmarkCollectionAsync(key);
        }
Пример #14
0
{     //this is the actual web scrapper
    public List <LinkItem> Find(string file)
    {
        List <LinkItem> linklist = new List <LinkItem>();

        // Find all matches in file.
        MatchCollection anchorFind = Regex.Matches(file, @"(<a.*?>.*?</a>)", RegexOptions.Singleline);

        // Loop over each match.
        foreach (Match theAnchr in anchorFind)
        {
            string   urivalue = theAnchr.Groups[1].Value;
            LinkItem webitem  = new LinkItem();

            // Get href attribute.
            Match hyperRef = Regex.Match(urivalue, @"href=\""(.*?)\""", RegexOptions.Singleline);
            if (hyperRef.Success)
            {
                webitem.Href = hyperRef.Groups[1].Value;
            }

            // Remove inner tags from text.
            string tag = Regex.Replace(urivalue, @"\s*<.*?>\s*", "", RegexOptions.Singleline);
            webitem.Text = tag;
            linklist.Add(webitem);
        }
        return(linklist);
    }
Пример #15
0
        /// <summary>
        ///     Returns IContent for provided LinkItem if it is EPiServer content otherwise returns null.
        /// </summary>
        /// <param name="source">Source LinkItem for which to return content.</param>
        /// <returns>Returns IContent for provided LinkItem if it is EPiServer content otherwise returns null.</returns>
        public static IContent ToContent(this LinkItem source)
        {
            var urlBuilder = new UrlBuilder(source.Href);
            var resolver   = ServiceLocator.Current.GetInstance <UrlResolver>();

            return(resolver.Route(urlBuilder));
        }
Пример #16
0
        private static Collection<LinkItem> cleanLinks2(MatchCollection m1)
        {
            Collection<LinkItem> list = new Collection<LinkItem>();

            // 2.
            // Loop over each match.
            foreach (Match m in m1)
            {
                string value = m.Groups[1].Value;
                LinkItem i = new LinkItem();
                int pos = value.IndexOf(' ');
                if (pos == -1)
                {
                    pos = value.IndexOf('\n');
                }
                if (pos == -1)
                {
                    pos = value.IndexOf('\t');
                }
                if (pos != -1)
                {
                    value = value.Substring(0, pos);
                }
                pos = value.IndexOf('<');
                if (pos != -1)
                {
                    value = value.Substring(0, pos);
                }
                i.Href = value;
                list.Add(i);

            }
            return list;
        }
Пример #17
0
        /// <summary>
        /// Remove the specified link from the list
        /// </summary>
        /// <param name="item">
        /// Item to remove
        /// </param>
        public void RemoveLink(LinkItem item)
        {
            // Check the arguments
            if (item == null)
            {
                return;
            }

            LinkItem next = item.Next;
            LinkItem prev = item.Previous;

            if (this.HeadLink == item)
            {
                this.HeadLink = next;
            }

            if (this.TailLink == item)
            {
                this.TailLink = prev;
            }

            if (prev != null)
            {
                prev.Next = next;
            }

            if (next != null)
            {
                next.Previous = prev;
            }

            // Decrement the count
            Interlocked.Decrement(ref this.m_count);
        }
Пример #18
0
    public static List<LinkItem> Find(string file, string tag)
    {
        List<LinkItem> list = new List<LinkItem>();

        // 1.
        // Find all matches in file.
        MatchCollection m1 = Regex.Matches(file, @"(<^^^.*?>.*?</^^^>)".Replace("^^^", tag),
            RegexOptions.Singleline);

        // 2.
        // Loop over each match.
        foreach (Match m in m1)
        {
            string value = m.Groups[1].Value;
            LinkItem i = new LinkItem();

            // 3.
            // Get href attribute.
            Match m2 = Regex.Match(value, @"^^^=\""(.*?)\""".Replace("^^^", tag),
            RegexOptions.Singleline);
            if (m2.Success)
            {
                i.Href = m2.Groups[1].Value;
            }

            // 4.
            // Remove inner tags from text.
            string t = Regex.Replace(value, @"\s*<.*?>\s*".Replace("^^^", tag), "",
            RegexOptions.Singleline);
            i.Text = t;

            list.Add(i);
        }
        return list;
    }
Пример #19
0
        private static Collection<LinkItem> cleanLinks(MatchCollection m1)
        {
            Collection<LinkItem> list = new Collection<LinkItem>();

            // 2.
            // Loop over each match.
            foreach (Match m in m1)
            {
                string value = m.Groups[1].Value;

                // 3.
                // Get href attribute.
                Match m2 = Regex.Match(value, @"href=\""(.*?)\""",
                RegexOptions.Singleline);
                if (m2.Success)
                {
                    LinkItem i = new LinkItem();
                    i.Href = m2.Groups[1].Value;

                    // 4.
                    // Remove inner tags from text and add.
                    string t = Regex.Replace(value, @"\s*<.*?>\s*", "",
                    RegexOptions.Singleline);
                    i.Text = t;

                    list.Add(i);
                }
            }
            return list;
        }
Пример #20
0
        public LinkViewModel All(ApiCall call)
        {
            LinkViewModel model = new LinkViewModel();

            var allpageroutes = call.WebSite.SiteDb().Routes.GetByType(ConstObjectType.Page);

            foreach (var item in allpageroutes)
            {
                if (item.objectId != default(Guid))
                {
                    LinkItem linkitem = new LinkItem();
                    linkitem.Url        = item.Name;
                    linkitem.Parameters = item.Parameters.Keys.ToList();
                    model.Pages.Add(linkitem);
                }
            }

            var allviews = call.WebSite.SiteDb().Views.All();

            foreach (var item in allviews)
            {
                LinkItem linkitem = new LinkItem();
                linkitem.Url = ObjectService.GetObjectRelativeUrl(call.WebSite.SiteDb(), item);
                //  linkitem.Parameters = Sites.Routing.PageRoute.GetViewParameters(call.SiteDb, item.Id);
                model.Views.Add(linkitem);
            }

            return(model);
        }
Пример #21
0
        private bool IsConnectWithInOneCorner(LinkItem startItem, LinkItem endItem, out LinkItem cornerOne)
        {
            var startRow    = startItem.Row;
            var startColumn = startItem.Column;

            var endRow    = endItem.Row;
            var endColumn = endItem.Column;

            // right top corner
            var cornerItem = this.Map[startRow][endColumn];

            if (cornerItem.IsDead)
            {
                if (this.IsDirectlyConnect(startItem, cornerItem) && IsDirectlyConnect(cornerItem, endItem))
                {
                    cornerOne = cornerItem;
                    return(true);
                }
            }

            // left bottom corner
            cornerItem = this.Map[endRow][startColumn];
            if (cornerItem.IsDead && this.IsDirectlyConnect(startItem, cornerItem) && this.IsDirectlyConnect(cornerItem, endItem))
            {
                cornerOne = cornerItem;
                return(true);
            }

            cornerOne = null;
            return(false);
        }
Пример #22
0
        private bool IsConnectWithinTwoCorner(LinkItem startItem, LinkItem endItem, out LinkItem cornerOne, out LinkItem cornerTwo)
        {
            var startRow    = startItem.Row;
            var startColumn = startItem.Column;

            var endRow    = endItem.Row;
            var endColumn = endItem.Column;

            LinkItem cornerOneItem, cornerTwoItem;

            // vertical line
            for (var column = 0; column < this.mode.ColumnCount; column++)
            {
                if (column == startColumn || column == endColumn)
                {
                    continue;
                }

                cornerOneItem = this.Map[startRow][column];
                cornerTwoItem = this.Map[endRow][column];

                if (cornerOneItem.IsDead && cornerTwoItem.IsDead)
                {
                    if (this.IsDirectlyConnect(startItem, cornerOneItem) && this.IsDirectlyConnect(cornerOneItem, cornerTwoItem) &&
                        this.IsDirectlyConnect(cornerTwoItem, endItem))
                    {
                        cornerOne = cornerOneItem;
                        cornerTwo = cornerTwoItem;
                        return(true);
                    }
                }
            }

            // horizontal line
            for (int row = 0; row < this.mode.RowCount; row++)
            {
                if (row == startRow || row == endRow)
                {
                    continue;
                }

                cornerOneItem = this.Map[row][startColumn];
                cornerTwoItem = this.Map[row][endColumn];

                if (cornerOneItem.IsDead && cornerTwoItem.IsDead)
                {
                    if (this.IsDirectlyConnect(startItem, cornerOneItem) && this.IsDirectlyConnect(cornerOneItem, cornerTwoItem) &&
                        this.IsDirectlyConnect(cornerTwoItem, endItem))
                    {
                        cornerOne = cornerOneItem;
                        cornerTwo = cornerTwoItem;
                        return(true);
                    }
                }
            }

            cornerOne = null;
            cornerTwo = null;
            return(false);
        }
Пример #23
0
        /// <summary>
        /// Check if two item can connect within two corners.
        /// </summary>
        /// <param name="startItem">The start LinkImage item.</param>
        /// <param name="endItem">The end LinkImage item.</param>
        /// <param name="cornerOne">Corner One.</param>
        /// <param name="cornerTwo">Corner Two.</param>
        private bool CanConnect(LinkItem startItem, LinkItem endItem, out LinkItem cornerOne, out LinkItem cornerTwo)
        {
            if (startItem == null)
            {
                throw new ArgumentNullException("startItem");
            }

            if (endItem == null)
            {
                throw new ArgumentNullException("endItem");
            }

            if (this.IsDirectlyConnect(startItem, endItem))
            {
                cornerOne = null;
                cornerTwo = null;
                return(true);
            }

            if (this.IsConnectWithInOneCorner(startItem, endItem, out cornerOne))
            {
                cornerTwo = null;
                return(true);
            }

            if (this.IsConnectWithinTwoCorner(startItem, endItem, out cornerOne, out cornerTwo))
            {
                return(true);
            }

            cornerOne = null;
            cornerTwo = null;
            return(false);
        }
 protected override void OnEnable()
 {
     base.OnEnable();
     targetItem = target as LinkItem;
     linkPorts  = targetItem.ChildNodes.ToArray();
     InitReorderLists();
 }
Пример #25
0
    public static List<LinkItem> Find(string file)
    {
        List<LinkItem> list = new List<LinkItem>();

        // Find all matches in file.
        MatchCollection m1 = Regex.Matches(file, @"(<a.*?>.*?</a>)",RegexOptions.Singleline);

        // Loop over each match.
        foreach (Match m in m1)
        {

            //Console.WriteLine("hello and hi");
            string value = m.Groups[1].Value;
            LinkItem i = new LinkItem();
            Console.WriteLine("\t"+value);

            // Get href attribute.
            Match m2 = Regex.Match(value, @"href=\""(.*?)\""",RegexOptions.Singleline);

            if (m2.Success)
            {
                i.Href = m2.Groups[1].Value;
                Console.WriteLine("\t\t"+ i);
            }

            // Remove inner tags from text.
            string t = Regex.Replace(value, @"\s*<.*?>\s*", "",RegexOptions.Singleline);
            i.Text = t;
            Console.WriteLine(t);
            list.Add(i);

        }
        return list;
        }
Пример #26
0
            /// <summary>
            /// The move next.
            /// </summary>
            /// <returns>
            /// The move next.
            /// </returns>
            public bool MoveNext()
            {
                bool result = false;

                if (this.m_current == null)
                {
                    // There are no items in the list
                    if (this.m_list.HeadLink == null)
                    {
                        return(false);
                    }

                    this.m_current = this.m_list.HeadLink;
                    result         = true;
                }
                else if (this.m_current.Next == null)
                {
                    this.m_current = null;
                    result         = false;
                }
                else
                {
                    this.m_current = this.m_current.Next;
                    result         = true;
                }

                return(result);
            }
        private List <LinkItem> getSubPages(string file)
        {
            List <LinkItem> list = new List <LinkItem>();

            MatchCollection matchs = Regex.Matches(file, @"(<a.*?>.*?</a>)",
                                                   RegexOptions.Singleline);

            foreach (Match match in matchs)
            {
                string   value = match.Groups[1].Value;
                LinkItem item  = new LinkItem();

                Match m2 = Regex.Match(value, @"href=\""(.*?)\""",
                                       RegexOptions.Singleline);
                if (m2.Success)
                {
                    item.Href = m2.Groups[1].Value;
                }

                string text = Regex.Replace(value, @"\s*<.*?>\s*", "",
                                            RegexOptions.Singleline);
                item.Text = text;

                list.Add(item);
            }
            return(list);
        }
Пример #28
0
        /// <summary>
        /// The insert.
        /// </summary>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        public void Insert(int index, object value)
        {
            int      i       = 0;
            LinkItem current = this.HeadLink;

            // Skip past existing items
            for (i = 0, current = this.HeadLink; current != null && i < index; i++, current = current.Next)
            {
                ;
            }

            if (i == index && current != null)
            {
                // Create the next link item
                var newItem = new LinkItem(current, current.Previous, value);

                current.Previous.Next = newItem;
                current.Previous      = newItem;

                if (this.HeadLink == current)
                {
                    this.HeadLink = newItem;
                }

                // Adjust the count
                Interlocked.Increment(ref this.m_count);
            }
            else if (current == null)
            {
                this.Add(value);
            }
        }
Пример #29
0
            public static List <LinkItem> Find(string file)
            {
                List <LinkItem> list = new List <LinkItem>();

                // 1.
                // Find all matches in file.
                MatchCollection m1 = Regex.Matches(file, @"(<a.*?>.*?</a>)",
                                                   RegexOptions.Singleline);

                // 2.
                // Loop over each match.
                foreach (Match m in m1)
                {
                    string   value = m.Groups[1].Value;
                    LinkItem i     = new LinkItem();

                    // 3.
                    // Get href attribute.
                    Match m2 = Regex.Match(value, @"href=\""(.*?)\""",
                                           RegexOptions.Singleline);
                    if (m2.Success)
                    {
                        i.Href = m2.Groups[1].Value;
                    }

                    // 4.
                    // Remove inner tags from text.
                    string t = Regex.Replace(value, @"\s*<.*?>\s*", "",
                                             RegexOptions.Singleline);
                    i.Text = t;

                    list.Add(i);
                }
                return(list);
            }
Пример #30
0
        public static string FindLink(string file)
        {
            string temp = "";

            MatchCollection m1 = Regex.Matches(file, @"(<a.*?>.*?</a>)",
                                               RegexOptions.Singleline);

            foreach (Match m in m1)
            {
                string   value = m.Groups[1].Value;
                LinkItem i     = new LinkItem();

                Match m2 = Regex.Match(value, @"href=\""(.*?)\""",
                                       RegexOptions.Singleline);
                if (m2.Success)
                {
                    i.Href = m2.Groups[1].Value;
                }

                string t = Regex.Replace(value, @"\s*<.*?>\s*", "",
                                         RegexOptions.Singleline);
                i.Text = t;

                string a = "plan.ics";
                if (i.Text.Contains(a))
                {
                    temp = i.Href;
                }
            }
            return(temp);
        }
Пример #31
0
        public static List<string> NumberExtractor2(string file)
        {
            List<string> list = new List<string>();

            MatchCollection m1 = Regex.Matches(file, @"(<a.*?>.*?</a>)",
                RegexOptions.Singleline);

            foreach (Match m in m1)
            {
                string value = m.Groups[1].Value;
                LinkItem i = new LinkItem();

                Match m2 = Regex.Match(value, @"href=\""(.*?)\""",
                RegexOptions.Singleline);
                if (m2.Success)
                {
                    i.Href = m2.Groups[1].Value;
                }
                string t = Regex.Replace(value, @"\s*<.*?>\s*", "",
                RegexOptions.Singleline);
                i.Text = t;
                if (i.Text == "You can do it there")
                {
                    list.Add("http://www.samair.ru" + i.Href);
                }
            }
            return list;
        }
Пример #32
0
        /// <summary>
        /// Extract the Anchors.
        /// </summary>
        /// <param name="file">
        /// The file.
        /// </param>
        /// <returns>
        /// All Anchors on the Page.
        /// </returns>
        public static List <LinkItem> ListAll(string file)
        {
            var anchorList = new List <LinkItem>();

            MatchCollection m1 = Regex.Matches(file, @"(<a.*?>.*?</a>)", RegexOptions.IgnoreCase);

            foreach (Match m in m1)
            {
                string   value = m.Groups[1].Value;
                LinkItem item  = new LinkItem();

                Match m2 = Regex.Match(value, @"href=\""(.*?)\""", RegexOptions.Singleline);

                if (m2.Success)
                {
                    item.Href = m2.Groups[1].Value;
                }

                Match m3 = Regex.Match(value, @"name=\""(.*?)\""", RegexOptions.Singleline);

                if (m3.Success)
                {
                    item.Anchor = m3.Groups[1].Value;
                }

                item.Text = Regex.Replace(value, @"\s*<.*?>\s*", string.Empty, RegexOptions.Singleline);

                anchorList.Add(item);
            }

            return(anchorList);
        }
Пример #33
0
        public static void WriteLinkItem(LinkItem linkItem, XmlDictionaryWriter xmlWriter)
        {
            /* What the contents of the link item look like...
             *
             *  <b:Id>xs:int</b:Id>
             *  <b:Title>xs:string</b:Title>
             *  <b:Description>xs:string</b:Description>
             *  <b:DateStart>xs:dateTime</b:DateStart>
             *  <b:DateEnd>xs:dateTime</b:DateEnd>
             *  <b:Url>xs:string</b:Url>
             */
            xmlWriter.WriteStartElement("Id", ns);
            xmlWriter.WriteValue(linkItem.Id);
            xmlWriter.WriteEndElement();

            xmlWriter.WriteElementString("Title", ns, linkItem.Title);
            xmlWriter.WriteElementString("Description", ns, linkItem.Description);

            xmlWriter.WriteStartElement("DateStart", ns);
            xmlWriter.WriteValue(linkItem.DateStart);
            xmlWriter.WriteEndElement();

            xmlWriter.WriteStartElement("DateEnd", ns);
            xmlWriter.WriteValue(linkItem.DateEnd);
            xmlWriter.WriteEndElement();

            xmlWriter.WriteElementString("Url", ns, linkItem.Url);
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,Title,Href,Description,Sort,OffLine")] LinkItem linkItem)
        {
            if (id != linkItem.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(linkItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LinkItemExists(linkItem.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(linkItem));
        }
Пример #35
0
        private void cmdGet_Click(object sender, EventArgs e)
        {
            System.ServiceModel.Channels.Message requestMessage = System.ServiceModel.Channels.Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "http://www.thatindigogirl.com/samples/2006/06/GigManagerServiceContract/GetGig");

            requestMessage.Headers.Action = "http://www.thatindigogirl.com/samples/2006/06/GigManagerServiceContract/GetGig";

            LicenseKeyHeader licenseKeyHeader = new LicenseKeyHeader("XXX");

            requestMessage.Headers.Add(licenseKeyHeader);

            GetGigResponse responseMessage = new GetGigResponse(m_proxy.GetGig(requestMessage));

            LinkItem item = responseMessage.Item;

            if (item != null)
            {
                this.txtId.Text          = item.Id.ToString();
                this.txtTitle.Text       = item.Title;
                this.txtDescription.Text = item.Description;

                if (item.DateStart != DateTime.MinValue)
                {
                    this.dtpStart.Value = item.DateStart;
                }
                if (item.DateEnd != DateTime.MinValue)
                {
                    this.dtpEnd.Value = item.DateEnd;
                }

                this.txtUrl.Text = item.Url;
            }
        }
        public string ResolveUrl(LinkItem linkItem)
        {
            var result = linkItem.Href;
            var url = new UrlBuilder(linkItem.ToMappedLink());

            int id;
            if (int.TryParse(url.QueryCollection["id"], out id))
                result = ResolveUrl(new ContentReference(id));

            return result;
        }
Пример #37
0
 private static void SetHref(LinkItem s, ApiReferenceModel index, string currentName, ResolverContext context)
 {
     if (s == null) return;
     if (!s.IsExternalPath)
     {
         s.Href = ResolveInternalLink(index, s.Name, currentName);
     }
     else
     {
         s.Href = ResolveExternalLink(s.Name, context);
     }
 }
Пример #38
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            LinkItem item = new LinkItem();

            item.Id = int.Parse(this.txtId.Text);
            item.Title = this.txtTitle.Text;
            item.Description = this.txtDescription.Text;
            item.DateStart = this.dtpStart.Value;
            item.DateEnd = this.dtpEnd.Value;
            item.Url = this.txtUrl.Text;

            m_proxy.SaveGig(item);
        }
Пример #39
0
        public void Test1()
        {
            LinkItem item = new LinkItem();

            if (testRanker.rankUrl(newresource, item) == 0)
            {
                Console.WriteLine("rankUrl(int parentRank, String parentContent, String url) PASSED");
            }
            else
            {
                Console.WriteLine("rankUrl(int parentRank, String parentContent, String url) FAILED");
                Console.WriteLine("Should have returned 0");
            }
        }
Пример #40
0
 public static SpecViewModel FromModel(LinkItem model)
 {
     if (model == null)
     {
         return null;
     }
     var result = new SpecViewModel
     {
         Uid = model.Name,
         Name = model.DisplayName,
         FullName = model.DisplayQualifiedNames,
         IsExternal = model.IsExternalPath,
         Href = model.Href,
     };
     return result;
 }
Пример #41
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            try
            {
                LinkItem item = new LinkItem();
                item.ID = int.Parse(this.txtId.Text);
                item.Title = this.txtTitle.Text;
                item.Description = this.txtDescription.Text;
                item.DateStart = this.dtpStart.Value;
                item.DateEnd = this.dtpEnd.Value;
                item.Url = this.txtUrl.Text;

                proxy.SaveGig(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #42
0
        private IEnumerable<LinkItem> GetContent(string pageString)
        {
            var list = new List<LinkItem>();
            var matchCollection = Regex.Matches(pageString, @"(<a.*?>.*?</a>)", RegexOptions.Singleline);

            foreach (Match match in matchCollection)
            {
                var val = match.Groups[1].Value;
                var i = new LinkItem();

                var m2 = Regex.Match(val, @"href=\""(.*?)\""", RegexOptions.Singleline);
                if (m2.Success)
                {
                    i.Href = m2.Groups[1].Value;
                }

                string t = Regex.Replace(val, @"\s*<.*?>\s*", "",
                RegexOptions.Singleline);
                i.Text = t;

                list.Add(i);
            }
            return list;
        }
Пример #43
0
    /// <summary>
    /// Remove the specified link from the list
    /// </summary>
    /// <param name="item">
    /// Item to remove 
    /// </param>
    public void RemoveLink(LinkItem item)
    {
      // Check the arguments
      if (item == null)
      {
        return;
      }

      LinkItem next = item.Next;
      LinkItem prev = item.Previous;

      if (this.HeadLink == item)
      {
        this.HeadLink = next;
      }

      if (this.TailLink == item)
      {
        this.TailLink = prev;
      }

      if (prev != null)
      {
        prev.Next = next;
      }

      if (next != null)
      {
        next.Previous = prev;
      }

      // Decrement the count
      Interlocked.Decrement(ref this.m_count);
    }
Пример #44
0
    /// <summary>
    /// Prepend the specified value to the head of the list
    /// </summary>
    /// <param name="value">
    /// Value to prepend to the list (not a LinkItem)
    /// </param>
    /// <returns>
    /// The LinkItem which points to this new value
    /// </returns>
    public LinkItem Prepend(object value)
    {
      var newItem = new LinkItem(this.HeadLink, null, value);

      if (this.HeadLink != null)
      {
        this.HeadLink.Previous = newItem;
      }

      if (this.TailLink == null)
      {
        this.TailLink = newItem;
      }

      this.HeadLink = newItem;

      // Increment the count
      Interlocked.Increment(ref this.m_count);

      return newItem;
    }
Пример #45
0
    /// <summary>
    /// Move the specified LinkItem to the head of the list
    /// </summary>
    /// <param name="item">
    /// The existing LinkItem in the list
    /// </param>
    public void MoveToHead(LinkItem item)
    {
      if (item == null)
      {
        return;
      }

      if (item != this.HeadLink)
      {
        LinkItem prev = item.Previous;
        LinkItem next = item.Next;

        if (prev != null)
        {
          prev.Next = next;
        }

        if (next != null)
        {
          next.Previous = prev;
        }

        if (this.TailLink == item)
        {
          this.TailLink = prev;
        }

        if (this.HeadLink != null)
        {
          this.HeadLink.Previous = item;
        }

        item.Next = this.HeadLink;
        item.Previous = null;
        this.HeadLink = item;
      }
    }
Пример #46
0
        private IEnumerable<LinkItem> GetLinkItems(IEnumerable<string> trustSignatures)
        {
            var linkItems = new List<LinkItem>();

            foreach (var trustSignature in trustSignatures)
            {
                LinkItem linkItem = null;

                {
                    var link = _amoebaManager.GetLink(trustSignature);

                    if (link != null) Settings.Instance.Cache_Links[trustSignature] = link;
                    else Settings.Instance.Cache_Links.TryGetValue(trustSignature, out link);

                    if (link != null)
                    {
                        linkItem = new LinkItem();
                        linkItem.Signature = trustSignature;
                        linkItem.TrustSignatures.AddRange(link.TrustSignatures);
                        linkItem.DeleteSignatures.AddRange(link.DeleteSignatures);
                    }
                }

                if (linkItem == null)
                {
                    linkItem = new LinkItem();
                    linkItem.Signature = trustSignature;
                }

                linkItems.Add(linkItem);
            }

            return linkItems;
        }
Пример #47
0
    /// <summary>
    /// The add.
    /// </summary>
    /// <param name="value">
    /// The value.
    /// </param>
    /// <returns>
    /// The add.
    /// </returns>
    public int Add(object value)
    {
      // Append this item to the tail
      this.TailLink = new LinkItem(null, this.TailLink, value);

      if (this.TailLink.Previous != null)
      {
        this.TailLink.Previous.Next = this.TailLink;
      }

      if (this.HeadLink == null)
      {
        this.HeadLink = this.TailLink;
      }

      // Adjust the count
      Interlocked.Increment(ref this.m_count);

      return this.m_count - 1;
    }
Пример #48
0
 /// <summary>
 /// Adds an item with the specified template. 
 /// </summary>
 /// <param name="template"></param>
 /// <param name="item"></param>
 /// <param name="itemNumber"></param>
 protected void AddItemTemplate(ITemplate template, LinkItem item, int itemNumber)
 {
     if (_addSeparator)
         AddSeparatorTemplate();
     AddTemplate(new LinkItemItemTemplateContainer(item, itemNumber), template);
     _added = true;
 }
Пример #49
0
    /// <summary>
    /// The insert.
    /// </summary>
    /// <param name="index">
    /// The index.
    /// </param>
    /// <param name="value">
    /// The value.
    /// </param>
    public void Insert(int index, object value)
    {
      int i = 0;
      LinkItem current = this.HeadLink;

      // Skip past existing items
      for (i = 0, current = this.HeadLink; current != null && i < index; i++, current = current.Next)
      {
        ;
      }

      if (i == index && current != null)
      {
        // Create the next link item
        var newItem = new LinkItem(current, current.Previous, value);

        current.Previous.Next = newItem;
        current.Previous = newItem;

        if (this.HeadLink == current)
        {
          this.HeadLink = newItem;
        }

        // Adjust the count
        Interlocked.Increment(ref this.m_count);
      }
      else if (current == null)
      {
        this.Add(value);
      }
    }
Пример #50
0
    /// <summary>
    /// The remove at.
    /// </summary>
    /// <param name="index">
    /// The index.
    /// </param>
    public void RemoveAt(int index)
    {
      int i = 0;
      LinkItem current = this.HeadLink;

      // Skip past existing items
      for (i = 0, current = this.HeadLink; current != null && i < index; i++, current = current.Next)
      {
        ;
      }

      if (i == index && current != null)
      {
        LinkItem prev = current.Previous;
        LinkItem next = current.Next;

        if (current == this.HeadLink)
        {
          this.HeadLink = next;
        }
        else if (prev != null)
        {
          prev.Next = next;
        }

        if (this.TailLink == current)
        {
          this.TailLink = prev;
        }
        else if (next != null)
        {
          next.Previous = prev;
        }

        // Decrement the count
        Interlocked.Decrement(ref this.m_count);
      }
    }
Пример #51
0
 /// <summary>
 /// The reset.
 /// </summary>
 public void Reset()
 {
   this.m_current = null;
 }
Пример #52
0
		private bool Equals (LinkItem other) { return string.Equals (HRef, other.HRef); }
Пример #53
0
 /// <summary>
 /// The clear.
 /// </summary>
 public void Clear()
 {
   this.HeadLink = null;
   this.TailLink = null;
 }
Пример #54
0
        /**
         * This method returns a rank for the anchor url
         */
        private int getRankOfAnchor(LinkItem item)
        {
            //These variables will contain the max and avg of the match levels of the Anchor Url
            int maxMatchLevelForAnchor = 0;
            int avgMatchLevelForAnchor = 0;

            if (item.getAnchor() == null)
                return 0;

            StreamWriter sw = null;
            if (LogDebuggerControl.getInstance().debugRanker)
            {
                sw = new
                StreamWriter("DataForRank" + System.Threading.Thread.CurrentThread.ManagedThreadId + ".txt", true);
                sw.WriteLine(" ***** REQUEST FOR ANCHOR URL RANK************************************ ");
                sw.WriteLine(" URL : " + item.getLink());
                sw.WriteLine(" CONTENT OF ANCHOR:");
                sw.WriteLine(item.getAnchor());
                sw.Close();
            }

            //calculate the min and max of the match levels of the anchor url to the categories.
            if (anchorOptions == null)
            {
                anchorOptions = getOptions("anchor");
            }

            List<int> matchLevelsForAnchor = categorizer.classifyContentToAllCategories(item.getAnchor(), anchorOptions);
            maxMatchLevelForAnchor = calculateMax(matchLevelsForAnchor);
            avgMatchLevelForAnchor = calculateAvg(matchLevelsForAnchor);

            if (LogDebuggerControl.getInstance().debugRanker)
            {
                sw = new StreamWriter("DataForRank" + System.Threading.Thread.CurrentThread.ManagedThreadId + ".txt", true);
                sw.WriteLine(" .MAX MATCH LEVEL OF ANCHOR: ");
                sw.WriteLine(maxMatchLevelForAnchor);
                sw.WriteLine(" .AVG MATCH LEVEL OF ANCHOR: ");
                sw.WriteLine(avgMatchLevelForAnchor);
                //sw.WriteLine(" .RANK OF ANCHOR: ");
                //sw.WriteLine((int)(RankParams.MinAndMaxRATIO * maxMatchLevelForAnchor + (1 - RankParams.MinAndMaxRATIO) * avgMatchLevelForAnchor));
                //sw.WriteLine(" * END ****************************************************************** ");
                sw.Close();
            }

            return ((int)(RankerOptions.MinAndMaxRATIO * maxMatchLevelForAnchor + (1 - RankerOptions.MinAndMaxRATIO) * avgMatchLevelForAnchor));
        }
Пример #55
0
    /// <summary>
    /// The remove.
    /// </summary>
    /// <param name="value">
    /// The value.
    /// </param>
    public void Remove(object value)
    {
      LinkItem current;

      // Skip past existing items
      for (current = this.HeadLink; current != null && current.Item != value; current = current.Next)
      {
        ;
      }

      if (current != null)
      {
        LinkItem prev = current.Previous;
        LinkItem next = current.Next;

        if (current == this.HeadLink)
        {
          this.HeadLink = next;
        }
        else if (prev != null)
        {
          prev.Next = next;
        }

        if (current == this.TailLink)
        {
          this.TailLink = prev;
        }
        else if (next != null)
        {
          next.Previous = prev;
        }

        // Adjust the count
        Interlocked.Decrement(ref this.m_count);
      }
    }
Пример #56
0
        /**
         * This method returns a rank for the nearby textof the url
         */
        private int getRankOfNearbyText(LinkItem item)
        {
            //These variables will contain the max and avg of the match levels of the nearby
            //text of the extracted url.
            int maxMatchLevelForNearby = 0;
            int avgMatchLevelForNearby = 0;

            StreamWriter sw = null;
            if (LogDebuggerControl.getInstance().debugRanker)
            {
                sw = new
                StreamWriter("DataForRank" + System.Threading.Thread.CurrentThread.ManagedThreadId + ".txt", true);
                sw.WriteLine(" ***** REQUEST FOR NEARBY TEXT RANK************************************ ");
                sw.WriteLine(" URL : " + item.getLink());
                sw.WriteLine(" CONTENT OF NEARBY TEXT:");
                sw.WriteLine(item.getText());
                sw.Close();
            }

            //calculate the min and max of the match levels of the nearby text to the categories.
            if (nearbyOptions == null)
            {
                nearbyOptions = getOptions("nearby");
            }

            List<int> matchLevelsForNearby = categorizer.classifyContentToAllCategories(item.getText(), nearbyOptions);
            maxMatchLevelForNearby = calculateMax(matchLevelsForNearby);
            avgMatchLevelForNearby = calculateAvg(matchLevelsForNearby);

            if (LogDebuggerControl.getInstance().debugRanker)
            {
                sw = new StreamWriter("DataForRank" + System.Threading.Thread.CurrentThread.ManagedThreadId + ".txt", true);
                sw.WriteLine(" .MAX MATCH LEVEL OF NEARBY TEXT: ");
                sw.WriteLine(maxMatchLevelForNearby);
                sw.WriteLine(" .AVG MATCH LEVEL OF NEARBY TEXT: ");
                sw.WriteLine(avgMatchLevelForNearby);
                //sw.WriteLine(" .RANK OF NEARBY TEXT: ");
                //sw.WriteLine((int)(RankParams.MinAndMaxRATIO * maxMatchLevelForNearby + (1 - RankParams.MinAndMaxRATIO) * avgMatchLevelForNearby));
                // sw.WriteLine(" * END ****************************************************************** ");
                sw.Close();
            }

            return ((int)(RankerOptions.MinAndMaxRATIO * maxMatchLevelForNearby + (1 - RankerOptions.MinAndMaxRATIO) * avgMatchLevelForNearby));
        }
Пример #57
0
      /// <summary>
      /// The move next.
      /// </summary>
      /// <returns>
      /// The move next.
      /// </returns>
      public bool MoveNext()
      {
        bool result = false;

        if (this.m_current == null)
        {
          // There are no items in the list
          if (this.m_list.HeadLink == null)
          {
            return false;
          }

          this.m_current = this.m_list.HeadLink;
          result = true;
        }
        else if (this.m_current.Next == null)
        {
          this.m_current = null;
          result = false;
        }
        else
        {
          this.m_current = this.m_current.Next;
          result = true;
        }

        return result;
      }
Пример #58
0
        /**
         * This method calculates the rank of a given url and returns it.
         */
        public int rankUrl(ResourceContent parentResource,LinkItem item)
        {
            //These variables will contain the ranks for the whole content match and nearby text match and
            //anchor match and the parentrank.
            int rankParentUrl = parentResource.getRankOfUrl();
            int anchorRank = 0;
            //int wholePageRank = 0;
            int nearbyTextRank = 0;

            int neighborhood = 0;
            int context = 0;
            int inherited = 0;

            char[] separators = {' ', '\t', '\n'};
            NumOfLinks++;
            sumOfTotalNearbyWords += item.getText().Split(separators).Length;
            sumOfTotalAnchorWords += item.getAnchor().Split(separators, StringSplitOptions.RemoveEmptyEntries).Length;

            StreamWriter sw = null;
            if (LogDebuggerControl.getInstance().debugRanker)
            {
                sw = new
                StreamWriter("DataForRank" + System.Threading.Thread.CurrentThread.ManagedThreadId + ".txt", true);
                sw.WriteLine(" *********HEAD REQUEST *********************************************");
                sw.WriteLine(" ***** DATA FOR RANKER******************************************** ");
                sw.WriteLine(" URL : " + item.getLink());
                sw.WriteLine(" PARENT URL : " + item.getParentUrl());
                sw.Close();
            }

            //rank of the whole page
            if (!((lastResourceContent!=null)&&(lastResourceContent.Equals(parentResource.getResourceContent()))))
            {
                lastResourceContent=parentResource.getResourceContent();
                wholePageRank = getRankOfWholeContent(parentResource);
            }

            //rank of the nearby text
            nearbyTextRank =getRankOfNearbyText(item);

            DateTime endTimeOfNearby = DateTime.Now;

            //rank of the anchor url
            anchorRank = getRankOfAnchor(item);

            //rank of the neighborhood,that includes rank of the anchor and the nearby text
            if (anchorRank > RankerOptions.ConfidenceLevelOfAnchor)
                context = 100;
            else
            {
                //nearbyTextRank = getRankOfNearbyText(item);
                context = nearbyTextRank;
            }
            neighborhood = (int)(RankerOptions.BETTA * anchorRank + (1 - RankerOptions.BETTA) * context);

            //rank of the inherited,that includes the rank of the parentUrl and paren content
            inherited = (int)(RankerOptions.ALPHA * rankParentUrl + (1 - RankerOptions.ALPHA) * wholePageRank);

            if (LogDebuggerControl.getInstance().debugRanker)
            {
                sw = new StreamWriter("DataForRank" + System.Threading.Thread.CurrentThread.ManagedThreadId + ".txt", true);
                sw.WriteLine("************************DATA CONCLUSION*************************");
                sw.WriteLine(" .PARENT RANK: ");
                sw.WriteLine(rankParentUrl);
                sw.WriteLine(" .RANK OF NEARBY TEXT: ");
                sw.WriteLine(nearbyTextRank);
                sw.WriteLine(" .AVG OF NEARBY WORDS");
                sw.WriteLine((int)(sumOfTotalNearbyWords / NumOfLinks));
                sw.WriteLine(" .RANK OF ANCHOR: ");
                sw.WriteLine(anchorRank);
                sw.WriteLine(" .AVG OF ANCHOR TEXT");
                sw.WriteLine((int)(sumOfTotalAnchorWords / NumOfLinks));
                sw.WriteLine(" .NEIGHBORHOOD: ");
                sw.WriteLine(neighborhood);
                sw.WriteLine(" .RANK OF WHOLE CONTENT: ");
                sw.WriteLine(wholePageRank);
                sw.WriteLine(" .INHERITED: ");
                sw.WriteLine(inherited);
                sw.WriteLine(" .RANK OF THE URL: ");
                sw.WriteLine((int)(RankerOptions.GAMMA * inherited + (1 - RankerOptions.GAMMA) * neighborhood));
                // sw.WriteLine(" * END ****************************************************************** ");
                sw.Close();
            }

            //Console.WriteLine(totalRankingTime.TotalSeconds);
            return ((int)(RankerOptions.GAMMA * inherited + (1 - RankerOptions.GAMMA) * neighborhood));
        }
Пример #59
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinkItem"/> class. 
 /// Build a new LinkItem pointing to the next, previous and current value
 /// </summary>
 /// <param name="next">
 /// The next LinkItem in the list
 /// </param>
 /// <param name="previous">
 /// The previous LinkItem in the list
 /// </param>
 /// <param name="item">
 /// The current value that this item points to
 /// </param>
 public LinkItem(LinkItem next, LinkItem previous, object item)
 {
   this.Next = next;
   this.Previous = previous;
   this.Item = item;
 }
        private void _okButton_Click(object sender, RoutedEventArgs e)
        {
            {
                List<LinkItem> downloadCollection = new List<LinkItem>();
                List<LinkItem> uploadCollection = new List<LinkItem>();

                foreach (var item in _downloadCollection)
                {
                    var LinkItem = new LinkItem();
                    LinkItem.Signature = item.Signature;
                    LinkItem.TrustSignatures.AddRange(item.TrustSignatures);
                    LinkItem.TrustSignatures.Sort();

                    downloadCollection.Add(LinkItem);
                }

                foreach (var item in _uploadCollection)
                {
                    var LinkItem = new LinkItem();
                    LinkItem.Signature = item.Signature;
                    LinkItem.TrustSignatures.AddRange(item.TrustSignatures);
                    LinkItem.TrustSignatures.Sort();

                    uploadCollection.Add(LinkItem);
                }

                foreach (var item in Settings.Instance.LinkOptionsWindow_DownloadLinkItems.ToArray())
                {
                    if (!downloadCollection.Contains(item))
                    {
                        Settings.Instance.LinkOptionsWindow_DownloadLinkItems.Remove(item);
                    }
                }

                foreach (var item in downloadCollection)
                {
                    if (!Settings.Instance.LinkOptionsWindow_DownloadLinkItems.Contains(item))
                    {
                        Settings.Instance.LinkOptionsWindow_DownloadLinkItems.Add(item);
                    }
                }

                foreach (var item in Settings.Instance.LinkOptionsWindow_UploadLinkItems.ToArray())
                {
                    if (!uploadCollection.Contains(item))
                    {
                        Settings.Instance.LinkOptionsWindow_UploadLinkItems.Remove(item);
                    }
                }

                foreach (var item in uploadCollection)
                {
                    if (!Settings.Instance.LinkOptionsWindow_UploadLinkItems.Contains(item))
                    {
                        Settings.Instance.LinkOptionsWindow_UploadLinkItems.Add(item);

                        {
                            var digitalSignature = Settings.Instance.Global_DigitalSignatureCollection.FirstOrDefault(n => n.ToString() == item.Signature);
                            if (digitalSignature == null) return;

                            var link = new Link();
                            link.TrustSignatures.AddRange(item.TrustSignatures);

                            _amoebaManager.Upload(link, digitalSignature);
                        }
                    }
                }
            }

            this.DialogResult = true;
        }