Exemplo n.º 1
0
        private IEnumerator GameRoutine()
        {
            foreach (var listener in _gameStartListeners)
            {
                listener.OnGameStart();
            }

            yield return(null);

            _log.Info("Game started");

            while (_spawnController.TrySpawnBlock())
            {
                _log.Info("Block spawned");

                while (_gravityController.TryApplyGravity(UnityEngine.Time.deltaTime))
                {
                    yield return(null);
                }

                _log.Info("Block dropped");

                _joinController.JoinBlock();

                _mergeController.TryMergeBlocks();
            }

            _log.Info("Game over");

            foreach (var listener in _gameFinishListeners)
            {
                listener.OnGameFinish();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取用户列表
        /// </summary>
        /// <param name="reqData"></param>
        /// <returns></returns>
        public XAIResGetUserList GetUserList(XAIReqGetUserList reqData)
        {
            LogModule.Info("XAI->BIDU:GetUserList--->入参:" + reqData.ToJson());
            string resJson;

            try
            {
                resJson = client.GroupGetusers(reqData.GroupId).ToJson();
            }
            catch (Exception ex)
            {
                throw new XAIException(7100, "请求人脸识别服务异常,请重试!" + ex.Message);
            }
            LogModule.Info("XAI->BIDU:GetUserList--->出参:" + resJson);
            var res = resJson.ToEntity <BIDUResponse>();

            if (res.error_code != 0)
            {
                throw new XAIException(7100, typeof(BIDUErrorCodeEnum).GetEnumName(res.error_code.ToInt()));
            }
            return(new XAIResGetUserList()
            {
                UserIdList = res.result.user_id_list
            });
        }
Exemplo n.º 3
0
 public virtual K OnExecu <T, K>(T o, BConfig x)
     where T : ExternalReqBase
     where K : ExternalResBase
 {
     try
     {
         using (var dbContext = new DbContextContainer(DbName.HCDb)._DataAccess)
         {
             var dynamicSql = @"SELECT * 
                                  FROM AT_RegDev
                                 WHERE AuthorizeHospitalCode = '" + x.HCode + "' " +
                              "AND RegDevCode = 'Conlin'";
             var dbRegDev = dbContext.Database.Connection.QueryFirstOrDefault <Db_RegDev>(dynamicSql);
             o.ReqHeader = new ReqHeader(dbRegDev, x.BCode, x.TCode, x.OCode);
             var s = String.Empty;
             var v = _ESBClient.ReqBusiness(o.ReqHeader.ReqHospitalCode, o.ReqHeader.ReqCompanyCode, x.TKind, OnEntry(o, x).ToJson(), ref s);
             return(OnExits(s, x).ToEntity <K>());
         }
     }
     catch (Exception ex)
     {
         LogModule.Info("执行ESB请求异常:", ex);
         throw ex;
     }
 }
Exemplo n.º 4
0
 public virtual T OnEntry <T>(T o, BConfig x) where T : class
 {
     LogModule.Info("执行ESB请求开始:------------------------------------------------------------------------------------------");
     LogModule.Info("执行ESB请求交易:" + x.TKind);
     LogModule.Info("执行ESB请求入参:" + o.ToJson());
     return(o);
 }
Exemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="o"></param>
 protected virtual void ResponseFilter(NancyContext o)
 {
     if (o.Request.Url.Path.ToLower() != "/api" &&
         o.Request.Url.Path.ToLower().Contains("receive") != true &&
         o.Response.StatusCode == HttpStatusCode.OK)
     {
         //增加签名
         var s = new MemoryStream();
         o.Response.Contents.Invoke(s);
         if (s.Length > 0)
         {
             s.Position = 0;
             using (var r = new StreamReader(s))
             {
                 var re = r.ReadToEnd();
                 if (re != null)
                 {
                     var res    = re.ToEntity <XAIResBase>();
                     var resMsg = res.ToJson();
                     LogModule.Info("XAI->Res--->出参:" + resMsg);
                     o.Response.Contents = (x) =>
                     {
                         var resBytes = Encoding.UTF8.GetBytes(resMsg);
                         x.Write(resBytes, 0, resBytes.Length);
                     };
                 }
             }
         }
         o.Response.WithContentType("application/json;charset=UTF-8");
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// 用户查询
        /// </summary>
        /// <param name="reqData"></param>
        /// <returns></returns>
        public XAIResFGet FGet(XAIReqFGet reqData)
        {
            LogModule.Info("XAI->BIDU:FGet--->入参:" + reqData.ToJson());
            string resJson;

            try
            {
                resJson = client.UserGet(reqData.UserId, reqData.GroupId).ToJson();
            }
            catch (Exception ex)
            {
                throw new XAIException(7100, "请求人脸识别服务异常,请重试!" + ex.Message);
            }
            LogModule.Info("XAI->BIDU:FGet--->出参:" + resJson);
            var res = resJson.ToEntity <BIDUResponse>();

            if (res.error_code != 0)
            {
                throw new XAIException(7100, typeof(BIDUErrorCodeEnum).GetEnumName(res.error_code.ToInt()));
            }
            return(new XAIResFGet()
            {
                UserInfo = res.result.user_list.FirstOrDefault()?.user_info.ToEntity <BCL.ToolLibWithApp.XAI.Entity.UserInfo>()
            });
        }
Exemplo n.º 7
0
        protected virtual UPPBase OnExecutingBefore(UPPBase _Req, UPPBiz _Biz)
        {
            if (_UPPCONFIG == null)
            {
                throw new ArgumentNullException("UPPClient配置错误,未获取到");
            }
            //校验入参
            _Req.AppId = _Req.AppId.IsNullOrEmptyOfVar() ? _UPPCONFIG.AppId : _Req.AppId;
            _Req.AppId.IsNullOrEmptyOfVar("AppId");
            _Req.Kind.IsNullOrEmptyOfVar("Kind");
            _Req.Mode.IsNullOrEmptyOfVar("Mode");
            _Req.ReqTime = _Req.ReqTime.IsNullOrEmptyOfVar() ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : _Req.ReqTime;
            _Req.Random  = _Req.Random.IsNullOrEmptyOfVar() ? GuidKind.N.BuildRandom() : _Req.Random;

            if (_Biz == null)
            {
                throw new ArgumentNullException("UPPClient业务参数为null");
            }

            //填充业务参数
            _Req.Args = _Biz.ToJson().UrlDecode();

            //加签
            _Req.Sign = _Req.EntityToKeyValue(_UPPCONFIG.Key).BuildCipher("", CipherKind.MD5);
            _Req.Args = _Biz.ToJson();
            LogModule.Info("UPPClient->UPP:入参:" + _Req.EntityToKeyValue(false));
            return(_Req);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 刷脸新增
        /// </summary>
        /// <param name="reqData"></param>
        /// <returns></returns>
        public XAIResFAdd FAdd(XAIReqFAdd reqData)
        {
            LogModule.Info("XAI->BIDU:FAdd--->入参:" + reqData.ToJson());
            var options = new Dictionary <string, object>()
            {
                { "user_info", reqData.UserInfo.ToJson() }
            };
            string resJson;

            try
            {
                resJson = client.UserAdd(reqData.Image.Split(new string[] { ";base64," }, StringSplitOptions.RemoveEmptyEntries)[1], "BASE64", reqData.GroupId, reqData.UserId, options).ToJson();
            }
            catch (Exception ex)
            {
                throw new XAIException(7100, "请求人脸识别服务异常,请重试!" + ex.Message);
            }
            LogModule.Info("XAI->BIDU:FAdd--->出参:" + resJson);
            var res = resJson.ToEntity <BIDUResponse>();

            if (res.error_code != 0)
            {
                throw new XAIException(7100, typeof(BIDUErrorCodeEnum).GetEnumName(res.error_code.ToInt()));
            }
            return(new XAIResFAdd()
            {
                AuthId = res.log_id,
                FaceToken = res.result.face_token,
                LocationLeft = res.result.location.left.ToString(),
                LocationTop = res.result.location.top.ToString(),
                LocationWidth = res.result.location.width.ToString(),
                LocationHeight = res.result.location.height.ToString(),
                LocationRotaion = res.result.location.rotation.ToString()
            });
        }
Exemplo n.º 9
0
        /// <summary>
        /// 刷脸识别
        /// </summary>
        /// <param name="reqData"></param>
        /// <returns></returns>
        public XAIResFind Find(XAIReqFind reqData)
        {
            LogModule.Info("XAI->BIDU:Find--->入参:" + reqData.ToJson());
            string resJson;

            try
            {
                resJson = client.Search(reqData.Image.Split(new string[] { ";base64," }, StringSplitOptions.RemoveEmptyEntries)[1], "BASE64", reqData.GroupId).ToJson();
            }
            catch (Exception ex)
            {
                throw new XAIException(7100, "请求人脸识别服务异常,请重试!" + ex.Message);
            }
            LogModule.Info("XAI->BIDU:Find--->出参:" + resJson);
            var res = resJson.ToEntity <BIDUResponse>();

            if (res.error_code != 0)
            {
                throw new XAIException(7100, typeof(BIDUErrorCodeEnum).GetEnumName(res.error_code.ToInt()));
            }
            res.result.user_list = res.result.user_list.Where(w => w.score > 80).OrderByDescending(o => o.score).ToList();
            if (res.result.user_list.Count() == 0)
            {
                throw new XAIException(7101, "未识别出有效用户");
            }
            return(new XAIResFind()
            {
                UserId = res.result.user_list.OrderByDescending(w => w.score).First().user_id
            });
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dbDetails"></param>
        /// <param name="dbOrder"></param>
        public void UPPAgreeNotify(Db_Agreement dbAgreement)
        {
            if (dbAgreement == null || dbAgreement.NotifyUrl.IsNullOrEmptyOfVar())
            {
                return;
            }
            var v    = Convert.ToInt32("NorCount".ConfigValue("3"));
            var _App = _AppCache.Where(w => w.Key == dbAgreement.AppCode).FirstOrDefault().Value;

            LogModule.Info("UPP->Nor--->开始通知:创建线程==================================");
            var x = Task.Run(() =>
            {
                var i = 1;
                do
                {
                    try
                    {
                        var notify = new UPPAgreeNoticeEntity()
                        {
                            NotifyTime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            Random      = GuidKind.N.BuildRandom(),
                            Kind        = dbAgreement.Status == 2 ? "AgreeSign" : "AgreeUnsign",
                            AppId       = dbAgreement.AppCode,
                            Mode        = dbAgreement.Mode,
                            Index       = dbAgreement.Index,
                            Name        = dbAgreement.Name,
                            AgreeNo     = dbAgreement.AgreeNo.ToString(),
                            Uid         = dbAgreement.Uid,
                            LoginId     = dbAgreement.LoginId,
                            ValidTime   = dbAgreement.ValidTime.HasValue ? dbAgreement.ValidTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : null,
                            InvalidTime = dbAgreement.InvalidTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
                            Status      = dbAgreement.Status.ToString(),
                            PCode       = dbAgreement.PCode,
                        };
                        notify.Sign = notify.EntityToKeyValue(_App.DevKey).BuildCipher("", CipherKind.MD5);
                        var req     = notify.EntityToKeyValue(false);
                        LogModule.Info("UPP->Nor--->参数:" + req);
                        var res = dbAgreement.NotifyUrl.Post(notify.ToJson(), false, "application/json");
                        LogModule.Info("UPP->Nor--->结果:" + res);
                        if (res == "OK")
                        {
                            i = 5;//终止推送通知
                        }
                    }
                    catch (Exception ex)
                    {
                        LogModule.Info("UPP->Nor--->异常:" + ex.Message);
                    };
                    i++;
                    if (i <= v)
                    {
                        Thread.Sleep(10000);
                    }
                }while (i <= v);
            });

            LogModule.Info("UPP->Nor--->通知发送:运行线程Id:" + x.Id + "================================");
        }
Exemplo n.º 11
0
 public virtual object[] OnEntry(params object[] args)
 {
     LogModule.Info("----------------------------------------------------------------");
     args.ToList().ForEach(o =>
     {
         LogModule.Info("入参:" + o);
     });
     return(args);
 }
Exemplo n.º 12
0
 public virtual string OnBusiness(Func <object[], string> _Func, params object[] args)
 {
     try
     {
         return(OnExit(_Func(OnEntry(args))));
     }
     catch (Exception ex)
     {
         LogModule.Info("异常:" + ex);
         throw ex;
     }
 }
Exemplo n.º 13
0
 public O OnExcuting <I, O>(I o, ParamKind _PKind = ParamKind.Send, MethodKind _Kind = MethodKind.GET) where I : SMSReqBase where O : SMSResBase
 {
     try
     {
         return(("SMPUrl".ConfigValue() + "/" + _PKind + "?" + o.EntityToKeyValue(false)).Get().ToEntity <O>());
     }
     catch (Exception ex)
     {
         LogModule.Info("SMP异常:" + ex);
         throw new Exception(ex.Message);
     }
 }
Exemplo n.º 14
0
 public override string Business(params object[] args)
 {
     return(OnBusiness(o =>
     {
         var s = String.Empty.PadRight(2048);
         var x = _HISClient.RunService(o[0].ToString(), o[1].ToString(), ref s);
         if (x < 0 || s.IsNullOrEmptyOfVar())
         {
             LogModule.Info("HIS错误:[" + x + "]" + s);
         }
         return s;
     }, args));
 }
Exemplo n.º 15
0
        /// <summary>
        /// 刷脸认证
        /// </summary>
        /// <param name="reqData"></param>
        /// <returns></returns>
        public XAIResAuth Auth(XAIReqAuth reqData)
        {
            var image_list      = new List <BIDUImageInfo>();
            var QualityControl  = "QualityControl".ConfigValue();
            var LivenessControl = "LivenessControl".ConfigValue();

            reqData.Images.ForEach(f =>
            {
                var image = new BIDUImageInfo()
                {
                    image            = f.Image.Split(new string[] { ";base64," }, StringSplitOptions.RemoveEmptyEntries)[1],
                    image_type       = "BASE64",
                    face_type        = f.Kind == "1" ? "LIVE" : f.Kind == "2" ? "IDCARD" : f.Kind,
                    quality_control  = QualityControl.IsNullOrEmptyOfVar() ? "NORMAL" : QualityControl,
                    liveness_control = (f.Kind == "LIVE" && !LivenessControl.IsNullOrEmptyOfVar()) ? LivenessControl : "NONE"
                };
                image_list.Add(image);
            });
            LogModule.Info("XAI->BIDU:Auth--->入参:" + reqData.ToJson());
            string resJson;

            try
            {
                resJson = client.Match(JArray.Parse(image_list.ToJson())).ToJson();
            }
            catch (Exception ex)
            {
                throw new XAIException(7100, "请求人脸识别服务异常,请重试!" + ex.Message);
            }
            LogModule.Info("XAI->BIDU:Auth--->出参:" + resJson);
            var res = resJson.ToEntity <BIDUResponse>();

            if (res.error_code != 0)
            {
                throw new XAIException(7100, typeof(BIDUErrorCodeEnum).GetEnumName(res.error_code.ToInt()));
            }

            if (res.result.score < 80)
            {
                throw new XAIException(7101, "图片对比阈值过低,对比失败!");
            }
            return(new XAIResAuth()
            {
                AuthId = res.log_id,
                FaceTokenList = res.result.face_list.Select(s => s.face_token).ToList(),
                PaperWorkNo = reqData.UserInfo.PaperWorkNo,
                PhoneNo = reqData.UserInfo.PhoneNo,
                UserId = reqData.UserId
            });
        }
Exemplo n.º 16
0
        public XAIAdminModule() : base("/Admin")
        {
            Init();

            Before += RequestFilter;

            After += ResponseFilter;

            Post["/AddGroup"] = o =>
            {
                try
                {
                    var biz = _Req.Args.ToEntity <XAIReqAddGroup>();
                    #region 参数判断
                    biz.GroupId.IsNullOrEmptyOfVar("GroupId");
                    #endregion

                    var resAddGroup = _Business.AddGroup(biz);

                    return(ResCode.交易成功.XAIAckOfBiz(new XAIResAddGroup()));
                }
                catch (Exception ex)
                {
                    LogModule.Info(ex);
                    return(ResCode.业务错误.XAIAckOfErr(ex.Message));
                }
            };

            Post["/DeleteGroup"] = o =>
            {
                try
                {
                    var biz = _Req.Args.ToEntity <XAIReqDeleteGroup>();
                    #region 参数判断
                    biz.GroupId.IsNullOrEmptyOfVar("GroupId");
                    #endregion

                    var resAddGroup = _Business.DeleteGroup(biz);

                    return(ResCode.交易成功.XAIAckOfBiz(new XAIResDeleteGroup()));
                }
                catch (Exception ex)
                {
                    LogModule.Info(ex);
                    return(ResCode.业务错误.XAIAckOfErr(ex.Message));
                }
            };
        }
Exemplo n.º 17
0
 public virtual string OnExecuting(string hospitalId, string companyCode, string tradeType, string tradeMsg)
 {
     try
     {
         var tradeMsgOut = String.Empty;
         LogModule.Info(string.Format("T->A:{0}:{1}", tradeType, tradeMsg));
         var retMsg = _ESBClient.ReqBusiness(hospitalId, companyCode, tradeType, tradeMsg, ref tradeMsgOut);
         LogModule.Info(string.Format("A->T:{0}:{1}", tradeType, retMsg + tradeMsgOut));
         return(tradeMsgOut);
     }
     catch (Exception ex)
     {
         LogModule.Info(ex);
         throw new Exception(string.Format("ESB异常:{0}->{1}", tradeType, ex.Message));
     }
 }
Exemplo n.º 18
0
 public ESBProviderFromHis(string _HCode = null)
 {
     try
     {
         var builder = new ContainerBuilder();
         builder.RegisterType(Type.GetType("BCL.ToolLibWithApp.ESB.ESBProvider.HisProviderH" + (_HCode ?? "HospitalId".ConfigValue()) + "Version".ConfigValue()))
         .As <IHisProvider>();
         _Business = builder.Build()
                     .Resolve <IHisProvider>();
     }
     catch (Exception ex)
     {
         LogModule.Info(ex);
         throw new Exception("创建HisProvider对象失败:" + ex.Message);
     }
 }
Exemplo n.º 19
0
        /// <summary>
        ///
        /// </summary>
        protected void InvalidAppCode()
        {
            if (this.Request.Headers.ContentType == "application/json" || this.Request.Headers.ContentType == "application/json;")
            {
                var body = this.Request.Body.AsString();
                LogModule.Info("XAI->Req--->入参:" + body);
                //支持Json传输 Args传对象
                try
                {
                    var _ReqJson = body.ToEntity <XAIReqBaseJson>();
                    _Req = new XAIReqBase()
                    {
                        AppCode  = _ReqJson.AppCode,
                        Channel  = _ReqJson.Channel,
                        Args     = _ReqJson.Args.ToJson(),
                        Kind     = _ReqJson.Kind,
                        ReqTime  = _ReqJson.ReqTime,
                        TermCode = _ReqJson.TermCode,
                    };
                }
                catch
                {
                    _Req = body.ToEntity <XAIReqBase>();
                }
            }
            else
            {
                _Req = this.Bind <XAIReqBase>();
                LogModule.Info("XAI->Req--->入参:" + _Req.ToJson());
            }
            if (_Req.AppCode.IsNullOrEmptyOfVar())
            {
                _Req.AppCode = "0000";
            }
            else
            {
                _App = _AppCache.Where(w => w.Key == _Req.AppCode).FirstOrDefault().Value;
            }
            if (_App == null)
            {
                throw new Exception("Invalid AppCode!");
            }

            _Req.ReqTime.IsDateTime("ReqTime");
            _Req.Channel.IsNullOrEmptyOfVar("Channel");
            _Req.Args.IsNullOrEmptyOfVar("Args");
        }
Exemplo n.º 20
0
        protected virtual UPPBase OnExecutingAfter(UPPBase _Res)
        {
            LogModule.Info("UPPClient->UPP:出参:" + _Res.EntityToKeyValue(false));
            //异常返回不再验签
            if (_Res.ResCode == "1001")
            {
                throw new Exception(_Res.ResMsg);
            }

            //验签
            if (_Res.Sign != _Res.EntityToKeyValue(_UPPCONFIG.Key).BuildCipher("", CipherKind.MD5))
            {
                throw new Exception("UPPClient签名验证失败");
            }

            return(_Res);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 短信发送
        /// </summary>
        /// <param name="dbOrder"></param>
        /// <param name="content"></param>
        public void UPPMessage(Db_AppOrder dbOrder, string content)
        {
            if (dbOrder.PhoneNo.IsNullOrEmptyOfVar())
            {
                return;
            }
            var v = Convert.ToInt32("MsgCount".ConfigValue("3"));

            LogModule.Info("UPP->Msg--->开始发送短信:创建线程==================================");
            var x = Task.Run(() =>
            {
                var i = 1;
                do
                {
                    try
                    {
                        var reqSend = new SMSReqSend
                        {
                            SMSKind  = "SMSKind".ConfigValue(),
                            PhoneNo  = dbOrder.PhoneNo,
                            Content  = content,
                            TempCode = "UPP",
                            SendDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            SignName = "SMSSign".ConfigValue(),
                        };
                        LogModule.Info("SMP--->参数:" + reqSend.ToJson());
                        var resSend = new SMPClient().OnExcuting <SMSReqSend, SMSResSend>(reqSend);
                        LogModule.Info("SMP--->结果:" + resSend.ToJson());
                        i = 5;//终止发送短信
                    }
                    catch (Exception ex)
                    {
                        LogModule.Info("SMP--->异常:" + ex.Message);
                    };
                    i++;
                    if (i <= v)
                    {
                        Thread.Sleep(10000);
                    }
                }while (i <= v);
            });

            LogModule.Info("UPP->Msg--->发送短信完毕:运行线程Id:" + x.Id + "================================");
        }
Exemplo n.º 22
0
        private dynamic Error(NancyContext ctx, Exception ex)
        {
            var exMsg = new XAIResBase()
            {
                Code = ((int)ResCode.交易异常).ToString(),
                Desc = ex.Message + (ex.InnerException == null ? "" : ex.InnerException.Message)
            }.ToJson();

            LogModule.Info("XAI->Err--->异常:" + exMsg);

            return(new Response()
            {
                StatusCode = HttpStatusCode.OK,
                ContentType = "application/json;charset=UTF-8",
                Contents = (s) =>
                {
                    var exMsgEncode = Encoding.UTF8.GetBytes(exMsg);
                    s.Write(exMsgEncode, 0, exMsgEncode.Length);
                }
            });
        }
Exemplo n.º 23
0
        protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
        {
            pipelines.BeforeRequest += (x) =>
            {
                LogModule.Info("---------------------------------------I'm Split Line---------------------------------------");
                LogModule.Info("XAI->Req--->Url:" + x.Request.Url);
                return(null);
            };

            pipelines.AfterRequest += (x) =>
            {
                if (x.Request.Url.Path.ToLower() == "/api" || x.Request.Url.Path.ToLower() == "/doc")
                {
                    x.Response.WithContentType("application/pdf");
                }
            };

            pipelines.OnError += Error;

            base.RequestStartup(container, pipelines, context);
        }
Exemplo n.º 24
0
        /// <summary>
        /// 刷脸更新
        /// </summary>
        /// <param name="reqData"></param>
        /// <returns></returns>
        public XAIResFMod FMod(XAIReqFMod reqData)
        {
            LogModule.Info("XAI->BIDU:FMod--->入参:" + reqData.ToJson());
            string resJson;

            try
            {
                resJson = client.UserUpdate(reqData.Image.Split(new string[] { ";base64," }, StringSplitOptions.RemoveEmptyEntries)[1], "BASE64", reqData.GroupId, reqData.UserId).ToJson();
            }
            catch (Exception ex)
            {
                throw new XAIException(7100, "请求人脸识别服务异常,请重试!" + ex.Message);
            }
            LogModule.Info("XAI->BIDU:FMod--->出参:" + resJson);
            var res = resJson.ToEntity <BIDUResponse>();

            if (res.error_code != 0)
            {
                throw new XAIException(7100, typeof(BIDUErrorCodeEnum).GetEnumName(res.error_code.ToInt()));
            }
            return(new XAIResFMod()
            {
            });
        }
Exemplo n.º 25
0
        /// <summary>
        /// 删除人脸
        /// </summary>
        /// <param name="reqData"></param>
        /// <returns></returns>
        public XAIResDeleteFace DeleteFace(XAIReqDeleteFace reqData)
        {
            LogModule.Info("XAI->BIDU:DeleteFace--->入参:" + reqData.ToJson());
            string resJson;

            try
            {
                resJson = client.FaceDelete(reqData.GroupId, reqData.UserId, reqData.FaceToken).ToJson();
            }
            catch (Exception ex)
            {
                throw new XAIException(7100, "请求人脸识别服务异常,请重试!" + ex.Message);
            }
            LogModule.Info("XAI->BIDU:DeleteFace--->出参:" + resJson);
            var res = resJson.ToEntity <BIDUResponse>();

            if (res.error_code != 0)
            {
                throw new XAIException(7100, typeof(BIDUErrorCodeEnum).GetEnumName(res.error_code.ToInt()));
            }
            return(new XAIResDeleteFace()
            {
            });
        }
Exemplo n.º 26
0
 public virtual string OnExit(string args)
 {
     LogModule.Info("出参:" + args);
     return(args);
 }
Exemplo n.º 27
0
 public virtual T OnExits <T>(T o, BConfig x) where T : class
 {
     LogModule.Info("执行ESB请求出参:" + o);
     return(o);
 }
Exemplo n.º 28
0
        public XAIModule()
            : base("/API")
        {
            Init();

            Before += RequestFilter;

            After += ResponseFilter;

            //PDF文档
            Get["/"] = o =>
            {
                return(Response.AsFile("XAI_交互协议.pdf"));
            };
            Post["/Auth"] = o =>
            {
                try
                {
                    _Req.AddAuthLog();
                    var biz     = _Req.Args.ToEntity <XAIReqAuth>();
                    var groupId = "G_" + _App.AppCode + "_01";
                    biz.UserId = groupId + "_" + biz.UserInfo.PaperWorkNo;
                    #region 参数判断
                    if (biz.Images.Count() != 2 || biz.Images.Where(w => w.Kind == "LIVE" || w.Kind == "1").Count() == 0 || biz.Images.Where(w => w.Kind == "IDCARD" || w.Kind == "2").Count() == 0)
                    {
                        throw new ArgumentNullException("Images对比图片必须为两张,且一张为生活照,一张为证件照");
                    }
                    biz.Images.ForEach(f =>
                    {
                        if (!f.Image.Replace("\r\n", "").IsBase64())
                        {
                            throw new ArgumentNullException("Images必须是BASE64编码");
                        }
                        if (!Regex.IsMatch(f.Image, @"^data:image/.{3,5};base64,"))
                        {
                            throw new ArgumentNullException("Images必须包含头如【data:image/.jpg;base64, 】的BASE64编码");
                        }
                        f.Kind.IsNullOrEmptyOfVar("Kind");
                    });
                    if (biz.UserInfo == null)
                    {
                        throw new ArgumentNullException("UserInfo用户信息不可为空!");
                    }
                    biz.UserInfo.PaperWorkNo.IsNullOrEmptyOfVar("UserInfo.PaperWorkNo");
                    #endregion
                    using (var dbContext = new DbContextContainer(DbKind.MySql, DbName.FACEDb)._DataAccess)
                    {
                        var patientList = dbContext.Set <Db_Patient>().Where(w => w.PaperworkNo == biz.UserInfo.PaperWorkNo && w.IsDetele == 0).AsNoTracking().FirstOrDefault();
                        if (patientList != null)
                        {
                            return(ResCode.业务错误.XAIAckOfErr("该用户已认证,请勿重复认证!"));
                        }
                        var authlog = dbContext.Set <Db_AuthLog>().Where(w => w.Id == _Req.RowId).FirstOrDefault();
                        if (authlog == null)
                        {
                            return(ResCode.业务错误.XAIAckOfErr("not found authlog,id=" + _Req.RowId));
                        }
                        //人脸对比
                        var resAuth = _Business.Auth(biz);

                        //插一条人员表
                        var dbPatient = new Db_Patient()
                        {
                            AuthId        = resAuth.AuthId,
                            UserId        = biz.UserId,
                            Name          = biz.UserInfo.Name,
                            PhoneNo       = biz.UserInfo.PhoneNo,
                            Sex           = biz.UserInfo.Sex,
                            Natrue        = biz.UserInfo.Nature,
                            Adress        = biz.UserInfo.Address,
                            Birthday      = biz.UserInfo.Birthday,
                            PaperworkType = "IDCARD",
                            PaperworkNo   = biz.UserInfo.PaperWorkNo,
                            IsDetele      = 0,
                            AddDate       = DateTime.Now
                        };
                        dbContext.Entry(dbPatient).State = EntityState.Added;
                        try
                        {
                            var IDCARDImage = biz.Images.Where(w => w.Kind == "IDCARD" || w.Kind == "2").FirstOrDefault();
                            //循环图片插入图片和人脸表
                            var dbImage = new Db_Image()
                            {
                                ImageId = Snowflake.Instance().GetId().ToString(), Image = IDCARDImage.Image
                            };
                            dbContext.Entry(dbImage).State = EntityState.Added;
                            var reqFAdd = new XAIReqFAdd()
                            {
                                UserId   = biz.UserId,
                                UserInfo = biz.UserInfo,
                                Image    = IDCARDImage.Image,
                                GroupId  = groupId
                            };
                            //人脸新增
                            var resFAdd = _Business.FAdd(reqFAdd);
                            var dbface  = new Db_Face()
                            {
                                AuthId  = resFAdd.AuthId,
                                AppCode = _App.AppCode,
                                ImageId = dbImage.ImageId,
                                //暂写死BASE64
                                ImageType       = "BASE64",
                                FaceType        = IDCARDImage.Kind,
                                FaceToken       = resFAdd.FaceToken,
                                GroupId         = groupId,
                                UserId          = biz.UserId,
                                UserInfo        = biz.UserInfo.ToJson(),
                                LocationLeft    = resFAdd.LocationLeft,
                                LocationTop     = resFAdd.LocationTop,
                                LocationHeight  = resFAdd.LocationHeight,
                                LocationWidth   = resFAdd.LocationWidth,
                                LocationRotaion = resFAdd.LocationRotaion,
                                IsDelete        = 0,
                                AddDate         = DateTime.Now,
                            };
                            dbContext.Entry(dbface).State = EntityState.Added;
                            resAuth.UserInfo         = biz.UserInfo;
                            resAuth.UserInfo.PhoneNo = biz.UserInfo.PhoneNo.IsNullOrEmptyOfVar() ? "" : biz.UserInfo.PhoneNo;
                            var res = ResCode.交易成功.XAIAckOfBiz(resAuth);
                            //补充authlog
                            res.ModAuthLog(_Req.RowId, biz.Images, resAuth.AuthId);
                            dbContext.SaveChanges();
                            return(res);
                        }
                        catch (Exception ex)
                        {
                            var reqFDel = new XAIReqFDel()
                            {
                                GroupId = groupId, UserId = biz.UserId
                            };
                            //删除用户
                            var resFAdd = _Business.FDel(reqFDel);
                            throw ex;
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogModule.Info(ex);
                    return(ResCode.业务错误.XAIAckOfErr(ex.Message));
                }
            };
            Post["/Find"] = o =>
            {
                try
                {
                    _Req.AddFindLog();
                    var biz = _Req.Args.ToEntity <XAIReqFind>();
                    biz.HospitalId = biz.HospitalId.IsNullOrEmptySetVar("0000");
                    #region 参数判断
                    var xxx = this.Request.Body;
                    if (!biz.Image.Replace("\r\n", "").IsBase64())
                    {
                        throw new ArgumentNullException("Image必须是BASE64编码");
                    }
                    if (!Regex.IsMatch(biz.Image, @"^^data:image/.{3,5};base64,"))
                    {
                        throw new ArgumentNullException("Image必须包含头如【data:image/.jpg;base64, 】的BASE64编码");
                    }
                    #endregion
                    var groupId = "G_" + _App.AppCode + "_01";
                    using (var dbContext = new DbContextContainer(DbKind.MySql, DbName.FACEDb)._DataAccess)
                    {
                        var dbImage = new Db_Image()
                        {
                            ImageId = Snowflake.Instance().GetId().ToString(), Image = biz.Image
                        };
                        dbContext.Entry(dbImage).State = EntityState.Added;
                        dbContext.SaveChanges();
                        biz.GroupId = groupId;
                        var resFind   = _Business.Find(biz);
                        var dbPatient = dbContext.Set <Db_Patient>().Where(w => w.UserId == resFind.UserId && w.IsDetele == 0).AsNoTracking().FirstOrDefault();
                        if (dbPatient == null)
                        {
                            return(ResCode.业务错误.XAIAckOfErr("未查找到用户:" + resFind.UserId));
                        }
                        resFind.UserInfo = new UserInfo
                        {
                            PhoneNo     = dbPatient.PhoneNo.IsNullOrEmptyOfVar() ? "" : dbPatient.PhoneNo,
                            PaperWorkNo = dbPatient.PaperworkNo,
                            Name        = dbPatient.Name,
                            Sex         = dbPatient.Sex,
                            Nature      = dbPatient.Natrue,
                            Address     = dbPatient.Adress,
                            Birthday    = dbPatient.Birthday
                        };
                        var dbUserIndexList = dbContext.Set <Db_UserIndex>().Where(w => w.HospitalId == biz.HospitalId && w.UserId == resFind.UserId && w.IsDelete == 0).ToList();
                        resFind.Indexs = dbUserIndexList.Select(s => new UserIndexInfo {
                            Index = s.Index, IndexType = s.IndexType
                        }).ToList();
                        var res = ResCode.交易成功.XAIAckOfBiz(resFind);
                        //补充identlog
                        res.ModFindLog(_Req.RowId, dbImage);
                        return(res);
                    }
                }
                catch (Exception ex)
                {
                    LogModule.Info(ex);
                    if (ex.HResult == 7101)
                    {
                        return(ResCode.刷脸业务错误.XAIAckOfErr(ex.Message));
                    }
                    return(ResCode.业务错误.XAIAckOfErr(ex.Message));
                }
            };
            Post["/FAdd"] = o =>
            {
                try
                {
                    var biz = _Req.Args.ToEntity <XAIReqFAdd>();
                    #region 参数判断
                    if (!biz.Image.Replace("\r\n", "").IsBase64())
                    {
                        throw new ArgumentNullException("Image必须是BASE64编码");
                    }
                    if (!Regex.IsMatch(biz.Image, @"^^data:image/.{3,5};base64,"))
                    {
                        throw new ArgumentNullException("Image必须包含头如【data:image/.jpg;base64, 】的BASE64编码");
                    }
                    if (biz.UserInfo == null)
                    {
                        throw new ArgumentNullException("UserInfo用户信息不可为空!");
                    }
                    biz.UserInfo.PhoneNo.IsNullOrEmptyOfVar("UserInfo.PhoneNo");
                    biz.UserInfo.PaperWorkNo.IsNullOrEmptyOfVar("UserInfo.PaperWorkNo");
                    #endregion
                    biz.GroupId = "G_" + _App.AppCode + "_01";
                    biz.UserId  = biz.GroupId + "_" + biz.UserInfo.PaperWorkNo;
                    //插入成功标志
                    var FaceToken = "";
                    using (var dbContext = new DbContextContainer(DbKind.MySql, DbName.FACEDb)._DataAccess)
                    {
                        var dbPatient    = dbContext.Set <Db_Patient>().Where(w => w.UserId == biz.UserId && w.IsDetele == 0).AsNoTracking().FirstOrDefault();
                        var IsDeleteUser = (dbPatient != null && dbPatient.IsDetele == 0) ? false : true;
                        var dbImage      = new Db_Image()
                        {
                            ImageId = Snowflake.Instance().GetId().ToString(), Image = biz.Image
                        };
                        dbContext.Entry(dbImage).State = EntityState.Added;
                        try
                        {
                            var resFAdd = _Business.FAdd(biz);
                            FaceToken = resFAdd.FaceToken;
                            if (dbPatient == null)
                            {
                                //插一条人员表
                                var newDbPatient = new Db_Patient()
                                {
                                    AuthId        = resFAdd.AuthId,
                                    UserId        = biz.UserId,
                                    Name          = biz.UserInfo.Name,
                                    PhoneNo       = biz.UserInfo.PhoneNo,
                                    Sex           = biz.UserInfo.Sex,
                                    Natrue        = biz.UserInfo.Nature,
                                    Adress        = biz.UserInfo.Address,
                                    Birthday      = biz.UserInfo.Birthday,
                                    PaperworkType = "IDCARD",
                                    PaperworkNo   = biz.UserInfo.PaperWorkNo,
                                    IsDetele      = 0,
                                    AddDate       = DateTime.Now
                                };
                                dbContext.Entry(newDbPatient).State = EntityState.Added;
                            }
                            else if (dbPatient != null && dbPatient.IsDetele != 0)
                            {
                                //更新人员表
                                dbPatient = new Db_Patient()
                                {
                                    AuthId        = resFAdd.AuthId,
                                    UserId        = biz.UserId,
                                    Empi          = null,
                                    Name          = biz.UserInfo.Name,
                                    PhoneNo       = biz.UserInfo.PhoneNo,
                                    Sex           = biz.UserInfo.Sex,
                                    Natrue        = biz.UserInfo.Nature,
                                    Adress        = biz.UserInfo.Address,
                                    Birthday      = biz.UserInfo.Birthday,
                                    PaperworkType = "IDCARD",
                                    PaperworkNo   = biz.UserInfo.PaperWorkNo,
                                    IsDetele      = 0,
                                    AddDate       = DateTime.Now
                                };
                                dbContext.Entry(dbPatient).State = EntityState.Modified;
                            }
                            //插入人脸表
                            var dbface = new Db_Face()
                            {
                                AuthId          = resFAdd.AuthId,
                                AppCode         = _App.AppCode,
                                ImageId         = dbImage.ImageId,
                                ImageType       = "BASE64",
                                FaceType        = "LIVE",
                                FaceToken       = resFAdd.FaceToken,
                                GroupId         = biz.GroupId,
                                UserId          = biz.UserId,
                                UserInfo        = biz.UserInfo.ToJson(),
                                LocationLeft    = resFAdd.LocationLeft,
                                LocationTop     = resFAdd.LocationTop,
                                LocationHeight  = resFAdd.LocationHeight,
                                LocationWidth   = resFAdd.LocationWidth,
                                LocationRotaion = resFAdd.LocationRotaion,
                                IsDelete        = 0,
                                AddDate         = DateTime.Now,
                            };
                            dbContext.Entry(dbface).State = EntityState.Added;
                            dbContext.SaveChanges();
                            return(ResCode.交易成功.XAIAckOfBiz(new XAIResFAdd()
                            {
                                UserId = biz.UserId
                            }));
                        }
                        catch (Exception ex)
                        {
                            if (IsDeleteUser)
                            {
                                var reqFDel = new XAIReqFDel()
                                {
                                    GroupId = biz.GroupId, UserId = biz.UserId
                                };
                                //删除用户
                                var resFAdd = _Business.FDel(reqFDel);
                            }
                            else
                            {
                                if (!FaceToken.IsNullOrEmptyOfVar())
                                {
                                    var reqDeleteFace = new XAIReqDeleteFace()
                                    {
                                        GroupId = biz.GroupId, UserId = biz.UserId, FaceToken = FaceToken
                                    };
                                    //删除用户
                                    var resDeleteFace = _Business.DeleteFace(reqDeleteFace);
                                }
                            }
                            throw ex;
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogModule.Info(ex);
                    return(ResCode.业务错误.XAIAckOfErr(ex.Message));
                }
            };
            Post["/FMod"] = o =>
            {
                try
                {
                    var biz = _Req.Args.ToEntity <XAIReqFMod>();
                    #region 参数判断
                    biz.UserId.IsNullOrEmptyOfVar("UserId");
                    #endregion
                    using (var dbContext = new DbContextContainer(DbKind.MySql, DbName.FACEDb)._DataAccess)
                    {
                        var dbPatient = dbContext.Set <Db_Patient>().Where(w => w.UserId == biz.UserId && w.IsDetele == 0).FirstOrDefault();
                        if (dbPatient == null)
                        {
                            return(ResCode.业务错误.XAIAckOfErr("未查询到用户:" + biz.UserId));
                        }
                        var dbface = dbContext.Set <Db_Face>().Where(w => w.UserId == biz.UserId && w.FaceType == "LIVE" && w.IsDelete == 0).FirstOrDefault();
                        if (dbface == null)
                        {
                            return(ResCode.业务错误.XAIAckOfErr("未查询到用户的人脸库:" + biz.UserId));
                        }
                        biz.GroupId = dbface.GroupId;
                        if (!biz.Image.IsNullOrEmptyOfVar())
                        {
                            if (!biz.Image.Replace("\r\n", "").IsBase64())
                            {
                                throw new ArgumentNullException("Image必须是BASE64编码");
                            }
                            if (!Regex.IsMatch(biz.Image, @"^^data:image/.{3,5};base64,"))
                            {
                                throw new ArgumentNullException("Image必须包含头如【data:image/.jpg;base64, 】的BASE64编码");
                            }
                            var dbImage = new Db_Image()
                            {
                                ImageId = Snowflake.Instance().GetId().ToString(), Image = biz.Image
                            };
                            dbContext.Entry(dbImage).State = EntityState.Added;
                            var resFMod = _Business.FMod(biz);
                            dbface.ImageId         = dbImage.ImageId;
                            dbface.LocationLeft    = resFMod.LocationLeft;
                            dbface.LocationTop     = resFMod.LocationTop;
                            dbface.LocationHeight  = resFMod.LocationHeight;
                            dbface.LocationWidth   = resFMod.LocationWidth;
                            dbface.LocationRotaion = resFMod.LocationRotaion;
                            dbface.ModDate         = DateTime.Now;
                            dbface.ModUser         = "******";
                        }
                        if (biz.UserInfo != null)
                        {
                            if (!biz.UserInfo.PhoneNo.IsNullOrEmptyOfVar())
                            {
                                dbPatient.PhoneNo = biz.UserInfo.PhoneNo;
                            }
                            if (!biz.UserInfo.PaperWorkNo.IsNullOrEmptyOfVar())
                            {
                                dbPatient.PaperworkNo = biz.UserInfo.PaperWorkNo;
                            }
                            if (!biz.UserInfo.Name.IsNullOrEmptyOfVar())
                            {
                                dbPatient.Name = biz.UserInfo.Name;
                            }
                            if (!biz.UserInfo.Nature.IsNullOrEmptyOfVar())
                            {
                                dbPatient.Natrue = biz.UserInfo.Nature;
                            }
                            if (!biz.UserInfo.Address.IsNullOrEmptyOfVar())
                            {
                                dbPatient.Adress = biz.UserInfo.Address;
                            }
                            if (!biz.UserInfo.Birthday.IsNullOrEmptyOfVar())
                            {
                                dbPatient.Birthday = biz.UserInfo.Birthday;
                            }
                        }
                        dbContext.SaveChanges();
                    }
                    return(ResCode.交易成功.XAIAckOfBiz(new XAIResFMod()));
                }
                catch (Exception ex)
                {
                    LogModule.Info(ex);
                    return(ResCode.业务错误.XAIAckOfErr(ex.Message));
                }
            };
            Post["/FDel"] = o =>
            {
                try
                {
                    var biz = _Req.Args.ToEntity <XAIReqFDel>();
                    #region 参数判断
                    biz.UserId.IsNullOrEmptyOfVar("UserId");
                    #endregion
                    using (var dbContext = new DbContextContainer(DbKind.MySql, DbName.FACEDb)._DataAccess)
                    {
                        var dbPatient = dbContext.Set <Db_Patient>().Where(w => w.UserId == biz.UserId && w.IsDetele == 0).FirstOrDefault();
                        if (dbPatient == null)
                        {
                            return(ResCode.业务错误.XAIAckOfErr("未查询到用户:" + biz.UserId));
                        }
                        var reqFDel = new XAIReqFDel()
                        {
                            GroupId = "G_" + _App.AppCode + "_01",
                            UserId  = biz.UserId
                        };
                        var resFDel = _Business.FDel(reqFDel);
                        dbPatient.IsDetele = 1;
                        var dbFaceList = dbContext.Set <Db_Face>().Where(w => w.UserId == biz.UserId).ToList();
                        dbFaceList.ForEach(f => { f.IsDelete = 1; });
                        dbContext.SaveChanges();
                        return(ResCode.交易成功.XAIAckOfBiz(new XAIResFDel()));
                    }
                }
                catch (Exception ex)
                {
                    LogModule.Info(ex);
                    return(ResCode.业务错误.XAIAckOfErr(ex.Message));
                }
            };
            Post["/FGet"] = o =>
            {
                try
                {
                    var biz = _Req.Args.ToEntity <XAIReqFGet>();
                    #region 参数判断
                    biz.UserId.IsNullOrEmptyOfVar("UserId");
                    #endregion
                    using (var dbContext = new DbContextContainer(DbKind.MySql, DbName.FACEDb)._DataAccess)
                    {
                        var dbPatient = dbContext.Set <Db_Patient>().Where(w => w.UserId == biz.UserId && w.IsDetele == 0).FirstOrDefault();
                        if (dbPatient == null)
                        {
                            return(ResCode.业务错误.XAIAckOfErr("未查询到用户:" + biz.UserId));
                        }
                        var dbFaceList      = dbContext.Set <Db_Face>().Where(w => w.UserId == biz.UserId && w.IsDelete == 0).ToList();
                        var dbUserIndexList = dbContext.Set <Db_UserIndex>().Where(w => w.UserId == biz.UserId && w.IsDelete == 0).ToList();
                        var res             = new XAIResFGet()
                        {
                            UserInfo = new UserInfo
                            {
                                PhoneNo     = dbPatient.PhoneNo,
                                PaperWorkNo = dbPatient.PaperworkNo,
                                Name        = dbPatient.Name,
                                Sex         = dbPatient.Sex,
                                Nature      = dbPatient.Natrue,
                                Address     = dbPatient.Adress,
                                Birthday    = dbPatient.Birthday,
                            },
                            Images = dbFaceList.Select(s => new ImageInfo {
                                ImageId = s.ImageId, Kind = s.FaceType
                            }).ToList(),
                            Indexs = dbUserIndexList.Select(s => new UserIndexInfo {
                                Index = s.Index, IndexType = s.IndexType
                            }).ToList()
                        };
                        //var resGet = _Business.FGet(biz);
                        return(ResCode.交易成功.XAIAckOfBiz(res));
                    }
                }
                catch (Exception ex)
                {
                    LogModule.Info(ex);
                    return(ResCode.业务错误.XAIAckOfErr(ex.Message));
                }
            };
            Post["/IAdd"] = o =>
            {
                try
                {
                    var biz = _Req.Args.ToEntity <XAIReqIAdd>();
                    biz.HospitalId = biz.HospitalId.IsNullOrEmptySetVar("0000");
                    #region 参数判断
                    biz.UserId.IsNullOrEmptyOfVar("UserId");
                    if (biz.Indexs == null)
                    {
                        throw new ArgumentNullException("Indexs用户索引信息不可为空!");
                    }
                    biz.Indexs.ForEach(f =>
                    {
                        f.Index.IsNullOrEmptyOfVar("Index");
                        f.IndexType.IsNullOrEmptyOfVar("IndexType");
                    });
                    #endregion
                    using (var dbContext = new DbContextContainer(DbKind.MySql, DbName.FACEDb)._DataAccess)
                    {
                        var dbIndexList = dbContext.Set <Db_UserIndex>().Where(w => w.HospitalId == biz.HospitalId && w.UserId == biz.UserId).ToList();
                        var IndexCount  = "IndexCount".ConfigValue("2").ToInt();
                        if (biz.Indexs.Count() > IndexCount || (dbIndexList.Count() + biz.Indexs.Count()) > IndexCount)
                        {
                            throw new XAIException("无法添加,用户索引添加索引超过最大限:" + IndexCount.ToString());
                        }
                        biz.Indexs.ForEach(f =>
                        {
                            var dbIndex = dbIndexList.Where(w => w.IndexType == f.IndexType).FirstOrDefault();
                            if (dbIndex != null)
                            {
                                if (dbIndex.IsDelete == 0 && dbIndex.Index == f.Index)
                                {
                                    throw new XAIException("用户索引已存在,请勿重复添加:" + f.Index);
                                }
                                dbIndex.IsDelete = 0;
                                dbIndex.ModDate  = DateTime.Now;
                                dbIndex.ModUser  = "******";
                            }
                            else
                            {
                                dbIndex = new Db_UserIndex()
                                {
                                    HospitalId = biz.HospitalId,
                                    UserId     = biz.UserId,
                                    Index      = f.Index,
                                    IndexType  = f.IndexType,
                                    IsDelete   = 0,
                                    AddDate    = DateTime.Now,
                                };
                                dbContext.Entry(dbIndex).State = EntityState.Added;
                            }
                        });
                        dbContext.SaveChanges();
                        return(ResCode.交易成功.XAIAckOfBiz(new XAIResIAdd()));
                    }
                }
                catch (Exception ex)
                {
                    LogModule.Info(ex);
                    return(ResCode.业务错误.XAIAckOfErr(ex.Message));
                }
            };
            Post["/IDel"] = o =>
            {
                try
                {
                    var biz = _Req.Args.ToEntity <XAIReqIDel>();
                    biz.HospitalId = biz.HospitalId.IsNullOrEmptySetVar("0000");
                    #region 参数判断
                    biz.UserId.IsNullOrEmptyOfVar("UserId");
                    if (biz.Indexs == null)
                    {
                        throw new ArgumentNullException("Indexs用户索引信息不可为空!");
                    }
                    biz.Indexs.ForEach(f =>
                    {
                        f.Index.IsNullOrEmptyOfVar("Index");
                        f.IndexType.IsNullOrEmptyOfVar("IndexType");
                    });
                    #endregion
                    using (var dbContext = new DbContextContainer(DbKind.MySql, DbName.FACEDb)._DataAccess)
                    {
                        var dbIndexList = dbContext.Set <Db_UserIndex>().Where(w => w.HospitalId == biz.HospitalId && w.UserId == biz.UserId).ToList();
                        biz.Indexs.ForEach(f =>
                        {
                            var dbIndex = dbContext.Set <Db_UserIndex>().Where(w => w.Index == f.Index && w.IndexType == f.IndexType).FirstOrDefault();
                            if (dbIndex == null)
                            {
                                throw new XAIException("未查询到用户索引:" + f.Index);
                            }
                            dbIndex.IsDelete = 1;
                            dbIndex.ModDate  = DateTime.Now;
                            dbIndex.ModUser  = "******";
                        });
                        dbContext.SaveChanges();
                        return(ResCode.交易成功.XAIAckOfBiz(new XAIResIDel()));
                    }
                }
                catch (Exception ex)
                {
                    LogModule.Info(ex);
                    return(ResCode.业务错误.XAIAckOfErr(ex.Message));
                }
            };
        }
Exemplo n.º 29
0
 public override string Business(params object[] args)
 {
     return(OnBusiness(o => {
         //电子健康卡平台身份验证
         if (args.Contains("SFYZ"))
         {
             var _Client = new RequestWsProvider <HealthCardService>("H" + _HOSPITALID + "_HCS").ReqClient;
             var getAuthKey = args[0] as getAuthKey;
             var res = _Client.getAuthKey(getAuthKey);
             if (res != null)
             {
                 if (res.@return != null)
                 {
                     return res.ToJson();
                 }
             }
             return null;
         }
         //电子健康卡平台建档
         else if (args.Contains("JD"))
         {
             var _Client = new RequestWsProvider <HealthCardService>("H" + _HOSPITALID + "_HCS").ReqClient;
             var syncCardInfo = args[0] as syncCardInfo;
             var res = _Client.syncCardInfo(syncCardInfo);
             if (res != null)
             {
                 if (res.@return != null)
                 {
                     return res.ToJson();
                 }
             }
             return null;
         }
         else if (args.Contains("RWMCX")) //二维码查询
         {
             var _Client = new RequestWsProvider <HealthCardService>("H" + _HOSPITALID + "_HCS").ReqClient;
             var virIdCardVerify = args[0] as virIdCardVerify;
             var res = _Client.virIdCardVerify(virIdCardVerify);
             if (res != null)
             {
                 if (res.@return != null)
                 {
                     return res.ToJson();
                 }
             }
             return null;
         }
         else
         {
             //新地址的几个接口(人员信息查询:)
             if (args[0].ToString().Contains("KL."))
             {
                 LogModule.Info("入参接口信息:" + args[0].ToString());
                 var _Client = new RequestWsProvider <BCL.ToolLibWithApp.ESB.IHisApplay>("H" + _HOSPITALID + "_His2").ReqClient;
                 var s = String.Empty.PadRight(2048);
                 var x = _Client.RunService(o[0].ToString(), o[1].ToString(), ref s);
                 if (x < 0 || s.IsNullOrEmptyOfVar())
                 {
                     LogModule.Info("HIS错误:[" + x + "]" + s);
                 }
                 return s;
             }
             else
             {
                 //var x = _HISClient.RunService(o[0].ToString(), o[1].ToString());
                 //return x;
                 //return base.Business(args);
                 var _Client = new RequestWsProvider <BCL.ToolLibWithApp.ESB.IHisApplay>("H" + _HOSPITALID).ReqClient;
                 var s = String.Empty.PadRight(2048);
                 var x = _Client.RunService(o[0].ToString(), o[1].ToString(), ref s);
                 if (x < 0 || s.IsNullOrEmptyOfVar())
                 {
                     LogModule.Info("HIS错误:[" + x + "]" + s);
                 }
                 return s;
             }
         }
     }, args));
     //return base.Business(args);
 }
Exemplo n.º 30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dbDetails"></param>
        /// <param name="dbOrder"></param>
        public void UPPNotify(Db_AppDetail dbDetails, Db_AppOrder dbOrder)
        {
            if (string.IsNullOrEmpty(dbOrder.NotifyUrl))
            {
                return;
            }
            var v    = Convert.ToInt32("NorCount".ConfigValue("3"));
            var _App = _AppCache.Where(w => w.Key == dbDetails.AppCode).FirstOrDefault().Value;

            LogModule.Info("UPP->Nor--->开始通知:创建线程==================================");
            var x = Task.Run(() =>
            {
                var i = 1;
                do
                {
                    try
                    {
                        var notify = new UPPNoticeEntity()
                        {
                            Random     = GuidKind.N.BuildRandom(),
                            Amount     = dbDetails.Amount.ToString(),
                            AppId      = dbDetails.AppCode,
                            HosCode    = dbDetails.HosCode,
                            Kind       = dbDetails.Kind,
                            PsDate     = dbDetails.PsDate.ToString("yyyy-MM-dd HH:mm:ss"),
                            PsNo       = dbDetails.PsNo,
                            ReqDate    = dbDetails.ReqDate.ToString("yyyy-MM-dd HH:mm:ss"),
                            ReqNo      = dbDetails.ReqNo,
                            ResDate    = dbDetails.ResDate.ToString("yyyy-MM-dd HH:mm:ss"),
                            ResNo      = dbDetails.ResNo,
                            State      = dbDetails.State.ToString(),
                            Mode       = dbDetails.Mode,
                            Index      = dbDetails.Index,
                            Name       = dbDetails.Name,
                            BackParams = dbOrder.BackParams,
                            NotifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        };
                        notify.Sign = notify.EntityToKeyValue(_App.DevKey).BuildCipher("", CipherKind.MD5);
                        var req     = notify.EntityToKeyValue(false);
                        LogModule.Info("UPP->Nor--->参数:" + req);
                        var res = string.Empty;
                        if (dbOrder.ReqChannel == "17" && dbOrder.TermCode == "ConlinApp")
                        {
                            res = dbOrder.NotifyUrl.Post(notify.ToJson(), false, "application/json");
                        }
                        else
                        {
                            res = dbOrder.NotifyUrl.Post(req);
                        }
                        LogModule.Info("UPP->Nor--->结果:" + res);
                        if (res == "OK")
                        {
                            i = 5;//终止推送通知
                        }
                    }
                    catch (Exception ex)
                    {
                        LogModule.Info("UPP->Nor--->异常:" + ex.Message);
                    };
                    i++;
                    if (i <= v)
                    {
                        Thread.Sleep(10000);
                    }
                }while (i <= v);
            });

            LogModule.Info("UPP->Nor--->通知发送:运行线程Id:" + x.Id + "================================");
        }