示例#1
0
        private void DownloadPage_Load(object sender, EventArgs e)
        {
            #region Read DB
            for (int i = 0; i < 20; i++)
            {
                FileInfo fi = new FileInfo(Global.DBPath + Global.DBName + i.ToString() + Global.DBExt);
                if (!fi.Exists)
                {
                    DBDownloader.DBDownload();

                    break;
                }
            }

            Thread tagsDB = new Thread(new ThreadStart(() =>
            {
                FileInfo fi = new FileInfo(Global.DBPath + Global.DBTags + Global.DBExt);
                if (!fi.Exists)
                {
                    DBDownloader.InfoDownload("tags");
                }
                StreamReader sr = new StreamReader(Global.DBPath + Global.DBTags + Global.DBExt);
                while (!sr.EndOfStream)
                {
                    Global.Tags.Add(sr.ReadLine());
                }
                sr.Close();
                if (!Global.SpeedLimit)
                {
                    listBox_TagAdd.Items.AddRange(SearchListBox.GetListBox(Global.Tags, String.Empty));
                    listBox_TagDelete.Items.AddRange(SearchListBox.GetListBox(Global.Tags, String.Empty));
                }
            }));
            Thread seriesDB = new Thread(new ThreadStart(() =>
            {
                FileInfo fi = new FileInfo(Global.DBPath + Global.DBSeries + Global.DBExt);
                if (!fi.Exists)
                {
                    DBDownloader.InfoDownload("series");
                }
                StreamReader sr = new StreamReader(Global.DBPath + Global.DBSeries + Global.DBExt);
                while (!sr.EndOfStream)
                {
                    Global.Series.Add(sr.ReadLine());
                }
                sr.Close(); if (!Global.SpeedLimit)
                {
                    listBox_SeriesAdd.Items.AddRange(SearchListBox.GetListBox(Global.Series, String.Empty));
                }
            }));
            Thread characterDB = new Thread(new ThreadStart(() =>
            {
                FileInfo fi = new FileInfo(Global.DBPath + Global.DBCharcter + Global.DBExt);
                if (!fi.Exists)
                {
                    DBDownloader.InfoDownload("characters");
                }
                StreamReader sr = new StreamReader(Global.DBPath + Global.DBCharcter + Global.DBExt);
                while (!sr.EndOfStream)
                {
                    Global.Character.Add(sr.ReadLine());
                }
                sr.Close();
                if (!Global.SpeedLimit)
                {
                    listBox_CharacterAdd.Items.AddRange(SearchListBox.GetListBox(Global.Character, String.Empty));
                    listBox_CharacterDelete.Items.AddRange(SearchListBox.GetListBox(Global.Character, String.Empty));
                }
            }));
            Thread artistsDB = new Thread(new ThreadStart(() =>
            {
                FileInfo fi = new FileInfo(Global.DBPath + Global.DBArtist + Global.DBExt);
                if (!fi.Exists)
                {
                    DBDownloader.InfoDownload("artists");
                }
                StreamReader sr = new StreamReader(Global.DBPath + Global.DBArtist + Global.DBExt);
                while (!sr.EndOfStream)
                {
                    Global.Artist.Add(sr.ReadLine());
                }
                sr.Close();
                if (!Global.SpeedLimit)
                {
                    listBox_ArtistAdd.Items.AddRange(SearchListBox.GetListBox(Global.Artist, String.Empty));
                }
            }));

            tagsDB.Start();
            seriesDB.Start();
            characterDB.Start();
            artistsDB.Start();

            #endregion

            FileInfo fis = new FileInfo(Global.ReDownloadPath);
            if (!fis.Exists)
            {
                return;
            }

            BinaryFormatter binFmt = new BinaryFormatter();;
            using (FileStream rdr = new FileStream(Global.ReDownloadPath, FileMode.Open))
            {
                Global.HioDownGalleries = (DownloadGallerie)binFmt.Deserialize(rdr);
            }

            for (int i = 0; i < Global.HioDownGalleries.ID.Count; i++)
            {
                Thread th = new Thread(new ParameterizedThreadStart((data) => {
                    var g             = Global.HioDownGalleries.Galleries[(int)data];
                    HioDownloader hio = new HioDownloader(g);
                    hio.Downloads    += Pre_Download;

                    if (Global.HioDownGalleries.DownloadPage[(int)data] - 1 == -1)
                    {
                        hio.Download(Global.DownloadPath, 0);
                    }
                    else
                    {
                        hio.Download(Global.DownloadPath, Global.HioDownGalleries.DownloadPage[(int)data] - 1);
                    }
                }));
                th.Start(i);

                var gs = Global.HioDownGalleries.Galleries[i];
                DownloadLog_AddReverse(gs, Global.HioDownGalleries.DownloadPage[i] / Global.HioDownGalleries.TotalPage[i]);
                DownloadLists.Add(gs, Global.HioDownGalleries.DownloadPage[i] / Global.HioDownGalleries.TotalPage[i]);
            }
        }
示例#2
0
        public void Find_Start(SearchData search, Panel Bar, Control text, bool IsOld = false)
        {
            for (int i = 0; i < 20; i++)
            {
                FileInfo fi = new FileInfo(Global.DBPath + Global.DBName + i.ToString() + Global.DBExt);
                if (!fi.Exists)
                {
                    DBDownloader.DBDownload();
                    var Struct = new Library.AlamStruct("Error", "DB파일이 존재하지 않아서 다운로드합니다.", 5f);
                    Global.manage.Add(Struct);
                    return;
                }
            }

            if (!IsOld)
            {
                var result = new List <JToken>();

                // DB가 0부터 19까지 존재합니다.
                for (int i = 0; i < 20; i++)
                {
                    int we = 0;
                    try
                    {
                        ///
                        /// 검색기능
                        ///
                        using (StreamReader sr = new StreamReader(Global.DBPath + Global.DBName + i.ToString() + Global.DBExt))
                        {
                            JArray list = JArray.Parse(sr.ReadToEnd());
                            we = 1;
                            // 검색한 자료만큼 반복을 합니다.
                            for (int w = 0; w < list.Count; w++)
                            {
                                if (Stop)
                                {
                                    return;
                                }
                                we = 2;
                                JObject j        = list[w].ToObject <JObject>();
                                bool    IsSearch = true;

                                // 필요없는 데이터 처리.

                                foreach (var content in j)
                                {
                                    if (search.Character_Delete.Count != 0 && content.Key == "c")
                                    {
                                        foreach (var delete in search.Character_Delete)
                                        {
                                            foreach (var contentName in content.Value)
                                            {
                                                if (delete == contentName.ToString().ToLower())
                                                {
                                                    IsSearch = false;
                                                    break;
                                                }
                                            }
                                            if (!IsSearch)
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    else if (search.Series_Delete.Count != 0 && content.Key == "p")
                                    {
                                        foreach (var delete in search.Series_Delete)
                                        {
                                            foreach (var contentName in content.Value)
                                            {
                                                if (delete == contentName.ToString().ToLower())
                                                {
                                                    IsSearch = false; break;
                                                }
                                            }
                                            if (!IsSearch)
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    else if (search.Tags_Delete.Count != 0 && content.Key == "t")
                                    {
                                        foreach (var data in search.Tags_Delete)
                                        {
                                            foreach (var contentName in content.Value)
                                            {
                                                if (data == contentName.ToString().ToLower())
                                                {
                                                    IsSearch = false;
                                                }
                                            }
                                            if (!IsSearch)
                                            {
                                                break;
                                            }
                                        }
                                    }

                                    if (IsSearch == false)
                                    {
                                        break;
                                    }
                                }

                                if (IsSearch)
                                {
                                    IsSearch = IsSearchData(search, j);
                                }

                                // 이 자료가 찾은 검색에 적합한지에 조사합니다.
                                if (IsSearch)
                                {
                                    // 찾은 검색에 적합한지에 조사한 자료에 본격적인 조사를 합니다.
                                    foreach (var content in j)
                                    {
                                        if (search.Title.Length != 0 && content.Key == "n")
                                        {
                                            if (content.Value.ToString().ToLower().IndexOf(search.Title, 0) == -1)
                                            {
                                                IsSearch = false;
                                            }
                                        }
                                        else if (search.Language.Count != 0 && content.Key == "l")
                                        {
                                            bool chk = false;
                                            foreach (var lang in search.Language)
                                            {
                                                if (lang == content.Value.ToString())
                                                {
                                                    chk = true;
                                                    break;
                                                }
                                            }
                                            IsSearch = chk;
                                        }
                                        else if (search.Type.Count != 0 && content.Key == "type")
                                        {
                                            bool chk = false;
                                            foreach (var Type in search.Type)
                                            {
                                                if (Type == content.Value.ToString())
                                                {
                                                    chk = true;
                                                    break;
                                                }
                                            }
                                            IsSearch = chk;
                                        }
                                        else if (search.Character.Count != 0 && content.Key == "c")
                                        {
                                            int count = 0;

                                            foreach (var data in search.Character)
                                            {
                                                foreach (var contentName in content.Value)
                                                {
                                                    if (contentName.ToString().ToLower() == data)
                                                    {
                                                        count++;
                                                    }
                                                }
                                            }
                                            if (count != search.Character.Count)
                                            {
                                                IsSearch = false;
                                            }
                                        }
                                        else if (search.Series.Count != 0 && content.Key == "p")
                                        {
                                            int count = 0;

                                            foreach (var data in search.Series)
                                            {
                                                foreach (var contentName in content.Value)
                                                {
                                                    if (contentName.ToString().ToLower() == data)
                                                    {
                                                        count++;
                                                    }
                                                }
                                            }
                                            if (count == 0)
                                            {
                                                IsSearch = false;
                                            }
                                        }
                                        else if (search.Tags.Count != 0 && content.Key == "t")
                                        {
                                            int count = 0;

                                            foreach (var data in search.Tags)
                                            {
                                                foreach (var contentName in content.Value)
                                                {
                                                    if (contentName.ToString().ToLower() == data)
                                                    {
                                                        count++;
                                                    }
                                                }
                                            }
                                            if (count != search.Tags.Count)
                                            {
                                                IsSearch = false;
                                            }
                                        }
                                        else if (search.Artist.Count != 0 && content.Key == "a")
                                        {
                                            bool chk = false;
                                            foreach (var lang in search.Artist)
                                            {
                                                if (lang == content.Value.ToString())
                                                {
                                                    chk = true;
                                                    break;
                                                }
                                            }
                                            IsSearch = chk;
                                        }

                                        if (IsSearch == false)
                                        {
                                            break;
                                        }
                                    }
                                }

                                // 검색한 결과를 OnFind 이벤트를 통해서 전달합니다.
                                if (IsSearch)
                                {
                                    we = 6;
                                    Gallerie g = new Gallerie
                                    {
                                        Tags      = new List <string>(),
                                        Character = new List <string>()
                                    };
                                    we = 7;
                                    if (j["n"] != null)
                                    {
                                        g.Title = j["n"].ToString();
                                    }
                                    if (j["id"] != null)
                                    {
                                        g.ID = j["id"].ToString();
                                    }
                                    if (j["g"] != null)
                                    {
                                        g.Uploader = j["g"].ToString().Split('\"')[1];
                                    }
                                    if (j["type"] != null)
                                    {
                                        g.Type = j["type"].ToString();
                                    }
                                    if (j["l"] != null)
                                    {
                                        g.Language = j["l"].ToString();
                                    }
                                    if (j["p"] != null)
                                    {
                                        g.Series = j["p"].ToString().Split('\"')[1];
                                    }
                                    if (j["a"] != null)
                                    {
                                        g.Artist = j["a"].ToString();
                                    }

                                    if (j["t"] != null)
                                    {
                                        foreach (var value in j["t"].Values <string>())
                                        {
                                            g.Tags.Add(value);
                                        }
                                    }
                                    if (j["c"] != null)
                                    {
                                        foreach (var value in j["c"].Values <string>())
                                        {
                                            g.Character.Add(value);
                                        }
                                    }
                                    g.ThumnailImage = "https://ltn.hitomi.la/galleryblock/" + g.ID + ".html";
                                    OnFind(g);
                                }
                            }

                            try
                            {
                                using (var draw = Bar.CreateGraphics())
                                    draw.DrawLine(new Pen(Color.FromArgb(100, 200, 100), Bar.Size.Height / 2), 0, Bar.Size.Height / 2.0f, Bar.Size.Width / 19.0f * i, Bar.Size.Height / 2.0f);
                            }
                            catch (Exception) { }

                            sr.Close();
                            GC.Collect();
                        }
                    }
                    catch (Exception e1)
                    {
                        MessageBox.Show(e1.ToString() + "\n\n\n" + we);
                    }
                }
            }
            text.Invoke(new MethodInvoker(() =>
            {
                text.Text = "검색";
            }));
        }