Hi @Jono
The connect timeout was set to 60 in the config and after I added more time it still broke and timed out after 10 minutes. Is there another solution, I'll post the code example below.
{using (var scope = new TransactionScope(TransactionScopeOption.Required, new System.TimeSpan(1, 0, 0)))
{
try
{
string dir = HttpContext.Current.Server.MapPath("\\");
HSSFWorkbook hssfwb;
using (FileStream file = new FileStream(dir + @"\DataImport\SC_Import.xls", FileMode.Open, FileAccess.Read))
{
hssfwb = new HSSFWorkbook(file);
}
List<SolutionCategoryItem> solutionCategories = new List<SolutionCategoryItem>();
//Excel.Range range = worksheet.UsedRange;
//int rowCount = range.Rows.Count;
ISheet sheet = hssfwb.GetSheetAt(0);
for (int row = 1; row <= sheet.LastRowNum; row++)
{
if (sheet.GetRow(row) != null) //null is when the row only contains empty cells
{
var ifpCategory1 = sheet.GetRow(row).GetCell(0).StringCellValue;
var titleValue = sheet.GetRow(row).GetCell(1).StringCellValue;
var descriptionValue = sheet.GetRow(row).GetCell(2).StringCellValue;
SolutionCategoryItem item = new SolutionCategoryItem
{
IFPCategory1 = ifpCategory1,
Title = titleValue,
Description = descriptionValue
};
solutionCategories.Add(item);
}
}
//ADD TO CATEGORIES MODULE
// Gets the parent category
CategoryInfo parentCategory = CategoryInfoProvider.GetCategoryInfo("SolutionCategories", SiteContext.CurrentSiteName);
if (parentCategory != null)
{
if (solutionCategories.Any())
{
foreach (var item in solutionCategories)
{
if (item != null)
{
// Creates a new category object
CategoryInfo subcategory = new CategoryInfo();
// Sets basic properties
subcategory.CategoryDisplayName = item.Title;
//subcategory.CategoryName = item.Title.Replace(" ", "");
var tempStr = Regex.Replace(item.Title, "[^A-Za-z0-9]", "");
subcategory.CategoryName = tempStr;
subcategory.CategoryDescription = item.Description;
subcategory.CategorySiteID = SiteContext.CurrentSiteID;
subcategory.CategoryEnabled = true;
// Assigns to the parent category
if (!string.IsNullOrEmpty(item.IFPCategory1))
{
CategoryInfo SolutionCategoryParent = CategoryInfoProvider.GetCategoryInfo(item.IFPCategory1, SiteContext.CurrentSiteName);
if (SolutionCategoryParent != null)
{
subcategory.CategoryParentID = SolutionCategoryParent.CategoryID;
}
}
// Saves the category to the database
CategoryInfoProvider.SetCategoryInfo(subcategory);
}
}
}
scope.Complete();
HttpContext.Current.Response.ContentType = "text/html";
HttpContext.Current.Response.Write("Solution categories added successfully...");
}
}
catch (Exception e)
{
HttpContext.Current.Response.ContentType = "text/html";
HttpContext.Current.Response.Write(e.Message);
}
}
}