private void ParsePlanVersion(XmlReader rdr, WellInfo wi, string planName) { while (rdr.Read()) { if (rdr.IsStartElement()) { if (rdr.Name == "VersionInfo") { PlanVersionInfo pvi = new PlanVersionInfo { PlanName = planName, VersionName = rdr.GetAttribute("versionName"), Comment = rdr.GetAttribute("comment"), IsCurrentPlan = false }; DateTime.TryParse(rdr.GetAttribute("versionDateCreated"), out var creationDate); pvi.CreationDate = creationDate; bool.TryParse(rdr.GetAttribute("isDefinitivePlan"), out bool isDefinitivePlan); pvi.IsDefinitivePlan = isDefinitivePlan; wi.PlanVersionList.Add(pvi); } } } }
private List <PlanVersionInfo> GetPlanDataByWellID(int wellID) { var recordList = new List <PlanVersionInfo>(); using (var conn = new SQLiteConnection(ConnectionString, true)) { conn.Open(); using (var cmd = new SQLiteCommand(conn)) { cmd.CommandText = "SELECT * FROM [PlanVersions] WHERE [WellID]=$wellID ORDER BY [CreationDate] DESC, [VersionName] DESC "; cmd.Parameters.AddWithValue("$wellID", wellID); using (var rdr = cmd.ExecuteReader()) { while (rdr.Read()) { var record = new PlanVersionInfo { PlanName = rdr["PlanName"].ToString(), VersionName = rdr["VersionName"].ToString(), Comment = rdr["Comment"].ToString(), CreationDate = DateTime.Parse(rdr["CreationDate"].ToString()), IsCurrentPlan = Convert.ToInt32(rdr["IsCurrent"]) != 0, IsDefinitivePlan = Convert.ToInt32(rdr["IsDefinitive"]) != 0 }; recordList.Add(record); } } } } return(recordList); }