Example #1
0
        public IHttpActionResult WxCode(string Code, string state)
        {
            WxCode wxCode = new WxCode();

            wxCode.code  = Code;
            wxCode.state = state;
            SimpleResult result = new SimpleResult();

            result.Status   = Result.SUCCEED;
            result.Resource = wxCode;
            return(Json(result));
        }
Example #2
0
        public WxCode CretaeWxCode()
        {
            var responseData = new WxCode();

            responseData.success = false;
            responseData.msg     = "二维码生成失败!";
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            try
            {
                //微信 公共平台
                var wapentity = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity
                {
                    CustomerId = loggingSessionInfo.ClientID,
                    IsDelete   = 0
                }, null).FirstOrDefault();

                //获取当前二维码 最大值
                var MaxWQRCod = new WQRCodeManagerBLL(loggingSessionInfo).GetMaxWQRCod() + 1;

                if (wapentity == null)
                {
                    responseData.success = false;
                    responseData.msg     = "无设置微信公众平台!";
                    return(responseData);
                }

                string imageUrl = string.Empty;

                #region 生成二维码
                JIT.CPOS.BS.BLL.WX.CommonBLL commonServer = new JIT.CPOS.BS.BLL.WX.CommonBLL();
                try
                {
                    imageUrl = commonServer.GetQrcodeUrl(wapentity.AppID.ToString().Trim()
                                                         , wapentity.AppSecret.Trim()
                                                         , "1", MaxWQRCod
                                                         , loggingSessionInfo);
                }
                catch (Exception e)
                {
                    responseData.success = false;
                    responseData.msg     = e.Message;// "二维码生成失败!";
                    return(responseData);
                }

                if (!string.IsNullOrEmpty(imageUrl))
                {
                    string host = ConfigurationManager.AppSettings["DownloadImageUrl"];
                    CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                    imageUrl = downloadServer.DownloadFile(imageUrl, host);
                }
                #endregion
                responseData.success   = true;
                responseData.msg       = "";
                responseData.ImageUrl  = imageUrl;
                responseData.MaxWQRCod = MaxWQRCod;


                return(responseData);
            }
            catch (Exception ex)
            {
                //throw new APIException(ex.Message);
                return(responseData);
            }
        }