Exemplo n.º 1
0
        protected override WifiSignRD ProcessRequest(DTO.Base.APIRequest <WifiSignRP> pRequest)
        {
            //调试日志1
            Loggers.Debug(new DebugLogInfo
            {
                Message = "<1>VIP.WifiSign.WifiSign接口开始执行___" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
            });


            WifiSignRD rd = new WifiSignRD();

            pRequest.CustomerID = ConfigurationManager.AppSettings["WiFiCustomerID"].Trim();
            pRequest.Parameters.Validate();

            string wiFiUser    = ConfigurationManager.AppSettings["WiFiUser"].Trim();
            string userSession = ConfigurationManager.AppSettings["UserSession"].Trim();
            string userLoginOk = ConfigurationManager.AppSettings["UserLoginOk"].Trim();

            if (string.IsNullOrEmpty(pRequest.UserID))
            {
                throw new Exception("UserID不能为空");
            }
            if (string.IsNullOrEmpty(wiFiUser))
            {
                throw new APIException("请配置WiFiUser对应的URL请求路径")
                      {
                          ErrorCode = ERROR_URL_ISNULL
                      }
            }
            ;
            if (string.IsNullOrEmpty(userSession))
            {
                throw new APIException("请配置UserSession对应的URL请求路径")
                      {
                          ErrorCode = ERROR_URL_ISNULL
                      }
            }
            ;
            if (string.IsNullOrEmpty(userLoginOk))
            {
                throw new APIException("请配置UserLoginOk对应的URL请求路径")
                      {
                          ErrorCode = ERROR_URL_ISNULL
                      }
            }
            ;

            #region 获取表单列表
            try
            {
                //调试日志2
                Loggers.Debug(new DebugLogInfo
                {
                    Message = "<2>获取SK参数值:" + pRequest.Parameters.DeviceID + ",获取用户ID参数值:" + pRequest.UserID + ",开始执行第三方接口___" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                });


                #region 调用第三方接口登录认证获取设备ID和连接时间
                //调用第三方接口通知WiFiCenter登录成功
                //RequestGet(string.Format(userLoginOk, pRequest.Parameters.deviceId));


                //调试日志3
                //Loggers.Debug(new DebugLogInfo
                //{
                //    Message = "<3>调用第三方接口通知WiFiCenter登录成功(" + string.Format(userLoginOk, pRequest.Parameters.deviceId) + "通过)___" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                //});


                //调用第三方接口从WiFiCenter获取指定WiFiCenterSessionKey对应的用户信息
                string json = RequestGet(string.Format(wiFiUser, pRequest.Parameters.DeviceID));


                //调试日志4
                Loggers.Debug(new DebugLogInfo
                {
                    Message = "<4>调用第三方接口从WiFiCenter获取指定WiFiCenterSessionKey对应的用户信息(" + string.Format(wiFiUser, pRequest.Parameters.DeviceID) + "通过,返回值:" + json + ")___" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                });


                //调用第三方接口根据指定的WiFiCenterSessionKey获得用户会话信息
                string json2 = RequestGet(string.Format(userSession, pRequest.Parameters.DeviceID));


                //调试日志5
                Loggers.Debug(new DebugLogInfo
                {
                    Message = "<5>调用第三方接口根据指定的WiFiCenterSessionKey获得用户会话信息(" + string.Format(userSession, pRequest.Parameters.DeviceID) + "通过,返回值:" + json2 + ")___" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                });


                JavaScriptSerializer serializer = new JavaScriptSerializer();
                WiFiUser             info       = serializer.Deserialize <WiFiUser>(json);
                WiFiUserSession      info2      = serializer.Deserialize <WiFiUserSession>(json2);


                //调试日志6
                Loggers.Debug(new DebugLogInfo
                {
                    Message = "<6>反序列化通过,获取节点编号:" + info.NodeSn + ",连接时间:" + info2.TimeSessionCreated + "___" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                });



                //节点编号
                string nodeSn = info.NodeSn;
                //连接时间
                DateTime beginTime = info2.TimeSessionCreated;

                if (string.IsNullOrEmpty(nodeSn))
                {
                    throw new APIException("获取节点编号为空")
                          {
                              ErrorCode = ERROR_URL_ISNULL
                          }
                }
                ;
                if (beginTime == null)
                {
                    throw new APIException("获取会话时间为空")
                          {
                              ErrorCode = ERROR_URL_ISNULL
                          }
                }
                ;
                #endregion

                #region 保存用户连接WiFi相关数据
                //WiFi设备表
                WiFiDeviceEntity wiFiInfo = new WiFiDeviceBLL(base.CurrentUserInfo).GetByNodeSn(nodeSn);

                if (wiFiInfo == null)
                {
                    throw new Exception("无WiFi设备");
                }

                if (wiFiInfo.DeviceID == null)
                {
                    throw new Exception("无WiFi设备数据");
                }

                //调试日志7
                Loggers.Debug(new DebugLogInfo
                {
                    Message = "<7>根据节点编号获取WiFi设备数据通过(设备ID:" + wiFiInfo.DeviceID == null ? "NULL" : wiFiInfo.DeviceID + "),开始执行插入数据___" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                });

                string where = string.Format(" and  UnitID='{0}' and VIPID='{1}' ", wiFiInfo.UnitID, pRequest.UserID);
                var uvbll = new WiFiUserVisitBLL(base.CurrentUserInfo);

                if (uvbll.IsExists(where))
                {
                    //更新当前设备ID
                    WiFiUserVisitEntity visitInfo = uvbll.GetByWhere(where);
                    visitInfo.CurrentDeviceID = wiFiInfo.DeviceID;
                    uvbll.Update(visitInfo);

                    //扩展:更新或添加详细信息
                }
                else
                {
                    //用户连接WiFi表
                    WiFiUserVisitEntity visitInfo = new WiFiUserVisitEntity();
                    visitInfo.VisitID         = Guid.NewGuid();
                    visitInfo.VIPID           = pRequest.UserID;
                    visitInfo.UnitID          = wiFiInfo.UnitID;
                    visitInfo.CurrentDeviceID = wiFiInfo.DeviceID;
                    visitInfo.CurrentDate     = DateTime.Now;
                    visitInfo.BeginTime       = DateTime.Parse(beginTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                    visitInfo.CustomerID      = CurrentUserInfo.CurrentLoggingManager.Customer_Id;
                    uvbll.Create(visitInfo);


                    //调试日志8
                    Loggers.Debug(new DebugLogInfo
                    {
                        Message = "<8>用户连接WiFi表添加数据成功___" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                    });


                    //用户连接WiFi详细信息表
                    WiFiUserVisitDetailEntity visitDetailInfo = new WiFiUserVisitDetailEntity();
                    visitDetailInfo.VisitDetailID = Guid.NewGuid();
                    visitDetailInfo.VisitID       = visitInfo.VisitID;
                    visitDetailInfo.VIPID         = pRequest.UserID;
                    visitDetailInfo.DeviceID      = wiFiInfo.DeviceID;
                    visitDetailInfo.BeginTime     = DateTime.Parse(beginTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                    visitDetailInfo.CustomerID    = CurrentUserInfo.CurrentLoggingManager.Customer_Id;
                    new WiFiUserVisitDetailBLL(base.CurrentUserInfo).Create(visitDetailInfo);


                    //调试日志9
                    Loggers.Debug(new DebugLogInfo
                    {
                        Message = "<9>用户连接WiFi详细信息表添加数据成功___" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                    });
                }


                #endregion

                #region 返回门店某个会员详细信息
                StringBuilder strWhere = new StringBuilder();

                if (!string.IsNullOrEmpty(pRequest.UserID) && !string.IsNullOrEmpty(pRequest.OpenID))
                {
                    strWhere.AppendFormat(" and (V.VIPID='{0}' or P.WeiXinUserId='{1}') ", pRequest.UserID, pRequest.OpenID);
                }
                else if (!string.IsNullOrEmpty(pRequest.UserID))
                {
                    strWhere.AppendFormat(" and V.VIPID='{0}' ", pRequest.UserID);
                }
                else if (!string.IsNullOrEmpty(pRequest.OpenID))
                {
                    strWhere.AppendFormat(" and P.WeiXinUserId='{0}' ", pRequest.OpenID);
                }
                if (!string.IsNullOrEmpty(wiFiInfo.DeviceID.ToString()))
                {
                    strWhere.AppendFormat(" and V.CurrentDeviceID='{0}' ", wiFiInfo.DeviceID);
                }

                var ds = uvbll.GetVipDetailList(strWhere.ToString());

                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    rd.Items = DataLoader.LoadFrom <VipInfo>(ds.Tables[0]);
                }


                //调试日志10
                Loggers.Debug(new DebugLogInfo
                {
                    Message = "<10>VIP.WifiSign.WifiSign接口成功结束___" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                });


                #endregion
            }
            catch (Exception ex)
            {
                Loggers.Exception(new ExceptionLogInfo(ex));
                //throw new APIException("查询数据错误") { ErrorCode = ERROR_FAILURE };
                throw new APIException(ex.Message)
                      {
                          ErrorCode = ERROR_FAILURE
                      };
            }
            #endregion

            return(rd);
        }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(WiFiUserVisitDetailEntity pEntity, IDbTransaction pTran)
 {
     Update(pEntity, true, pTran);
 }
 public void Update(WiFiUserVisitDetailEntity pEntity, bool pIsUpdateNullField, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pIsUpdateNullField, pTran);
 }
 /// <summary>
 /// 创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Create(WiFiUserVisitDetailEntity pEntity)
 {
     _currentDAO.Create(pEntity);
 }
 /// <summary>
 /// 在事务内创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Create(WiFiUserVisitDetailEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Create(pEntity, pTran);
 }
 /// <summary>
 /// 分页根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public PagedQueryResult <WiFiUserVisitDetailEntity> PagedQueryByEntity(WiFiUserVisitDetailEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex)
 {
     return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex));
 }
 /// <summary>
 /// 根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public WiFiUserVisitDetailEntity[] QueryByEntity(WiFiUserVisitDetailEntity pQueryEntity, OrderBy[] pOrderBys)
 {
     return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys));
 }
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity"></param>
 public void Delete(WiFiUserVisitDetailEntity pEntity)
 {
     _currentDAO.Delete(pEntity);
 }
 public void Update(WiFiUserVisitDetailEntity pEntity, bool pIsUpdateNullField)
 {
     _currentDAO.Update(pEntity, pIsUpdateNullField);
 }
Exemplo n.º 10
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Update(WiFiUserVisitDetailEntity pEntity)
 {
     Update(pEntity, true);
 }