public static int HTMLParsingQuest(string str)
        {
            /*Строковые метки*/
            string questBegin    = $"<div class=\"questBox__quest\">";
            string questEnd      = "</div>";
            string AnswerBegin   = $"   <div class=\"questBox__answer\"><div> &#10004;</div>";
            string UnAnswerBegin = $"   <div class=\"questBox__unanwser\"><div> &#10008;</div>";
            string AnswerEnd     = "</div>" + "\n";
            string comentBegin   = "<summary>ПОЯСНЕНИЕ:</summary><div>";
            string comentEnd     = "</div></details>";

            /*Старт*/
            string[]  separator = { "\n", "\r" };
            string[]  lineItem  = str.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            QuestItem questItem = null;
            int       count     = 0;

            foreach (string line in lineItem)
            {
                string temp;
                try
                {
                    if (line.IndexOf(questBegin) >= 0)
                    {
                        if (questItem != null && !EditionTXT.if_ThereQuest(questItem.quest))
                        {
                            questItem.Description = questItem.ToolTypeListBox(); QuestsBox.questItems.Add(questItem); count++;
                        }
                        questItem       = new QuestItem();
                        temp            = line.Replace(questBegin, "");
                        temp            = temp.Replace(questEnd, "");
                        temp            = temp.Remove(0, temp.IndexOf(')') + 2);
                        questItem.quest = temp;
                    }
                    else if (line.IndexOf(AnswerBegin) == 0)
                    {
                        temp = line.Replace(AnswerBegin, "");
                        temp = temp.Replace(AnswerEnd, "");
                        Answer tempAns = new Answer(temp, true);
                        questItem.answerItem.Add(tempAns);
                    }
                    else if (line.IndexOf(UnAnswerBegin) == 0)
                    {
                        temp = line.Replace(UnAnswerBegin, "");
                        temp = temp.Replace(AnswerEnd, "");
                        Answer tempAns = new Answer(temp, false);
                        questItem.answerItem.Add(tempAns);
                    }
                    else if (line.IndexOf("КОММЕНТАРИЙ:") == 0)
                    {
                        temp = line.Replace(comentBegin, "");
                        temp = temp.Replace(comentEnd, "");
                        questItem.comment = temp;
                    }
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show(e.ToString());
                    /*Просто игнорируем*/
                }
            }
            if (questItem != null && !EditionTXT.if_ThereQuest(questItem.quest))
            {
                questItem.Description = questItem.ToolTypeListBox(); QuestsBox.questItems.Add(questItem); count++;
            }
            return(count);
        }
Пример #2
0
		private static int parsing_quest(string str)
		{
			string[] separator = { "\n", "\r" };
			string[] lineItem = str.Split(separator, StringSplitOptions.RemoveEmptyEntries);
			QuestItem questItem = null;
			int count = 0;

			foreach (string line in lineItem)
			{
				try
				{
					//	string line = _line.Replace("\n", "");
					//line = line.Replace("\r", "");

					if (line.IndexOf("ВОПРОС:") >= 0)
					{
						if (questItem != null)
						{
							questItem.EndlForSpase();
							if (!if_ThereQuest(questItem.quest))
							{
								questItem.Description = questItem.ToolTypeListBox();
								QuestsBox.questItems.Add(questItem);
								count++;
							}
						}
						questItem = new QuestItem();
						questItem.quest = line.Substring(line.LastIndexOf("ВОПРОС: ") + 8);
					}
					else if (line.IndexOf("ВЕРНО:") == 0)
					{
						Answer temp = new Answer(line.Substring(7), true);
						questItem.answerItem.Add(temp);
					}
					else if (line.IndexOf("НЕ ВЕРНО:") == 0)
					{
						Answer temp = new Answer(line.Substring(10), false);
						questItem.answerItem.Add(temp);
					}
					else if (line.IndexOf("КОММЕНТАРИЙ:") == 0)
					{
						questItem.comment = line.Substring(13);
					}
				}
				catch (Exception e)
				{
					System.Windows.MessageBox.Show(e.ToString());
					/*Просто игнорируем*/
				}
			}
			if (questItem != null)
			{
				questItem.EndlForSpase();
				if (!if_ThereQuest(questItem.quest))
				{
					questItem.Description = questItem.ToolTypeListBox();
					QuestsBox.questItems.Add(questItem);
					count++;
				}
			}
			return count;
		}