コード例 #1
0
        public async Task <IActionResult> CreateTable([FromBody] TableFile tableFile)
        {
            try
            {
                Guid guid = Guid.NewGuid();

                string tableGuid = guid.ToString();

                //save meta data about data set
                int insertedId = await tableFile.InsertDataTable(_dal, tableGuid);

                //save meta data about columns
                tableFile.InsertColumns(insertedId, _dal);

                //create table and insert rows into it
                try
                {
                    var    folderName = "TableFiles";
                    string pathToSave = Path.Combine(Directory.GetCurrentDirectory(), folderName);
                    string fullPath   = Path.Combine(pathToSave, tableFile.FileName);

                    tableFile.CreateTableAndLoadData(tableGuid, pathToSave, fullPath, _dal, _signalHubContext);

                    return(Ok());
                }
                catch (Exception ex)
                {
                    tableFile.RollBackInserts(insertedId, _dal, tableGuid);

                    return(StatusCode(500, ex.Message));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }