public JsonResult DownloadContact(Guid sid)
 {
     IWXContactsService srv = new WXContactsService();
     Simulator smr = new Simulator();
     List<Contact> cntList = smr.GetWxContacts(sid);
     foreach (Contact cnt in cntList)
     {
         IEnumerable<WX_Contacts> temp = srv.FindByConditions(null, f => f.AccountId == sid && f.fake_id == cnt.id);
         if (temp != null && temp.Count() > 0)
         {
             //更新
             //WX_Contacts tempCnt = temp.FirstOrDefault();
             //tempCnt.nick_name = cnt.nick_name;
             //tempCnt.city = cnt.city;
             //tempCnt.province = cnt.province;
             //tempCnt.signature = cnt.signature;
             //tempCnt.country = cnt.country;
             //tempCnt.remark_name = cnt.remark_name;
             //srv.Update(tempCnt);
             continue;
         }
         //新增
         WX_Contacts tempNewCnt = new WX_Contacts();
         tempNewCnt.fake_id = cnt.id;
         tempNewCnt.nick_name = cnt.nick_name;
         tempNewCnt.city = cnt.city;
         tempNewCnt.province = cnt.province;
         tempNewCnt.signature = cnt.signature;
         tempNewCnt.country = cnt.country;
         tempNewCnt.remark_name = cnt.remark_name;
         tempNewCnt.AccountId = sid;
         tempNewCnt.groupName = cnt.group;
         srv.Insert(tempNewCnt);
     }
     return Json(ResultMsg.Success("微信账号同步已完成!共计:" + cntList.Count.ToString() + "条"));
 }
 public void ContactHeadImg(Guid sid, long fakeId)
 {
     Simulator smr = new Simulator();
     Bitmap myImage = new Bitmap(smr.GetHeadImg(sid, fakeId));
     MemoryStream ms = new MemoryStream();
     myImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
     Response.ClearContent();
     Response.ContentType = "image/Jpeg";
     Response.BinaryWrite(ms.ToArray());
 }
 public JsonResult SendMsg(Guid sid, long[] fakeIds, string msg)
 {
     Simulator smr = new Simulator();
     int success = 0;
     foreach (long id in fakeIds)
     {
         if (smr.SendMsg(sid, id, Server.UrlEncode(msg)))
             success++;
     }
     return Json(ResultMsg.Success("消息发送成功!共计:"+success.ToString()+"条"));
 }
        public JsonResult ContactsDetail(Guid sid, long fakeId)
        {
            Simulator smr = new Simulator();
            Contact cnt = smr.GetContactDetail(sid, fakeId);

            IWXContactsService srv = new WXContactsService();
            IEnumerable<WX_Contacts> temp = srv.FindByConditions(null, f => f.AccountId == sid && f.fake_id == fakeId);
            if (temp != null && temp.Count() > 0)
            {
                //更新
                WX_Contacts tempCnt = temp.FirstOrDefault();
                tempCnt.nick_name = cnt.nick_name;
                tempCnt.city = cnt.city;
                tempCnt.province = cnt.province;
                tempCnt.signature = cnt.signature;
                tempCnt.country = cnt.country;
                tempCnt.remark_name = cnt.remark_name;
                srv.Update(tempCnt);
            }
            return Json(cnt);
        }