using System.Text; using WebDoorCreator.Data.DbModels; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; namespace WebDoorCreator.Data.DTO { [Serializable] public class DDFDto { #region Public Constructors public DDFDto() { } #endregion Public Constructors #region Public Properties public string version { get; set; } = "0"; public bool produce { get; set; } = true; public string measures { get; set; } = "inches"; public string code { get; set; } = "0015943"; public OrderDto order { get; set; } = new OrderDto(); public DateTime date { get; set; } = DateTime.Today.Date; public string piece { get; set; } = "DO_1"; #endregion Public Properties #region Public Methods /// /// Restituisce conf serializzata in formato YAML /// /// public string GetObjYaml() { var serializer = new SerializerBuilder() .WithNamingConvention(CamelCaseNamingConvention.Instance) .Build(); var rawdata = serializer.Serialize(this); return rawdata; } /// /// Scrive conf serializzata in formato YAML /// /// /// /// /// /// /// /// /// public string GetSerialized(List headRows, List footRows, string serialDoorOps, string serialEdges, string serialSize, string serialSwing, string serialProperties, string serialFinishing) { string fullData = ""; StringBuilder sb = new StringBuilder(); try { // header! if (headRows != null && headRows.Count > 0) { sb = new StringBuilder(); foreach (var row in headRows) { sb.AppendLine(row); } fullData = sb.ToString(); } // obj principale var currYaml = GetObjYaml(); fullData += currYaml; #if false // aggiungo la parte woodType come yaml reale/striped... if (!string.IsNullOrEmpty(serialProperties)) { fullData += serialProperties; } // aggiungo la parte finishing come yaml reale/striped... if (!string.IsNullOrEmpty(serialFinishing)) { fullData += serialFinishing; } #endif // aggiungo la parte size come yaml reale/striped... if (!string.IsNullOrEmpty(serialSize)) { fullData += serialSize; } // aggiungo la parte swing come yaml reale/striped... if (!string.IsNullOrEmpty(serialSwing)) { fullData += serialSwing; } // aggiungo la parte profiles come yaml reale/striped... if (!string.IsNullOrEmpty(serialEdges)) { fullData += serialEdges; } // aggiungo la parte doorOp come yaml reale/striped... if (!string.IsNullOrEmpty(serialDoorOps)) { fullData += serialDoorOps; } // footer! if (footRows != null && footRows.Count > 0) { sb = new StringBuilder(); foreach (var row in footRows) { sb.AppendLine(row); } fullData += sb.ToString(); } } catch { } return fullData; } #endregion Public Methods } }