Exemplo n.º 1
0
            /// <summary>
            /// 注册TCP服务端
            /// </summary>
            /// <param name="attribute">TCP服务配置</param>
            /// <returns>是否注册成功</returns>
            public registerState Register(fastCSharp.code.cSharp.tcpServer attribute)
            {
                registerResult result = new registerResult {
                    State = registerState.NoClient
                };

#if NotFastCSharpCode
                fastCSharp.log.Error.Throw(fastCSharp.log.exceptionType.NotFastCSharpCode);
#else
                Monitor.Enter(clientLock);
                try
                {
                    result = registerClient.register(clientId, new service {
                        Host = new host {
                            Host = attribute.RegisterHost, Port = attribute.RegisterPort
                        }, IsCheck = attribute.IsRegisterCheckHost, Name = attribute.ServiceName, IsSingle = attribute.IsSingleRegister, IsPerp = attribute.IsPerpleRegister
                    }).Value;
                }
                catch (Exception error)
                {
                    fastCSharp.log.Error.Add(error, null, false);
                }
                finally { Monitor.Exit(clientLock); }
                if (result.State == registerState.Success)
                {
                    attribute.RegisterHost = result.Service.Host.Host;
                    attribute.RegisterPort = result.Service.Host.Port;
                }
#endif
                return(result.State);
            }
        public async Task <IActionResult> CreateNewUser([FromBody] ApplicationUserDtocs userModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var res = await _profileManager.InsertUser(userModel);

            registerResult registerResult = new registerResult();

            registerResult.success = res;

            if (res)
            {
                registerResult.token     = _profileManager.GetAuthToken(userModel, userModel.PasswordHash);
                registerResult.id        = userModel.Id;
                registerResult.firstName = userModel.firstName;
                registerResult.lastName  = userModel.lastName;
            }


            return(Ok(registerResult));
        }