public object BuscarLista()
        {
            var listaConverter = new ListConverters();

            return(new {
                Nome = listaConverter.Nome,
                Data = listaConverter.Data
            });
        }
        public IEnumerable <object> Index()
        {
            var listaConverter = new ListConverters();

            return(listaConverter.ListaCondicoes.Select(x => new {
                Bandeira = x.Bandeira,
                Internacional = x.Internacional,
                Debito = x.Debito
            }));
        }
示例#3
0
        public static void ParticipantDataToCSV(IList <Participant> allParticipants, IEnumerable <Vaccine> allVaccines, char delimiter, string dateFormat, bool encloseStringInQuotes, bool encloseDateInQuotes, TextWriter writer)
        {
            var participants = ListConverters.ToStringValues(allParticipants, CSVOptions(dateFormat, encloseStringInQuotes, encloseDateInQuotes));

            for (int c = 0; c < participants.PropertiesDetail.Count; c++)
            {
                if (c > 0)
                {
                    writer.Write(delimiter);
                }
                writer.Write(participants.PropertiesDetail[c].Name);
            }
            foreach (var v in allVaccines)
            {
                writer.Write(delimiter);
                writer.Write(ListConverters.StataSafeVarname(v.Name, ""));
            }
            writer.Write("\r\n");
            int[] vaccineIds = allVaccines.Select(v => v.Id).ToArray();
            for (int r = 0; r < participants.StringValues.Length; r++)
            {
                writer.Write(participants.StringValues[r][0]);
                for (int c = 1; c < participants.PropertiesDetail.Count; c++)
                {
                    writer.Write(delimiter);
                    writer.Write(participants.StringValues[r][c]);
                }
                foreach (int vid in vaccineIds)
                {
                    writer.Write(delimiter);
                    var admin = allParticipants[r].VaccinesAdministered.FirstOrDefault(va => va.VaccineId == vid);
                    if (admin != null)
                    {
                        writer.Write(admin.AdministeredAt.ToString(dateFormat));
                    }
                }
                writer.Write("\r\n");
            }
        }
示例#4
0
        public void Save(object param)
        {
            if (!IsValid())
            {
                throw new InvalidOperationException("CreateCsvViewModel not valid - cannot call save");
            }
            string dofile = null;

            switch (TableType)
            {
            case TableOptions.Participant:
                var vaccines = _repository.Vaccines.ToList();
                try
                {
                    using (StreamWriter sw = new StreamWriter(_model.Filename))
                    {
                        PatientDataToCSV.ParticipantDataToCSV(_repository.Participants.Include("VaccinesAdministered").ToList(), vaccines, SelectedFileType.Delimiter, DateFormat, IsStringInQuotes, IsDateInQuotes, sw);
                    }
                }
                catch (System.IO.IOException e)
                {
                    System.Windows.MessageBox.Show(e.Message);
                    return;
                }
                if (SimultaneousStata)
                {
                    dofile = new ParticipantDataStataTemplate(
                        new ParticipantStataData(_model.FileNameWithExtension,
                                                 SelectedFileType.Delimiter,
                                                 _repository.LocalStudyCentres.Select(s => new KeyValuePair <int, string>(s.Id, s.Name)),
                                                 vaccines.Select(v => v.Name)
                                                 )).TransformText();
                }
                break;

            case TableOptions.ScreenedPatients:
                var screened           = Mapper.Map <ScreenedPatientCsvModel[]>(_repository.ScreenedPatients.ToArray());
                var csvEncodedScreened = ListConverters.ToCSV(screened, SelectedFileType.Delimiter, PatientDataToCSV.CSVOptions(DateFormat, IsStringInQuotes, IsDateInQuotes));
                try
                {
                    File.WriteAllText(_model.FileNameWithExtension, csvEncodedScreened);
                }
                catch (System.IO.IOException e)
                {
                    System.Windows.MessageBox.Show(e.Message);
                    return;
                }
                if (SimultaneousStata)
                {
                    dofile = new ScreenedPatientStataTemplate(new CentreStataData(
                                                                  _model.FileNameWithExtension,
                                                                  SelectedFileType.Delimiter,
                                                                  _repository.LocalStudyCentres.Select(s => new KeyValuePair <int, string>(s.Id, s.Name))
                                                                  )).TransformText();
                }
                break;

            case TableOptions.ProtocolViolations:
                var viol            = _repository.ProtocolViolations.ToArray();
                var csvEncodedViols = ListConverters.ToCSV(viol, SelectedFileType.Delimiter, PatientDataToCSV.CSVOptions(DateFormat, IsStringInQuotes, IsDateInQuotes));
                try
                {
                    File.WriteAllText(_model.FileNameWithExtension, csvEncodedViols);
                }
                catch (System.IO.IOException e)
                {
                    System.Windows.MessageBox.Show(e.Message);
                    return;
                }
                if (SimultaneousStata)
                {
                    dofile = new ScreenedPatientStataTemplate(new CentreStataData(
                                                                  _model.FileNameWithExtension,
                                                                  SelectedFileType.Delimiter,
                                                                  _repository.LocalStudyCentres.Select(s => new KeyValuePair <int, string>(s.Id, s.Name))
                                                                  )).TransformText();
                }
                break;

            default:
                throw new InvalidOperationException("save called no table selected");
            }
            if (dofile != null)
            {
                try
                {
                    File.WriteAllText(Path.ChangeExtension(_model.Filename, "do"), dofile);
                }
                catch (System.IO.IOException e)
                {
                    System.Windows.MessageBox.Show(e.Message);
                    return;
                }
            }
            CloseCmd.Execute(null);
        }