/// <summary> /// DoWork is virtual method of LongRunningOperationJob base class and overrided into BatchImportLongRunningProcess. /// </summary> public override void DoWork() { this.StatusDescription = "Batch Import started..."; this.UpdateStatus(); string strError = string.Empty; this.Title = "Batch Import"; this.WaitMessage = "Please wait while all the documents are uploaded..."; this.RedirectWhenFinished = false; this.UserCanCancel = true; this.MillisecondsToWaitForFinish = 100; this.TotalOperationsToBePerformed = 100; string strCompletePath = string.Empty; string strFileName = string.Empty; int intCounter = 1; DataTable dtBatchLog = new DataTable(); dtBatchLog.Columns.Add("PageName"); dtBatchLog.Columns.Add("ChapterName"); dtBatchLog.Columns.Add("DateAndTime"); dtBatchLog.Columns.Add("Status"); dtBatchLog.Columns.Add("Detail"); foreach (DataRow eachRow in dtBatchUpload.Rows) { strError = string.Empty; this.StatusDescription = "Uploading Document " + intCounter.ToString(); this.UpdateStatus(); try { #region Call UploadFile to document library if (this.UserRequestedCancel) { break; } else { //Fetch the complete path from data table strCompletePath = eachRow["CompleteSharedPath"].ToString(); if (!string.IsNullOrEmpty(strCompletePath)) { strFileName = strCompletePath.Substring(strCompletePath.LastIndexOf("\\") + 1); UploadFileToDocumentLibrary(strCompletePath, strFileName, eachRow["PageId"].ToString()); } } #endregion Call UploadFile to document library } catch (FileNotFoundException fnfException) { strError = fnfException.Message; dtBatchLog.Rows.Add(eachRow["PageName"].ToString(), eachRow["ChapterName"].ToString(), DateTime.Now, "Fail", strError); continue; } catch (Exception Ex) { strError = Ex.Message; dtBatchLog.Rows.Add(eachRow["PageName"].ToString(), eachRow["ChapterName"].ToString(), DateTime.Now, "Fail", strError); continue; } if (string.IsNullOrEmpty(strError)) { dtBatchLog.Rows.Add(eachRow["PageName"].ToString(), eachRow["ChapterName"].ToString(), DateTime.Now, "Success", ""); } this.OperationsPerformed++; } //Add BatchLog data table to sharepoint list. objWellBookBLL = new WellBookBLL(); objWellBookBLL.SaveBatchImportLog(Web.Url, BATCHIMPORTLOGLISTNAME, dtBatchLog); if (this.UserRequestedCancel) { this.StatusDescription = "Batch Import Could not complete as you have canceled the process in between."; } else { this.StatusDescription = "Batch Import Process completed successfully, Please check the logs to know more details."; } this.NavigateWhenDoneUrl = "/Pages/BatchImportStatus.aspx?status=" + this.StatusDescription; this.UpdateStatus(); }