Beispiel #1
0
        public string GenerateXml(Scheme scheme, LRSRecord record)
        {
            MemoryStream ms = new MemoryStream();
            XmlWriter xw = XmlWriter.Create(ms);

            xw.WriteStartDocument();
            xw.WriteStartElement("item");

            if (scheme != null)
            {
                foreach (SchemeRecord col in scheme)
                {
                    xw.WriteStartElement(col.ColumnName);
                    string value = record.Columns.SingleOrDefault(x => x.Key.Equals(col.ColumnName)).Value;
                    xw.WriteString(value);
                    xw.WriteEndElement();
                }
            }

            xw.WriteEndElement();
            xw.WriteEndDocument();

            xw.Flush();

            Byte[] buffer = new Byte[ms.Length];
            buffer = ms.ToArray();

            string xmlOutput = Encoding.UTF8.GetString(buffer);

            return xmlOutput;
        }
Beispiel #2
0
 public bool Contains(LRSRecord item)
 {
     return this.List.Contains(item);
 }
Beispiel #3
0
 public int Add(LRSRecord item)
 {
     return this.List.Add(item);
 }
        public LRSRecords GetSegmentLRSSummary(int schemeId, int segmentId)
        {
            LRSRecords records = new LRSRecords();
            LRSRecord record;

            using (SqlCommand command = new SqlCommand("[RTP].[GetSegmentLRSSummaryData]") { CommandType = CommandType.StoredProcedure })
            {
                command.Parameters.AddWithValue("@LRSSchemeId", schemeId);
                command.Parameters.AddWithValue("@SegmentId", segmentId);

                using (IDataReader rdr = ExecuteReader(command))
                {
                    while (rdr.Read())
                    {
                        record = new LRSRecord() { Columns = new Dictionary<string, string>() };
                        record.Id = rdr["Id"].ToString().SmartParseDefault<int>(default(int));
                        record.Columns.Add("Routename", rdr["Routename"].ToString());
                        record.Columns.Add("BEGINMEASU", rdr["BEGINMEASU"].ToString());
                        record.Columns.Add("ENDMEASURE", rdr["ENDMEASURE"].ToString());
                        record.Scheme = GetLRSScheme(schemeId);
                        records.Add(record);

                        //if (record.Id.Equals(default(int))) { record.Id = rdr["Id"].ToString().SmartParseDefault<int>(default(int)); }
                        //record.Columns.Add(rdr["NodeName"].ToString(), rdr["Value"].ToString());
                    }
                }
            }
            return records;
        }
        public LRSRecord GetSegmentLRSData(int schemeId, int LRSId)
        {
            LRSRecord record = new LRSRecord() { Columns = new Dictionary<string, string>() };

            using (SqlCommand command = new SqlCommand("[RTP].[GetSegmentLRSData]") { CommandType = CommandType.StoredProcedure })
            {
                command.Parameters.AddWithValue("@LRSSchemeId", schemeId);
                command.Parameters.AddWithValue("@LRSId", LRSId);

                using (IDataReader rdr = ExecuteReader(command))
                {
                    while (rdr.Read())
                    {
                        if (record.Id.Equals(default(int))) { record.Id = rdr["Id"].ToString().SmartParseDefault<int>(default(int)); }
                        record.Columns.Add(rdr["NodeName"].ToString(), rdr["Value"].ToString());
                    }
                }
                record.Scheme = GetLRSScheme(schemeId);
            }
            return record;
        }