Esempio n. 1
0
        public ResultReal GetRealTime(NTS.WEB.DataContact.RealQuery query)
        {
            ResultReal result = new ResultReal();

            var objectList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(string.Format(" and deviceid={0}", query.ObjectId), " order by deviceid");
            var itemList   = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + objectList[0].ItemCodeID + "'", " order by ItemcodeID")[0];

            result.Info = new DeviceInfo();
            result.Data = new RealData();
            result.Info.Affiliations = objectList[0].Organization;
            result.Info.DevType      = objectList[0].DeviceType.ToString(CultureInfo.InvariantCulture);
            result.Info.Category     = (itemList.ItemCodeNumber == "01000" || itemList.ItemCodeNumber == "01A00" ||
                                        itemList.ItemCodeNumber == "01B00" || itemList.ItemCodeNumber == "01C00" ||
                                        itemList.ItemCodeNumber == "01D00")
                                     ? "电表"
                                     : itemList.ItemCodeName + "表";
            result.Info.Nature   = objectList[0].DEVMODE;
            result.Info.Number   = objectList[0].DeviceNumber;
            result.Info.Status   = objectList[0].Status;
            result.Info.Location = objectList[0].Location;
            result.Info.Rating   = objectList[0].Rating.ToString();
            if (query.IsDetail == 1)
            {
                for (int i = 1; i < 4; i++)
                {
                    BaseListModel model = new BaseListModel();
                    model.Page       = 1;
                    model.PageSize   = 10000;
                    model.ObjectId   = objectList[0].DeviceID;
                    model.CategoryId = i;
                    DataTable dt = new Real().GetRealTimeData(model);
                    if (dt.Rows.Count > 0)
                    {
                        if (i == 1)
                        {
                            result.Data.Pulse = new List <dataUnit>();
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {
                                result.Data.Pulse.Add(new dataUnit()
                                {
                                    Id       = j + 1,
                                    DataName = dt.Rows[j]["DataPoint_Name"].ToString(),
                                    Unit     = itemList.Unit,
                                    Value    = decimal.Parse(dt.Rows[j]["Result"].ToString())
                                });
                            }
                        }
                        else if (i == 2)
                        {
                            result.Data.Analog = new List <dataUnit>();
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {
                                result.Data.Analog.Add(new dataUnit()
                                {
                                    Id       = j + 1,
                                    DataName = dt.Rows[j]["DataPoint_Name"].ToString(),
                                    Unit     = itemList.Unit,
                                    Value    = decimal.Parse(dt.Rows[j]["Result"].ToString())
                                });
                            }
                        }
                        else
                        {
                            result.Data.Switch = new List <dataUnit>();
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {
                                result.Data.Switch.Add(new dataUnit()
                                {
                                    Id       = j + 1,
                                    DataName = dt.Rows[j]["DataPoint_Name"].ToString(),
                                    Unit     = itemList.Unit,
                                    Value    = decimal.Parse(dt.Rows[j]["Result"].ToString())
                                });
                            }
                        }
                    }
                }
            }

            //result.Data.Analog = new List<dataUnit>();
            //result.Data.Analog.Add(new dataUnit() { Id = 1, DataName = "29189H92-00", Unit = "kwh", Value = 900.88m });
            //result.Data.Pulse = new List<dataUnit>();
            //result.Data.Pulse.Add(new dataUnit() { Id = 1, DataName = "29189H92-10", Unit = "kwh", Value = 400.88m });
            //result.Data.Switch = new List<dataUnit>();
            //result.Data.Switch.Add(new dataUnit() { Id = 1, DataName = "29189H92-20", Unit = "kwh", Value = 200.88m });
            return(result);
        }
Esempio n. 2
0
        public ResultReal GetRealTime(NTS.WEB.DataContact.RealQuery query)
        {
            ResultReal result = new ResultReal();

            var objectList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(string.Format(" and deviceid={0}", query.ObjectId), " order by deviceid");
            var itemList = new BLL.Itemcode().GetItemcodeList(" and ItemCodeNumber='" + objectList[0].ItemCodeID + "'", " order by ItemcodeID")[0];

            result.Info = new DeviceInfo();
            result.Data = new RealData();
            result.Info.Affiliations = objectList[0].Organization;
            result.Info.DevType = objectList[0].DeviceType.ToString(CultureInfo.InvariantCulture);
            result.Info.Category = (itemList.ItemCodeNumber == "01000" || itemList.ItemCodeNumber == "01A00" ||
                                  itemList.ItemCodeNumber == "01B00" || itemList.ItemCodeNumber == "01C00" ||
                                  itemList.ItemCodeNumber == "01D00")
                                     ? "电表"
                                     : itemList.ItemCodeName + "表";
            result.Info.Nature = objectList[0].DEVMODE;
            result.Info.Number = objectList[0].DeviceNumber;
            result.Info.Status = objectList[0].Status;
            result.Info.Location = objectList[0].Location;
            result.Info.Rating = objectList[0].Rating.ToString();
            if (query.IsDetail == 1)
            {
                for (int i = 1; i < 4; i++)
                {
                    BaseListModel model = new BaseListModel();
                    model.Page = 1;
                    model.PageSize = 10000;
                    model.ObjectId = objectList[0].DeviceID;
                    model.CategoryId = i;
                    DataTable dt = new Real().GetRealTimeData(model);
                    if (dt.Rows.Count > 0)
                    {

                        if (i == 1)
                        {
                            result.Data.Pulse = new List<dataUnit>();
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {
                                result.Data.Pulse.Add(new dataUnit()
                                    {
                                        Id = j + 1,
                                        DataName = dt.Rows[j]["DataPoint_Name"].ToString(),
                                        Unit = itemList.Unit,
                                        Value = decimal.Parse(dt.Rows[j]["Result"].ToString())
                                    });
                            }
                        }
                        else if (i == 2)
                        {
                            result.Data.Analog = new List<dataUnit>();
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {

                                result.Data.Analog.Add(new dataUnit()
                                    {
                                        Id = j + 1,
                                        DataName = dt.Rows[j]["DataPoint_Name"].ToString(),
                                        Unit = itemList.Unit,
                                        Value = decimal.Parse(dt.Rows[j]["Result"].ToString())
                                    });
                            }
                        }
                        else
                        {
                            result.Data.Switch = new List<dataUnit>();
                            for (int j = 0; j < dt.Rows.Count; j++)
                            {
                                result.Data.Switch.Add(new dataUnit()
                                    {
                                        Id = j + 1,
                                        DataName = dt.Rows[j]["DataPoint_Name"].ToString(),
                                        Unit = itemList.Unit,
                                        Value = decimal.Parse(dt.Rows[j]["Result"].ToString())
                                    });
                            }
                        }
                    }
                }
            }

            //result.Data.Analog = new List<dataUnit>();
            //result.Data.Analog.Add(new dataUnit() { Id = 1, DataName = "29189H92-00", Unit = "kwh", Value = 900.88m });
            //result.Data.Pulse = new List<dataUnit>();
            //result.Data.Pulse.Add(new dataUnit() { Id = 1, DataName = "29189H92-10", Unit = "kwh", Value = 400.88m });
            //result.Data.Switch = new List<dataUnit>();
            //result.Data.Switch.Add(new dataUnit() { Id = 1, DataName = "29189H92-20", Unit = "kwh", Value = 200.88m });
            return result;
        }