コード例 #1
0
        /// <summary>
        /// 获取用户基本信息
        /// </summary>


        private bool RefreshAccessToken(MpResponse res, string accesstoken)
        {
            if (res.IsError && res.ErrInfo.ErrCode == 40001)//invalid credential
            {
                LogHelper.WriteDebug(LogModule, "accesstoken expired:" + accesstoken);
                GetAccessToken(accesstoken);
                return(true);
            }
            return(false);
        }
コード例 #2
0
        public MpResponse GetOpportunityResponse(int opportunityId, int eventId, MpParticipant participant)
        {
            var searchString = string.Format(",{0},{1},{2}", opportunityId, eventId, participant.ParticipantId);
            List <Dictionary <string, object> > dictionaryList;

            try
            {
                dictionaryList =
                    WithApiLogin(
                        apiToken =>
                        (_ministryPlatformService.GetPageViewRecords("ResponseByOpportunityAndEvent",
                                                                     apiToken,
                                                                     searchString,
                                                                     "",
                                                                     0)));
            }
            catch (Exception ex)
            {
                throw new ApplicationException(
                          string.Format(
                              "GetOpportunityResponse failed.  Participant Id: {0}, Opportunity Id: {1}, Event Id: {2}",
                              participant,
                              opportunityId,
                              eventId),
                          ex.InnerException);
            }

            if (dictionaryList.Count == 0)
            {
                return(new MpResponse());
            }

            var response = new MpResponse();

            try
            {
                var dictionary = dictionaryList.First();
                response.Response_ID        = dictionary.ToInt("dp_RecordID");
                response.Opportunity_ID     = dictionary.ToInt("Opportunity_ID");
                response.Participant_ID     = dictionary.ToInt("Participant_ID");
                response.Response_Result_ID = dictionary.ToInt("Response_Result_ID");
            }
            catch (InvalidOperationException ex)
            {
                throw new ApplicationException(
                          string.Format("RespondToOpportunity failed.  Participant Id: {0}, Opportunity Id: {1}",
                                        participant,
                                        opportunityId),
                          ex.InnerException);
            }


            return(response);
        }
コード例 #3
0
        public void TextReturnMessage(ReceiveMessageBase receiveMessageBase)
        {
            IMpClient mpClient = new MpClient();
            //有效性校验
            var request = new AccessTokenGetRequest()
            {
                AppIdInfo = new AppIdInfo()
                {
                    AppId = AppId, AppSecret = AppSecret
                }
            };
            var response = mpClient.Execute(request);

            if (response.IsError)
            {
                HttpContext.Current.Response.Write("获取令牌环失败..");
            }
            MpResponse send = MessageHandler.SendTextCustomMessage(response.AccessToken.AccessToken, receiveMessageBase.FromUserName, "http://wuhanallview.ticp.net");

            Logger.WriteTxtLog(send.Body, "D:/Log20160802.txt");
            HttpContext.Current.Response.Write(send.Body.ToString());
        }
コード例 #4
0
        public MpResponse GetOpportunityResponse(int contactId, int opportunityId)
        {
            var searchString       = ",,,," + contactId;
            var subpageViewRecords = _ministryPlatformService.GetSubpageViewRecords(_contactOpportunityResponses,
                                                                                    opportunityId,
                                                                                    ApiLogin(),
                                                                                    searchString);
            var record = subpageViewRecords.ToList().FirstOrDefault();

            if (record == null)
            {
                return(null);
            }

            var response = new MpResponse();

            response.Response_ID        = record.ToInt("dp_RecordID");
            response.Opportunity_ID     = record.ToInt("Opportunity ID");
            response.Participant_ID     = record.ToInt("Participant ID");
            response.Response_Date      = record.ToDate("Response Date");
            response.Response_Result_ID = record.ToNullableInt("Response Result ID");
            return(response);
        }
コード例 #5
0
        public MpResponse GetMyOpportunityResponses(int contactId, int opportunityId)
        {
            var searchString       = ",,,," + contactId;
            var subpageViewRecords = MinistryPlatformService.GetSubpageViewRecords(_contactOpportunityResponses,
                                                                                   opportunityId,
                                                                                   ApiLogin(),
                                                                                   searchString);
            var list = subpageViewRecords.ToList();
            var s    = list.SingleOrDefault();

            if (s == null)
            {
                return(null);
            }
            var response = new MpResponse
            {
                Opportunity_ID     = (int)s["Opportunity ID"],
                Participant_ID     = (int)s["Participant ID"],
                Response_Date      = (DateTime)s["Response Date"],
                Response_Result_ID = (int?)s["Response Result ID"]
            };

            return(response);
        }