public void dataIndexing(string args)
        {
            List <tbInformasi> InfoList  = null;// db.tbInformasis.ToList();
            tbInfDetail        datadetil = null;

            if (CheckInternetConnectionByPing() && CheckInternetConnectionbyWebPage())
            {
                InetCon = true;
            }
            if (args.ToLower().Equals("all"))
            {
                InfoList = db.tbInformasis.ToList();
            }
            else
            {
                InfoList = db.tbInformasis.Where(x => x.Indexed == 0).ToList();
            }

            for (int i = 0; i < InfoList.Count; i++)
            {
                bool cek = File.Exists(InfoList[i].Lokasi);
                if (cek)// && InfoList[i].Indexed==0)
                {
                    InfoList[i].Indexed = 1;
                    string   text     = File.ReadAllText(InfoList[i].Lokasi);
                    string[] Fragment = text.Split(';').ToArray();
                    for (int j = 0; j < Fragment.Length; j++)
                    {
                        if (!String.IsNullOrWhiteSpace(Fragment[j]))
                        {
                            datadetil = CreateDataDetil(Fragment[j]);
                            if (datadetil != null && db.tbInfDetails.Where(x => x.info.ToString() == datadetil.info.ToString()).FirstOrDefault() == null)
                            {
                                InfoList[i].tbInfDetails.Add(datadetil);
                            }
                            createInvertedIndex(Fragment[j], InfoList[i].DomainID, InfoList[i].Id, j);
                        }
                    }
                    bool isExist = File.Exists(Lingkungan.getDataCache() + InfoList[i].tbDomain.Name + "\\" + InfoList[i].Judul);
                    File.Move(InfoList[i].Lokasi, Lingkungan.getDataCache() + InfoList[i].tbDomain.Name + "\\" + InfoList[i].Judul);
                    InfoList[i].Lokasi = Lingkungan.getDataCache() + InfoList[i].tbDomain.Name + "\\" + InfoList[i].Judul;
                }
            }
            if (File.Exists(Lingkungan.getInvertedIndexLocation()))
            {
                HitungPembobotanKata();
            }
            InetCon = false;
            db.SubmitChanges();
        }
Пример #2
0
        public void FileCrawler(string args) //uncalled
        {
            //Crawler
            List <string> LokasiFile = new List <string>();
            //menyimpan daftar folder yang akan di crawl
            Queue <string> ListLocation = new Queue <string>();
            //menimpan daftar file yang akan di index
            List <string> FileLocation = new List <string>();

            string process; // variabel pemrosesan
            string location;

            if (args == "cache")
            {
                location = Lingkungan.getDataCache(); // menyimpan lokasi cache yang akan dicrawl
            }
            else
            {
                location = Lingkungan.getDataBaru(); // menyimpan lokasi Data baru yang akan dicrawl
            }
            if ((File.Exists(location) || Directory.Exists(location)) && string.IsNullOrWhiteSpace(location) == false)
            {
                ListLocation.Enqueue(location);
                do
                {
                    process = ListLocation.Dequeue();
                    if (File.GetAttributes(process) == FileAttributes.Directory)
                    {
                        foreach (string item in Directory.GetDirectories(process))
                        {
                            ListLocation.Enqueue(item);
                        }
                        foreach (string item2 in Directory.GetFiles(process))
                        {
                            FileLocation.Add(item2);
                        }
                    }
                } while (ListLocation.Count > 0);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Gagal Melakukan Crawling");
            }
            locations = FileLocation;
        }