Exemple #1
0
        private void LoadDetailFile()
        {
            var provider = new CsvProvider();
            var schools  = provider.Read(this.shellViewModel.DetailFilePath);

            //var distinct = (from s in schools
            //                select s).DistinctBy(s => s.SchoolFullName);

            //this.shellViewModel.Schools.Clear();

            //foreach (var school in distinct)
            //{
            //    this.shellViewModel.Schools.Add(new SchoolViewModel(school));
            //}
        }
        public CsvProvider MapProviderToCsvProvider(Provider result)
        {
            var csvProvider = new CsvProvider
            {
                Ukprn        = result.Ukprn,
                Name         = result.Name,
                ProviderType = Enumerations.GetEnumDescription(result.ProviderType),
                NewOrganisationWithoutFinancialTrackRecord = result.NewOrganisationWithoutFinancialTrackRecord,
                ParentCompanyGuarantee = result.ParentCompanyGuarantee,
                StartDate = FormatDate(result.StartDate),
                ProviderNotCurrentlyStartingNewApprentices = result.CurrentlyNotStartingNewApprentices ? "TRUE":string.Empty,
                ApplicationDeterminedDate = FormatDate(result.ApplicationDeterminedDate)
            };

            return(csvProvider);
        }
        static async Task Main(string[] args)
        {
            var config = new OpcoesServico();

            config.DirArqImportar         = @"C:\Laranjeiras\OutputCnpjPublico\Fontes";
            config.DirTrabalho            = @"C:\Laranjeiras\OutputCnpjPublico";
            config.TamanhoLote            = 100_000;
            config.RegistroInicial        = 0_000_000;
            config.QuantRegistrosImportar = 1_000_000_000;

            EFContexto.SqlLiteDatabaseName = $"SqlLite_DadosPublicosCnpj.db";

            // Provider para EF/Sqlite
            //var provider = new EFProvider();
            var provider = new CsvProvider(config.DirTrabalho);
            var servico  = new ImportarServico(provider, config);
            await servico.ExecutarAsync();
        }
Exemple #4
0
        private static void Main(string[] args)
        {
            var e = new ExcelProvider();

            e.Read(OdsFile, "KiTa");

            var data = File.ReadAllBytes(CsvFile);


            var lines = File.ReadAllLines(CsvFile);

            using (var reader = new StreamReader(CsvFile, true))
            {
                reader.Read();
                Console.WriteLine(reader.CurrentEncoding);
            }



            var c = new CsvProvider();

            c.Read(CsvFile);
        }
        public CsvProvider MapCsv(RoatpResult result)
        {
            if (!long.TryParse(result?.Ukprn, out long ukprn))
            {
                return(null);
            }

            var csvProvider = new CsvProvider
            {
                Ukprn        = ukprn,
                Name         = result.OrganisationName,
                ProviderType = result?.ProviderType,
                NewOrganisationWithoutFinancialTrackRecord = !string.IsNullOrEmpty(result.NewOrganisationWithoutFinancialTrackRecord) && result.NewOrganisationWithoutFinancialTrackRecord.ToUpper() == "Y",
                ParentCompanyGuarantee = result.ParentCompanyGuarantee != null && result.ParentCompanyGuarantee.ToUpper() == "Y",


                StartDate = FormatDate(result?.StartDate),
                ProviderNotCurrentlyStartingNewApprentices = result.ProviderNotCurrentlyStartingNewApprentices != null ? "TRUE" : string.Empty,
                ApplicationDeterminedDate = FormatDate(result?.ApplicationDeterminedDate)
            };

            return(csvProvider);
        }
Exemple #6
0
        private void ExportToFile(object parameter)
        {
            if (parameter == null)
            {
                return;
            }

            string exportType = parameter.ToString().ToUpper();
            string filter     = string.Empty;

            switch (exportType)
            {
            case "EXCEL":
                exportType = exportType.ToLower();
                filter     = "Excel Files(*.xlsx)|*.xlsx|All(*.*)|*";
                break;

            case "CSV":
                exportType = exportType.ToLower();
                filter     = "Csv Files(*.csv)|*.csv|All(*.*)|*";
                break;

            default:
                return;
            }

            string excelFile = ModelInfoSelected.ModelName + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
            var    dialog    = new SaveFileDialog()
            {
                FileName = excelFile,
                Filter   = filter
            };

            if (dialog.ShowDialog() == true)
            {
                excelFile = dialog.FileName;
                bool   exportResult = false;
                string title        = string.Empty;

                if (exportType == "excel")
                {
                    exportResult = ExcelProvider.Export(ModuleItems, excelFile);
                    title        = "Export To Excel";
                }
                else
                {
                    exportResult = CsvProvider.Export(ModuleItems, excelFile);
                    title        = "Export To Csv";
                }

                BBCodeBlock codeBlock = new BBCodeBlock();
                if (exportResult)
                {
                    codeBlock.BBCode = string.Format("Succesfully exported {0} model data to {1}.\nFile: {2}.\n[color=Green]Open file?[/color]", ModelInfoSelected.ModelName, exportType, excelFile);

                    var dlg = new ModernDialog
                    {
                        Title   = title,
                        Content = codeBlock
                    };
                    dlg.Buttons = new[] { dlg.YesButton, dlg.NoButton };
                    bool?result = dlg.ShowDialog();
                    if (result != null && result.Value)
                    {
                        Process.Start(excelFile);
                    }
                }
                else
                {
                    codeBlock.BBCode = string.Format("Error exporting {0} model data to {1}.\nFile: {2}.\n[color=Red]Please try again.[/color]", ModelInfoSelected.ModelName, exportType, excelFile);
                    var dlg = new ModernDialog
                    {
                        Title   = title,
                        Content = codeBlock
                    };
                    dlg.Buttons = new[] { dlg.OkButton };
                    dlg.ShowDialog();
                }
            }
        }