示例#1
0
 public void CreateEmptyFile(string FileName)
 {
     List<Message> m = new List<Message>();
     List<Prescription> p = new List<Prescription>();
     DocumentSerializable d = new DocumentSerializable(m, p);
     string path = GetPathFile(FileName);
     SerializeListDoc(d, path);
 }
示例#2
0
        public Data getUser(string pseudo, string password)
        {
            int id = _db.SelectRequest.SelectUser(pseudo, password).UserId;
            DocumentManager _doc = new DocumentManager(_db);
            DocumentSerializable doc;
            Dictionary<Patient, Professional[]> follower = _db.SelectRequest.SelectAllFollow(id);
            User user = _db.SelectRequest.SelectUser(id);
            Professional test = _db.SelectRequest.SelectProfessional(id);
            if (test == null)
            {
                doc = _doc.SeeDocument(id);
            }
            else
            {

                doc = new DocumentSerializable(new List<Message>(), new List<Prescription>());

                //follower.Select(p => follower.Keys).

                foreach (var patient in follower)
                {

                    foreach (var message in _doc.SeeDocument(id, patient.Key.PatientId).Messages)
                    {
                        doc.Messages.Add(message);
                    }
                    foreach (var prescription in _doc.SeeDocument(id, patient.Key.PatientId).Prescriptions)
                    {
                        doc.Prescriptions.Add(prescription);
                    }
                }
            }

            Data swag = new Data(doc, follower, user);
            return swag;
        }
示例#3
0
 public DocumentSerializableXML CreateDocuments(DocumentSerializable documents)
 {
     DocumentSerializableXML d = new DocumentSerializableXML();
     d.Message = CreateMessagesList(documents.Messages);
     d.Prescription = CreatePrescriptionList(documents.Prescriptions);
     return d;
 }
示例#4
0
        private DocumentSerializable DeserializeListDoc(string FilePath)
        {
            List<Message> m = new List<Message>();
            List<Prescription> p = new List<Prescription>();
            DocumentSerializable d = new DocumentSerializable(m, p);

            Stream fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
            try
            {
                BinaryFormatter formatter = new BinaryFormatter();
                DocumentSerializable newdoc = (DocumentSerializable)formatter.Deserialize(fileStream);
                foreach(var message in newdoc.Messages)
                {
                    d.Messages.Add(message);
                }
                foreach (var prescription in newdoc.Prescriptions)
                {
                    d.Prescriptions.Add(prescription);
                }
            }
            catch (SerializationException e)
            {
                Console.WriteLine("Failed to deserialize. Reason: " + e.Message);
                throw;
            }
            finally
            {
                fileStream.Close();
            }
            return d;
        }
示例#5
0
 private void SerializeListDoc(DocumentSerializable Documents, string FilePath)
 {
     Stream fileStream = new FileStream(FilePath, FileMode.Create, FileAccess.Write, FileShare.None);
     BinaryFormatter formatter = new BinaryFormatter();
     try
     {
         formatter.Serialize(fileStream, Documents);
     }
     catch (SerializationException e)
     {
         Console.WriteLine("Failed to serialize. Reason: " + e.Message);
         throw;
     }
     finally
     {
         fileStream.Close();
     }
 }