예제 #1
0
        public override void InnerRun(Dictionary <string, object> vars, Dictionary <string, object> outputVars, Dictionary <string, object> InvertedInputVars, Message message)
        {
            // init
            string         serviceName = (string)vars["WSName"];
            string         methodName  = (string)vars["MethodName"];
            NexusWSService svc         = new NexusWSService();
            JToken         data;

            if (vars.ContainsKey("JsonBody"))
            {
                data = svc.CallWebService(serviceName, methodName, (string)vars["JsonBody"]);
            }
            else
            {
                List <string>        parameters = new List <string>();
                IEnumerable <string> urlParams  = vars.Keys.Where(k => k.StartsWith("Param[") && k.EndsWith("]"));

                foreach (string key in urlParams)
                {
                    parameters.Add((string)vars[key]);
                }
                object[] args = parameters.ToArray <object>();

                data = svc.CallWebService(serviceName, methodName, args);
            }
            outputVars["Data"] = data;
        }
예제 #2
0
        public ActionResult Test()
        {
            NexusWSService service = new NexusWSService();

            object[] parameters = new[] { "Praha / Ruzyne", "Czech Republic" };
            JToken   result     = service.CallWebService("Global Weather", "GetWeather", parameters);

            ViewBag.result = result.ToString();

            return(View("~/Views/Nexus/WS/Test.cshtml"));
        }
예제 #3
0
        private List <User> GetUserList()
        {
            /// INIT
            COREobject core    = COREobject.i;
            DBEntities context = core.Context;

            //
            NexusWSService webService = new NexusWSService();

            object[] parameters = new[] { "Auction_User" };
            JToken   results    = webService.CallWebService("RWE_WSO_SOAP", "getUserListOfRole", parameters);
            var      x          = results.Children().First().Value <String>();

            //get the list of users names and add it to the list.
            IEnumerable <String> usersNames = results.Children().Values().Select(y => y.Value <String>());

            List <User> listUsers = new List <User>();

            //iterate list of usersNames and make USerObject
            foreach (string userName in usersNames)
            {
                object[] param     = new[] { userName, null };
                JToken   userClaim = webService.CallWebService("RWE_WSO_SOAP", "getUserClaimValues", param);
                User     newUser   = new User();
                newUser.AuthTypeId           = Id;
                newUser.localExpiresAt       = DateTime.Today;//for test
                newUser.LastLogin            = DateTime.Today;
                newUser.CurrentLogin         = DateTime.Today;
                newUser.EmailConfirmed       = false;
                newUser.PhoneNumberConfirmed = false;
                newUser.TwoFactorEnabled     = false;
                newUser.LockoutEnabled       = false;
                newUser.AccessFailedCount    = 0;
                newUser.isActive             = true;
                foreach (JToken property in userClaim.Children())
                {
                    var a = (property.Children().Single(c => (c as JProperty).Name == "claimUri") as JProperty).Value.ToString();

                    switch (a)
                    {
                    case "email":
                        var email = (property.Children().Single(c => (c as JProperty).Name == "value") as JProperty).Value.ToString();
                        newUser.Email    = email;
                        newUser.UserName = email;
                        break;

                    case "http://wso2.org/claims/mobile":
                        var mobile = (property.Children().Single(c => (c as JProperty).Name == "value") as JProperty).Value.ToString();
                        newUser.MobilPhone = mobile;
                        break;

                    case "http://wso2.org/claims/organization":
                        var organization = (property.Children().Single(c => (c as JProperty).Name == "value") as JProperty).Value.ToString();
                        newUser.Company = organization;
                        break;

                    case "fullname":
                        var fullname = (property.Children().Single(c => (c as JProperty).Name == "value") as JProperty).Value.ToString();
                        newUser.DisplayName = fullname;
                        break;

                    //SET ROLES FOR this newly created USER
                    case "http://wso2.org/claims/role":
                        var roles = (property.Children().Single(c => (c as JProperty).Name == "value") as JProperty).Value.ToString().Split(',').Where(r => r.Substring(0, 8) == "Auction_").Select(e => e.Remove(0, 8));
                        foreach (string role in roles)
                        {
                            PersonaAppRole approle = context.AppRoles.SingleOrDefault(r => r.Name == role && r.ApplicationId == core.Application.Id);
                            if (approle == null)
                            {
                                context.AppRoles.Add(new PersonaAppRole()
                                {
                                    Name = role, Application = core.Application, Priority = 0
                                });
                                context.SaveChanges();
                            }
                            //User_Role userRole = newUser.Roles.SingleOrDefault(ur => ur.AppRole == approle && ur.User == newUser);
                            if (approle != null && !newUser.Users_Roles.Contains(new User_Role {
                                RoleName = approle.Name, Application = approle.Application, User = newUser
                            }))
                            {
                                newUser.Users_Roles.Add(new User_Role {
                                    RoleName = approle.Name, Application = approle.Application, User = newUser
                                });
                            }
                        }
                        break;
                    }
                }
                listUsers.Add(newUser);
            }

            return(listUsers);
        }