Пример #1
0
        /// <summary>
        /// 活动报名表数据提交
        /// </summary>
        public string submitEventApply()
        {
            string ReqContent = string.Empty;
            string content    = string.Empty;
            var    respObj    = new submitEventApplyRespData();
            string respStr    = string.Empty;

            try
            {
                ReqContent = Request["Form"];

                //ReqContent = HttpUtility.HtmlDecode(ReqContent);
                var reqContentObj = ReqContent.DeserializeJSONTo <submitEventApplyReqData>();

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format(
                        "submitEventApply ReqContent:{0}",
                        ReqContent)
                });

                var service = new QuestionnaireBLL(Default.GetLoggingSession());

                // WEventUserMappingEntity
                //WEventUserMappingEntity userMappingEntity = new WEventUserMappingEntity();
                //userMappingEntity.UserName = reqContentObj.special.userName;
                //userMappingEntity.Mobile = reqContentObj.special.mobile;
                //userMappingEntity.Email = reqContentObj.special.email;

                // quesAnswerList
                IList <QuesAnswerEntity> quesAnswerList = new List <QuesAnswerEntity>();
                if (reqContentObj.special.questions != null)
                {
                    foreach (var question in reqContentObj.special.questions)
                    {
                        QuesAnswerEntity quesAnswerEntity = new QuesAnswerEntity();
                        quesAnswerEntity.QuestionID    = question.questionId;
                        quesAnswerEntity.QuestionValue = question.questionValue;
                        quesAnswerList.Add(quesAnswerEntity);
                    }
                }

                string userId = reqContentObj.common.userId;
                if (userId == null || userId.Trim().Length == 0)
                {
                    userId = "1";
                }
                //Jermyn20130621 判断特殊的openId=123456,作为公众平台编辑模式进来的判断逻辑
                if (reqContentObj.common.openId.Equals("123456") || reqContentObj.common.openId.Equals("111"))
                {
                    reqContentObj.common.openId = System.Guid.NewGuid().ToString().Replace("-", "");
                }
                if (reqContentObj.special.userName == null || reqContentObj.special.userName.Trim().Length == 0)
                {
                    reqContentObj.special.userName = System.Guid.NewGuid().ToString().Replace("-", "");
                }
                GetResponseParams <bool> returnDataObj = service.WEventSubmitEventApply(
                    reqContentObj.common.openId,
                    reqContentObj.special.eventId,
                    userId,
                    //userMappingEntity,
                    quesAnswerList, reqContentObj.special.userName);

                respObj.Code        = returnDataObj.Code;
                respObj.Description = returnDataObj.Description;

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format(
                        "submitEventApply RespContent:{0}",
                        respObj.ToJSON())
                });

                #region 推送消息

                string msgUrl  = ConfigurationManager.AppSettings["push_weixin_msg_url"].Trim();
                string msgText = "感谢您积极参与我们的活动。";
                string msgData = "<xml><OpenID><![CDATA[" + reqContentObj.common.openId + "]]></OpenID><Content><![CDATA[" + msgText + "]]></Content></xml>";

                var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData);

                #endregion
            }
            catch (Exception ex)
            {
                respObj.Code        = "103";
                respObj.Description = "数据库操作错误";
                respObj.Exception   = ex.ToString();
            }
            content = respObj.ToJSON();
            return(content);
        }