コード例 #1
0
        public async Task <Report> AddReportAsync(Report report)
        {
            List <Event> events = _dal.GetEvents(e => e.StartTime <= EntityFunctions.AddMinutes(report.Time, 5).Value&&
                                                 e.EndTime >= EntityFunctions.AddMinutes(report.Time, -5).Value).ToList();

            /*(from e in GetEvents()
             *                where e.StartTime <= report.Time.AddMinutes(10) &&
             *                e.EndTime >= report.Time.AddMinutes(-10)
             * select e).ToList();*/

            if (events.Count == 1)
            {
                Event e = modifyEvent(events[0], report);

                UpdateEvent(e);
                report.Event = e;
            }
            else if (events.Count > 1)
            {
                Event  closestEvent = events[0]; // initialize pointer for compare later
                double tmpInterval, minInterval = Math.Abs((report.Time - closestEvent.StartTime).TotalMinutes);

                foreach (Event ev in events) // check closest start time
                {
                    tmpInterval = Math.Abs((report.Time - ev.StartTime).TotalMinutes);
                    if (tmpInterval < minInterval)
                    {
                        minInterval  = tmpInterval;
                        closestEvent = ev;
                    }
                }

                foreach (Event ev in events) // check closest end time
                {
                    tmpInterval = Math.Abs((report.Time - ev.EndTime).TotalMinutes);
                    if (tmpInterval < minInterval)
                    {
                        minInterval  = tmpInterval;
                        closestEvent = ev;
                    }
                }
                Event e = modifyEvent(closestEvent, report); //after check with all the end and the start events we found the closest event.
                UpdateEvent(e);
                report.Event = e;
            }
            else// event.count == 0
            {
                report.Event = new Event(report.Time)
                {
                    StartTime = report.Time
                };
            }

            var res = await _dal.AddReportAsync(report);

            UpdateHits(report);
            return(res);
        }
コード例 #2
0
        private StatusData.Status GetCurrentStatusMinus30(int counterId, double minThreshold, double maxThreshold)
        {
            var stat = _context.Results
                       .Where(c => c.DeviceCounter.Id == counterId)
                       .Where(t => t.LogDate <= EntityFunctions.AddMinutes(DateTime.Now, -20) && t.LogDate >= EntityFunctions.AddMinutes(DateTime.Now, -30))
                       .FirstOrDefault();

            if (stat != null)
            {
                return(GetStatus(minThreshold, maxThreshold, stat.AverageRead, stat.DeviceCounter.Device.Name));
            }
            return(StatusData.Status.Green);
        }
コード例 #3
0
        private StatusData.Status GetCurrentDeviceCounterStatus(DeviceCounterBase counter)
        {
            var result = _context.Results
                         .Where(r => r.DeviceCounter.Id == counter.Id)
                         .Where(r => r.LogDate >= EntityFunctions.AddMinutes(DateTime.Now, -5))
                         .Select(r => r.AverageRead)
                         .FirstOrDefault();

            if (result <= counter.MinThreshold)
            {
                return(StatusData.Status.Green);
            }
            return(result >= counter.MaxThreshold ? StatusData.Status.Red : StatusData.Status.Yellow);
        }
コード例 #4
0
        public void DateTimeOffsetAddMinutes()
        {
            DateTimeOffset offset = stored.AddMinutes(-1);

#if !EFOLD
            var q = this.Entities
                    .Where(x =>
                           DbFunctions.AddMinutes(x.Offset, -1) == offset);
#else
            var q = this.Entities
                    .Where(x =>
                           EntityFunctions.AddMinutes(x.Offset, -1) == offset);
#endif

            q.Should().NotBeEmpty();
        }
コード例 #5
0
        public void DateTimeAddMinutes()
        {
            DateTime date = stored.AddMinutes(-1);

#if !EFOLD
            var q = this.Entities
                    .Where(x =>
                           DbFunctions.AddMinutes(x.DateTime, -1) == date);
#else
            var q = this.Entities
                    .Where(x =>
                           EntityFunctions.AddMinutes(x.DateTime, -1) == date);
#endif

            q.Should().NotBeEmpty();
        }
コード例 #6
0
        public void TimeAddMinutes()
        {
            TimeSpan time = stored.Add(TimeSpan.FromMinutes(-1));

#if !EFOLD
            var q = this.Entities
                    .Where(x =>
                           DbFunctions.AddMinutes(x.Time, -1) == time);
#else
            var q = this.Entities
                    .Where(x =>
                           EntityFunctions.AddMinutes(x.Time, -1) == time);
#endif

            q.Should().NotBeEmpty();
        }
コード例 #7
0
 /// <summary>
 /// Determina si el imputado ya tiene otra cita en otra area.
 /// </summary>
 /// <param name="fechaInicio">Fecha de inicio de la cita</param>
 /// <param name="fechaFin">Fecha Final de la cita</param>
 /// <param name="id_anio">id_anio del folio del ingreso</param>
 /// <param name="id_centro">id_centro del folio del ingreso</param>
 /// <param name="id_imputado">id_imputado del folio del ingreso</param>
 /// <param name="id_ingreso">id_ingreso del folio del ingreso</param>
 /// <param name="id_cita">id de la cita de la llave primaria</param>
 /// <param name="id_centro_ubi">id del centro de la llave primaria</param>
 /// <returns>Objeto AtencionCita</returns>
 public ATENCION_CITA ObtieneCitaOtraArea(short id_centro, short id_anio, int id_imputado, short id_ingreso, DateTime fechaInicio, DateTime fechaFin, int?id_cita = null, short?id_centro_ubi = null)
 {
     try
     {
         //revisar
         var predicate = PredicateBuilder.True <ATENCION_CITA>();
         predicate = predicate.And(w => w.CITA_FECHA_HORA <= fechaFin && EntityFunctions.AddMinutes(w.CITA_HORA_TERMINA, -1) >= fechaInicio &&
                                   w.INGRESO.ID_CENTRO == id_centro && w.INGRESO.ID_ANIO == id_anio && w.ID_IMPUTADO == id_imputado && w.ID_INGRESO == id_ingreso);
         if (id_cita.HasValue && id_centro_ubi.HasValue)
         {
             predicate = predicate.And(w => w.ID_CITA != id_cita.Value && w.ID_CENTRO_UBI == id_centro_ubi.Value);
         }
         return(GetData(predicate.Expand()).FirstOrDefault());
     }
     catch (Exception ex)
     {
         throw new ApplicationException(ex.Message + " " + (ex.InnerException != null ? ex.InnerException.InnerException.Message : ""));
     }
 }
コード例 #8
0
        public void UpdateExpiredStories()
        {
            var expiredStory = (from story in db.BigStories
                                where story.CurrentUser != null &&
                                DateTime.Now > EntityFunctions.AddMinutes(story.WhenLocked, story.HoursToWrite) &&
                                story.UnModeratedPost == null
                                select story).ToList();

            if (expiredStory.Any())
            {
                foreach (var story in expiredStory)
                {
                    story.CurrentUser.isWritting = false;
                    story.CurrentUser            = null;
                    story.WhenLocked             = null;
                    story.IsLocked = false;
                }

                db.SaveChanges();
            }
        }
コード例 #9
0
        public GraphData GetGraphDataForCounter(int deviceId, int counterID)
        {
            var AxisData = new GraphData
            {
                XYAxisData = new Dictionary <CounterDetails, IList <Result> >()
            };

            var counters = (from c in _context.DeviceCounters where c.Device.Id == deviceId where c.Deleted != 1 where c.Id == counterID select c).ToList();

            foreach (var counter in counters)
            {
                var key = new CounterDetails
                {
                    Counter = new CounterBase
                    {
                        Description  = counter.GetDescription(),
                        LogInterval  = counter.LogInterval,
                        MaxThreshold = (int)counter.MaxThreshold,
                        MinThreshold = (int)counter.MinThreshold,
                        ReadInterval = counter.ReadInterval
                    }
                };
                var stat = _context.Results
                           .Where(c => c.DeviceCounter.Id == counter.Id)
                           .Where(t => t.LogDate <= DateTime.Now && t.LogDate >= EntityFunctions.AddMinutes(DateTime.Now, -2))
                           .FirstOrDefault();

                var values = _context.Results
                             .Where(c => c.DeviceCounter.Id == counter.Id)
                             .Where(t => t.LogDate <= DateTime.Now && t.LogDate >= EntityFunctions.AddMinutes(DateTime.Now, -2))
                             .ToList();


                AxisData.XYAxisData.Add(key, values);
            }

            return(AxisData);
        }
コード例 #10
0
        public StatusData.Trends GetCounterTrend(int counterId, double threshold, int startTime, int endTime)
        {
            var resultSet = (from r in _context.Results
                             .Where(r => r.LogDate >= EntityFunctions.AddMinutes(DateTime.Now, startTime))
                             .Where(r => r.LogDate <= EntityFunctions.AddMinutes(DateTime.Now, endTime))
                             .Where(r => r.DeviceCounter.Id == counterId)
                             select r).ToList();


            var lowerResultSet = (from rs in resultSet
                                  where rs.LogDate >= DateTime.Now.AddMinutes(endTime) &&
                                  rs.LogDate <= DateTime.Now.AddMinutes(startTime / 2)
                                  select rs.AverageRead).ToList();


            var upperResultSet = (from rs in resultSet
                                  where rs.LogDate >= DateTime.Now.AddMinutes(endTime / 2) &&
                                  rs.LogDate <= DateTime.Now.AddMinutes(startTime)
                                  select rs.AverageRead).ToList();

            var processedSetOne = TrendIterator(lowerResultSet, threshold);

            var processedSerTwo = TrendIterator(upperResultSet, threshold);

            var trend = StatusData.Trends.Up;

            if (processedSetOne < processedSerTwo)
            {
                trend = StatusData.Trends.Down;
            }
            else if (processedSetOne <= processedSerTwo + _upperTrendThreshold || processedSetOne >= processedSerTwo - _lowerTrendThreshold)
            {
                trend = StatusData.Trends.Steady;
            }

            return(trend);
        }
コード例 #11
0
 /// <summary>
 /// Determina si una cita se sobrepone sobre otra cita ya agendada en el area medica o dental.
 /// </summary>
 /// <param name="id_cita">ID de la cita a comparar</param>
 /// <param name="id_responsable">Id del responsable de la cita</param>
 /// <param name="fechaInicio">Fecha de inicio de la cita</param>
 /// <param name="fechaFin">Fecha final de la cita</param>
 /// <param name="estatus_administrativos_inactivos">Arreglo de estatus administrativos inactivos para ingresos</param>
 /// <returns>bool</returns>
 public bool IsOverlapCitaporResponsable(int id_responsable, DateTime fechaInicio, DateTime fechaFin, short?[] estatus_administrativos_inactivos, int?id_cita = null)
 {
     try
     {
         var predicate   = PredicateBuilder.True <ATENCION_CITA>();
         var predicateOR = PredicateBuilder.False <ATENCION_CITA>();
         predicate = predicate.And(w => w.ID_CITA != id_cita && w.ID_RESPONSABLE.HasValue && w.ID_RESPONSABLE.Value == id_responsable && w.CITA_FECHA_HORA <= fechaFin && EntityFunctions.AddMinutes(w.CITA_HORA_TERMINA, -1) >= fechaInicio);
         if (estatus_administrativos_inactivos != null || estatus_administrativos_inactivos.Count() > 0)
         {
             //predicateOR = PredicateBuilder.False<ATENCION_CITA>();
             foreach (var item in estatus_administrativos_inactivos)
             {
                 if (item.HasValue)
                 {
                     predicate = predicate.And(w => w.INGRESO.ID_ESTATUS_ADMINISTRATIVO != item.Value);
                 }
             }
             //predicate = predicate.And(predicateOR.Expand());
         }
         return(GetData(predicate.Expand()).Any());
     }
     catch (Exception ex)
     {
         throw new ApplicationException(ex.Message + " " + (ex.InnerException != null ? ex.InnerException.InnerException.Message : ""));
     }
 }
コード例 #12
0
        public List <EventModel> GetMyEvents(string UserName, string start, string end)
        {
            List <EventModel> result = new List <EventModel>();

            try
            {
                var fromDate = Convert.ToDateTime(start);
                var toDate   = Convert.ToDateTime(end);
                using (objworkorderEMSEntities = new workorderEMSEntities())
                {
                    //var rslt = objworkorderEMSEntities.Appointments.Where(s => s.DateTimeScheduled >= fromDate && EntityFunctions.AddMinutes(s.DateTimeScheduled, s.AppointmentLength) <= toDate && s.CreatedBy == UserName);
                    // var rslt = objworkorderEMSEntities.BookSlotTimes.Join(objworkorderEMSEntities.SlotTimes).Where(s => s.BST_SlotDate >= fromDate && EntityFunctions.AddMinutes(s.BST_SlotDate, 60) <= toDate && s.BST_EMP_EmployeeID == UserId);
                    var rslt = objworkorderEMSEntities.SlotTimes                       // your starting point - table in the "from" statement
                               .Join(objworkorderEMSEntities.BookSlotTimes,            // the source table of the inner join
                                     post => post.SLT_Id,                              // Select the primary key (the first part of the "on" clause in an sql "join" statement)
                                     meta => meta.BST_SLT_Id,                          // Select the foreign key (the second part of the "on" clause)
                                     (post, meta) => new { Post = post, Meta = meta }) // selection
                               .Where(postAndMeta => postAndMeta.Meta.BST_Date >= fromDate && EntityFunctions.AddMinutes(postAndMeta.Meta.BST_Date, 60) <= toDate && postAndMeta.Meta.BST_EMP_EmployeeID == UserName);

                    foreach (var item in rslt)
                    {
                        EventModel rec = new EventModel();
                        //DateTime dt = Convert.ToDateTime(item.Meta.BST_SlotDate + " " + item.Post.SLT_fromTime);
                        //DateTime dt1 = DateTime.ParseExact(item.Meta.BST_SlotDate + " " + item.Post.SLT_fromTime, "dd/MM/yy h:mm:ss tt", CultureInfo.InvariantCulture);
                        rec.id = item.Meta.BST_Id;
                        // rec.SomeImportantKey = item.SomeImportantKey;
                        rec.start = Convert.ToDateTime(item.Meta.BST_SlotDate.ToShortDateString() + " " + item.Post.SLT_fromTime).ToString("s"); // "s" is a preset format that outputs as: "2009-02-27T12:12:22"
                        //rec.start = item.Meta.BST_SlotDate.ToString("s"); // "s" is a preset format that outputs as: "2009-02-27T12:12:22"
                        rec.end   = item.Meta.BST_SlotDate.AddMinutes(60).ToString("s");                                                         // field AppointmentLength is in minutes
                        rec.title = string.IsNullOrEmpty(item.Meta.BST_IsActive) ? "Title:" + rec.start.ToString() : "Title: " + item.Meta.BST_IsActive;
                        //rec.title = string.IsNullOrEmpty(item.Meta.BST_Title) ? "Title:" + rec.start.ToString() : "Title: " + item.Meta.BST_Title;
                        //rec.StatusString = Enums.GetName<AppointmentStatus>((AppointmentStatus)item.StatusENUM);
                        //rec.StatusColor = Enums.GetEnumDescription<AppointmentStatus>(rec.StatusString);
                        rec.StatusString = "#FF8000:BOOKED";
                        rec.StatusColor  = "#FF8000:BOOKED";
                        string ColorCode = rec.StatusColor.Substring(0, rec.StatusColor.IndexOf(":"));
                        rec.ClassName   = rec.StatusColor.Substring(rec.StatusColor.IndexOf(":") + 1, rec.StatusColor.Length - ColorCode.Length - 1);
                        rec.StatusColor = ColorCode;
                        result.Add(rec);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(result);
        }
コード例 #13
0
 public ActionResult Edit([Bind(Include = "ID,AgentID,CustomerID,Date,StartTime,EndTime,Comment")] Appointment appointment)
 {
     if (ModelState.IsValid)
     {
         if (db.Appointments.Any(b => b.AgentID == appointment.AgentID && b.Date == appointment.Date && (appointment.StartTime >= b.StartTime && appointment.StartTime <= b.EndTime)))
         {
             TempData["Message"] = "This time is not available, please choose another time";
             return(RedirectToAction("Index"));
         }
         else if (db.Appointments.Any(b => b.AgentID == appointment.AgentID && b.Date == appointment.Date && (appointment.EndTime >= b.StartTime && appointment.EndTime <= b.EndTime)))
         {
             TempData["Message"] = "This time is not available, please choose another time";
             return(RedirectToAction("Index"));
         }
         else if (db.Appointments.Any(b => b.AgentID == appointment.AgentID && b.Date == appointment.Date && (appointment.StartTime <= EntityFunctions.AddMinutes(b.EndTime, 15))))
         {
             TempData["Message"] = "This time is not available, please choose another time";
             return(RedirectToAction("Index"));
         }
         TempData["Message"]         = "Successfully";
         db.Entry(appointment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AgentID    = new SelectList(db.Agents, "ID", "FirstName", appointment.AgentID);
     ViewBag.CustomerID = new SelectList(db.Customers, "ID", "FirstName", appointment.CustomerID);
     return(View(appointment));
 }
コード例 #14
0
        public ActionResult Create([Bind(Include = "ID,AgentID,CustomerID,Date,StartTime,EndTime,Comment")] Appointment appointment)
        {
            if (ModelState.IsValid)
            {
                if (appointment.Date.CompareTo(DateTime.Now) < 0)
                {
                    appointment.GetCustomersList = db.Customers.ToList();
                    appointment.GetAgentsList    = db.Agents.ToList();
                    TempData["ErrMessage"]       = "Booking Date cannot be in the past";
                    return(View(appointment));
                }
                if (db.Appointments.Any(b => b.AgentID == appointment.AgentID && b.Date == appointment.Date && (appointment.StartTime >= b.StartTime && appointment.StartTime <= b.EndTime)))
                {
                    TempData["ErrMessage"] = "Unfortunately, this time is not available, please choose another time";
                    return(RedirectToAction("Index"));
                }
                else if (db.Appointments.Any(b => b.AgentID == appointment.AgentID && b.Date == appointment.Date && (appointment.EndTime >= b.StartTime && appointment.EndTime <= b.EndTime)))
                {
                    TempData["ErrMessage"] = "Unfortunately, this time is not available, please choose another time";
                    return(RedirectToAction("Index"));
                }
                else if (db.Appointments.Any(b => b.AgentID == appointment.AgentID && b.Date == appointment.Date && (appointment.StartTime <= EntityFunctions.AddMinutes(b.EndTime, 15))))
                {
                    TempData["ErrMessage"] = "Unfortunately, this time is not available, please choose another time";
                    return(RedirectToAction("Index"));
                }
                TempData["ErrMessage"] = "Booked Successfully!";

                db.Appointments.Add(appointment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            appointment.GetCustomersList = db.Customers.ToList();
            appointment.GetAgentsList    = db.Agents.ToList();
            return(View(appointment));
        }
コード例 #15
0
        public static List <DiaryEvent> LoaddAllApointmentInDateRange(double start, double end)
        {
            var fromDate = ConvertFromUnixTimestamp(start);
            var toDate   = ConvertFromUnixTimestamp(end);

            using (DiaryContainer ent = new DiaryContainer())
            {
                var rslt = ent.AppointmentDiaries.Where(s => s.DateTimeSchedule >= fromDate && EntityFunctions.AddMinutes(s.DateTimeSchedule, s.AppointmentLength) <= toDate);

                List <DiaryEvent> result = new List <DiaryEvent>();

                foreach (var item in rslt)
                {
                    DiaryEvent rec = new DiaryEvent();

                    rec.ID = item.ID;
                    rec.SomeImportantKeyID = item.SomeImportantKey;
                    rec.StartDateString    = item.DateTimeSchedule.ToString("s");                                    // "s" is a preset format that outputs as: "2009-02-27T12:12:22"
                    rec.EndDateString      = item.DateTimeSchedule.AddMinutes(item.AppointmentLength).ToString("s"); // field AppointmentLength is in minutes
                    rec.Title        = item.Title + " - " + item.AppointmentLength.ToString() + " mins";
                    rec.StatusString = Enums.GetName <AppointmentStatus>((AppointmentStatus)item.StatuENUM);
                    rec.StatusColor  = Enums.GetEnumDescription <AppointmentStatus>(rec.StatusString);
                    string ColorCode = rec.StatusColor.Substring(0, rec.StatusColor.IndexOf(":"));
                    rec.ClassName   = rec.StatusColor.Substring(rec.StatusColor.IndexOf(":") + 1, rec.StatusColor.Length - ColorCode.Length - 1);
                    rec.StatusColor = ColorCode;
                    result.Add(rec);
                }

                return(result);
            }
        }
コード例 #16
0
ファイル: DairyEvents.cs プロジェクト: rammerst/ClayOnWheels
        public static List <DiaryEvent> LoadAllAppointmentsInDateRange(double start, double end, string userid)
        {
            var isAdmin = false;

            if (ClaimsPrincipal.Current != null)
            {
                isAdmin = ClaimsPrincipal.Current.IsInRole("Admin");
            }
            var fromDate = ConvertFromUnixTimestamp(start);
            var toDate   = ConvertFromUnixTimestamp(end);

            toDate = toDate.AddHours(2);
            using (var ent = new MyDbContext())
            {
                var rslt     = ent.AppointmentDiaries.Where(s => s.DateTimeScheduled >= fromDate && EntityFunctions.AddMinutes(s.DateTimeScheduled, s.AppointmentLength) <= toDate).ToArray();
                var userRslt = ent.UserSubscriptions.Where(s => s.UserId == userid && s.Pending != 1).Select(d => d.AppointmentDairyId).ToArray();
                var result   = new List <DiaryEvent>();
                foreach (var item in rslt)
                {
                    var rec = new DiaryEvent
                    {
                        ID = item.Id,
                        StartDateString = item.DateTimeScheduled.ToString("s"),
                        EndDateString   = item.DateTimeScheduled.AddMinutes(item.AppointmentLength + 30).ToString("s"),
                        Title           = item.Title
                    };

                    // "s" is a preset format that outputs as: "2009-02-27T12:12:22"
                    // field AppointmentLength is in minutes

                    //when cursist has booked, show event in orange
                    if (userRslt.Contains(item.Id))
                    {
                        rec.StatusString       = Enums.GetName((AppointmentStatus)1);
                        rec.SomeImportantKeyID = item.DateTimeScheduled <= DateTime.Now.AddDays(1) ? 667 : 666;
                    }
                    else
                    {
                        rec.OriginalKeyID = item.StatusEnum;
                        //when no admin (so cursist) & 24hours before event, show as unavailable = gray
                        if (item.DateTimeScheduled <= DateTime.Now.AddDays(1) && !isAdmin)
                        {
                            rec.StatusString       = Enums.GetName((AppointmentStatus)3);
                            rec.SomeImportantKeyID = 3;
                        }
                        else
                        {
                            //check when cursus is fully booked & the current cursist has not booked yet, show in red:
                            var results = ent.UserSubscriptions.Count(w => w.AppointmentDairyId == item.Id && w.Pending != 1);
                            if (results >= 10)
                            {
                                rec.StatusString       = Enums.GetName((AppointmentStatus)4);
                                rec.SomeImportantKeyID = 4;
                                rec.Title = "Les volzet";
                            }
                            //everything else: show as available or holiday
                            else
                            {
                                rec.StatusString       = Enums.GetName((AppointmentStatus)item.StatusEnum);
                                rec.SomeImportantKeyID = item.StatusEnum;
                            }
                        }
                    }

                    rec.StatusColor = Enums.GetEnumDescription <AppointmentStatus>(rec.StatusString);
                    var ColorCode = rec.StatusColor.Substring(0, rec.StatusColor.IndexOf(":"));
                    rec.ClassName   = rec.StatusColor.Substring(rec.StatusColor.IndexOf(":") + 1, rec.StatusColor.Length - ColorCode.Length - 1);
                    rec.StatusColor = ColorCode;
                    result.Add(rec);
                }

                return(result);
            }
        }
コード例 #17
0
        public List <AppointmentEntityModel> LoadAppointmentSummaryInDateRange(double start, double end)
        {
            var fromDate = ConvertFromUnixTimestamp(start);
            var toDate   = ConvertFromUnixTimestamp(end);

            var rslt = _unitOfWork.Repository <CaseAppointment>().Table().Where(s => s.CaseAppointmentDate >= fromDate && EntityFunctions.AddMinutes(s.CaseAppointmentDate, s.AppointmentLength) <= toDate)
                       .GroupBy(s => EntityFunctions.TruncateTime(s.CaseAppointmentDate))
                       .Select(x => new { DateTimeScheduled = x.Key, Count = x.Count() });

            List <AppointmentEntityModel> result = new List <AppointmentEntityModel>();
            int i = 0;

            foreach (var item in rslt)
            {
                AppointmentEntityModel rec = new AppointmentEntityModel();
                rec.ID = i;                                     //we dont link this back to anything as its a group summary but the fullcalendar needs unique IDs for each event item (unless its a repeating event)
                string StringDate = string.Format("{0:yyyy-MM-dd}", item.DateTimeScheduled);
                rec.StartDateString = StringDate + "T00:00:00"; //ISO 8601 format
                rec.EndDateString   = StringDate + "T23:59:59";
                rec.Title           = "Booked: " + item.Count.ToString();

                result.Add(rec);
                i++;
            }

            return(result);
        }
コード例 #18
0
ファイル: DairyEvents.cs プロジェクト: rammerst/ClayOnWheels
        public static List <DiaryEvent> LoadAppointmentSummaryInDateRange(double start, double end)
        {
            var fromDate = ConvertFromUnixTimestamp(start);
            var toDate   = ConvertFromUnixTimestamp(end);

            using (var ent = new MyDbContext())
            {
                var rslt = ent.AppointmentDiaries.Where(s => s.DateTimeScheduled >= fromDate && EntityFunctions.AddMinutes(s.DateTimeScheduled, s.AppointmentLength) <= toDate)
                           .GroupBy(s => EntityFunctions.TruncateTime(s.DateTimeScheduled))
                           .Select(x => new { DateTimeScheduled = x.Key, Count = x.Count() });

                List <DiaryEvent> result = new List <DiaryEvent>();
                int i = 0;
                foreach (var item in rslt)
                {
                    DiaryEvent rec = new DiaryEvent();
                    rec.ID = i; //we dont link this back to anything as its a group summary but the fullcalendar needs unique IDs for each event item (unless its a repeating event)
                    rec.SomeImportantKeyID = -1;
                    string StringDate = string.Format("{0:yyyy-MM-dd}", item.DateTimeScheduled);
                    rec.StartDateString = StringDate + "T00:00:00"; //ISO 8601 format
                    rec.EndDateString   = StringDate + "T23:59:59";
                    rec.Title           = "Booked: " + item.Count.ToString();
                    result.Add(rec);
                    i++;
                }

                return(result);
            }
        }