예제 #1
0
 public Reco3Component(Reco3Component pSrcComponent)
 {
     PDNumber            = pSrcComponent.PDNumber;
     PD_Source           = PDSource.ctYDMC;
     DownloadedTimestamp = DateTime.Now;
     Description         = pSrcComponent.Description;
     PD_Status           = PDStatus.ctUnknown;
     Component_Type      = pSrcComponent.Component_Type;
     SourceComponentId   = pSrcComponent.ComponentId;
     XML = pSrcComponent.XML;
 }
예제 #2
0
        protected void ReplacePDNodeWithComponent(ref XElement pdNode, string strNodeLocalName, string strPdNumber, bool bAddAsChildInsteadOfReplace,
                                                  Scania.Baseline.vehiclesVehicle vehicle, ref bool bContainsImprovements)
        {
            try
            {
                Reco3Component job = GetComponent(vehicle, strPdNumber, ref bContainsImprovements);
                if (job == null)
                {
                    throw new ConverterException("Failed to obtain a (" + strNodeLocalName + ") pd for PDID: " + strPdNumber);
                }


                XElement componentWithoutNamespace = job.XmlElement.ParseXsltTransform(RemoveNamespaces);
                if (componentWithoutNamespace == null)
                {
                    throw new ConverterException("Failed to remove namespaces from component (" + strNodeLocalName + ") .");
                }
                componentWithoutNamespace.SetDefaultNamespace(pdNode.GetDefaultNamespace());
                var components = componentWithoutNamespace.Descendants(CurrentNamespace + strNodeLocalName).FirstOrDefault();
                if (components == null)
                {
                    components = componentWithoutNamespace.Descendants(strNodeLocalName).FirstOrDefault();
                }
                if (EnsureSignatureIsPresent == true)
                {
                    // Check to see that the component being loaded contains a signature, if not add!
                    var signatureNode = components.Descendants(CurrentNamespace + "Signature").FirstOrDefault();
                    if (signatureNode == null)
                    {
                        components.Add(Signature);
                    }
                    else
                    {
                        signatureNode.ReplaceWith(Signature);
                    }
                }
                if (bAddAsChildInsteadOfReplace == true)
                {
                    pdNode.Add(components);
                }
                else
                {
                    pdNode.ReplaceWith(components);
                }
            }
            catch (Exception ex)
            {
                throw new ConverterException("Failed to patch <Components:  (" + strNodeLocalName + ") >: PDID: " + strPdNumber, ex);
            }
        }
예제 #3
0
        public Reco3Component CloneComponent(int nComponentId)
        {
            try {
                Reco3Component sourceComponent = this.Reco3Components.Where(x => x.ComponentId == nComponentId).FirstOrDefault();
                if (sourceComponent != null)
                {
                    Reco3Component targetComponent = new Reco3Component(sourceComponent);
                    this.Reco3Components.Add(targetComponent);
                    this.SaveChanges();
                    return(targetComponent);
                }
            }
            catch {
            }

            return(null);
        }