Beispiel #1
0
        public String getPath(int times = 0, int labelledPatients = 0)
        {
            CSVRecord            = null;
            informationCSVMerger = null;
            if (times > 10)
            {
                MessageBox.Show("Przekroczono limit losowania bez powtorzenia - zmien dane");
                Environment.FailFast("");
                return(null);
            }
            String path = pathProvider.getPath();
            String final;

            if (informationCSVMerger == null)
            {
                informationCSVMerger = new InformationCSVMerger <CSVRecord>(CSVSaver.CsvPath);
            }
            if (labelledPatients > 0 && informationCSVMerger.getRecords().Count > loadedLabelled)
            {
                final = getLabelledPath();
            }
            else
            {
                if (labelledPatients > 0)
                {
                    MessageBox.Show("Załadowano nowego pacjenta - nie ma kolejnych rekordów danych do załadowania oznaczonych");
                }
                final = analyzePath(path) && dropPolitics?getPath(times + 1, labelledPatients : labelledPatients) : path;
            }

            informationCSVMerger = null;
            return(final);
        }
Beispiel #2
0
        public void saveToCSV(CSVStructure record, String path)
        {
            CSVRecord rec = record.getRecordFromStructure(path);

            saveRecordsToCsv(new CSVRecord[] { rec });
            MessageBox.Show("Zapisano wiersz:\n" + buildRecordString(rec));
        }
Beispiel #3
0
        public void deleteRecord(CSVRecord record)
        {
            if (record == null)
            {
                return;
            }

            deleteTemplate(readCSV(), record);
        }
Beispiel #4
0
 public void storeCSVRecord(CSVRecord CSVRecord)
 {
     if (records.Count <= currentPath)
     {
         records.Add(CSVRecord);
     }
     else
     {
         records[currentPath] = CSVRecord;
     }
 }
Beispiel #5
0
        public void addDeleted()
        {
            if (deleted == null)
            {
                return;
            }

            saveRecordsToCsv(new CSVRecord[] { deleted });
            MessageBox.Show("Ponownie dopisano wiersz:\n" + buildRecordString(deleted));
            deleted = null;
        }
Beispiel #6
0
 public static CSVStructure getStructure(CSVRecord CSVRecord = null)
 {
     if (CSVRecord != null)
     {
         return(Mapper.Map <CSVStructure>(CSVRecord));
     }
     else
     {
         return(new CSVStructure());
     }
 }
Beispiel #7
0
        private void deleteTemplate(List <CSVRecord> records, CSVRecord toDelete)
        {
            bool removed = records.Remove(toDelete);

            if (removed)
            {
                deleted = toDelete;
                String recordString = buildRecordString(toDelete);
                MessageBox.Show("Pozostało wierszy: " + records.Count + "\nUsuwanie wiersza:\n" + recordString);
                rewriteCSV(records);
            }
        }
Beispiel #8
0
        public void deleteRecord()
        {
            List <CSVRecord> records = readCSV();

            if (records.Count == 0)
            {
                return;
            }
            CSVRecord removed = records.Last();

            deleteTemplate(records, removed);
        }
Beispiel #9
0
        public static String buildRecordString(CSVRecord record)
        {
            StringBuilder sb = new StringBuilder();

            foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(record))
            {
                string name  = descriptor.Name;
                object value = descriptor.GetValue(record);
                sb.Append(name + ": " + value + ", ");
            }
            return(sb.ToString());
        }
Beispiel #10
0
        public override bool Equals(object obj)
        {
            CSVRecord ob = (CSVRecord)obj;

            if (this.Patient.Equals(ob.Patient) && this.Date.Equals(ob.Date) && this.Eye.Equals(ob.Eye) && this.EyeImage.Equals(ob.EyeImage) && this.SrodekImage.Equals(ob.SrodekImage) &&
                this.WyjscieImage.Equals(ob.WyjscieImage) && this.KrawedzImage.Equals(ob.KrawedzImage) &&
                this.ObrzekImage.Equals(ob.ObrzekImage) && this.PierscienImage.Equals(ob.PierscienImage))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #11
0
        private String getLabelledPath()
        {
            CSVRecord = informationCSVMerger.getRecords().ElementAt(loadedLabelled);
            loadedLabelled++;
            String dir    = PropertiesReader.PATH_PROVIDER_ADDITIONAL_ARGS + "/" + CSVRecord.Patient + "/" + CSVRecord.Date;
            String dirEye = dir + "/" + CSVRecord.Eye;

            if (Directory.Exists(dirEye))
            {
                return(dirEye);
            }
            else
            {
                return(dir);
            }
        }
Beispiel #12
0
        public bool analyzePath(String path)
        {
            if (informationCSVMerger == null)
            {
                informationCSVMerger = new InformationCSVMerger <CSVRecord>(CSVSaver.CsvPath);
            }
            CSVRecord = null;
            CSVRecord = InformationCSVMerger <CSVRecord> .getRecord(path, informationCSVMerger.getRecords());

            if (CSVRecord == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }