Example #1
0
        //public static LesionEntities FindByOrderId(string orderId)
        //{
        //    return Deserialize().FirstOrDefault(item => item.OrderID == orderId);
        //}

        //public static void UpdatePatient(LesionEntities patient)
        //{
        //    LesionEntities airwayPatients = Deserialize();

        //    int idx = airwayPatients.IndexOf(airwayPatients.FirstOrDefault(item => item.PatientId == patient.PatientId));

        //    airwayPatients[idx] = patient;

        //    LesionEntities.Serialize(airwayPatients);
        //}

        public static void Serialize(LesionEntities entity)
        {
            //TestSave(entity);
            return;

            TextWriter tw = new StringWriter();

            var formatter = new XmlSerializer(typeof(LesionEntities));

            formatter.Serialize(tw, entity);

            if (!Directory.Exists(Path.GetDirectoryName(Filename)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(Filename));
            }
            File.WriteAllText(Filename, tw.ToString());
        }
Example #2
0
        public static LesionEntities TestLoad(string baseFolder)
        {
            BaseFolder = baseFolder;
            Filename   = Path.Combine(BaseFolder, "LesionEntities.xml");
            if (!File.Exists(Filename))
            {
                //MessageBox.Show("ûÓÐÊý¾Ý");
                return(null);
                //TestSave(new AirwayPatients());
            }
            var            serializer = new DataContractSerializer(typeof(LesionEntities));
            LesionEntities o          = null;

            using (var stream = new MemoryStream(File.ReadAllBytes(Filename)))
            {
                o = serializer.ReadObject(stream) as LesionEntities;
            }
            return(o);
        }
Example #3
0
        public static void TestSave(LesionEntities patients, string baseFolder)
        {
            BaseFolder = baseFolder;
            Filename   = Path.Combine(BaseFolder, "LesionEntities.xml");
            if (!Directory.Exists(BaseFolder))
            {
                Directory.CreateDirectory(BaseFolder);
                if (!File.Exists(Filename))
                {
                    //File.Create(Filename);
                    File.Copy("LesionEntities.xml", Filename, true);
                    //File.WriteAllText(Filename,"<ArrayOfAirwayPatient></ArrayOfAirwayPatient>");
                }
            }
            var serializer = new DataContractSerializer(typeof(LesionEntities));

            using (var stream = new MemoryStream())
            {
                serializer.WriteObject(stream, patients);
                File.WriteAllBytes(Filename, stream.ToArray());
            }
        }
Example #4
0
        public static void Delete(string baseFolder, LesionEntity lesion)
        {
            LesionEntities list        = TestLoad(baseFolder);
            int            selectIndex = -1;

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].Index == lesion.Index)
                {
                    selectIndex = i;
                }
            }

            if (selectIndex != -1)
            {
                list.RemoveAt(selectIndex);
                TestSave(list, baseFolder);
                MessageBox.Show("ɾ³ý³É¹¦!");
            }
            else
            {
                // MessageBox.Show("ɾ³ýʧ°Ü:δÕÒµ½¸Ã²¡Ô");
            }
        }