private static bool ParseDO(XDocument doc) { IEnumerable <XElement> xDo = (from x in doc.Descendants() where x.Name.LocalName == "DOType" select x).ToList(); if (!xDo.Any()) { Log.Log.Write("ParseDocunent.ParseDO: DOType == null", "Error "); return(false); } foreach (var DO in xDo) { if (DO.Attribute("id") == null || DO.Attribute("cdc") == null) { Log.Log.Write("ParseDocunent.ParseDO: DO.id == null or DO.cdc", "Error "); return(false); } ServerModel.ListTempDO.Add(new ServerModel.NodeDO(DO.Attribute("id")?.Value, DO.Attribute("cdc")?.Value, DO.Attribute("desc") != null ? DO.Attribute("desc")?.Value : "")); IEnumerable <XElement> xDAElements = (from x in DO.Descendants() where x.Name.LocalName == "DA" select x).ToList(); if (!xDAElements.Any()) { Log.Log.Write("ParseDocunent.ParseDO: DA == null", "Error "); continue; } foreach (var da in xDAElements) { if (da.Attribute("name") != null && da.Attribute("bType")?.Value == "Class") { var nameDA = da.Attribute("name")?.Value; var typeDA = da.Attribute("type") != null?da.Attribute("type")?.Value : da.Parent.Attribute("type") != null?da.Parent.Attribute("type")?.Value : null; ServerModel.ListTempDO.Last().ListDO.Add(new ServerModel.NodeDO(nameDA, typeDA, da.Attribute("desc") != null ? da.Attribute("desc")?.Value : "")); } else { if (da.Attribute("name") == null || da.Attribute("bType") == null || da.Attribute("fc") == null) { Log.Log.Write("ParseDocunent.ParseDO: DA.name == null or DA.bType == null or DA.fc == null", "Warning "); continue; } var nameDA = da.Attribute("name")?.Value; var fcDA = da.Attribute("fc")?.Value; var bTypeDA = da.Attribute("bType")?.Value; var typeDA = da.Attribute("type") != null?da.Attribute("type")?.Value : da.Parent.Attribute("type") != null?da.Parent.Attribute("type")?.Value : null; var trgOpsDA = TriggerOptions.NONE; var countDA = da.Attribute("count") != null?da.Attribute("count")?.Value : "0"; if ((da.Attribute("dchg")?.Value ?? "false").ToLower() == "true") { trgOpsDA |= TriggerOptions.DATA_CHANGED; } if ((da.Attribute("qchg")?.Value ?? "false").ToLower() == "true") { trgOpsDA |= TriggerOptions.QUALITY_CHANGED; } if ((da.Attribute("dupd")?.Value ?? "false").ToLower() == "true") { trgOpsDA |= TriggerOptions.DATA_UPDATE; } ServerModel.ListTempDO.Last().ListDA.Add(new ServerModel.NodeDA(nameDA, fcDA, bTypeDA, typeDA, (byte)trgOpsDA, countDA)); if (da.Value != null) { ServerModel.ListTempDO.Last().ListDA.Last().Value = da.Value; } } } } return(true); }