Esempio n. 1
0
        public static Boolean WriteListHostToFile(ListHost listHost, String filePath)
        {
            if (listHost == null)
            {
                return(false);
            }
            if (listHost.tag == null)
            {
                return(false);
            }

            String outPut = JsonConvert.SerializeObject(listHost, Formatting.Indented).ToString();

            if (outPut.Length <= 0)
            {
                return(false);
            }
            if (!ValidateJSON(outPut))
            {
                return(false);
            }

            Console.WriteLine(outPut);

            WriteFile(filePath, outPut);



            return(true);
        }
Esempio n. 2
0
 public MainWindow()
 {
     InitializeComponent();
     document = new Web_Document(" ");
     listHost = new ListHost();
     listHost = Lib.LoadJsonFileToListHost(Web_Document.filePathJson);
     document.IntListHost(listHost);
 }
Esempio n. 3
0
        public Window_Add_Att()
        {
            InitializeComponent();
            if (File.Exists(Web_Document.filePathJson))
            {
                listHost = Lib.LoadJsonFileToListHost(Web_Document.filePathJson);
                Console.WriteLine("Data exits.");
            }
            else
            {
                listHost = new ListHost();
                Console.WriteLine("Data does not exits.");
            }
            TAG = new HostTag();

            this.TextBox_Result.Text   = Lib.GetHostInUrl(this.textBox_Url_Test.Text);
            this.textBox_Url_Test.Text = "https://wikidich.com/truyen/than-con-xuong-nui-ky/chuong-1-nhu-the-thay-tro-XEB~xsQsRFCg_2DR";
        }
Esempio n. 4
0
        /// <summary>
        /// add hostTag to listHost
        /// </summary>
        /// <param name="listHost">listHost</param>
        /// <param name="hostTag">hostTag</param>
        /// <param name="Update">true= replace hostTag in listHost when hostTag exits in listhost</param>
        /// <returns>false= add hostTag to listHost
        /// true = Update hostTag in listHost (Update=true)
        /// </returns>
        public static bool UpdateHostTag(ListHost listHost, HostTag hostTag, bool Update)
        {
            if (Lib.FindHostTagWithUrl(hostTag.Host, listHost) == null)
            {
                listHost.tag.Add(hostTag);
                return(false);
            }
            if (Update)
            {
                for (int i = 0; i < listHost.tag.Count; i++)
                {
                    if (listHost.tag[i].Host.IndexOf(hostTag.Host) >= 0)
                    {
                        listHost.tag[i] = hostTag;
                        break;
                    }
                }
            }

            return(true);
        }
Esempio n. 5
0
        private void Button_TestFullTag_Click(object sender, RoutedEventArgs e)
        {
            Web_Document doc = new Web_Document("");

            doc.UpdateDocumentWithNewUrl(this.textBox_Url_Test.Text);

            //TAG.Host = "wikidich";
            //this.TextBox_Result.Text = doc.ToString();
            ListHost ls = new ListHost();

            ls.tag.Add(TAG);
            doc.IntListHost(ls);

            doc.DetectHost(this.textBox_Url_Test.Text);

            String data = doc.GetContentInDocument(Web_Document.IndexOfArray_BookName) + Environment.NewLine;

            data += doc.GetContentInDocument(Web_Document.IndexOfArray_ChapName) + Environment.NewLine;
            data += doc.GetContentInDocument(Web_Document.IndexOfArray_ChapContent) + Environment.NewLine;
            data += doc.GetContentInDocument(Web_Document.IndexOfArray_UrlNext) + Environment.NewLine;
            this.TextBox_Result.Text = data;
        }
Esempio n. 6
0
 /// <summary>
 /// find hostTag whit url
 /// </summary>
 /// <param name="url">url-ex:https://wikidich.com/truyen/xxxx  </param>
 /// <param name="listhost"></param>
 /// <returns> HostTag or null </returns>
 public static HostTag FindHostTagWithUrl(String url, ListHost listhost)
 {
     if (listhost == null)
     {
         return(null);
     }
     if (listhost.tag == null)
     {
         return(null);
     }
     foreach (var ee in listhost.tag)
     {
         if (ee.Host != null)
         {
             if (url.IndexOf(ee.Host) >= 0)
             {
                 return(ee);
             }
         }
     }
     return(null);
 }
Esempio n. 7
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            HostTag TAG = new HostTag();

            int    index = (this.comboBox_Tag.SelectedItem as ItemComboBox).Value;
            String test  = (this.comboBox_Tag.SelectedItem.ToString());

            TAG = GetHostFromForm();

            test += "  " + (this.comboBox_Type.SelectedItem as ItemComboBox).Value;
            test += "  \"" + this.TextBox_Name.Text + "\"";
            test += "  " + (this.comboBox_TypeToGet.SelectedItem as ItemComboBox).Value;
            test += "  " + Int16.Parse(this.textBox_Index.Text);
            test += "  " + (this.comboBox_Att_Type_Compare.SelectedItem as ItemComboBox).Value;
            test += "  \"" + this.textBox_StrToCompare.Text + "\"";
            test += "  " + (this.comboBox_Att_Type_Get.SelectedItem as ItemComboBox).Value;



            Web_Document doc = new Web_Document("");

            doc.UpdateDocumentWithNewUrl(this.textBox_Url_Test.Text);

            //TAG.Host = "wikidich";
            //this.TextBox_Result.Text = doc.ToString();
            ListHost ls = new ListHost();

            ls.tag.Add(TAG);
            doc.IntListHost(ls);

            doc.DetectHost(this.textBox_Url_Test.Text);

            String data = doc.GetContentInDocument((Int16)index);

            this.TextBox_Result.Text = data;

            this.TextBox_Result.Text += Environment.NewLine + test;
        }
Esempio n. 8
0
 /// <summary>
 /// add list host (ListHost) to Web Document
 /// </summary>
 /// <param name="listHost">list host in ListHost</param>
 public void IntListHost(ListHost listHost)
 {
     this.ListHost = listHost;
 }