ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TelerikUpload.aspx.cs" Inherits="ImportMPV2_WebTest.TelerikUpload" %>
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
></
telerik:RadScriptManager
>
<
div
>
<
telerik:RadAsyncUpload
AllowedFileExtensions
=
"xlsx"
EnableInlineProgress
=
"true"
ID
=
"RadAsyncUpload1"
MaxFileInputsCount
=
"1"
MultipleFileSelection
=
"Disabled"
OnFileUploaded
=
"RadAsyncUpload1_FileUploaded"
RenderMode
=
"Lightweight"
runat
=
"server"
Skin
=
"Telerik"
TargetDir
=
"Uploads"
>
<
FileFilters
>
<
telerik:FileFilter
Description
=
"Excel Files(xlsx)"
Extensions
=
"xlsx"
/>
</
FileFilters
>
</
telerik:RadAsyncUpload
>
</
div
>
<
br
/>
<
telerik:RadButton
AutoPostBack
=
"true"
runat
=
"server"
Text
=
"Import"
Skin
=
"Telerik"
/>
</
form
>
<
pre
>
<
asp:label
id
=
"lblUploadResults"
runat
=
"server"
></
asp:label
>
</
pre
>
<
pre
>
<
asp:label
id
=
"lblSSISResults"
runat
=
"server"
></
asp:label
>
</
pre
>
</
body
>
</
html
>
Code behind:
protected
void
RadAsyncUpload1_FileUploaded(
object
sender, FileUploadedEventArgs e)
{
UploadedFile uploadFile = e.File;
string
xlFilePath = Path.Combine(Server.MapPath(WebConfigurationManager.AppSettings[
"uploadDir"
]), uploadFile.FileName);
// Display upload results
lblUploadResults.Text =
"File Uploaded\n"
+
"File name: "
+ uploadFile.FileName +
"\n"
+
"Content type: "
+ uploadFile.ContentType +
"\n"
+
"Content length: "
+ uploadFile.ContentLength +
"\n"
+
"Last modified date: "
+ uploadFile.LastModifiedDate +
"\n"
;
// Execute SSIS package
SSISExecutor ssisExecutor =
new
SSISExecutor(
xlFilePath
,
"Balance Import"
,
"gregorym"
,
false
, WebConfigurationManager.AppSettings[
"logFilePath"
]
, WebConfigurationManager.ConnectionStrings[
"DatabasePEP1"
].ConnectionString
);
ssisExecutor.Exec(
out
List<
string
> resultList);
// Display SSIS results
string
s =
"SSIS results:\n"
+ xlFilePath +
":\n\n"
;
foreach
(
string
result
in
resultList)
{
s += result +
"\n"
;
}
lblSSISResults.Text = s;
}
Output:
File Uploaded
File name: ImportV2_Sample.xlsx
Content type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Content length: 326210
Last modified date: 1/13/2020 4:47:40 PM
SSIS results:
C:\ImportMPV2_WebTest\Uploads\ImportV2_Sample.xlsx:
Error: File "C:\ImportMPV2_WebTest\Uploads\ImportV2_Sample.xlsx" not found