Example #1
0
 public bool addEvent(Event d)
 {
     try
     {
         if (MySqlConnection.State == System.Data.ConnectionState.Open)
         {
             //lets add it.
             MySqlCommand cmd = new MySqlCommand("INSERT INTO `events` (`title`,`time`,`date`,`description`,`location`,`from`)VALUES(?title,?time,?date,?desc,?location,?from);", MySqlConnection);
             cmd.Parameters.AddWithValue("?title", d.Title);
             cmd.Parameters.AddWithValue("?time", d.Time);
             cmd.Parameters.AddWithValue("?desc", d.Description);
             cmd.Parameters.AddWithValue("?location", d.Location);
             cmd.Parameters.AddWithValue("?from", d.From);
             cmd.Parameters.AddWithValue("?date", d.Date);
             cmd.ExecuteNonQuery();
             return true;
         }
     }
     catch (Exception eee)
     {
         GlobalHandlers.Debugger.write(eee.ToString());
         return false;
     }
     return false;
 }
Example #2
0
        public string getEventJsonFromEvent(Event d)
        {
            eventjson jsonEvent = new eventjson();
            jsonEvent.title = d.Title;
            jsonEvent.id = d.ID;
            jsonEvent.description = d.Description;

            bool allDay = false;
            DateTime start = new DateTime(2012, 7, 18, 20, 25, 26, 0);
            DateTime end = new DateTime(2012, 7, 18, 20, 26, 26, 0);
            bool noEnd = false;
            if (d.Time == "allday")
            {
                allDay = true;
            }
            else
            {
                //is not all day, parse the times.
                try
                {
                    if (!d.Time.Contains("-"))
                    {
                        //its only the start
                        //then lets just parse the start.
                        noEnd = true;
                        end = getTime(d.Time, d.Date);
                        jsonEvent.setEndTime(end);
                     //   jsonEvent.end = end;
                    }
                    string[] splitted = d.Time.Split(char.Parse("-"));
                    if (splitted.Length == 2)
                    {
                        string firstTime = splitted[0];
                        start = getTime(firstTime, d.Date);
                        string endTime = splitted[1];
                        end = getTime(endTime, d.Date);
                        jsonEvent.setEndTime(end);
                        jsonEvent.setStartTime(start);
                    }

                }
                catch (Exception ee)
                {
                    Debug.WriteLine(ee);
                }
            }
            if (noEnd)
            {
                return "";
                //jsonEvent.end = jsonEvent.start;
            }
            else
            {
                var serializer = new JavaScriptSerializer();
                return serializer.Serialize(jsonEvent) + ",";
                //Response.Write(serializer.Serialize(list));
            }
        }
Example #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //lets add an event.
            bool noEnd = checkbox.Checked;
            Event eventToAdd = new Event();
            string Event_Title = String.Empty;
            string Event_Time = String.Empty;
            string Event_Date = String.Empty;
            string Event_Desc = String.Empty;
            string Event_Loc = String.Empty;
            string Event_Room = String.Empty; //coming soon
            if (noEnd)
            {
                //ok.. so lets just set the starting time.
                Event_Time = starttime.Text;
            }
            else
            {
                Event_Time = starttime.Text + "-" + endtime.Text;
            }
            Event_Title = title.Text;
            Event_Date = date.Text;
            Event_Desc = desc.Text;
            Event_Loc = getLongLat();

            eventToAdd.Title = Event_Title;
            eventToAdd.Time = Event_Time;
            eventToAdd.Location = Event_Loc;
            eventToAdd.Date = Event_Date;
            eventToAdd.Description = Event_Desc;
            eventToAdd.From = "0";
            if (GlobalHandlers.DatabaseHandler.addEvent(eventToAdd))
            {
                Response.Redirect("default.aspx", false);
            }
            //Debug.WriteLine("Title: " + Event_Title + " : Date: " + Event_Date + " : Desc: " + Event_Desc + " : Loc: " + Event_Loc);
              //  string timeStartEvent =
        }
Example #4
0
        public List<Event> getEvents(bool justToday)
        {
            List<Event> events = new List<Event>();
            if (MySqlConnection.State == System.Data.ConnectionState.Open)
            {
                try
                {
                    MySqlCommand cmd = new MySqlCommand();
                    cmd.Connection = MySqlConnection;
                    if (justToday == true)
                    {
                        string dateToday = DateTime.Now.ToString("MM/dd/yyyy");
                        Debug.WriteLine("dateToday: " + dateToday);
                        cmd.CommandText = "SELECT * FROM `events` WHERE `date` = '" + dateToday + "';";
                    }
                    else if (justToday == false)
                    {
                        cmd.CommandText = "SELECT * FROM `events`";
                    }
                    using(MySqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.HasRows == false)
                        {
                            reader.Close();
                            cmd.Dispose();
                            Debug.WriteLine("no events returned");
                            return events;
                        }
                        while (reader.Read())
                        {
                            string id = reader["eventid"].ToString();
                            string title = reader["title"].ToString();
                            string time = reader["time"].ToString();
                            string date = reader["date"].ToString();
                            string desc = reader["description"].ToString();
                            string loc = reader["location"].ToString();
                            string from = reader["from"].ToString();
                            Event eventx = new Event();
                            eventx.ID = id;
                            eventx.Title = title;
                            eventx.Time = time;
                            eventx.Date = date;
                            eventx.Description = desc;
                            eventx.Location = loc;
                            eventx.From = from;
                            events.Add(eventx);

                        }
                        reader.Close();
                    }
                    return events;
                }
                catch (MySqlException Ex)
                {
                    GlobalHandlers.Debugger.write(Ex.ToString());
                    return events;

                }
            }
            return events;
        }
Example #5
0
 public Event getEventById(string id)
 {
     Event d = new Event();
     try
     {
         if (MySqlConnection.State == System.Data.ConnectionState.Open)
         {
             MySqlCommand cmd = new MySqlCommand("SELECT * FROM `events` WHERE `eventid` = ?id", MySqlConnection);
             cmd.Parameters.AddWithValue("?id", id);
             using (MySqlDataReader reader = cmd.ExecuteReader())
             {
                 if (reader.HasRows == false)
                 {
                     reader.Close();
                     cmd.Dispose();
                     return null;
                 }
                 while (reader.Read())
                 {
                     //lets get all the info we need.
                     d.Title = reader["title"].ToString();
                     d.Time = reader["time"].ToString();
                     d.Date = reader["date"].ToString();
                     d.Description = reader["description"].ToString();
                     d.Location = reader["location"].ToString();
                     d.From = reader["from"].ToString();
                 }
             }
             d.Filter = getFilterFromLocation(d.Location);
             cmd.Dispose();
             return d;
         }
         return null; //connection not open
     }
     catch (Exception eee)
     {
         GlobalHandlers.Debugger.write(eee.ToString());
         return null; //error
     }
 }
Example #6
0
        public static List<Event> parseRSS(RSSHelper.Channel channel)
        {
            List<Event> listOFEventsToReturn = new List<Event>();
            foreach (var item in channel.Items)
            {
                string title = String.Empty;
                string desc = String.Empty;
                string Location = string.Empty;
                string time = String.Empty;
                Filter fitler = new Filter();
                Event events = new Event();

                string letsGetInfoFromThis = item.Description;
                try
                {
                    title = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(item.Title);
                    title = cleanUpSpaces(title);
                    letsGetInfoFromThis = letsGetInfoFromThis.Replace(item.Title, "");
                    letsGetInfoFromThis = cleanUpMain(letsGetInfoFromThis);
                    //gets now get the date out
                    letsGetInfoFromThis = removeDate(letsGetInfoFromThis);
                    //  Debug.WriteLine("Info: "  +letsGetInfoFromThis + ":Title:"+title);
                    string commentSection = getCommentSection(letsGetInfoFromThis);
                    desc = cleanUpSpaces(commentSection);
                    time = getTime(letsGetInfoFromThis).getTimeRangeString();

                    //  Debug.WriteLine("Found time of: " + getTime(letsGetInfoFromThis).getTimeRangeString());
                    Filter d = getLocation(letsGetInfoFromThis);
                    if (d != null)
                    {
                        //good. we found the location - lets return it now
                        fitler = d;
                    }
                    else if(d == null)
                    {
                        d = GlobalHandlers.DatabaseHandler.getDefaultFilter();
                    }

                    events.Description = desc;
                    events.From = "0";
                    events.Filter = d;
                    events.Time = time;
                    events.Title = title;
                    events.Date = DateTime.Now.ToString("MM/dd/yyyy");
                    Debug.WriteLine("date: " + events.Date);
                    listOFEventsToReturn.Add(events);

                    Debug.WriteLine("Title: " + events.Title + " Desc: " + events.Description + " Filter Name: " + events.Filter.Name + " LongLat: " + events.Filter.Long + "," + events.Filter.Lat + " Time: " + events.Time);

                    //Debug.WriteLine("Rest:" + letsGetInfoFromThis + "Time:" + getTime(letsGetInfoFromThis).getTimeRangeString() + "Title:" + title + "Comments:" + commentSection);
                }
                catch (Exception eee)
                {
                    GlobalHandlers.Debugger.write(eee.ToString());
                }

                //  Debug.WriteLine("Title: " +item.Title + ":" + item.Description);

            }
            return listOFEventsToReturn;
        }
Example #7
0
 public Score getScoreFromEvent(Event eventD)
 {
     string longString = eventD.Description + " " + eventD.Title;
     return new Score();
 }