public RenderResult GenerateRenderResult(DateTime from, DateTime to, bool isRealTime)
        {
            GraphicsLayer layer;

            if (isRealTime)
            {
                var entity = new HydrologicReader().RetrieveEntity(from, to);
                //var entity = FakeDataSource();

                layer = GenerateGraphicLayer(entity);
            }
            else
            {
                var entity = new HydrologicReader().RetrieveHisEntity(from, to);
                //var entity = FakeDataSource();

                layer = GenerateGraphicLayer(entity);
            }


            var labelListSetting = GenerateDefaultLabelSetting();

            layer.Labeling    = GenerateLabelProperties(labelListSetting);
            layer.DisplayName = $"水情数据 {from} - {to}";

            var result = new RenderResult
            {
                Layer          = layer,
                LabelSettings  = labelListSetting,
                GraphicGroupVM = GraphicGroupVM
            };

            return(result);
        }
Exemple #2
0
        private void ShowNotification(object sender, EventArgs e)
        {
            LogHelper.WriteLog(typeof(App), "ShowNotification");
            try
            {
                bool hasWarning = false;

                var from   = DateTime.Now.AddHours(-1 * interval);
                var to     = DateTime.Now;
                var entity = new HydrologicReader().RetrieveEntity(from, to);

                if (entity != null && entity.Items != null)
                {
                    foreach (var item in entity.Items)
                    {
                        if (item.L > item.Wl1 && item.Wl1 > 0.05)
                        {
                            hasWarning = true;
                            break;
                        }
                    }
                }

                if (hasWarning)
                {
                    var customBalloon = new CustomBalloon();
                    customBalloon.BalloonText        = "水情监控警报";
                    customBalloon.BalloonDescription = "发现水情警报,请在 [监控 -> 水情监控 -> 实时数据] 查看详情。";

                    notifyIcon.ShowCustomBalloon(customBalloon, PopupAnimation.Slide, 4000);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(App), ex.ToString());
            }
        }
Exemple #3
0
        public void GenFile()
        {
            string all_str = "";
            int    num     = 1;
            string sss     = "";
            string tmp     = "";

            if (this.TimeGap == 24)
            {
                /*最大要素*/
                var entity = new HydrologicReader().RetrieveHighestEntity(TimeFrom, TimeTo, Type);
                foreach (HydrologicEntityItem item in entity.Items)
                {
                    if (!double.IsNaN(item.Latitude) && !double.IsNaN(item.Longitude))
                    {
                        MicapsRecord record = new MicapsRecord();
                        record.Uid       = item.Stationid.GetHashCode();
                        record.Latitude  = item.Latitude;
                        record.Longitude = item.Longitude;
                        record.ValueL    = item.L;
                        record.ValueQ    = item.Q;
                        record.ValueWL1  = item.Wl1;
                        record.ValueWL2  = item.Wl2;
                        ListRecord.Add(record);
                        all_str += num + "\t\t";
                        num++;
                        all_str += item.Basin + "\t\t";
                        all_str += item.Administrativeregion + "\t\t";
                        all_str += item.River + "\t\t";
                        all_str += item.Name + "\t\t";
                        all_str += item.Latitude.ToString("F2") + "\t\t";
                        all_str += item.Longitude.ToString("F2") + "\t\t";
                        if (double.IsNaN(item.L))
                        {
                            all_str += "9999\t\t";
                        }
                        else
                        {
                            all_str += item.L.ToString("F2") + "\t\t";
                        }
                        if (double.IsNaN(item.Q))
                        {
                            all_str += "9999\t\t";
                        }
                        else
                        {
                            all_str += item.Q.ToString("F2") + "\t\t";
                        }
                        if (double.IsNaN(item.Wl1))
                        {
                            all_str += "9999\t\t";
                        }
                        else
                        {
                            all_str += item.Wl1.ToString("F2") + "\t\t";
                        }
                        if (double.IsNaN(item.Wl2))
                        {
                            all_str += "9999" + System.Environment.NewLine;
                        }
                        else
                        {
                            all_str += item.Wl2.ToString("F2") + System.Environment.NewLine;
                        }
                    }
                }

                if (Type.Equals("河道站"))
                {
                    sss = "最高水位\t\t最大流量\t\t警戒水位\t\t保证水位" + System.Environment.NewLine;
                }
                if (Type.Equals("水库站"))
                {
                    sss = "最高库水位\t\t最大蓄水量\t\t警戒水位\t\t保证水位" + System.Environment.NewLine;
                }
                all_str = "序号\t\t流域\t\t行政区\t\t河名\t\t站名\t\t纬度\t\t经度\t\t" + sss + all_str;
                /*生成最大全部要素*/
                infodir       = this.TimeGap + "小时最大全部要素";
                tmp           = TimeGap.ToString("D3");
                this.FilePath = @"D:/products/" + Type + @"/" + tmp + @"/" + this.infodir + @"/" + this.FileName;
                FileInfo fileInfo = new FileInfo(this.FilePath);
                if (!fileInfo.Exists)
                {
                    Directory.CreateDirectory(fileInfo.Directory.FullName);
                }
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(FilePath, false, Encoding.Default))
                {
                    file.Write(all_str);
                }


                /*生成最新要素*/
                all_str = "";
                num     = 1;
                entity  = new HydrologicReader().RetrieveEntity(TimeFrom, TimeTo, Type);
                foreach (HydrologicEntityItem item in entity.Items)
                {
                    if (!double.IsNaN(item.Latitude) && !double.IsNaN(item.Longitude))
                    {
                        MicapsRecord record = new MicapsRecord();
                        record.Uid       = item.Stationid.GetHashCode();
                        record.Latitude  = item.Latitude;
                        record.Longitude = item.Longitude;
                        record.ValueL    = item.L;
                        record.ValueQ    = item.Q;
                        record.ValueWL1  = item.Wl1;
                        record.ValueWL2  = item.Wl2;
                        ListRecord.Add(record);
                        all_str += num + "\t\t";
                        num++;
                        all_str += item.Basin + "\t\t";
                        all_str += item.Administrativeregion + "\t\t";
                        all_str += item.River + "\t\t";
                        all_str += item.Name + "\t\t";
                        all_str += item.Latitude.ToString("F2") + "\t\t";
                        all_str += item.Longitude.ToString("F2") + "\t\t";
                        if (double.IsNaN(item.L))
                        {
                            all_str += "9999\t\t";
                        }
                        else
                        {
                            all_str += item.L.ToString("F2") + "\t\t";
                        }
                        if (double.IsNaN(item.Q))
                        {
                            all_str += "9999\t\t";
                        }
                        else
                        {
                            all_str += item.Q.ToString("F2") + "\t\t";
                        }
                        if (double.IsNaN(item.Wl1))
                        {
                            all_str += "9999\t\t";
                        }
                        else
                        {
                            all_str += item.Wl1.ToString("F2") + "\t\t";
                        }
                        if (double.IsNaN(item.Wl2))
                        {
                            all_str += "9999" + System.Environment.NewLine;;
                        }
                        else
                        {
                            all_str += item.Wl2.ToString("F2") + System.Environment.NewLine;
                        }
                    }
                }
                sss = "";
                if (Type.Equals("河道站"))
                {
                    sss = "最新水位\t\t最新流量\t\t警戒水位\t\t保证水位" + System.Environment.NewLine;
                }
                if (Type.Equals("水库站"))
                {
                    sss = "最新库水位\t\t最新蓄水量\t\t警戒水位\t\t保证水位" + System.Environment.NewLine;
                }
                all_str = "序号\t\t流域\t\t行政区\t\t河名\t\t站名\t\t纬度\t\t经度\t\t" + sss + all_str;
                /*生成最新全部要素*/
                infodir       = this.TimeGap + "小时最新全部要素";
                tmp           = TimeGap.ToString("D3");
                this.FilePath = @"D:/products/" + Type + @"/" + tmp + @"/" + this.infodir + @"/" + this.FileName;
                fileInfo      = new FileInfo(this.FilePath);
                if (!fileInfo.Exists)
                {
                    Directory.CreateDirectory(fileInfo.Directory.FullName);
                }
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(FilePath, false, Encoding.Default))
                {
                    file.Write(all_str);
                }
            }

            if (this.TimeGap == 1)
            {
                /*生成最新要素*/
                all_str = "";
                num     = 1;
                var entity = new HydrologicReader().RetrieveEntity(TimeFrom, TimeTo, Type);
                foreach (HydrologicEntityItem item in entity.Items)
                {
                    if (!double.IsNaN(item.Latitude) && !double.IsNaN(item.Longitude))
                    {
                        MicapsRecord record = new MicapsRecord();
                        record.Uid       = item.Stationid.GetHashCode();
                        record.Latitude  = item.Latitude;
                        record.Longitude = item.Longitude;
                        record.ValueL    = item.L;
                        record.ValueQ    = item.Q;
                        record.ValueWL1  = item.Wl1;
                        record.ValueWL2  = item.Wl2;
                        ListRecord.Add(record);
                        all_str += num + "\t\t";
                        num++;
                        all_str += item.Basin + "\t\t";
                        all_str += item.Administrativeregion + "\t\t";
                        all_str += item.River + "\t\t";
                        all_str += item.Name + "\t\t";
                        all_str += item.Latitude.ToString("F2") + "\t\t";
                        all_str += item.Longitude.ToString("F2") + "\t\t";
                        if (double.IsNaN(item.L))
                        {
                            all_str += "9999\t\t";
                        }
                        else
                        {
                            all_str += item.L.ToString("F2") + "\t\t";
                        }
                        if (double.IsNaN(item.Q))
                        {
                            all_str += "9999\t\t";
                        }
                        else
                        {
                            all_str += item.Q.ToString("F2") + "\t\t";
                        }
                        if (double.IsNaN(item.Wl1))
                        {
                            all_str += "9999\t\t";
                        }
                        else
                        {
                            all_str += item.Wl1.ToString("F2") + "\t\t";
                        }
                        if (double.IsNaN(item.Wl2))
                        {
                            all_str += "9999" + System.Environment.NewLine;;
                        }
                        else
                        {
                            all_str += item.Wl2.ToString("F2") + System.Environment.NewLine;
                        }
                    }
                }
                sss = "";
                if (Type.Equals("河道站"))
                {
                    sss = "最新水位\t\t最新流量\t\t警戒水位\t\t保证水位" + System.Environment.NewLine;
                }
                if (Type.Equals("水库站"))
                {
                    sss = "最新库水位\t\t最新蓄水量\t\t警戒水位\t\t保证水位" + System.Environment.NewLine;
                }
                all_str = "序号\t\t流域\t\t行政区\t\t河名\t\t站名\t\t纬度\t\t经度\t\t" + sss + all_str;
                /*生成最新全部要素*/
                infodir       = this.TimeGap + "小时最新全部要素";
                tmp           = TimeGap.ToString("D3");
                this.FilePath = @"D:/products/" + Type + @"/" + tmp + @"/" + this.infodir + @"/" + this.FileName;
                FileInfo fileInfo = new FileInfo(this.FilePath);
                fileInfo = new FileInfo(this.FilePath);
                if (!fileInfo.Exists)
                {
                    Directory.CreateDirectory(fileInfo.Directory.FullName);
                }
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(FilePath, false, Encoding.Default))
                {
                    file.Write(all_str);
                }
            }
        }
Exemple #4
0
        public static List <RiverWarningRecord> GetRiverWarningInfo()
        {
            List <RiverWarningRecord> infoList = new List <RiverWarningRecord>();
            List <RiverWarningRecord> rtnList  = new List <RiverWarningRecord>();

            HydrologicReader dbReader = new HydrologicReader();
            HydrologicEntity entity   = dbReader.RetrieveEntity(DateTime.Now.AddDays(-1), DateTime.Now, "河道站");  //获取最近1天河道站最新水情

            foreach (var item in entity.Items)
            {
                if ((item.L - item.Wl1) > -0.5)  //超过监测门限-0.5
                {
                    RiverWarningRecord record = new RiverWarningRecord();

                    if (item.Basin != null)
                    {
                        int index = item.Basin.IndexOf("流域");
                        record.Basin = (index < 0) ? item.Basin : item.Basin.Remove(index);
                    }
                    else
                    {
                        record.Basin = item.Basin;
                    }

                    if (item.L > item.Wl1)
                    {
                        record.IsBeyond = true;
                    }
                    else
                    {
                        record.IsBeyond = false;
                    }

                    record.Level            = item.L;
                    record.Name             = item.Name;
                    record.OverWarningLevel = item.L - item.Wl1;
                    record.Province         = GetProvinceByAdm(item.Administrativeregion); //从行政地址获得省名
                    record.River            = item.River;
                    record.Stationid        = item.Stationid;
                    record.Time             = item.Time;
                    record.WarningLevel     = item.Wl1;
                    int tr = dbReader.ComparedWithRecent(item, DateTime.Now.AddDays(-2), DateTime.Now);  //最近2天内的最新趋势
                    if (tr > 0)
                    {
                        record.ComparedBefore = Trend.Rise;
                    }
                    else if (tr == 0)
                    {
                        record.ComparedBefore = Trend.Hold;
                    }
                    else
                    {
                        record.ComparedBefore = Trend.Fall;
                    }

                    if (!(double.IsNaN(record.WarningLevel) || record.WarningLevel <= 0))
                    {
                        infoList.Add(record);
                    }
                }
            }

            var groupedList = from info in infoList
                              group info by info.Basin into g
                              select g;

            /*infoList = new List<RiverWarningRecord>();
             * foreach(var g in groupedList)
             * {
             *  foreach(var x in g)
             *  {
             *      infoList.Add(x);
             *  }
             * }*/
            foreach (var group in groupedList)
            {
                foreach (var item in group)
                {
                    rtnList.Add(item);
                }
            }

            return(rtnList);
        }
Exemple #5
0
        public static List <RiverWarningRecord> LakeGetByWarningList()
        {
            List <WarningData> listWarning = new List <WarningData>();

            listWarning.Add(new WarningData {
                Uid = "61512000", Time = DateTime.Now, L = 0, WL1 = 0
            });                                                                                          //61512000    城陵矶(七里山)    洞庭湖湖口
            listWarning.Add(new WarningData {
                Uid = "62601600", Time = DateTime.Now, L = 0, WL1 = 0
            });                                                                                            //62601600        湖口              湖口水道
            listWarning.Add(new WarningData {
                Uid = "63201999", Time = DateTime.Now, L = 0, WL1 = 0
            });                                                                                           //63201999    太湖水位          太湖
            List <RiverWarningRecord> listRecord = new List <RiverWarningRecord>();
            HydrologicReader          dbReader   = new HydrologicReader();

            foreach (WarningData warning in listWarning)
            {
                RiverWarningRecord record = new RiverWarningRecord();
                bool   isBeyond           = false;
                double OverWarningLevel   = 0;
                HydrologicEntityItem item = new HydrologicEntityItem();
                int t = dbReader.GetLastWarningData(DateTime.Now.AddDays(-2), DateTime.Now, warning.Uid, out item, out isBeyond, out OverWarningLevel);

                if (item.Basin != null || !item.Basin.Contains("其他"))
                {
                    int index = item.Basin.IndexOf("流域");
                    record.Basin = (index < 0) ? item.Basin : item.Basin.Remove(index);
                }
                else
                {
                    record.Basin = item.Basin;
                }

                record.IsBeyond         = isBeyond;
                record.Level            = item.L;
                record.Name             = item.Name;
                record.OverWarningLevel = OverWarningLevel;
                record.Province         = GetProvinceByAdm(item.Administrativeregion); //从行政地址获得省名
                record.River            = item.River;
                record.Time             = item.Time;
                record.WarningLevel     = item.Wl1;

                if (t > 0)
                {
                    record.ComparedBefore = Trend.Rise;
                }
                else if (t == 0)
                {
                    record.ComparedBefore = Trend.Hold;
                }
                else
                {
                    record.ComparedBefore = Trend.Fall;
                }

                listRecord.Add(record);
            }

            return(listRecord);
        }
Exemple #6
0
        public static List <ReservoirWarningRecord> ResGetByWarningList(List <WarningData> listWarning)
        {
            List <ReservoirWarningRecord> listRecord    = new List <ReservoirWarningRecord>();
            List <ReservoirWarningRecord> listRtnRecord = new List <ReservoirWarningRecord>();
            HydrologicReader dbReader = new HydrologicReader();

            foreach (WarningData warning in listWarning)
            {
                ReservoirWarningRecord record = new ReservoirWarningRecord();
                bool   isBeyond           = false;
                double OverWarningLevel   = 0;
                HydrologicEntityItem item = new HydrologicEntityItem();
                int t = dbReader.GetLastWarningData(DateTime.Now.AddDays(-2), DateTime.Now, warning.Uid, out item, out isBeyond, out OverWarningLevel);

                if (item.Basin != null || !item.Basin.Contains("其他"))
                {
                    int index = item.Basin.IndexOf("流域");
                    record.Basin = (index < 0) ? item.Basin : item.Basin.Remove(index);
                }
                else
                {
                    record.Basin = item.Basin;
                }

                record.IsBeyond         = isBeyond;
                record.Level            = item.L;
                record.Name             = item.Name;
                record.OverWarningLevel = OverWarningLevel;
                record.Province         = GetProvinceByAdm(item.Administrativeregion); //从行政地址获得省名
                record.River            = item.River;
                record.Time             = item.Time;
                record.WarningLevel     = item.Wl1;

                if (t > 0)
                {
                    record.ComparedBefore = Trend.Rise;
                }
                else if (t == 0)
                {
                    record.ComparedBefore = Trend.Hold;
                }
                else
                {
                    record.ComparedBefore = Trend.Fall;
                }

                if (!(double.IsNaN(record.WarningLevel) || record.WarningLevel <= 0))
                {
                    listRecord.Add(record);
                }
            }

            var groupedList = from info in listRecord
                              group info by info.Basin into g
                              select g;

            foreach (var group in groupedList)
            {
                List <ReservoirWarningRecord> toSortList = new List <ReservoirWarningRecord>();

                foreach (var item in group)
                {
                    toSortList.Add(item);
                }
                toSortList.Sort(delegate(ReservoirWarningRecord a, ReservoirWarningRecord b) { return(b.OverWarningLevel.CompareTo(a.OverWarningLevel)); });
                listRtnRecord.AddRange(toSortList);
            }

            return(listRtnRecord);
        }
Exemple #7
0
        public static List <ReservoirWarningRecord> GetKeyReservoirWarningInfo()
        {
            List <ReservoirWarningRecord> infoList = new List <ReservoirWarningRecord>();

            HydrologicReader dbReader = new HydrologicReader();
            HydrologicEntity entity   = dbReader.RetrieveEntity(DateTime.Now.AddDays(-1), DateTime.Now, "水库站");  //获取最近1天水库站最新水情

            foreach (var item in entity.Items)
            {
                if ((item.L - item.Wl1) > -20 && item.Issign == true)  //超过监测门限-20且为重点站
                {
                    ReservoirWarningRecord record = new ReservoirWarningRecord();

                    if (item.Basin != null)
                    {
                        int index = item.Basin.IndexOf("流域");
                        record.Basin = (index < 0) ? item.Basin : item.Basin.Remove(index);
                    }
                    else
                    {
                        record.Basin = item.Basin;
                    }

                    if (item.L > item.Wl1)
                    {
                        record.IsBeyond = true;
                    }
                    else
                    {
                        record.IsBeyond = false;
                    }

                    record.Level            = item.L;
                    record.Name             = item.Name;
                    record.OverWarningLevel = item.L - item.Wl1;
                    record.Province         = GetProvinceByAdm(item.Administrativeregion); //从行政地址获得省名
                    record.River            = item.River;
                    record.Stationid        = item.Stationid;
                    record.Time             = item.Time;
                    record.WarningLevel     = item.Wl1;
                    int tr = dbReader.ComparedWithRecent(item, DateTime.Now.AddDays(-2), DateTime.Now);  //最近2天内的最新趋势
                    if (tr > 0)
                    {
                        record.ComparedBefore = Trend.Rise;
                    }
                    else if (tr == 0)
                    {
                        record.ComparedBefore = Trend.Hold;
                    }
                    else
                    {
                        record.ComparedBefore = Trend.Fall;
                    }

                    if (!(double.IsNaN(record.WarningLevel) || record.WarningLevel <= 0))
                    {
                        infoList.Add(record);
                    }
                }
            }

            return(infoList);
        }