Esempio n. 1
0
        private static EventsData LoadEventData()
        {
            //string data = SharePoint.ReadData(eventsFileName);
            EventsData events = Binary_Serializer.Deserialize <EventsData>(RelativePath.SaveDataPath + eventsFileName);

            return(events);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a new events entry to <paramref name="eventData"/> and saves it to file
        /// </summary>
        public static void AppendData(EventData eventData)
        {
            bool entryExists = false;
            int  index       = -1;

            foreach (EventData e in SaveLoad.events.eventsData)
            {
                if (e.EventId == eventData.EventId)
                {
                    entryExists = true;
                    index       = SaveLoad.events.eventsData.IndexOf(e);
                    continue;
                }
            }

            if (!entryExists)
            {
                SaveLoad.events.eventsData.Add(eventData);
            }
            else
            {
                SaveLoad.events.eventsData[index] = eventData;
            }

            EventsData combined = CombineEventData();

            Binary_Serializer.Serialize <EventsData>(combined, RelativePath.SaveDataPath + eventsFileName);
            //SharePoint.WriteData(eventsFileName, data);
        }
Esempio n. 3
0
        /// <summary>
        /// Removes event: <paramref name="eventData"/> from the save file
        /// </summary>
        public static void RemoveData(EventData eventData)
        {
            EventsData combined = CombineEventData();

            foreach (EventData e in combined.eventsData)
            {
                if (e.EventId == eventData.EventId)
                {
                    events.eventsData.Remove(e);
                    break;
                }
            }
            events = combined;

            Binary_Serializer.Serialize <EventsData>(combined, RelativePath.SaveDataPath + usersFileName);
            //SharePoint.WriteData(eventsFileName, data);
        }
Esempio n. 4
0
        /// <summary>
        /// Combine events data created during runtime with already saved events data
        /// </summary>
        private static EventsData CombineEventData()
        {
            EventsData oldData = events;
            EventsData newData = LoadEventData();

            for (int i = oldData.eventsData.Count - 1; i >= 0; i--)
            {
                if (newData.FindEvent(oldData.eventsData[i].EventId) == null)
                {
                    newData.eventsData.Add(oldData.eventsData[i]);
                    continue;
                }
                else
                {
                    newData.eventsData[i] = oldData.eventsData[i];
                }
            }
            events = newData;

            return(newData);
        }
Esempio n. 5
0
 /// <summary>
 /// Function used to refresh the saved events data.
 /// </summary>
 public static void RenewEventsData()
 {
     events = SaveLoad.LoadEventData();
 }