旺旺SDK2.8插件 TC

SDK2.8 联系人及联系人集合操作

入口类,实现了主程序和插件借口:

using System.Linq;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Text;
using wwsdkcomLib;
using System.Xml;

namespace TC01
{
public class Global
{
public static int lPluginCookie;
public static int lCookie;
public static object pSlot;
public static string appid = "13141123";
public static object pApplication;
}
[ComVisible(true),
Guid("B61D33ED-9689-4551-B102-A00E2B437938"),
ClassInterface(ClassInterfaceType.None)]
public class Class1 : ISDKPlugin2, ISDKDevPlugin
{
public void OnConnect(object pApplication, int lPluginCookie)
{
// OnConnect 不建议使用末态对话框
//ISDKPluginQueryResult pqr = (pApplication as ISDKApplication3).GetSubScriptionInfo(lPluginCookie) as ISDKPluginQueryResult;
//Global.appid = pqr.appID;
Global.lPluginCookie = lPluginCookie;
Global.pApplication = pApplication;
}

public void OnDisconnect(object pApplication, int lPluginCookie)
{
// OnDisConnect 不建议使用末态对话框
// MessageBox.Show("我被卸载了", "csharp helloworld");
}


public void OnNotify(SDKMessageID MsgID, object pParam)
{

if (MsgID == SDKMessageID.NOTIFY_OFFLINE)
{
}

else if (MsgID == SDKMessageID.NOTIFY_USERLOGIN)
{
}
}

public void OnUninstall()
{
}

public void Require()
{
}
}
[ComVisible(true),
Guid("D8A84BDF-6681-4c17-8B7B-A416C7BCF6A4"),
ClassInterface(ClassInterfaceType.None)]

public class Class2 : ISDKPluginItem
{

Form1 f1;

public void OnMenuClick(int lCmdID)
{
}

// 插件作为按钮出现时候得到点击后被调用
// 本例中此方法将在点击发生后得到调用

public void OnClick()
{
MessageBox.Show("进入工作平台");
try
{
this.f1.Show();
}
catch (Exception ex)
{
this.f1 = new Form1();
this.f1.Show();
}
}

// 插件接入到插槽后得到通知

public void OnCreate(object pSlot, int hParentWnd, int lCookie)
{
Global.lCookie = lCookie;
Global.pSlot = pSlot;
}

// 插件在附属插槽被销毁时候得到通知

public void OnDestroy()
{
// 使用模态对话框可能导致异常
// MessageBox.Show("聊天对话框输入工具条插件被销毁", "csharp allinone plugin");
}

// 和插件项本身相关的消息通知

public void OnNotify(SDKItemNotifyID MsgIDD, object pParam)
{

}

// 当插件以窗口形式出现情况下,在父窗口发生变化情况下得到通知

public void OnSize(int cx, int cy)
{
}

}

}


插件类,实现了插件的具体功能:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using wwsdkcomLib;

namespace TC01
{
public partial class Form1 : Form
{
ISDKContact3 ct3;
ISDKContact2 ct2;
ISDKContactMgr3 ctm3;
ISDKContactMgr2 ctm2;
ISDKLoginUser3 luser3;
ISDKApplication3 app3;

public Form1()
{
//MessageBox.Show("开始加载");
InitializeComponent();
try
{
this.app3 = (Global.pApplication as ISDKApplication3);
//MessageBox.Show("pApplication");
}
catch (Exception ex)
{
MessageBox.Show("(Global.pApplication as ISDKApplication);\n" + ex);
}
try
{
this.ctm3 = this.app3.GetContactMgr(Global.lPluginCookie) as ISDKContactMgr3;
}
catch (Exception ex)
{
MessageBox.Show(" (Global.pApplication as ISDKApplication3).GetContactMgr(Global.lPluginCookie) as ISDKContactMgr3;\n"+ex);
}
try
{
this.luser3 = this.app3.GetLoginUser(Global.lPluginCookie) as ISDKLoginUser3;
//MessageBox.Show("GetLoginUser OK");
}
catch (Exception ex)
{
MessageBox.Show(" (Global.pApplication as ISDKApplication3).GetLoginUser as ISDKLoginUser3;\n" + ex);
}
try
{
this.textBox5.Text ="用户昵称 ; "+ this.luser3.GetNickName(Global.lPluginCookie);
this.textBox5.Text += "\r\n用户活跃度 : "+this.luser3.GetActivitiesLevel(Global.lPluginCookie);
this.textBox5.Text += "\r\n当前服务器时间 : " + this.luser3.GetServerTime(Global.lPluginCookie);
//this.textBox5.Text += "\r\n用户Status : " + this.luser3(Global.lPluginCookie);
this.textBox5.Text += "\r\n用户SiteID : " + this.luser3.GetSiteID(Global.lPluginCookie);
this.textBox5.Text += "\r\n用户SiteName : " + this.luser3.GetSiteName(Global.lPluginCookie);
this.textBox5.Text += "\r\n用户UserID : " + this.luser3.GetUserID(Global.lPluginCookie);
this.textBox5.Text += "\r\n用户WWID : " + this.luser3.GetWangID(Global.lPluginCookie);
//MessageBox.Show("UserInfo OK");
}
catch (Exception ex)
{
MessageBox.Show(" (Global.pApplication as ISDKApplication3).GetLoginUser as ISDKLoginUser3;\r\n" + ex);
}
//MessageBox.Show("加载完毕");
}

private void button1_Click(object sender, EventArgs e)
{
try
{
string tempstr=this.textBox1.Text;
this.ct3 = this.ctm3.GetContact(Global.lPluginCookie, tempstr) as ISDKContact3;
this.label3.Text=this.ct3.GetUserID(Global.lPluginCookie);
}
catch(Exception ex)
{
MessageBox.Show("this.ctm2.GetContact(Global.lPluginCookie, this.label1.Text) as ISDKContact2;\n" + ex);
}
}

private void button2_Click(object sender, EventArgs e)
{
try
{
this.textBox4.Text = this.ct3.GetNickName(Global.lPluginCookie);
}
catch(Exception ex)
{
MessageBox.Show("this.ct3.GetNickName(Global.lPluginCookie);\n"+ex);
}

}

private void button3_Click(object sender, EventArgs e)
{
try
{
this.textBox4.Text = this.ct3.GetSiteID(Global.lPluginCookie);
}
catch (Exception ex)
{
MessageBox.Show("this.ct3.GetSiteID(Global.lPluginCookie);\n" + ex);
}
}

private void button4_Click(object sender, EventArgs e)
{
try
{
this.textBox4.Text = this.ct3.GetSiteName(Global.lPluginCookie);
}
catch (Exception ex)
{
MessageBox.Show("this.ct3.GetSiteName(Global.lPluginCookie);\n" + ex);
}
}

private void button5_Click(object sender, EventArgs e)
{
try
{
ISDKGroup sdkGroup = (this.ct3.GetInGroup(Global.lPluginCookie) as ISDKGroup);
string s = sdkGroup.GetGroupName(Global.lPluginCookie);
this.textBox4.Text = s;
}
catch (Exception ex)
{
MessageBox.Show("this.(ct3.GetInGroup(Global.lPluginCookie) as ISDKGroup).GetGroupName(Global.lPluginCookie);\n" + ex);
}
}

private void button6_Click(object sender, EventArgs e)
{
ISDKObjectCollection ct3s;
string tempstr = "GetNickName" + "\t" + "GetSiteID" + "\t" + "GetSiteName" + "\t" + "GetInGroup" + "\t用户Status" + "\r\n";
try
{
ct3s=this.ctm3.GetRecentContactCollection(Global.lPluginCookie) as ISDKObjectCollection;
foreach(ISDKContact3 ct3 in ct3s){
tempstr += (ct3.GetNickName(Global.lPluginCookie)+"\t"+ct3.GetSiteID(Global.lPluginCookie) +"\t"+ct3.GetSiteName(Global.lPluginCookie)+"\t"+(ct3.GetInGroup(Global.lPluginCookie) as ISDKGroup).GetGroupName(Global.lPluginCookie)+"\t"+ct3.GetStatus(Global.lPluginCookie)+"\r\n");
}
tempstr +="\n最近联系人总数为:" + ct3s.Count;
this.textBox3.Text = tempstr;
}
catch (Exception ex) { MessageBox.Show("this.ctm3.GetRecentContactCollection(Global.lPluginCookie) as ISDKObjectCollection;"); }
}

private void button7_Click(object sender, EventArgs e)
{
ISDKObjectCollection ct3s;
string tempstr = "GetNickName" + "\t" + "GetSiteID" + "\t" + "GetSiteName" + "\t" + "GetInGroup" + "\t用户Status" + "\r\n";
try
{
ct3s = this.ctm3.GetFilterContactCollection(Global.lPluginCookie) as ISDKObjectCollection;
foreach (ISDKContact3 ct3 in ct3s)
{
tempstr += (ct3.GetNickName(Global.lPluginCookie) + "\t" + ct3.GetSiteID(Global.lPluginCookie) + "\t" + ct3.GetSiteName(Global.lPluginCookie) + "\t" + (ct3.GetInGroup(Global.lPluginCookie) as ISDKGroup).GetGroupName(Global.lPluginCookie) + ct3.GetStatus(Global.lPluginCookie) + "\r\n");
}
tempstr += "\n黑名单联系人总数为:" + ct3s.Count;
this.textBox3.Text = tempstr;
}
catch (Exception ex) { MessageBox.Show("this.ctm3.GetFilterContactCollection(Global.lPluginCookie) as ISDKObjectCollection;"); }
}

private void button8_Click(object sender, EventArgs e)
{
ISDKObjectCollection ct3s;
string tempstr = "GetNickName" + "\t" + "GetSiteID" + "\t" + "GetSiteName" + "\t" + "GetInGroup" + "\t用户Status" + "\r\n";
try
{
ct3s = this.ctm3.GetStrangerContactCollection(Global.lPluginCookie) as ISDKObjectCollection;
foreach (ISDKContact3 ct3 in ct3s)
{
tempstr += (ct3.GetNickName(Global.lPluginCookie) + "\t" + ct3.GetSiteID(Global.lPluginCookie) + "\t" + ct3.GetSiteName(Global.lPluginCookie) + "\t" + (ct3.GetInGroup(Global.lPluginCookie) as ISDKGroup).GetGroupName(Global.lPluginCookie) + ct3.GetStatus(Global.lPluginCookie) + "\r\n");
}
tempstr += "\n陌生联系人总数为:" + ct3s.Count;
this.textBox3.Text = tempstr;
}
catch (Exception ex) { MessageBox.Show("this.ctm3.GetStrangerContactCollection(Global.lPluginCookie) as ISDKObjectCollection;"); }
}

private void button16_Click(object sender, EventArgs e)
{
//活跃度级别
MessageBox.Show("活跃度级别 : "+this.luser3.GetActivitiesLevel(Global.lPluginCookie));
}

private void button17_Click(object sender, EventArgs e)
{
MessageBox.Show("旺号 : " + this.luser3.GetWangID(Global.lPluginCookie));
}

private void button18_Click(object sender, EventArgs e)
{
MessageBox.Show("昵称 : " + this.luser3.GetNickName(Global.lPluginCookie));
}
}
}


插件如下:

[img]/upload/attachment/55675/c17c9925-349b-3dc1-8b88-22157605fa4e.jpg[/img]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值