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();
        }
Beispiel #2
0
        public FormViewer()
        {
            InitializeComponent();

            try
            {
                MiqoGridFinderOptions options = new MiqoGridFinderOptions();
                options.Load(VPL.Application.Data.OptionLocation.GlobalOption);
                ListGatheringNodes = options.ListGatheringNodes;
                if (ListGatheringNodes.Count <= 0)
                {
                    ListGatheringNodes = MiqoCraftCore.ConsoleGamesWiki.GetFFXIVGatheringNodes();
                }

                ListAetherytes = options.ListAetherytes;
                if (ListAetherytes.Count <= 0)
                {
                    ListAetherytes = MiqoCraftCore.ConsoleGamesWiki.GetAetherytes();
                }
                _aetheryteComboBox.Items.Clear();
                foreach (FFXIVAetheryte aetherythe in ListAetherytes)
                {
                    _aetheryteComboBox.Items.Add(aetherythe);
                }

                options.ListGatheringNodes = ListGatheringNodes;
                options.ListAetherytes     = ListAetherytes;
                options.Save();
            }
            catch
            {
            }
        }
        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++;
                }
            }
        }