|
42 | 42 | using DotNetNuke.UI.WebControls; |
43 | 43 | using DotNetNuke.Services.Mail; |
44 | 44 | using DotNetNuke.Security.Permissions; |
| 45 | +using DotNetNuke.Services.Exceptions; |
45 | 46 |
|
46 | 47 | namespace DotNetNuke.Modules.Repository |
47 | 48 | { |
48 | 49 |
|
49 | 50 | public abstract class Repository : Entities.Modules.PortalModuleBase, Entities.Modules.Communications.IModuleListener |
50 | 51 | { |
51 | | - |
52 | | - #region "Controls" |
53 | | - protected Label lblDescription; |
| 52 | + static Instrumentation.DnnLogger log = Instrumentation.DnnLogger.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString()); |
| 53 | + #region "Controls" |
| 54 | + protected Label lblDescription; |
54 | 55 | private DataGrid withEventsField_lstObjects; |
55 | 56 | protected DataGrid lstObjects { |
56 | 57 | get { return withEventsField_lstObjects; } |
@@ -406,8 +407,48 @@ public void lstObjects_PageIndexChanged(object source, DataGridPageChangedEventA |
406 | 407 | BindObjectList(); |
407 | 408 |
|
408 | 409 | } |
409 | | - |
410 | | - private void SendCommentNotification(RepositoryInfo objRepository, TextBox txtName, TextBox txtComment) |
| 410 | + private void SendDownloadNotification(RepositoryInfo objRepository) |
| 411 | + { |
| 412 | + try |
| 413 | + { |
| 414 | + log.ErrorFormat("Download: {0} {1}", Settings["EmailOnDownload"], Settings["EmailOnDownloadAddress"]); |
| 415 | + // check to see if we need to send an email notification |
| 416 | + if (string.IsNullOrEmpty(Convert.ToString(Settings["EmailOnDownload"])) == false) |
| 417 | + { |
| 418 | + if (bool.Parse(Settings["EmailOnDownload"].ToString()) == true) |
| 419 | + { |
| 420 | + string _email = Convert.ToString(Settings["EmailOnDownloadAddress"]); |
| 421 | + if (string.IsNullOrEmpty(_email) == false) |
| 422 | + { |
| 423 | + // send an email |
| 424 | + string _subject = string.Format("[{0}] New Download from Your Repository", PortalSettings.PortalName); |
| 425 | + System.Text.StringBuilder _body = new System.Text.StringBuilder(); |
| 426 | + _body.Append(string.Format("A new download at {0}<br />", System.DateTime.Now)); |
| 427 | + _body.Append(string.Format("by {0} ({1})<br /><br />", UserInfo.DisplayName, UserInfo.Email)); |
| 428 | + _body.Append(string.Format("File {0}<br /><br />", objRepository.FileName)); |
| 429 | + _body.Append("------------------------------------------------------------<br />"); |
| 430 | + _body.Append(string.Format("{0}<br />", this.Request.UserHostAddress)); |
| 431 | + Mail.SendMail( |
| 432 | + PortalSettings.Email, |
| 433 | + _email, |
| 434 | + "", "", |
| 435 | + Services.Mail.MailPriority.Normal, |
| 436 | + _subject, |
| 437 | + Services.Mail.MailFormat.Html, |
| 438 | + System.Text.Encoding.Default, |
| 439 | + _body.ToString(), |
| 440 | + "", "", "", "", ""); |
| 441 | + } |
| 442 | + } |
| 443 | + } |
| 444 | + } |
| 445 | + catch (Exception ex) |
| 446 | + { |
| 447 | + Exceptions.ProcessModuleLoadException(this, ex); |
| 448 | + } |
| 449 | + } |
| 450 | + |
| 451 | + private void SendCommentNotification(RepositoryInfo objRepository, TextBox txtName, TextBox txtComment) |
411 | 452 | { |
412 | 453 | // check to see if we need to send an email notification |
413 | 454 | if (!string.IsNullOrEmpty(Convert.ToString(Settings["EmailOnComment"]))) { |
@@ -504,7 +545,8 @@ public void lstObjects_ItemCommand(object source, DataGridCommandEventArgs e) |
504 | 545 | string target = oRepositoryBusinessController.GetSkinAttribute(xmlDoc, "DOWNLOAD", "Target", "NEW"); |
505 | 546 | oRepositoryBusinessController.DownloadFile(e.CommandArgument.ToString(), target); |
506 | 547 |
|
507 | | - break; |
| 548 | + SendDownloadNotification(objRepository); |
| 549 | + break; |
508 | 550 | case "PostComment": |
509 | 551 | objCommentsPanel = null; |
510 | 552 | TextBox txtName = null; |
@@ -736,7 +778,8 @@ private void DataList1_ItemCommand(object source, System.Web.UI.WebControls.Data |
736 | 778 | string target = oRepositoryBusinessController.GetSkinAttribute(xmlDoc, "DOWNLOAD", "Target", "NEW"); |
737 | 779 | oRepositoryBusinessController.DownloadFile(e.CommandArgument.ToString(), target); |
738 | 780 |
|
739 | | - break; |
| 781 | + SendDownloadNotification(objRepository); |
| 782 | + break; |
740 | 783 | case "PostComment": |
741 | 784 | objCommentsPanel = null; |
742 | 785 | TextBox txtName = null; |
@@ -797,8 +840,7 @@ private void DataList1_ItemCommand(object source, System.Web.UI.WebControls.Data |
797 | 840 |
|
798 | 841 | } |
799 | 842 |
|
800 | | - |
801 | | - private void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) |
| 843 | + private void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) |
802 | 844 | { |
803 | 845 | if (e.Item.ItemType == ListItemType.Item | e.Item.ItemType == ListItemType.AlternatingItem) { |
804 | 846 | PlaceHolder holder = (PlaceHolder)e.Item.FindControl("PlaceHolder1"); |
|
0 commit comments