Kentico CMS 7.0 Developer's Guide

Managing issues

Managing issues

Previous topic Next topic Mail us feedback on this topic!  

Managing issues

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Arrow


API examples for newer versions


Please visit the latest API Examples documentation to view API examples for newer versions of Kentico.



The following example creates a static issue.

 

private bool CreateStaticIssue()
{
  // Gets the newsletter
  NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewStaticNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Creates a new static issue object
      IssueInfo newIssue = new IssueInfo();

 
      // Sets 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;

 
      // Saves the static issue
      IssueInfoProvider.SetIssueInfo(newIssue);

 
      return true;
   }

 
  return false;
}

 

The following example gets and updates a static issue.

 

private bool GetAndUpdateStaticIssue()
{
  // Gets the newsletter
  NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewStaticNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Prepares the parameters
      string where = "IssueNewsletterID = " + newsletter.NewsletterID;

 
      // Gets the data
      DataSet issues = IssueInfoProvider.GetIssues(where, null);

 
      if (!DataHelper.DataSourceIsEmpty(issues))
       {
          // Creates an object from the DataRow
          IssueInfo updateIssue = new IssueInfo(issues.Tables[0].Rows[0]);

 
          if (updateIssue != null)
           {
              // Updates the properties
               updateIssue.IssueSubject = updateIssue.IssueSubject.ToLower();

 
              // Saves the changes
              IssueInfoProvider.SetIssueInfo(updateIssue);

 
              return true;
           }
       }
   }
  return false;
}

 

The following example gets and bulk updates static issues.

 

private bool GetAndBulkUpdateStaticIssues()

{
  // Gets the newsletter
  NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewStaticNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Prepares the parameters
      string where = "IssueNewsletterID = " + newsletter.NewsletterID;

 
      // Gets the data
      DataSet issues = IssueInfoProvider.GetIssues(where, null);
      if (!DataHelper.DataSourceIsEmpty(issues))
       {
          // Loops through the items
          foreach (DataRow issueDr in issues.Tables[0].Rows)
           {
              // Creates object from the DataRow
              IssueInfo modifyIssue = new IssueInfo(issueDr);

 
              // Updates the properties
               modifyIssue.IssueSubject = modifyIssue.IssueSubject.ToUpper();

 
              // Saves the changes
              IssueInfoProvider.SetIssueInfo(modifyIssue);
           }

 
          return true;
       }
   }

 
  return false;
}

 

The following example creates a dynamic issue.

 

private bool CreateDynamicIssue()
{
  // Gets the newsletter
  NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Generates a dynamic issue
      EmailQueueManager.GenerateDynamicIssue(newsletter.NewsletterID);

 
      return true;
   }

 
  return false;
}

 

The following example gets and updates a dynamic issue.

 

private bool GetAndUpdateDynamicIssue()
{
  // Gets the newsletter
  NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Prepares the parameters
      string where = "IssueNewsletterID = " + newsletter.NewsletterID;

 
      // Gets the data
      DataSet issues = IssueInfoProvider.GetIssues(where, null);

 
      if (!DataHelper.DataSourceIsEmpty(issues))
       {
          // Creates an object from the DataRow
          IssueInfo updateIssue = new IssueInfo(issues.Tables[0].Rows[0]);

 
          if (updateIssue != null)
           {
              // Updates the properties
               updateIssue.IssueSubject = updateIssue.IssueSubject.ToLower();

 
              // Saves the changes
              IssueInfoProvider.SetIssueInfo(updateIssue);

 
              return true;
           }
       }
   }
  return false;
}

 

The following example gets and bulk updates dynamic issues.

 

private bool GetAndBulkUpdateDynamicIssues()
{
  // Gets the newsletter
  NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Prepares the parameters
      string where = "IssueNewsletterID = " + newsletter.NewsletterID;

 
      // Gets the data
      DataSet issues = IssueInfoProvider.GetIssues(where, null);
      if (!DataHelper.DataSourceIsEmpty(issues))
       {
          // Loops through the individual items
          foreach (DataRow issueDr in issues.Tables[0].Rows)
           {
              // Creates an object from the DataRow
              IssueInfo modifyIssue = new IssueInfo(issueDr);

 
              // Updates the properties
               modifyIssue.IssueSubject = modifyIssue.IssueSubject.ToUpper();

 
              // Saves the changes
              IssueInfoProvider.SetIssueInfo(modifyIssue);
           }

 
          return true;
       }
   }
  return false;
}

 

The following example deletes a dynamic issue.

 

private bool DeleteDynamicIssue()
{
  // Gets the newsletter
  NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Prepares the parameters
      string where = "IssueNewsletterID = " + newsletter.NewsletterID;

 
      // Gets the data
      DataSet issues = IssueInfoProvider.GetIssues(where, null);

 
      if (!DataHelper.DataSourceIsEmpty(issues))
       {
          // Creates an object from the DataRow
          IssueInfo deleteIssue = new IssueInfo(issues.Tables[0].Rows[0]);

 
          // Deletes the dynamic issue
          IssueInfoProvider.DeleteIssueInfo(deleteIssue);

 
          return (deleteIssue != null);
       }
   }
  return false;
}

 

The following example deletes a static issue.

 

private bool DeleteStaticIssue()
{
  // Gets the newsletter
  NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewStaticNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Prepares the parameters
      string where = "IssueNewsletterID = " + newsletter.NewsletterID;

 
      // Gets the data
      DataSet issues = IssueInfoProvider.GetIssues(where, null);

 
      if (!DataHelper.DataSourceIsEmpty(issues))
       {
          // Creates an object from the DataRow
          IssueInfo deleteIssue = new IssueInfo(issues.Tables[0].Rows[0]);

 

          // Deletes the static issue
          IssueInfoProvider.DeleteIssueInfo(deleteIssue);

 
          return (deleteIssue != null);
       }
   }
  return false;
}