public override DiscoverShapesResponse Shapes(DiscoverPublisherShapesRequest request) { Logger.LogInfo("Discovering Shapes"); _settings = request.Settings; var configFile = (string)_settings["config"]; var configStr = File.ReadAllText(configFile); var config = JObject.Parse(configStr); var shapeObj = (JObject)config["shape"]; var shapes = new List <ShapeDefinition>(); shapes.Add(shapeObj.ToObject <ShapeDefinition>()); _shapes = shapes; return(new DiscoverShapesResponse { Shapes = shapes }); }
public override DiscoverShapesResponse Shapes(DiscoverPublisherShapesRequest request) { var siteUrl = request.Settings["site_url"] as string; var userName = request.Settings["username"] as string; var password = request.Settings["password"] as string; var domain = request.Settings["domain"] as string; var shapes = new List <ShapeDefinition>(); ClientContext clientContext = new ClientContext(siteUrl); clientContext.Credentials = new System.Net.NetworkCredential(userName, password, domain); Web site = clientContext.Web; clientContext.Load(site); clientContext.ExecuteQuery(); clientContext.Load(site.Lists); clientContext.ExecuteQuery(); foreach (var list in site.Lists) { if (list.BaseType == BaseType.GenericList) { var shape = new ShapeDefinition { Name = list.Title, Description = list.Description, Properties = new List <PropertyDefinition>() }; clientContext.Load(list.Fields); clientContext.ExecuteQuery(); foreach (var field in list.Fields) { if (SUPPORTED_FIELD_TYPES.Contains(field.TypeAsString)) { var propDef = new PropertyDefinition { Name = normalizeFieldName(field.Title), Description = field.Description }; switch (field.FieldTypeKind) { case FieldType.Boolean: propDef.Type = "boolean"; break; case FieldType.Number: case FieldType.Integer: propDef.Type = "number"; break; default: propDef.Type = "string"; break; } shape.Properties.Add(propDef); } } shapes.Add(shape); } } _shapes = shapes; return(new DiscoverShapesResponse { Shapes = shapes }); }
public abstract DiscoverShapesResponse Shapes(DiscoverPublisherShapesRequest request);
public DiscoverShapesResponse DiscoverShapes(DiscoverPublisherShapesRequest request) => _publisher.Shapes(request);