/// <summary> /// Displays info label and increases number of unsubscriptions. /// </summary> private void DisplayConfirmation() { // Display coinfirmation message lblInfo.Visible = true; lblInfo.Text = String.IsNullOrEmpty(UnsubscribedText) ? GetString("Unsubscribe.Unsubscribed") : UnsubscribedText; // If subscriber has been unsubscribed after some issue, increase number of unsubscribed persons of the issue by 1 int issueId = QueryHelper.GetInteger("issueid", 0); if (issueId > 0) { // Unsubscribe using specified issue ID IssueInfoProvider.IncreaseUnsubscribeCount(issueId); return; } // If issue ID not available, try to unsubscribe using issue GUID Guid issueGuid = QueryHelper.GetGuid("issueguid", Guid.Empty); if (issueGuid != Guid.Empty) { IssueInfo issue = IssueInfoProvider.GetIssueInfo(issueGuid, SiteContext.CurrentSiteID); if (issue != null) { IssueInfoProvider.IncreaseUnsubscribeCount(issue.IssueID); } } }
private string GetPreviewScriptForCampaign(IssueInfo issue, NewsletterInfo newsletter, IssueHelper issueHelper) { string currentSiteName = SiteContext.CurrentSiteName; var output = new StringBuilder(); var recipients = issue.GetRecipientsProvider() .GetMarketableRecipients() .TopN(MAX_PREVIEW_SUBSCRIBERS) .ToList(); if (!recipients.Any()) { return(InitializePreviewScriptForZeroSubscribers(issue, GetPreviewSubject(issue, newsletter, issueHelper, null, currentSiteName))); } output.AppendLine(InitializePreviewScript(issue, recipients.Count)); for (int index = 0; index < recipients.Count; index++) { var recipient = recipients[index]; var dummySubscriber = new SubscriberInfo { SubscriberFirstName = recipient.ContactFirstName, SubscriberLastName = recipient.ContactLastName, SubscriberEmail = recipient.ContactEmail }; output.AppendFormat("guid[{0}] = '{1}';", index, recipient.ContactGUID); output.AppendFormat("email[{0}] = '{1}';", index, recipient.ContactEmail); output.AppendFormat("subject[{0}] = {1};", index, ScriptHelper.GetString(HTMLHelper.HTMLEncode(GetPreviewSubject(issue, newsletter, issueHelper, dummySubscriber, currentSiteName)))); } return(output.ToString()); }
private void PostProcessVariants(IssueInfo issue) { if (issue.IssueIsABTest) { // Select variants including the parent issue var issues = IssueInfoProvider.GetIssues() .WhereNotEquals("IssueID", issue.IssueID) .And(w => w.WhereEquals("IssueVariantOfIssueID", issue.IssueVariantOfIssueID) .Or() .WhereEquals("IssueID", issue.IssueVariantOfIssueID)) .ToList(); foreach (var variant in issues) { // Synchronize issue data between all A/B test variants (including parent issue). variant.IssueDisplayName = issue.IssueDisplayName; // UTM parameters variant.IssueUTMCampaign = issue.IssueUTMCampaign; variant.IssueUTMSource = issue.IssueUTMSource; variant.IssueUseUTM = issue.IssueUseUTM; IssueInfoProvider.SetIssueInfo(variant); } } }
protected void Page_Load(object sender, EventArgs e) { // Check read permission for newsletters if (MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Newsletter", "Read")) { IssueInfo iss = null; int issueId = QueryHelper.GetInteger("IssueId", 0); if (issueId > 0) { // Get newsletter issue by ID iss = IssueInfoProvider.GetIssueInfo(issueId); } else { // Get newsletter issue by GUID and site ID Guid issueGuid = QueryHelper.GetGuid("IssueGUID", Guid.Empty); iss = IssueInfoProvider.GetIssueInfo(issueGuid, SiteContext.CurrentSiteID); } if ((iss != null) && (iss.IssueSiteID == SiteContext.CurrentSiteID)) { // Get newsletter NewsletterInfo news = NewsletterInfoProvider.GetNewsletterInfo(iss.IssueNewsletterID); Response.Clear(); Response.Write(IssueInfoProvider.GetEmailBody(iss, news, null, null, false, SiteContext.CurrentSiteName, null, null, null)); Response.Flush(); RequestHelper.EndResponse(); } } }
protected void Page_Load(object sender, EventArgs e) { PageTitle.TitleText = GetString("newsletter_issue_subscribersclicks.title"); linkId = QueryHelper.GetInteger("linkid", 0); if (linkId == 0) { RequestHelper.EndResponse(); } LinkInfo link = LinkInfoProvider.GetLinkInfo(linkId); EditedObject = link; IssueInfo issue = IssueInfoProvider.GetIssueInfo(link.LinkIssueID); EditedObject = issue; // Prevent accessing issues from sites other than current site if (issue.IssueSiteID != SiteContext.CurrentSiteID) { RedirectToResourceNotAvailableOnSite("Issue with ID " + link.LinkIssueID); } var where = new WhereCondition().Where("LinkID", QueryOperator.Equals, linkId); // Link's issue is the main A/B test issue if (issue.IssueIsABTest && !issue.IssueIsVariant) { // Get A/B test and its winner issue ID ABTestInfo test = ABTestInfoProvider.GetABTestInfoForIssue(issue.IssueID); if (test != null) { // Get ID of the same link from winner issue var winnerLink = LinkInfoProvider.GetLinks() .WhereEquals("LinkIssueID", test.TestWinnerIssueID) .WhereEquals("LinkTarget", link.LinkTarget) .WhereEquals("LinkDescription", link.LinkDescription) .TopN(1) .Column("LinkID") .FirstOrDefault(); if (winnerLink != null) { if (winnerLink.LinkID > 0) { // Add link ID of winner issue link where.Or(new WhereCondition().Where("LinkID", QueryOperator.Equals, winnerLink.LinkID)); } } } } where.And(new WhereCondition(fltOpenedBy.WhereCondition)); UniGrid.WhereCondition = where.WhereCondition; UniGrid.QueryParameters = where.Parameters; UniGrid.Pager.DefaultPageSize = PAGESIZE; UniGrid.Pager.ShowPageSize = false; UniGrid.FilterLimit = 1; UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound; }
protected void Page_Load(object sender, EventArgs e) { IssueInfo issue = EditedObject as IssueInfo; if (issue == null) { RedirectToAccessDenied(GetString("general.invalidparameters")); } if (!issue.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser)) { RedirectToAccessDenied(issue.TypeInfo.ModuleName, "AuthorIssues"); } var subscriber = GetSubscriber(NewsletterInfoProvider.GetNewsletterInfo(issue.IssueNewsletterID)); // Switch culture to the site culture, so the e-mail isn't rendered in the editor's culture string culture = CultureHelper.GetDefaultCultureCode(SiteContext.CurrentSiteName); using (new CMSActionContext { ThreadCulture = CultureHelper.GetCultureInfo(culture) }) { string htmlPage = NewsletterHelper.GetPreviewHTML(issue, subscriber); Response.Clear(); Response.Write(htmlPage); } RequestHelper.EndResponse(); }
/// <summary> /// Deletes dynamic issue. Called when the "Delete issue" button is pressed. /// Expects the CreateDynamicIssue method to be run first. /// </summary> private bool DeleteDynamicIssue() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", CMSContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters string where = "IssueNewsletterID = " + newsletter.NewsletterID; // Get the data DataSet issues = IssueInfoProvider.GetIssues(where, null); if (!DataHelper.DataSourceIsEmpty(issues)) { // Create object from DataRow IssueInfo deleteIssue = new IssueInfo(issues.Tables[0].Rows[0]); // Delete the dynamic issue IssueInfoProvider.DeleteIssueInfo(deleteIssue); return(deleteIssue != null); } } return(false); }
/// <summary> /// Gets and bulk updates dynamic issues. Called when the "Get and bulk update issues" button is pressed. /// Expects the CreateDynamicIssue method to be run first. /// </summary> private bool GetAndBulkUpdateDynamicIssues() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", CMSContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters string where = "IssueNewsletterID = " + newsletter.NewsletterID; // Get the data DataSet issues = IssueInfoProvider.GetIssues(where, null); if (!DataHelper.DataSourceIsEmpty(issues)) { // Loop through the individual items foreach (DataRow issueDr in issues.Tables[0].Rows) { // Create object from DataRow IssueInfo modifyIssue = new IssueInfo(issueDr); // Update the properties modifyIssue.IssueSubject = modifyIssue.IssueSubject.ToUpper(); // Save the changes IssueInfoProvider.SetIssueInfo(modifyIssue); } return(true); } } return(false); }
protected void Page_Load(object sender, EventArgs e) { PageTitle.TitleText = GetString("newsletter_issue_trackedlinks.title"); issueId = QueryHelper.GetInteger("objectid", 0); if (issueId == 0) { RequestHelper.EndResponse(); } IssueInfo issue = IssueInfoProvider.GetIssueInfo(issueId); EditedObject = issue; // Prevent accessing issues from sites other than current site if (issue.IssueSiteID != SiteContext.CurrentSiteID) { RedirectToResourceNotAvailableOnSite("Issue with ID " + issueId); } // Get number of sent emails sentEmails = issue.IssueSentEmails; ScriptHelper.RegisterDialogScript(this); string scriptBlock = string.Format(@" function OpenTarget(url) {{ window.open(url, 'LinkTarget'); return false; }} function ViewClicks(id) {{ modalDialog('{0}?linkid=' + id, 'NewsletterIssueSubscriberClicks', '900px', '700px'); return false; }}", ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_SubscribersClicks.aspx")); ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Actions", scriptBlock, true); // Issue is the main A/B test issue isMainABTestIssue = issue.IssueIsABTest && !issue.IssueIsVariant; if (isMainABTestIssue) { // Initialize variant selector in the filter fltLinks.IssueId = issue.IssueID; if (RequestHelper.IsPostBack()) { // Get issue ID from variant selector issueId = fltLinks.IssueId; } } string whereCondition = string.Empty; if (issueId > 0) { // Filter by Issue ID (from querystring or variant selector in case of A/B test issue) whereCondition = SqlHelper.GetWhereCondition("IssueID", issueId); } UniGrid.WhereCondition = SqlHelper.AddWhereCondition(whereCondition, fltLinks.WhereCondition); UniGrid.Pager.DefaultPageSize = PAGESIZE; UniGrid.Pager.ShowPageSize = false; UniGrid.FilterLimit = 1; UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound; UniGrid.OnAction += UniGrid_OnAction; }
private object GridVariants_OnExternalDataBound(object sender, string sourceName, object parameter) { if (sourceName.Equals("variantName", StringComparison.OrdinalIgnoreCase)) { var drv = UniGridFunctions.GetDataRowView(sender as DataControlFieldCell); var issue = new IssueInfo(drv.Row); string navigateUrl = EmailBuilderHelper.GetNavigationUrl(Issue.IssueNewsletterID, issue.IssueID, 2); return(new HyperLink { NavigateUrl = navigateUrl, Text = HTMLHelper.HTMLEncode(issue.GetVariantName()) }); } if (sourceName.Equals("delete", StringComparison.OrdinalIgnoreCase)) { var dr = UniGridFunctions.GetDataRowView(parameter); int issueId = Convert.ToInt32(dr["IssueID"]); var deleteButton = (CMSGridActionButton)sender; deleteButton.Enabled = (OriginalVariant.IssueID != issueId) && Enabled; } return(parameter); }
public APIGatewayProxyResponse AddIssue(APIGatewayProxyRequest request, ILambdaContext context) { context.Logger.LogLine("Get Request\n"); //IssueInfo info = new IssueInfo() //{ // Subject = "Test", // Description = "TESTTTTTT", // CategoryId = CategoryTypes.None, // PriorityId = PriorityTypes.High, // DueDate = DateTime.Today, // Status = StatusTypes.New, // CreatedBy = "kannop" //}; //var json = JsonConvert.SerializeObject(info); IssueInfo info = JsonConvert.DeserializeObject <IssueInfo>(request.Body); var response = new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.OK, Body = JsonConvert.SerializeObject(new IssueController().AddIssue(info)), Headers = new Dictionary <string, string> { { "Content-Type", "text/json" } } }; return(response); }
public override bool LoadData(ActivityInfo ai) { if ((ai == null) || (ai.ActivityType != PredefinedActivityType.NEWSLETTER_OPEN)) { return(false); } // Get newsletter name int newsletterId = ai.ActivityItemID; NewsletterInfo newsletterInfo = NewsletterInfoProvider.GetNewsletterInfo(newsletterId); if (newsletterInfo != null) { string subject = ValidationHelper.GetString(newsletterInfo.NewsletterDisplayName, null); ucDetails.AddRow("om.activitydetails.newsletter", subject); } // Get issue subject int issueId = ai.ActivityItemDetailID; IssueInfo issueInfo = IssueInfoProvider.GetIssueInfo(issueId); if (issueInfo != null) { string subject = ValidationHelper.GetString(issueInfo.IssueSubject, null); ucDetails.AddRow("om.activitydetails.newsletterissue", MacroSecurityProcessor.RemoveSecurityParameters(subject, true, null)); } return(ucDetails.IsDataLoaded); }
public ActionResult EditTicket(IssueInfo info) { using (IssueDbContext db = new IssueDbContext()) { var result = db.RegisterTickets.SingleOrDefault(u => u.UserId == info.UserId); if (result != null) { result.AssignTo = info.AssignTo; result.Status = info.Status; if (info.Status.ToUpper() == "CLOSED") { result.ClosedDate = DateTime.Now.ToString(); result.ClosedBy = info.ClosedBy; } else { result.ClosedDate = "Pending"; result.ClosedBy = "Pending"; } db.SaveChanges(); } } return(RedirectToAction("ViewIssue")); }
/// <summary> /// Returns information message according to current state, issue and A/B test. /// </summary> /// <param name="currState">Current state</param> /// <param name="issue">Issue</param> /// <param name="winnerOption">Winner option</param> private string GetInfoMessage(VariantStatusEnum currState, IssueInfo issue, ABTestWinnerSelectionEnum winnerOption) { if (issue == null) { return(null); } switch (currState) { case VariantStatusEnum.WaitingToSend: return(GetString("Newsletter_Issue_Header.NotSentYet")); case VariantStatusEnum.WaitingToSelectWinner: return(GetWaitingToSelectWinnerInfoMessage(issue, winnerOption)); case VariantStatusEnum.ReadyForSending: return(String.Format(GetString("newsletterinfo.issuescheduledwinnerselmanually"), GetTimeOrNA(issue.IssueMailoutTime), GetWinnerSelectionTime())); case VariantStatusEnum.ReadyForTesting: return(GetReadyForTestingInfoMessage(winnerOption)); case VariantStatusEnum.Finished: return(GetFinishedInfoMessage(issue, winnerOption)); default: return(null); } }
public override bool LoadData(ActivityInfo ai) { if ((ai == null) || (ai.ActivityType != PredefinedActivityType.NEWSLETTER_CLICKTHROUGH)) { return(false); } // Get newsletter name int newsletterId = ai.ActivityItemID; NewsletterInfo newsletterInfo = NewsletterInfo.Provider.Get(newsletterId); if (newsletterInfo != null) { ucDetails.AddRow("om.activitydetails.newsletter", newsletterInfo.NewsletterDisplayName); } // Get issue subject int issueId = ai.ActivityItemDetailID; IssueInfo issueInfo = IssueInfo.Provider.Get(issueId); if (issueInfo != null) { ucDetails.AddRow("om.activitydetails.newsletterissue", issueInfo.IssueDisplayName); } string targetLink = ai.ActivityURL; ucDetails.AddRow("om.activitydetails.newstargetlink", GetLink(targetLink, targetLink), false); return(ucDetails.IsDataLoaded); }
/// <summary> /// Deletes dynamic issue. Called when the "Delete issue" button is pressed. /// Expects the CreateDynamicIssue method to be run first. /// </summary> private bool DeleteDynamicIssue() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", SiteContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters var condition = new WhereCondition().WhereEquals("IssueNewsletterID", newsletter.NewsletterID); // Get the data var issues = IssueInfoProvider.GetIssues().Where(condition); if (issues.Any()) { // Create object from DataRow IssueInfo deleteIssue = issues.First(); // Delete the dynamic issue IssueInfoProvider.DeleteIssueInfo(deleteIssue); return(deleteIssue != null); } } return(false); }
/// <summary> /// Gets and updates dynamic issue. Called when the "Get and update issue" button is pressed. /// Expects the CreateDynamicIssue method to be run first. /// </summary> private bool GetAndUpdateDynamicIssue() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", SiteContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters var condition = new WhereCondition().WhereEquals("IssueNewsletterID", newsletter.NewsletterID); // Get the data var issues = IssueInfoProvider.GetIssues().Where(condition); if (issues.Any()) { // Create object from DataRow IssueInfo updateIssue = issues.First(); if (updateIssue != null) { // Update the properties updateIssue.IssueSubject = updateIssue.IssueSubject.ToLower(); // Save the changes IssueInfoProvider.SetIssueInfo(updateIssue); return(true); } } } return(false); }
/// <summary> /// Creates static issue. Called when the "Create issue" button is pressed. /// </summary> private bool CreateStaticIssue() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewStaticNewsletter", SiteContext.CurrentSiteID); if (newsletter != null) { // Create new static issue object IssueInfo newIssue = new IssueInfo(); // Set the properties newIssue.IssueSubject = "My new static issue"; newIssue.IssueNewsletterID = newsletter.NewsletterID; newIssue.IssueSiteID = SiteContext.CurrentSiteID; newIssue.IssueText = "<?xml version=\"1.0\" encoding=\"utf-16\"?><content><region id=\"content\">Issue text</region></content>"; newIssue.IssueUnsubscribed = 0; newIssue.IssueSentEmails = 0; newIssue.IssueTemplateID = newsletter.NewsletterTemplateID; newIssue.IssueShowInNewsletterArchive = false; // Save the static issue IssueInfoProvider.SetIssueInfo(newIssue); return(true); } return(false); }
public void TestNewIssuesOverExistingIssues() { // initialize parameter needed var newProjects = new List <ProjectInfo>(); var currentIssues = new Dictionary <int, IssueInfo>(); var changedIssue = new IssueInfo() { Id = 0, ProjectId = 42 }; currentIssues.Add(0, changedIssue); // get external data source ExternalDataSourceFactory.UseTestManager = true; var source = ExternalDataSourceFactory.GetRedmineMangerInstance("", "", 50); var issuesChangedProject = DownloadHelper.DownloadIssues(newProjects, currentIssues, source); // assert Assert.That(issuesChangedProject.Count, Is.GreaterThanOrEqualTo(1)); Assert.That(changedIssue.Id.HasValue, Is.True); var issueId = changedIssue.Id.Value; Assert.That(issuesChangedProject.Keys, Contains.Item(issueId)); var issue = issuesChangedProject[issueId]; Assert.That(issue.ProjectId, Is.EqualTo(0)); }
/// <summary> /// Gets and updates dynamic issue. Called when the "Get and update issue" button is pressed. /// Expects the CreateDynamicIssue method to be run first. /// </summary> private bool GetAndUpdateDynamicIssue() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", CMSContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters string where = "IssueNewsletterID = " + newsletter.NewsletterID; // Get the data DataSet issues = IssueInfoProvider.GetIssues(where, null); if (!DataHelper.DataSourceIsEmpty(issues)) { // Create object from DataRow IssueInfo updateIssue = new IssueInfo(issues.Tables[0].Rows[0]); if (updateIssue != null) { // Update the properties updateIssue.IssueSubject = updateIssue.IssueSubject.ToLower(); // Save the changes IssueInfoProvider.SetIssueInfo(updateIssue); return(true); } } } return(false); }
private void InitIssueHeaderActions(IssueInfo issue, HeaderActions hdrActions) { var sendingIssueAllowed = issue.IssueStatus == IssueStatusEnum.Idle || issue.IssueStatus == IssueStatusEnum.ReadyForSending; if (!sendingIssueAllowed) { return; } var recipientsCountAllowed = LicenseMaxNumberOfRecipients.Value == 0 || MarketableRecipientsCount.Value <= LicenseMaxNumberOfRecipients.Value; if (!recipientsCountAllowed) { plcMess.AddError(string.Format(GetString("newsletter.issue.send.subcriberlimiterror"), MarketableRecipientsCount.Value, LicenseMaxNumberOfRecipients.Value)); } var hasWidgetWithUnfilledRequiredProperty = issue.HasWidgetWithUnfilledRequiredProperty(); var hasWidgetWithMissingDefinition = issue.HasWidgetWithMissingDefinition(); var isValidWidgetDefinition = !hasWidgetWithUnfilledRequiredProperty && !hasWidgetWithMissingDefinition; if (!isValidWidgetDefinition) { plcMess.AddError(GetString("newsletter.issue.send.widgeterror")); } if (IsIssueTemplateBased) { AddTemplateBasedHeaderActions(hdrActions, isValidWidgetDefinition && recipientsCountAllowed); } else { AddSendHeaderAction(hdrActions, isValidWidgetDefinition && recipientsCountAllowed); } }
/// <summary> /// Reloads dropdown lists. /// </summary> protected void ReloadData() { usNewsletters.WhereCondition = "NewsletterSiteID = " + SiteContext.CurrentSiteID; usNewsletters.ReturnColumnName = "NewsletterID"; usNewsletters.OnSelectionChanged += new EventHandler(DropDownSingleSelect_SelectedIndexChanged); usNewsletters.DropDownSingleSelect.AutoPostBack = true; usIssues.WhereCondition = GetIssueWhereCondition(usNewsletters.Value);; usIssues.ReturnColumnName = ReturnColumnName; // Initialize both dropdown lists according to incoming issue ID if (!RequestHelper.IsPostBack()) { if (mValue > 0) { // Retrieve newsletter ID from issue info IssueInfo issue = IssueInfo.Provider.Get(mValue); int issueNewsletterID = 0; if (issue != null) { issueNewsletterID = issue.IssueNewsletterID; } usNewsletters.Value = issueNewsletterID; usIssues.WhereCondition = GetIssueWhereCondition(issueNewsletterID);; usIssues.Reload(true); usIssues.DropDownSingleSelect.SelectedValue = mValue.ToString(); usIssues.Value = mValue; } } }
private static string GetPreviewSubject(IssueInfo issue, NewsletterInfo newsletter, IssueHelper issueHelper, SubscriberInfo subscriber, string siteName) { // Resolve dynamic field macros ({%FirstName%}, {%LastName%}, {%Email%}) return(issueHelper.LoadDynamicFields(subscriber, newsletter, null, issue, true, siteName, null, null, null) ? issueHelper.ResolveDynamicFieldMacros(issue.IssueSubject, newsletter, issue) : null); }
private void InitializeSubscribersForCampaign(IssueInfo issue, NewsletterInfo newsletter) { var recipients = issue.GetRecipientsProvider() .GetMarketableRecipients() .TopN(MAX_PREVIEW_SUBSCRIBERS) .ToList(); if (recipients.Count > 0) { for (int index = 0; index < recipients.Count; index++) { var recipient = recipients[index]; var subscriber = recipient.ToContactSubscriber(); var emailViewer = new EmailViewer(issue, newsletter, subscriber, true); emails.Add(HttpUtility.UrlEncode(recipient.ContactEmail)); subjects.Add(GetEncodedSubscriberSubject(emailViewer)); preheaders.Add(GetEncodedSubscriberPreheader(emailViewer)); drpSubscribers.Items.Add(new ListItem(recipient.ContactEmail, index.ToString())); } } else { DisableSubscribersDropDownList(); var emailViewer = new EmailViewer(issue, newsletter, null, true); InitializeZeroSubscribers(emailViewer.GetSubject(), emailViewer.GetPreheader()); } }
private void SetLabelValues(IssueInfo issue, NewsletterInfo newsletter) { var senderRetriever = new SenderRetriever(issue, newsletter); lblFromValue.Text = HTMLHelper.HTMLEncode(senderRetriever.GetSenderName()); lblFromEmailValue.Text = senderRetriever.GetSenderEmail(); }
protected void Page_Load(object sender, EventArgs e) { PageTitle.TitleText = GetString("newsletter.issue.clicks"); var issueId = QueryHelper.GetInteger("objectid", 0); issueLinks.IssueID = issueId; issueLinks.NoDataText = GetString("newsletter.issue.noclicks"); IssueInfo issue = IssueInfoProvider.GetIssueInfo(issueId); EditedObject = issue; if (issue.IssueSentEmails <= 0) { ShowInformation(GetString("newsletter.issue.overviewnotsentyet")); pnlContent.Visible = false; return; } // Prevent accessing issues from sites other than current site if (issue.IssueSiteID != SiteContext.CurrentSiteID) { RedirectToResourceNotAvailableOnSite("Issue with ID " + issueId); } }
private string GetWaitingToSelectWinnerInfoMessage(IssueInfo issue, ABTestWinnerSelectionEnum winnerOption) { // Get current planned winner selection task var taskToSelectWinner = TaskInfo.Provider.Get(mABTest.TestWinnerScheduledTaskID); var plannedWinnerSelectionTime = taskToSelectWinner?.TaskNextRunTime ?? DateTimeHelper.ZERO_TIME; switch (winnerOption) { case ABTestWinnerSelectionEnum.Manual: if (issue.IssueMailoutTime > DateTime.Now) { return(String.Format(GetString("newsletterinfo.issuesentwaitingtosentwinner"), GetTimeOrNA(issue.IssueMailoutTime), GetWinnerSelectionTime())); } return(String.Format(GetString("newsletterinfo.issuesentwaitingtoselwinnermanually"), GetTimeOrNA(issue.IssueMailoutTime))); case ABTestWinnerSelectionEnum.OpenRate: return(String.Format(GetString("newsletterinfo.issuesentwaitingtoselwinneropen"), GetTimeOrNA(issue.IssueMailoutTime), GetTimeOrNA(plannedWinnerSelectionTime))); case ABTestWinnerSelectionEnum.TotalUniqueClicks: return(String.Format(GetString("newsletterinfo.issuesentwaitingtoselwinnerclicks"), GetTimeOrNA(issue.IssueMailoutTime), GetTimeOrNA(plannedWinnerSelectionTime))); default: return(null); } }
protected void Page_Load(object sender, EventArgs e) { PageTitle.TitleText = GetString("newsletter_winnermailout.title"); PageTitle.ShowFullScreenButton = false; RegisterModalPageScripts(); RegisterEscScript(); // Register script for refreshing parent page ScriptHelper.RegisterStartupScript(Page, GetType(), "RefreshParent", "function RefreshPage() {if((wopener)&&(wopener.RefreshPage!=null)){wopener.RefreshPage();}}", true); btnSend.Click += btnSend_Click; // Show variant name in info message string variantName = GetString("general.na"); IssueInfo winner = (IssueInfo)EditedObject; if (winner != null) { // Prevent accessing issues from sites other than current site if (winner.IssueSiteID != SiteContext.CurrentSiteID) { RedirectToResourceNotAvailableOnSite("Issue with ID " + winner.IssueID); } variantName = HTMLHelper.HTMLEncode(winner.GetVariantName()); } lblInfo.Text = String.Format(GetString("newsletter_winnermailout.question"), variantName); }
/// <summary> /// Determines current state of newsletter A/B test. /// </summary> /// <param name="issue">Parent issue</param> private static VariantStatusEnum GetCurrentState(IssueInfo issue) { if (issue == null) { return(VariantStatusEnum.Unknown); } switch (issue.IssueStatus) { case IssueStatusEnum.Idle: return(VariantStatusEnum.WaitingToSend); case IssueStatusEnum.ReadyForSending: return(AreAllVariantsSent(issue) ? VariantStatusEnum.ReadyForSending : VariantStatusEnum.ReadyForTesting); case IssueStatusEnum.TestPhase: return(IssueHelper.IsWinnerSelected(issue) ? VariantStatusEnum.ReadyForSending : VariantStatusEnum.WaitingToSelectWinner); case IssueStatusEnum.PreparingData: case IssueStatusEnum.Sending: case IssueStatusEnum.Finished: return(VariantStatusEnum.Finished); default: return(VariantStatusEnum.Unknown); } }
private void InitABTestHeaderActions(IssueInfo issue, HeaderActions hdrActions) { if (IsEditable(issue)) { hdrActions.ActionsList.Add(new SaveAction()); } var sendingIssueAllowed = issue.IssueStatus == IssueStatusEnum.Idle; if (!sendingIssueAllowed) { return; } var variants = GetIssueVariants(issue); var variantNamesWithUnfilledRequiredWidgetProperties = GetVariantNamesWithUnfilledRequiredWidgetProperties(variants); var variantNamesWithMissingWidgetDefinition = GetVariantNamesWithMissingWidgetDefinition(variants); var isValidDefinition = !variantNamesWithUnfilledRequiredWidgetProperties.Any() && !variantNamesWithMissingWidgetDefinition.Any(); AddSendHeaderAction(hdrActions, isValidDefinition, ButtonStyle.Default); if (!isValidDefinition) { var invalidVariantNames = variantNamesWithUnfilledRequiredWidgetProperties.Union(variantNamesWithMissingWidgetDefinition); plcMess.AddError(string.Format(GetString("newsletter.issue.send.variantwidgeterror"), string.Join(", ", invalidVariantNames))); } }
/// <summary> /// Initializes header menu. /// </summary> /// <param name="issue">Issue object</param> protected void InitalizeMenu(IssueInfo issue) { // Get newsletter NewsletterInfo news = NewsletterInfoProvider.GetNewsletterInfo(issue.IssueNewsletterID); if (news == null) { return; } // Initialize breadcrumbs CurrentPage.InitBreadcrumbs(2); CurrentPage.SetBreadcrumb(0, GetString("Newsletter_Header.Issues"), "~/CMSModules/Newsletters/Tools/Newsletters/Newsletter_Issue_List.aspx?newsletterid=" + news.NewsletterID, "_parent", null); CurrentPage.SetBreadcrumb(1, MacroResolver.RemoveSecurityParameters(issue.IssueSubject, true, null), null, null, null); InitTabs("newsletterIssueContent"); // Show only 'Send' tab for dynamic newsletter if (news.NewsletterType == NewsletterType.Dynamic) { SetTab(0, GetString("Newsletter_Issue_Header.Send"), "Newsletter_Issue_Send.aspx?issueid=" + issue.IssueID, "SetHelpTopic('helpTopic', 'send_tab');"); // Set proper context help page SetHelp("send_tab", "helpTopic"); } else { SetTab(0, GetString("General.Content"), "Newsletter_Issue_Edit.aspx?issueid=" + issue.IssueID, "SetHelpTopic('helpTopic', 'edit_tab');"); // Display send page if the issue is A/B test or the issue may be re-sent or the issue has 'Idle' status bool displaySendPage = issue.IssueIsABTest || news.NewsletterEnableResending || (issue.IssueStatus == IssueStatusEnum.Idle); // Show 'Send' tab only to authorized users and if send page is allowed if (CMSContext.CurrentUser.IsAuthorizedPerResource("cms.newsletter", "authorissues") && displaySendPage) { SetTab(1, GetString("Newsletter_Issue_Header.Send"), "Newsletter_Issue_Send.aspx?issueid=" + issue.IssueID, issue.IssueIsABTest ? "SetHelpTopic('helpTopic', 'newsletterab_send');" : "SetHelpTopic('helpTopic', 'send_tab');"); } } }
protected object UniGrid_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName) { case "variantname": if (!isMainABTestIssue) { return null; } IssueInfo issue = IssueInfoProvider.GetIssueInfo(ValidationHelper.GetInteger(parameter, 0)); string variantName = null; if (issue != null) { if (!issue.IssueIsVariant) { // Get variant name from the winner issue if (winnerIssue == null) { ABTestInfo test = ABTestInfoProvider.GetABTestInfoForIssue(issue.IssueID); if (test != null) { // Get A/B test winner variant winnerIssue = IssueInfoProvider.GetIssueInfo(test.TestWinnerIssueID); } } if (winnerIssue != null) { // Get variant name variantName = winnerIssue.IssueVariantName; } } else { // Get variant name variantName = issue.IssueVariantName; } } return HTMLHelper.HTMLEncode(variantName); default: return parameter; } }
/// <summary> /// Gets and updates static issue. Called when the "Get and update issue" button is pressed. /// Expects the CreateStaticIssue method to be run first. /// </summary> private bool GetAndUpdateStaticIssue() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewStaticNewsletter", CMSContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters string where = "IssueNewsletterID = " + newsletter.NewsletterID; // Get the data DataSet issues = IssueInfoProvider.GetIssues(where, null); if (!DataHelper.DataSourceIsEmpty(issues)) { // Create object from DataRow IssueInfo updateIssue = new IssueInfo(issues.Tables[0].Rows[0]); if (updateIssue != null) { // Update the properties updateIssue.IssueSubject = updateIssue.IssueSubject.ToLower(); // Save the changes IssueInfoProvider.SetIssueInfo(updateIssue); return true; } } } return false; }
/// <summary> /// Gets and bulk updates static issues. Called when the "Get and bulk update issues" button is pressed. /// Expects the CreateStaticIssue method to be run first. /// </summary> private bool GetAndBulkUpdateStaticIssues() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewStaticNewsletter", CMSContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters string where = "IssueNewsletterID = " + newsletter.NewsletterID; // Get the data DataSet issues = IssueInfoProvider.GetIssues(where, null); if (!DataHelper.DataSourceIsEmpty(issues)) { // Loop through the individual items foreach (DataRow issueDr in issues.Tables[0].Rows) { // Create object from DataRow IssueInfo modifyIssue = new IssueInfo(issueDr); // Update the properties modifyIssue.IssueSubject = modifyIssue.IssueSubject.ToUpper(); // Save the changes IssueInfoProvider.SetIssueInfo(modifyIssue); } return true; } } return false; }
/// <summary> /// Deletes static issue. Called when the "Delete issue" button is pressed. /// Expects the CreateStaticIssue method to be run first. /// </summary> private bool DeleteStaticIssue() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewStaticNewsletter", CMSContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters string where = "IssueNewsletterID = " + newsletter.NewsletterID; // Get the data DataSet issues = IssueInfoProvider.GetIssues(where, null); if (!DataHelper.DataSourceIsEmpty(issues)) { // Create object from DataRow IssueInfo deleteIssue = new IssueInfo(issues.Tables[0].Rows[0]); // Delete the static issue IssueInfoProvider.DeleteIssueInfo(deleteIssue); return (deleteIssue != null); } } return false; }
/// <summary> /// Creates static issue. Called when the "Create issue" button is pressed. /// </summary> private bool CreateStaticIssue() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewStaticNewsletter", CMSContext.CurrentSiteID); if (newsletter != null) { // Create new static issue object IssueInfo newIssue = new IssueInfo(); // Set the properties newIssue.IssueSubject = "My new static issue"; newIssue.IssueNewsletterID = newsletter.NewsletterID; newIssue.IssueSiteID = CMSContext.CurrentSiteID; newIssue.IssueText = "<?xml version=\"1.0\" encoding=\"utf-16\"?><content><region id=\"content\">Issue text</region></content>"; newIssue.IssueUnsubscribed = 0; newIssue.IssueSentEmails = 0; newIssue.IssueTemplateID = newsletter.NewsletterTemplateID; newIssue.IssueShowInNewsletterArchive = false; // Save the static issue IssueInfoProvider.SetIssueInfo(newIssue); return true; } return false; }
/// <summary> /// Synchronize UTM parameters between all A/B test variants. /// </summary> /// <param name="issue">Issue</param> private void SynchronizeUTMParameters(IssueInfo issue) { var variants = IssueInfoProvider.GetIssues() .WhereNotEquals("IssueID", issue.IssueID) .And(w => w.WhereEquals("IssueVariantOfIssueID", issue.IssueVariantOfIssueID) .Or() .WhereEquals("IssueID", issue.IssueVariantOfIssueID)) .ToList(); foreach (var variant in variants) { variant.IssueUTMCampaign = issue.IssueUTMCampaign; variant.IssueUTMSource = issue.IssueUTMSource; variant.IssueUseUTM = issue.IssueUseUTM; IssueInfoProvider.SetIssueInfo(variant); } }
/// <summary> /// Creates new or updates existing newsletter issue. /// </summary> public bool Save() { if (mValidated || IsValid()) { IssueInfo issue; if (IssueID == 0) { // Initialize new issue issue = new IssueInfo(); issue.IssueUnsubscribed = 0; issue.IssueSentEmails = 0; issue.IssueNewsletterID = NewsletterID; issue.IssueSiteID = SiteContext.CurrentSiteID; } else { issue = IssueInfoProvider.GetIssueInfo(IssueID); } if (issue != null) { issue.IssueTemplateID = TemplateID; issue.IssueShowInNewsletterArchive = chkShowInArchive.Checked; issue.IssueSenderName = txtSenderName.Text.Trim(); issue.IssueSenderEmail = txtSenderEmail.Text.Trim(); issue.IssueUseUTM = chkIssueUseUTM.Checked; var normalizedUtmSource = Normalize(txtIssueUTMSource.Text.Trim()); if (string.IsNullOrEmpty(normalizedUtmSource)) { normalizedUtmSource = Normalize(Newsletter.NewsletterName + "_" + txtSubject.Text.Trim()); } txtIssueUTMSource.Text = issue.IssueUTMSource = normalizedUtmSource; if (radUTMCampaignNew.Checked) { var normalizedUtmCampaign = Normalize(txtIssueUTMCampaign.Text.Trim()); if (string.IsNullOrEmpty(normalizedUtmCampaign)) { normalizedUtmCampaign = Normalize(Newsletter.NewsletterName); } txtIssueUTMCampaign.Text = issue.IssueUTMCampaign = normalizedUtmCampaign; } else { issue.IssueUTMCampaign = selectorUTMCampaign.Value.ToString().ToLower(); } if (issue.IssueIsABTest) { SynchronizeUTMParameters(issue); } // Saves content of editable region(s) // Get content from hidden field string content = hdnIssueContent.Value; string[] regions = null; if (!string.IsNullOrEmpty(content)) { // Split content for each region, separator is '#|#' regions = content.Split(new[] { "#|#" }, StringSplitOptions.RemoveEmptyEntries); } issue.IssueText = IssueHelper.GetContentXML(regions); // Remove '#' from macros if included txtSubject.Text = txtSubject.Text.Trim().Replace("#%}", "%}"); // Sign macros if included in the subject issue.IssueSubject = MacroSecurityProcessor.AddSecurityParameters(txtSubject.Text, MembershipContext.AuthenticatedUser.UserName, null); // Save issue IssueInfoProvider.SetIssueInfo(issue); // Update IssueID IssueID = issue.IssueID; return true; } } return false; }
protected void Page_Load(object sender, EventArgs e) { ScriptHelper.RegisterScriptFile(Page, "cmsedit.js"); ScriptHelper.RegisterStartupScript(Page, typeof(string), "Initialize", ScriptHelper.GetScript("InitializePage();")); // Get issue ID mIssueID = QueryHelper.GetInteger("issueid", 0); // Get newsletter ID mNewsletterID = QueryHelper.GetInteger("newsletterid", 0); // Get template ID mTemplateID = QueryHelper.GetInteger("templateid", 0); // Get read only flag mReadOnly = QueryHelper.GetInteger("readonly", 0) == 1; if (mIssueID > 0) { // Get issue object issue = IssueInfoProvider.GetIssueInfo(mIssueID); } if (mTemplateID == 0) { if (issue != null) { mTemplateID = issue.IssueTemplateID; } else if (mNewsletterID > 0) { NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo(mNewsletterID); if (newsletter != null) { mTemplateID = newsletter.NewsletterTemplateID; } } } if (mTemplateID > 0) { // Load content from the template LoadContent(); LoadRegionList(); RegisterScript(); } }
protected void Page_Load(object sender, EventArgs e) { // Get issue ID mIssueID = QueryHelper.GetInteger("objectid", 0); // Get newsletter ID mNewsletterID = QueryHelper.GetInteger("parentobjectid", 0); // Get template ID mTemplateID = QueryHelper.GetInteger("templateid", 0); // Get read only flag mReadOnly = QueryHelper.GetInteger("readonly", 0) == 1; if (mIssueID > 0) { // Get issue object issue = IssueInfoProvider.GetIssueInfo(mIssueID); } if (mTemplateID == 0) { if (issue != null) { mTemplateID = issue.IssueTemplateID; } else if (mNewsletterID > 0) { NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo(mNewsletterID); if (newsletter != null) { mTemplateID = newsletter.NewsletterTemplateID; } } } if (mTemplateID > 0) { // Load content from the template LoadContent(); LoadRegionList(); RegisterScript(); } }
/// <summary> /// Creates new scheduled task for the given issue and newsletter. /// </summary> /// <param name="issueId">Issue</param> /// <param name="newsletter">Newsletter</param> private int CreateScheduledTask(IssueInfo issue, NewsletterInfo newsletter) { if ((issue == null) || (newsletter == null)) { return 0; } // Create new scheduled task TaskInfo task = IssueInfoProvider.CreateMailoutTask(issue, newsletter, DateTime.Now, false); if (task != null) { TaskInfoProvider.SetTaskInfo(task); return task.TaskID; } return 0; }
/// <summary> /// Determines current state of newsletter A/B test. /// </summary> /// <param name="parentIssue">Parent issue</param> private int GetCurrentState(IssueInfo parentIssue) { int currentState = 0; if (parentIssue == null) { return currentState; } switch (parentIssue.IssueStatus) { case IssueStatusEnum.Idle: if (Mode == SendControlMode.Send) { currentState = STATE_WAITING_TO_SEND_PAGE; } else { currentState = STATE_WAITING_TO_SEND_WIZARD; } break; case IssueStatusEnum.ReadyForSending: currentState = STATE_TEST_READY_FOR_SENDING; break; case IssueStatusEnum.TestPhase: currentState = STATE_TEST_WAITING_TO_SEL_WINNER; break; case IssueStatusEnum.PreparingData: case IssueStatusEnum.Sending: case IssueStatusEnum.Finished: currentState = STATE_TEST_FINISHED; break; } return currentState; }
protected object UniGrid_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView row = null; if (parameter is DataRowView) { row = (DataRowView)parameter; } int subscriberId = 0; switch (sourceName) { case "name": subscriberId = ValidationHelper.GetInteger(DataHelper.GetDataRowValue(row.Row, "SubscriberID"), 0); string name = null; if (subscriberId == 0) { // Get full name for contact group member (contact) name = ValidationHelper.GetString(DataHelper.GetDataRowValue(row.Row, "SubscriberFullName"), string.Empty); // Return encoded name return HTMLHelper.HTMLEncode(name); } else { // Add the field transformation control that handles the translation var tr = new ObjectTransformation("newsletter.subscriber", subscriberId); tr.Transformation = "SubscriberFullName"; return tr; } case "email": subscriberId = ValidationHelper.GetInteger(DataHelper.GetDataRowValue(row.Row, "SubscriberID"), 0); string email = null; if (subscriberId == 0) { // Get email for contact group member (contact) email = ValidationHelper.GetString(DataHelper.GetDataRowValue(row.Row, "SubscriberEmail"), string.Empty); } else { SubscriberInfo subscriber = SubscriberInfoProvider.GetSubscriberInfo(subscriberId); if (subscriber != null) { if (subscriber.SubscriberType == null) { // Get email for classic subscriber email = subscriber.SubscriberEmail; } else { switch (subscriber.SubscriberType) { case UserInfo.OBJECT_TYPE: UserInfo user = UserInfoProvider.GetUserInfo(subscriber.SubscriberRelatedID); if (user != null) { // Get email for user subscriber email = user.Email; } break; case PredefinedObjectType.CONTACT: DataSet ds = ModuleCommands.OnlineMarketingGetContactForNewsletters(subscriber.SubscriberRelatedID, "ContactEmail"); if (!DataHelper.DataSourceIsEmpty(ds)) { // Get email from contact subscriber email = ValidationHelper.GetString(ds.Tables[0].Rows[0]["ContactEmail"], string.Empty); } break; } } } } if (!string.IsNullOrEmpty(email)) { // Return encoded email email = HTMLHelper.HTMLEncode(email); } return email; case "variantname": if (!isMainABTestIssue) { return null; } IssueInfo issue = IssueInfoProvider.GetIssueInfo(ValidationHelper.GetInteger(parameter, 0)); string variantName = null; if (issue != null) { if (!issue.IssueIsVariant) { // Get varinat name from the winner issue if (winnerIssue == null) { ABTestInfo test = ABTestInfoProvider.GetABTestInfoForIssue(issue.IssueID); if (test != null) { // Get A/B test winner variant winnerIssue = IssueInfoProvider.GetIssueInfo(test.TestWinnerIssueID); } } if (winnerIssue != null) { // Get variant name variantName = winnerIssue.IssueVariantName; } } else { // Get variant name variantName = issue.IssueVariantName; } } return variantName; default: return parameter; } }
/// <summary> /// Returns information message according to current state, issue and A/B test. /// </summary> /// <param name="currState">Current state</param> /// <param name="issue">Issue</param> /// <param name="winnerOption">Winner option</param> private string GetInfoMessage(int currState, IssueInfo issue, ABTestWinnerSelectionEnum winnerOption, DateTime plannedMailoutTime) { if (issue == null) { return null; } switch (currState) { case STATE_WAITING_TO_SEND_WIZARD: return null; case STATE_WAITING_TO_SEND_PAGE: return GetString("Newsletter_Issue_Header.NotSentYet"); case STATE_TEST_WAITING_TO_SEL_WINNER: switch (winnerOption) { case ABTestWinnerSelectionEnum.Manual: if (issue.IssueMailoutTime > DateTime.Now) { return String.Format(GetString("newsletterinfo.issuesentwaitingtosentwinner"), issue.IssueMailoutTime, (abTest != null ? abTest.TestWinnerSelected.ToString() : GetString("general.na"))); } else { return String.Format(GetString("newsletterinfo.issuesentwaitingtoselwinnermanually"), issue.IssueMailoutTime); } case ABTestWinnerSelectionEnum.OpenRate: return String.Format(GetString("newsletterinfo.issuesentwaitingtoselwinneropen"), issue.IssueMailoutTime, plannedMailoutTime); case ABTestWinnerSelectionEnum.TotalUniqueClicks: return String.Format(GetString("newsletterinfo.issuesentwaitingtoselwinnerclicks"), issue.IssueMailoutTime, plannedMailoutTime); } break; case STATE_TEST_READY_FOR_SENDING: return String.Format(GetString("newsletter_issue_header.issuesending"), plannedMailoutTime); case STATE_TEST_FINISHED: switch (winnerOption) { case ABTestWinnerSelectionEnum.Manual: return String.Format(GetString("newsletterinfo.issuesentwinnerselmanually"), issue.IssueMailoutTime, (abTest != null ? abTest.TestWinnerSelected.ToString() : GetString("general.na"))); case ABTestWinnerSelectionEnum.OpenRate: return String.Format(GetString("newsletterinfo.issuesentwinnerselopen"), (abTest != null ? abTest.TestWinnerSelected.ToString() : GetString("general.na"))); case ABTestWinnerSelectionEnum.TotalUniqueClicks: return String.Format(GetString("newsletterinfo.issuesentwinnerselclicks"), (abTest != null ? abTest.TestWinnerSelected.ToString() : GetString("general.na"))); } break; } return null; }
/// <summary> /// Creates new scheduled task for the given issue and newsletter. /// </summary> /// <param name="issue">Issue</param> private int CreateScheduledTask(IssueInfo issue) { if (issue == null) { throw new ArgumentNullException("issue"); } // Create new scheduled task TaskInfo task = NewsletterTasksManager.CreateMailoutTask(issue, DateTime.Now, false); TaskInfoProvider.SetTaskInfo(task); return task.TaskID; }
/// <summary> /// Reloads control data. /// </summary> /// <param name="forceReload">Indicates if force reload should be used</param> public override void ReloadData(bool forceReload) { if (StopProcessing && !forceReload) { return; } if (ForceReloadNeeded) { forceReload = true; ForceReloadNeeded = false; } int parentIssueId = 0; parentIssue = IssueInfoProvider.GetOriginalIssue(IssueID); if (parentIssue != null) { parentIssueId = parentIssue.IssueID; } // Get A/B test configuration abTest = ABTestInfoProvider.GetABTestInfoForIssue(parentIssueId); if (abTest == null) { // Ensure A/B test object with default settings abTest = new ABTestInfo() { TestIssueID = parentIssueId, TestSizePercentage = 50, TestWinnerOption = ABTestWinnerSelectionEnum.OpenRate, TestSelectWinnerAfter = 60 }; ABTestInfoProvider.SetABTestInfo(abTest); } CurrentState = GetCurrentState(parentIssue); InitControls(CurrentState, forceReload); ucMailout.ParentIssueID = parentIssueId; ucMailout.ReloadData(forceReload); InfoMessage = GetInfoMessage(CurrentState, parentIssue, (abTest != null ? abTest.TestWinnerOption : ABTestWinnerSelectionEnum.OpenRate), GetPlannedMailoutTime(ucMailout.HighestMailoutTime)); // Init test group slider List<IssueABVariantItem> variants = IssueHelper.GetIssueVariants(parentIssue, null); ucGroupSlider.Variants = variants; bool allVariantsSent = true; if (variants != null) { allVariantsSent = variants.TrueForAll(delegate(IssueABVariantItem item) { return item.IssueStatus == IssueStatusEnum.Finished; }); } if ((parentIssue.IssueStatus == IssueStatusEnum.Finished) || allVariantsSent) { // Issue was sent long time ago => get number of subscribers from issue properties instead of current number of subscribers int perVariantEmails = 1; if (abTest != null) { perVariantEmails = abTest.TestNumberPerVariantEmails; } ucGroupSlider.NumberOfTestSubscribers = ucGroupSlider.Variants.Count * perVariantEmails; if (parentIssue.IssueStatus == IssueStatusEnum.Finished) { // Issue was sent => get number of subscribers from number of sent issues ucGroupSlider.NumberOfSubscribers = parentIssue.IssueSentEmails; } else { // Only variants was sent => get current number of subscribers ucGroupSlider.NumberOfSubscribers = GetEmailAddressCount(parentIssue.IssueNewsletterID, parentIssue.IssueSiteID); } } else { ucGroupSlider.NumberOfSubscribers = GetEmailAddressCount(parentIssue.IssueNewsletterID, parentIssue.IssueSiteID); } if (forceReload || !ucGroupSlider.Enabled) { ucGroupSlider.CurrentSize = (abTest != null ? abTest.TestSizePercentage : 10); } ucGroupSlider.ReloadData(forceReload); ucWO_OnChange(this, EventArgs.Empty); }
/// <summary> /// Returns issue's sent emails amount or delivered emails amount based on /// monitor bounced email setting. /// </summary> /// <param name="issue">Issue</param> private int GetSentOrDelivered(IssueInfo issue) { if (NewsletterHelper.MonitorBouncedEmails(CurrentSite.SiteName)) { return issue.IssueSentEmails - issue.IssueBounces; } return issue.IssueSentEmails; }
/// <summary> /// Creates new or updates existing newsletter issue. /// </summary> public bool Save() { if (validated || IsValid()) { IssueInfo issue = null; if (IssueID == 0) { // Initialize new issue issue = new IssueInfo(); issue.IssueUnsubscribed = 0; issue.IssueSentEmails = 0; issue.IssueNewsletterID = NewsletterID; issue.IssueSiteID = CMSContext.CurrentSiteID; } else { issue = IssueInfoProvider.GetIssueInfo(IssueID); } if (issue != null) { issue.IssueTemplateID = TemplateID; issue.IssueShowInNewsletterArchive = chkShowInArchive.Checked; issue.IssueSenderName = txtSenderName.Text.Trim(); issue.IssueSenderEmail = txtSenderEmail.Text.Trim(); // Saves content of editable region(s) // Get content from hidden field string content = hdnIssueContent.Value; string[] regions = null; if (!string.IsNullOrEmpty(content)) { // Split content for each region, separator is '#|#' regions = content.Split(new string[] { "#|#" }, StringSplitOptions.RemoveEmptyEntries); } issue.IssueText = IssueHelper.GetContentXML(regions); // Remove '#' from macros if included txtSubject.Text = txtSubject.Text.Trim().Replace("#%}", "%}"); // Sign macros if included in the subject issue.IssueSubject = MacroResolver.AddSecurityParameters(txtSubject.Text, CMSContext.CurrentUser.UserName, null); // Save issue IssueInfoProvider.SetIssueInfo(issue); // Update IssueID IssueID = issue.IssueID; return true; } } return false; }
/// <summary> /// In the parent issue is stored "SentEmail" amount of all variants and the remainder, /// so the remainder amount have to be computed by subtraction of all sent amounts /// from particular variants. /// </summary> /// <param name="parentIssue">Parent issue</param> /// <param name="variantIssue">Current variant</param> /// <returns></returns> private int CalculateVariantSentEmails(IssueInfo parentIssue, IssueInfo variantIssue) { if ((parentIssue == null) || (variantIssue == null)) { return 0; } if (IncludeAllVariants) { return GetSentOrDelivered(parentIssue); } // If the winner has not been selected yet, or the selected variant is not the winner // return SentEmails of the current variant if (parentIssue.IssueID != variantIssue.IssueID) { return variantIssue.IssueSentEmails; } var abTest = ABTestInfoProvider.GetABTestInfoForIssue(parentIssue.IssueID); if (abTest == null) { return 0; } // If variantIssue equals parentIssue it means that winner variant was selected, but the // filter has returned the parent variant, and we need winner variant object // For the winner variant is returned the sum of variant SentEmail amount and the remainder SentEmail amount. // See the "Summary" section for the domain specification. var sentSumFromRemainingVariants = IssueInfoProvider.GetIssues() .Column(new AggregatedColumn(AggregationType.Sum, "IssueSentEmails")) .WhereEquals("IssueVariantOfIssueID", parentIssue.IssueID) .And() .WhereNotEquals("IssueID", abTest.TestWinnerIssueID) .GetScalarResult(0); return parentIssue.IssueSentEmails - sentSumFromRemainingVariants; }
/// <summary> /// Returns information message according to current state, issue and A/B test. /// </summary> /// <param name="currState">Current state</param> /// <param name="issue">Issue</param> /// <param name="winnerOption">Winner option</param> /// <param name="plannedMailoutTime">Planned mailout time</param> private string GetInfoMessage(int currState, IssueInfo issue, ABTestWinnerSelectionEnum winnerOption, DateTime plannedMailoutTime) { if (issue == null) { return null; } switch (currState) { case STATE_WAITING_TO_SEND_WIZARD: return null; case STATE_WAITING_TO_SEND_PAGE: return GetString("Newsletter_Issue_Header.NotSentYet"); case STATE_TEST_WAITING_TO_SEL_WINNER: // Get current planned winner selection task var taskToSelectWinner = TaskInfoProvider.GetTaskInfo(abTest.TestWinnerScheduledTaskID); var plannedWinnerSelectionTime = (taskToSelectWinner == null) ? DateTimeHelper.ZERO_TIME : taskToSelectWinner.TaskNextRunTime; switch (winnerOption) { case ABTestWinnerSelectionEnum.Manual: if (issue.IssueMailoutTime > DateTime.Now) { return String.Format(GetString("newsletterinfo.issuesentwaitingtosentwinner"), GetTimeOrNA(issue.IssueMailoutTime), GetWinnerSelectionTime()); } return String.Format(GetString("newsletterinfo.issuesentwaitingtoselwinnermanually"), GetTimeOrNA(issue.IssueMailoutTime)); case ABTestWinnerSelectionEnum.OpenRate: return String.Format(GetString("newsletterinfo.issuesentwaitingtoselwinneropen"), GetTimeOrNA(issue.IssueMailoutTime), GetTimeOrNA(plannedWinnerSelectionTime)); case ABTestWinnerSelectionEnum.TotalUniqueClicks: return String.Format(GetString("newsletterinfo.issuesentwaitingtoselwinnerclicks"), GetTimeOrNA(issue.IssueMailoutTime), GetTimeOrNA(plannedWinnerSelectionTime)); } break; case STATE_TEST_READY_FOR_SENDING: return String.Format(GetString("newsletter_issue_header.issuesending"), GetTimeOrNA(plannedMailoutTime)); case STATE_TEST_FINISHED: switch (winnerOption) { case ABTestWinnerSelectionEnum.Manual: return String.Format(GetString("newsletterinfo.issuesentwinnerselmanually"), GetTimeOrNA(issue.IssueMailoutTime), GetWinnerSelectionTime()); case ABTestWinnerSelectionEnum.OpenRate: return String.Format(GetString("newsletterinfo.issuesentwinnerselopen"), GetWinnerSelectionTime()); case ABTestWinnerSelectionEnum.TotalUniqueClicks: return String.Format(GetString("newsletterinfo.issuesentwinnerselclicks"), GetWinnerSelectionTime()); } break; } return null; }