using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace HuizhongLibrary.Weixin { public class WeixinUser { public string userid { get; set; } public string name { get; set; } public List department { get; set; } public string position { get; set; } public string mobile { get; set; } public string gender { get; set; } public string email { get; set; } public string weixinid { get; set; } public string avatar_mediaid { get; set; } public int enable { get; set; } public List extattr { get; set; } public WeixinUser() { department = new List(); extattr = new List(); enable = -1; } public string ToJsonString() { StringBuilder sb = new StringBuilder(); sb.Append("{"); sb.Append("\"userid\":\"" + this.userid + "\","); if (string.IsNullOrEmpty(name)==false) sb.Append("\"name\":\"" + this.name + "\","); if (department.Count > 0) { sb.Append("\"department\":["); foreach (int item in department) { sb.Append(item); int index = department.IndexOf(item); if (index < department.Count-1) sb.Append(","); } sb.Append("],"); } if (string.IsNullOrEmpty(position) == false) sb.Append("\"position\":\"" + this.position + "\","); if (string.IsNullOrEmpty(mobile) == false) sb.Append("\"mobile\":\"" + this.mobile + "\","); if (string.IsNullOrEmpty(gender) == false) sb.Append("\"gender\":\"" + this.gender + "\","); if (string.IsNullOrEmpty(email) == false) sb.Append("\"email\":\"" + this.email + "\","); if (string.IsNullOrEmpty(weixinid) == false) sb.Append("\"weixinid\":\"" + this.weixinid + "\","); if (this.enable>=0) sb.Append("\"enable\":" + this.enable + ","); if (string.IsNullOrEmpty(avatar_mediaid) == false) sb.Append("\"avatar_mediaid\":\"" + this.avatar_mediaid + "\","); if (extattr.Count > 0) { sb.Append("\"extattr\": {\"attrs\":"); sb.Append("["); foreach (var item in extattr) { sb.Append(item.ToJsonString()); int index = extattr.IndexOf(item); if (index < extattr.Count-1) sb.Append(","); } sb.Append("]"); sb.Append("}"); sb.Append("}"); return sb.ToString(); } else { string s = sb.ToString(); s = s.Remove(s.Length-1); s += "}"; return s; } } } public class WeixinAttr { public string name { get; set; } public string value { get; set; } public string ToJsonString() { StringBuilder sb = new StringBuilder(); sb.Append("{"); sb.Append("\"name\":\"" + this.name + "\","); sb.Append("\"value\":\"" + this.value + "\""); sb.Append("}"); return sb.ToString(); } } public class WeixinUserResult : WeixinResult { public string UserId { get; set; } public string DeviceId { get; set; } public string OpenId { get; set; } public string user_ticket { get; set; } public string expires_in { get; set; } } public class WeixinUserResult2 { public string openid { get; set; } public string sex { get; set; } public string nickname { get; set; } public string province { get; set; } public string city { get; set; } public string country { get; set; } public string unionid { get; set; } public string headimgurl { get; set; } public int errcode { get; set; } public string errmsg { get; set; } } public class WeixinPayOddResult { public string error { get; set; } public string timeStamp { get; set; } public string nonceStr { get; set; } public string package { get; set; } public string paySign { get; set; } } }