Пример #1
0
        public static List <NDData> GetAllWithDate(String Date, userModel user)
        {
            List <NDData> data = new List <NDData>();

            using (SqlConnection cnn = new SqlConnection(CONNECTIONSTRING))
                using (SqlCommand cmd = new SqlCommand("select * from NazData", cnn))
                {
                    cnn.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            String test   = reader["DateandTime"].ToString();
                            int    testId = int.Parse(reader["UserID"].ToString());
                            if (test.Contains(Date.Trim()) && testId == user.ID)
                            {
                                NDData entry = new NDData();
                                entry.TimeandDate = test;
                                entry.Title       = reader["Title"].ToString();
                                entry.Data        = reader["DataText"].ToString();
                                entry.Symbol      = reader["Symbol"].ToString();

                                data.Add(entry);
                            }
                        }
                    }
                    cnn.Close();
                }

            return(data);
        }
Пример #2
0
        public static List <NDData> parseString(List <HtmlNode> cleanedNodes, TitleAndLink titleLink)
        {
            List <NDData> toBeReturned = new List <NDData>();

            foreach (HtmlNode item in cleanedNodes)
            {
                String baseText = item.InnerHtml;

                String[] paragraphs = System.Text.RegularExpressions.Regex.Split(item.InnerHtml, @"\s{4,}");

                foreach (String paragraph in paragraphs)
                {
                    //Console.WriteLine("\tPARAGRAPH: " + paragraph);

                    String[] splitData = paragraph.Split(':');

                    if (splitData.Length <= 1)
                    {
                        continue;
                    }

                    String dataNeeded = splitData[1];

                    String Symbol = dataNeeded.Substring(0, dataNeeded.IndexOf(")")).Replace(")", "").Replace(",", "").Trim();
                    //Console.WriteLine("\tSYMBOL = " + Symbol);

                    dataNeeded = dataNeeded.Remove(0, dataNeeded.IndexOf(")")).Replace(")", "").TrimStart();

                    if (dataNeeded[0] == ',')
                    {
                        //Console.WriteLine("The first char is a ,");
                        dataNeeded = dataNeeded.Remove(0, 1);
                        dataNeeded = dataNeeded.TrimStart();
                    }

                    dataNeeded = dataNeeded[0].ToString().ToUpper() + dataNeeded.Substring(1);

                    //Console.WriteLine("\tDATA = " + dataNeeded + "\n");

                    NDData data = new NDData();

                    data.Symbol      = Symbol;
                    data.Data        = dataNeeded;
                    data.TimeandDate = titleLink.Time;
                    data.Title       = titleLink.Title;

                    toBeReturned.Add(data);
                }
            }

            return(toBeReturned);
        }
Пример #3
0
        public static void Insert(NDData item, userModel user)
        {
            using (SqlConnection cnn = new SqlConnection(CONNECTIONSTRING))
                using (SqlCommand cmd = new SqlCommand(INSERTDATA, cnn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@Title", item.Title);
                    cmd.Parameters.AddWithValue("@Date", item.TimeandDate);
                    cmd.Parameters.AddWithValue("@Symbol", item.Symbol);
                    cmd.Parameters.AddWithValue("@Data", item.Data);
                    cmd.Parameters.AddWithValue("@UserID", user.ID);

                    cnn.Open();
                    cmd.ExecuteNonQuery();
                    cnn.Close();
                }
        }