protected override void CreateChildControls() { base.CreateChildControls(); IIncidentManagementRepository incidentManagementRepository = SharePointServiceLocator.Current.GetInstance <IIncidentManagementRepository>(); // The Identifier of the incident that the current site is collaborating on is located // in the property bag. The identifier is stored during the subsite creation workflow. var incident = incidentManagementRepository.GetIncident(SPContext.Current.Web.Properties["incidentId"]); StringBuilder content = new StringBuilder("<h2>Incident Information (from incident management service)</h2>"); if (incident == null) { content.AppendLine("incident information is unavailable."); } else { content.AppendLine(string.Format(CultureInfo.CurrentCulture, "<h3>Description: {0}</h3>", incident.Description)); content.AppendLine(string.Format(CultureInfo.CurrentCulture, "<h3>Status: {0}</h3>", incident.Status)); content.AppendLine(string.Format(CultureInfo.CurrentCulture, "<h3>Product: {0}</h3>", incident.Product)); content.AppendLine("<h3>History:</h3>"); foreach (string note in incident.History) { content.AppendLine(string.Format(CultureInfo.CurrentCulture, "<li>{0}</li>", note)); } } LiteralControl literal = new LiteralControl(); literal.Text = content.ToString(); this.Controls.Add(literal); }
public IncidentTaskReceiver() { //Need to get the repository in the contructor because the SPContext is available. //The SPContext is NOT available in the ItemAdding event receiver. incidentManagementRepository = SharePointServiceLocator.Current.GetInstance <IIncidentManagementRepository>(); }