Wednesday, January 27, 2010

png.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Drawing;
using System.Text;
//5_1_a_s_p_x.c_o_m

public partial class png : System.Web.UI.Page
{
private readonly string ImagePath = "Validator.jpg";
private static string gif = "";

protected void Page_Load(object sender, EventArgs e)
{

switch (Request.QueryString["aa"])
{
case "1":
gif = stxt();
Session["gif"]= stxt();
break;
case "2":
gif = GetRandomint();
Session["gif"]= GetRandomint();
break;
case "3":
gif = RndNum(3);
Session["gif"]= RndNum(3);
break;
default:
gif = RndNum(3);
Session["gif"]= GetRandomint();
break;
}

///创建Bmp位图
Bitmap bitMapImage = new System.Drawing.Bitmap(Server.MapPath(ImagePath));
Graphics graphicImage = Graphics.FromImage(bitMapImage);

///设置画笔的输出模式
graphicImage.SmoothingMode = SmoothingMode.HighSpeed;
///添加文本字符串
graphicImage.DrawString(gif, new Font("Arial", 20, FontStyle.Bold), SystemBrushes.WindowText, new Point(0, 0));

///设置图像输出的格式
Response.ContentType = "image/jpeg";

///保存数据流
bitMapImage.Save(Response.OutputStream, ImageFormat.Jpeg);

///释放占用的资源
graphicImage.Dispose();
bitMapImage.Dispose();
}
private String GetRandomint()
{
Random random = new Random();
return (random.Next(100000, 999999).ToString());
}
/**//*
此函数在汉字编码范围内随机创建含两个元素的十六进制字节数组,每个字节数组代表一个汉字,并将
四个字节数组存储在object数组中。
参数:strlength,代表需要产生的汉字个数
*/
public static object[] CreateRegionCode(int strlength)
{
//定义一个字符串数组储存汉字编码的组成元素
string[] rBase=new String [16]{"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"};

Random rnd=new Random();

//定义一个object数组用来
object[] bytes=new object[strlength];

/**//*每循环一次产生一个含两个元素的十六进制字节数组,并将其放入bject数组中
每个汉字有四个区位码组成
区位码第1位和区位码第2位作为字节数组第一个元素
区位码第3位和区位码第4位作为字节数组第二个元素
*/
for(int i=0;i {
//区位码第1位
int r1=rnd.Next(11,14);
string str_r1=rBase[r1].Trim();

//区位码第2位
rnd=new Random(r1*unchecked((int)DateTime.Now.Ticks)+i);//更换随机数发生器的种子避免产生重复值
int r2;
if (r1==13)
{
r2=rnd.Next(0,7);
}
else
{
r2=rnd.Next(0,16);
}
string str_r2=rBase[r2].Trim();

//区位码第3位
rnd=new Random(r2*unchecked((int)DateTime.Now.Ticks)+i);
int r3=rnd.Next(10,16);
string str_r3=rBase[r3].Trim();

//区位码第4位
rnd=new Random(r3*unchecked((int)DateTime.Now.Ticks)+i);
int r4;
if (r3==10)
{
r4=rnd.Next(1,16);
}
else if (r3==15)
{
r4=rnd.Next(0,15);
}
else
{
r4=rnd.Next(0,16);
}
string str_r4=rBase[r4].Trim();

//定义两个字节变量存储产生的随机汉字区位码
byte byte1=Convert.ToByte(str_r1 + str_r2,16);
byte byte2=Convert.ToByte(str_r3 + str_r4,16);
//将两个字节变量存储在字节数组中
byte[] str_r=new byte[]{byte1,byte2};

//将产生的一个汉字的字节数组放入object数组中
bytes.SetValue(str_r,i);

}

return bytes;

}
private string stxt()
{
Encoding gb = Encoding.GetEncoding("gb2312");

//调用函数产生4个随机中文汉字编码
object[] bytes = CreateRegionCode(3);

//根据汉字编码的字节数组解码出中文汉字
string str1 = gb.GetString((byte[])Convert.ChangeType(bytes[0], typeof(byte[])));
string str2 = gb.GetString((byte[])Convert.ChangeType(bytes[1], typeof(byte[])));
string str3 = gb.GetString((byte[])Convert.ChangeType(bytes[2], typeof(byte[])));

string txt = str1 + str2 + str3;
return txt;
}
///
/// 这个是使用文字,字母,数字混合
///

///
///
public String RndNum(int VcodeNum)
{
String Vchar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,W,X,Y,Z,呵,哈,弹,簧,秤,嬉,戏";
String[] VcArray = Vchar.Split(',');
String VNum = "";
Random random = new Random();
for (int i = 1; i <= VcodeNum; i++)
{
int iNum = 0;
while ((iNum = Convert.ToInt32(VcArray.Length * random.NextDouble())) == VcArray.Length)
{
iNum = Convert.ToInt32(VcArray.Length * random.NextDouble());
}
VNum += VcArray[iNum];
}
return VNum;
}
}

Common.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

using System.Text.RegularExpressions;
namespace PowerTalkClient
{
public class Common
{
///
/// 数据库联接
///

public static OleDbConnection OleConn
{
get {
return new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Jet OLEDB:Database Password=;Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "\\IP.mdb"); //Access数据库连接字符串
}
}
///
/// 数据库联接
///

public static OleDbConnection OleSysConn
{
get
{
return new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Jet OLEDB:Database Password=powertalkbox;Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "\\PowerData.mdb"); //Access数据库连接字符串
}
}
///
/// 获取真实地址
///

public static string GetAddr(string IPStr)
{

string DiZhi = "未知网络";
OleDbConnection Conn = OleConn;
try
{
string IP = IPToInt(IPStr).ToString();

Conn.Open();
object Obj = new OleDbCommand("select top 1 region from ip where IPN1<=" + IP + " and IPN2>=" + IP, Conn).ExecuteScalar();
if (Obj != null)
{
DiZhi = Obj.ToString();
}
}
catch { }
finally { Conn.Close(); }
return DiZhi;
//5-1-a-s-p-x
}

///
/// IP地址和数字之间转化的算法

///

/// 传入IP地址
///

public static uint IPToInt(string ipAddress)
{
string disjunctiveStr = ".,: ";
char[] delimiter = disjunctiveStr.ToCharArray();
string[] startIP = null;
for (int i = 1; i <= 5; i++)
{
startIP = ipAddress.Split(delimiter, i);
}
string a1 = startIP[0].ToString();
string a2 = startIP[1].ToString();
string a3 = startIP[2].ToString();
string a4 = startIP[3].ToString();
uint U1 = uint.Parse(a1);
uint U2 = uint.Parse(a2);
uint U3 = uint.Parse(a3);
uint U4 = uint.Parse(a4);
uint U = U1 << 24;
U += U2 << 16;
U += U3 << 8;
U += U4;
return U;
}
///
/// 数字和IP地址之间转化的算法
///

/// 传入IP地址
///
public static string IntToIP(uint ipAddress)
{
long ui1 = ipAddress & 0xFF000000;
ui1 = ui1 >> 24;
long ui2 = ipAddress & 0x00FF0000;
ui2 = ui2 >> 16;
long ui3 = ipAddress & 0x0000FF00;
ui3 = ui3 >> 8;
long ui4 = ipAddress & 0x000000FF;
string IPstr = "";
IPstr = System.Convert.ToString(ui1) + "." + System.Convert.ToString(ui2) + "." + System.Convert.ToString(ui3) + "." + System.Convert.ToString(ui4);
return IPstr;
}

///
/// 转换成为MSN表情
///

///
public static string MatchImg(string MatchStr)
{
string regstr = @"src\=.+?\.(gif|jpg|png|bmp)";
Regex myrg = new Regex(regstr);
Match mt = myrg.Match(MatchStr, 0);
int i = 0;
while (mt.Success)
{
string Values = mt.Value;
string Mtch = Values;
Values = Regex.Replace(Values, "src=", "", RegexOptions.IgnoreCase);
Values = Regex.Replace(Values, "‘", "", RegexOptions.IgnoreCase);
Values = Regex.Replace(Values, "\"", "", RegexOptions.IgnoreCase);
Values = Regex.Replace(Values, "'", "", RegexOptions.IgnoreCase);
Values = Regex.Replace(Values, "’", "", RegexOptions.IgnoreCase);

Values = Values.Substring(Values.LastIndexOf(@"/") + 1);

MatchStr = MatchStr.Replace("", ToMsnFace(Values));

mt = mt.NextMatch();
}
return MatchStr;
}
//5~1~a~s~p~x
///
/// 从Image转换为Msn的头像
///

/// 头像图片名称
///
private static string ToMsnFace(string faceimg)
{
string MsnFace = "";
switch (faceimg)
{

case "img1.gif":
MsnFace = ":)";
break;
case "img2.gif":
MsnFace = ":-O";
break;
case "img3.gif":
MsnFace = ":P";
break;
case "img4.gif":
MsnFace = "(H)";
break;
case "img5.gif":
MsnFace = ":@";
break;
case "img6.gif":
MsnFace = ":S";
break;
case "img7.gif":
MsnFace = ":$";
break;
case "img8.gif":
MsnFace = ":'(";
break;
case "img9.gif":
MsnFace = ":|";
break;
case "img10.gif":
MsnFace = "(A)";
break;
case "img11.gif":
MsnFace = "8o|";
break;
case "img12.gif":
MsnFace = "8-|";
break;
case "img13.gif":
MsnFace = "+o(";
break;
case "img14.gif":
MsnFace = "<:o)";
break;
case "img15.gif":
MsnFace = "|-)";
break;
case "img16.gif":
MsnFace = "*-)";
break;
case "img17.gif":
MsnFace = ":-#";
break;
case "img18.gif":
MsnFace = ":-*";
break;
case "img19.gif":
MsnFace = "^o)";
break;
case "img20.gif":
MsnFace = "8-)";
break;
case "img21.gif":
MsnFace = "(L)";
break;
case "img22.gif":
MsnFace = "(U)";
break;
case "img23.gif":
MsnFace = "(M)";
break;
case "img24.gif":
MsnFace = "(@)";
break;
case "img25.gif":
MsnFace = "(&)";
break;
case "img26.gif":
MsnFace = "(sn)";
break;
case "img27.gif":
MsnFace = "(bah)";
break;
case "img28.gif":
MsnFace = "(S)";
break;
case "img29.gif":
MsnFace = "(*)";
break;
case "img30.gif":
MsnFace = "(#)";
break;
case "img31.gif":
MsnFace = "(R)";
break;
case "img32.gif":
MsnFace = "({)";
break;
case "img33.gif":
MsnFace = "(})";
break;
case "img34.gif":
MsnFace = "(K)";
break;
case "img35.gif":
MsnFace = "(F)";
break;
case "img36.gif":
MsnFace = "(W)";
break;
case "img37.gif":
MsnFace = "(O)";
break;
case "img38.gif":
MsnFace = ";)";
break;
case "img39.gif":
MsnFace = ":D";
break;
case "img40.gif":
MsnFace = ":(";
break;
default:
MsnFace = ":)";
break;


}
return MsnFace;
}

}

//5~1-a^s^p^x
public enum Action
{
///
/// 鼓掌
///

CONGRATULATE,
///
/// 查找
///

CHECKINGSOMETHING,
///
/// 眨眼
///

DEEPIDLE1,
///
/// 缩小
///

HIDE,
///
/// 销毁
///

EMPTYTRASH,
///
/// 手势•下
///

GESTUREDOWN,
///
/// 手势•左
///

GESTURELEFT,
///
/// 手势•右
///

GESTURERIGHT,
///
/// 手势•上
///

GESTUREUP,
///
/// 靠近屏幕打招呼
///

GETATTENTION,
///
/// 感汉号
///

WAVE,
///
/// 鲜花
///

GETTECHY,
///
/// 鞠躬
///

GETWIZARDY,
///
/// 小助手下班
///

GOODBYE,
///
/// 小助手上班
///

GREETING,
///
/// 想一下
///

ALERT,
///
/// 往下看
///

LOOKDOWN,
///
/// 往左下看
///

LOOKDOWNLEFT,
///
/// 往右下看
///

LOOKDOWNRIGHT,
///
/// 往左看
///

LOOKLEFT,
///
/// 往右看
///

LOOKRIGHT,
///
/// 往上看
///

LOOKUP,
///
/// 往左上看
///

LOOKUPLEFT,
///
/// 往右上看
///

LOOKUPRIGHT,
///
/// 打印
///

PRINT,
///
/// 动作还原
///

RESTPOSE,
///
/// 保存
///

SAVE,
///
/// 后面找东西
///

SEARCHING,
///
/// 邮件
///

SENDMAIL,
///
/// 思考
///

THINKING,
///
/// 挥手再见
///

PROCESSING,
///
/// 写东西
///

WRITING,
}

public class 助手
{
Timer timer = null;
Timer speakTimer = null;

Action _Action;
public Action Action
{
get { return _Action; }
set
{
if (value.ToString() != "")
{
_Action = value;
this.Character.Stop(null);
Character.Play(value.ToString());
}
}
}

AgentObjects.IAgentCtlCharacterEx Character = null;
AxAgentObjects.AxAgent Agent = null;
string Name = string.Empty;
string Path = string.Empty;

Action[] actions = new Action[] {
Action.CONGRATULATE,
Action.DEEPIDLE1,
Action.EMPTYTRASH,
Action.GETATTENTION,
Action.WAVE,
Action.GETTECHY,
Action.GETWIZARDY,
Action.ALERT,
Action.PRINT,
Action.SAVE,
Action.SENDMAIL
};

bool visible = true;
public bool Visible
{
get { return visible; }
set
{
visible = value;
if (visible)
{
Character.Show(Action.GREETING);
timer.Enabled = true;
}
else
{
Character.Hide(Action.GOODBYE);
timer.Enabled = false;
}
}
}

public 助手(ref AxAgentObjects.AxAgent axAgent, string name, string path, bool Visibled)
{
Agent = axAgent;
Name = name;
Path = path;
visible = Visibled;

Agent.Characters.Load(Name, (object)Path);
Character = Agent.Characters[Name];
Character.AutoPopupMenu = false;
Character.Balloon.Style = 3;

Character.Left = (short)(Screen.PrimaryScreen.WorkingArea.Width - 160);
Character.Top = (short)(Screen.PrimaryScreen.WorkingArea.Height - 140);

timer = new Timer();
timer.Interval = 40000;
timer.Tick += new EventHandler(timer_Tick);
timer.Enabled = true;

speakTimer = new Timer();
speakTimer.Interval = 5000;
speakTimer.Tick += new EventHandler(speakTimer_Tick);

if (visible)
{
Character.Show(Action.GREETING);
this.Action = Action.GREETING;
}

}

void speakTimer_Tick(object sender, EventArgs e)
{
if (Character.Balloon.Visible)
{
speakTimer.Enabled = false;
Character.Balloon.Visible = false;
}
}

//随机播放动画
void timer_Tick(object sender, EventArgs e)
{
if (!visible)
return;

this.timer.Enabled = false;

this.Character.Stop(null);

Random rand = new Random();
int number = rand.Next(10000);

this.Action = actions[number % actions.Length];
this.Action = Action.RESTPOSE;
this.timer.Enabled = true;
}

public void Speak(string Text)
{
if (!visible)
return;

this.Character.StopAll(null);
this.Action = Action.RESTPOSE;
this.Character.Speak(Text, "");
timer.Enabled = true;
speakTimer.Enabled = true;
}

public void Think(string Text)
{
if (!visible)
return;

timer.Enabled = false;

this.Character.Think(Text);
timer.Enabled = true;
}

//退出
public void ExitAssistant()
{
this.timer.Enabled = false;
Agent.Characters.Unload(Name);
}
}
}

Fetion.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using NullStudio.Fetion_SDK;
using System.Data.OleDb;
namespace PowerTalkClient
{
public partial class Fetion : Form
{
FrmMain FetionServerTemp = null;
public Fetion()
{
InitializeComponent();
}
public Fetion(FrmMain ftmp)
{
InitializeComponent();
//FetionServerTemp = ftmp;
//FetionServerTemp.PTB_Runner.Text = "运行";
//FetionServerTemp.timer1.Enabled = false;

}


///
/// 登陆飞信
///

private bool FetionLogin(string userName,string pwd)
{
sdk.AccountManager.FillUserIdAndPassword(userName, pwd, false);//第三个参数为是否自动登陆
bool isOk=sdk.AccountManager.Login();//登陆
return isOk;
}

///
/// 发送消息
///

private bool SendFetionMsg(string userName, string msg)
{
bool isOk = false;
try
{
int state = sdk.ContactControl.SendIM.SendIM(userName, msg);
}
catch { isOk = false; }
return isOk;
}


///
/// 发送手机消息
///

private bool SendFetionMobileMsg(string userName, string msg)
{
bool isOk = false;
try
{
int state = sdk.ContactControl.SendSMS.SendSMS(userName, msg);
}
catch { isOk = false; }
return isOk;
}


///
/// 加载好友列表
///

/// 飞信sdk对象
/// 返回飞信好友信息集合
private List GetFetionFriendList(FetionSDK psSdk)
{
List fetionFriends = new List();
try
{
List list = psSdk.ContactControl.getAllContactList();
for (int i = 0; i < list.Count; i++)
{
try
{
FetionFriend fetionFriend = new FetionFriend();//自定义飞信用户实体信息类
fetionFriend.UserId = int.Parse(list[i].Uri.Id);
fetionFriend.Nickname = list[i].DisplayName;
fetionFriend.Mobile = list[i].PersonalInfo.MobileNo;
fetionFriends.Add(fetionFriend);
}
catch { }
}
}
catch { fetionFriends = new List(); }
return fetionFriends;
}
//5^1^a^s^p^x

///
/// 飞信sdk出现错误
///

private void Sdk_SDK_Error(object sender, NullStudio.Fetion_SDK.Event.SDK_ErrorEventArgs fe)
{
this.txtBox.Text += "信息:"+fe.Message.Message+"\r\n";
}
private string userName = "";
private string userPwd = "";
///
/// 当前飞信号状态
///

private void Sdk_SDK_UserSatusChange(object sender, Imps.Client.Core.UserSatusChangedEventArgs e)
{
switch (e.NewStatus.ToString())
{
case "Disconnected"://断开了网络
FetionLogin(userName, userPwd);//重新登陆
break;
case "Initialized"://已初始化

break;
case "Loginning"://登陆中

break;
case "Logon"://已登陆
sdk.AccountManager.CurrentUser.Presence.AsyncChangeMainPresence(Imps.Common.MainPresence.Online, Imps.Common.MainPresence.Online.ToString());//设置PC在线
break;
case "Logoff"://离开网络

break;
case "Logouting"://注销中

break;
case "None"://无状态

break;
case "OfflineLogon"://离线

break;
case "StandBy"://待机

break;
case "WaitReconnect"://等待

break;
}
this.txtBox.Text += "状态"+e.NewStatus.ToString() + "\r\n";
}

///
/// 接收到的消息
///

private void sdk_SDK_ReceiveMessage(object sender, NullStudio.Fetion_SDK.Event.SDK_ReceiveMessageEventArgs fe)
{
string Content = fe.Message.Substring(fe.Message.IndexOf("\r\n")+2);
string[] ContentS = Content.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
int lc=Content.IndexOf(':');
string UserTo=ContentS[0].ToString();
string Msg=Content.Substring(lc+1);
if (Msg[0] == '@')//如果是转移字符串
{
string CChar = Msg.Substring(1);
int topi = 0;
if (int.TryParse(CChar, out topi))//如果为转意数字的话
{
string ListStr = textBox6.Text;
string[] ChangeChar = ListStr.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string istr in ChangeChar)
{
string[] OneChar = istr.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
string One = OneChar[0];
if (CChar == One)
{
Msg = OneChar[1];
}
}
}
}
PowerTalkService.FetionInterFace PTFIF = new PowerTalkClient.PowerTalkService.FetionInterFace();
PTFIF.ChatAdd(textBox3.Text, "游客"+UserTo,Msg);
this.txtBox.Text += "" + string.Format(fe.Message, fe.Contact.PersonalInfo.Nickname +"("+ fe.Contact.Uri.Sid.ToString()+")") + "\r\n";
}
//5*1^a-s-p-x
private FetionSDK sdk = new FetionSDK();//实例化飞信sdk
private void Fetion_Load(object sender, EventArgs e)
{
sdk.SDK_ReceiveMessage += new FetionSDK.SDK_ReceiveMessageEventHandler(sdk_SDK_ReceiveMessage);//消息接收事件
sdk.SDK_UserSatusChange += new FetionSDK.SDK_UserSatusChangedEventHandler(Sdk_SDK_UserSatusChange);//用户状态事件
sdk.SDK_Error += new FetionSDK.SDK_ErrorEventHandler(Sdk_SDK_Error);//sdk错误事件
OleDbConnection Conn = Common.OleSysConn;
Conn.Open();
try
{
OleDbCommand cmd = new OleDbCommand("select * from 系统设置", Conn);
OleDbDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
textBox1.Text= dr["飞信用户名"].ToString();
textBox2.Text = dr["飞信密码"].ToString();
// textBox6.Text = dr["飞信用语"].ToString();
textBox6.Text = "1:您好!\r\n2:有什么可以帮助您的?\r\n3:是的,我们的产品是开源但不免费的。";

}
}
catch
{ }
finally
{
Conn.Close();
}
}

private void button1_Click(object sender, EventArgs e)
{
userName=textBox1.Text;
userPwd = textBox2.Text;
FetionLogin(textBox1.Text, textBox2.Text);
List MyUsers = GetFetionFriendList(sdk);
foreach (FetionFriend MyUser in MyUsers)
{
this.txtBox.Text += MyUser.Mobile+"\r\n";
}
}

private void button2_Click(object sender, EventArgs e)
{
if (checkBox1.Checked)
{ SendFetionMsg(textBox3.Text, textBox4.Text); }
else
{ SendFetionMobileMsg(textBox3.Text, textBox4.Text); }

}



private void button4_Click(object sender, EventArgs e)
{
PowerTalkService.FetionInterFace PTFIF = new PowerTalkClient.PowerTalkService.FetionInterFace();
PowerTalkService.ChatInfo[] LPCI= PTFIF.GetChatInfos(textBox3.Text);
foreach(PowerTalkService.ChatInfo PTSCI in LPCI)
{
this.txtBox.Text += "接收者:" + PTSCI.Reciver + "发送者:" + PTSCI.Sender + "内容:" + PTSCI.SendContent + "\r\n";
SendToMoble(PTSCI.Reciver, PTSCI.Sender, PTSCI.SendContent);
}
}
///
/// 发送操作
///

/// 手机号码
/// 发送者
/// 内容
public void SendToMoble(string MobleNum,string Sender,string Content)
{
if (checkBox1.Checked)
{ SendFetionMsg(MobleNum, Sender + ":" + Content); }
else
{ SendFetionMobileMsg(MobleNum, Sender + ":" + Content); }
}

private void button3_Click(object sender, EventArgs e)
{
if (timer1.Enabled == false)
{
button3.Text = "停止";
this.txtBox.Text += "服务运行";
timer1.Enabled = true;
}
else
{
button3.Text = "运行";
this.txtBox.Text += "服务停止";
timer1.Enabled = false;
}
}

//5^1^a^s^p^x
private void timer1_Tick(object sender, EventArgs e)
{
PowerTalkService.FetionInterFace PTFIF = new PowerTalkClient.PowerTalkService.FetionInterFace();
PowerTalkService.ChatInfo[] LPCI = PTFIF.GetChatInfos(textBox3.Text);
foreach (PowerTalkService.ChatInfo PTSCI in LPCI)
{
this.txtBox.Text += "接收者:" + PTSCI.Reciver + "发送者:" + PTSCI.Sender + "内容:" + PTSCI.SendContent + "\r\n";
PTSCI.SendContent = Common.MatchImg(PTSCI.SendContent);
PTSCI.SendContent = HttpContext.Current.Server.HtmlDecode(PTSCI.SendContent);
SendToMoble(PTSCI.Reciver, PTSCI.Sender, PTSCI.SendContent);
}
}

private void textBox5_TextChanged(object sender, EventArgs e)
{
timer1.Interval =int.Parse(textBox5.Text);
}

private void txtBox_TextChanged(object sender, EventArgs e)
{
if (txtBox.Text.Length > 32767)
{
txtBox.Text = "";
}
}

private void Fetion_FormClosing(object sender, FormClosingEventArgs e)
{

//FetionServerTemp.PTB_Runner.Text = "停止";
//FetionServerTemp.timer1.Enabled = true;
//button3.Text = "运行";
//timer1.Enabled = false;
}



}
public class FetionFriend
{
public int UserId =0;
public string Nickname = "";
public string Mobile = "";

}
}

Fetion.Designer.cs

namespace PowerTalkClient
{
partial class Fetion
{
///
/// 必需的设计器变量。
///

private System.ComponentModel.IContainer components = null;

///
/// 清理所有正在使用的资源。
///

/// 如果应释放托管资源,为 true;否则为 false。
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows 窗体设计器生成的代码

///
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
///

private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Fetion));
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtBox = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.textBox4 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.button4 = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.button3 = new System.Windows.Forms.Button();
this.textBox5 = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.textBox6 = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(92, 93);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(55, 23);
this.button1.TabIndex = 0;
this.button1.Text = "登陆";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(92, 29);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 21);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "15104054261";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(92, 65);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 21);
this.textBox2.TabIndex = 2;
this.textBox2.Text = "1231231";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(8, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(71, 12);
this.label1.TabIndex = 3;
this.label1.Text = "服务手机号:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(9, 71);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(35, 12);
this.label2.TabIndex = 4;
this.label2.Text = "密码:";
//
// txtBox
//
this.txtBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtBox.Location = new System.Drawing.Point(267, 29);
this.txtBox.Multiline = true;
this.txtBox.Name = "txtBox";
this.txtBox.Size = new System.Drawing.Size(345, 315);
this.txtBox.TabIndex = 5;
this.txtBox.TextChanged += new System.EventHandler(this.txtBox_TextChanged);
//
// button2
//
this.button2.Location = new System.Drawing.Point(93, 179);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(69, 23);
this.button2.TabIndex = 6;
this.button2.Text = "发送测试";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(265, 9);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 12);
this.label3.TabIndex = 7;
this.label3.Text = "监视日志";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(92, 125);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(169, 21);
this.textBox3.TabIndex = 8;
this.textBox3.Text = "15898110767";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(8, 128);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(71, 12);
this.label4.TabIndex = 9;
this.label4.Text = "客服手机号:";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(92, 152);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(169, 21);
this.textBox4.TabIndex = 10;
this.textBox4.Text = "测试一下";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(8, 160);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(59, 12);
this.label5.TabIndex = 11;
this.label5.Text = "测试内容:";
//
// button4
//
this.button4.Location = new System.Drawing.Point(168, 180);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(93, 23);
this.button4.TabIndex = 13;
this.button4.Text = "测试网站接收";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(9, 320);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(120, 16);
this.checkBox1.TabIndex = 14;
this.checkBox1.Text = "发送到飞信客户端";
this.checkBox1.UseVisualStyleBackColor = true;
//
// button3
//
this.button3.Font = new System.Drawing.Font("隶书", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button3.Location = new System.Drawing.Point(170, 289);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(90, 47);
this.button3.TabIndex = 15;
this.button3.Text = "运行";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(86, 295);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(76, 21);
this.textBox5.TabIndex = 16;
this.textBox5.Text = "1000";
this.textBox5.TextChanged += new System.EventHandler(this.textBox5_TextChanged);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(8, 298);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(59, 12);
this.label6.TabIndex = 17;
this.label6.Text = "间隔时间:";
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// textBox6
//
this.textBox6.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox6.Location = new System.Drawing.Point(12, 225);
this.textBox6.Multiline = true;
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(248, 58);
this.textBox6.TabIndex = 18;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(12, 210);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(221, 12);
this.label7.TabIndex = 19;
this.label7.Text = "转意列表:(每行一条,手机短信@加序号)";
//
// label8
//
this.label8.AutoSize = true;
this.label8.ForeColor = System.Drawing.Color.Red;
this.label8.Location = new System.Drawing.Point(8, 336);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(149, 12);
this.label8.TabIndex = 20;
this.label8.Text = "注:不勾选,默认发送到手机";
//
// Fetion
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(624, 356);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.textBox6);
this.Controls.Add(this.label6);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.button3);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.button4);
this.Controls.Add(this.label5);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.label4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.label3);
this.Controls.Add(this.button2);
this.Controls.Add(this.txtBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Fetion";
this.Text = "PowerTalk接收飞信客服服务器";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Fetion_FormClosing);
this.Load += new System.EventHandler(this.Fetion_Load);
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtBox;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.TextBox textBox6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
}
}

FrmClientAdd.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace PowerTalkClient
{
public partial class FrmClientAdd : Form
{
public string ModID = "";
public FrmClientAdd()
{
InitializeComponent();
}
public bool Mod = false;
///
/// 修改保存
///

///
public FrmClientAdd(string Id)
{
InitializeComponent();
ModID = Id;
Mod = true;
AddOrSave.Text = "更新";
OleDbConnection Conn = Common.OleSysConn;
Conn.Open();
try
{
OleDbCommand Cmd = new OleDbCommand("select * from 客户信息", Conn);
OleDbDataReader dr = Cmd.ExecuteReader();
if (dr.Read())
{
xingming_textBox.Text = dr["姓名"].ToString();
nicheng_textBox.Text = dr["昵称"].ToString();
xingbie_comboBox.Text = dr["性别"].ToString();
gudingdianhua_textbox.Text = dr["固定电话"].ToString();
shoujihaoma_textbox.Text = dr["手机号码"].ToString();
Email_textBox.Text = dr["Email"].ToString();
QQ_textBox.Text = dr["QQ"].ToString();
MSN_textBox.Text = dr["MSN"].ToString();
gongsi_textBox.Text = dr["公司"].ToString();
dizhi_textBox.Text = dr["地址"].ToString();
wangzhi_textBox.Text = dr["网址"].ToString();
yixiang_comboBox.Text = dr["分类"].ToString();
xiangxidizhi_textbox.Text = dr["详细地址"].ToString();
dengluIP_textBox.Text = dr["登录IP"].ToString();
dingyue_checkBox.Checked = bool.Parse(dr["订阅与否"].ToString());
beizhu_textBox.Text = dr["备注"].ToString();
}
}
catch
{ }
finally { Conn.Close(); }
}
///
/// 添加
///

public FrmClientAdd(string xingmingstr,string ipstr,string xiangxidizhistr)
{
InitializeComponent();
nicheng_textBox.Text = xingmingstr;
dengluIP_textBox.Text = ipstr;
xiangxidizhi_textbox.Text = xiangxidizhistr;
}

//5#1#a#s#p#x
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
this.Close();
}

private void AddOrSave_Click(object sender, EventArgs e)
{
if (!Mod)
{
OleDbConnection conn = Common.OleSysConn;
conn.Open();
OleDbCommand cmd = new OleDbCommand();
try
{
string SqlStr = "insert into 客户信息(姓名,昵称,性别,固定电话,手机号码,Email,QQ,MSN,公司,地址,网址,分类,详细地址,登录IP,订阅与否,备注) ";
SqlStr += "values('" + xingming_textBox.Text + "','" + nicheng_textBox.Text + "','" + xingbie_comboBox.Text + "','" + gudingdianhua_textbox.Text + "','" + shoujihaoma_textbox.Text + "','" + Email_textBox.Text + "','" + QQ_textBox.Text + "','" + MSN_textBox.Text + "','" + gongsi_textBox.Text + "','" + dizhi_textBox.Text + "','" + wangzhi_textBox.Text + "','" + yixiang_comboBox.Text + "','" + xiangxidizhi_textbox.Text + "','" + dengluIP_textBox.Text + "','" + dingyue_checkBox.Checked.ToString() + "','" + beizhu_textBox.Text + "')";
cmd.Connection = conn;
cmd.CommandText = SqlStr;
cmd.ExecuteNonQuery();
MessageBox.Show("添加成功!");
}
catch (Exception exp)
{
MessageBox.Show("添加失败!" + exp.Message);
}
finally
{
conn.Close();
}
}
else
{
OleDbConnection conn = Common.OleSysConn;
conn.Open();
OleDbCommand cmd = new OleDbCommand();
try
{
string SqlStr = "update 客户信息 set 姓名='" + xingming_textBox.Text + "',昵称='" + nicheng_textBox.Text + "',性别='" + xingbie_comboBox.Text + "',固定电话='" + gudingdianhua_textbox.Text + "',手机号码='" + shoujihaoma_textbox.Text + "',Email='" + Email_textBox.Text + "',QQ='" + QQ_textBox.Text + "',MSN='" + MSN_textBox.Text + "',公司='" + gongsi_textBox.Text + "',地址='" + dizhi_textBox.Text + "',网址='" + wangzhi_textBox.Text + "',分类='" + yixiang_comboBox.Text + "',详细地址='" + xiangxidizhi_textbox.Text + "',登录IP='" + dengluIP_textBox.Text + "',订阅与否='" + dingyue_checkBox.Checked.ToString() + "',备注='" + beizhu_textBox.Text + "' where ID=" + ModID;

cmd.Connection = conn;
cmd.CommandText = SqlStr;
cmd.ExecuteNonQuery();
MessageBox.Show("修改成功!");
}
catch (Exception exp)
{
MessageBox.Show("修改失败!" + exp.Message);
}
finally
{
conn.Close();
}
}
this.Close();
}

private void FrmClientAdd_Load(object sender, EventArgs e)
{

}
}
}

/////////////////////////5///1///a///s///p///x//////////////////////////////