Esempio n. 1
0
        private List <AntonymDTO> getListOfAntonyms(string temp)
        {
            List <AntonymDTO> results = new List <AntonymDTO>();
            int    locationA          = 0;
            int    locationB          = 0;
            string ulSubstring        = string.Empty;

            locationA   = temp.IndexOf("<ul>");
            locationB   = temp.IndexOf("</div>", locationA);
            ulSubstring = temp.Substring(locationB);

            while (ulSubstring.Contains("data-complexity"))
            {
                locationA = ulSubstring.IndexOf("<li>");
                locationB = ulSubstring.IndexOf("</li>");
                string li = ulSubstring.Substring(locationA, locationB + 5 - locationA);
                ulSubstring = ulSubstring.Substring(locationB + 5);
                locationA   = li.IndexOf("data-complexity=");
                locationA   = locationA + "data-complexity=".Length;
                locationA   = li.IndexOf('"', locationA);
                locationB   = li.IndexOf('"', locationA + 1);
                string complexity = li.Substring(locationA + 1, locationB - locationA - 1);
                locationA = li.IndexOf("<span class=\"text\">");
                locationA = locationA + "<span class=\"text\">".Length;
                locationB = li.IndexOf("<", locationA);
                string     ant = li.Substring(locationA, locationB - locationA);
                AntonymDTO tmp = new AntonymDTO();
                tmp.complexity = int.Parse(complexity);
                tmp.word       = ant;
                results.Add(tmp);
            }

            return(results);
        }
Esempio n. 2
0
        private void insertAntonyms(int wordId, AntonymDTO wd)
        {
            try
            {
                using (SqlCommand cmd = new SqlCommand("sp_insert_Antonym", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@wordID", SqlDbType.Int).Value     = wordId;
                    cmd.Parameters.Add("@ant", SqlDbType.VarChar).Value    = wd.word;
                    cmd.Parameters.Add("@complexity", SqlDbType.Int).Value = wd.complexity;
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                throw;
            }
        }