Exemple #1
0
    public CalendarData GetCalData()
    {
        WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin", "*");

        List <Event> _events = new List <Event>()
        {
            new Event()
            {
                Id                    = 1,
                Subject               = "Test",
                StartDate             = JSDateTime.ToStr(DateTime.UtcNow.AddHours(5.5).Date),
                EndDate               = JSDateTime.ToStr(DateTime.UtcNow.AddHours(5.5).Date.AddHours(11)),
                IsAllDayEvent         = 1,
                IsEditable            = 1,
                IsMoreThanOneDayEvent = 0,
                Attendents            = "",
                Location              = "Noida",
                RecurringEvent        = 0,
                Color                 = 2
            },

            new Event()
            {
                Id                    = 2,
                Subject               = "More Test",
                StartDate             = JSDateTime.ToStr(DateTime.UtcNow.AddHours(5.5).Date.AddDays(1)),
                EndDate               = JSDateTime.ToStr(DateTime.UtcNow.AddHours(5.5).Date.AddHours(45)),
                IsAllDayEvent         = 1,
                IsEditable            = 1,
                IsMoreThanOneDayEvent = 0,
                Attendents            = "",
                Location              = "Delhi",
                RecurringEvent        = 0,
                Color                 = 4
            }
        };


        CalendarData objCalData = new CalendarData();

        objCalData.events = new List <ArrayList>();

        foreach (var item in _events)
        {
            objCalData.events.Add(ConvertToArrayList <Event>(item));
        }

        objCalData.issort = true;
        objCalData.start  = JSDateTime.ToStr(new DateTime(2013, 7, 1));
        objCalData.end    = JSDateTime.ToStr(new DateTime(2013, 7, 31));
        objCalData.error  = null;
        return(objCalData);
    }
Exemple #2
0
        public CalendarData GetCalData()
        {
            WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin", "*");
            List <Event> list2 = new List <Event>();
            Event        item  = new Event {
                Id                    = 1,
                Subject               = "Test",
                StartDate             = JSDateTime.ToStr(DateTime.Now.Date),
                EndDate               = JSDateTime.ToStr(DateTime.Now.Date.AddHours(11.0)),
                IsAllDayEvent         = 1,
                IsEditable            = 0,
                IsMoreThanOneDayEvent = 0,
                Attendents            = "",
                Location              = "Noida",
                RecurringEvent        = 0,
                Color                 = 2
            };

            list2.Add(item);
            Event event4 = new Event {
                Id                    = 2,
                Subject               = "More Test",
                StartDate             = JSDateTime.ToStr(DateTime.Now.Date.AddDays(1.0)),
                EndDate               = JSDateTime.ToStr(DateTime.Now.Date.AddHours(45.0)),
                IsAllDayEvent         = 1,
                IsEditable            = 0,
                IsMoreThanOneDayEvent = 0,
                Attendents            = "",
                Location              = "Delhi",
                RecurringEvent        = 0,
                Color                 = 4
            };

            list2.Add(event4);
            List <Event> list = list2;
            CalendarData data = new CalendarData {
                events = new List <ArrayList>()
            };

            foreach (Event event2 in list)
            {
                data.events.Add(this.ConvertToArrayList <Event>(event2));
            }
            data.issort = true;
            data.start  = JSDateTime.ToStr(new DateTime(0x7dd, 7, 1));
            data.end    = JSDateTime.ToStr(new DateTime(0x7dd, 7, 0x1f));
            data.error  = null;
            return(data);
        }
Exemple #3
0
    public CalendarData listCalendarByRange(DateTime sd, DateTime ed)
    {
        CalendarData objCalData = new CalendarData();

        objCalData.events = new List <ArrayList>();

        try
        {
            List <Event> _events = new List <Event>();


            using (SqlConnection conn = new SqlConnection(connDietDB))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    cmd.Connection  = conn;
                    cmd.CommandText = "select * from dbo.jqcalendar where StartTime between @StartTime and @EndTime and SessionCode in " +
                                      "(select ISNULL(PARENT_ID,'') from admin_maps_user_master k where USER_NAME='" + Convert.ToString(HttpContext.Current.Session["UserCode"]) + "'  UNION 	select Isnull(USER_NAME,'') from admin_maps_user_master k where PARENT_ID='"+ Convert.ToString(HttpContext.Current.Session["UserCode"]) + "' UNION SELECT '" + Convert.ToString(HttpContext.Current.Session["UserCode"]) + "')";

                    cmd.Parameters.Add("@StartTime", SqlDbType.DateTime).Value = sd;
                    cmd.Parameters.Add("@EndTime", SqlDbType.DateTime).Value   = ed;

                    using (SqlDataAdapter da = new SqlDataAdapter())
                    {
                        da.SelectCommand = cmd;

                        using (DataTable dt = new DataTable())
                        {
                            da.Fill(dt);
                            foreach (DataRow row in dt.Rows)
                            {
                                DateTime startDate = Convert.ToDateTime(row["StartTime"].ToString());
                                DateTime endDate   = Convert.ToDateTime(row["EndTime"].ToString());

                                Event _event = new Event();

                                _event.Id                    = Convert.ToInt32(row["Id"].ToString());
                                _event.Subject               = row["Subject"].ToString();
                                _event.StartDate             = JSDateTime.ToStr(startDate);
                                _event.EndDate               = JSDateTime.ToStr(endDate);
                                _event.Location              = row["Location"].ToString();
                                _event.Description           = row["Description"].ToString();
                                _event.IsAllDayEvent         = Convert.ToInt16(row["IsAllDayEvent"].ToString());
                                _event.IsEditable            = 1;
                                _event.IsMoreThanOneDayEvent = 0;
                                _event.Attendents            = "";
                                _event.RecurringEvent        = 0;
                                _event.Color                 = Convert.ToInt16((row["Color"].ToString() != "") ? row["Color"].ToString() : "-1");
                                _event.CustomerID            = Convert.ToInt64((row["CustID"].ToString() != "") ? row["CustID"].ToString() : "0");
                                _events.Add(_event);
                                _event = null;
                            }
                        }
                    }
                }
            }


            foreach (var item in _events)
            {
                objCalData.events.Add(ConvertToArrayList <Event>(item));
            }

            objCalData.issort = true;
            objCalData.start  = JSDateTime.ToStr(sd);
            objCalData.end    = JSDateTime.ToStr(ed);
            objCalData.error  = null;
        }
        catch (Exception ex)
        {
            objCalData.error = ex.Message;
        }


        return(objCalData);
    }