예제 #1
0
        public static void ExportCSV <TBody, TBodyList>(string configFile, string tableId, string exportId, Stream targetStream, TBodyList tList,
                                                        DataValidatingHandler <TBody, TBodyList> dataValidater = null, GetValueHandler <TBody> getValueCallback = null)
            where TBody : class
            where TBodyList : class
        {
            CSVExport <TBody, TBodyList> export = CreateCSVExport <TBody, TBodyList>(configFile, tableId, exportId, dataValidater, getValueCallback);

            export.Export(targetStream, tList);
            export.Dispose();
        }
예제 #2
0
        /// <summary>
        /// Export data to a stream
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="tList"></param>
        public static void ExportExcel <TBody, TBodyList>(string configFile, string tableId, string exportId, Stream stream, TBodyList tList,
                                                          DataValidatingHandler <TBody, TBodyList> dataValidater = null, ExtendDataWritingHandler <TBody, TBodyList> extendDataWriter = null, TableWritingHandler tableHeaderWriter = null,
                                                          TableWritingHandler tableFooterWriter = null, PageWritingHandler pageHeaderWriter = null, PageWritingHandler pageFooterWriter = null, GetValueHandler <TBody> getValueCallback = null)
            where TBody : class
            where TBodyList : class
        {
            NPOIExport <TBody, TBodyList> export = CreateNPOIExport <TBody, TBodyList>(configFile, tableId, exportId, dataValidater, extendDataWriter, tableHeaderWriter, tableFooterWriter, pageHeaderWriter, pageFooterWriter, getValueCallback, null);

            export.Export(stream, tList);
            export.Dispose();
        }
예제 #3
0
        private static CSVImport <T, TList> CreateCsvImport <T, TList>(string configFile, string tableId, string importId, bool withEvents,
                                                                       SourceDataValidatingHandler <DataRow, DataTable> sourceDataVilidater = null, DataValidatingHandler <T, TList> targetDataValidater = null)
            where T : class, new()
            where TList : class
        {
            CSVImport <T, TList> import = new CSVImport <T, TList>(configFile, tableId);

            import.ImportId = importId;

            if (withEvents)
            {
                if (sourceDataVilidater != null)
                {
                    import.SourceDataValidating += sourceDataVilidater;
                }

                if (targetDataValidater != null)
                {
                    import.TargetDataValidating += targetDataValidater;
                }
            }

            return(import);
        }
예제 #4
0
        public static void ImportCsv <T, TList>(string configFile, string tableId, string importId, string sourceFile, TList successList, TList failList,
                                                bool withEvents, SourceDataValidatingHandler <DataRow, DataTable> sourceDataVilidater = null, DataValidatingHandler <T, TList> targetDataValidater = null)
            where T : class, new()
            where TList : class
        {
            CSVImport <T, TList> import = CreateCsvImport <T, TList>(configFile, tableId, importId, withEvents, sourceDataVilidater, targetDataValidater);

            import.Import(sourceFile, successList, failList);
            import.Dispose();
        }
예제 #5
0
        private static CSVExport <TBody, TBodyList> CreateCSVExport <TBody, TBodyList>(string configFile, string tableId, string exportId,
                                                                                       DataValidatingHandler <TBody, TBodyList> dataValidater, GetValueHandler <TBody> getValueCallback)
            where TBody : class
            where TBodyList : class
        {
            CSVExport <TBody, TBodyList> export = new CSVExport <TBody, TBodyList>(configFile, tableId);

            export.ExportId = exportId;

            if (dataValidater != null)
            {
                export.SourceDataValidating += dataValidater;
            }

            if (getValueCallback != null)
            {
                export.GetValueCallback += getValueCallback;
            }

            return(export);
        }
예제 #6
0
        private static NPOIExport <TBody, TBodyList> CreateNPOIExport <TBody, TBodyList>(string configFile, string tableId, string exportId,
                                                                                         DataValidatingHandler <TBody, TBodyList> dataValidater, ExtendDataWritingHandler <TBody, TBodyList> extendDataWriter, TableWritingHandler tableHeaderWriter,
                                                                                         TableWritingHandler tableFooterWriter, PageWritingHandler pageHeaderWriter, PageWritingHandler pageFooterWriter, GetValueHandler <TBody> getValueCallback, GetValueHandler <object> getHeaderValueCallback)
            where TBody : class
            where TBodyList : class
        {
            NPOIExport <TBody, TBodyList> export = new NPOIExport <TBody, TBodyList>(configFile, tableId);

            export.ExportId = exportId;

            if (dataValidater != null)
            {
                export.SourceDataValidating += dataValidater;
            }

            if (extendDataWriter != null)
            {
                export.ExtendDataWriting += extendDataWriter;
            }

            if (tableHeaderWriter != null)
            {
                export.TableHeaderWriting += tableHeaderWriter;
            }

            if (tableFooterWriter != null)
            {
                export.TableFooterWriting += tableFooterWriter;
            }

            if (pageHeaderWriter != null)
            {
                export.PageHeaderWriting += pageHeaderWriter;
            }

            if (pageFooterWriter != null)
            {
                export.PageFooterWriting += pageFooterWriter;
            }

            if (getValueCallback != null)
            {
                export.GetValueCallback += getValueCallback;
            }

            if (getHeaderValueCallback != null)
            {
                export.GetHeaderValueCallback += getHeaderValueCallback;
            }

            return(export);
        }