Example #1
0
        public static ExportEntity GetCustomEntities()
        {
            ExportEntity result = new ExportEntity();

            using (var ctx = new PSContext())
            {
                ctx.Load(ctx.EntityTypes.ProjectEntity);
                ctx.Load(ctx.EntityTypes.TaskEntity);
                ctx.Load(ctx.EntityTypes.ResourceEntity);
                ctx.ExecuteQuery();

                var customFieldNames = ctx.LoadQuery(ctx.CustomFields.IncludeWithDefaultProperties(
                                                         f => f.InternalName,
                                                         f => f.Id,
                                                         f => f.Name,
                                                         f => f.Description,
                                                         f => f.EntityType,
                                                         f => f.FieldType,
                                                         f => f.Formula,
                                                         f => f.IsMultilineText,
                                                         f => f.IsEditableInVisibility,
                                                         f => f.IsRequired,
                                                         f => f.IsWorkflowControlled,
                                                         f => f.LookupAllowMultiSelect,
                                                         f => f.LookupDefaultValue,
                                                         f => f.LookupTable));
                ctx.ExecuteQuery();

                result.Fields = customFieldNames.Select(cf => cf.GetExportField(ctx)).ToList();

                var lookupTables = ctx.LoadQuery(ctx.LookupTables.IncludeWithDefaultProperties(
                                                     f => f.Id,
                                                     f => f.Name,
                                                     f => f.Masks,
                                                     f => f.FieldType,
                                                     f => f.Entries,
                                                     f => f.SortOrder));
                ctx.ExecuteQuery();

                result.Tables = lookupTables.Select(t => t.GetExportTable(ctx)).ToList();

                return(result);
            }
        }
Example #2
0
        public static bool AddTables(PSContext ctx, List <LookupTableCreationInformation> tables)
        {
            foreach (var t in tables)
            {
                ctx.LookupTables.Add(t);
            }

            ctx.LookupTables.Update();
            ctx.ExecuteQuery();
            return(true);
        }
Example #3
0
        public static bool AddFields(PSContext ctx, List <CustomFieldCreationInformation> fields)
        {
            foreach (var f in fields)
            {
                ctx.CustomFields.Add(f);
            }

            ctx.CustomFields.Update();
            ctx.ExecuteQuery();
            return(true);
        }