public HttpResponseMessage <SampleTable> GetSampleTable([FromUri] int hrow, [FromUri] int drow, [FromUri] FileInfo fileInfo, [FromUri] string sheet, [FromUri] int?last = null)
        {
            if (fileInfo == null)
            {
                throw new WebArgumentNullException(nameof(fileInfo));
            }
            if (hrow < 0)
            {
                throw new WebArgumentOutOfRangeException(nameof(hrow));
            }
            if (drow < 0)
            {
                throw new WebArgumentOutOfRangeException(nameof(drow));
            }

            Interface.SampleTable sampleTable;

            sampleTable = _spreadsheetInspector.GetSampleTable(fileInfo.FileId, GetFileFormat(fileInfo.FileFormat), sheet, hrow, drow, last);

            if (sampleTable == null)
            {
                return(new HttpResponseMessage <SampleTable>(HttpStatusCode.NotFound));
            }

            return(new HttpResponseMessage <SampleTable>(PackSampleTable(sampleTable), HttpStatusCode.OK));
        }
Пример #2
0
        public static ImportRun RunTest(EntityType entityType, string fileName, ImportFormat importFormat, string sheetName = null)
        {
            string fileToken;

            using (Stream stream = SheetTestHelper.GetStream(fileName))
            {
                fileToken = FileRepositoryHelper.AddTemporaryFile(stream);
            }


            EntityType   type         = entityType;
            ImportConfig importConfig = CreateImportConfig(type, importFormat, sheetName);

            ImportRun importRun = CreateImportRun(importConfig, fileToken);

            ISpreadsheetInspector inspector = Factory.Current.Resolve <ISpreadsheetInspector>( );
            SpreadsheetInfo       info      = inspector.GetSpreadsheetInfo(fileToken, importFormat);
            SampleTable           sample    = inspector.GetSampleTable(fileToken, importFormat, sheetName, 1, 2, null);

            AddAllFields(importConfig, sample);

            // Run import
            IImportRunWorker worker = Factory.Current.Resolve <IImportRunWorker>( );

            worker.StartImport(importRun.Id);

            return(importRun);
        }