예제 #1
0
        public override DataSchema GetDefaultDataSchema()
        {
            var pd_schema = DataSourceInfo.GetPipedriveDataSchema(helper)
                            .Select(p => p.Value)
                            .OrderBy(o => o.Order_nr)
                            .ToList();

            DataSchema schema = new DataSchema();

            pd_schema.ForEach(p => schema.Map.Add(p.ToDataSchemaItem()));

            return(schema);
        }
예제 #2
0
        public override DataTableStore GetDataTable(DataTableStore dt)
        {
            //Set the Datasource Identifier.
            dt.AddIdentifierColumn(typeof(int));

            DataSchemaMapping      mapping = new DataSchemaMapping(SchemaMap, Side);
            IList <DataSchemaItem> columns = SchemaMap.GetIncludedColumns();
            var schema = DataSourceInfo.GetPipedriveDataSchema(helper);

            int  start         = 0;
            bool continue_load = false;

            do
            {
                var result = helper.GetRequestAsJson($"{DataSourceInfo.PipedriveEndpointUrl}&start={start}&limit={PageSize}");

                //Loop around your data adding it to the DataTableStore dt object.
                foreach (var item_row in result["data"])
                {
                    if (dt.Rows.AddWithIdentifier(mapping, columns,
                                                  (item, columnName) =>
                    {
                        var pds = schema[columnName];
                        return(pds.Parser.ParseValue(item_row[columnName]));
                    }
                                                  , item_row["id"].ToObject <int>()) == DataTableStore.ABORT)
                    {
                        break;
                    }
                }

                continue_load = result["additional_data"]?["pagination"] != null && result["additional_data"]["pagination"]["more_items_in_collection"].ToObject <bool>();
                if (continue_load)
                {
                    start = result["additional_data"]["pagination"]["next_start"].ToObject <int>();
                }
            } while (continue_load);

            return(dt);
        }