/// <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); }
public void OnSaveRequest(SaveEvent e) { //1. Validation //Most of validations are completed by the validation rule in design mode //a. Validate the SubmitAnswers button //1)There is one SubmitAnswers button on the active pages //2)There is only one SubmitAnswers button on the active pages //3)That page must be the last page IXMLDOMNodeList endQuizPages = this.thisXDocument.DOM.selectNodes("//Complete/Page[@IsActive='true' and .//SubmitAnswers]"); //1) no SubmitAnswers control if (endQuizPages.length == 0) { this.thisXDocument.UI.Alert("This form contains the following validation errors:\n\nThere is no SubmitAnswers control, this control must be on the last active page.\n"); e.ReturnStatus = true; return; } //2) More that 1 SubmitAnswers control else if (endQuizPages.length > 1) { this.thisXDocument.UI.Alert("This form contains the following validation errors:\n\nSubmitAnswers control is on more than one active pages, this control can only be on the last active page.\n"); e.ReturnStatus = true; return; } //One SubmitAnswers control else { IXMLDOMNode endControlPage = endQuizPages[0]; //3) Is this page the last active page? IXMLDOMNodeList followingSiblingPages = endControlPage.selectNodes("following-sibling::Page[@IsActive='true']"); if (followingSiblingPages.length > 0) { this.thisXDocument.UI.Alert("This form contains the following validation errors:\n\nSubmitAnswers control is on other active page, this control can only be on the last active page.\n"); e.ReturnStatus = true; return; } } //2. Set the quiz ID as the default new file name if (e.IsSaveAs || this.thisXDocument.IsNew) { IXMLDOMNode node = this.thisXDocument.DOM.selectSingleNode("//Summary/@ID"); this.thisXDocument.UI.SetSaveAsDialogFileName(node.text); } //3. If the form is modified, set the last modified data if (!this.thisXDocument.IsNew) { IXMLDOMNode lastModifiedBy = this.thisXDocument.DOM.selectSingleNode("//Summary/LastModifiedBy"); IXMLDOMNode lastModifiedDate = this.thisXDocument.DOM.selectSingleNode("//Summary/LastModifiedDate"); lastModifiedBy.text = System.Environment.UserName; //Determine whether the xsi:nil attribute is set for this //element. If so, remove the xsi:nil attributes so that //the value can be set. if (lastModifiedDate.attributes.getNamedItem("xsi:nil") != null) { lastModifiedDate.attributes.removeNamedItem("xsi:nil"); } lastModifiedDate.text = DateTime.Now.ToString("s"); } e.IsCancelled = e.PerformSaveOperation(); // Write the code to be run after saving here. e.ReturnStatus = true; }