Пример #1
0
        /// <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)));
                }
            }
        }
Пример #2
0
        /// <summary>
        ///     Determines whether the specified <see cref="object" /> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="object" /> to compare with this instance.</param>
        /// <returns>
        ///     <c>true</c> if the specified <see cref="object" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (!(obj is EDM))
            {
                return(false);
            }

            EDM other = (EDM)obj;

            return(string.Equals(this.Name, other.Name, StringComparison.OrdinalIgnoreCase) &&
                   string.Equals(this.Value, other.Value, StringComparison.OrdinalIgnoreCase) &&
                   string.Equals(this.Type, other.Type, StringComparison.OrdinalIgnoreCase));
        }
Пример #3
0
        /// <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);
        }
Пример #4
0
        /// <summary>
        ///     Given the <paramref name="element" /> and the <paramref name="edmTable" /> and
        ///     all of the records that satsify the <paramref name="filter" /> will be added as EDMPROP elements in the document
        ///     from the table.
        /// </summary>
        /// <param name="element">IXMLDOMElement of the current xml document.</param>
        /// <param name="edmTable">The edm table.</param>
        /// <param name="filter">Filter used to narrow down the table search.</param>
        private void SetProperty(IXMLDOMElement element, EdmTable edmTable, string filter)
        {
            // Obtain all of the rows the satisfy the given filter.
            IEnumerable <DataRow> rows = this.GetRows(edmTable, filter);

            if (rows == null)
            {
                return;
            }

            // Iterate through all of the rows.
            foreach (DataRow row in rows)
            {
                EDM            edm     = new EDM(row);
                IXMLDOMElement edmprop = element.ownerDocument.createElement("EDMPROP");
                edmprop.setAttribute("Name", edm.Name);
                edmprop.setAttribute("Type", edm.Type);
                edmprop.text = edm.Value;
                element.appendChild(edmprop);
            }
        }