コード例 #1
0
        /// <summary>
        /// Saves Contacts in memory to persistent storage.
        /// </summary>
        protected void SaveContacts(PeriodicAppointment appointment, VariableLengthRecord record)
        {
            Relation1M <Contact> contacts = appointment.GetContacts();

            record.AppendValue(contacts.GetChildCount());   //#4  //might be a 0
            for (int contactIndex = 0; contactIndex < contacts.GetChildCount(); ++contactIndex)
            {
                record.AppendValue(contacts.GetChild(contactIndex).GetObjectId());   //#5 - N
            }
        }
コード例 #2
0
        /// <summary>
        /// Recreates an existing PeriodicAppointment from persistent storage.
        /// </summary>
        /// <param name="objectId"></param>
        /// <returns></returns>
        public override DiaryProduct Create(ObjectId objectId)
        {
            // Check if it already exists
            for (int childIndex = 0; childIndex < mPeriodicAppointments.GetChildCount(); ++childIndex)
            {
                PeriodicAppointment periodicAppointment = mPeriodicAppointments.GetChild(childIndex);
                if (periodicAppointment.GetObjectId() == objectId)
                {
                    return(periodicAppointment);
                }
            }

            // Not already loaded ?
            VariableLengthRecord record = Read(objectId);

            if (record != null)
            {
                var label = String.Empty;
                if (record.GetValue(0, ref label))
                {
                    var firstOccurs = new DateTime();
                    if (record.GetValue(1, ref firstOccurs))
                    {
                        int durationMinutes = 0;
                        if (record.GetValue(2, ref durationMinutes))
                        {
                            var notToExceedDateTime = new DateTime();
                            if (record.GetValue(3, ref notToExceedDateTime))
                            {
                                int periodHours = 0;
                                if (record.GetValue(4, ref periodHours))
                                {
                                    var details = String.Empty;
                                    if (record.GetValue(5, ref details))
                                    {
                                        var periodicAppointment = new PeriodicAppointment(objectId, label, firstOccurs, durationMinutes, notToExceedDateTime, periodHours, details);

                                        mPeriodicAppointments.Add(periodicAppointment);

                                        LoadContacts(6, periodicAppointment, record); // Now take care of any Contacts

                                        return(periodicAppointment);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(null);  // No such appointment
        }
コード例 #3
0
ファイル: AppointmentCreator.cs プロジェクト: cheriephi/diary
        /// <summary>
        /// Recreates an existing Appointment from persistent storage.
        /// </summary>
        /// <param name="objectId"></param>
        /// <returns></returns>
        public override DiaryProduct Create(ObjectId objectId)
        {
            // Check if it already exists
            for (int childIndex = 0; childIndex < mAppointments.GetChildCount(); ++childIndex)
            {
                Appointment appointment = mAppointments.GetChild(childIndex);
                if (appointment.GetObjectId() == objectId)
                {
                    return(appointment);
                }
            }

            // Not already loaded ?
            VariableLengthRecord record = Read(objectId);

            if (record != null)
            {
                var label = String.Empty;
                if (record.GetValue(0, ref label))
                {
                    var details = String.Empty;
                    if (record.GetValue(1, ref details))
                    {
                        var occurs = new DateTime();
                        if (record.GetValue(2, ref occurs))
                        {
                            int durationMinutes = 0;
                            if (record.GetValue(3, ref durationMinutes))
                            {
                                var appointment = new Appointment(objectId, label, occurs, durationMinutes, details);

                                mAppointments.Add(appointment);

                                LoadContacts(4, appointment, record); // Now take care of any Contacts

                                return(appointment);
                            }
                        }
                    }
                }
            }

            return(null);  // No such appointment
        }
コード例 #4
0
        /// <summary>
        /// Recreates an existing Contact from persistent storage.
        /// </summary>
        /// <param name="objectId"></param>
        /// <returns></returns>
                public override DiaryProduct Create(ObjectId objectId)
        {
                        // Check if it already exists in memory.
                        for(int childIndex = 0; childIndex < mContacts.GetChildCount(); ++childIndex)
            {
                Contact contact = mContacts.GetChild(childIndex);

                if (contact.GetObjectId() == objectId)
                {
                    return(contact);
                }
            }

                        // Not already loaded ?
                        VariableLengthRecord record = Read(objectId);

            if (record != null)
            {
                var firstName = String.Empty;
                if (record.GetValue(0, ref firstName))
                {
                    var lastName = String.Empty;
                    if (record.GetValue(1, ref lastName))
                    {
                        var contactInfo = String.Empty;
                        if (record.GetValue(2, ref contactInfo))
                        {
                            var contact = new Contact(objectId, firstName, lastName, contactInfo);

                            mContacts.Add(contact);
                            return(contact);
                        }
                    }
                }
            }

            return(null);  // No such contact
                        
        }
コード例 #5
0
        /// <summary>
        /// Recreates an existing Reminder from persistent storage.
        /// </summary>
        /// <param name="objectId"></param>
        /// <returns></returns>
        public override DiaryProduct Create(ObjectId objectId)
        {
                        // Check if it already exists in memory.
                        for(int childIndex = 0; childIndex < mReminders.GetChildCount(); ++childIndex)
            {
                Reminder reminder = mReminders.GetChild(childIndex);

                if (reminder.GetObjectId() == objectId)
                {
                    return(reminder);
                }
            }

                        // Not already loaded ?
                        VariableLengthRecord record = Read(objectId);

            if (record != null)
            {
                var label = String.Empty;
                if (record.GetValue(0, ref label))
                {
                    var date = new Date();
                    if (record.GetValue(1, ref date))
                    {
                        var details = String.Empty;
                        if (record.GetValue(2, ref details))
                        {
                            var reminder = new Reminder(objectId, label, date, details);

                            mReminders.Add(reminder);
                            return(reminder);
                        }
                    }
                }
            }

            return(null);  // No such reminder
        }