예제 #1
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="req">用户信息</param>
        /// <param name="oper">操作者信息</param>
        public BaseItemRes <bool> AddUser(AddUserReq req, OperatorInfo oper)
        {
            //判断登录名是否已存在
            if (this.userDAL.ExistUser(req.LoginName))
            {
                return(AccHelper.FailItemRes(AccConfig.Msg.ExistLoginName, false));
            }

            //用户实体
            var model = new User();

            model.LoginName   = req.LoginName;
            model.UserName    = req.UserName;
            model.Password    = EncryptHelper.Md5(req.Password);
            model.Gender      = req.Gender;
            model.Birthday    = req.Birthday;
            model.MobilePhone = req.MobilePhone;
            model.Email       = req.Email;
            model.Enable      = true;
            this.SetCreateUpdateFields(model, oper);

            //插入数据库
            this.userDAL.AddUser(model);

            return(AccHelper.OkItemRes(true));
        }
예제 #2
0
        // Token: 0x0600038B RID: 907 RVA: 0x00007614 File Offset: 0x00005814
        public UserTaskResp AddUser(AddUserReq req)
        {
            string text = RestClientUtil.sendRequest("POST", "/service/users", req, this.bean, "AddUser");

            UserResource.log.Info("AddUser result : " + text);
            return(JsonConvert.DeserializeObject <UserTaskResp>(text));
        }
예제 #3
0
        public static bool CreateUserInfo(AddUserReq user)
        {
            AddUserResp resp;
            var         serve = new PortalHttpSendService <AddUserReq, AddUserResp>();

            serve.GetJsonData(user, out resp);
            return(resp != null && resp.errcode == 0);
        }
예제 #4
0
        public Task <Resp <long> > AddUser([FromBody] AddUserReq req)
        {
            if (string.IsNullOrEmpty(req.email) && string.IsNullOrEmpty(req.mobile) || !ModelState.IsValid)
            {
                return(Task.FromResult(GetInvalidResp <long>()));
            }

            return(_service.AddUser(req.MapToUserInfo()));
        }
예제 #5
0
        public Task <IdResp <string> > AddUser([FromBody] AddUserReq req)
        {
            if (string.IsNullOrEmpty(req.email) && string.IsNullOrEmpty(req.mobile) || !ModelState.IsValid)
            {
                return(Task.FromResult(new IdResp <string>().WithResp(ParaErrorResp)));
            }

            return(_service.AddUser(req.MapToUserInfo()));
        }
예제 #6
0
        public void CreateUser2()
        {
            var axlClient = new AxlClient(new UcClientSettings {
                Server = "10.10.20.1", User = "******", Password = "******"
            });

            var appresult = axlClient.Execute(client =>
            {
                var res = client.getAppUser(new GetAppUserReq
                {
                    ItemElementName = ItemChoiceType102.userid,
                    Item            = "administrator"
                });
                return(res.@return);
            });

            Assert.IsNull(appresult.Exception);

            var addUserResult = axlClient.Execute(async client =>
            {
                var userId  = Guid.NewGuid().ToString();
                var request = new AddUserReq
                {
                    user = new XUser
                    {
                        userid       = userId,
                        userIdentity = userId,
                        password     = "******",
                        firstName    = "test",
                        lastName     = "test"
                    }
                };
                var response = await client.addUserAsync(request);
                return(response.addUserResponse1.@return);
            });

            Assert.IsNull(addUserResult.Exception);

            var users = axlClient.Execute(client =>
            {
                var request = new ListUserReq
                {
                    returnedTags = new LUser {
                        firstName = string.Empty
                    },
                    searchCriteria = new ListUserReqSearchCriteria {
                        firstName = "%"
                    }
                };
                var response = client.listUser(request);
                return([email protected](u => u.firstName).ToList());
            });

            Assert.IsTrue(users.Value.Any());
        }
예제 #7
0
        public async Task <IActionResult> PostAsync([FromBody] AddUserReq req, CancellationToken cancellationToken)
        {
            var(code, msg) = req.Valid();

            if (code != ApiReturnCode.Succeed)
            {
                return(BadRequest(ApiSlimResponse.GetResult(code, msg)));
            }

            var res = await _svc.AddUserAsync(req.BuildAddUserInput(TraceId, UserIp), cancellationToken);

            return(Ok(res));
        }
예제 #8
0
        /*
         * A simple  AddEndUser  request with only mandatory tags
         * ##Values in the method are hardcoded please modify accordingly to make it work##
         */
        private static void callAddEndUser(AXLAPIService axlApiService)
        {
            AddUserReq addUserReq = new AddUserReq();

            addUserReq.user          = new XUser();
            addUserReq.user.userid   = "DotNetuser";
            addUserReq.user.lastName = "Visual Studio";
            XFkType xfktype = new XFkType();

            //presenceGroup Name value
            xfktype.Value = "Standard Presence group";
            //Or the UUID
            //xfktype.uuid=""
            addUserReq.user.presenceGroupName = xfktype;
            StandardResponse res2 = axlApiService.addUser(addUserReq);

            Console.WriteLine("Successfully added an User using  AddEndUserRequest" + res2.@return);
        }
예제 #9
0
        public async Task CreateUser()
        {
            var axlClient = new AxlClient(new UcClientSettings {
                Server = "10.10.20.1", User = "******", Password = "******"
            });

            var addUserResult = await axlClient.ExecuteAsync(async client =>
            {
                var userId  = Guid.NewGuid().ToString();
                var request = new AddUserReq
                {
                    user = new XUser
                    {
                        userid       = userId,
                        userIdentity = userId,
                        password     = "******",
                        firstName    = "test",
                        lastName     = "test"
                    }
                };
                var response = await client.addUserAsync(request);
                return(response.addUserResponse1.@return);
            });

            Assert.Inconclusive(addUserResult.Exception.Message);
            Assert.IsNull(addUserResult.Exception);

            var users = await axlClient.ExecuteAsync(async client =>
            {
                var request = new ListUserReq
                {
                    returnedTags = new LUser {
                        firstName = string.Empty
                    },
                    searchCriteria = new ListUserReqSearchCriteria {
                        firstName = "%"
                    }
                };
                var response = await client.listUserAsync(request);
                return([email protected](u => u.firstName).ToList());
            });

            Assert.IsTrue(users.Value.Any());
        }
예제 #10
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("\nStarting up...\n");

            // Load environment variables from .env
            DotNetEnv.Env.Load("../../.env");

            // Change to true to enable output of request/response headers and XML
            var DEBUG = System.Environment.GetEnvironmentVariable("DEBUG");

            // Create a custom binding so we can allow the client to use cookies with AXL
            BasicHttpsBinding binding = new BasicHttpsBinding();

            binding.AllowCookies = true;

            // Specify the CUCM AXL API location for the SOAP client
            EndpointAddress address = new EndpointAddress($"https://{ System.Environment.GetEnvironmentVariable( "CUCM_ADDRESS" ) }:8443/axl/");

            //Class generated from AXL WSDL
            AXLPortClient client = new AXLPortClient(binding, address);

            if (DEBUG == "True")
            {
                client.Endpoint.EndpointBehaviors.Add(new DebugEndpointBehaviour());
            }

            // To disable HTTPS certificate checking, uncomment the below lines
            // NOT for production use!  See README.md for AXL certificate install steps

            // client.ChannelFactory.Credentials.ServiceCertificate.SslCertificateAuthentication = new X509ServiceCertificateAuthentication
            //     {
            //         CertificateValidationMode = X509CertificateValidationMode.None,
            //         RevocationMode = X509RevocationMode.NoCheck
            //     };
            // client.ChannelFactory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
            // client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;

            // Incantation to force alternate serializer reflection behaviour due to complexities in the AXL schema
            // See https://github.com/dotnet/wcf/issues/2219
            MethodInfo method = typeof(XmlSerializer).GetMethod("set_Mode", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);

            method.Invoke(null, new object[] { 1 });

            // Base64 encode AXL username/password for Basic Auth
            var encodedUserPass = Convert.ToBase64String(Encoding.ASCII.GetBytes(
                                                             System.Environment.GetEnvironmentVariable("CUCM_USERNAME") + ":" +
                                                             System.Environment.GetEnvironmentVariable("CUCM_PASSWORD")
                                                             ));

            // Incantation to create and populate a Basic Auth HTTP header
            // This must be done to force SoapCore to include the Authorization header on the first attempt
            HttpRequestMessageProperty requestProperty = new HttpRequestMessageProperty();

            requestProperty.Headers["Authorization"] = "Basic " + encodedUserPass;

            // Creating context block allows attaching custom HTTP headers to the request
            var scope = new OperationContextScope(client.InnerChannel);

            OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestProperty;

            //Create the request object
            AddUserReq addUserReq = new AddUserReq();

            addUserReq.user          = new XUser();
            addUserReq.user.lastName = "TestUser";
            addUserReq.user.userid   = "testUser";
            addUserReq.user.password = "******";

            string userPkid = "";

            //Try the addUser request
            try
            {
                addUserResponse addUserResp = await client.addUserAsync(addUserReq);

                userPkid = addUserResp.addUserResponse1.@return;
            }
            catch (Exception ex)
            {
                Console.WriteLine($"\nError: addUser: { ex.Message }");
                Environment.Exit(-1);
            }

            Console.WriteLine($"addUser: SUCCESS  pkid: { userPkid }\n");

            Console.WriteLine("Press Enter to continue...");
            Console.ReadLine();

            RemoveUserReq removeUserReq = new RemoveUserReq();

            removeUserReq.ItemElementName = ItemChoiceType102.userid;
            removeUserReq.Item            = "testUser";

            //Try the removeUser request
            try
            {
                removeUserResponse removeUserResp = await client.removeUserAsync(removeUserReq);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"\nError: removeUser: { ex.Message }");
                Environment.Exit(-1);
            }

            Console.WriteLine("removeUser: SUCCESS");
        }
예제 #11
0
 public BaseItemRes <bool> AddUser([FromBody] AddUserReq req)
 {
     return(this.userBLL.AddUser(req, this.CurUser));
 }
예제 #12
0
        public async Task <ActionResult> AddOne([FromBody] AddUserReq req)
        {
            var vm = await Mediator.Send(req);

            return(Ok(vm));
        }