コード例 #1
0
        public ResultObject <JOMedia> GetNewsMeterialFromWX(int pageIndex = 0, int pageSize = 20)
        {
            ResultObject <JOMedia> result = new ResultObject <JOMedia>();

            try
            {
                string          access_token = WXApi.getAccessToken().access_token;
                string          wxUrl        = $"https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token={access_token}";
                MaterialList_In paremeter    = new MaterialList_In
                {
                    type   = "news",
                    offset = pageIndex * pageSize,
                    count  = pageSize,
                };
                var    json = JsonConvert.SerializeObject(paremeter);
                string data = HttpHelper.RequestUrlSendMsg(wxUrl, HttpHelper.HttpMethod.Post, json);


                result.Entity = JsonConvert.DeserializeObject <JOMedia>(data);
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }
            return(result);
        }
コード例 #2
0
        public void OnPostTestDb()
        {
            //// DbTest = "Done";
            //// DbTest =  EduCodeGenerator.GetTecCode(1);
            ////// _context.DBCourseInfo.Count(a=>a.RecordStatus=1)
            //    DbTest =  $"{_context.DBCourseInfo("select count(1) from CourseInfo")}";

            WXApi.getAccessToken();
        }
コード例 #3
0
        public ResultObject <AccessToken> getMiniAccessToken()
        {
            ResultObject <AccessToken> result = new ResultObject <AccessToken>();

            try
            {
                result.Entity = WXApi.getAccessToken(EduConfig.WXAppId, EduConfig.WXSecret);
                result.Entity.expire_DateTime = DateTime.Now.AddSeconds(7200);
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }
            return(result);
        }
コード例 #4
0
ファイル: SalesSrv.cs プロジェクト: flysnoopy1984/EduCenter
        public bool GenQRInvite(string openId, string phone, string headerUrl)
        {
            var qr = _dbContext.DBQRInvite.Where(a => a.UserOpenId == openId &&
                                                 a.InviteQRType == InviteQRType.UserInvite).FirstOrDefault();

            if (qr != null)
            {
                throw new EduException("不能重复创建邀请码");
            }
            string qrDownFilePath     = EduEnviroment.GetQRInviteUserFilePath($"OrigUserInvite_{phone}.png");
            string qrWithLogoFilePath = EduEnviroment.GetQRInviteUserFilePath($"UserInviteWithLogo_{phone}.png");
            string bkFilePath         = EduEnviroment.GetQRFilePath("InviteBK.png");
            string finalFilePath      = EduEnviroment.GetQRInviteUserFilePath($"FinalUserInvite_{phone}.png");

            AccessToken accessToken = WXApi.getAccessToken();
            WXQRResult  result      = WXApi.getQR(WxConfig.QR_Invite_User + "_" + openId, accessToken.access_token);

            WXApi.DownLoadWXQR(result.ticket, qrDownFilePath);

            //添加Logo ,且添加文字
            List <string> text = new List <string>();

            text.Add("您的朋友邀请您加入云艺书院");
            QRHelper.AddLogoForQR(headerUrl, new Bitmap(qrDownFilePath), qrWithLogoFilePath, text);


            //添加背景
            QRHelper.AddBKForQR(bkFilePath, qrWithLogoFilePath, finalFilePath);

            qr = new EQRInvite()
            {
                OrigFilePath     = EduEnviroment.VirPath_QRInviteUser + $"OrigUserInvite_{phone}.png",
                FileWithLogoPath = EduEnviroment.VirPath_QRInviteUser + $"UserInviteWithLogo_{phone}.png",
                FinalFilePath    = EduEnviroment.VirPath_QRInviteUser + $"FinalUserInvite_{phone}.png",
                InviteQRType     = InviteQRType.UserInvite,
                RecordStatus     = RecordStatus.Normal,

                TargetUrl      = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result.ticket + "",
                CreateDateTime = DateTime.Now,
                UserOpenId     = openId
            };
            _dbContext.DBQRInvite.Add(qr);
            _dbContext.SaveChanges();


            return(true);
        }
コード例 #5
0
        public void OnPostCreateTecQR()
        {
            Msg = "创建成功!";

            string qrDownFilePath = EduEnviroment.GetQRInviteTecFilePath("WXInvite.png");
            string bkFilePath     = EduEnviroment.GetQRFilePath("InviteBK.png");
            string finalFilePath  = EduEnviroment.GetQRInviteTecFilePath("EduTecInvite.png");

            try
            {
                AccessToken accessToken = WXApi.getAccessToken();
                WXQRResult  result      = WXApi.getQR(WxConfig.QR_Invite_TecPre, accessToken.access_token);
                WXApi.DownLoadWXQR(result.ticket, qrDownFilePath);


                QRHelper.AddBKForQR(bkFilePath, qrDownFilePath, finalFilePath);
            }
            catch (Exception ex)
            {
                Msg = ex.Message;
            }
        }
コード例 #6
0
        public IActionResult OnPostCreateMenu()
        {
            ResultNormal result = new ResultNormal();

            try
            {
                string access_token = WXApi.getAccessToken().access_token;
                string posturl      = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + access_token;
                string menuStr      = "";// " 菜单结构";
                using (StreamReader sr = new StreamReader(EduEnviroment.Menus_JsonFilePath))
                {
                    menuStr = sr.ReadToEnd();
                }
                result.SuccessMsg = HttpHelper.RequestUrlSendMsg(posturl, HttpHelper.HttpMethod.Post, menuStr, "application/json");
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
                //  throw ex;
            }
            return(new JsonResult(result));
        }
コード例 #7
0
        public void OnPostGetPicMeterial()
        {
            try
            {
                string          access_token = WXApi.getAccessToken().access_token;
                string          wxUrl        = $"https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token={access_token}";
                MaterialList_In paremeter    = new MaterialList_In
                {
                    type   = "image",
                    offset = 0,
                    count  = 20,
                };
                var    json = JsonConvert.SerializeObject(paremeter);
                string data = HttpHelper.RequestUrlSendMsg(wxUrl, HttpHelper.HttpMethod.Post, json);


                PicMedia = JsonConvert.DeserializeObject <JOMedia>(data);
            }
            catch (Exception ex)
            {
                Msg = ex.Message;
            }
        }
コード例 #8
0
ファイル: SyncWXNews.cs プロジェクト: flysnoopy1984/EduCenter
        private JOMedia QueryNews()
        {
            if (_pageIndex * 20 >= _NewsTotalItems && _NewsTotalItems != -1)
            {
                return(null);
            }

            string          access_token = WXApi.getAccessToken().access_token;
            string          wxUrl        = $"https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token={access_token}";
            MaterialList_In paremeter    = new MaterialList_In
            {
                type   = "news",
                offset = _pageIndex * 20,
                count  = 20,
            };
            var    json = JsonConvert.SerializeObject(paremeter);
            string data = HttpHelper.RequestUrlSendMsg(wxUrl, HttpHelper.HttpMethod.Post, json);


            var JOMedia = JsonConvert.DeserializeObject <JOMedia>(data);

            _NewsTotalItems = Convert.ToInt32(JOMedia.total_count);
            return(JOMedia);
        }