/// <summary> /// Updates the EDMPROP element with the Extended Data associated with the specified WFM node. /// </summary> /// <param name="element">The element.</param> /// <param name="node">A WFM node object representing a Work Request, Design, Work Location, or Compatible Unit.</param> private void UpdateEdm(IXMLDOMElement element, IMMWMSNode node) { IMMWMSWorkRequest workRequest = node as IMMWMSWorkRequest; if (workRequest != null) { this.SetProperty(element, _EdmRepository.WorkRequest, string.Format(CultureInfo.InvariantCulture, "{0} = {1}", Fields.WorkRequestID, workRequest.ID)); } else { IMMWMSDesign design = node as IMMWMSDesign; if (design != null) { this.SetProperty(element, _EdmRepository.Design, string.Format(CultureInfo.InvariantCulture, "{0} = {1}", Fields.DesignID, design.ID)); } else { IMMWMSWorklocation workLocation = node as IMMWMSWorklocation; if (workLocation != null) { this.SetProperty(element, _EdmRepository.WorkLocation, string.Format(CultureInfo.InvariantCulture, "{0} = {1}", Fields.WorkLocationID, workLocation.ID)); } else { IMMWMSCompatibleUnit compatibleUnit = node as IMMWMSCompatibleUnit; if (compatibleUnit != null) { this.SetProperty(element, _EdmRepository.CompatibleUnit, string.Format(CultureInfo.InvariantCulture, "{0} = {1}", Fields.CompatibleUnitID, compatibleUnit.ID)); } } } } }
/// <summary> /// This will save the given node and edm struct data into the correct configured edm tables. /// </summary> /// <param name="node">IMMWMSNode which can be the WorkRequest, Design, WorkLocation, or CU.</param> /// <param name="edm">EDM struct containing the data.</param> private void Save(IMMWMSNode node, EDM edm) { string sql = null; EdmTable table = null; IMMWMSWorkRequest workRequest = node as IMMWMSWorkRequest; if (workRequest != null) // WorkRequest { table = _EdmRepository.WorkRequest; sql = string.Format(CultureInfo.InvariantCulture, "INSERT INTO {0} ({1},{2},{3},{4},{5}) VALUES ({6}, {7},'{8}','{9}','{10}')", "{0}", Fields.WorkRequestID, Fields.DesignID, EDM.Fields.Name, EDM.Fields.Value, EDM.Fields.Type, workRequest.ID, _ID, edm.Name, edm.Value, edm.Type); } else { IMMWMSDesign design = node as IMMWMSDesign; if (design != null) // Design { table = _EdmRepository.Design; sql = string.Format(CultureInfo.InvariantCulture, "INSERT INTO {0} ({1},{2},{3},{4}) VALUES ({5}, {6},'{7}','{8}', '{9}')", "{0}", Fields.DesignID, EDM.Fields.Name, EDM.Fields.Value, EDM.Fields.Type, design.ID, _ID, edm.Name, edm.Value, edm.Type); } else { IMMWMSWorklocation workLocation = node as IMMWMSWorklocation; if (workLocation != null) // WorkLocation { table = _EdmRepository.WorkLocation; sql = string.Format(CultureInfo.InvariantCulture, "INSERT INTO {0} ({1},{2},{3},{4},{5}) VALUES ({6}, {7},'{8}','{9}','{10}')", "{0}", Fields.WorkLocationID, Fields.DesignID, EDM.Fields.Name, EDM.Fields.Value, EDM.Fields.Type, workLocation.ID, _ID, edm.Name, edm.Value, edm.Type); } else { IMMWMSCompatibleUnit compatibleUnit = node as IMMWMSCompatibleUnit; if (compatibleUnit != null) // CompatibleUnit { table = _EdmRepository.CompatibleUnit; sql = string.Format(CultureInfo.InvariantCulture, "INSERT INTO {0} ({1},{2},{3},{4},{5}) VALUES ({6}, {7},'{8}','{9}','{10}')", "{0}", Fields.CompatibleUnitID, Fields.DesignID, EDM.Fields.Name, EDM.Fields.Value, EDM.Fields.Type, compatibleUnit.ID, _ID, edm.Name, edm.Value, edm.Type); } } } } // Insert the EDM when the table is valid. if (table != null && table.Valid) { // Check to see that the field is not being excluded. if (table.Fields.Count(o => o.Name.Equals(edm.Name, StringComparison.OrdinalIgnoreCase)) == 0) { // Add the EDM record into the table. _PxApp.ExecuteNonQuery(string.Format(CultureInfo.InvariantCulture, sql, _PxApp.GetQualifiedTableName(table.TableName))); } } }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"> /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only /// unmanaged resources. /// </param> protected virtual void Dispose(bool disposing) { if (disposing) { if (this.Node != null) { while (Marshal.ReleaseComObject(this.Node) > 0) { // Loop until reference counter zero. } } this.Node = null; } }
/// <summary> /// Saves Extended Data for the specified element. /// </summary> /// <param name="wmsNode">The WFM object being processed (Work Request, Design, Work Location, or Compatible Unit).</param> /// <param name="edmNode">The "EDM" XML element from the design XML that corresponds to the WFM object.</param> public virtual void WriteEDMFromXML(IMMWMSNode wmsNode, IXMLDOMNode edmNode) { if (_EdmRepository == null || edmNode == null) { return; } // If design not valid exit. if (!this.IsValid(wmsNode)) { return; } // Remove any existing Extended Data rows, if necessary. if (!_IsDeleted) { // Delete all the EDM data from the Work Request, Design, Work Locaiton and CUs associated with the current design id. this.Delete(_ID); // Update the flag. _IsDeleted = true; } // Iterate through each of the Extended Data properties associated with the node and save non Site-Condition EDM to EDM tables. IXMLDOMNodeList nodelist = edmNode.selectNodes("EDMPROP"); foreach (IXMLDOMNode node in nodelist) { EDM edm = new EDM(); edm.Name = node.attributes.getNamedItem("Name").text; edm.Value = node.text; edm.Type = node.attributes.getNamedItem("Type").text; if (_EdmRepository.Type.Equals(edm.Type, StringComparison.OrdinalIgnoreCase)) { this.Save(wmsNode, edm); } } // Use the OOTB component to save Site Condition info. _WmsExtendedData.WriteEDMFromXML(wmsNode, edmNode); }
/// <summary> /// Determines if the node is valid, which means it needs to have a design id > 0. /// </summary> /// <param name="node">IMMWMSNode which can be the WorkRequest, Design, WorkLocation, or CU.</param> /// <returns>Returns true if this node has a valid IMMWMSDesign ID</returns> private bool IsValid(IMMWMSNode node) { // The design node should be the first node passed to this component (even before the Work Request). if (_ID != 0) { return(true); } IMMWMSDesign design = node as IMMWMSDesign; if (design != null) { _ID = design.ID; } else { return(false); } return(_ID != 0); }
/// <summary> /// Returns the "EDM" node and child EDMPROP elements containing Extended Data associated with the specified WFM node. /// </summary> /// <param name="wmsNode">A WFM node object representing a Work Request, Design, Work Location, or Compatible Unit.</param> /// <returns>An XML element corresponding to the "EDM" structure.</returns> public virtual IXMLDOMNode GetEDMAsXML(IMMWMSNode wmsNode) { if (_EdmRepository == null) { return(null); } // If design not valid exit. if (!this.IsValid(wmsNode)) { return(null); } // Only load the data from the Extended Data tables once. this.Load(); // Call the OOTB EDM component to get any Site Condition data. IXMLDOMNode node = _WmsExtendedData.GetEDMAsXML(wmsNode); IXMLDOMElement element; if (node == null) { // Create the base "EDM" element. IXMLDOMDocument dom = new DOMDocumentClass(); element = dom.createElement("EDM"); dom.documentElement = element; node = element; } else { element = (IXMLDOMElement)node; } // Set the appropriate EDM Property data. this.UpdateEdm(element, wmsNode); // Return the updated node. return(node); }
/// <summary> /// Initializes a new instance of the <see cref="BaseWMSNode" /> class. /// </summary> /// <param name="node">The node.</param> protected BaseWMSNode(IMMWMSNode node) { this.Node = node; }