protected void btnSend_Click(object sender, EventArgs e) { // Validate date/time if (dtpMailout.SelectedDateTime == DateTimeHelper.ZERO_TIME) { ShowError(GetString("newsletterissue_send.invaliddatetime")); return; } IssueInfo winner = (IssueInfo)EditedObject; int parentIssueId = winner.IssueVariantOfIssueID; // Get A/B test info ABTestInfo abi = ABTestInfoProvider.GetABTestInfoForIssue(parentIssueId); if (abi != null) { IssueInfo issue = IssueInfoProvider.GetIssueInfo(parentIssueId); // Check if winner was selected and sent if (abi.TestWinnerIssueID != 0) { if ((issue.IssueStatus == IssueStatusEnum.Finished) || (issue.IssueStatus == IssueStatusEnum.Sending)) { // Winner was already sent CloseDialogAndRefreshParent(); return; } } // Update A/B test info and winner selection task (if exist) abi.TestWinnerOption = ABTestWinnerSelectionEnum.Manual; NewsletterTasksManager.EnsureWinnerSelectionTask(abi, issue, false, DateTime.Now); abi.TestSelectWinnerAfter = 0; abi.TestWinnerSelected = DateTime.Now; abi.TestWinnerIssueID = winner.IssueID; ABTestInfoProvider.SetABTestInfo(abi); if ((issue != null) && (winner != null)) { // Copy data from winner to parent IssueHelper.CopyIssueProperties(winner, issue, "issuesubject;issuetext;issuetemplateid;issueshowinnewsletterarchive;issuesendername;issuesenderemail"); IssueInfoProvider.SetIssueInfo(issue); // Remove previous scheduled task of this issue NewsletterTasksManager.DeleteMailoutTask(issue.IssueGUID, issue.IssueSiteID); DateTime mailoutTime = dtpMailout.SelectedDateTime; IssueSender issueSender = new IssueSender(IssueInfoProvider.GetIssueInfo(parentIssueId)); issueSender.Send(mailoutTime); } } // Close dialog and refresh parent page CloseDialogAndRefreshParent(); }
protected void btnSend_Click(object sender, EventArgs e) { // Validate date/time if (dtpMailout.SelectedDateTime == DateTimeHelper.ZERO_TIME) { ShowError(GetString("newsletterissue_send.invaliddatetime")); return; } IssueInfo winner = (IssueInfo)EditedObject; int parentIssueId = winner.IssueVariantOfIssueID; // Get A/B test info ABTestInfo abi = ABTestInfoProvider.GetABTestInfoForIssue(parentIssueId); if (abi != null) { IssueInfo issue = IssueInfoProvider.GetIssueInfo(parentIssueId); // Check if winner was selected and sent if (abi.TestWinnerIssueID != 0) { if ((issue.IssueStatus == IssueStatusEnum.Finished) || (issue.IssueStatus == IssueStatusEnum.Sending)) { // Winner was already sent CloseDialogAndRefreshParent(); return; } } // Update A/B test info and winner selection task (if exist) abi.TestWinnerOption = ABTestWinnerSelectionEnum.Manual; NewsletterTasksManager.EnsureWinnerSelectionTask(abi, issue, false, DateTime.Now); abi.TestSelectWinnerAfter = 0; abi.TestWinnerSelected = DateTime.Now; abi.TestWinnerIssueID = winner.IssueID; ABTestInfoProvider.SetABTestInfo(abi); if ((issue != null) && (winner != null)) { // Copy data from winner to parent IssueHelper.CopyIssueProperties(winner, issue, "issuesubject;issuetext;issuetemplateid;issueshowinnewsletterarchive;issuesendername;issuesenderemail"); IssueInfoProvider.SetIssueInfo(issue); // Remove previous scheduled task of this issue NewsletterTasksManager.DeleteMailoutTask(issue.IssueGUID, issue.IssueSiteID); DateTime mailoutTime = dtpMailout.SelectedDateTime; IssueSender issueSender = new IssueSender(IssueInfoProvider.GetIssueInfo(parentIssueId)); issueSender.Send(mailoutTime); } } // Close dialog and refresh parent page CloseDialogAndRefreshParent(); }
/// <summary> /// Removes all scheduled tasks for the given issue. /// </summary> /// <param name="when">DateTime when to send</param> private void RemovePreviousTaskAndSendIssue(DateTime when) { IssueInfo issue = IssueInfoProvider.GetIssueInfo(IssueID); if (issue != null) { // Remove all previously scheduled tasks (if any) NewsletterTasksManager.DeleteMailoutTask(issue.IssueGUID, issue.IssueSiteID); // Schedule new task for new mailout time IssueSender issueSender = new IssueSender(issue); issueSender.Send(when); } }
/// <summary> /// Removes all scheduled tasks for the given issue. /// </summary> /// <param name="when">DateTime when to send</param> private void RemovePreviousTaskAndSendIssue(DateTime when) { IssueInfo issue = IssueInfoProvider.GetIssueInfo(IssueID); if (issue != null) { // Remove all previously scheduled tasks (if any) NewsletterTasksManager.DeleteMailoutTask(issue.IssueGUID, issue.IssueSiteID); // Schedule new task for new mailout time IssueSender issueSender = new IssueSender(issue); issueSender.Send(when); } }