Esempio n. 1
0
        public DataTable GetRealTimeData(BaseListModel model)
        {
            int page = model.Page;
            int pagesize = model.PageSize;

            //string path = GetXmlFilePath(model);

            //var doc = new XmlDocument();

            //doc.Load(path.Trim());

            //var dt = NTS.WEB.Common.XmlHelper.Query(doc, "RealDataInfo", page, pagesize);
            //return dt;

            #region 测试
            string xml = string.Empty;
            using (ChannelFactory<Framework.Processing.Utility.IRealDataService> channelFactory = new ChannelFactory<Framework.Processing.Utility.IRealDataService>(new WSHttpBinding(), ConfigurationManager.AppSettings["realtimedataurl"]))
            {
                Framework.Processing.Utility.IRealDataService proxy = channelFactory.CreateChannel();
                using (proxy as IDisposable)
                {
                    xml = proxy.GetRealDataByDeviceId(model.ObjectId);
                }
            }

            var doc = new XmlDocument();

            doc.LoadXml(xml);

            var dt = NTS.WEB.Common.XmlHelper.Query(doc, "RealDataInfo", page, pagesize);

            DataTable newdt = new DataTable();
            newdt = dt.Clone();
            DataRow[] rows = dt.Select("DataPoint_Type=" + model.CategoryId);
            foreach (DataRow row in rows)
            {
                newdt.Rows.Add(row.ItemArray);
            }
            return newdt;
            #endregion
        }
Esempio n. 2
0
        private string GetXmlFilePath(BaseListModel model)
        {
            //string filePath = System.AppDomain.CurrentDomain.BaseDirectory + "realdata\\2012-10-19-9-4-27_AI.xml";
            string filePath;
            try
            {
                int sobjectid = model.ObjectId;
                int stype = model.CategoryId;

                string queryString = "sobjectid=" + sobjectid + "&stype=" + stype;
                string queryCache = NTS.WEB.Common.CacheHelper.GetCache("CurQueryString") == null ? "" : NTS.WEB.Common.CacheHelper.GetCache("CurQueryString").ToString();
                object queryPath = NTS.WEB.Common.CacheHelper.GetCache("CurQueryPath");

                if (queryCache != string.Empty && queryPath != null && queryCache == queryString)
                {
                    filePath = queryPath.ToString();
                }
                else
                {

                    var inter = new IRealtimeData();

                    filePath = inter.sergetcurrentdata(sobjectid, 3, stype);

                    if (ConfigurationManager.AppSettings["realtimedataurl"].IndexOf("localhost", System.StringComparison.Ordinal) == -1)
                    {
                        filePath = string.Format("{0}{1}", ConfigurationManager.AppSettings["serverurl"], filePath.Substring(filePath.LastIndexOf("\\", StringComparison.Ordinal)));
                    }
                    NTS.WEB.Common.CacheHelper.SetCache("CurQueryString", queryString);
                    NTS.WEB.Common.CacheHelper.SetCache("CurQueryPath", filePath);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return filePath;
        }
Esempio n. 3
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;
        }