Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
        public ActionResult Save(WS model, HttpPostedFileBase upload)
        {
            DBEntities e = COREobject.i.Context;

            if (ModelState.IsValid)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    using (var reader = new System.IO.BinaryReader(upload.InputStream)) {
                        model.WSDL_File = reader.ReadBytes(upload.ContentLength);
                    }
                }


                // Záznam již existuje - pouze upravujeme
                if (!model.Id.Equals(null))
                {
                    WS row = e.WSs.Single(m => m.Id == model.Id);
                    row.Name          = model.Name;
                    row.WSDL_Url      = model.WSDL_Url;
                    row.Auth_User     = model.Auth_User;
                    row.Auth_Password = model.Auth_Password;
                    row.SOAP_Endpoint = model.SOAP_Endpoint;
                    row.SOAP_XML_NS   = model.SOAP_XML_NS;
                    row.REST_Base_Url = model.REST_Base_Url;
                    row.Type          = model.Type;


                    if (model.WSDL_File != null)
                    {
                        row.WSDL_File = model.WSDL_File;
                    }
                    else
                    {
                        model.WSDL_File = row.WSDL_File;
                    }

                    e.SaveChanges();
                }
                else
                {
                    e.WSs.Add(model);
                    e.SaveChanges();
                }

                // Pokud se jedná o SOAP WS, vygenerujeme proxy class
                if (model.Type == WSType.SOAP)
                {
                    NexusWSService service = new NexusWSService();
                    bool           result  = service.CreateProxyForWS(model);
                }

                return(RedirectToRoute("Nexus", new { @action = "Index" }));
            }
            else
            {
                return(View("~/Views/Nexus/WS/Form.cshtml", model));
            }
        }
Ejemplo n.º 3
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"));
        }
Ejemplo n.º 4
0
        public ActionResult TestRest()
        {
            NexusWSService service = new NexusWSService();

            NameValueCollection queryParams = new NameValueCollection();

            queryParams.Add("text", "republic");

            // zavolá http://services.groupkt.com/country/search?text=republic
            JToken result = service.CallRestService("Country Search", "search", queryParams);

            ViewBag.result = result.ToString();

            return(View("~/Views/Nexus/WS/Test.cshtml"));
        }
Ejemplo n.º 5
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);
        }