public Task <DataFile> Upload(string database = null)
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            database = ValidateDatabaseName(database);
            string root = System.Web.HttpContext.Current.Server.MapPath(DataConfig.uploadDir);
            MultipartFormDataStreamProvider provider = new MultipartFormDataStreamProvider(root);

            Task <DataFile> task = Request.Content.ReadAsMultipartAsync(provider).ContinueWith(o => {
                MultipartFileData data = provider.FileData.First();
                string path            = data.LocalFileName;
                string fileName        = data.Headers.ContentDisposition.FileName;

                DataFile file = new DataFile(path, fileName, database);
                if (file.dataType == DataType.Archive)
                {
                    throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
                }

                IDatabaseContext context        = DatabaseContextFactory.CreateDatabaseContext(database);
                DataLoaderHandler loaderHandler = new DataLoaderHandler(context);

                loaderHandler.ImportData(file);

                return(file);
            });

            return(task);
        }
        public string GetExport(string database, string type)
        {
            IDatabaseContext  context       = DatabaseContextFactory.CreateDatabaseContext(database);
            DataLoaderHandler loaderHandler = new DataLoaderHandler(context);
            DataFile          file          = loaderHandler.ExportData(DataTypeConverter.Convert(type), database);
            string            downloadUrl   = Path.Combine(Request.RequestUri.GetLeftPart(UriPartial.Authority), file.relativePath);

            return(downloadUrl);
        }