134 lines
3.4 KiB
C#
134 lines
3.4 KiB
C#
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; } }
|
|
|
|
/// <summary>
|
|
/// MDB name to open
|
|
/// </summary>
|
|
public string MdbName { get; set; }
|
|
|
|
/// <summary>
|
|
/// If true then all DBs will be opened in read
|
|
/// </summary>
|
|
public bool ReadOnly { get; set; }
|
|
|
|
/// <summary>
|
|
/// Default database type. e.g. Design
|
|
/// </summary>
|
|
public string DefaultType { get; set; }
|
|
|
|
/// <summary>
|
|
/// DbTypes to open in read (string form, e.g. ["Design","Catalog"])
|
|
/// </summary>
|
|
public List<string> ReadTypes
|
|
{
|
|
get { return _readTypes; }
|
|
set { _readTypes = NormalizeList(value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// DbTypes to open in write (string form)
|
|
/// </summary>
|
|
public List<string> WriteTypes
|
|
{
|
|
get { return _writeTypes; }
|
|
set { _writeTypes = NormalizeList(value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Stamp at which to open the MDB (optional)
|
|
/// </summary>
|
|
public string Stamp { get; set; }
|
|
|
|
/// <summary>
|
|
/// Subtype, i.e. marine or not (optional)
|
|
/// </summary>
|
|
public int? Subtype { get; set; }
|
|
|
|
private List<string> _readTypes;
|
|
private List<string> _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<string> NormalizeList(IEnumerable<string> source)
|
|
{
|
|
if (source == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
var normalized = new List<string>();
|
|
|
|
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; }
|
|
}
|
|
}
|
|
|