Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. // Get Current Row So We Know Where To Start From.
  2. int currentRow = excelWorksheet.Dimension.End.Row;
  3.  
  4. string campaignDate = string.Join("", sourceExcelPackage.Worksheet(DATABASE_1_WORKSHEET).Select(x => x["CAMPAIGN_DATE"].Value));
  5.  
  6. // Start The Real Work.
  7. foreach (var row in sourceExcelPackage.Worksheet(EVENT_1_WORKSHEET))
  8. {
  9. // CustomerID
  10. string customerId = row["CustomerId"].Value.ToString();
  11.  
  12. // Create Report Object To Help Keep Things Readable.
  13. ReportObject reportObject = new ReportObject
  14. {
  15. EventType = row["EventType"].Value.ToString(),
  16. DateCreated = row["DateCreated"].Value.ToString(),
  17. EmailType = row["Context"].Value.ToString(),
  18. LinkClicked = row["Destination"].Value.ToString(),
  19. CampaignDate = campaignDate,
  20. SupporterID = string.Join("", sourceExcelPackage.Worksheet(DATABASE_1_WORKSHEET).Where(x => x["DSM_CustomerID"] == customerId)
  21. .Select(x => x["SUPPORTER_ID"].Value)),
  22.  
  23. PathwayStageHistoryOID = string.Join("", sourceExcelPackage.Worksheet(DATABASE_1_WORKSHEET).Where(x => x["DSM_CustomerID"] == customerId)
  24. .Select(x => x["PATHWAY_STAGE_HISTORY_OID"].Value))
  25. };
  26.  
  27. // Add Next Row.
  28. currentRow++;
  29.  
  30. // Assign Data Here.
  31. excelWorksheet.Cells[currentRow, 1].Value = reportObject.SupporterID;
  32. excelWorksheet.Cells[currentRow, 2].Value = reportObject.CampaignDate;
  33. excelWorksheet.Cells[currentRow, 3].Value = reportObject.EmailType;
  34. excelWorksheet.Cells[currentRow, 4].Value = reportObject.DateCreated;
  35. excelWorksheet.Cells[currentRow, 5].Value = reportObject.EventType;
  36. excelWorksheet.Cells[currentRow, 6].Value = reportObject.LinkClicked;
  37. excelWorksheet.Cells[currentRow, 7].Value = reportObject.PathwayStageHistoryOID;
  38.  
  39. // Return the current row as we may
  40. // use this to build some sort of progress.
  41. yield return currentRow;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement