/// <summary> /// IshTypeFieldDefinition creation with the bare descriptive identifiers, defaulting values to AllowOnRead only /// </summary> /// <param name="logger">Instance of the ILogger interface to allow some logging although Write-* is not very thread-friendly.</param> /// <param name="ishType">Card type identifier</param> /// <param name="level">The level of the field on this ISHType (card type)</param> /// <param name="name">The name of the field</param> /// <param name="dataType">The field data type, indicating reference field or simple type</param> internal IshTypeFieldDefinition(ILogger logger, Enumerations.ISHType ishType, Enumerations.Level level, string name, Enumerations.DataType dataType) { _logger = logger; ISHType = ishType; Level = level; Name = name; DataType = dataType; IsMandatory = false; IsMultiValue = false; AllowOnRead = true; AllowOnCreate = false; AllowOnUpdate = false; AllowOnSearch = false; IsSystem = false; IsBasic = false; IsDescriptive = false; Label = ""; Description = ""; ReferenceLov = ""; ReferenceType = new List <Enumerations.ISHType>(); }
/// <summary> /// IshTypeFieldDefinition creation with the full descriptive identifiers /// </summary> /// <param name="logger">Instance of the ILogger interface to allow some logging although Write-* is not very thread-friendly.</param> /// <param name="ishType">Card type identifier</param> /// <param name="level">The level of the field on this ISHType (card type)</param> /// <param name="isMandatory">Boolean attribute indicating whether the field is mandatory or not. </param> /// <param name="isMultiValue">Boolean attribute indicating whether the field can contain multiple values or not. </param> /// <param name="allowOnRead">Boolean attribute indicating whether the field can be passed as filter or passed as requested metadata to an API READ method (e.g. GetMetadata, RetrieveMetadata, Find,...). </param> /// <param name="allowOnCreate">Boolean attribute indicating whether the field can be set via metadata by an API CREATE method. Note: Some fields(e.g.USERNAME) must be passed as a parameter to the CREATE method.So, although these fields are mandatory, they will have allowoncreate false! </param> /// <param name="allowOnUpdate">Boolean attribute indicating whether the field can be set via metadata by an API UPDATE method (e.g. SetMetadata, Update,...). </param> /// <param name="allowOnSearch">Boolean attribute indicating whether the field is part of the full text index and can be used as part of the search query. </param> /// <param name="isSystem">Boolean attribute indicating whether this field is part of the internal Content Manager business logic. </param> /// <param name="isBasic">Boolean attribute indicating whether this field is a basic field (e.g. FSTATUS) or a more advanced field (e.g. FISHSTATUSTYPE). </param> /// <param name="isDescriptive">Boolean attribute indicating whether this field is one of the fields that define an object. Note: These fields are also used by the internal Content Manager business code, therefore they don't require an extra call to the database when requested. </param> /// <param name="name">Name of the card field or the table column.</param> /// <param name="dataType">The field data type, indicating reference field or simple type</param> /// <param name="referenceLov">Lists the referenced list of values name (e.g. USERNAME or DBACKGROUNDTASKSTATUS)</param> /// <param name="description">Free text description, anything which can help an implementor</param> internal IshTypeFieldDefinition(ILogger logger, Enumerations.ISHType ishType, Enumerations.Level level, bool isMandatory, bool isMultiValue, bool allowOnRead, bool allowOnCreate, bool allowOnUpdate, bool allowOnSearch, bool isSystem, bool isBasic, bool isDescriptive, string name, Enumerations.DataType dataType, string referenceLov, string description) { _logger = logger; ISHType = ishType; Level = level; Name = name; DataType = dataType; IsMandatory = isMandatory; IsMultiValue = isMultiValue; AllowOnRead = allowOnRead; AllowOnCreate = allowOnCreate; AllowOnUpdate = allowOnUpdate; AllowOnSearch = allowOnSearch; IsSystem = isSystem; IsBasic = isBasic; IsDescriptive = isDescriptive; Label = ""; Description = description; ReferenceLov = referenceLov; ReferenceType = new List <Enumerations.ISHType>(); }
/// <summary> /// Returns a PSNoteProperty (PSVariable doesn't allow sortable date) /// * Naming convention is lowercase using '=' as separator /// * Levels Lng, None, Task, Progress for ValueType Value are not part of the property name. All the rest is explicit /// Examples /// * e.g. DocumentObj... fauthor, fauthor=lng=value, fauthor=lng=element … modified-on, modified-on=lng=value, modified-on=ver=value, modified-on=log=value /// * e.g. User... level-None types… username, username=none=value, username=none=element /// * e.g. Events... not a card type… userid=progress=value /// </summary> /// <remarks>PSNoteProperty: date fields converting dd/MM/yyyy HH:mm:ss to a sortable format; so ISO8601 (ToString('s', dt)) yyyy'-'MM'-'dd'T'HH':'mm':'ss /// (similar format 'u' add time zone which I consider non-scope for now). Note that TranslationJob's LEASEDON is returned by the API in Utc.</remarks> public PSNoteProperty GetPSNoteProperty(Enumerations.ISHType[] ishTypes, IshMetadataField ishField) { foreach (var ishType in ishTypes) { StringBuilder propertyName = new StringBuilder(); switch (ishType) { default: switch (ishField.Level) { case Enumerations.Level.Lng: case Enumerations.Level.None: case Enumerations.Level.Task: case Enumerations.Level.Progress: // Incoming field "CHECK-OUT" should become "checkout" otherwise PowerShell will enforce single quote around so $ishObject.'check-out' propertyName.Append(ishField.Name.Replace("-", "").ToLower()); switch (ishField.ValueType) { case Enumerations.ValueType.Element: case Enumerations.ValueType.Id: propertyName.Append(_levelNameValueTypeSeparator); propertyName.Append(ishField.Level.ToString().ToLower()); propertyName.Append(_levelNameValueTypeSeparator); propertyName.Append(ishField.ValueType.ToString().ToLower()); break; default: break; } break; default: propertyName.Append(ishField.Name.Replace("-", "").ToLower()); propertyName.Append(_levelNameValueTypeSeparator); propertyName.Append(ishField.Level.ToString().ToLower()); propertyName.Append(_levelNameValueTypeSeparator); propertyName.Append(ishField.ValueType.ToString().ToLower()); break; } break; } string propertyValue = ""; Enumerations.DataType dataType = _ishSession.IshTypeFieldSetup.GetDataType(ishType, ishField); switch (dataType) { // date fields converting dd/MM/yyy HH:mm:ss to a sortable format; either proprietary yyyyMMdd.HHmmss // or ISO8601 (ToString('s', dt)) yyyy-MM-ddTHH:mm:ss (similar format 'u' add time zone which I consider non-scope for now) // Note that TranslationJob's LEASEDON is returned by the API in Utc. case Enumerations.DataType.DateTime: //var formatStrings = new string[] { "dd/MM/yyy HH:mm:ss", "yyyy-MM-dd hh:mm:ss", "dd/MM/yyy" }; DateTime dateTime; if (DateTime.TryParse(ishField.Value, out dateTime)) { propertyValue = dateTime.ToString("s"); } else { propertyValue = ishField.Value; } break; default: propertyValue = ishField.Value; break; } return(new PSNoteProperty(propertyName.ToString(), propertyValue)); } return(new PSNoteProperty("zzzNameHelperError", $"ISHType[{ishTypes}] Level[{ishField.Level.ToString()}] Name[{ishField.Name}] is unknown")); }
private void IsBufferSizeSufficient(Enumerations.DataType dataType) { byte requiredSpace; switch (dataType) { case Enumerations.DataType.DigitalInput: requiredSpace = Constants.DigitalInputSize; break; case Enumerations.DataType.DigitialOutput: requiredSpace = Constants.DigitalOutputSize; break; case Enumerations.DataType.AnalogInput: requiredSpace = Constants.AnalogInputSize; break; case Enumerations.DataType.AnalogOutput: requiredSpace = Constants.AnalogOutputSize; break; case Enumerations.DataType.Luminosity: requiredSpace = Constants.LuminositySize; break; case Enumerations.DataType.Presence: requiredSpace = Constants.PresenceSize; break; case Enumerations.DataType.Temperature: requiredSpace = Constants.TemperatureSize; break; case Enumerations.DataType.RelativeHumidity: requiredSpace = Constants.RelativeHumiditySize; break; case Enumerations.DataType.Accelerometer: requiredSpace = Constants.AccelerometerSize; break; case Enumerations.DataType.BarometricPressure: requiredSpace = Constants.BarometricPressureSize; break; case Enumerations.DataType.Gyrometer: requiredSpace = Constants.GyrometerSize; break; case Enumerations.DataType.Gps: requiredSpace = Constants.GpsSize; break; default: throw new ArgumentException($"DataType {dataType} unknown", "dataType"); } ; if ((index + requiredSpace) > buffer.Length) { throw new ApplicationException($"Datatype {dataType} insufficent buffer capacity, maximum {buffer.Length} bytes"); } }