using System; using System.Collections.Generic; namespace TellmePdmsPluging.Models { public class OpenMdbRequest { public string ExecutionId { get; set; } public string execution_id { get { return ExecutionId; } set { ExecutionId = value; } } /// /// MDB name to open /// public string MdbName { get; set; } /// /// If true then all DBs will be opened in read /// public bool ReadOnly { get; set; } /// /// Default database type. e.g. Design /// public string DefaultType { get; set; } /// /// DbTypes to open in read (string form, e.g. ["Design","Catalog"]) /// public List ReadTypes { get { return _readTypes; } set { _readTypes = NormalizeList(value); } } /// /// DbTypes to open in write (string form) /// public List WriteTypes { get { return _writeTypes; } set { _writeTypes = NormalizeList(value); } } /// /// Stamp at which to open the MDB (optional) /// public string Stamp { get; set; } /// /// Subtype, i.e. marine or not (optional) /// public int? Subtype { get; set; } private List _readTypes; private List _writeTypes; public void ApplyDefaults() { MdbName = Normalize(MdbName); DefaultType = Normalize(DefaultType); Stamp = Normalize(Stamp); } private static string Normalize(string value) { if (IsNullOrWhiteSpace(value)) { return null; } return value.Trim(); } private static List NormalizeList(IEnumerable source) { if (source == null) { return null; } var normalized = new List(); foreach (var item in source) { if (IsNullOrWhiteSpace(item)) { continue; } var formatted = item.Trim(); if (!normalized.Contains(formatted)) { normalized.Add(formatted); } } return normalized; } private static bool IsNullOrWhiteSpace(string value) { if (value == null) { return true; } for (int i = 0; i < value.Length; i++) { if (!char.IsWhiteSpace(value[i])) { return false; } } return true; } } public class OpenMdbResult { public bool Success { get; set; } public string Message { get; set; } public string MdbName { get; set; } public bool WasAlreadyOpen { get; set; } public bool ReadOnly { get; set; } public string DefaultType { get; set; } public long FileSize { get; set; } public long PolygonCount { get; set; } public long FeatureCount { get; set; } public DateTime CompletedAt { get; set; } } }