private static string createTag(string tagName) { Tag us = new Tag(); us.tagname = tagName; string data = MyUtility.GetJsonFromObj(us); string accss = MyUtility.GetGroupAccess(); RequestContainer req = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/tag/create?access_token=" + accss); req.RequestObj.Method = "POST"; req.RequestObj.ContentType = "application/Json"; req.SetRequestContent(data); HttpWebResponse rep = req.GetResponse(); string x = req.GetResponseContent(rep); dynamic dy = MyUtility.GetObjFromJson <dynamic>(x); if (dy.errcode == 0) { return(dy.tagid); } else { return(""); } }
private static string Create_Par(string Name, string pid) { Department us = new Department(); us.name = Name; us.parentid = pid; string data = MyUtility.GetJsonFromObj(us); string accss = MyUtility.GetGroupAccess(); RequestContainer req = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/department/create?access_token=" + accss); req.RequestObj.Method = "POST"; req.RequestObj.ContentType = "application/Json"; req.SetRequestContent(data); HttpWebResponse rep = req.GetResponse(); string x = req.GetResponseContent(rep); dynamic dy = MyUtility.GetObjFromJson <dynamic>(x); if (dy.errcode == 0) { return(dy.id); } else { return("false"); } }
private static MessageApi Create_Usr(string depId, string Name, string userId, string mobile) { MessageApi mm = new MessageApi(); User us = new User(); us.department = depId; us.name = Name; us.userid = userId; us.mobile = mobile; string data = MyUtility.GetJsonFromObj(us); string accss = MyUtility.GetGroupAccess(); RequestContainer req = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token=" + accss); req.RequestObj.Method = "POST"; req.RequestObj.ContentType = "application/Json"; req.SetRequestContent(data); HttpWebResponse rep = req.GetResponse(); string x = req.GetResponseContent(rep); dynamic dy = MyUtility.GetObjFromJson <dynamic>(x); if (dy.errcode == 0) { mm.code = "0"; mm.txt = ""; return(mm); } else { mm.code = "404"; mm.txt = dy.errmsg; return(mm); } }
private static MessageApi createUser(string depId, string Name, string userId, string mobile) { MessageApi mm = new MessageApi(); User us = new User(); Regex reg = new Regex(@"^[1]+\d{10}"); if (depId == "" || Name == "" || userId == "") { mm.code = "404"; mm.txt = "用户信息不完善"; return(mm); } else if (!reg.IsMatch(userId)) { mm.code = "404"; mm.txt = "Id要11位电话号码"; return(mm); } else { if (Exist_Usr(userId)) { us.department = depId; us.name = Name; us.userid = userId; us.mobile = mobile; string data = MyUtility.GetJsonFromObj(us); string accss = MyUtility.GetGroupAccess(); RequestContainer req = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token=" + accss); req.RequestObj.Method = "POST"; req.RequestObj.ContentType = "application/Json"; req.SetRequestContent(data); HttpWebResponse rep = req.GetResponse(); string x = req.GetResponseContent(rep); dynamic dy = MyUtility.GetObjFromJson <dynamic>(x); if (dy.errcode == 0) { mm.code = "0"; mm.txt = ""; return(mm); } else { mm.code = "404"; mm.txt = dy.errmsg; return(mm); } } else { mm = Create_Usr(depId, Name, userId, mobile); return(mm); } } }
private static List <Tag> get_TagList() { string accss = MyUtility.GetGroupAccess(); RequestContainer req = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/tag/list?access_token=" + accss); HttpWebResponse rep = req.GetResponse(); string a = req.GetResponseContent(rep); List <Tag> tt = new List <Tag>(); string json = Convert.ToString(MyUtility.GetObjFromJson <dynamic>(a).taglist); tt = MyUtility.GetObjFromJson <List <Tag> >(json); return(tt); }
private static List <Department> getTree() { string accss = MyUtility.GetGroupAccess(); RequestContainer req = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=" + accss); HttpWebResponse rep = req.GetResponse(); string a = req.GetResponseContent(rep); string dy = Convert.ToString(MyUtility.GetObjFromJson <dynamic>(a).department); List <Department> department = new List <Department>(); department = MyUtility.GetObjFromJson <List <Department> >(dy); //for (int i = 0; i <= dy.department.Count; i++) { //} return(department); }
private static void createUser_tag(string tagId, string UserId) { UserTag us = new UserTag(); us.tagid = tagId; us.userlist.Add(UserId); string data = MyUtility.GetJsonFromObj(us); string accss = MyUtility.GetGroupAccess(); RequestContainer req = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/tag/addtagusers?access_token=" + accss); req.RequestObj.Method = "POST"; req.RequestObj.ContentType = "application/Json"; req.SetRequestContent(data); HttpWebResponse rep = req.GetResponse(); string x = req.GetResponseContent(rep); }
private static bool Exist_Usr(string userid) { string accss = MyUtility.GetGroupAccess(); RequestContainer req = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=" + accss + "&userid=" + userid); HttpWebResponse rep = req.GetResponse(); string a = req.GetResponseContent(rep); dynamic dy = MyUtility.GetObjFromJson <dynamic>(a); if (dy.errcode == 0) { return(true); } else { return(false); } }
private static string getUser(string id) { string accss = MyUtility.GetGroupAccess(); RequestContainer req = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=" + accss + "&department_id=" + id + "&fetch_child=1"); HttpWebResponse rep = req.GetResponse(); string a = req.GetResponseContent(rep); dynamic dy = MyUtility.GetObjFromJson <dynamic>(a); List <Customer> userlist = new List <Customer>(); for (int i = 0; i < dy.userlist.Count; i++) { Customer mm = new Customer(); mm.userid = dy.userlist[i].userid; mm.status = dy.userlist[i].status; mm.name = dy.userlist[i].name; mm.mobile = dy.userlist[i].mobile; userlist.Add(mm); } return(MyUtility.GetJsonFromObj(userlist)); }
private static string GetOnlyUser(string id) { string ls = ""; string accss = MyUtility.GetGroupAccess(); RequestContainer req = new RequestContainer("https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=" + accss + "&userid=" + id); HttpWebResponse rep = req.GetResponse(); string a = req.GetResponseContent(rep); dynamic dy = MyUtility.GetObjFromJson <dynamic>(a); if (dy.errcode == 0) { ls = Convert.ToString(dy.status); } else { ls = "3"; } //List<Customer> userlist = new List<Customer>(); //Customer mm = new Customer(); //mm.status = dy.userlist[i].status; //userlist.Add(mm); return(ls); }