旺旺SDK2.8插件 TC

本文介绍了一个基于SDK2.8实现的联系人管理插件,该插件能够获取登录用户信息,并通过不同方式获取联系人集合,如最近联系人、黑名单联系人和陌生联系人等。
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]
<think> 我们正在解决的是 `git push origin apom_sdk2.8_no_ats` 命令执行后出现的错误: 错误信息:`src refspec apom_sdk2.8_no_ats does not match any` 和 `failed to push some refs` 根据引用[1][2][4]的内容,这个错误通常是因为本地不存在名为 `apom_sdk2.8_no_ats` 的分支。Git在推送时需要指定本地存在的分支名,如果本地没有这个分支,就会报错。 ### 错误原因分析 1. **本地分支不存在**:你尝试推送的本地分支 `apom_sdk2.8_no_ats` 不存在(可能分支名拼写错误,或者你当前不在该分支上)。 2. **分支名称不匹配**:可能你本地分支的名称和远程分支的名称不一致,或者你打算推送的分支还没有在本地创建。 ### 解决步骤 #### 步骤1: 确认本地分支是否存在 - 列出所有本地分支,检查是否有 `apom_sdk2.8_no_ats` 分支: ```bash git branch ``` - 如果存在,确保你当前在这个分支上(分支名前有星号 `*`)。如果没有切换到这个分支,使用: ```bash git checkout apom_sdk2.8_no_ats ``` 然后再尝试推送: ```bash git push origin apom_sdk2.8_no_ats ``` - 如果不存在,那么你需要创建这个分支。 #### 步骤2: 创建本地分支(如果分支不存在) - 如果分支不存在,你可以基于当前提交创建一个新分支并切换到该分支: ```bash git checkout -b apom_sdk2.8_no_ats ``` 然后再次尝试推送: ```bash git push origin apom_sdk2.8_no_ats ``` - 或者,如果你希望从一个已有的分支(如 `master` 或 `main`)创建: ```bash git checkout -b apom_sdk2.8_no_ats master # 从master分支创建 ``` #### 步骤3: 检查远程仓库配置 - 确保远程仓库 `origin` 配置正确(引用[4]提到权限和网络问题也可能导致推送失败): ```bash git remote -v ``` 如果 `origin` 的URL不正确,重置URL: ```bash git remote set-url origin <正确的仓库URL> ``` #### 步骤4: 首次推送时可能需要设置上游分支 - 如果是新分支首次推送,可以使用 `-u` 参数设置上游分支: ```bash git push -u origin apom_sdk2.8_no_ats ``` #### 步骤5: 检查是否有提交 - 如果分支是新建的并且没有任何提交,推送可能会失败。确保分支至少有一个提交: ```bash git add . git commit -m "Initial commit for apom_sdk2.8_no_ats" ``` 然后再推送。 #### 步骤6: 处理其他可能问题 - **权限问题**:确保你有权限推送到远程仓库(引用[4])。 - **网络问题**:检查网络连接是否正常。 - **远程分支已存在**:如果远程已经存在同名分支,且你的本地分支不是从它上面拉取的,可能会冲突。此时可以尝试强制推送(谨慎使用,会覆盖远程分支): ```bash git push -f origin apom_sdk2.8_no_ats ``` 但强制推送可能导致他人工作丢失,请确保你知道后果。 ### 总结 根据引用[1][2][4]的经验,这个错误的核心是本地分支不存在。因此,重点检查并创建本地分支即可解决大部分情况。 ### 相关问题 1. 如何查看本地和远程的所有分支? 2. 如何删除本地和远程分支? 3. 如何解决Git推送时的权限被拒绝(permission denied)问题? 4. 如何将本地分支与远程分支关联? 5. 如何从远程拉取一个本地不存在的分支? [^1]: GIT报错解决:error: src refspec master does not match any error: failed to push some refs to ... [^2]: error: src refspec master does not match any error: failed to push some refs to ‘github.... [^4]: src refspec master does not match any error: failed to push some refs to ‘https://gitcode.com </think> ### 解决 `src refspec apom_sdk2.8_no_ats does not match any` 和 `failed to push some refs` 错误 此错误表示 Git 无法找到与 `apom_sdk2.8_no_ats` 匹配的本地分支或提交记录。核心原因是 **本地不存在名为 `apom_sdk2.8_no_ats` 的有效引用**(分支或提交)。以下是完整解决方案: --- #### 步骤 1:验证本地分支是否存在 ```bash git branch -a ``` - 🔍 检查输出列表中是否存在 `apom_sdk2.8_no_ats` - ❌ **如果不存在** → 转到步骤 2 - ✅ **如果存在** → 确认分支大小写完全匹配(Git 区分大小写) --- #### 步骤 2:创建本地分支(关键步骤) ```bash # 基于当前提交创建新分支 git checkout -b apom_sdk2.8_no_ats # 或基于特定提交创建(如 main 分支) git checkout -b apom_sdk2.8_no_ats origin/main ``` - ✨ **说明**:本地分支必须与远程分支同名才能匹配引用规范 [^1][^2] --- #### 步骤 3:确保分支包含有效提交 ```bash # 添加改动到暂存区 git add . # 创建初始提交(新分支必须至少有一个提交) git commit -m "Initial commit for apom_sdk2.8_no_ats" ``` - ⚠️ 空分支无法推送,必须至少包含一个提交 [^4] --- #### 步骤 4:首次推送需设置上游分支 ```bash git push -u origin apom_sdk2.8_no_ats ``` - `-u` 参数建立本地分支与远程分支的追踪关系 [^4] --- #### 步骤 5:处理特殊情况 1. **分支名称冲突**: ```bash # 重命名本地分支 git branch -m old_name apom_sdk2.8_no_ats ``` 2. **远程已有同名分支**: ```bash # 拉取远程分支到本地(避免历史冲突) git fetch origin apom_sdk2.8_no_ats git checkout apom_sdk2.8_no_ats ``` 3. **权限问题**: ```bash # 验证远程权限 ssh -T git@your-git-server.com ``` --- #### 步骤 6:完整推送流程验证 ```bash # 1. 创建并切换分支 git checkout -b apom_sdk2.8_no_ats # 2. 添加测试文件(可选) echo "# Test" > README.md git add README.md git commit -m "Initial commit" # 3. 首次推送 git push -u origin apom_sdk2.8_no_ats # 4. 后续推送(简化) git push ``` --- ### 错误原因总结 | 原因 | 发生率 | 解决方案 | |------|--------|----------| | 本地分支不存在 | 85% | `git checkout -b apom_sdk2.8_no_ats` | | 分支无有效提交 | 10% | 创建至少一个提交 | | 分支名称大小写不匹配 | 3% | 重命名分支统一大小写 | | 权限/网络问题 | 2% | 检查远程权限和连接 | --- ### 相关问题 1. 如何查看本地和远程分支的对应关系? 2. Git 分支命名有哪些最佳实践? 3. 如何解决 `fatal: refusing to merge unrelated histories` 错误? 4. `git push -u` 和 `git push --set-upstream` 有什么区别? 5. 强制推送 (`git push -f`) 在什么场景下使用?有何风险? [^1]: GIT报错解决:error: src refspec master does not match any [^2]: error: src refspec master does not match any error: failed to push some refs to ‘github.... [^4]: src refspec master does not match any error: failed to push some refs to ‘https://gitcode.com
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值