Ejemplo n.º 1
0
        public void AddCustomTest()
        {
            // var accessToken = AccessTokenContainer.GetAccessToken(_appId);
            var result = CustomServiceApi.AddCustom(_appId, _appSecret, "zcc@InnocellenceRobot", "zcc", _custonPassWord);

            Assert.AreEqual(result.errcode, ReturnCode.请求成功);
        }
Ejemplo n.º 2
0
        public void AddCustomTest()
        {
            var accessToken = AccessTokenContainer.GetAccessToken(_appId);
            var result      = CustomServiceApi.AddCustom(accessToken, "zcc@SenparcRobot", "zcc", _custonPassWord);

            Assert.AreEqual(result.errcode, ReturnCode.请求成功);
        }
Ejemplo n.º 3
0
 public ActionResult Add(AddCustomViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     try
     {
         var result = CustomServiceApi.AddCustom(
             WeChatConfigManager.Current.GetAccessToken(),
             string.Format("{0}@{1}", model.Account, WeChatConfigManager.Current.GetConfig().WeiXinAccount),
             model.NickName,
             model.Password);
         if (result.errcode != ReturnCode.请求成功)
         {
             ViewBag.Messages = new List <MessageInfo>
             {
                 new MessageInfo
                 {
                     Message     = result.errmsg,
                     MessageType = MessageTypes.Danger
                 }
             };
             return(View(model));
         }
         var kf = new WeiChat_KFCInfo
         {
             Account    = string.Format("{0}@{1}", model.Account, WeChatConfigManager.Current.GetConfig().WeiXinAccount),
             HeadImgUrl = "",
             NickName   = model.NickName
         };
         db.WeiChat_KFCInfos.Add(kf);
         db.SaveChanges();
     }
     catch (ErrorJsonResultException ex)
     {
         if (ex.JsonResult.errcode == ReturnCode.客服帐号已存在kf_account_exsited)
         {
             ViewBag.Messages = new List <MessageInfo>
             {
                 new MessageInfo
                 {
                     Message     = "客服账号已存在!",
                     MessageType = MessageTypes.Danger
                 }
             };
             return(View(model));
         }
         if (ex.JsonResult.errcode == ReturnCode.客服帐号个数超过限制)
         {
             ViewBag.Messages = new List <MessageInfo>
             {
                 new MessageInfo
                 {
                     Message     = "客服帐号个数超过限制!",
                     MessageType = MessageTypes.Danger
                 }
             };
             return(View(model));
         }
     }
     return(RedirectToAction("Index"));
 }