Exemple #1
0
        public List <SCNextLink> ChangeToTopicLinkList()
        {
            List <SCNextLink> scNextLinks = new List <SCNextLink>();

            if (TopicLink != "")
            {
                try
                {
                    string[] topiclinks = TopicLink.Split(',');
                    foreach (string var in topiclinks)
                    {
                        string[]   topiclink  = var.Split('/');
                        SCNextLink scNextLink = new SCNextLink();
                        scNextLink.Topic  = topiclink[0].Substring(1);
                        scNextLink.LinkID = topiclink[1].Substring(0, topiclink[1].Length - 1);
                        scNextLinks.Add(scNextLink);
                    }
                }
                catch (Exception ex)
                {
                    //ex.Message;
                }
            }
            return(scNextLinks);
        }
Exemple #2
0
        public async Task <IActionResult> Edit(int id, [Bind("TopicLinkId,TopicItemId,TopicLinkRemark,LinkCreateDate")] TopicLink topicLink)
        {
            if (id != topicLink.TopicLinkId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(topicLink);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TopicLinkExists(topicLink.TopicLinkId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TopicItemId"] = new SelectList(_context.TopicItem, "TopicItemId", "TopicItemId", topicLink.TopicItemId);
            return(View(topicLink));
        }
Exemple #3
0
        ///********************Edit Link
        // GET: TopicLinks/Edit/5
        public IActionResult EditLink(int?id)
        {
            TopicLink myLink = _context.TopicLink.Find(id);

            //so now retrieve the topicitemid

            return(View(myLink));
        }
Exemple #4
0
 public IActionResult CreateLink([Bind("TopicItemId,TopicLinkRemark,LinkCreateDate")] TopicLink topicLink)
 {
     if (ModelState.IsValid)
     {
         _context.Add(topicLink);
         _context.SaveChanges();
         return(RedirectToAction(nameof(MyWorkSpace)));
     }
     return(View(topicLink));
 }
Exemple #5
0
        public async Task <IActionResult> Create([Bind("TopicLinkId,TopicItemId,TopicLinkRemark,LinkCreateDate")] TopicLink topicLink)
        {
            if (ModelState.IsValid)
            {
                _context.Add(topicLink);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TopicItemId"] = new SelectList(_context.TopicItem, "TopicItemId", "TopicItemId", topicLink.TopicItemId);
            return(View(topicLink));
        }
Exemple #6
0
 public IActionResult updateTopicLink([FromBody] TopicLink topicLink)
 {
     if (topicLink != null)
     {
         db.TopicLinks.Update(topicLink);
         db.SaveChanges();
         return(Json(Ok("TopicLink updated")));
     }
     else
     {
         return(NotFound("UPDATE: TopicLink was not found"));
     }
 }
Exemple #7
0
        public IActionResult getTopicLink(int id)
        {
            TopicLink topicLink = db.TopicLinks.Find(id);

            if (topicLink != null)
            {
                return(Json(topicLink));
            }
            else
            {
                return(NotFound("GET: TopicLink with ID = " + id + " was not found."));
            }
        }
Exemple #8
0
 public IActionResult deleteTopicLink(int id)
 {
     try
     {
         TopicLink topicLink = db.TopicLinks.Find(id);
         db.TopicLinks.Remove(topicLink);
         db.SaveChanges();
         return(Json(Ok("TopicLink deleted")));
     }
     catch (ArgumentNullException)
     {
         return(NotFound("DELETE: TopicLink with ID = " + id + " was not found."));
     }
 }
Exemple #9
0
        private void DoSync()
        {
            String topicID = TopicLink.GetMshcTopicID(webBrowser1);

            if (!String.IsNullOrEmpty(topicID))
            {
                inSyncMethod = true;
                try
                {
                    tocPanel.Sync(topicID);
                }
                finally
                {
                    inSyncMethod = false;
                }
            }
        }
Exemple #10
0
        // MSDN Online Link

        private void OnlineLinkBtn_Click(object sender, EventArgs e)
        {
            String topicId = TopicLink.GetMshcTopicID(webBrowser1);

            if (!String.IsNullOrEmpty(topicId))
            {
                Topic  topic = (Topic)_catalogRead.GetIndexedTopicDetails(_catalog, topicId, null);
                String url   = TopicLink.MakeMsdnLibraryUrl(topicId, "", topic.TopicVersion);
                if (!String.IsNullOrEmpty(url) && topic.Vendor.Equals("Microsoft", StringComparison.InvariantCultureIgnoreCase))
                {
                    webBrowser1.Navigate(url);
                    richTextBoxCodeView.Text = "";
                    return;
                }
            }
            //defaul to MSDN Library home page
            webBrowser1.Navigate(TopicLink.GetMSDNLibraryHome(_CatalogLocale));
            richTextBoxCodeView.Text = "";
        }
Exemple #11
0
        public List <TopicLink> GetTopicLinks(string url)
        {
            url = url.Replace("https://www.ninisite.com/discussion/forum/", "");
            int    iSlash  = url.IndexOf("/");
            string fid     = url.Substring(0, iSlash);
            int    forumId = int.Parse(fid);

            url = $"https://www.ninisite.com/discussion/forum/{fid}/a";
            List <TopicLink> links = new List <TopicLink>();
            var web = new HtmlWeb();
            var doc = web.Load(url);

            // بدست آوردن عنصر انتهایی در صفحه بندی لیست تاپیک ها
            // برای شروع مقدار یک را قرار میدهیم که در صورت وجود نداشتن
            // صفحه بندی حداقل مقدار یک به صورت پییشفرض در نظر گرفته شود
            int max = 1;

            if (doc.DocumentNode.SelectNodes("//ul[@class='pagination']//li[@class='page-item']//a[@class='page-link']").Any())
            {
                var pagging = doc.DocumentNode.SelectNodes("//ul[@class='pagination']//li[@class='page-item']//a[@class='page-link']").ToList().Select(x => x.InnerText).ToArray();
                foreach (var item in pagging.Where(x => !string.IsNullOrEmpty(x)))
                {
                    if (int.TryParse(item, out int ss))
                    {
                        max = ss > max ? ss : max;
                    }
                }
            }

            // حلقه ای که در آن از ابتدا به تا عنصر نهایی بدست آمده سر میزنیم
            // و تمامی لینک های تاپیک ها را ذخیره میکنیم
            for (int i = 1; i < max + 1; i++)
            {
                string page   = url + "?page=" + i;
                var    web1   = new HtmlWeb();
                var    doc1   = web1.Load(page);
                var    topics = doc1.GetElementbyId("cat").SelectNodes(
                    "//div[@class='col-xs-12 category--header p-x-0']" +
                    "//div[@class='col-xs-12  pull-xs-right category--item']" +
                    "//div[@class='col-xs-12 col-md-6 pull-xs-right p-x-0']").Select(x => x.InnerHtml).ToList();

                foreach (var item in topics)
                {
                    try
                    {
                        var docTopic = new HtmlDocument();
                        docTopic.LoadHtml(item);
                        var       lnk       = docTopic.DocumentNode.SelectSingleNode("//a").Attributes["href"].Value;
                        var       name      = docTopic.DocumentNode.SelectSingleNode("//a//h2").InnerText.Trim();
                        TopicLink topicLink = new TopicLink();
                        lnk = lnk.Replace("/discussion/topic/", "");
                        int s = lnk.IndexOf("/");
                        if (s == -1 && int.TryParse(lnk, out int lnkId))
                        {
                            topicLink.TopicId = lnkId;
                        }
                        else
                        {
                            string topicId = lnk.Substring(0, s);
                            topicLink.TopicId = int.Parse(topicId);
                        }

                        topicLink.URL       = "https://www.ninisite.com/discussion/topic/" + topicLink.TopicId + "/a";
                        topicLink.TopicName = name;
                        topicLink.ForumId   = forumId;
                        links.Add(topicLink);
                    }
                    catch (Exception)
                    {
                        Console.Write("\n •  Error: " + i + "  •\n");
                    }
                }
                if (i % 20 == 0)
                {
                    Console.Write("." + i);
                }
                else
                {
                    Console.Write(".");
                }
                if (i == max)
                {
                    Console.Write("." + i + "\t end. \n");
                }
            }

            return(links);
        }
Exemple #12
0
        // GET: TopicLinks/CreateLink
        public IActionResult CreateLink()
        {
            TopicLink myLink = new TopicLink();

            return(View(myLink));
        }