Esempio n. 1
0
        /// <summary>
        /// 接收数据
        /// </summary>
        /// <param name="value"></param>
        /// <param name="type"></param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="data">数据缓存</param>
        /// <param name="length">待接收数据长度</param>
        /// <param name="timeout">超时时间</param>
        internal void receive(object value, receiver.type type, byte[] data, int startIndex, int length, DateTime timeout)
        {
            receiver receiver = typePool <receiver> .Pop();

            if (receiver == null)
            {
                try
                {
                    receiver = new receiver();
                }
                catch (Exception error)
                {
                    log.Error.Add(error, null, false);
                }
                if (receiver == null)
                {
                    receiver.OnReceive(value, type, false);
                    return;
                }
            }
            currentReceiveData       = data;
            currentReceiveStartIndex = startIndex;
            currentReceiveEndIndex   = length + startIndex;
            receiver.Receive(this, value, type, timeout);
        }
Esempio n. 2
0
 public void ProcessMessage(ref byte[] message, receiver rec)
 {
     if (rec)
     {
         rec.ProcessMessage(ref message);
     }
 }
 _inputHandler = new InputHandler(
     input,
     outputHandler,
     receiver,
     requestRouter,
     responseRouter,
     requestInvoker,
     loggerFactory,
     onUnhandledException,
     getException
     );
Esempio n. 4
0
 _inputHandler = new InputHandler(
     input,
     outputHandler,
     receiver,
     requestProcessIdentifier,
     requestRouter,
     responseRouter,
     loggerFactory,
     onUnhandledException,
     getException,
     requestTimeout,
     supportContentModified,
     concurrency > 1 ? (int?)concurrency : null,
Esempio n. 5
0
this.Maps = this.Validate(receiver, compilation);
Esempio n. 6
0
        public async Task <YaeherUser> YaeherUserInfo(TencentFocusUser usermsg, string access_token, String OperType)
        {
            string UserOpenID = usermsg.openid;

            try
            {
                using (var unitOfWork = _unitOfWorkManager.Begin())
                {
                    TencentUserManage usermanage   = new TencentUserManage();
                    TencentWXPay      tencentWXPay = new TencentWXPay();
                    // 通过Openid查询是否存在用户
                    var UserInfo = await _repository.FirstOrDefaultAsync(a => a.WecharOpenID == usermsg.openid && a.IsDelete == false);

                    // 获取标签参数
                    var paramlist = await _SystemParameterrepository.GetAllListAsync(a => a.IsDelete == false && a.SystemCode == "WXRole");

                    // var paramlist = await _SystemParameterrepository.GetAll().Where(a => a.IsDelete == false && a.SystemCode == "WXRole").ToListAsync();
                    List <Tag> tags = new List <Tag>();
                    if (paramlist != null)
                    {
                        foreach (var tagItem in paramlist)
                        {
                            var Tag = JsonHelper.FromJson <Tag>(tagItem.ItemValue);
                            tags.Add(Tag);
                        }
                    }
                    //  取消获取用户微信信息
                    //var usermsg =await usermanage.WeiXinUserInfoUtils(UserOpenID, access_token);
                    bool IsHistory = false;
                    // 当OpenID查询无用户时   未关注的用户不做任何处理
                    if (usermsg.subscribe != 0)
                    {
                        #region 去掉昵称检查
                        //if (UserInfo == null)
                        //{
                        //    通过昵称判断是否存在 不存在则新增用户  增加返回标签判断
                        //    int WecharLable = 0;
                        //    if (usermsg.tagid_list != null && usermsg.tagid_list.Count > 0)
                        //    {
                        //        // 当用户存在多标签时,查询是否是医生标签
                        //        int DoctorLableId = tags.Where(a => a.name == "doctor").FirstOrDefault().id;
                        //        if (usermsg.tagid_list.Exists(a => a == DoctorLableId))
                        //        {
                        //            WecharLable = DoctorLableId;
                        //        }
                        //        else
                        //        {
                        //            WecharLable = usermsg.tagid_list[0];
                        //        }
                        //    }
                        //    通过昵称匹配到的历史数据
                        //    if (WecharLable != 0)
                        //    {
                        //        UserInfo = _repository.GetAll().Where(a => a.NickName == usermsg.nickname && a.WecharLableId == WecharLable && a.IsDelete == false).FirstOrDefault();
                        //    }
                        //}
                        #endregion
                        if (UserInfo == null)
                        {
                            string FullName = "YH" + DateTime.Now.ToString("yyyyMMdd") + new RandomCode().GenerateCheckCode(5);
                            var    newuser  = new YaeherUser();
                            newuser.WecharOpenID  = UserOpenID;
                            newuser.UserImage     = usermsg.headimgurl;
                            newuser.WecharName    = usermsg.nickname;
                            newuser.FullName      = usermsg.nickname;
                            newuser.Sex           = usermsg.sex;
                            newuser.RoleName      = "patient";
                            newuser.Userorigin    = "WXGZH"; //微信公众号
                            newuser.Enabled       = true;    // 默认激活
                            newuser.WecharLable   = "patient";
                            newuser.LoginName     = FullName;
                            newuser.NickName      = usermsg.nickname;
                            newuser.WecharLableId = tags.Where(a => a.name == "patient").FirstOrDefault().id; // 将咨询者的标签赋值   //JsonHelper.FromJson<Tag>(Lableparmlist.ItemValue).id;
                            // newuser.WeCharUserJson = JsonHelper.ToJson(usermsg);
                            newuser.CreatedOn       = DateTime.Now;
                            newuser.LoginPwd        = Commons.DefaultPassword; // 默认增加密码
                            newuser.IsLabel         = true;
                            newuser.IsPay           = false;
                            newuser.IsUpdate        = false;
                            newuser.IsProfitSharing = false;
                            newuser.Id = await _repository.InsertAndGetIdAsync(newuser);

                            UserInfo = newuser;
                        }
                        else
                        {
                            IsHistory         = true; // 如果查询有数据则设置为true
                            UserInfo.IsUpdate = false;
                        }
                        if (!UserInfo.IsPay)
                        {
                            var payment = await _YaeherUserPaymentrepository.FirstOrDefaultAsync(a => a.IsDelete == false && a.UserID == UserInfo.Id);

                            if (payment == null || payment.Id < 1)
                            {
                                //http请求微信信息,获取账户的信息 新增用户payment
                                var CreateUserPayment = new YaeherUserPayment()
                                {
                                    UserID        = UserInfo.Id,
                                    FullName      = UserInfo.FullName,
                                    PayMethod     = "wxpay",
                                    PayMethodName = "微信支付",
                                    PaymentAccout = UserInfo.WecharName,
                                    BankName      = "wx",
                                    Subbranch     = "wx",
                                    BandAdd       = "wx",
                                    BankNo        = "wx",
                                    CreatedOn     = DateTime.Now,
                                    IsDefault     = true,
                                };
                                await _YaeherUserPaymentrepository.InsertAsync(CreateUserPayment);
                            }
                            UserInfo.IsPay = true;
                        }
                        if (!UserInfo.IsUpdate)
                        {
                            // 通过昵称获取的用户信息 去更新历史OpenID
                            if (IsHistory)
                            {
                                UserInfo.OpenID       = "将现有科技注册数据转换:" + UserInfo.WecharOpenID; //将历史的OpenID存储起来
                                UserInfo.WecharOpenID = UserOpenID;                             // 重新给新的OpenID
                            }
                            if (UserInfo.RoleName != "doctor")
                            {
                                UserInfo.UserImage = usermsg.headimgurl;
                            }
                            UserInfo.IsUpdate = true;
                            //当用户为医生时查询分账信息
                            if (UserInfo.RoleName == "doctor")
                            {
                                var DoctorInfo = await _doctorrepository.FirstOrDefaultAsync(a => a.IsDelete == false && a.UserID == UserInfo.Id);

                                if (DoctorInfo != null && DoctorInfo.IsSharing && UserInfo.IsProfitSharing == false)   //医生角色切没有生成分账账号
                                {
                                    //查询分账配置
                                    var configs = await _SystemConfigsrepository.GetAll().Where(a => a.IsDelete == false && a.SystemType == "TencentWechar").ToListAsync();

                                    // 查询医生信息
                                    var tencentparam = configs.FirstOrDefault();
                                    var receiver     = new receiver();
                                    receiver.name    = DoctorInfo.DoctorName;
                                    receiver.type    = "PERSONAL_OPENID";
                                    receiver.account = UserOpenID;
                                    var addresult = await tencentWXPay.ProfitSharingAddReceiver(receiver, tencentparam);

                                    if (addresult.result_code == "SUCCESS")  //插入成功后更新状态
                                    {
                                        UserInfo.IsProfitSharing = true;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (UserInfo.RoleName != "doctor")
                            {
                                UserInfo.UserImage = usermsg.headimgurl;
                            }
                            UserInfo.IsUpdate = true;
                        }
                        await usermanage.YaeherUserLable(usermsg, UserInfo, access_token);

                        // 将用户信息更新
                        if (!UserInfo.IsLabel)
                        {
                            UserInfo.IsLabel = true;
                        }
                        UserInfo.NickName   = usermsg.nickname;
                        UserInfo.WecharName = usermsg.nickname;
                        UserInfo.FullName   = usermsg.nickname;
                        UserInfo.ModifyOn   = DateTime.Now;
                        UserInfo.ModifyBy   = UserInfo.Id;
                        UserInfo            = await _repository.UpdateAsync(UserInfo);

                        #region 增加有效用户访问记录  暂时取消有效访问量
                        //YaeherOperList yaeherOperList = new YaeherOperList();
                        //yaeherOperList.CreatedOn = DateTime.Now;
                        //yaeherOperList.OperExplain = "UserInfo:" + UserOpenID;
                        //yaeherOperList.OperContent = JsonHelper.ToJson(UserInfo);
                        //yaeherOperList.OperType = OperType;
                        //await _YaeherOperListrepository.InsertAsync(yaeherOperList);
                        #endregion
                    }
                    unitOfWork.Complete();
                    return(UserInfo);
                }
            }
            catch (Exception ex)
            {
                #region 增加异常记录信息
                YaeherOperList yaeherOperList = new YaeherOperList();
                yaeherOperList.CreatedOn   = DateTime.Now;
                yaeherOperList.OperExplain = "UserInfo:" + UserOpenID;
                yaeherOperList.OperContent = "error:" + ex.ToString();
                yaeherOperList.OperType    = "用户操作错误:" + OperType;
                await _YaeherOperListrepository.InsertAsync(yaeherOperList);

                #endregion
                throw ex;
            }
        }