Esempio n. 1
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));
            }
        }
Esempio n. 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));
            }
        }