/// <summary> /// Constructor. /// </summary> /// <param name="proxy">XML proxy.</param> /// <exception cref="XNeut.InvalidMessageException">Thrown if an error is encountered.</exception> internal QuantityValue(XsdNs.QuantityValueType proxy) { // Quantity string if (proxy.QuantityString == null) { throw new XNeut.InvalidMessageException("Quantity value is required"); } RawQuantityString = string.IsNullOrEmpty(proxy.QuantityString.Value) ? "" : proxy.QuantityString.Value; // Data type if (proxy.DataType != null) { DataType = new DataType(proxy.DataType); // throws InvalidMessageException } else { DataType = null; } // Unit of measure UnitOfMeasure = proxy.UnitOfMeasure?.Value; // Key if (proxy.Key != null) { Key = new IdentifierType(proxy.Key); } else { Key = null; } }
/// <summary> /// Constructor. /// </summary> /// <param name="eqId">Equipment identifier.</param> /// <param name="lev">Equipment element level.</param> /// <exception cref="ArgumentException">Thrown if equipment ID is null.</exception> public HierarchyScope(IdentifierType eqId, EquipmentElementLevelType lev) { if (eqId == null || eqId.Value == null) { throw new ArgumentException("Equipment ID must not be null in hierarchy scope"); } EquipmentIdentifier = eqId; EquipmentElementLevel = lev; }
/// <summary> /// Constructor. /// </summary> /// <param name="proxy">XML proxy.</param> /// <exception cref="XNeut.InvalidMessageException">Thrown if an error is encountered.</exception> internal ProductionRequest(XsdNs.ProductionRequestType proxy) { SegmentRequirements = new List <SegmentRequirement>(); try { // Read identifier if (proxy.ID != null) { Identifier = new IdentifierType(proxy.ID); } // Read hierarchy scope if (proxy.HierarchyScope != null) { HierarchyScopeObj = new HierarchyScope(proxy.HierarchyScope); // throws InvalidMessageException } // Read segment requirements if (proxy.SegmentRequirement != null) { foreach (var segReq in proxy.SegmentRequirement) { SegmentRequirements.Add(new SegmentRequirement(segReq)); // throws InvalidMessageException } } // Read scheduling parameters if (proxy.SchedulingParameters != null) { try { // Expecting a data record in an XML node array SchedulingParameters = (SXml.XmlNode[])proxy.SchedulingParameters; } catch (InvalidCastException e) { throw new XNeut.InvalidMessageException("Unexpected type of scheduling parameters", e); } } } catch (NullReferenceException e) { var msg = string.Format("Failed to read ProductionRequest {0} - something required is missing", TryGetIdString()); throw new XNeut.InvalidMessageException(msg, e); } catch (XNeut.InvalidMessageException e) { var msg = string.Format("Failed to read ProductionRequest {0}: {1}", TryGetIdString(), e.Message); throw new XNeut.InvalidMessageException(msg, e); } }
/// <summary> /// Constructor. /// </summary> /// <param name="proxy">XML proxy.</param> /// <exception cref="XNeut.InvalidMessageException">Thrown if an error is encountered.</exception> internal SegmentRequirement(XsdNs.SegmentRequirementType proxy) : this() // Call the default constructor { try { if (proxy.ProcessSegmentID != null) { ProcessSegmentIdentifier = new IdentifierType(proxy.ProcessSegmentID); } m_earliestStartTime = TryGetTime(proxy.EarliestStartTime); m_latestEndTime = TryGetTime(proxy.LatestEndTime); // Check if end is before start if (m_earliestStartTime.HasValue && m_latestEndTime.HasValue && m_earliestStartTime.Value > m_latestEndTime.Value) { var msg = string.Format("Segment end must not be before start; start at {0} UTC", m_earliestStartTime.Value.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.fff")); throw new XNeut.InvalidMessageException(msg); } if (proxy.EquipmentRequirement != null) { foreach (var req in proxy.EquipmentRequirement) { EquipmentRequirements.Add(new EquipmentRequirement(req)); // throws InvalidMessageException } } if (proxy.MaterialRequirement != null) { foreach (var req in proxy.MaterialRequirement) { MaterialRequirements.Add(new MaterialRequirement(req)); // throws InvalidMessageException } } if (proxy.SegmentRequirement != null) { foreach (var req in proxy.SegmentRequirement) { SegmentRequirements.Add(new SegmentRequirement(req)); // throws InvalidMessageException } } } catch (NullReferenceException e) { throw new XNeut.InvalidMessageException("Failed to read SegmentRequirement - something required is missing", e); } }
/// <summary> /// Constructor. /// </summary> /// <param name="proxy">XML proxy.</param> /// <exception cref="XNeut.InvalidMessageException">Thrown if an error is encountered.</exception> internal HierarchyScope(XsdNs.HierarchyScopeType proxy) { try { EquipmentIdentifier = new IdentifierType(proxy.EquipmentID); // throws InvalidMessageException string eqLevRaw = proxy.EquipmentElementLevel.Value; EquipmentElementLevel = (EquipmentElementLevelType)Enum.Parse(typeof(EquipmentElementLevelType), eqLevRaw); } catch (ArgumentException e) { throw new XNeut.InvalidMessageException("Invalid equipment element level", e); } catch (NullReferenceException e) { throw new XNeut.InvalidMessageException("Failed to read HierarchyScope - something expected is missing", e); } }