/// <summary> /// 根据微信的固定二维码获取活动信息 /// </summary> /// <param name="wxCode"></param> /// <returns></returns> public LEventsEntity GetEventInfoByWX(string wxCode) { DataSet ds = new DataSet(); LEventsEntity info = new LEventsEntity(); IList <LEventsEntity> list = new List <LEventsEntity>(); ds = _currentDAO.GetEventInfoByWX(wxCode); if (ds != null && ds.Tables[0].Rows.Count > 0) { info = DataTableToObject.ConvertToObject <LEventsEntity>(ds.Tables[0].Rows[0]); } return(info); }
public string getEventTotalInfo() { var loggingSessionInfo = Default.GetLjLoggingSession(); //根据客户标识获取连接字符串 qianzhi 2013-07-30 if (!string.IsNullOrEmpty(Request["customerId"])) { loggingSessionInfo = Default.GetBSLoggingSession(Request["customerId"].Trim(), ""); } string content = string.Empty; GetResponseParams <EventTotalInfo> response = new GetResponseParams <EventTotalInfo>(); response.Code = "200"; response.Description = "操作成功"; try { string WeiXinId = Request["WeiXinId"].ToString().Trim(); string EventId = Request["EventId"].ToString().Trim(); LEventsEntity eventInfo = new LEventsEntity(); LEventsBLL inoutServer = new LEventsBLL(loggingSessionInfo); string strError = string.Empty; eventInfo = inoutServer.GetEventTotalInfo(WeiXinId, EventId, loggingSessionInfo, out strError); if (eventInfo == null) { response.Code = "201"; response.Description = strError; } else { EventTotalInfo eventTotalInfo = new EventTotalInfo(); eventTotalInfo.hasOrderCount = eventInfo.hasOrderCount; eventTotalInfo.hasPayCount = eventInfo.hasPayCount; eventTotalInfo.hasSalesAmount = eventInfo.hasSalesAmount; eventTotalInfo.hasVipCount = eventInfo.hasVipCount; eventTotalInfo.newVipCount = eventInfo.newVipCount; response.Params = eventTotalInfo; } } catch (Exception ex) { response.Code = "201"; response.Description = "失败" + ex.ToString(); } content = string.Format("{{\"Description\":\"{2}\",\"Code\":\"{1}\",\"Vip\":{0}}}", response.Params.ToJSON(), response.Code, response.Description); return(content); }
/// <summary> /// 活动列表获取 /// </summary> public DataTable WEventGetWebEvents(LEventsEntity eventsEntity, int Page, int PageSize, out int pPageCount) { if (PageSize <= 0) { PageSize = 15; } DataSet ds = new DataSet(); pPageCount = 0; ds = _currentDAO.WEventGetWebEvents(eventsEntity, Page, PageSize); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { if (ds.Tables.Count > 1 && ds.Tables[1].Rows.Count > 0) { pPageCount = Convert.ToInt32(ds.Tables[1].Rows[0][0]); } return(ds.Tables[0]); } return(null); }
/// <summary> /// 获取活动相关的统计信息 /// </summary> /// <param name="WeiXinId">微信公众号标识</param> /// <param name="EventId">活动标识</param> /// <param name="loggingSessionInfo">登录</param> /// <returns></returns> public LEventsEntity GetEventTotalInfo(string WeiXinId , string EventId , LoggingSessionInfo loggingSessionInfo , out string strError) { LEventsEntity eventInfo = new LEventsEntity(); #region if (EventId == null || EventId.Equals("")) { strError = "必须选择商品"; return(eventInfo); } if (WeiXinId == null || WeiXinId.Equals("")) { strError = "微信公众号不能为空"; return(eventInfo); } #endregion try { //1.获取已关注会员数量 VipBLL vipServer = new VipBLL(loggingSessionInfo); eventInfo.hasVipCount = vipServer.GetHasVipCount(WeiXinId); //2.获取新采集会员数量 eventInfo.newVipCount = vipServer.GetNewVipCount(WeiXinId); //3.获取已下单数量 InoutService inoutServer = new InoutService(loggingSessionInfo); eventInfo.hasOrderCount = inoutServer.GetHasOrderCount(EventId); //4.获取已付款订单数 eventInfo.hasPayCount = inoutServer.GetHasPayCount(EventId); //5.获取已销售订单额 eventInfo.hasSalesAmount = inoutServer.GetHasSalesAmount(EventId); strError = "ok"; return(eventInfo); } catch (Exception ex) { throw (ex); } }
/// <summary> /// 获取返校日活动 /// </summary> /// <param name="eventId"></param> /// <param name="userId"></param> /// <returns></returns> public LEventsEntity getSchoolEventList(string eventId, string userId) { LEventsEntity eventInfo = new LEventsEntity(); DataSet ds = _currentDAO.GetEventFXInfo(eventId, userId); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { eventInfo = DataTableToObject.ConvertToObject <LEventsEntity>(ds.Tables[0].Rows[0]); eventInfo.IsSignUp = 1; DataSet ds1 = _currentDAO.getSchoolEventList(eventId, userId); if (ds1 != null && ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { IList <LEventsEntity> eventList = new List <LEventsEntity>(); eventList = DataTableToObject.ConvertToList <LEventsEntity>(ds1.Tables[0]); eventInfo.EventList = eventList; } } return(eventInfo); }
/// <summary> /// 获取列表信息 /// </summary> public LEventsEntity GetMessageEventList(LEventsEntity entity) { try { LEventsEntity obj = new LEventsEntity(); IList <LEventsEntity> list = new List <LEventsEntity>(); DataSet ds = _currentDAO.GetMessageEventList(entity); if (ds != null && ds.Tables[0].Rows.Count > 0) { list = DataTableToObject.ConvertToList <LEventsEntity>(ds.Tables[0]); } obj.EventList = list; return(obj); } catch (Exception ex) { throw (ex); } }
/// <summary> /// 获取活动明细 /// </summary> /// <param name="EventID"></param> /// <param name="UserID"></param> /// <returns></returns> public GetResponseParams <LEventsEntity> WEventGetEventDetail(string EventID, string UserID) { #region 判断对象不能为空 if (EventID == null || EventID.ToString().Equals("")) { return(new GetResponseParams <LEventsEntity> { Flag = "0", Code = "419", Description = "活动标识不能为空", }); } #endregion GetResponseParams <LEventsEntity> response = new GetResponseParams <LEventsEntity>(); response.Flag = "1"; response.Code = "200"; response.Description = "成功"; try { LEventsEntity eventsInfo = new LEventsEntity(); DataSet ds = new DataSet(); ds = this._currentDAO.GetEventDetailById(EventID);; if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { eventsInfo = DataTableToObject.ConvertToObject <LEventsEntity>(ds.Tables[0].Rows[0]); } response.Params = eventsInfo; return(response); } catch (Exception ex) { response.Flag = "0"; response.Code = "103"; response.Description = "失败" + ":" + ex.ToString(); return(response); } }
/// <summary> /// 删除 /// </summary> /// <param name="pEntity"></param> public void Delete(LEventsEntity pEntity) { _currentDAO.Delete(pEntity); }
public void Update(LEventsEntity pEntity, bool pIsUpdateNullField) { _currentDAO.Update(pEntity, pIsUpdateNullField); }
/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> public void Update(LEventsEntity pEntity) { Update(pEntity, true); }
/// <summary> /// 保存更新游戏信息 /// </summary> /// <param name="para"></param> /// <returns></returns> public void SaveGameEvent(SetCTWEventRP para, LPrizesBLL bllPrize, T_CTW_LEventInteractionBLL bllCustomerInteraction, string strThemeId, out string strStartDate, out string strEndDate, out string strGameEventGuid) { strGameEventGuid = string.Empty; var imageBll = new ObjectImagesBLL(loggingSessionInfo); LEventsBLL bllGameEvent = new LEventsBLL(loggingSessionInfo); var eventEntity = new LEventsEntity(); strStartDate = para.GameEventInfo.BeginTime; strEndDate = para.GameEventInfo.EndTime + " 23:59:59"; if (string.IsNullOrEmpty(para.GameEventInfo.LeventId)) { strGameEventGuid = Guid.NewGuid().ToString(); eventEntity.EventID = strGameEventGuid; eventEntity.Title = para.GameEventInfo.Title; eventEntity.BeginTime = para.GameEventInfo.BeginTime; eventEntity.EndTime = para.GameEventInfo.EndTime; eventEntity.DrawMethodId = GetDrawMethodIdByDrawMethodCode(para.DrawMethodCode); eventEntity.PersonCount = para.GameEventInfo.PersonCount; eventEntity.PointsLottery = para.GameEventInfo.PointsLottery; eventEntity.LotteryNum = para.GameEventInfo.LotteryNum; eventEntity.IsDelete = 0; if (DateTime.Compare(Convert.ToDateTime(para.GameEventInfo.BeginTime), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) <= 0 && DateTime.Compare(Convert.ToDateTime(para.GameEventInfo.EndTime), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) >= 0) { eventEntity.EventStatus = 20; //10=未开始,20=运行中,30=暂停,40=结束 } else if (DateTime.Compare(Convert.ToDateTime(para.GameEventInfo.BeginTime), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) > 0) { eventEntity.EventStatus = 10; //10=未开始,20=运行中,30=暂停,40=结束 } eventEntity.IsCTW = 1; eventEntity.CustomerId = loggingSessionInfo.ClientID; bllGameEvent.Create(eventEntity); } else { strGameEventGuid = para.GameEventInfo.LeventId; eventEntity = bllGameEvent.GetByID(strGameEventGuid); eventEntity.Title = para.GameEventInfo.Title; eventEntity.BeginTime = para.GameEventInfo.BeginTime; eventEntity.EndTime = para.GameEventInfo.EndTime; eventEntity.DrawMethodId = GetDrawMethodIdByDrawMethodCode(para.DrawMethodCode); eventEntity.PersonCount = para.GameEventInfo.PersonCount; eventEntity.PointsLottery = para.GameEventInfo.PointsLottery; eventEntity.LotteryNum = para.GameEventInfo.LotteryNum; bllGameEvent.Update(eventEntity); } ///图片 if (para.GameEventInfo.ImageList.Count > 0) { imageBll.DeleteByObjectID(strGameEventGuid); foreach (var i in para.GameEventInfo.ImageList) { imageEntity = new ObjectImagesEntity(); imageEntity.ImageURL = i.ImageURL; imageEntity.ObjectId = strGameEventGuid; imageEntity.CreateBy = loggingSessionInfo.UserID; imageEntity.ImageId = Guid.NewGuid().ToString(); imageEntity.BatId = i.BatId; imageEntity.RuleId = para.GameEventInfo.RuleId ?? 1; imageEntity.RuleContent = para.GameEventInfo.RuleContent; imageEntity.IsDelete = 0; imageEntity.CustomerId = loggingSessionInfo.ClientID; imageBll.Create(imageEntity); } } //奖品信息 var entityPrize = new LPrizesEntity(); var redisPrizePoolsBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.PrizePools.RedisPrizePoolsBLL(); if (!string.IsNullOrEmpty(para.GameEventInfo.LeventId)) { //bllPrize.Delete(new LPrizesEntity() { EventId = para.GameEventInfo.LeventId }); bllPrize.DeletePrizesByEventId(para.GameEventInfo.LeventId); CC_PrizePool prizePool = new CC_PrizePool(); prizePool.CustomerId = loggingSessionInfo.ClientID; prizePool.EventId = para.GameEventInfo.LeventId; redisPrizePoolsBLL.DeletePrizePoolsList(prizePool); } if (para.GameEventInfo.PrizeList.Count > 0) { foreach (var i in para.GameEventInfo.PrizeList) { entityPrize.EventId = strGameEventGuid; entityPrize.PrizeTypeId = i.PrizeTypeId; entityPrize.Point = i.Point; entityPrize.CouponTypeID = i.CouponTypeID; entityPrize.PrizeName = i.PrizeName; entityPrize.CountTotal = i.PrizeCount; entityPrize.CreateBy = loggingSessionInfo.UserID; entityPrize.PrizesID = Guid.NewGuid().ToString(); bllPrize.SavePrize(entityPrize); } //入奖品池队列 LPrizePoolsBLL bllPools = new LPrizePoolsBLL(loggingSessionInfo); DataSet dsPools = bllPools.GetPrizePoolsByEvent(loggingSessionInfo.ClientID, strGameEventGuid); if (dsPools != null && dsPools.Tables.Count > 0 && dsPools.Tables[0].Rows.Count > 0) { var poolTemp = DataTableToObject.ConvertToList <CC_PrizePool>(dsPools.Tables[0]); var poolsList = Utils.GetRandomList <CC_PrizePool>(poolTemp); //随机列表 if (poolsList != null && poolsList.Count > 0) { CC_PrizePool prizePool = new CC_PrizePool(); prizePool.CustomerId = loggingSessionInfo.ClientID; prizePool.EventId = strGameEventGuid; redisPrizePoolsBLL.DeletePrizePoolsList(prizePool); redisPrizePoolsBLL.SetPrizePoolsToRedis(poolsList); } } } if (!string.IsNullOrEmpty(para.CTWEventId)) { bllCustomerInteraction.DeleteByCTWEventID(para.CTWEventId); } ///互动类型与(游戏或促销)关联 entityInteraction = new T_CTW_LEventInteractionEntity() { CTWEventId = new Guid(strCTWEventId), ThemeId = new Guid(strThemeId), InteractionType = para.InteractionType, DrawMethodCode = para.DrawMethodCode, LeventId = strGameEventGuid, OriginalLeventId = new Guid(para.OriginalLeventId), CustomerId = loggingSessionInfo.ClientID }; bllCustomerInteraction.Create(entityInteraction); }
/// <summary> /// 活动报名表数据获取 /// </summary> public string getEventApplyQues() { string ReqContent = string.Empty; string content = string.Empty; var respObj = new getEventApplyQuesRespData(); string respStr = string.Empty; try { ReqContent = Request["ReqContent"]; ReqContent = HttpUtility.HtmlDecode(ReqContent); var reqContentObj = ReqContent.DeserializeJSONTo <getEventApplyQuesReqData>(); Loggers.Debug(new DebugLogInfo() { Message = string.Format( "getEventApplyQues ReqContent:{0}", ReqContent) }); if (!string.IsNullOrEmpty(reqContentObj.common.customerId)) { customerId = reqContentObj.common.customerId; } LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); var service = new WEventUserMappingBLL(loggingSessionInfo); GetResponseParams <QuestionnaireEntity> returnDataObj = service.getEventApplyQues( reqContentObj.special.eventId); var contentObj = new getEventApplyQuesRespContentData(); respObj.code = returnDataObj.Code; respObj.description = returnDataObj.Description; if (returnDataObj.Flag == "1" && returnDataObj.Params != null) { contentObj.questionCount = Default.ToStr(returnDataObj.Params.QuestionCount); // questions if (returnDataObj.Params.QuesQuestionEntityList != null) { contentObj.questions = new List <getEventApplyQuesRespQuestionData>(); foreach (var tmpQuestion in returnDataObj.Params.QuesQuestionEntityList) { if (tmpQuestion == null) { continue; } var tmpQues = new getEventApplyQuesRespQuestionData(); tmpQues.questionId = Default.ToStr(tmpQuestion.QuestionID); tmpQues.isSaveOutEvent = Default.ToStr(tmpQuestion.IsSaveOutEvent); tmpQues.cookieName = Default.ToStr(tmpQuestion.CookieName); tmpQues.questionText = Default.ToStr(tmpQuestion.QuestionDesc); tmpQues.questionType = Default.ToStr(tmpQuestion.QuestionType); tmpQues.minSelected = Default.ToStr(tmpQuestion.MinSelected); tmpQues.maxSelected = Default.ToStr(tmpQuestion.MaxSelected); tmpQues.isRequired = Default.ToStr(tmpQuestion.IsRequired); tmpQues.isFinished = Default.ToStr(tmpQuestion.IsFinished); // options if (tmpQuestion.QuesOptionEntityList != null) { tmpQues.options = new List <getEventApplyQuesRespOptionData>(); foreach (var tmpOption in tmpQuestion.QuesOptionEntityList) { if (tmpOption == null) { continue; } var tmpOp = new getEventApplyQuesRespOptionData(); tmpOp.optionId = Default.ToStr(tmpOption.OptionsID); tmpOp.optionText = Default.ToStr(tmpOption.OptionsText); tmpOp.isSelected = Default.ToStr(tmpOption.IsSelect); tmpQues.options.Add(tmpOp); } } contentObj.questions.Add(tmpQues); } } } respObj.content = contentObj; LEventsBLL eventServer = new LEventsBLL(loggingSessionInfo); LEventsEntity eventInfo = new LEventsEntity(); eventInfo = eventServer.GetByID(reqContentObj.special.eventId); respObj.content.imageUrl = eventInfo.URL; Loggers.Debug(new DebugLogInfo() { Message = string.Format( "getEventApplyQues RespContent:{0}", respObj.ToJSON()) }); } catch (Exception ex) { respObj.code = "103"; respObj.description = "数据库操作错误"; //respObj.exception = ex.ToString(); } content = respObj.ToJSON(); return(content); }
/// <summary> /// 在事务内创建一个新实例 /// </summary> /// <param name="pEntity">实体实例</param> /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param> public void Create(LEventsEntity pEntity, IDbTransaction pTran) { _currentDAO.Create(pEntity, pTran); }
/// <summary> /// 分页根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public PagedQueryResult <LEventsEntity> PagedQueryByEntity(LEventsEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex) { return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex)); }
/// <summary> /// 活动列表数量获取 /// </summary> public int WEventGetWebEventsCount(LEventsEntity eventsEntity) { return(_currentDAO.WEventGetWebEventsCount(eventsEntity)); }
public void PushWeiXin(string OpenId, LoggingSessionInfo loggingSessionInfo, string OrderId, string VipId) { string webUrl = ConfigurationManager.AppSettings["website_url"]; string msgUrl = ConfigurationManager.AppSettings["push_weixin_msg_url"];; Random rad = new Random(); string msgText = "<a href='" + webUrl + "wap/Event/20131109/aboutEvent.htm'>点击查看本次活动议程</a>"; string msgData = "<xml><OpenID><![CDATA[" + OpenId + "]]></OpenID>" + "<Content><![CDATA[" + msgText + "]]></Content></xml>"; //var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData); #region 发送日志 MarketSendLogBLL logServer = new MarketSendLogBLL(loggingSessionInfo); MarketSendLogEntity logInfo = new MarketSendLogEntity(); logInfo.LogId = BaseService.NewGuidPub(); logInfo.IsSuccess = 1; logInfo.MarketEventId = OrderId; logInfo.SendTypeId = "2"; logInfo.TemplateContent = msgData; logInfo.VipId = VipId; logInfo.WeiXinUserId = OpenId; logInfo.CreateTime = System.DateTime.Now; logServer.Create(logInfo); #endregion #region msgText = "亲爱的,为答谢您参加本次活动,主办方推出多个奖品的刮刮卡等你来刮,快来试试运气,<a href='" + webUrl + "OnlineClothing/1109guagua.html?customerId=" + loggingSessionInfo.CurrentUser.customer_id + "&userId=" + VipId + "&openId=" + OpenId + "&eventId=" + OrderId + "'>点击试试手气</a>"; //msgData = "<xml><OpenID><![CDATA[" + OpenId + "]]></OpenID>" // + "<Content><![CDATA[" + msgText + "]]></Content></xml>"; LEventsBLL eventServer = new LEventsBLL(loggingSessionInfo); LEventsEntity eventInfo = new LEventsEntity(); eventInfo = eventServer.GetByID(OrderId); if (eventInfo != null && eventInfo.EventID != null) { string picUrl1 = eventInfo.Content; string Url1 = "" + webUrl + "OnlineClothing/1109guagua.html?customerId=" + loggingSessionInfo.CurrentUser.customer_id + "&userId=" + VipId + "&openId=" + OpenId + "&eventId=" + OrderId + ""; msgData = "<xml>" + "<OpenID><![CDATA[" + OpenId + "]]></OpenID>" + "<MsgType><![CDATA[news]]></MsgType>" + "<Articles>" + "<item>" + "<Title><![CDATA[活动刮刮卡,惊喜享不停!]]></Title> " + "<Description><![CDATA[亲!为答谢您来参加本次活动,我们特别推出刮刮卡,大量精美奖品等你来取,快来试试运气吧。]]></Description> " + "<Url><![CDATA[" + Url1 + "]]></Url> " + "<PicUrl><![CDATA[" + picUrl1 + "]]></PicUrl> " + "</item>" + "</Articles>" + "</xml>"; var msgResult1 = Common.Utils.GetRemoteData(msgUrl, "POST", msgData); } #endregion #region 发送日志 MarketSendLogEntity logInfo1 = new MarketSendLogEntity(); logInfo1.LogId = BaseService.NewGuidPub(); logInfo1.IsSuccess = 1; logInfo1.MarketEventId = OrderId; logInfo1.SendTypeId = "2"; logInfo1.TemplateContent = msgData; logInfo1.VipId = VipId; logInfo1.WeiXinUserId = OpenId; logInfo1.CreateTime = System.DateTime.Now; logServer.Create(logInfo1); #endregion }
/// <summary> /// 删除 /// </summary> /// <param name="pEntity">实体实例</param> /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param> /// public void Delete(LEventsEntity pEntity, IDbTransaction pTran) { _currentDAO.Delete(pEntity, pTran); }
/// <summary> /// 根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public LEventsEntity[] QueryByEntity(LEventsEntity pQueryEntity, OrderBy[] pOrderBys) { return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys)); }
public void Update(LEventsEntity pEntity, bool pIsUpdateNullField, IDbTransaction pTran) { _currentDAO.Update(pEntity, pIsUpdateNullField, pTran); }
/// <summary> /// 创建一个新实例 /// </summary> /// <param name="pEntity">实体实例</param> public void Create(LEventsEntity pEntity) { _currentDAO.Create(pEntity); }
public string ReplaceTemplate(string message, EventVipEntity eventVip, VipEntity vip, LEventsEntity eventEntity) { message = message.Replace("$VipName$", eventVip.VipName); message = message.Replace("$Region$", eventVip.Seat); message = message.Replace("$Seat$", eventVip.Seat); message = message.Replace("$Ver$", new Random().Next().ToString()); message = message.Replace("$CustomerId$", eventVip.CustomerId); message = message.Replace("$UserId$", vip.VIPID); message = message.Replace("$OpenId$", vip.WeiXinUserId); message = message.Replace("$EventName$", eventEntity.Title); return(message); }
/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param> public void Update(LEventsEntity pEntity, IDbTransaction pTran) { Update(pEntity, true, pTran); }
/// <summary> /// 发送微信消息 /// </summary> /// <param name="VipId">用户标识</param> /// <param name="EventId">活动标识</param> /// <param name="strError">错误提示</param> /// <returns></returns> public bool SetEventVipSeatPush(string VipId, string EventId, out string strError) { strError = "成功."; #region //1.判断用户是否关注过活动 WEventUserMappingBLL eventServer = new WEventUserMappingBLL(this.CurrentUserInfo); var eventList = eventServer.QueryByEntity(new WEventUserMappingEntity { UserID = VipId , IsDelete = 0 , EventID = EventId }, null); if (eventList == null || eventList.Length == 0) { #region WEventUserMappingEntity eventUserMappingInfo = new WEventUserMappingEntity(); eventUserMappingInfo.Mapping = Common.Utils.NewGuid(); eventUserMappingInfo.EventID = EventId; eventUserMappingInfo.UserID = VipId; eventServer.Create(eventUserMappingInfo); #endregion } #endregion #region //2.判断用户是否注册 VipBLL vipServer = new VipBLL(this.CurrentUserInfo); VipEntity vipInfo = new VipEntity(); vipInfo = vipServer.GetByID(VipId); if (vipInfo == null || vipInfo.VIPID.Equals("")) { strError = "用户不存在"; return(false); } #endregion else { #region EventVipEntity eventVipInfo = new EventVipEntity(); var eventVipList = _currentDAO.QueryByEntity(new EventVipEntity { Phone = vipInfo.Phone , IsDelete = 0 }, null); if (eventVipList == null || eventVipList.Length == 0) { strError = "没有合适的员工."; return(false); } else { eventVipInfo = eventVipList[0]; } #endregion LEventsEntity lEventsEntity = new LEventsEntity(); lEventsEntity = new LEventsBLL(this.CurrentUserInfo).GetByID(EventId); //string message = "尊贵的" + eventVipInfo.VipName + "先生/女士:\r\n 诚挚地欢迎您参加复星集团2014年全球工作会议,本次会议将于8:30正式开始。请您至5楼静安大宴会厅" + eventVipInfo.Seat + "区域就坐,或参见胸卡背面提示."; string message = new WMaterialWritingBLL(this.CurrentUserInfo).GetWMaterialWritingByModelId(EventId).Content; message = ReplaceTemplate(message, eventVipList[0], vipInfo, lEventsEntity); //组织消息 string code = JIT.CPOS.BS.BLL.WX.CommonBLL.SendWeixinMessage(message, VipId, this.CurrentUserInfo, vipInfo); switch (code) { case "103": strError = "未查询到匹配的公众账号信息"; break; case "203": strError = "发送失败"; break; default: break; } } return(true); }
public bool SetEventWXPush(LEventsEntity eventInfo, string WeiXin, string OpenId, string VipId, string msgUrl, out string strError, string AuthUrl, int iRad) { try { MarketSendLogBLL logServer = new MarketSendLogBLL(this.CurrentUserInfo); Random rad = new Random(); if (eventInfo == null || eventInfo.ModelId == null || eventInfo.ModelId.Equals("")) { strError = "获取信息不全,缺少模板。"; return(false); } #region WEventUserMappingBLL eventUserMapping = new WEventUserMappingBLL(CurrentUserInfo); int eventPersonCount = 0; eventPersonCount = eventUserMapping.GetEventSignInCount(eventInfo.EventID); #endregion WApplicationInterfaceBLL wAServer = new WApplicationInterfaceBLL(this.CurrentUserInfo); var wxArray = wAServer.QueryByEntity(new WApplicationInterfaceEntity { WeiXinID = WeiXin , IsDelete = 0 , CustomerId = this.CurrentUserInfo.CurrentUser.customer_id }, null); if (wxArray == null || wxArray.Length == 0 || wxArray[0].AppID == null || wxArray[0].AppID.Equals("")) { strError = "不存在对应的微信帐号"; return(false); } else { WApplicationInterfaceEntity wxInfo = wxArray[0]; WX.CommonBLL server = new WX.CommonBLL(); JIT.CPOS.BS.Entity.WX.SendMessageEntity sendMessageInfo = new Entity.WX.SendMessageEntity(); WMaterialTextBLL wTextServer = new WMaterialTextBLL(this.CurrentUserInfo); IList <WMaterialTextEntity> textlist = new List <WMaterialTextEntity>(); textlist = wTextServer.GetMaterialTextListByModelId(eventInfo.ModelId); if (textlist != null && textlist.Count > 0 && textlist[0].TextId != null) { #region VipBLL vipServer = new VipBLL(CurrentUserInfo); VipEntity vipInfo = vipServer.GetByID(VipId); sendMessageInfo.msgtype = "news"; sendMessageInfo.touser = OpenId; List <JIT.CPOS.BS.Entity.WX.NewsEntity> newsList = new List <JIT.CPOS.BS.Entity.WX.NewsEntity>(); foreach (var info in textlist) { JIT.CPOS.BS.Entity.WX.NewsEntity newsInfo = new Entity.WX.NewsEntity(); newsInfo.title = info.Title; if (vipInfo != null && !vipInfo.VIPID.Equals("")) { newsInfo.description = info.Author.Replace("#VIPNAME#", vipInfo.VipName); } else { newsInfo.description = info.Author; } newsInfo.description = newsInfo.description.Replace("#PERSONCOUNT#", Convert.ToString(eventPersonCount)); //string url = info.OriginalUrl; //JIT.Utility.Log.Loggers.Debug(new DebugLogInfo() //{ // Message = string.Format("处理原文链接出错:{0},url:{1};Status:{2};",) //}); if (info.OriginalUrl != null && !info.OriginalUrl.Equals("") && vipInfo.Status != null && !vipInfo.Status.ToString().Equals("")) { if (vipInfo.Status.Equals(1) && info.OriginalUrl.IndexOf("Fuxing") > 0) { newsInfo.description = info.Text; } else { } } if (info.OriginalUrl.IndexOf("?") > 0) { newsInfo.url = info.OriginalUrl + "&rnd=" + rad.Next(1000, 100000) + ""; } else { string goUrl = info.OriginalUrl + "?1=1&applicationId=" + wxInfo.ApplicationId + "&eventId=" + eventInfo.EventID + "&openId=" + OpenId + "&userId=" + VipId + ""; goUrl = HttpUtility.UrlEncode(goUrl); newsInfo.url = AuthUrl + "OnlineClothing/go.htm?customerId=" + this.CurrentUserInfo.CurrentUser.customer_id + "&applicationId=" + wxInfo.ApplicationId + "&openId=" + OpenId + "&userId=" + VipId + "&backUrl=" + goUrl + ""; } //OnlineClothing/go.htm?customerId=" + customerId + "&openId=" + OpenId + "&userId=" + vipId + "&backUrl=" + HttpUtility.UrlEncode(goUrl) + ""; newsInfo.picurl = info.CoverImageUrl; newsList.Add(newsInfo); } sendMessageInfo.articles = newsList; #endregion #region 发送日志 MarketSendLogEntity logInfo1 = new MarketSendLogEntity(); logInfo1.LogId = BaseService.NewGuidPub(); logInfo1.IsSuccess = 1; logInfo1.MarketEventId = eventInfo.EventID; logInfo1.SendTypeId = "2"; logInfo1.Phone = iRad.ToString(); if (sendMessageInfo.ToJSON().ToString().Length > 2000) { logInfo1.TemplateContent = sendMessageInfo.ToJSON().ToString().Substring(1, 1999); } else { logInfo1.TemplateContent = sendMessageInfo.ToJSON().ToString(); } logInfo1.VipId = VipId; logInfo1.WeiXinUserId = OpenId; logInfo1.CreateTime = System.DateTime.Now; logServer.Create(logInfo1); #endregion } var ResultEntity = server.SendMessage(sendMessageInfo, wxInfo.AppID, wxInfo.AppSecret, this.CurrentUserInfo, true); #region Jermyn20140110 处理复星年会的座位信息,是临时的 //FStaffBLL staffServer = new FStaffBLL(this.CurrentUserInfo); //bool bReturn = staffServer.SetStaffSeatsPush(VipId, eventInfo.EventID, out strError); //MarketSendLogEntity logInfo2 = new MarketSendLogEntity(); //logInfo2.LogId = BaseService.NewGuidPub(); //logInfo2.IsSuccess = 1; //logInfo2.MarketEventId = eventInfo.EventID; //logInfo2.SendTypeId = "2"; //logInfo2.TemplateContent = strError; //logInfo2.Phone = iRad.ToString(); //logInfo2.VipId = VipId; //logInfo2.WeiXinUserId = OpenId; //logInfo2.CreateTime = System.DateTime.Now; //logServer.Create(logInfo2); #endregion strError = "ok"; return(true); } } catch (Exception ex) { strError = ex.ToString(); return(false); } }
private void DoWork() { while (true) { try { ConfigurationManager.RefreshSection("appSettings"); var time = ConfigurationManager.AppSettings["Timing"]; TimeSpan.TryParse(time, out _timeSpan); if (DateTime.Now.TimeOfDay.Hours == _timeSpan.Hours) { //支持配置多客户 string[] customerIDs = ConfigurationManager.AppSettings["CustomerIDs"].Split(','); foreach (string customerID in customerIDs) { loggingSessionInfo = Default.GetBSLoggingSession(customerID, "1"); var eventsService = new LEventsBLL(loggingSessionInfo); LEventsEntity queryEntity = new LEventsEntity(); queryEntity.EventType = 0; var data = eventsService.WEventGetWebEvents(queryEntity, 0, 100000000); foreach (var item in data) { XieHuiBaoBLL b = new XieHuiBaoBLL(loggingSessionInfo, "vip"); List <DefindControlEntity> l = new List <DefindControlEntity>(); PageResultEntity pageEntity = null; try { pageEntity = b.GetPageDataByEventID(l, 100000000, 0, item.EventID); } catch (Exception e) { Loggers.Debug(new DebugLogInfo { Message = string.Format("{0} {1} (EventID:{3})报名人员信息通知邮件发送{2}", DateTime.Now.ToShortDateString(), DateTime.Now.TimeOfDay, "失败", item.EventID) }); Loggers.Exception(new BasicUserInfo(), e); continue; } if (pageEntity.GridData != null) { if (pageEntity.GridData.Rows.Count == 0) { continue; } } GridInitEntity g = GetInitGridDataByEventID(item.EventID); if (pageEntity != null && pageEntity.GridData != null) { #region 替换标题信息 if (g != null && g.GridColumnDefinds != null) { if (pageEntity.GridData.Columns.Contains("ROW_NUMBER")) { pageEntity.GridData.Columns.Remove("ROW_NUMBER"); } if (pageEntity.GridData.Columns.Contains("SignUpID")) { pageEntity.GridData.Columns.Remove("SignUpID"); } if (pageEntity.GridData.Columns.Count == 0) { continue; } for (int i = 0; i < pageEntity.GridData.Columns.Count; i++) { for (int j = 0; j < g.GridColumnDefinds.Count; j++) { if (pageEntity.GridData.Columns[i].ColumnName.ToLower() == g.GridColumnDefinds[j].DataIndex.ToLower()) { pageEntity.GridData.Columns[i].ColumnName = g.GridColumnDefinds[j].ColumnText; break; } } } } #endregion } //数据获取 Workbook wb = DataTableExporter.WriteXLS(pageEntity.GridData, 0); wb.Worksheets[0].Name = "参加活动人员信息"; string savePath = ConfigurationManager.AppSettings["FileURL"]; if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); } savePath = savePath + "/" + item.Title + DateTime.Now.ToString("yyyyMMdd") + ".xls"; wb.Save(savePath);//保存Excel文件 #region 邮件发送 FromSetting fs = new FromSetting(); fs.SMTPServer = ConfigurationManager.AppSettings["SmtpServer"]; fs.SendFrom = ConfigurationManager.AppSettings["MailSendFrom"]; fs.UserName = ConfigurationManager.AppSettings["MailUserName"]; fs.Password = ConfigurationManager.AppSettings["MailUserPassword"]; string mailTo = ConfigurationManager.AppSettings["MailTo"]; string isSendMail = ConfigurationManager.AppSettings["IsSendMailToCreator"]; //是否发送成功 bool result = false; if (!string.IsNullOrEmpty(mailTo)) { result = Mail.SendMail(fs, mailTo, ConfigurationManager.AppSettings["MailTitle"], ConfigurationManager.AppSettings["Subject"], savePath.Split(',')); } if (isSendMail == "1") { if (!string.IsNullOrEmpty(item.Email)) { if (DateTime.Now < DateTime.Parse(item.EndTime)) { //等于0表示不发送邮件 if (item.MailSendInterval == null || item.MailSendInterval == 0) { continue; } //日期差与间隔时间取余判断是否符合发送邮件日期 int dateDiff = ((TimeSpan)(DateTime.Now.Date - item.LastUpdateTime.Value.Date)).Days; if (dateDiff % item.MailSendInterval != 0) { continue; } result = Mail.SendMail(fs, item.Email, ConfigurationManager.AppSettings["MailTitle"], ConfigurationManager.AppSettings["Subject"], savePath.Split(',')); Loggers.Debug(new DebugLogInfo { Message = string.Format("{0} {1} (EventID:{3})报名人员信息通知邮件发送{2}", DateTime.Now.ToShortDateString(), DateTime.Now.TimeOfDay, result ? "成功" : "失败", item.EventID) }); } } } #endregion } } } } catch (Exception ex) { Loggers.Exception(new BasicUserInfo(), ex); } Thread.Sleep(new TimeSpan(0, 1, 0, 0)); } }