Exemple #1
0
 public Group(Group parent)
 {
     Parent = parent;
     Members = new ArrayList();
     this.GroupType = GroupType.None;
     Occurrence = Occurrence.Required;
 }
Exemple #2
0
 /// <summary>
 ///   Initialises a new Content Model Group.
 /// </summary>
 /// <param name = "parent">The parent model group.</param>
 public Group(Group parent)
 {
     m_parent = parent;
     Members = new ArrayList();
     m_groupType = GroupType.None;
     m_occurrence = Occurrence.Required;
 }
        private bool CheckAllOccurrencesDestinationSlots(Occurrence currentOccurrence, Slot currentDestinationSlot, Occurrence editedOccurrence)
        {
            var currentApp = currentOccurrence.Appointment as Appointment;

            var offsetOfTheOccurrence = currentApp.Start - currentOccurrence.Start;
            var destSlotOfMasterApp = OffsetSlot(currentDestinationSlot, offsetOfTheOccurrence);

            var occurrences = currentApp.GetOccurrences(scheduleView.VisibleRange.Start, scheduleView.VisibleRange.End);

            destinationSlot = null;
            foreach (var occ in occurrences)
            {
                var occurrenceDestinationSlot = OffsetSlot(destSlotOfMasterApp, occ.Start - currentApp.Start);

                var appsInOccurrenceDestinationSlot = scheduleView.AppointmentsSource
                    .OfType<IAppointment>()
                    .Where((IAppointment a) => a != occ.Appointment)
                    .All((IAppointment a) => !ConflictChecking.AreOverlapping(a, occurrenceDestinationSlot, editedOccurrence));

                if (!appsInOccurrenceDestinationSlot)
                {
                    ShowErrorWindow();
                    return true;
                }
            }

            return false;
        }
Exemple #4
0
 /// <summary>
 /// Initializes a new Content Model Group.
 /// </summary>
 /// <param name="parent">The parent model group.</param>
 public Group(Group parent)
 {
     _parent = parent;
     _members = new ArrayList();
     _type = GroupType.None;
     _occurrence = Occurrence.Required;
 }
        public static bool AreOverlapping(IAppointment appointment, Slot slot, Occurrence draggedOccurrence)
        {
            //check whether the dragged appointment goes over an appointment or an occurrence
            if (appointment.RecurrenceRule == null)
                return (appointment.IntersectsWith(slot) && AreIntersected(appointment.Resources.OfType<IResource>(), slot.Resources.OfType<IResource>()));
            else
                return CheckOccurrences(appointment, slot, draggedOccurrence);

        }
 public static bool CheckOccurrences(IAppointment app, Slot slot, Occurrence draggedOccurrence)
 {
     var occurrences = app.GetOccurrences(slot.Start, slot.End).Where(p => !p.Equals(draggedOccurrence));
     var realOccurrences = new List<Occurrence>();
     foreach (var occ in occurrences)
     {
         if (occurrences != null)
         {
             if (occ.IntersectsWith(slot) && AreIntersected(occ.Appointment.Resources.OfType<IResource>(), slot.Resources.OfType<IResource>()))
             {
                 realOccurrences.Add(occ);
             }
         }
     }
     return realOccurrences.Count() > 0;
 }
Exemple #7
0
        private string GetEventString(Occurrence o, IEvent evt)
        {
            // Get a string that represents our event
            string summary = o.Period.StartTime.ToString("d") + " - " + evt.Summary;
            if (evt.IsAllDay)
                summary += " (All Day)";
            else
            {
                string startTime = _ConvertToLocalTime ?
                    o.Period.StartTime.Local.ToString("t") :
                    o.Period.StartTime.ToString("t") + " " + o.Period.StartTime.TimeZoneName;
                string endTime = _ConvertToLocalTime ?
                    o.Period.EndTime.Local.ToString("t") :
                    o.Period.EndTime.ToString("t") + " " + o.Period.EndTime.TimeZoneName;

                summary += " (" + startTime + " to " + endTime + ")";
            }

            return summary;
        }
Exemple #8
0
        public Group(Group parent)
        {
            Parent = parent;
            this.GroupType = GroupType.None;
            Occurrence = Occurrence.Required;

            this.members = new ArrayList();
            this.symbols = new Set<string>();
        }
        public static DateTime GetOccurrenceOfNextMonth(this DateTime from, DayOfWeek day, Occurrence occurrence)
        {
            DateTime relevantMonthEnd;

            if (occurrence > 0)
            {
                relevantMonthEnd = from.GetFirstOfNextMonth(day);
                occurrence -= 1;
            }
            else
            {
                relevantMonthEnd = from.GetLastOfNextMonth(day);
                occurrence += 1;
            }

            MonthOfYear monthToScan = relevantMonthEnd.MonthOfYear();
            DateTime foundDate = relevantMonthEnd.AddWeeks((int)occurrence);

            if (foundDate.MonthOfYear() == monthToScan)
            {
                return foundDate;
            }

            string errorMessage = String.Format("Cannot get the {0} {1} of {2}", occurrence, day, monthToScan);
            throw new ArgumentOutOfRangeException(errorMessage);
        }
Exemple #10
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as SupplyRequest;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.SupplyRequest.SupplyRequestStatus>)StatusElement.DeepCopy();
            }
            if (Category != null)
            {
                dest.Category = (Hl7.Fhir.Model.CodeableConcept)Category.DeepCopy();
            }
            if (PriorityElement != null)
            {
                dest.PriorityElement = (Code <Hl7.Fhir.Model.RequestPriority>)PriorityElement.DeepCopy();
            }
            if (Item != null)
            {
                dest.Item = (Hl7.Fhir.Model.DataType)Item.DeepCopy();
            }
            if (Quantity != null)
            {
                dest.Quantity = (Hl7.Fhir.Model.Quantity)Quantity.DeepCopy();
            }
            if (Parameter != null)
            {
                dest.Parameter = new List <Hl7.Fhir.Model.SupplyRequest.ParameterComponent>(Parameter.DeepCopy());
            }
            if (Occurrence != null)
            {
                dest.Occurrence = (Hl7.Fhir.Model.DataType)Occurrence.DeepCopy();
            }
            if (AuthoredOnElement != null)
            {
                dest.AuthoredOnElement = (Hl7.Fhir.Model.FhirDateTime)AuthoredOnElement.DeepCopy();
            }
            if (Requester != null)
            {
                dest.Requester = (Hl7.Fhir.Model.ResourceReference)Requester.DeepCopy();
            }
            if (Supplier != null)
            {
                dest.Supplier = new List <Hl7.Fhir.Model.ResourceReference>(Supplier.DeepCopy());
            }
            if (ReasonCode != null)
            {
                dest.ReasonCode = new List <Hl7.Fhir.Model.CodeableConcept>(ReasonCode.DeepCopy());
            }
            if (ReasonReference != null)
            {
                dest.ReasonReference = new List <Hl7.Fhir.Model.ResourceReference>(ReasonReference.DeepCopy());
            }
            if (DeliverFrom != null)
            {
                dest.DeliverFrom = (Hl7.Fhir.Model.ResourceReference)DeliverFrom.DeepCopy();
            }
            if (DeliverTo != null)
            {
                dest.DeliverTo = (Hl7.Fhir.Model.ResourceReference)DeliverTo.DeepCopy();
            }
            return(dest);
        }
Exemple #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AppointmentSlot"/> class.
 /// </summary>
 /// <param name="occurrence">The occurrence.</param>
 /// <param name="timeSlot">The time slot.</param>
 public AppointmentSlot(Occurrence occurrence, TimeSlot timeSlot)
 {
     this.occurrence = occurrence;
     this.timeSlot   = timeSlot;
 }
Exemple #12
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with given <see cref="Schedule"/> as schedule.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="schedule">specifies the schedule of this task.</param>
 /// <param name="occurrence">specifies the occurrence of this task.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 public Task(string owner, Schedule schedule, Occurrence occurrence, DateTime expires) :
     this(owner, schedule, occurrence, expires, true) { }
Exemple #13
0
        /// <summary>
        /// Gets the occurrences.
        /// </summary>
        /// <param name="startTime">The start time.</param>
        /// <param name="endTime">The end time.</param>
        /// <remarks> Вычисляет все экземпляры рекурсивного события в соотв с паттерном рекурсии. С учетом exception event.
        /// </remarks>
        /// <returns></returns>
        public override List<Occurrence> GetOccurrences(iCalDateTime startTime, iCalDateTime endTime)
        {
            //Очищаем кеш повторений
            ClearEvaluation();

            List<Occurrence> retVal = base.GetOccurrences(startTime, endTime);

            if(RecurrenceException != null)
            {
                foreach (McEvent exception in RecurrenceException)
                {
                    if (exception.Recurrence_ID != null)
                    {
                        //Start = RecurrenceId, Duration = Parent event duration
                        Occurrence exceptionOccur = new Occurrence(null, new Period(exception.Recurrence_ID, this.Duration));
                        //remove exception from orig occurrences list
                        if (retVal.Contains(exceptionOccur))
                        {
                            retVal.Remove(exceptionOccur);
                        }
                    }
                }
            }
            return retVal;
        }
Exemple #14
0
 public async Task OccurrenceWarning(Occurrence occurrence)
 {
     await Clients.All.SendAsync("OccurrenceWarning", occurrence);
 }
Exemple #15
0
        private bool CheckAllOccurrencesDestinationSlots(Occurrence currentOccurrence, Slot currentDestinationSlot, Occurrence editedOccurrence)
        {
            var currentApp = currentOccurrence.Appointment as Appointment;

            var offsetOfTheOccurrence = currentApp.Start - currentOccurrence.Start;
            var destSlotOfMasterApp   = OffsetSlot(currentDestinationSlot, offsetOfTheOccurrence);


            var occurrences = currentApp.GetOccurrences(scheduleView.VisibleRange.Start, scheduleView.VisibleRange.End);

            destinationSlot = null;
            foreach (var occ in occurrences)
            {
                var occurrenceDestinationSlot = OffsetSlot(destSlotOfMasterApp, occ.Start - currentApp.Start);

                var appsInOccurrenceDestinationSlot = scheduleView.AppointmentsSource
                                                      .OfType <IAppointment>()
                                                      .Where((IAppointment a) => a != occ.Appointment)
                                                      .All((IAppointment a) => !ConflictChecking.AreOverlapping(a, occurrenceDestinationSlot, editedOccurrence));

                if (!appsInOccurrenceDestinationSlot)
                {
                    ShowErrorWindow();
                    return(true);
                }
            }

            return(false);
        }
Exemple #16
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with given <see cref="Schedule"/> as schedule.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="schedule">specifies the schedule of this task.</param>
 /// <param name="occurrence">specifies the occurrence of this task.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 /// <param name="forceRun">specifies whether a schedule should be triggered forcefully in case system was down when schedule was due (true).</param>
 public Task(string owner, Schedule schedule, Occurrence occurrence, DateTime expires, bool forceRun) :
     this(owner, schedule, occurrence, expires, forceRun, false)
 {
 }
Exemple #17
0
 internal static void Map(OccurrenceEntity entity, Occurrence occur)
 {
     entity.OccurenceID = occur.ID;
     entity.Count       = occur.Count;
 }
Exemple #18
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with given <see cref="Schedule"/> as schedule.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="schedule">specifies the schedule of this task.</param>
 /// <param name="occurrence">specifies the occurrence of this task.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 public Task(string owner, Schedule schedule, Occurrence occurrence, DateTime expires) :
     this(owner, schedule, occurrence, expires, true)
 {
 }
Exemple #19
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with given <see cref="Schedule"/> as schedule.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="schedule">specifies the schedule of this task.</param>
 /// <param name="occurrence">specifies the occurrence of this task.</param>
 public Task(string owner, Schedule schedule, Occurrence occurrence) : this(owner, schedule, occurrence, DateTime.MaxValue)
 {
 }
Exemple #20
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with a time-based <see cref="Schedule"/>.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="minute">specifies at which minute this task should run (-1 = every minute).</param>
 /// <param name="hour">specifies at which hour this task should run (-1 = every hour).</param>
 /// <param name="day">specifies at which day of the week this task should run (-1 = every day).</param>
 /// <param name="occurrence">specifies when the task's schedule should occur.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 /// <param name="forceRun">specifies whether a schedule should be triggered forcefully in case system was down when schedule was due (true).</param>
 public Task(string owner, int minute, int hour, int day, Occurrence occurrence, DateTime expires, bool forceRun) :
     this(owner, minute, hour, day, occurrence, expires, forceRun, false)
 {
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">Id des Kurses</param>
        /// <returns></returns>

        public PartialViewResult Subscribe(Guid id)
        {
            var logger = LogManager.GetLogger("Booking");

            var user    = GetCurrentUser();
            var student = StudentService.GetCurrentStudent(user);
            var course  = Db.Activities.OfType <Course>().SingleOrDefault(x => x.Id == id);
            OccurrenceSubscription succeedingSubscription = null;

            Occurrence             occ          = course.Occurrence;
            OccurrenceSubscription subscription = null;

            using (var transaction = Db.Database.BeginTransaction())
            {
                subscription = occ.Subscriptions.FirstOrDefault(x => x.UserId.Equals(user.Id));

                var bookingService = new BookingService(Db);
                var bookingLists   = bookingService.GetBookingLists(occ.Id);
                var bookingState   = new BookingState
                {
                    Student      = student,
                    Occurrence   = occ,
                    BookingLists = bookingLists
                };
                bookingState.Init();

                var bookingList = bookingState.MyBookingList;

                if (subscription == null)
                {
                    // eintragen
                    // den Status aus den Buchungslisten ermitteln
                    // ermittle Buchungsliste
                    // wenn eine Liste
                    // wenn voll, dann Warteliste
                    // sonst Teilnehmer
                    // sonst
                    // Fehlermeldung an Benutzer mit Angabe des Grunds

                    if (bookingList != null)
                    {
                        subscription = new OccurrenceSubscription
                        {
                            TimeStamp     = DateTime.Now,
                            Occurrence    = occ,
                            UserId        = user.Id,
                            OnWaitingList = bookingState.AvailableSeats <= 0
                        };

                        Db.Subscriptions.Add(subscription);
                    }
                }
                else
                {
                    // austragen
                    var subscriptionService = new SubscriptionService(Db);
                    subscriptionService.DeleteSubscription(subscription);

                    // Nachrücken
                    if (bookingList != null)
                    {
                        var succBooking = bookingList.GetSucceedingBooking();
                        if (succBooking != null)
                        {
                            succBooking.Subscription.OnWaitingList = false;
                            succeedingSubscription = succBooking.Subscription;
                        }
                    }
                }

                Db.SaveChanges();
                transaction.Commit();
            }

            // Mail an Nachrücker versenden
            if (succeedingSubscription != null)
            {
                var mailService = new SubscriptionMailService();
                mailService.SendSucceedingEMail(course, succeedingSubscription);

                var subscriber = GetUser(succeedingSubscription.UserId);
                logger.InfoFormat("{0} ({1}) for [{2}]: set on participient list",
                                  course.Name, course.ShortName, subscriber.UserName);
            }

            // jetzt neu abrufen und anzeigen
            var model = GetBookingStateModel(course.Id);

            return(PartialView("_CourseSummaryBookingBox", model));
        }
        public static Dictionary <Pattern, List <Occurrence> > FindPatternsOfTypeInSong(
            Song song,
            int version,
            PatternType patternType,
            int minLengthToSearch = 3,
            int maxLengthToSearch = 50)
        {
            var retObj = new Dictionary <Pattern, List <Occurrence> >();

            foreach (var instr in song.Instruments)
            {
                var notes       = song.Versions[0].NotesOfInstrument(instr);
                var voicesNotes = GetVoices(notes);
                foreach (var voice in voicesNotes.Keys)
                {
                    var melody   = new Melody(voicesNotes[voice]);
                    var elements = new List <string>();
                    switch (patternType)
                    {
                    case PatternType.Pitch:
                        elements = melody.DeltaPitchesAsStrings;
                        break;

                    case PatternType.Rythm:
                        elements = melody.DurationsInTicksAsStrings;
                        break;

                    case PatternType.Melody:
                        elements = melody.AsListOfStrings.ToList();
                        break;
                    }
                    var patterns = FindPatternsInListOfStrings(elements, minLengthToSearch, maxLengthToSearch);
                    foreach (var pat in patterns)
                    {
                        var patito = new Pattern()
                        {
                            AsString = pat.Key, PatternTypeId = patternType
                        };
                        var ocur = new List <Occurrence>();
                        foreach (var oc in pat.Value)
                        {
                            var firstNote = melody.Notes[oc];
                            var noteOfSongCorrespondingToFirstNote = FindNoteOfSong(firstNote, song, version, instr);
                            var patternLength = pat.Key.Split(",").Length;
                            var lastNote      = melody.Notes[oc + patternLength];
                            var noteOfSongCorrespondingToLastNote = FindNoteOfSong(lastNote, song, version, instr);

                            var o = new Occurrence()
                            {
                                Pattern       = patito,
                                FirstNoteId   = noteOfSongCorrespondingToFirstNote.Id,
                                LastNoteId    = noteOfSongCorrespondingToLastNote.Id,
                                SongVersionId = song.Versions[version].Id
                            };
                            ocur.Add(o);
                        }
                        retObj[patito] = ocur;
                    }
                }
            }
            return(SimplifyPatterns(retObj));
        }
Exemple #23
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with a time-based <see cref="Schedule"/>.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="minute">specifies at which minute this task should run (-1 = every minute).</param>
 /// <param name="hour">specifies at which hour this task should run (-1 = every hour).</param>
 /// <param name="day">specifies at which day of the week this task should run (-1 = every day).</param>
 /// <param name="occurrence">specifies when the task's schedule should occur.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 public Task(string owner, int minute, int hour, int day, Occurrence occurrence, DateTime expires) :
     this(owner, minute, hour, day, occurrence, expires, true)
 {
 }
Exemple #24
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Media;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (BasedOn != null)
            {
                dest.BasedOn = new List <Hl7.Fhir.Model.ResourceReference>(BasedOn.DeepCopy());
            }
            if (TypeElement != null)
            {
                dest.TypeElement = (Code <Hl7.Fhir.Model.Media.DigitalMediaType>)TypeElement.DeepCopy();
            }
            if (Subtype != null)
            {
                dest.Subtype = (Hl7.Fhir.Model.CodeableConcept)Subtype.DeepCopy();
            }
            if (View != null)
            {
                dest.View = (Hl7.Fhir.Model.CodeableConcept)View.DeepCopy();
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (Context != null)
            {
                dest.Context = (Hl7.Fhir.Model.ResourceReference)Context.DeepCopy();
            }
            if (Occurrence != null)
            {
                dest.Occurrence = (Hl7.Fhir.Model.Element)Occurrence.DeepCopy();
            }
            if (Operator != null)
            {
                dest.Operator = (Hl7.Fhir.Model.ResourceReference)Operator.DeepCopy();
            }
            if (ReasonCode != null)
            {
                dest.ReasonCode = new List <Hl7.Fhir.Model.CodeableConcept>(ReasonCode.DeepCopy());
            }
            if (BodySite != null)
            {
                dest.BodySite = (Hl7.Fhir.Model.CodeableConcept)BodySite.DeepCopy();
            }
            if (Device != null)
            {
                dest.Device = (Hl7.Fhir.Model.ResourceReference)Device.DeepCopy();
            }
            if (HeightElement != null)
            {
                dest.HeightElement = (Hl7.Fhir.Model.PositiveInt)HeightElement.DeepCopy();
            }
            if (WidthElement != null)
            {
                dest.WidthElement = (Hl7.Fhir.Model.PositiveInt)WidthElement.DeepCopy();
            }
            if (FramesElement != null)
            {
                dest.FramesElement = (Hl7.Fhir.Model.PositiveInt)FramesElement.DeepCopy();
            }
            if (DurationElement != null)
            {
                dest.DurationElement = (Hl7.Fhir.Model.UnsignedInt)DurationElement.DeepCopy();
            }
            if (Content != null)
            {
                dest.Content = (Hl7.Fhir.Model.Attachment)Content.DeepCopy();
            }
            if (Note != null)
            {
                dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
            }
            return(dest);
        }
Exemple #25
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with given <see cref="Schedule"/> as schedule.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="schedule">specifies the schedule of this task.</param>
 /// <param name="occurrence">specifies the occurrence of this task.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 /// <param name="forceRun">specifies whether a schedule should be triggered forcefully in case system was down when schedule was due (true).</param>
 /// <param name="wakeup">specifies whether the system should be woken up from standby for this task's schedule (false).</param>
 public Task(string owner, Schedule schedule, Occurrence occurrence, DateTime expires, bool forceRun, bool wakeup)
 {
   _owner = owner;
   _schedule = schedule;
   _occurrence = occurrence;
   _expires = expires;
   _forceRun = forceRun;
   _wakeup = wakeup;
 }
Exemple #26
0
        public List <BookingList> GetBookingLists(Guid occId)
        {
            _lists = new List <BookingList>();

            _occ = Db.Occurrences.SingleOrDefault(x => x.Id == occId);
            if (_occ != null)
            {
                if (BookingType == BookingType.green)
                {
                    if (!_occ.UseGroups)
                    {
                        CreateMiscList("Offene Liste", false);
                    }
                    else
                    {
                        CreateListByCurriculum();
                        CreateMiscList("sonstige", true);
                    }
                }
                else
                {
                    if (_occ.UseGroups)
                    {
                        CreateListByCurriculum();
                    }
                    else
                    {
                        CreateJoinedList();
                    }

                    CreateMiscList("sonstige", true);
                }
            }

            foreach (var subscription in _occ.Subscriptions)
            {
                var student = GetStudent(subscription.UserId);
                var booking = new Data.Booking
                {
                    Student      = student,
                    Subscription = subscription
                };

                if (student == null)
                {
                    _globalMiscList.Bookings.Add(booking);
                }
                else
                {
                    var list = _lists.FirstOrDefault(x => x.Curricula.Any(c => c.Id == student.Curriculum.Id));
                    if (list == null)
                    {
                        _globalMiscList.Bookings.Add(booking);
                    }
                    else
                    {
                        list.Bookings.Add(booking);
                    }
                }
            }

            return(_lists);
        }
Exemple #27
0
        protected override void Execute(CodeActivityContext context)
        {
            Result.Set(context, "Not Masked");
            string inputFilePath   = InputFilePath.Get(context);
            string outputDirPath   = OutputDirPath.Get(context);
            string maskingKeyWord  = MaskingKeyWord.Get(context);
            string occurrenceValue = Occurrence.Get(context);
            bool   maskOnlyKeyword = MaskOnlyKeyword.Get(context);

            if (!string.IsNullOrEmpty(inputFilePath) && !string.IsNullOrEmpty(outputDirPath) && !string.IsNullOrEmpty(maskingKeyWord) &&
                maskingKeyWord.IndexOf(" ") < 0 && !string.IsNullOrEmpty(occurrenceValue) && File.Exists(inputFilePath) &&
                Directory.Exists(outputDirPath))
            {
                string redactedPDFNameEscaped = Regex.Replace(Path.GetFileName(inputFilePath), "%", "%%");
                string redactedPDFPath        = $@"{outputDirPath}\{redactedPDFNameEscaped}";
                string jpgFilesDir            = ConvertPDFToJPGs(inputFilePath);
                if (maskOnlyKeyword)
                {
                    if (!string.IsNullOrEmpty(occurrenceValue) && occurrenceValue.Equals("ALL", StringComparison.OrdinalIgnoreCase))
                    {
                        int occurrence       = 0;
                        var redactedJPGFiles = RedactOnlyKeyword(jpgFilesDir, maskingKeyWord, occurrence, maskOnlyKeyword);
                        if (maskingSuccessfull)
                        {
                            ConvertJPGsToPDF(redactedJPGFiles, redactedPDFPath);
                            Result.Set(context, "Success");
                        }
                    }
                    else if (!string.IsNullOrEmpty(occurrenceValue))
                    {
                        if (IsDigitsOnly(occurrenceValue))
                        {
                            int occurrence       = Convert.ToInt32(occurrenceValue);
                            var redactedJPGFiles = RedactOnlyKeyword(jpgFilesDir, maskingKeyWord, occurrence, maskOnlyKeyword);
                            if (maskingSuccessfull)
                            {
                                ConvertJPGsToPDF(redactedJPGFiles, redactedPDFPath);
                                Result.Set(context, "Success");
                            }
                        }
                        else
                        {
                            throw new Exception("Occurrence should contain only digits.");
                        }
                    }
                }
                else if (!string.IsNullOrEmpty(occurrenceValue))
                {
                    if (IsDigitsOnly(occurrenceValue))
                    {
                        int occurrence       = Convert.ToInt32(occurrenceValue);
                        var redactedJPGFiles = RedactTextTillEnd(jpgFilesDir, maskingKeyWord, occurrence, maskOnlyKeyword);
                        if (maskingSuccessfull)
                        {
                            ConvertJPGsToPDF(redactedJPGFiles, redactedPDFPath);
                            Result.Set(context, "Success");
                        }
                    }
                    else
                    {
                        throw new Exception("Occurrence should contain only digits.");
                    }
                }
                Directory.Delete(jpgFilesDir, recursive: true);
            }
            else
            {
                if (!string.IsNullOrEmpty(inputFilePath) && File.Exists(inputFilePath))
                {
                    throw new Exception("Input File Path is not correct.");
                }
                else if (!string.IsNullOrEmpty(outputDirPath) && Directory.Exists(outputDirPath))
                {
                    throw new Exception("Directory Path is not correct.");
                }
                else if (!string.IsNullOrEmpty(maskingKeyWord) && maskingKeyWord.IndexOf(" ") < 0)
                {
                    throw new Exception("Masking Keyword is not correct.");
                }
                else if (!string.IsNullOrEmpty(occurrenceValue))
                {
                    throw new Exception("Occurrence Value should not be null.");
                }
            }
        }
        internal static SleepJournalAM ToSleepJournalAM(this Observation observation)
        {
            var sleepJournalAm = observation.ToThingBase <SleepJournalAM>();

            sleepJournalAm.When = ObservationToHealthVault.GetHealthVaultTimeFromEffectiveDate(observation.Effective);

            foreach (var component in observation.Component)
            {
                if (string.IsNullOrEmpty(component.Code?.Text) || component.Value == null)
                {
                    continue;
                }

                switch (component.Code.Text)
                {
                case HealthVaultVocabularies.SleepJournalAMBedtime:
                    if (component.Value.GetType() == typeof(Time))
                    {
                        sleepJournalAm.Bedtime = ((Time)component.Value).ToAppoximateTime();
                    }

                    break;

                case HealthVaultVocabularies.SleepJournalAMWaketime:
                    if (component.Value.GetType() == typeof(Time))
                    {
                        sleepJournalAm.WakeTime = ((Time)component.Value).ToAppoximateTime();
                    }

                    break;

                case HealthVaultVocabularies.SleepJournalAMSleepMinutes:
                    if (component.Value.GetType() == typeof(SimpleQuantity))
                    {
                        var sleepMinutes = (Quantity)component.Value;
                        if (sleepMinutes.Value.HasValue)
                        {
                            sleepJournalAm.SleepMinutes = (int)sleepMinutes.Value.Value;
                        }
                    }

                    break;

                case HealthVaultVocabularies.SleepJournalAMSettlingMinutes:
                    if (component.Value.GetType() == typeof(SimpleQuantity))
                    {
                        var settlingMinutes = (Quantity)component.Value;
                        if (settlingMinutes.Value.HasValue)
                        {
                            sleepJournalAm.SettlingMinutes = (int)settlingMinutes.Value.Value;
                        }
                    }

                    break;

                case HealthVaultVocabularies.SleepJournalAMWakeState:
                    if (component.Value.GetType() == typeof(FhirString))
                    {
                        WakeState wakeState;
                        var       wakeStateValue = (FhirString)component.Value;

                        if (Enum.TryParse(wakeStateValue.Value, out wakeState))
                        {
                            sleepJournalAm.WakeState = wakeState;
                        }
                    }

                    break;

                case HealthVaultVocabularies.SleepJournalAMMedication:
                    if (component.Value.GetType() == typeof(CodeableConcept))
                    {
                        sleepJournalAm.Medications = ((CodeableConcept)component.Value).ToCodableValue();
                    }

                    break;

                case HealthVaultVocabularies.SleepJournalAMAwakening:
                    if (component.Value.GetType() == typeof(Period))
                    {
                        var startTime = ((Period)component.Value).StartElement.ToDateTimeOffset();
                        var endTime   = ((Period)component.Value).EndElement.ToDateTimeOffset();

                        var approximateTime = new ApproximateTime
                        {
                            Hour        = startTime.Hour,
                            Minute      = startTime.Minute,
                            Second      = startTime.Second,
                            Millisecond = startTime.Millisecond
                        };

                        var occurrence = new Occurrence
                        {
                            When    = approximateTime,
                            Minutes = (endTime - startTime).Minutes
                        };

                        sleepJournalAm.Awakenings.Add(occurrence);
                    }

                    break;
                }
            }

            return(sleepJournalAm);
        }
 public static IEnumerable<DateTime> GetAllOccurrences(DateTime from, DateTime to, DayOfWeek day, Occurrence occurrence)
 {
     return GetAllDayOfWeek(from, to, day).Where(x => x.IsOccurrenceOf(day, occurrence));
 }
Exemple #30
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as ProcedureRequest;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (Definition != null)
            {
                dest.Definition = new List <Hl7.Fhir.Model.ResourceReference>(Definition.DeepCopy());
            }
            if (BasedOn != null)
            {
                dest.BasedOn = new List <Hl7.Fhir.Model.ResourceReference>(BasedOn.DeepCopy());
            }
            if (Replaces != null)
            {
                dest.Replaces = new List <Hl7.Fhir.Model.ResourceReference>(Replaces.DeepCopy());
            }
            if (Requisition != null)
            {
                dest.Requisition = (Hl7.Fhir.Model.Identifier)Requisition.DeepCopy();
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.RequestStatus>)StatusElement.DeepCopy();
            }
            if (IntentElement != null)
            {
                dest.IntentElement = (Code <Hl7.Fhir.Model.RequestIntent>)IntentElement.DeepCopy();
            }
            if (PriorityElement != null)
            {
                dest.PriorityElement = (Code <Hl7.Fhir.Model.RequestPriority>)PriorityElement.DeepCopy();
            }
            if (DoNotPerformElement != null)
            {
                dest.DoNotPerformElement = (Hl7.Fhir.Model.FhirBoolean)DoNotPerformElement.DeepCopy();
            }
            if (Category != null)
            {
                dest.Category = new List <Hl7.Fhir.Model.CodeableConcept>(Category.DeepCopy());
            }
            if (Code != null)
            {
                dest.Code = (Hl7.Fhir.Model.CodeableConcept)Code.DeepCopy();
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (Context != null)
            {
                dest.Context = (Hl7.Fhir.Model.ResourceReference)Context.DeepCopy();
            }
            if (Occurrence != null)
            {
                dest.Occurrence = (Hl7.Fhir.Model.Element)Occurrence.DeepCopy();
            }
            if (AsNeeded != null)
            {
                dest.AsNeeded = (Hl7.Fhir.Model.Element)AsNeeded.DeepCopy();
            }
            if (AuthoredOnElement != null)
            {
                dest.AuthoredOnElement = (Hl7.Fhir.Model.FhirDateTime)AuthoredOnElement.DeepCopy();
            }
            if (Requester != null)
            {
                dest.Requester = (Hl7.Fhir.Model.ProcedureRequest.RequesterComponent)Requester.DeepCopy();
            }
            if (PerformerType != null)
            {
                dest.PerformerType = (Hl7.Fhir.Model.CodeableConcept)PerformerType.DeepCopy();
            }
            if (Performer != null)
            {
                dest.Performer = (Hl7.Fhir.Model.ResourceReference)Performer.DeepCopy();
            }
            if (ReasonCode != null)
            {
                dest.ReasonCode = new List <Hl7.Fhir.Model.CodeableConcept>(ReasonCode.DeepCopy());
            }
            if (ReasonReference != null)
            {
                dest.ReasonReference = new List <Hl7.Fhir.Model.ResourceReference>(ReasonReference.DeepCopy());
            }
            if (SupportingInfo != null)
            {
                dest.SupportingInfo = new List <Hl7.Fhir.Model.ResourceReference>(SupportingInfo.DeepCopy());
            }
            if (Specimen != null)
            {
                dest.Specimen = new List <Hl7.Fhir.Model.ResourceReference>(Specimen.DeepCopy());
            }
            if (BodySite != null)
            {
                dest.BodySite = new List <Hl7.Fhir.Model.CodeableConcept>(BodySite.DeepCopy());
            }
            if (Note != null)
            {
                dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
            }
            if (RelevantHistory != null)
            {
                dest.RelevantHistory = new List <Hl7.Fhir.Model.ResourceReference>(RelevantHistory.DeepCopy());
            }
            return(dest);
        }
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as DeviceRequest;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (InstantiatesCanonicalElement != null)
            {
                dest.InstantiatesCanonicalElement = new List <Hl7.Fhir.Model.Canonical>(InstantiatesCanonicalElement.DeepCopy());
            }
            if (InstantiatesUriElement != null)
            {
                dest.InstantiatesUriElement = new List <Hl7.Fhir.Model.FhirUri>(InstantiatesUriElement.DeepCopy());
            }
            if (BasedOn != null)
            {
                dest.BasedOn = new List <Hl7.Fhir.Model.ResourceReference>(BasedOn.DeepCopy());
            }
            if (PriorRequest != null)
            {
                dest.PriorRequest = new List <Hl7.Fhir.Model.ResourceReference>(PriorRequest.DeepCopy());
            }
            if (GroupIdentifier != null)
            {
                dest.GroupIdentifier = (Hl7.Fhir.Model.Identifier)GroupIdentifier.DeepCopy();
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.RequestStatus>)StatusElement.DeepCopy();
            }
            if (IntentElement != null)
            {
                dest.IntentElement = (Code <Hl7.Fhir.Model.RequestIntent>)IntentElement.DeepCopy();
            }
            if (PriorityElement != null)
            {
                dest.PriorityElement = (Code <Hl7.Fhir.Model.RequestPriority>)PriorityElement.DeepCopy();
            }
            if (Code != null)
            {
                dest.Code = (Hl7.Fhir.Model.CodeableReference)Code.DeepCopy();
            }
            if (Parameter != null)
            {
                dest.Parameter = new List <Hl7.Fhir.Model.DeviceRequest.ParameterComponent>(Parameter.DeepCopy());
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (Encounter != null)
            {
                dest.Encounter = (Hl7.Fhir.Model.ResourceReference)Encounter.DeepCopy();
            }
            if (Occurrence != null)
            {
                dest.Occurrence = (Hl7.Fhir.Model.DataType)Occurrence.DeepCopy();
            }
            if (AuthoredOnElement != null)
            {
                dest.AuthoredOnElement = (Hl7.Fhir.Model.FhirDateTime)AuthoredOnElement.DeepCopy();
            }
            if (Requester != null)
            {
                dest.Requester = (Hl7.Fhir.Model.ResourceReference)Requester.DeepCopy();
            }
            if (PerformerType != null)
            {
                dest.PerformerType = (Hl7.Fhir.Model.CodeableConcept)PerformerType.DeepCopy();
            }
            if (Performer != null)
            {
                dest.Performer = (Hl7.Fhir.Model.ResourceReference)Performer.DeepCopy();
            }
            if (Reason != null)
            {
                dest.Reason = new List <Hl7.Fhir.Model.CodeableReference>(Reason.DeepCopy());
            }
            if (Insurance != null)
            {
                dest.Insurance = new List <Hl7.Fhir.Model.ResourceReference>(Insurance.DeepCopy());
            }
            if (SupportingInfo != null)
            {
                dest.SupportingInfo = new List <Hl7.Fhir.Model.ResourceReference>(SupportingInfo.DeepCopy());
            }
            if (Note != null)
            {
                dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
            }
            if (RelevantHistory != null)
            {
                dest.RelevantHistory = new List <Hl7.Fhir.Model.ResourceReference>(RelevantHistory.DeepCopy());
            }
            return(dest);
        }
Exemple #32
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with a time-based <see cref="Schedule"/>.
 /// This schedule will occur every every minute, every hour, every day.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="occurrence">specifies when the task's schedule should occur.</param>
 public Task(string owner, Occurrence occurrence) : this(owner, -1, occurrence) { }
        public static DateTime GetNearestOccurrence(this DateTime from, DayOfWeek day, Occurrence occurrence)
        {
            var nextSuitableDate = from.GetOccurrenceOfNextMonth(day, occurrence);
            var previousSuitableDate = from.AddMonths(-1).GetOccurrenceOfNextMonth(day, occurrence);

            return CalculateClosest(previousSuitableDate, from, nextSuitableDate);
        }
Exemple #34
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with a time-based <see cref="Schedule"/>.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="minute">specifies at which minute this task should run (-1 = every minute).</param>
 /// <param name="hour">specifies at which hour this task should run (-1 = every hour).</param>
 /// <param name="day">specifies at which day of the week this task should run (-1 = every day).</param>
 /// <param name="occurrence">specifies when the task's schedule should occur.</param>
 public Task(string owner, int minute, int hour, int day, Occurrence occurrence) :
     this(owner, minute, hour, day, occurrence, DateTime.MaxValue) { }
        public static bool IsOccurrenceOf(this DateTime date, DayOfWeek day, Occurrence occurrence)
        {
            if (day != date.DayOfWeek)
            {
                return false;
            }

            try
            {
                var compare = date.AddMonths(-1).GetOccurrenceOfNextMonth(day, occurrence);
                return compare.Date == date.Date;
            }
            catch
            {
                return false;
            }
        }
Exemple #36
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with a time-based <see cref="Schedule"/>.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="minute">specifies at which minute this task should run (-1 = every minute).</param>
 /// <param name="hour">specifies at which hour this task should run (-1 = every hour).</param>
 /// <param name="day">specifies at which day of the week this task should run (-1 = every day).</param>
 /// <param name="occurrence">specifies when the task's schedule should occur.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 /// <param name="forceRun">specifies whether a schedule should be triggered forcefully in case system was down when schedule was due (true).</param>
 public Task(string owner, int minute, int hour, int day, Occurrence occurrence, DateTime expires, bool forceRun) :
     this(owner, minute, hour, day, occurrence, expires, forceRun, false) { }
 /// <summary>
 /// Gets the occurrence text.
 /// </summary>
 /// <param name="occurrence">The occurrence.</param>
 /// <returns></returns>
 private static string GetOccurrenceText( Occurrence occurrence )
 {
     string occurrenceText = string.Empty;
     if ( occurrence.Period.Duration <= new TimeSpan( 0, 0, 1 ) )
     {
         // no or very short duration. Probably a schedule for starting something that doesn't care about duration, like Metrics
         occurrenceText = string.Format( "{0}", occurrence.Period.StartTime.Value.ToString( "g" ) );
     }
     else if ( occurrence.Period.StartTime.Value.Date.Equals( occurrence.Period.EndTime.Value.Date ) )
     {
         // same day for start and end time
         occurrenceText = string.Format( "{0} - {1} to {2} ( {3} hours) ", occurrence.Period.StartTime.Value.Date.ToShortDateString(), occurrence.Period.StartTime.Value.TimeOfDay.ToTimeString(), occurrence.Period.EndTime.Value.TimeOfDay.ToTimeString(), occurrence.Period.Duration.TotalHours.ToString( "#0.00" ) );
     }
     else
     {
         // spans over midnight
         occurrenceText = string.Format( "{0} to {1} ( {2} hours) ", occurrence.Period.StartTime.Value.ToString( "g" ), occurrence.Period.EndTime.Value.ToString( "g" ), occurrence.Period.Duration.TotalHours.ToString( "#0.00" ) );
     }
     return occurrenceText;
 }
Exemple #38
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with an interval-based <see cref="Schedule"/>.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="interval">specifies the interval of this task's schedule.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 /// <param name="forceRun">specifies whether a schedule should be triggered forcefully in case system was down when schedule was due (true).</param>
 /// <param name="wakeup">specifies whether the system should be woken up from standby for this task's schedule (false).</param>
 public Task(string owner, TimeSpan interval, DateTime expires, bool forceRun, bool wakeup)
 {
   _owner = owner;
   _schedule.Interval = interval;
   _schedule.Type = ScheduleType.IntervalBased;
   _occurrence = Occurrence.Repeat;
   _expires = expires;
   _forceRun = forceRun;
   _wakeup = wakeup;
 }
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 24, Configuration.FieldSeparator),
                       Id,
                       SetIdUb1.HasValue ? SetIdUb1.Value.ToString(culture) : null,
                       BloodDeductible,
                       BloodFurnishedPints.HasValue ? BloodFurnishedPints.Value.ToString(Consts.NumericFormat, culture) : null,
                       BloodReplacedPints.HasValue ? BloodReplacedPints.Value.ToString(Consts.NumericFormat, culture) : null,
                       BloodNotReplacedPints.HasValue ? BloodNotReplacedPints.Value.ToString(Consts.NumericFormat, culture) : null,
                       CoInsuranceDays.HasValue ? CoInsuranceDays.Value.ToString(Consts.NumericFormat, culture) : null,
                       ConditionCode != null ? string.Join(Configuration.FieldRepeatSeparator, ConditionCode) : null,
                       CoveredDays.HasValue ? CoveredDays.Value.ToString(Consts.NumericFormat, culture) : null,
                       NonCoveredDays.HasValue ? NonCoveredDays.Value.ToString(Consts.NumericFormat, culture) : null,
                       ValueAmountCode != null ? string.Join(Configuration.FieldRepeatSeparator, ValueAmountCode.Select(x => x.ToDelimitedString())) : null,
                       NumberOfGraceDays.HasValue ? NumberOfGraceDays.Value.ToString(Consts.NumericFormat, culture) : null,
                       SpecialProgramIndicator?.ToDelimitedString(),
                       PsroUrApprovalIndicator?.ToDelimitedString(),
                       PsroUrApprovedStayFm.HasValue ? PsroUrApprovedStayFm.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       PsroUrApprovedStayTo.HasValue ? PsroUrApprovedStayTo.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       Occurrence != null ? string.Join(Configuration.FieldRepeatSeparator, Occurrence.Select(x => x.ToDelimitedString())) : null,
                       OccurrenceSpan?.ToDelimitedString(),
                       OccurSpanStartDate.HasValue ? OccurSpanStartDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       OccurSpanEndDate.HasValue ? OccurSpanEndDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       Ub82Locator2,
                       Ub82Locator9,
                       Ub82Locator27,
                       Ub82Locator45
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Exemple #40
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with a time-based <see cref="Schedule"/>.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="minute">specifies at which minute this task should run (-1 = every minute).</param>
 /// <param name="hour">specifies at which hour this task should run (-1 = every hour).</param>
 /// <param name="day">specifies at which day of the week this task should run (-1 = every day).</param>
 /// <param name="occurrence">specifies when the task's schedule should occur.</param>
 public Task(string owner, int minute, int hour, int day, Occurrence occurrence) :
     this(owner, minute, hour, day, occurrence, DateTime.MaxValue)
 {
 }
Exemple #41
0
 /// <summary>
 /// Creates a new task for the task scheduler with a time-based <see cref="Schedule"/>.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="minute">specifies at which minute this task should run (-1 = every minute).</param>
 /// <param name="hour">specifies at which hour this task should run (-1 = every hour).</param>
 /// <param name="occurrence">specifies when the task's schedule should occur.</param>
 public Task(string owner, int minute, int hour, Occurrence occurrence) : this(owner, minute, hour, -1, occurrence) { }
Exemple #42
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as CommunicationRequest;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (BasedOn != null)
            {
                dest.BasedOn = new List <Hl7.Fhir.Model.ResourceReference>(BasedOn.DeepCopy());
            }
            if (Replaces != null)
            {
                dest.Replaces = new List <Hl7.Fhir.Model.ResourceReference>(Replaces.DeepCopy());
            }
            if (GroupIdentifier != null)
            {
                dest.GroupIdentifier = (Hl7.Fhir.Model.Identifier)GroupIdentifier.DeepCopy();
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.RequestStatus>)StatusElement.DeepCopy();
            }
            if (StatusReason != null)
            {
                dest.StatusReason = (Hl7.Fhir.Model.CodeableConcept)StatusReason.DeepCopy();
            }
            if (Category != null)
            {
                dest.Category = new List <Hl7.Fhir.Model.CodeableConcept>(Category.DeepCopy());
            }
            if (PriorityElement != null)
            {
                dest.PriorityElement = (Code <Hl7.Fhir.Model.RequestPriority>)PriorityElement.DeepCopy();
            }
            if (DoNotPerformElement != null)
            {
                dest.DoNotPerformElement = (Hl7.Fhir.Model.FhirBoolean)DoNotPerformElement.DeepCopy();
            }
            if (Medium != null)
            {
                dest.Medium = new List <Hl7.Fhir.Model.CodeableConcept>(Medium.DeepCopy());
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (About != null)
            {
                dest.About = new List <Hl7.Fhir.Model.ResourceReference>(About.DeepCopy());
            }
            if (Encounter != null)
            {
                dest.Encounter = (Hl7.Fhir.Model.ResourceReference)Encounter.DeepCopy();
            }
            if (Payload != null)
            {
                dest.Payload = new List <Hl7.Fhir.Model.CommunicationRequest.PayloadComponent>(Payload.DeepCopy());
            }
            if (Occurrence != null)
            {
                dest.Occurrence = (Hl7.Fhir.Model.DataType)Occurrence.DeepCopy();
            }
            if (AuthoredOnElement != null)
            {
                dest.AuthoredOnElement = (Hl7.Fhir.Model.FhirDateTime)AuthoredOnElement.DeepCopy();
            }
            if (Requester != null)
            {
                dest.Requester = (Hl7.Fhir.Model.ResourceReference)Requester.DeepCopy();
            }
            if (Recipient != null)
            {
                dest.Recipient = new List <Hl7.Fhir.Model.ResourceReference>(Recipient.DeepCopy());
            }
            if (Sender != null)
            {
                dest.Sender = (Hl7.Fhir.Model.ResourceReference)Sender.DeepCopy();
            }
            if (ReasonCode != null)
            {
                dest.ReasonCode = new List <Hl7.Fhir.Model.CodeableConcept>(ReasonCode.DeepCopy());
            }
            if (ReasonReference != null)
            {
                dest.ReasonReference = new List <Hl7.Fhir.Model.ResourceReference>(ReasonReference.DeepCopy());
            }
            if (Note != null)
            {
                dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
            }
            return(dest);
        }
Exemple #43
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with a time-based <see cref="Schedule"/>.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="minute">specifies at which minute this task should run (-1 = every minute).</param>
 /// <param name="hour">specifies at which hour this task should run (-1 = every hour).</param>
 /// <param name="day">specifies at which day of the week this task should run (-1 = every day).</param>
 /// <param name="occurrence">specifies when the task's schedule should occur.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 public Task(string owner, int minute, int hour, int day, Occurrence occurrence, DateTime expires) :
     this(owner, minute, hour, day, occurrence, expires, true) { }
Exemple #44
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with a time-based <see cref="Schedule"/>.
 /// This schedule will occur every every minute, every hour, every day.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="occurrence">specifies when the task's schedule should occur.</param>
 public Task(string owner, Occurrence occurrence) : this(owner, -1, occurrence)
 {
 }
Exemple #45
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with a time-based <see cref="Schedule"/>.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="minute">specifies at which minute this task should run (-1 = every minute).</param>
 /// <param name="hour">specifies at which hour this task should run (-1 = every hour).</param>
 /// <param name="day">specifies at which day of the week this task should run (-1 = every day).</param>
 /// <param name="occurrence">specifies when the task's schedule should occur.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 /// <param name="forceRun">specifies whether a schedule should be triggered forcefully in case system was down when schedule was due (true).</param>
 /// <param name="wakeup">specifies whether the system should be woken up from standby for this task's schedule (false).</param>
 public Task(string owner, int minute, int hour, int day, Occurrence occurrence, DateTime expires, bool forceRun, bool wakeup)
 {
   _owner = owner;
   _schedule.Minute = minute;
   _schedule.Hour = hour;
   _schedule.Day = day;
   _schedule.Type = ScheduleType.TimeBased;
   _occurrence = occurrence;
   _expires = expires;
   _forceRun = forceRun;
   if (wakeup && (occurrence == Occurrence.EveryStartUp || occurrence == Occurrence.EveryWakeUp))
     throw new ArgumentException("wakeup setting cannot be used together with Occurrence " + _occurrence);
   _wakeup = wakeup;
 }
Exemple #46
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with a time-based <see cref="Schedule"/>.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="minute">specifies at which minute this task should run (-1 = every minute).</param>
 /// <param name="occurrence">specifies when the task's schedule should occur.</param>
 public Task(string owner, int minute, Occurrence occurrence) : this(owner, minute, -1, occurrence)
 {
 }
Exemple #47
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with given <see cref="Schedule"/> as schedule.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="schedule">specifies the schedule of this task.</param>
 /// <param name="occurrence">specifies the occurrence of this task.</param>
 public Task(string owner, Schedule schedule, Occurrence occurrence) : this(owner, schedule, occurrence, DateTime.MaxValue) { }
Exemple #48
0
		internal static String UnparseOccurrence(Occurrence o)
		{
			String result = String.Empty;
			switch(o)
			{
				case Occurrence.Prefix: result = "prefix"; break;
				case Occurrence.Infix: result = "infix"; break;
				case Occurrence.Postfix: result = "postfix"; break;
				case Occurrence.FunctionModel: result = "function-model"; break;
			}
			return result;
		}
Exemple #49
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with given <see cref="Schedule"/> as schedule.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="schedule">specifies the schedule of this task.</param>
 /// <param name="occurrence">specifies the occurrence of this task.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 /// <param name="forceRun">specifies whether a schedule should be triggered forcefully in case system was down when schedule was due (true).</param>
 public Task(string owner, Schedule schedule, Occurrence occurrence, DateTime expires, bool forceRun) :
     this(owner, schedule, occurrence, expires, forceRun, false) { }
        public virtual void WriteOccurrence(Occurrence toSave)
        {
            var lines = new[]{toSave.AsWriteable() };

            Paths.AppendAllLines(this.OccurrencesPath,lines);
        }
        public override HashSet<IPeriod> Evaluate(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
        {
            // Ensure the reference date is associated with the time zone
            if (referenceDate.AssociatedObject == null)
                referenceDate.AssociatedObject = TimeZone;

            List<ITimeZoneInfo> infos = new List<ITimeZoneInfo>(TimeZone.TimeZoneInfos);

            // Evaluate extra time periods, without re-evaluating ones that were already evaluated
            if ((EvaluationStartBounds == DateTime.MaxValue && EvaluationEndBounds == DateTime.MinValue) ||
                (periodEnd.Equals(EvaluationStartBounds)) ||
                (periodStart.Equals(EvaluationEndBounds)))
            {
                foreach (ITimeZoneInfo curr in infos)
                {
                    IEvaluator evaluator = curr.GetService(typeof(IEvaluator)) as IEvaluator;
                    Debug.Assert(curr.Start != null, "TimeZoneInfo.Start must not be null.");
                    Debug.Assert(curr.Start.TZID == null, "TimeZoneInfo.Start must not have a time zone reference.");
                    Debug.Assert(evaluator != null, "TimeZoneInfo.GetService(typeof(IEvaluator)) must not be null.");

                    // Time zones must include an effective start date/time
                    // and must provide an evaluator.
                    if (evaluator != null)
                    {
                        // Set the start bounds
                        if (EvaluationStartBounds > periodStart)
                            EvaluationStartBounds = periodStart;

                        // FIXME: 5 years is an arbitrary number, to eliminate the need
                        // to recalculate time zone information as much as possible.
                        DateTime offsetEnd = periodEnd.AddYears(5);

                        // Adjust our reference date to never fall out of bounds with
                        // the time zone information
                        var tziReferenceDate = referenceDate;
                        if (tziReferenceDate.LessThan(curr.Start))
                            tziReferenceDate = curr.Start;

                        // Determine the UTC occurrences of the Time Zone observances
                        var periods = evaluator.Evaluate(
                            tziReferenceDate,
                            periodStart,
                            offsetEnd,
                            includeReferenceDateInResults);

                        foreach (IPeriod period in periods)
                        {
                            if (!Periods.Contains(period))
                            {
                                Periods.Add(period);

                                Occurrence o = new Occurrence(curr, period);

                                if (!m_Occurrences.ContainsKey(o))
                                    m_Occurrences.Add(o, o);
                            }
                        }

                        if (EvaluationEndBounds == DateTime.MinValue || EvaluationEndBounds < offsetEnd)
                            EvaluationEndBounds = offsetEnd;
                    }
                }
                
                ProcessOccurrences(referenceDate);
            }
            else
            {
                if (EvaluationEndBounds != DateTime.MinValue && periodEnd > EvaluationEndBounds)
                    Evaluate(referenceDate, EvaluationEndBounds, periodEnd, includeReferenceDateInResults);
            }

            return Periods;
        }
 public void WriteOccurrence(Occurrence toSave)
 {
     foreach (var provider in Providers)
         provider.WriteOccurrence (toSave);
 }
 public void AddOccurrence(char c)
 {
     Occurrence o = Occurrence.Required;
     switch (c) 
     {
         case '?': 
             o = Occurrence.Optional;
             break;
         case '+':
             o = Occurrence.OneOrMore;
             break;
         case '*':
             o = Occurrence.ZeroOrMore;
             break;
     }
     Occurrence = o;
 }
Exemple #54
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as RiskAssessment;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = (Hl7.Fhir.Model.Identifier)Identifier.DeepCopy();
            }
            if (BasedOn != null)
            {
                dest.BasedOn = (Hl7.Fhir.Model.ResourceReference)BasedOn.DeepCopy();
            }
            if (Parent != null)
            {
                dest.Parent = (Hl7.Fhir.Model.ResourceReference)Parent.DeepCopy();
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.ObservationStatus>)StatusElement.DeepCopy();
            }
            if (Method != null)
            {
                dest.Method = (Hl7.Fhir.Model.CodeableConcept)Method.DeepCopy();
            }
            if (Code != null)
            {
                dest.Code = (Hl7.Fhir.Model.CodeableConcept)Code.DeepCopy();
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (Context != null)
            {
                dest.Context = (Hl7.Fhir.Model.ResourceReference)Context.DeepCopy();
            }
            if (Occurrence != null)
            {
                dest.Occurrence = (Hl7.Fhir.Model.Element)Occurrence.DeepCopy();
            }
            if (Condition != null)
            {
                dest.Condition = (Hl7.Fhir.Model.ResourceReference)Condition.DeepCopy();
            }
            if (Performer != null)
            {
                dest.Performer = (Hl7.Fhir.Model.ResourceReference)Performer.DeepCopy();
            }
            if (Reason != null)
            {
                dest.Reason = (Hl7.Fhir.Model.Element)Reason.DeepCopy();
            }
            if (Basis != null)
            {
                dest.Basis = new List <Hl7.Fhir.Model.ResourceReference>(Basis.DeepCopy());
            }
            if (Prediction != null)
            {
                dest.Prediction = new List <Hl7.Fhir.Model.RiskAssessment.PredictionComponent>(Prediction.DeepCopy());
            }
            if (MitigationElement != null)
            {
                dest.MitigationElement = (Hl7.Fhir.Model.FhirString)MitigationElement.DeepCopy();
            }
            if (CommentElement != null)
            {
                dest.CommentElement = (Hl7.Fhir.Model.FhirString)CommentElement.DeepCopy();
            }
            return(dest);
        }