YahooPublisher.cs :  » Build-Systems » CruiseControl.NET » ThoughtWorks » CruiseControl » Core » Publishers » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Build Systems » CruiseControl.NET 
CruiseControl.NET » ThoughtWorks » CruiseControl » Core » Publishers » YahooPublisher.cs
using System;
using System.Collections;
using System.IO;
using System.Xml;
using Exortech.NetReflector;
using System.Runtime.InteropServices;




namespace ThoughtWorks.CruiseControl.Core.Publishers{
  /// <summary>
  /// Summary description for YahooPublisher.
  /// Yahoo Publisher uses YPluginDLL.DLL for sending the Yahoo IM Message to any one. It works only on Windows Platforms
  /// 
  /// Configuring Yahoo Publisher
  /// 1.  Yahoo Publisher Expects a already Logged in User
  ///    a.  Start Yahoo Messenger
  ///    b.  Set to login when systems starts, and to remember your user id and password
  ///  2.  Make sure that Yahoo Messenger is there and you can send message using Yahoo Messenger.
  ///  3.  In config file, add users and their IDs, a sample of yahoo plugin config is given below.
  ///  4.  I have removed left angular bracket from begning of the line because of parsing problems of the compiler, Please add brackets.
  ///  
  ///  @  yplugin from=""ccnet@thoughtworks.com"" projectUrl=""http://localhost/ccnet""
  ///  @    yahoousers>
  ///  @      yuser ame=""buildmaster"" group=""buildmaster"" id=""itsajey""/>
  ///  @      yuser name=""netbuzzme"" group=""developers"" id=""netbuzzme""/>
  ///  @      yuser name=""itsajey""  group=""developers"" id=""ajey.gore""/>
  ///  @      yuser name=""narsi"" group=""developers"" id=""narsi321""/>
  ///  @      yuser name=""asubrama"" group=""developers"" id=""ashok_subramanian""/>
  ///  @    /yahoousers>
  ///  @    yahoogroups>
  ///  @      ygroup  name=""developers""  notification=""change""/>
  ///  @      ygroup  name=""buildmaster"" notification=""always""/>        
  ///  @    /yahoogroups>
  ///  @  /yplugin>
  ///    
  /// </summary>
  /// 
  public unsafe class YahooWrap
  {
    [ DllImport( "YpluginDLL.DLL", EntryPoint="SendYahooMessage")]
    //, CharSet=CharSet.Ansi commented CharSet because it may fail on some systems, 
    // if we experience problem we will add this again (Interop Services comments)
    
    public static extern int SendYahooMessage(String to, String message);
        
  }  
  [ReflectorType("yplugin")]
  public class YahooPublisher : PublisherBase
  {
    private string _projectUrl;
  
    private Hashtable _users = new Hashtable();
    private Hashtable _groups = new Hashtable();

    public YahooPublisher()
    {
      //
      // TODO: Add constructor logic here
      //
    }
    public override void Publish(object source, IntegrationResult result)
    {
    
      String Message = CreateMessage(result);
      SendMessageToNotifyGroupMembers(result, Message);
      SendMessageToModifiersWhoCheckedInTheFiles(result.Modifications, Message);

    
    }
    public void SendMessageToNotifyGroupMembers(IntegrationResult result, String Message)
    {
      foreach (YahooUser yuser in YahooUserIDs.Values)
      {
        YahooGroup group = GetYahooGroup(yuser.Group);
        if ( group!= null && group.Notification.Equals(YahooGroup.NotificationType.Always))
        {
          YahooWrap.SendYahooMessage(yuser.ID, Message);
        }
      }
    }

    public void SendMessageToModifiersWhoCheckedInTheFiles(Modification[] modifications, String Message)
    {
      foreach (Modification modification in modifications)
      {
        YahooUser yuser = GetYahooUser(modification.UserName);
        if (yuser!=null)
        {
          YahooWrap.SendYahooMessage(yuser.ID, Message);
        }
      }

    }

    public void SendYahooMessage(String name, String message)
    {
      YahooWrap.SendYahooMessage(name, message);
    }

    public YahooUser GetYahooUser(string username)
    {
      return (YahooUser)_users[username];
    }

    public YahooGroup GetYahooGroup(string groupname)
    {
      return (YahooGroup)_groups[groupname];
    }
    
    internal string CreateMessage(IntegrationResult result)
    {
      // TODO Add culprit to message text -- especially if modifier is not an email user
      return String.Format(@"CC.NET Build Results for {0}: {1}", 
        result.ProjectName, LogFile.CreateUrl(ProjectUrl, result));
    }

    #region Configuration Properties
    

    [ReflectorProperty("projectUrl")]
    public string ProjectUrl
    {
      get { return _projectUrl; }
      set { _projectUrl = value; }
    }

    [ReflectorHash("yahoousers", "id")]
    public Hashtable YahooUserIDs
    {
      get { return _users; }
      set { _users = value; }
    }

    [ReflectorHash("yahoogroups", "name")]
    public Hashtable YahooGroups
    {
      get { return _groups; }
      set { _groups = value; }
    }
    #endregion

  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.