예제 #1
0
        //        public void Validator(ConcurrentQueue<string> Cq)
        //        {
        //            while (true)
        //            {
        //                try
        //                {
        //                    string receiveMessage;
        //                    Cq.TryDequeue(out receiveMessage);
        //                    var json = receiveMessage;
        //                    var message = JObject.Parse(json);
        //                    var CreateJson = JsonConvert.DeserializeObject<CreateEmployeeDto>(json);
        //                    if (message.IsValid(schema))
        //                        client.CreateUser(CreateJson);
        //                    var LockJson = JsonConvert.DeserializeObject<LockUser>(json);
        //                    if (message.IsValid(schema1))
        //                        client.BlockUser(LockJson);
        //                    var ROleJson = JsonConvert.DeserializeObject<CreateUserRoleDto>(json);
        //                    if (message.IsValid(schema2))
        //                        client.CreateUserRole(ROleJson);
        //                }
        //                catch
        //                {
        //
        //                }
        //            }
        //        }
        //    }
        //}

        public void Validator(Queue <string> messages)
        {
            while (true)
            {
                try
                {
                    lock (messages)
                    {
                        var messageJson = messages.Dequeue();
                        var message     = JObject.Parse(messageJson);
                        var CreateJson  = JsonConvert.DeserializeObject <CreateEmployeeDto>(messageJson);
                        if (message.IsValid(schema))
                        {
                            client.CreateUser(CreateJson);
                            CreateUserEvent?.Invoke(CreateJson);
                        }

                        var LockJson = JsonConvert.DeserializeObject <LockUser>(messageJson);
                        if (message.IsValid(schema1))
                        {
                            client.BlockUser(LockJson);
                            BlockUserEvent?.Invoke(LockJson);
                        }

                        var ROleJson = JsonConvert.DeserializeObject <CreateUserRoleDto>(messageJson);
                        if (message.IsValid(schema2))
                        {
                            client.CreateUserRole(ROleJson);
                            ChangeRoleEvent?.Invoke(ROleJson);
                        }
                    }
                }
                catch { }
            }
        }
예제 #2
0
 private void Apply(CreateUserEvent @event)
 {
     Id       = @event.SourceId;
     Username = @event.Data.Username;
     Password = @event.Data.Password;
     Salt     = @event.Data.Salt;
     Age      = @event.Data.Age;
     Male     = @event.Data.Male;
 }
예제 #3
0
        public IActionResult Eventbus()
        {
            CreateUserEvent user = new CreateUserEvent();

            user.Name       = "hanh";
            user.Address    = "hubei";
            user.CreateTime = DateTime.Now;
            _eventBus.Publish(user);
            return(Ok("ok"));
        }
예제 #4
0
        public static User CreateUser(UserModel obj)
        {
            var user = new User();

            var @event = new CreateUserEvent
            {
                SourceId = obj.Id,
                Data     = new UserModel
                {
                    Id       = obj.Id,
                    Username = obj.Username,
                    Password = obj.Password,
                    Salt     = obj.Salt,
                    Age      = obj.Age,
                    Male     = obj.Male
                }
            };

            user.ApplyChange(@event);

            return(user);
        }
예제 #5
0
        public void Handle(CreateUserEvent evt)
        {
            string        sql = "INSERT INTO T_user ( address, birthday, createrid, createtime, degree, employeenum, entrytime, gender, id, idnum, nationid, PASSWORD, phonenum, realname, STATUS, username ) VALUES ( @address ,@birthday ,@createrid ,@createtime ,@degree ,@employeenum ,@entrytime ,@gender ,@id ,@idnum ,@nationid ,@PASSWORD ,@phonenum ,@realname ,@STATUS ,@username )";
            IDbParameters pms = AdoTemplate.CreateDbParameters();

            pms.AddWithValue("address", evt.Address);
            pms.AddWithValue("birthday", evt.Birthday);
            pms.AddWithValue("createrid", evt.CreaterId);
            pms.AddWithValue("createtime", evt.CreateTime);
            pms.AddWithValue("degree", evt.Degree);
            pms.AddWithValue("employeenum", evt.EmployeeNum);
            pms.AddWithValue("entrytime", evt.EntryTime);
            pms.AddWithValue("gender", evt.Gender);
            pms.AddWithValue("id", evt.Id);
            pms.AddWithValue("idnum", evt.IdNum);
            pms.AddWithValue("nationid", evt.NationId);
            pms.AddWithValue("PASSWORD", evt.Password);
            pms.AddWithValue("phonenum", evt.PhoneNum);
            pms.AddWithValue("realname", evt.RealName);
            pms.AddWithValue("STATUS", evt.Status);
            pms.AddWithValue("username", evt.UserName);

            AdoTemplate.ExecuteNonQuery(CommandType.Text, sql, pms);
        }