Ejemplo n.º 1
0
 private IEnumerable <CommenceFieldMetaData> GetFieldMetaData(string categoryName, IEnumerable <string> fields)
 {
     foreach (string fieldName in fields)
     {
         ICommenceFieldDefinition d = _db.GetFieldDefinition(categoryName, fieldName);
         CommenceFieldMetaData    f = new CommenceFieldMetaData(fieldName, d);
         yield return(f);
     }
 }
Ejemplo n.º 2
0
 private IEnumerable <object> GetFields(string categoryName)
 {
     using (ICommenceDatabase db = new CommenceDatabase())
     {
         var fieldNames = db.GetFieldNames(categoryName);
         foreach (string fname in fieldNames)
         {
             ICommenceFieldDefinition fdef = db.GetFieldDefinition(categoryName, fname);
             yield return(new { Name = fname,
                                Combobox = fdef.Combobox,
                                DefaultString = fdef.DefaultString,
                                Mandatory = fdef.Mandatory,
                                MaxChars = fdef.MaxChars,
                                Recurring = fdef.Recurring,
                                Shared = fdef.Shared,
                                Type = fdef.Type });
         }
     }
 }
        /// <summary>
        /// Sets the replacement rules for the fieldtypes.
        /// If no rules are specified, the field will not be processed.
        /// </summary>
        /// <param name="d">Commence field definition</param>
        /// <returns>Dictionary of chars to replace</returns>
        private Dictionary <char, string> GetReplacementCharsForField(ICommenceFieldDefinition d)
        {
            var retval = new Dictionary <char, string>();

            switch (d.Type)
            {
            case CommenceFieldType.Name:
            case CommenceFieldType.Datafile:
            case CommenceFieldType.Telephone:
                retval.Add('\t', " ");
                retval.Add('\n', string.Empty);     // not strictly needed, it just means remove
                retval.Add('\r', string.Empty);
                return(retval);

            case CommenceFieldType.Email:
            case CommenceFieldType.URL:
                retval.Add('\t', string.Empty);
                retval.Add('\n', string.Empty);
                retval.Add('\r', string.Empty);
                return(retval);

            case CommenceFieldType.Text:
                retval.Add('\t', " ");     // debatable but may be useful for tab-delimited exports
                // A Commence large text field that is later reset to a smaller size will retain \r\n
                // in effect it stays a 'Memo' field, only smaller.
                // A text field that started life as a text field cannot have \n or \r written to it
                // not even by copy/paste or API.
                // Therefore, we cannot get information on the field from just
                // looking at its length. Hmm.
                // the only viable way to move forward I think is
                // to remove stand-alone linefeeds (aka Unix-style line-endings)
                retval.Add('\n', "\r\n");
                retval.Add('\r', string.Empty);
                return(retval);

            default:
                return(retval);
            }
        }
 internal CommenceFieldMetaData(string name, ICommenceFieldDefinition definition)
 {
     Name        = name;
     _definition = definition;
 }