Ejemplo n.º 1
0
        public static FeedCollection LoadMyCollection()
        {
            FeedCollection mainCollection = null;

            try
            {
                var            MyFilePath   = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\MainCollection.xml";
                FeedCollection loadMyObject = null;

                if (File.Exists(MyFilePath))
                {
                    var xmlLoad = new XmlSerializer(typeof(FeedCollection));
                    var load    = File.Open(MyFilePath, FileMode.Open);

                    loadMyObject = xmlLoad.Deserialize(load) as FeedCollection;
                    load.Flush();
                    load.Close();
                    mainCollection = loadMyObject;
                }
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
            return(mainCollection);
        }
Ejemplo n.º 2
0
        public static FeedCollection IntervalHandler(FeedCollection mainCollection)
        {
            DateTime CurrentTime = DateTime.Now;

            if (mainCollection != null && mainCollection.Count > 0)
            {
                try
                {
                    for (int i = 0; i < mainCollection.Count; i++)
                    {
                        TimeSpan timeDiff        = CurrentTime - mainCollection[i].TimeLastChecked;
                        var      hoursSinceCheck = timeDiff.Hours;
                        Feed     feedToCheck     = (Feed)mainCollection[i].DeepClone();

                        if (mainCollection[i].UpdateInterval == 24 && hoursSinceCheck >= 24 ||
                            mainCollection[i].UpdateInterval == 1 && hoursSinceCheck >= 1)
                        {
                            TransferInterface.UpdateChecker(feedToCheck);

                            if (TransferInterface.TransmitFeed.FeedItems.Count > mainCollection[i].FeedItems.Count)
                            {
                                mainCollection[i] = TransferInterface.TransmitFeed;
                                mainCollection[i].TimeLastChecked = DateTime.Now;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.Write(e.Message);
                }
            }
            return(mainCollection);
        }
Ejemplo n.º 3
0
        public static FeedCollection HandleCollectionLoadRequest()
        {
            Object feedCollectionToLoad = Storage.LoadCollection();

            FeedCollection loadCollection = (FeedCollection)feedCollectionToLoad;

            return(loadCollection);
        }
Ejemplo n.º 4
0
 public static void SaveMyCollection(FeedCollection mainCollection)
 {
     try
     {
         var MyFilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\MainCollection.xml";
         var xmlSave    = new XmlSerializer(typeof(FeedCollection));
         var save       = File.Open(MyFilePath, FileMode.Create);
         xmlSave.Serialize(save, mainCollection);
         save.Flush();
         save.Close();
     }
     catch (Exception e)
     {
         Console.Write(e.Message);
     }
 }
Ejemplo n.º 5
0
        public static void HandleCollectionSaveRequest(FeedCollection feedCollectionToSave)
        {
            Object FeedCoObject = (Object)feedCollectionToSave;

            Storage.SaveCollection(FeedCoObject);
        }