Beispiel #1
0
        /// <summary>
        /// Чтение данных
        /// </summary>
        public void LoadData()
        {
            try
            {
                //Отчего-то фишка как с сериализацией не прокатила(хотя в потоке все нормально)
                //так что костыли - наше все
                XmlSerializer    formatter  = new XmlSerializer(typeof(ClassData));
                GoogleDriveClass driveClass = new GoogleDriveClass();
                driveClass.Authorize();

                MemoryStream stream = driveClass.FileRead(driveClass.GetFileId("Data.txt"));
                FileStream   file   = new FileStream("TempData.xml", FileMode.OpenOrCreate);
                stream.Seek(0, SeekOrigin.Begin);
                stream.CopyTo(file);
                file.Close();

                using (FileStream fs = new FileStream("TempData.xml", FileMode.OpenOrCreate))
                //using (XmlWriter xmlWriter = new XmlTextWriter(fs, Encoding.UTF8))
                {
                    ClassData classData = (ClassData)formatter.Deserialize(fs);
                    this.calendar           = classData.calendar;
                    this.diary              = classData.diary;
                    this.finansialAssistant = classData.finansialAssistant;
                    this.information        = classData.information;
                    this.notes              = classData.notes;
                    this.photo              = classData.photo;
                    this.plants             = classData.plants;
                    this.routineDay         = classData.routineDay;
                    this.test = classData.test;
                }
                File.Delete("TempData.xml");
            } catch { }
        }
Beispiel #2
0
 public ClassData()
 {
     calendar           = new ClassCalendar();
     diary              = new ClassDiary();
     finansialAssistant = new ClassFinansialAssistant();
     information        = new ClassInformation();
     notes              = new ClassNotes();
     photo              = new ClassPhoto();
     plants             = new ClassPlants();
     routineDay         = new ClassRoutineDay();
     test = getTestString();
 }