|
@@ -1792,7 +1792,36 @@ namespace PRSDesktop
|
|
|
|
|
|
private void DoEmailReport(DataModel model, byte[] data)
|
|
|
{
|
|
|
- EmailUtils.CreateEMLFile(model.Name, data, App.EmployeeEmail, "Emailing report for " + model.Name);
|
|
|
+ string attachmentName = DetermineName(model);
|
|
|
+
|
|
|
+ EmailUtils.CreateEMLFile(attachmentName, data, App.EmployeeEmail, "Emailing report for " + attachmentName);
|
|
|
+ }
|
|
|
+
|
|
|
+ private string DetermineName(DataModel model)
|
|
|
+ {
|
|
|
+ string title = model.Name;
|
|
|
+ if (model.AsDictionary.ContainsKey(typeof(Requisition)))
|
|
|
+ {
|
|
|
+ CoreTable table = model.AsDictionary[typeof(Requisition)];
|
|
|
+ title = title + " - " + table.Rows.FirstOrDefault().Get<Requisition, string>(x => x.Title);
|
|
|
+ }
|
|
|
+ else if (model.AsDictionary.ContainsKey(typeof(PurchaseOrder)))
|
|
|
+ {
|
|
|
+ title = "Purchase Order";
|
|
|
+ CoreTable table = model.AsDictionary[typeof(PurchaseOrder)];
|
|
|
+ if (table.Rows.Count == 1)
|
|
|
+ title = title + table.Rows.FirstOrDefault().Get<PurchaseOrder, string>(x => x.PONumber);
|
|
|
+ else if (table.Rows.Count > 1)
|
|
|
+ {
|
|
|
+ foreach (CoreRow row in table.Rows)
|
|
|
+ {
|
|
|
+ title = title + row.Get<PurchaseOrder, string>(x => x.PONumber) + ", ";
|
|
|
+ }
|
|
|
+ title = title.Substring(0, title.Length - 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return title;
|
|
|
}
|
|
|
#endregion
|
|
|
|