コード例 #1
0
        private void MainThread()
        {
            MiqoGridFinderOptions options = new MiqoGridFinderOptions();

            options.Load(VPL.Application.Data.OptionLocation.GlobalOption);
            ListGatheringNodes = options.ListGatheringNodes;
            if (ListGatheringNodes.Count <= 0)
            {
                VPThreading.SetText(_progressLabel, "Downloading all gathering nodes...");
                ListGatheringNodes = MiqoCraftCore.ConsoleGamesWiki.GetFFXIVGatheringNodes();
            }

            ListAetherytes = options.ListAetherytes;
            if (ListAetherytes.Count <= 0)
            {
                VPThreading.SetText(_progressLabel, "Downloading all aetherytes...");
                ListAetherytes = MiqoCraftCore.ConsoleGamesWiki.GetAetherytes();
            }

            options.ListGatheringNodes = ListGatheringNodes;
            options.ListAetherytes     = ListAetherytes;
            options.Save();

            AnalyzeGridThread();
        }
コード例 #2
0
        /// <summary>
        /// Search an element on FFXIVCrafting
        /// </summary>
        private void SearchThread()
        {
            string        elemToSearch = VPThreading.GetText(_searchTextBox);
            int           minLevel     = (int)VPThreading.GetValue(_minLevelNumericUpDown);
            int           maxLevel     = (int)VPThreading.GetValue(_maxLevelNumericUpDown);
            List <string> jobs         = new List <string>();

            lock (_locker)
            {
                jobs = _jobFilter;
            }
            Service_Misc.LogText(_logTextBox, "Alright, let's look for " + elemToSearch);
            List <FFXIVSearchItem> listResults = GarlandTool.Search(elemToSearch, _logTextBox, FFXIVItem.TypeItem.Crafted, jobs, minLevel, maxLevel);

            //Storing in options
            MiqoCraftOptions options = new MiqoCraftOptions();

            options.Load(OptionLocation.UserOption);
            options.LastSearchResult = listResults;
            options.Save();

            if (listResults.Count > 0)
            {
                Service_Misc.LogText(_logTextBox, "All done ! Found " + listResults.Count + " items!");
            }
            else
            {
                Service_Misc.LogText(_logTextBox, "All done ! But I couldn't find your item...");
            }

            DisplayItemList(listResults);
        }
コード例 #3
0
        private void DisplayItemList(List <FFXIVSearchItem> iItems)
        {
            VPThreading.ClearItems(_resultListView);
            _lastDisplayedItems = iItems;

            Service_Misc.LogText(_logTextBox, "Updating list...");
            foreach (FFXIVSearchItem item in iItems)
            {
                if (null == item)
                {
                    continue;
                }

                ListViewItem listViewItem = new ListViewItem();
                listViewItem.Tag  = item;
                listViewItem.Text = item.Quantity + "x " + item.Name;
                listViewItem.SubItems.Add(item.Class + " lvl" + item.Level);
                listViewItem.ToolTipText = item.Class + " lvl" + item.Level;

                VPThreading.AddItem(_resultListView, listViewItem);
            }
            VPThreading.SetText(_nbResultItemLabel, iItems.Count + " Items found");

            UpdateResultPictures();
        }
コード例 #4
0
        private void UpdateResultPicturesThread()
        {
            List <ListViewItem> iItems = VPThreading.GetItems(_resultListView);

            Service_Misc.LogText(_logTextBox, "Updating Item Pictures...");
            foreach (ListViewItem listViewItem in iItems)
            {
                try
                {
                    FFXIVSearchItem item = VPThreading.GetTag(listViewItem) as FFXIVSearchItem;
                    if (!_prerequisiteImageList.Images.ContainsKey(item.ID))
                    {
                        System.Net.WebRequest  request    = System.Net.WebRequest.Create(item.UrlImage);
                        System.Net.WebResponse resp       = request.GetResponse();
                        System.IO.Stream       respStream = resp.GetResponseStream();
                        Bitmap bmp = new Bitmap(respStream);
                        respStream.Dispose();

                        VPThreading.AddImage(_resultListView, _prerequisiteImageList, item.ID, bmp);
                    }
                    VPThreading.SetImageKey(listViewItem, item.ID);
                }
                catch (Exception)
                {
                }
            }
        }
コード例 #5
0
        private void UpdateResultPictures()
        {
            VPThreading.Abort(_updateResultPictureThread);
            ThreadStart starter = new ThreadStart(UpdateResultPicturesThread);

            _updateResultPictureThread = new Thread(starter);
            _updateResultPictureThread.Start();
        }
コード例 #6
0
        private void _downloadFromURLButton_Click(object sender, EventArgs e)
        {
            ThreadStart starter = new ThreadStart(DownloadFromURLThread);

            VPThreading.Abort(_thread);
            _thread = new Thread(starter);
            _thread.Start();
        }
コード例 #7
0
        /// <summary>
        /// Starts search thread
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _searchButton_Click(object sender, EventArgs e)
        {
            VPThreading.Abort(_searchThread);
            ThreadStart starter = new ThreadStart(SearchThread);

            _searchThread = new Thread(starter);
            _searchThread.Start();
        }
コード例 #8
0
        private void Button1_Click(object sender, EventArgs e)
        {
            VPThreading.Abort(_updateBDDThread);
            ThreadStart starter = new ThreadStart(UpdateGridBDDThread);

            _updateBDDThread = new Thread(starter);
            _updateBDDThread.Start();
        }
コード例 #9
0
 /// <summary>
 /// Nettoyage des ressources utilisées.
 /// </summary>
 /// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
 protected override void Dispose(bool disposing)
 {
     VPThreading.Abort(_thread);
     if (disposing && (components != null))
     {
         components.Dispose();
     }
     base.Dispose(disposing);
 }
コード例 #10
0
 /// <summary>
 /// Nettoyage des ressources utilisées.
 /// </summary>
 /// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
 protected override void Dispose(bool disposing)
 {
     VPThreading.Abort(_searchThread);
     VPThreading.Abort(_updateBDDThread);
     VPThreading.Abort(_updateResultPictureThread);
     if (disposing && (components != null))
     {
         components.Dispose();
     }
     base.Dispose(disposing);
 }
コード例 #11
0
 private void _addToCraftingListButton_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem listViewItem in _resultListView.SelectedItems)
     {
         try
         {
             FFXIVSearchItem item = VPThreading.GetTag(listViewItem) as FFXIVSearchItem;
             if (null != item)
             {
                 _itemsToCraft.Add(item);
             }
         }
         catch
         {
         }
     }
     UpdateCraftingList();
 }
コード例 #12
0
        private void _quantityNumericUpDown_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                ListView.SelectedListViewItemCollection iItems = _resultListView.SelectedItems;

                Service_Misc.LogText(_logTextBox, "Updating Item Pictures...");
                foreach (ListViewItem listViewItem in iItems)
                {
                    try
                    {
                        FFXIVSearchItem item = VPThreading.GetTag(listViewItem) as FFXIVSearchItem;
                        //if (null != item) item.Quantity = (int)VPThreading.GetValue(_quantityNumericUpDown);
                        DisplayItemList(_lastDisplayedItems);
                    }
                    catch
                    {
                    }
                }
            }
        }
コード例 #13
0
        private void UpdateBDDStatusFromOptions()
        {
            VPThreading.SetText(_gridStatusLabel, "-");

            try
            {
                MiqoCraftOptions options = new MiqoCraftOptions();
                options.Load(OptionLocation.GlobalOption);

                int percentage = options.ListGridOKItems.Count * 100 / options.ListGatherableItems.Count;

                VPThreading.SetText(_gridStatusLabel, percentage + " % (" + options.ListGridOKItems.Count + " / " + options.ListGatherableItems.Count + ")");

                int    nbOK   = 0;
                string OKList = "";
                string KOList = "";
                foreach (string item in options.ListGatherableItems)
                {
                    if (options.ListGridOKItems.Contains(item))
                    {
                        nbOK++;
                        OKList += item + Environment.NewLine;
                    }
                    else
                    {
                        KOList += item + Environment.NewLine;
                    }
                }
                Console.WriteLine("--- OK Items");
                Console.WriteLine(OKList);
                Console.WriteLine("--- KO Items");
                Console.WriteLine(KOList);
            }
            catch
            {
            }
        }
コード例 #14
0
        private void AnalyzeGridThread()
        {
            VPThreading.ClearItems(_gridListView);

            DirectoryInfo exeDirectory     = new DirectoryInfo(Service_Misc.GetExecutionPath());
            DirectoryInfo cacheDirectory   = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "CacheGrid"));
            DirectoryInfo analyzeDirectory = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "DownloadedGrids"));

            if (!analyzeDirectory.Exists)
            {
                DownloadMissingItemGrids();
            }
            if (!analyzeDirectory.Exists)
            {
                return;
            }
            Dictionary <string, double> dictionaryClosestAetherytes = new Dictionary <string, double>();

            FileInfo[] files = analyzeDirectory.GetFiles();
            int        index = 0;

            foreach (FileInfo file in files)
            {
                index++;
                double percentage = (double)index / (double)files.Count() * 100.0;

                VPThreading.SetText(_progressLabel, "Analyzing Grids..." + percentage + "%");
                if (null == file)
                {
                    continue;
                }
                try
                {
                    string itemName = file.Name.Split(new string[] { " Grid---" }, StringSplitOptions.None)[0];

                    //Looking into cache directory
                    string   gridItemName  = itemName + " Grid";
                    FileInfo cacheGridFile = new FileInfo(Path.Combine(cacheDirectory.FullName, gridItemName + ".txt"));
                    if (cacheGridFile.Exists)
                    {
                        VPThreading.SetText(_progressLabel, "Item already has a grid.");
                        continue;
                    }

                    FFXIVItemGridF gridF = new FFXIVItemGridF();
                    gridF.ItemName = itemName;
                    gridF.GridFile = new FileInfo(file.FullName);
                    gridF.Analyze(ListAetherytes, ListGatheringNodes, ref dictionaryClosestAetherytes);
                    ListGridF.Add(gridF);

                    if (gridF.IsValid)
                    {
                        gridF.SaveAsGrids();
                    }

                    ListViewItem item = new ListViewItem();
                    item.Text = file.Name;
                    item.SubItems.Add(gridF.Status);
                    item.Tag = gridF;
                    VPThreading.AddItem(_gridListView, item);
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc.Message);
                }
            }
        }
コード例 #15
0
        private void DownloadMissingItemGrids()
        {
            List <MiqoItemPage> result            = new List <MiqoItemPage>();
            CookieCollection    logMiqobotCookies = Miqobot.LogInForum();

            CookieCollection oCookies = new CookieCollection();
            HttpStatusCode   oCode    = HttpStatusCode.NotFound;

            HtmlAgilityPack.HtmlDocument answer = Service_Misc.GetWebPageFromRequest("GET https://miqobot.com/forum/forums/topic/index-gathering-grids/ HTTP/1.1|Host: miqobot.com|Connection: keep-alive|Cache-Control: max-age=0|Upgrade-Insecure-Requests: 1|User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36|Sec-Fetch-Mode: navigate|Sec-Fetch-User: ?1|Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3|Sec-Fetch-Site: same-origin|Referer: https://miqobot.com/forum/forums/forum/grids-and-presets/|Accept-Encoding: gzip, deflate, br|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|Cookie: wordpress_test_cookie=WP+Cookie+check; _ga=GA1.2.1771485810.1566089776||",
                                                                                     logMiqobotCookies, ref oCookies, ref oCode);
            if (null == answer)
            {
                VPThreading.SetText(_progressLabel, "Failed to update database. No answer from miqobot forum.");
                return;
            }

            HtmlAgilityPack.HtmlNode firstAnswerNode = Service_Misc.GetFirstChildNode(answer.DocumentNode, "div", "topic-tag-gathering");

            List <HtmlAgilityPack.HtmlNode> listItemNodes = firstAnswerNode.Descendants("li").ToList();

            DirectoryInfo exeDirectory     = new DirectoryInfo(Service_Misc.GetExecutionPath());
            DirectoryInfo cacheDirectory   = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "CacheGrid"));
            DirectoryInfo analyzeDirectory = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "DownloadedGrids"));

            if (!analyzeDirectory.Exists)
            {
                analyzeDirectory.Create();
            }
            if (!cacheDirectory.Exists)
            {
                VPThreading.SetText(_progressLabel, "Failed to compute database status, CacheGrid directory does not exist.");
                return;
            }
            int indexProg = 0;

            foreach (HtmlAgilityPack.HtmlNode node in listItemNodes)
            {
                indexProg++;

                VPThreading.SetProgress(_progressBar, indexProg * 100 / listItemNodes.Count);
                if (null == node)
                {
                    continue;
                }

                string nodeInnerTextLower = node.InnerText.ToLower();
                if (nodeInnerTextLower.Contains("Mining Your Own Business".ToLower()))
                {
                    break;
                }
                if (nodeInnerTextLower.Contains("lv."))
                {
                    //Found node !
                    string level    = nodeInnerTextLower.Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                    string itemName = nodeInnerTextLower.Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries)[1].Trim().Replace("(hidden)", "").Trim();

                    //Check if grid exist
                    string gridItemName = itemName + " Grid";

                    //Looking into cache directory
                    FileInfo cacheGridFile = new FileInfo(Path.Combine(cacheDirectory.FullName, gridItemName + ".txt"));
                    if (cacheGridFile.Exists)
                    {
                        VPThreading.SetText(_progressLabel, "Item already has a grid.");
                        continue;
                    }
                    VPThreading.SetText(_progressLabel, "Trying to find a new grid : " + itemName);

                    //Looking for all links
                    List <MiqoItemPage> listLinks = Miqobot.GetURLItem(itemName, logMiqobotCookies, answer);
                    foreach (MiqoItemPage page in listLinks)
                    {
                        //List<string> ListGrids = Miqobot.GetAllGridsFromForum(itemName, logMiqobotCookies, page);
                        //if (null == ListGrids) continue;

                        //foreach(string grid in ListGrids)
                        //{
                        //    try
                        //    {
                        //        string pathGrid = Path.Combine(analyzeDirectory.FullName, gridItemName + "---" + gridIndex + ".txt");
                        //        if (File.Exists(pathGrid)) File.Delete(pathGrid);

                        //        File.WriteAllText(pathGrid, grid);
                        //        gridIndex++;
                        //    }
                        //    catch
                        //    {

                        //    }
                        //}
                        DownloadFromURL(page.URL, itemName, logMiqobotCookies);
                    }
                }
            }
            VPThreading.SetProgress(_progressBar, 100);
            VPThreading.SetText(_progressLabel, "Done!");
        }
コード例 #16
0
 private void DownloadFromURLThread()
 {
     DownloadFromURL(VPThreading.GetText(_urlTextBox));
 }
コード例 #17
0
        private void DownloadFromURL(string iURL, string iItemName = "", CookieCollection iCookies = null)
        {
            VPThreading.SetText(_progressLabel, "Downloading grid from given URL...");
            if (null == iCookies)
            {
                iCookies = Miqobot.LogInForum();
            }
            List <string>      listGridRawContent = Miqobot.GetAllGridsRawContentFromForum(iURL, iCookies);
            List <MiqobotGrid> listGrids          = new List <MiqobotGrid>();

            MiqoGridFinderOptions options = new MiqoGridFinderOptions();

            options.Load(VPL.Application.Data.OptionLocation.GlobalOption);
            List <FFXIVSearchItem> listAllGatheredItems = options.ListAllGatheredItems;

            if (listAllGatheredItems.Count <= 0)
            {
                VPThreading.SetText(_progressLabel, "Downloading all item names...");
                listAllGatheredItems = GarlandTool.Search("", null, FFXIVItem.TypeItem.Gathered);
            }
            options.ListAllGatheredItems = listAllGatheredItems;
            options.Save();


            VPThreading.SetText(_progressLabel, "Reading grids...");
            foreach (string rawContent in listGridRawContent)
            {
                listGrids.AddRange(Miqobot.GetAllGridsFromContent(rawContent));
            }

            DirectoryInfo exeDirectory     = new DirectoryInfo(Service_Misc.GetExecutionPath());
            DirectoryInfo cacheDirectory   = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "CacheGrid"));
            DirectoryInfo analyzeDirectory = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "DownloadedGrids"));

            if (!analyzeDirectory.Exists)
            {
                analyzeDirectory.Create();
            }
            if (!cacheDirectory.Exists)
            {
                VPThreading.SetText(_progressLabel, "Failed to compute database status, CacheGrid directory does not exist.");
                return;
            }

            VPThreading.SetText(_progressLabel, "Matching grid to item list...");
            int gridIndex = 1;

            foreach (MiqobotGrid grid in listGrids)
            {
                List <string> listCorrespondingItemNames = new List <string>();
                foreach (FFXIVSearchItem item in listAllGatheredItems)
                {
                    if (null == grid.Description)
                    {
                        continue;
                    }
                    if (grid.Description.ToLower().Contains(item.Name.ToLower()))
                    {
                        listCorrespondingItemNames.Add(item.Name);
                    }
                    if (grid.Header.ToLower().Contains(item.Name.ToLower()))
                    {
                        listCorrespondingItemNames.Add(item.Name);
                    }
                }

                if (listCorrespondingItemNames.Count <= 0 && iItemName != "")
                {
                    listCorrespondingItemNames.Add(iItemName);
                }
                List <string> listFilteredCorrespondingItemNames = new List <string>();
                foreach (string itemName in listCorrespondingItemNames)
                {
                    bool hasBigger = false;
                    foreach (string itemName2 in listCorrespondingItemNames)
                    {
                        if (itemName2 != itemName && itemName2.Contains(itemName))
                        {
                            hasBigger = true;
                            break;
                        }
                    }
                    if (!hasBigger)
                    {
                        listFilteredCorrespondingItemNames.Add(itemName);
                    }
                }
                foreach (string itemName in listFilteredCorrespondingItemNames)
                {
                    //Check if grid exist
                    string gridItemName = itemName + " Grid";

                    //Looking into cache directory
                    FileInfo cacheGridFile = new FileInfo(Path.Combine(cacheDirectory.FullName, gridItemName + ".txt"));
                    if (cacheGridFile.Exists)
                    {
                        continue;
                    }

                    //Saving grid
                    string pathGrid = Path.Combine(analyzeDirectory.FullName, gridItemName + "---" + gridIndex + ".txt");
                    if (File.Exists(pathGrid))
                    {
                        File.Delete(pathGrid);
                    }

                    File.WriteAllText(pathGrid, "grid." + grid.Header + Environment.NewLine + grid.Content);
                    gridIndex++;
                }
            }
        }
コード例 #18
0
        private void UpdateGridBDDThread()
        {
            List <string> _gatherableItemNames = new List <string>();
            List <string> _gridOKItemNames     = new List <string>();

            Service_Misc.LogText(_logTextBox, "Updating database...");
            VPThreading.SetText(_gridStatusLabel, "-");

            MiqoCraftCore.MiqoCraftCore.DownloadGrids();

            try
            {
                List <MiqoItemPage> result            = new List <MiqoItemPage>();
                CookieCollection    logMiqobotCookies = Miqobot.LogInForum();

                CookieCollection             oCookies = new CookieCollection();
                HttpStatusCode               oCode    = HttpStatusCode.NotFound;
                HtmlAgilityPack.HtmlDocument answer   = Service_Misc.GetWebPageFromRequest("GET https://miqobot.com/forum/forums/topic/index-gathering-grids/ HTTP/1.1|Host: miqobot.com|Connection: keep-alive|Cache-Control: max-age=0|Upgrade-Insecure-Requests: 1|User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36|Sec-Fetch-Mode: navigate|Sec-Fetch-User: ?1|Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3|Sec-Fetch-Site: same-origin|Referer: https://miqobot.com/forum/forums/forum/grids-and-presets/|Accept-Encoding: gzip, deflate, br|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|Cookie: wordpress_test_cookie=WP+Cookie+check; _ga=GA1.2.1771485810.1566089776||",
                                                                                           logMiqobotCookies, ref oCookies, ref oCode);
                if (null == answer)
                {
                    Service_Misc.LogText(_logTextBox, "Failed to update database. No answer from miqobot forum.");
                    return;
                }

                HtmlAgilityPack.HtmlNode firstAnswerNode = Service_Misc.GetFirstChildNode(answer.DocumentNode, "div", "topic-tag-gathering");

                List <HtmlAgilityPack.HtmlNode> listItemNodes = firstAnswerNode.Descendants("li").ToList();

                DirectoryInfo exeDirectory   = new DirectoryInfo(Service_Misc.GetExecutionPath());
                DirectoryInfo cacheDirectory = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "CacheGrid"));
                if (!cacheDirectory.Exists)
                {
                    Service_Misc.LogText(_logTextBox, "Failed to compute database status, CacheGrid directory does not exist.");
                    return;
                }

                foreach (HtmlAgilityPack.HtmlNode node in listItemNodes)
                {
                    if (null == node)
                    {
                        continue;
                    }

                    string nodeInnerTextLower = node.InnerText.ToLower();
                    if (nodeInnerTextLower.Contains("Mining Your Own Business".ToLower()))
                    {
                        break;
                    }
                    if (nodeInnerTextLower.Contains("lv."))
                    {
                        //Found node !
                        string level    = nodeInnerTextLower.Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                        string itemName = nodeInnerTextLower.Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries)[1].Trim().Replace("(hidden)", "").Trim();

                        _gatherableItemNames.Add(itemName);
                        if (File.Exists(Path.Combine(cacheDirectory.FullName, itemName + " Grid.txt")))
                        {
                            _gridOKItemNames.Add(itemName);
                        }
                    }
                }

                lock (_locker)
                {
                    MiqoCraftOptions options = new MiqoCraftOptions();
                    options.Load(OptionLocation.GlobalOption);
                    options.ListGatherableItems = _gatherableItemNames;
                    options.ListGridOKItems     = _gridOKItemNames;
                    options.Save();
                }

                UpdateBDDStatusFromOptions();

                {
                    Service_Misc.LogText(_logTextBox, "Database updated !");
                    return;
                }
            }
            catch
            {
                Service_Misc.LogText(_logTextBox, "Failed to compute database status, CacheGrid directory does not exist.");
                return;
            }
        }
コード例 #19
0
 private void DownloadMissingItemGridsThread()
 {
     VPThreading.SetText(_progressLabel, "Downloading all grids from miqobot forum index...");
     DownloadMissingItemGrids();
 }