Esempio n. 1
0
        /// <summary>
        /// Получить список тегов в формате DataMeasurement
        /// </summary>
        /// <param name="list_id"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public List <DataMeasurement> GetDataMeasurement(List <int> list_id, SQLParameter[] sqlparams)
        {
            List <DataMeasurement> list = new List <DataMeasurement>();
            EFDataSources          efds = new EFDataSources();

            List <Tags> list_tags = efds.GetTags(list_id.ToArray()).ToList();

            List <IGrouping <int, Tags> > result = list_tags.GroupBy(t => t.id_dataset).ToList();

            foreach (IGrouping <int, Tags> ds in result)
            {
                DataSources dsc = GetDataSources(ds.Key, sqlparams);
                if (dsc == null)
                {
                    return(null);
                }
                DataTable data = GetDataTable(dsc);
                foreach (Tags tag in ds)
                {
                    try
                    {
                        object val = null;
                        if (data != null && data.Rows.Count > 0)
                        {
                            val = tag.tag.GetExpression(data.Rows[0]);
                        }
                        list.Add(new DataMeasurement()
                        {
                            id                = tag.id,
                            id_dataset        = tag.id_dataset,
                            value_measurement = ((TypeMeasurement)tag.type_measurement).GetDBValueMeasurement(val, tag.tag.Trim(), "", tag.unit, (Multiplier)tag.multiplier)
                        });
                    }
                    catch (Exception e)
                    {
                        e.WriteError(String.Format("Ошибка преобразования тега: id={0}, tag={1} ", tag.id, tag.tag), eventID);
                    }
                }
            }
            return(list);
        }
Esempio n. 2
0
 /// <summary>
 /// Получить список тегов
 /// </summary>
 /// <param name="forms"></param>
 /// <param name="id_objs"></param>
 /// <returns></returns>
 public List <int> GetIDTags(object forms, int[] id_objs)
 {
     try
     {
         List <int>  list     = new List <int>();
         string      xmlforms = ToXMLString(forms);
         XmlDocument doc      = new XmlDocument();
         doc.LoadXml(xmlforms);
         XmlNode       root = doc.DocumentElement;
         XmlNodeList   tags = root.SelectNodes(".//tag");
         EFDataSources efds = new EFDataSources();
         foreach (XmlNode tag in tags)
         {
             if (!String.IsNullOrWhiteSpace(tag.LastChild.InnerText) &&
                 tag.LastChild.InnerText != "0")
             {
                 int  id = int.Parse(tag.LastChild.InnerText);
                 Tags t  = efds.GetTags(id);
                 if (t != null)
                 {
                     int?obj = id_objs.ToList().Find(i => i == t.trobj);
                     if (obj > 0)
                     {
                         list.Add(t.id);
                     }
                 }
             }
         }
         return(list);
     }
     catch (Exception e)
     {
         e.WriteErrorMethod(String.Format("GetIDTags(forms={0}, id_objs={1})", forms, id_objs), eventID);
         return(null);
     }
 }