/// ------------------------------------------------------------------------------------ public static Exception SaveProjectFields(PaProject project) { if (s_displayPropsCache == null) { s_displayPropsCache = FieldDisplayPropsCache.LoadProjectFieldDisplayProps(project); } var e = s_displayPropsCache.SaveProjectFieldDisplayProps(project); var path = project.ProjectPathFilePrefix + "Fields.xml"; XmlSerializationHelper.SerializeToFile(path, project.Fields.ToList(), "Fields", out e); return(e); }
/// ------------------------------------------------------------------------------------ private static FieldDisplayPropsCache GetDefaultCache() { int displayIndex = 0; var list = from string name in Properties.Settings.Default.DefaultVisibleFields select new PaFieldDisplayProperties(name, true, true) { DisplayIndexInGrid = displayIndex, DisplayIndexInRecView = displayIndex++ }; var cache = new FieldDisplayPropsCache(); cache.AddRange(list); return(cache); }
public static List <PaField> GetProjectFields(PaProject project) { s_displayPropsCache = FieldDisplayPropsCache.LoadProjectFieldDisplayProps(project); if (project.DataSources.Count <= 0) { return(GetDefaultFields()); } Fw7CustomField cusfields = null; foreach (var ds in project.DataSources) { if (cusfields == null) { cusfields = new Fw7CustomField(ds); } else { cusfields.CustomFields.AddRange( new Fw7CustomField(ds).CustomFields.Where(p => cusfields.CustomFields.All(s => s.Name != p.Name))); cusfields.CustomValues.AddRange( new Fw7CustomField(ds).CustomValues.Where(p => cusfields.CustomValues.All(s => s.CustomFields != p.CustomFields))); } } var defaultFields = GetDefaultFields(cusfields); var path = GetFileForProject(project.ProjectPathFilePrefix); if (!File.Exists(path)) { return(defaultFields); } // Go through the project's fields making sure that // all the default fields are contained therein. var fields = LoadFields(path, "Fields", cusfields); foreach (var fld in defaultFields.Where(fld => !fields.Any(f => f.Name == fld.Name))) { fields.Add(fld); } return(fields); }