Beispiel #1
0
    public void InstantiateIn(System.Web.UI.Control container)
    {
        PlaceHolder ph = new PlaceHolder();

        string        host = HttpContext.Current.Request.Url.AbsolutePath;
        List <String> days = new List <string>();

        days.Add("Monday");
        days.Add("Tuesday");
        days.Add("Wednesday");
        days.Add("Thursday");
        days.Add("Friday");
        days.Add("Saturday");
        days.Add("Sunday");

        List <String> times = new List <string>();

        times.Add("8:00");
        times.Add("9:00");
        times.Add("10:00");
        times.Add("11:00");
        times.Add("12:00");
        times.Add("13:00");
        times.Add("14:00");
        times.Add("15:00");
        times.Add("16:00");
        times.Add("17:00");
        times.Add("18:00");
        times.Add("19:00");
        times.Add("20:00");
        times.Add("21:00");
        times.Add("22:00");

        List <String> colours = new List <string>();

        colours.Add("#fbcf61");
        colours.Add("#ff6f6f");
        colours.Add("#3498db");
        colours.Add("#a8d164");
        colours.Add("#b23f73");
        colours.Add("#48647c");
        colours.Add("#0dccc0");
        colours.Add("#832d51");
        colours.Add("#e84b3a");
        colours.Add("#c0392b");

        switch (templateType)
        {
        case ListItemType.Header:
            ph.Controls.Add(new LiteralControl("<div class='week'>" + Convert.ToString(GetWeekNo(Gettoday(add))) + "</div>"));
            ph.Controls.Add(new LiteralControl("<div class='calendarbody'>"));
            ph.Controls.Add(new LiteralControl("<div class='timebody'>"));
            ph.Controls.Add(new LiteralControl("<div class='time'><a id='click'>Week View</a></div>"));
            for (int i = 0; i < times.Count; i++)
            {
                ph.Controls.Add(new LiteralControl("<div class='time'>" + times[i] + "</div>"));
            }
            ph.Controls.Add(new LiteralControl("</div>"));

            break;

        case ListItemType.Item:
            string userid = HttpContext.Current.Session["userID"].ToString();

            getCalendar gc = new getCalendar();
            getEvent    ge = new getEvent();
            getNote     gn = new getNote();



            customevents ce = new customevents();
            ce.overallID  = "getEventInfo";
            ce.CalenderID = "1";

            // ARRAYS

            var       Cal    = JsonConvert.DeserializeObject <List <calendar> >(gc.dc(userid));
            ESObject0 obj    = ge.getCBSEvents();
            var       Events = JsonConvert.DeserializeObject <List <customevents> >(ge.getEvents(ce));

            for (int o = 0; o < days.Count; o++)
            {
                ph.Controls.Add(new LiteralControl("<div class='weekdaybody'>"));

                //GET EVENTS

                List <String> type = new List <String>();

                int y;
                int m;
                int d;

                int sh;
                int sm;

                int eh;
                int em;

                int startpos;
                int endpos;
                int duration;

                for (int e = 0; e < obj.events.Count(); e++)
                {
                    y = Int32.Parse(obj.events[e].start[0]);
                    m = Int32.Parse(obj.events[e].start[1]);
                    d = Int32.Parse(obj.events[e].start[2]);

                    if (checkweek(y, m, d, o))
                    {
                        sh = Int32.Parse(obj.events[e].start[3]);
                        sm = Int32.Parse(obj.events[e].start[4]);

                        eh = Int32.Parse(obj.events[e].end[3]);
                        em = Int32.Parse(obj.events[e].end[4]);

                        startpos = ((sh - 8) * 60) + sm + 60;
                        endpos   = ((eh - 8) * 60) + em + 60;
                        duration = endpos - startpos;

                        ph.Controls.Add(new LiteralControl("<div class='event' style='top:" + startpos + "px;" + " height:" + duration + "px; background-color:" + colours[8] + ";'>"));
                        ph.Controls.Add(new LiteralControl("<a href='" + host + "?activityID=" + obj.events[e].eventid + "'>"));
                        ph.Controls.Add(new LiteralControl("<div class='eventtime'>" + obj.events[e].start[3] + ":" + obj.events[e].start[4] + "-" + obj.events[e].end[3] + ":" + obj.events[e].end[4] + "</div> <br />"));
                        ph.Controls.Add(new LiteralControl(obj.events[e].description + "<br /><br />"));
                        ph.Controls.Add(new LiteralControl("Location: " + obj.events[e].location + "<br />"));
                        ph.Controls.Add(new LiteralControl(obj.events[e].type + "<br />"));
                        ph.Controls.Add(new LiteralControl("</a>"));
                        ph.Controls.Add(new LiteralControl("</div>"));
                    }
                }
                ph.Controls.Add(new LiteralControl("<div class='weekday no-bg'>" + days[o] + "<br /><span class='date'>" + daysfromtoday(days[o]) + "</span></div"));
                for (int t = 0; t <= times.Count; t++)
                {
                    ph.Controls.Add(new LiteralControl("<div class='weekday'></div>"));
                }
                ph.Controls.Add(new LiteralControl("</div>"));
            }

            break;

        case ListItemType.Footer:
            ph.Controls.Add(new LiteralControl("</div>"));
            break;
        }
        container.Controls.Add(ph);
    }
    public void populate()
    {
        string userid = Session["userID"].ToString();
        quot   q      = new quot();

        q.overallID = "getQuote";
        getQuote gq  = new getQuote();
        var      quo = JsonConvert.DeserializeObject <quot>((gq.gQ(q)));

        Quoteotd.Text = "Quote: " + quo.quote + "Author: " + quo.author;

        getCalendar gc  = new getCalendar();
        getEvent    ge  = new getEvent();
        getNote     gn  = new getNote();
        var         Cal = JsonConvert.DeserializeObject <List <calendar> >(gc.dc(userid));


        if (Cal.Count > 0)
        {
            for (int i = 0; i < Cal.Count; i++)
            {
                var item = new ListItem
                {
                    Text  = Cal[i].calenderName,
                    Value = Cal[i].CalendarID
                };
                deleteCalendarName.Items.Add(item);
                createEventCalendar.Items.Add(item);
            }

            customevents e = new customevents();
            e.overallID = "getEventInfo";
            for (int o = 0; o < Cal.Count; o++)
            {
                e.CalenderID = Cal[o].CalendarID;
                var Events = JsonConvert.DeserializeObject <List <customevents> >(ge.getEvents(e));

                if (Events.Count > 0)
                {
                    var item = new ListItem
                    {
                        Text  = Events[o].name,
                        Value = Events[o].eventid
                    };
                    deleteEventName.Items.Add(item);
                    createNoteEvents.Items.Add(item);
                }
                note n = new note();
                n.overallID = "getNote";

                for (int a = 0; a < Events.Count; a++)
                {
                    n.eventid = Events[a].eventid;
                    var Notes = JsonConvert.DeserializeObject <List <note> >(gn.gn(n));

                    if (Notes.Count > 0)
                    {
                        var item = new ListItem
                        {
                            Text  = Notes[a].noteText,
                            Value = Notes[a].noteId
                        };

                        deleteNoteName.Items.Add(item);
                    }
                }
            }
        }
        else
        {
            var item = new ListItem
            {
                Text = "None found"
            };
            deleteCalendarName.Items.Add(item);
            createEventCalendar.Items.Add(item);
            deleteEventName.Items.Add(item);
            createNoteEvents.Items.Add(item);
            deleteNoteName.Items.Add(item);
        }
    }