cloudflight
2023-12-02 c0f9915265878e56e91ee97f7f8d925db1e12626
2023年12月2日_3

添加MapViewer项目
修改MapViewNetwork类中,输入输出、构建管网等方法
已删除4个文件
已重命名6个文件
已修改41个文件
已添加8个文件
2078 ■■■■ 文件已修改
Hydro.CommonBase/Helper/Base64Helper.cs 179 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Helper/CalcExt.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Helper/DbHelper.cs 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Helper/ExcelHelper.cs 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Helper/GlobalConfig.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Helper/JsonHelper.cs 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Helper/Log.cs 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Helper/SolutionSelector.cs 212 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Helper/Type.cs 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Helper/dictHelper.cs 225 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Hydro.CommonBase.csproj 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/ParamModel.cs 123 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Properties/AssemblyInfo.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Properties/Resources.Designer.cs 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Properties/Resources.resx 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Resources/config.wdb 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/component/Range.cs 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/component/Relation.cs 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/component/Trigger.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/component/dict.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/packages.config 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.HydraulicOptimizer/Hydro.HydraulicOptimizer.csproj 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.HydraulicOptimizer/packages.config 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Inp/NetWork.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/GlobalObject.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/Hydro.MapUI.csproj 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/Map/MapContainer.Designer.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/Map/MapContainer.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/Map/MapViewer.Designer.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/Map/MapViewer.Model.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/Map/MapViewer.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/Map/map_old.Designer.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/Map/map_old.Model.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/Map/map_old.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/Form_EditFloors.Designer.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/Form_EditFloors.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/Form_Magnifier.Designer.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/Form_Magnifier.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/Form_Magnifier.resx 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/Form_importObjs.Designer.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/Form_importObjs.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/InputBox.Designer.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/InputBox.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/InputBox.resx 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/Progress.cs 159 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/Progress.designer.cs 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/Progress.resx 145 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/propertyform.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/propertyform.designer.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/模板管理.Designer.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapBase/WindowsForm/模板管理.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapView/Base/LinkViewModel.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapView/Base/NodeViewModel.cs 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapView/MapViewNetWork.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.MapView/MapViewNetWork2Inp.cs 247 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Revit/RevitNetWork.cs 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
TestForm/Form1.Designer.cs 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
TestForm/Form1.cs 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
TestForm/Form1.resx 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.CommonBase/Helper/Base64Helper.cs
@@ -78,4 +78,183 @@
    }
    public static class MessageCompressHelper
    {
        public static void SaveCompressedBase64ToFile<T>(T obj, string filePath)
        {
            // å°†å¯¹è±¡åºåˆ—化为字节数组
            var formatter = MessagePackSerializer.Serialize<T>(obj);
            //var obj1 = MessagePackSerializer.Deserialize<T>(formatter);
            File.WriteAllBytes(filePath, formatter);
            //byte[] compressedData;
            //// ä½¿ç”¨ GZip åŽ‹ç¼©å­—èŠ‚æ•°ç»„
            //using (var outputStream = new MemoryStream())
            //{
            //    using (var gzipStream = new GZipStream(outputStream, CompressionMode.Compress))
            //    {
            //        outputStream.Write(formatter, 0, formatter.Length);
            //    }
            //    compressedData = outputStream.ToArray();
            //}
            //// å°†åŽ‹ç¼©åŽçš„å­—èŠ‚æ•°ç»„è½¬ä¸º Base64 å­—符串
            //var base64String = Convert.ToBase64String(compressedData);
            // å°† Base64 å­—符串写入文件
            //File.WriteAllText(filePath, base64String);
        }
        public static T ReadCompressedBase64FromFile<T>(string filePath)
        {
            //// ä»Žæ–‡ä»¶ä¸­è¯»å– Base64 å­—符串
            //var base64String = File.ReadAllText(filePath);
            //// å°† Base64 å­—符串转为压缩后的字节数组
            //byte[] compressedData = Convert.FromBase64String(base64String);
            //// ä½¿ç”¨ GZip è§£åŽ‹ç¼©å­—èŠ‚æ•°ç»„
            //using (var inputStream = new MemoryStream(compressedData))
            //using (var outputStream = new MemoryStream())
            //{
            //    using (var gzipStream = new GZipStream(inputStream, CompressionMode.Decompress))
            //    {
            //        gzipStream.CopyTo(outputStream);
            //    }
            //    // å°†è§£åŽ‹ç¼©åŽçš„å­—èŠ‚æ•°ç»„ååºåˆ—åŒ–ä¸ºå¯¹è±¡
            //    var obj = MessagePackSerializer.Deserialize<T>(outputStream.ToArray());
            //    return obj;
            //}
            var formatter=File.ReadAllBytes(filePath );
            var obj = MessagePackSerializer.Deserialize<T>(formatter);
            return obj;
        }
        //public static void CopyMessage<T>(this object obj)
        //{
        //    //return obj1;
        //}
    }
    public class ProtoBufHelper
    {
        //public static void SaveCompressedProtoBufToFile<T>(T obj, string filePath) where T : IMessage<T>
        //{
        //    // å°†å¯¹è±¡åºåˆ—化为字节数组
        //    byte[] buffer = obj.ToByteArray();
        //    // ä½¿ç”¨ GZip åŽ‹ç¼©å­—èŠ‚æ•°ç»„
        //    byte[] compressedData;
        //    using (var outputStream = new MemoryStream())
        //    {
        //        using (var gzipStream = new GZipStream(outputStream, CompressionMode.Compress))
        //        {
        //            gzipStream.Write(buffer, 0, buffer.Length);
        //        }
        //        compressedData = outputStream.ToArray();
        //    }
        //    // å°†åŽ‹ç¼©åŽçš„å­—èŠ‚æ•°ç»„å†™å…¥æ–‡ä»¶
        //    File.WriteAllBytes(filePath, compressedData);
        //}
        //public static T ReadCompressedProtoBufFromFile<T>(string filePath) where T : IMessage<T>, new()
        //{
        //    // ä»Žæ–‡ä»¶ä¸­è¯»å–字节数组
        //    byte[] buffer = File.ReadAllBytes(filePath);
        //    // ä½¿ç”¨ GZip è§£åŽ‹ç¼©å­—èŠ‚æ•°ç»„
        //    byte[] decompressedData;
        //    using (var inputStream = new MemoryStream(buffer))
        //    using (var outputStream = new MemoryStream())
        //    {
        //        using (var gzipStream = new GZipStream(inputStream, CompressionMode.Decompress))
        //        {
        //            gzipStream.CopyTo(outputStream);
        //        }
        //        decompressedData = outputStream.ToArray();
        //    }
        //    // å°†è§£åŽ‹ç¼©åŽçš„å­—èŠ‚æ•°ç»„ååºåˆ—åŒ–ä¸ºå¯¹è±¡
        //    T obj = new T();
        //    obj.MergeFrom(decompressedData);
        //    return obj;
        //}
    }
    //[Serializable]
    //public class CDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    //{
    //    public CDictionary() :base() { }
    //    public new void Add(TKey key, TValue value)
    //    {
    //        if (ContainsKey(key))
    //        {
    //            // å¤„理重复键的逻辑,这里以覆盖原有值为例
    //            this[key] = value;
    //        }
    //        else
    //        {
    //            base.Add(key, value);
    //        }
    //    }
    //    public void FromDictionary(Dictionary<TKey, TValue> dictionary)
    //    {
    //        //CustomDictionary<TKey, TValue> customDictionary = new CustomDictionary<TKey, TValue>();
    //        this.Clear();
    //        foreach (KeyValuePair<TKey, TValue> kvp in dictionary)
    //        {
    //            this.Add(kvp.Key, kvp.Value);
    //        }
    //        //return customDictionary;
    //    }
    //    public Dictionary<TKey, TValue> ToDictionary()
    //    {
    //        Dictionary<TKey, TValue> dictionary = new Dictionary<TKey, TValue>();
    //        foreach (KeyValuePair<TKey, TValue> kvp in this)
    //        {
    //            dictionary[kvp.Key] = kvp.Value;
    //        }
    //        return dictionary;
    //    }
    //}
    public static class ToDictionaryExtentions
    {
        public static ConcurrentDictionary<TKey, TValue> ToDictionaryEx<TElement, TKey, TValue>(
            this IEnumerable<TElement> source,
            Func<TElement, TKey> keyGetter,
            Func<TElement, TValue> valueGetter)
        {
            ConcurrentDictionary<TKey, TValue> dict = new ConcurrentDictionary<TKey, TValue>(); // new Dictionary<TKey, TValue>();
            foreach (var e in source)
            {
                var key = keyGetter(e);
                if (dict.ContainsKey(key))
                {
                    continue;
                }
                dict.TryAdd(key, valueGetter(e));
            }
            return dict;
        }
    }
}
Hydro.CommonBase/Helper/CalcExt.cs
@@ -171,4 +171,6 @@
    }
}
Hydro.CommonBase/Helper/DbHelper.cs
@@ -1,4 +1,5 @@
using System;
using CommonBase.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -22,8 +23,8 @@
                path = AppDomain.CurrentDomain.BaseDirectory + "config.wdb";
            //检查数据库是否存在,不在则新建
            //if (!File.Exists(path))
             //   File.WriteAllBytes(path, Resources.Db);
            if (!File.Exists(path))
                File.WriteAllBytes(path, Resources.Db);
            //初始化数据库连接串
            Connection = new SQLiteConnection($"Data Source={path};Pooling=true;FailIfMissing=false");
@@ -119,8 +120,8 @@
            
            
            //检查数据库是否存在,不在则新建
            //if (!File.Exists(path))
            //    File.WriteAllBytes(path, Resources.Db);
            if (!File.Exists(path))
                File.WriteAllBytes(path, Resources.Db);
            // ç§»é™¤åªè¯»å±žæ€§
            FileAttributes attributes = File.GetAttributes(path);
Hydro.CommonBase/Helper/ExcelHelper.cs
@@ -241,12 +241,12 @@
                }
                else
                {
                    throw new Exception("没有数据可供导出");
                    MessageBox.Show("没有数据可供导出", "提示");
                }
            }
            catch
            {
                throw new Exception("操作失败");
                MessageBox.Show("操作失败", "提示");
            }
        }//DataSet输出Excel
@@ -281,8 +281,8 @@
                if (filePath.Length <= 0 || !(extension == ".xls" || extension == ".xlsx" || extension == ".csv"))
                {
                    throw new Exception("文件名称错误或者格式错误");
                    //return null;
                    MessageBox.Show("文件名称错误或者格式错误");
                    return null;
                }
                int r = 0;
@@ -633,8 +633,8 @@
                if (strFileNme.Length <= 0 || !(strFileNme.Substring(strFileNme.LastIndexOf(".")).ToLower() == ".xls" || strFileNme.Substring(strFileNme.LastIndexOf(".")).ToLower() == ".xlsx"))
                {
                    throw new Exception("文件名称错误或者格式错误");
                    //return null;
                    MessageBox.Show("文件名称错误或者格式错误");
                    return null;
                }
                int r = 0;
Hydro.CommonBase/Helper/GlobalConfig.cs
@@ -22,7 +22,8 @@
    }
    public class GlobalPath
    {
        public static string Path { get; set; }
        private static string path = null;
        public static string Path { get { return path; } set {   path = value; if (!string.IsNullOrEmpty(path) && path[path.Length - 1] != '\\') path = path + "\\"; } }
        public static string configPath { get { string p = Path + @"\config\"; if (!Directory.Exists(p)) Directory.CreateDirectory(p); return p; }}
        public static string modelPath { get { string p = Path + @"\model\"; if (!Directory.Exists(p)) Directory.CreateDirectory(p); return p; } }
@@ -111,12 +112,11 @@
        public Dictionary<string, SaveSettings> saveSettings { get; set; } = new Dictionary<string, SaveSettings>();
    }
    public class SaveSettings
    {
        public List<int> Length_Ds=null;
        public List<DRange> list_Range=null;
        public List<MyDoubleRange> list_Range=null;
        public ConcurrentDictionary<ulong, double> saveDatas = null;
        public string savePath=null;
@@ -176,7 +176,7 @@
                {
                    if (value == null) return;
                   
                    list_Range = value.Split('|').ToList().Select(n => new DRange(double.Parse(n.Split(',')[0]), double.Parse(n.Split(',')[1]))).ToList();
                    list_Range = value.Split('|').ToList().Select(n => new MyDoubleRange(double.Parse(n.Split(',')[0]), double.Parse(n.Split(',')[1]))).ToList();
                }
Hydro.CommonBase/Helper/JsonHelper.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CommonBase
{
    public class Json
    {
        public static string Serialize(object obj)
        {
            return JsonConvert.SerializeObject(obj);
        }
        public static T Deserialize<T>(string json)
        {
            return JsonConvert.DeserializeObject<T>(json);
        }
    }
}
Hydro.CommonBase/Helper/Log.cs
@@ -10,6 +10,7 @@
{
    public class Log
    {
        public static int LengthLimit = 100000;
        public static bool Enable = false;
        public static bool isAdded = false;
        public static object lockObj=new object();
@@ -32,9 +33,10 @@
                var time = DateTime.Now;
                var now = time.ToString("HH:mm:ss");
                string nowtxt = "";
                if (now != lastTime)
                {
                    sbs[name].AppendLine(now);
                    nowtxt= $"\r\n{now}";
                }
                string tt = "";
@@ -60,7 +62,7 @@
                {
                    signtxt = ":";
                }
                sbs[name].AppendLine($"{signtxt}{tt}{time.ToString("fff")}\t{txt}\t({(time - ts[name][level]).TotalMilliseconds})");
                sbs[name].Append($"({(time - ts[name][level]).TotalMilliseconds})\r\n{nowtxt}{signtxt}{tt}{time.ToString("fff")}\t{txt}\t");
                lastTime = now;
                ts[name][level] = time;
            }           
@@ -81,7 +83,7 @@
                {
                    var name = key == "default" ? "" : key;
                    var file = $@"Log\log_{name}.lua";
                    //if (File.Exists(file)) File.Copy(file, $@"Log\log_{name}_bk_{DateTime.Now.ToString("yyyyMMddHHmmss")}.lua", true);
                    if (!Directory.Exists("Log\\")) Directory.CreateDirectory("Log\\");
                    StreamWriter sw = null;
@@ -90,13 +92,20 @@
                        sw = new StreamWriter(file);
                        sw.WriteLine(sbs[key].ToString());
                        sw.Close();
                        if (sbs[key].Length>LengthLimit)
                        {
                            if (File.Exists(file)) File.Copy(file, $@"Log\log_{name}_bk_{DateTime.Now.ToString("yyyyMMddHHmmss")}.lua", true);
                            sbs[key].Clear();
                        }
                    }
                    catch
                    {
                        if (sw != null) sw.Close();
                    }
                }
            }
        }
        public static void OpenFile()
Hydro.CommonBase/Helper/SolutionSelector.cs
@@ -31,7 +31,18 @@
            if (dateTime==default(DateTime)) { dateTime=DateTime.Now; }
            //string currentDirectory = Directory.GetCurrentDirectory();
            string resultPath = GlobalPath.resultPath;// Path.Combine(GlobalPath.resultPath, "result");
            string currentDirectory = Directory.GetCurrentDirectory();
            //string resultPath = GlobalPath.resultPath;
            string userPathFile = resultPath + "UserPath.ini";
            string userPath = null;
            if (File.Exists(userPathFile))
            {
                userPath = File.ReadAllText(userPathFile);
            }
            if (userPath == null || !Directory.Exists(userPath))
            {
                userPath = resultPath;
            }
            bool flag = false;
            int lastMinutes = 10;
@@ -57,7 +68,8 @@
                    if (MessageBox.Show("自动选择历史输出?\r\n是:自动\r\n否:手动", "方案择优", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        OpenFileDialog openFileDialog = new OpenFileDialog();
                        openFileDialog.InitialDirectory = resultPath;
                        openFileDialog.InitialDirectory = userPath;
                        openFileDialog.Filter = "JSON Files (*.json)|*.json";
                        openFileDialog.Multiselect = true;
@@ -76,10 +88,10 @@
                        DateTime tenMinutesAgo = currentTime.AddMinutes(-lastMinutes);
                        // æŸ¥æ‰¾ç›®å½•下的所有.json文件,并根据修改时间进行筛选
                        string[] jsonFiles = Directory.GetFiles(resultPath, "*.json")
                        string[] jsonFiles = Directory.GetFiles(userPath, "*.json")
                            .Where(file => File.GetLastWriteTime(file) >= tenMinutesAgo && File.GetLastWriteTime(file) <=  currentTime)
                            .ToArray();
                        string[] inputFiles = Directory.GetFiles(resultPath, "*.input")
                        string[] inputFiles = Directory.GetFiles(userPath, "*.input")
                    .Where(file => File.GetLastWriteTime(file) >= tenMinutesAgo && File.GetLastWriteTime(file) <= currentTime)
                    .ToArray();
                        files = jsonFiles.ToList();
@@ -96,12 +108,12 @@
                DateTime tenMinutesAgo = currentTime.AddMinutes(-lastMinutes);
                // æŸ¥æ‰¾ç›®å½•下的所有.json文件,并根据修改时间进行筛选
                string[] jsonFiles = Directory.GetFiles(resultPath, "*.json")
                string[] jsonFiles = Directory.GetFiles(userPath, "*.json")
                    .Where(file => getTimeByFileName(file) >= tenMinutesAgo && getTimeByFileName(file) <= currentTime)
                    .OrderBy(file =>file)
                    .ToArray();
                string[] inputFiles = Directory.GetFiles(resultPath, "*.input")
                string[] inputFiles = Directory.GetFiles(userPath, "*.input")
                    .Where(file => getTimeByFileName(file) >= tenMinutesAgo && getTimeByFileName(file) <= currentTime)
                    .OrderBy(file=>file)
                    .ToArray();
@@ -115,7 +127,11 @@
            List<PointF3D> points = new List<PointF3D>();
            DataTable dt = new DataTable();
            dt.Columns.Add("时间", typeof(DateTime));
            if (Inputfiles.Count!=0)   dt.Columns.Add("接口文件");
            if (Inputfiles.Count != 0)
            {
                dt.Columns.Add("接口文件");
                dt.Columns.Add("结果文件");
            }
            List<double> RecentScada=null;
            if (files.Count>0)
            {
@@ -140,6 +156,13 @@
                        param = JsonConvert.DeserializeObject<LogicModelParams>(fileContent);
                    }
                    ParamBuffer.dict.TryAdd(name, param.CloneResult());
                    if (ParamBuffer.dict.Count> lastMinutes*3)
                    {
                        foreach(var key in ParamBuffer.dict.Keys.ToList())
                        {
                            if (getTimeByFileName(key) < DateTime.Now.AddMinutes(-lastMinutes)) ParamBuffer.dict.TryRemove(key,out LogicModelParams v);
                        }
                    }
                }
                param.dict_ID.TryGetValue(hostID, out variable obj);
@@ -148,6 +171,8 @@
                dict dict = new dict();
                dict.LoadFromString(obj.objListString);
                RecentScada = getScadaPumpStatusList(dict);
            }
            else
            {
@@ -170,16 +195,17 @@
                    }
                    else
                    {
                        try
                        {
                            param = MessageCompressHelper.ReadCompressedBase64FromFile<LogicModelParams>(file_full);
                        }
                        catch
                        {
                            // è¯»å–文件内容
                            string fileContent = File.ReadAllText(file_full);
                            param = JsonConvert.DeserializeObject<LogicModelParams>(fileContent);
                        }
                        //try
                        //{
                        //    param = MessageCompressHelper.ReadCompressedBase64FromFile<LogicModelParams>(file_full);
                        //}
                        //catch
                        //{
                        //}
                        string fileContent = File.ReadAllText(file_full);
                        param = JsonConvert.DeserializeObject<LogicModelParams>(fileContent);
                        // è¯»å–文件内容
                        ParamBuffer.dict.TryAdd(name, param.CloneResult());
                    }
@@ -220,7 +246,11 @@
                    if (i==files.Count-1 && dt.Rows.Count==0  || (double)dr["福永目标"] < 4000 && æ°´æ³µæœªå˜åŒ–时水厂压力变化是否正常(doubles, int.Parse( dr["开关量维度值"].ToString())))
                    {
                        points.Add(new PointF3D(doubles[0], doubles[1], doubles[2], dt.Rows.Count));
                        if (Inputfiles.Count != 0) dr["接口文件"] = Inputfiles[i];
                        if (Inputfiles.Count != 0)
                        {
                            dr["接口文件"] = Inputfiles[i];
                            dr["结果文件"] = files[i];
                        }
                        dt.Rows.Add(dr);
                    }
                }
@@ -230,7 +260,13 @@
                }
            }
            dt.Columns.Add("标记");
            if (Inputfiles.Count != 0)  dt.Columns["接口文件"].SetOrdinal(dt.Columns.Count-1);
            if (Inputfiles.Count != 0)
            {
                dt.Columns["结果文件"].SetOrdinal(dt.Columns.Count - 1);
                dt.Columns["接口文件"].SetOrdinal(dt.Columns.Count - 1);
            }
            if (points.Count <= 0) return new DataTable();
            var filterpoints = points;
@@ -253,6 +289,7 @@
                dt.Rows[p.rowIndex]["标记"] = "";
            }
            dt.Rows[minP.rowIndex]["标记"] = "√";
            ValidNum=filterpoints.Count;
            return dt;
        }
@@ -274,9 +311,10 @@
        static bool æ°´æ³µæœªå˜åŒ–时水厂压力变化是否正常(double[] doubles,int å¼€å…³é‡)
        {
            if (开关量 != 0) return true; 
            var ç«‹æ–°å˜åŒ–=  Math.Abs(doubles[0] - doubles[3]);
            var å‡¤å‡°å˜åŒ– = Math.Abs(doubles[1] - doubles[4]);
            if (立新变化*101.972 > 1.2 || å‡¤å‡°å˜åŒ–*101.972 > 1.2) return false;
            var ç«‹æ–°å˜åŒ–=  doubles[0] - doubles[3];
            var å‡¤å‡°å˜åŒ– = doubles[1] - doubles[4];
            if (立新变化* å‡¤å‡°å˜åŒ–<0 && (Math.Abs(立新变化) *101.972 > 1.2 || Math.Abs(凤凰变化) *101.972 > 1.2)) return false;
            return true;
        }
        static DateTime getTimeByFileName(string filename)
@@ -413,19 +451,31 @@
            double stdDev = Math.Sqrt(sumOfSquares / values.Count);
            return stdDev;
        }
        static string getOptString(double x)
        {
            if (x < 0) return "关闭";
            else return "开启";
        }
        public static string getOrderTxt(DataView dv, int bestRowIndex)
        {
            if (bestRowIndex < 0) return null;
            DataRowView row = dv[bestRowIndex];
            int recentRowIndex = dv.Count - 1;
            double num = (double)dv[bestRowIndex][3];
            bool isChangePump = false;
            if (num<-1000)
            {
                isChangePump = true;
            }
            string stateTxt = (num > 0) ? "开启" : "关闭";
            int num1 = (int)Math.Abs(num);
            int PumpNum = num1 / 100;
            string facTxt = (PumpNum <= 5) ? "立新" : "凤凰";
            int PumpNumShow = PumpNum > 5 ? PumpNum - 5 : PumpNum;
            string pumpChangeTxt = num == 0 ? "水泵开停不变" : $"{facTxt}{stateTxt}{PumpNumShow}#æ³µ";
            //string pumpChangeTxt = num == 0 ? "水泵开停不变" : $"{facTxt}{stateTxt}{PumpNumShow}#æ³µ";
            string pumpChangeTxt_lx = "";
            string pumpChangeTxt_fh = "";
            var time = DateTime.Now;
            string PumpStateList_lx0 = "";
            string PumpStateList_fh0 = "";
@@ -433,46 +483,58 @@
            string PumpStateList_fh1 = "";
            for (int i = 1; i <= 5; i++)
            {
                if ((double)dv[bestRowIndex][5 + i] == 1)
                {
                    PumpStateList_lx1 += $"{i}#";
                    if (i != PumpNum)
                    {
                        PumpStateList_lx0 += $"{i}#";
                    }
                }
                else if (i == PumpNum)
                {
                    PumpStateList_lx0 += $"{i}#";
                }
                double d = 0;
                if ((d = (double)dv[bestRowIndex][15 + i]) == 1) PumpStateList_lx0 += $"{i}#";
                if ((d = (double)dv[bestRowIndex][20 + i]) == 1) PumpStateList_fh0 += $"{i}#";
                if ((d = (double)dv[bestRowIndex][5 + i]) == 1) PumpStateList_lx1 += $"{i}#";
                if ((d = (double)dv[bestRowIndex][10 + i]) == 1) PumpStateList_fh1 += $"{i}#";
                if ((d=(double)dv[bestRowIndex][25 + i]) != 0) pumpChangeTxt_lx += $"{getOptString(d)}{i}#";
                if ((d = (double)dv[bestRowIndex][30 + i]) != 0) pumpChangeTxt_fh += $"{getOptString(d)}{i}#";
            }
            if (pumpChangeTxt_lx != "") pumpChangeTxt_lx = "立新" + pumpChangeTxt_lx;
            if (pumpChangeTxt_fh != "") pumpChangeTxt_fh = "凤凰" + pumpChangeTxt_fh;
            //for (int i = 1; i <= 5; i++)
            //{
            //    if ((double)dv[bestRowIndex][5 + i] == 1)
            //    {
            //        PumpStateList_lx1 += $"{i}#";
            //        if (i != PumpNum)
            //        {
            //            PumpStateList_lx0 += $"{i}#";
            //        }
            //    }
            //    else if (i == PumpNum)
            //    {
            //        PumpStateList_lx0 += $"{i}#";
            //    }
            //}
            PumpNum = PumpNum - 5;
            for (int i = 1; i <= 5; i++)
            {
                if ((double)dv[bestRowIndex][10 + i] == 1)
                {
                    PumpStateList_fh1 += $"{i}#";
                    if (i != PumpNum)
                    {
                        PumpStateList_fh0 += $"{i}#";
                    }
                }
                else if (i == PumpNum)
                {
                    PumpStateList_fh0 += $"{i}#";
                }
            }
            //PumpNum = PumpNum - 5;
            //for (int i = 1; i <= 5; i++)
            //{
            //    if ((double)dv[bestRowIndex][10 + i] == 1)
            //    {
            //        PumpStateList_fh1 += $"{i}#";
            //        if (i != PumpNum)
            //        {
            //            PumpStateList_fh0 += $"{i}#";
            //        }
            //    }
            //    else if (i == PumpNum)
            //    {
            //        PumpStateList_fh0 += $"{i}#";
            //    }
            //}
            string txt = $@"{time:HH:mm}
方案内容:
    å½“前运行方案:
立新:{PumpStateList_lx0}           å‡ºåŽ‚åŽ‹åŠ›ï¼š{dv[recentRowIndex][4]}MPa
凤凰:{PumpStateList_fh0}           å‡ºåŽ‚åŽ‹åŠ›ï¼š{dv[recentRowIndex][5]}MPa
立新:{PumpStateList_lx0} å‡ºåŽ‚åŽ‹åŠ›ï¼š{dv[recentRowIndex][4]:0.000}MPa å‡ºåŽ‚æµé‡ï¼š{dv[recentRowIndex][38]:0}m³/h
凤凰:{PumpStateList_fh0} å‡ºåŽ‚åŽ‹åŠ›ï¼š{dv[recentRowIndex][5]:0.000}MPa å‡ºåŽ‚æµé‡ï¼š{dv[recentRowIndex][39]:0}m³/h
    æŽ¨èæ–¹æ¡ˆï¼š
立新:{PumpStateList_lx1}           å‡ºåŽ‚åŽ‹åŠ›ï¼š{dv[bestRowIndex][1]}MPa
凤凰:{PumpStateList_fh1}           å‡ºåŽ‚åŽ‹åŠ›ï¼š{dv[bestRowIndex][2]}MPa
{pumpChangeTxt},压力调整
立新:{PumpStateList_lx1} å‡ºåŽ‚åŽ‹åŠ›ï¼š{dv[bestRowIndex][1]:0.000}MPa å‡ºåŽ‚æµé‡ï¼š{dv[recentRowIndex][36]:0}m³/h
凤凰:{PumpStateList_fh1} å‡ºåŽ‚åŽ‹åŠ›ï¼š{dv[bestRowIndex][2]:0.000}MPa å‡ºåŽ‚æµé‡ï¼š{dv[recentRowIndex][37]:0}m³/h
{pumpChangeTxt_lx}{pumpChangeTxt_fh}
";
            txt = txt.Trim('\n').Trim(' ');
            return txt;
@@ -490,26 +552,28 @@
                    content = txt
                }
            });
            using (HttpClient client = new HttpClient())
            if (url == null) return "url is null";
            foreach(var url0 in url.Split(';'))
            {
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpContent content = new StringContent(param, Encoding.UTF8, "application/json");
                HttpResponseMessage response = client.PostAsync(url, content).Result;
                if (response.IsSuccessStatusCode)
                using (HttpClient client = new HttpClient())
                {
                    // å‘送成功
                    return null;
                }
                else
                {
                    // å‘送失败
                    return response.ReasonPhrase;
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    HttpContent content = new StringContent(param, Encoding.UTF8, "application/json");
                    HttpResponseMessage response = client.PostAsync(url0, content).Result;
                    if (!response.IsSuccessStatusCode)
                    {
                        // å‘送失败
                        return response.ReasonPhrase;
                    }
                }
            }
            // å‘送成功
            return null;
        }
    }
    class PointF3D
Hydro.CommonBase/Helper/Type.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CommonBase
{
    public class MyDoubleRange
    {
        public MyDoubleRange(double min, double max)
        {
            Min = min;
            Max = max;
        }
        public double Min { get; set; }
        public double Max { get; set; }
        public double Length { get { return Max - Min; } }
        public bool IsInside(double x)
        {
            return x >= Min && x <= Max;
        }
    }
}
Hydro.CommonBase/Helper/dictHelper.cs
ÎļþÒÑɾ³ý
Hydro.CommonBase/Hydro.CommonBase.csproj
@@ -40,6 +40,9 @@
    <Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
      <HintPath>..\packages\BouncyCastle.Cryptography.2.2.1\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
    </Reference>
    <Reference Include="Dapper, Version=1.50.2.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\Dapper.1.50.2\lib\net451\Dapper.dll</HintPath>
    </Reference>
    <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
      <HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
    </Reference>
@@ -159,9 +162,6 @@
    <Compile Include="component\DeepCopy.cs" />
    <Compile Include="component\dict.cs" />
    <Compile Include="component\json.cs" />
    <Compile Include="component\Range.cs" />
    <Compile Include="component\Relation.cs" />
    <Compile Include="component\Trigger.cs" />
    <Compile Include="control\messageCtrl.cs" />
    <Compile Include="ex\JObjectExtensions.cs" />
    <Compile Include="Helper\Base64Helper.cs" />
@@ -183,6 +183,11 @@
    <Compile Include="IFitnessFunction.cs" />
    <Compile Include="ParamModel.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <None Include="app.config" />
@@ -197,6 +202,12 @@
      <Name>Hydro.Core</Name>
    </ProjectReference>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
Hydro.CommonBase/ParamModel.cs
@@ -11,7 +11,8 @@
//using NPOI.SS.Formula.Eval;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Hydro.Core.Model;
using System.Collections.Concurrent;
using Dapper;
namespace CommonBase
{
@@ -25,6 +26,23 @@
            Count++;
        }
        public GeneticParams(string ConfigPath,  GeneticParams gParam)
        {
            if (gParam == null)  gParam = new GeneticParams(0);
            this.Level = gParam.Level;
            this.ID = gParam.ID;
            if (gParam.Db == null) gParam.Db = new Db();
            if (!string.IsNullOrEmpty(ConfigPath)) gParam.Db.Init(ConfigPath);
            this.Db = gParam.Db;
            if (gParam.Quene!=null) gParam.Quene.Dispose();
            gParam.Quene = new Quene();
            this.Quene= gParam.Quene;
            //获取全局默认设置
            var globalConfig = gParam.Db.Connection.QueryFirstOrDefault<string>("SELECT FValue FROM MyConfig WHERE FKey='GlobalConfig'");
            gParam.GlobalConfig = JsonConvert.DeserializeObject<GlobalConfig>(globalConfig) ?? new GlobalConfig();
            this.GlobalConfig = gParam.GlobalConfig;
            //return gParam;
        }
        public void Dispose()
        {
            onReportProgress = null;
@@ -60,14 +78,14 @@
        public int num;
        public double BestOptValue;
        public DoubleRange tolerance;
        public MyDoubleRange tolerance;
        public FinishEvent onFinished;
        public FinishEvent onError;
        public FinishEvent onReportProgress;
        public SetEvent setVars;
        public Db Db;
        //public SolutionDBHelper SolutionDBHelper = null;
        public dynamic SolutionDBHelper = null;
        public GlobalConfig GlobalConfig;
        public Quene Quene;
        public int Level;
@@ -143,6 +161,46 @@
        public DateTime ScadaTime;
        public List<TimePoint> TimePoints;
        public double BestResult=double.MaxValue;
        public void Dispose()
        {
            if (RequestQueues != null)
            {
                RequestQueues.Clear();
                RequestQueues = null;
            }
            if (RequestFinished != null)
            {
                RequestFinished.Clear();
                RequestFinished = null;
            }
            if (ResultHash != null)
            {
                ResultHash.Clear();
                ResultHash = null;
            }
            if (ResultDictionary != null)
            {
                ResultDictionary.Clear();
                ResultDictionary = null;
            }
            if (ResultChrome != null)
            {
                ResultChrome.Clear();
                ResultChrome = null;
            }
            if (MissionQuene != null)
            {
                MissionQuene.Clear();
                MissionQuene = null;
            }
            if (TimePoints != null)
            {
                TimePoints.Clear();
                TimePoints = null;
            }
        }
    }
    [Serializable]
@@ -155,6 +213,8 @@
        public Guid ID;
        public List<TimePoint> ScadaPoints { get; set; } = new List<TimePoint>();
        public ConcurrentDictionary<string, TimePoint> dict_Scada_key = null;
        public List<TimePoint> ConfigPoints { get; set; } = new List<TimePoint>();
        public List<TimePoint> ResultPoints { get; set; } = new List<TimePoint>();
        public double Fitness = -1;
@@ -303,39 +363,39 @@
        }
    }
    //[Serializable]
    [Serializable]
    //public class TimePoint
    //{
    //    public TimePoint()
    //    {
    public class TimePoint
    {
        public TimePoint()
        {
    //    }
    //    public TimePoint(string key, double value)
    //    {
    //        Key = key;
    //        Value = value;
    //    }
        }
        public TimePoint(string key, double value)
        {
            Key = key;
            Value = value;
        }
    //    public string Name;
    //    public DateTime ValueTime { get; set; }
    //    public string Key { get; set; }
    //    public double Value { get; set; }
    //    public double[] Pattern { get; set; } = null;
    //    public string ModelObjectID { get; set; }
    //    public SettingCalcType CType { get; set; } = SettingCalcType.Add;
        public string Name;
        public DateTime ValueTime { get; set; }
        public string Key { get; set; }
        public double Value { get; set; }
        public double[] Pattern { get; set; } = null;
        public string ModelObjectID { get; set; }
        public SettingCalcType CType { get; set; } = SettingCalcType.Add;
    //    public double SearchRange = 0;
        public double SearchRange = 0;
    //    public bool isNeedtoSave = false;
        public bool isNeedtoSave = false;
    //    public string SaveKey = null;
        public string SaveKey = null;
    //    public override string ToString()
    //    {
    //        return $"{Name}\t[{Key}]\t{Value}";
    //    }
    //}
        public override string ToString()
        {
            return $"{Name}\t[{Key}]\t{Value}";
        }
    }
    [Serializable]
@@ -416,7 +476,7 @@
        public Dictionary<string, variable> dict_Name;
        public Dictionary<int, variable> dict_ID;
        public string inputFileString;
        //public string inputFileString;
        public void buildDict()
        {
@@ -784,12 +844,13 @@
    public class OBJFunction
    {
        public string Text_origin;
        public string Text_change;
        public string Text;
        public string ExpressType;
        public string Name;
        public double value;
        public DoubleRange tolerance;
        public MyDoubleRange tolerance;
        public variable variable;
        public List<variable> paramVariables;
        public List<double> paramValues;
Hydro.CommonBase/Properties/AssemblyInfo.cs
@@ -8,9 +8,9 @@
[assembly: AssemblyTitle("CommonBase")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Administrator")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CommonBase")]
[assembly: AssemblyCopyright("Copyright Â© Administrator 2023")]
[assembly: AssemblyCopyright("Copyright Â©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -20,7 +20,7 @@
[assembly: ComVisible(false)]
// å¦‚果此项目向 COM å…¬å¼€ï¼Œåˆ™ä¸‹åˆ— GUID ç”¨äºŽç±»åž‹åº“çš„ ID
[assembly: Guid("84e17ba3-ba03-43c1-9d19-8ce64508f2b5")]
[assembly: Guid("9f7b845f-4b4d-40e5-bd8e-5afbc23deaca")]
// ç¨‹åºé›†çš„版本信息由下列四个值组成: 
//
Hydro.CommonBase/Properties/Resources.Designer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
//     æ­¤ä»£ç ç”±å·¥å…·ç”Ÿæˆã€‚
//     è¿è¡Œæ—¶ç‰ˆæœ¬:4.0.30319.42000
//
//     å¯¹æ­¤æ–‡ä»¶çš„æ›´æ”¹å¯èƒ½ä¼šå¯¼è‡´ä¸æ­£ç¡®çš„行为,并且如果
//     é‡æ–°ç”Ÿæˆä»£ç ï¼Œè¿™äº›æ›´æ”¹å°†ä¼šä¸¢å¤±ã€‚
// </auto-generated>
//------------------------------------------------------------------------------
namespace CommonBase.Properties {
    using System;
    /// <summary>
    ///   ä¸€ä¸ªå¼ºç±»åž‹çš„资源类,用于查找本地化的字符串等。
    /// </summary>
    // æ­¤ç±»æ˜¯ç”± StronglyTypedResourceBuilder
    // ç±»é€šè¿‡ç±»ä¼¼äºŽ ResGen æˆ– Visual Studio çš„工具自动生成的。
    // è‹¥è¦æ·»åŠ æˆ–ç§»é™¤æˆå‘˜ï¼Œè¯·ç¼–è¾‘ .ResX æ–‡ä»¶ï¼Œç„¶åŽé‡æ–°è¿è¡Œ ResGen
    // (以 /str ä½œä¸ºå‘½ä»¤é€‰é¡¹),或重新生成 VS é¡¹ç›®ã€‚
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    internal class Resources {
        private static global::System.Resources.ResourceManager resourceMan;
        private static global::System.Globalization.CultureInfo resourceCulture;
        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        internal Resources() {
        }
        /// <summary>
        ///   è¿”回此类使用的缓存的 ResourceManager å®žä¾‹ã€‚
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Resources.ResourceManager ResourceManager {
            get {
                if (object.ReferenceEquals(resourceMan, null)) {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CommonBase.Properties.Resources", typeof(Resources).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }
        }
        /// <summary>
        ///   é‡å†™å½“前线程的 CurrentUICulture å±žæ€§ï¼Œå¯¹
        ///   ä½¿ç”¨æ­¤å¼ºç±»åž‹èµ„源类的所有资源查找执行重写。
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Globalization.CultureInfo Culture {
            get {
                return resourceCulture;
            }
            set {
                resourceCulture = value;
            }
        }
    }
}
Hydro.CommonBase/Properties/Resources.resx
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
    <!--
        Microsoft ResX Schema
        Version 1.3
        The primary goals of this format is to allow a simple XML format
        that is mostly human readable. The generation and parsing of the
        various data types are done through the TypeConverter classes
        associated with the data types.
        Example:
        ... ado.net/XML headers & schema ...
        <resheader name="resmimetype">text/microsoft-resx</resheader>
        <resheader name="version">1.3</resheader>
        <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
        <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
        <data name="Name1">this is my long string</data>
        <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
        <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
            [base64 mime encoded serialized .NET Framework object]
        </data>
        <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
            [base64 mime encoded string representing a byte array form of the .NET Framework object]
        </data>
        There are any number of "resheader" rows that contain simple
        name/value pairs.
        Each data row contains a name, and value. The row also contains a
        type or mimetype. Type corresponds to a .NET class that support
        text/value conversion through the TypeConverter architecture.
        Classes that don't support this are serialized and stored with the
        mimetype set.
        The mimetype is used for serialized objects, and tells the
        ResXResourceReader how to depersist the object. This is currently not
        extensible. For a given mimetype the value must be set accordingly:
        Note - application/x-microsoft.net.object.binary.base64 is the format
        that the ResXResourceWriter will generate, however the reader can
        read any of the formats listed below.
        mimetype: application/x-microsoft.net.object.binary.base64
        value   : The object must be serialized with
            : System.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
        mimetype: application/x-microsoft.net.object.soap.base64
        value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.
        mimetype: application/x-microsoft.net.object.bytearray.base64
        value   : The object must be serialized into a byte array
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
    <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
        <xsd:element name="root" msdata:IsDataSet="true">
            <xsd:complexType>
                <xsd:choice maxOccurs="unbounded">
                    <xsd:element name="data">
                        <xsd:complexType>
                            <xsd:sequence>
                                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
                            </xsd:sequence>
                            <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
                            <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
                            <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
                        </xsd:complexType>
                    </xsd:element>
                    <xsd:element name="resheader">
                        <xsd:complexType>
                            <xsd:sequence>
                                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                            </xsd:sequence>
                            <xsd:attribute name="name" type="xsd:string" use="required" />
                        </xsd:complexType>
                    </xsd:element>
                </xsd:choice>
            </xsd:complexType>
        </xsd:element>
    </xsd:schema>
    <resheader name="resmimetype">
        <value>text/microsoft-resx</value>
    </resheader>
    <resheader name="version">
        <value>1.3</value>
    </resheader>
    <resheader name="reader">
        <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    </resheader>
    <resheader name="writer">
        <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    </resheader>
</root>
Hydro.CommonBase/Resources/config.wdb
Binary files differ
Hydro.CommonBase/component/Range.cs
ÎļþÒÑɾ³ý
Hydro.CommonBase/component/Relation.cs
ÎļþÒÑɾ³ý
Hydro.CommonBase/component/Trigger.cs
ÎļþÒÑɾ³ý
Hydro.CommonBase/component/dict.cs
@@ -10,6 +10,7 @@
using System.Data;
//using æ–‡ä»¶è¯»å†™;
namespace CommonBase
{
Hydro.CommonBase/packages.config
@@ -2,6 +2,7 @@
<packages>
  <package id="AForge" version="2.2.5" targetFramework="net472" />
  <package id="BouncyCastle.Cryptography" version="2.2.1" targetFramework="net472" />
  <package id="Dapper" version="1.50.2" targetFramework="net472" />
  <package id="EntityFramework" version="6.4.4" targetFramework="net472" />
  <package id="Enums.NET" version="4.0.1" targetFramework="net472" />
  <package id="ExcelDataReader" version="3.6.0" targetFramework="net472" />
Hydro.HydraulicOptimizer/Hydro.HydraulicOptimizer.csproj
@@ -34,8 +34,8 @@
    <Reference Include="AForge, Version=2.2.5.0, Culture=neutral, PublicKeyToken=c1db6ff4eaa06aeb, processorArchitecture=MSIL">
      <HintPath>..\packages\AForge.2.2.5\lib\AForge.dll</HintPath>
    </Reference>
    <Reference Include="Dapper, Version=1.50.1.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\Dapper.1.50.1\lib\net451\Dapper.dll</HintPath>
    <Reference Include="Dapper, Version=1.50.2.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\Dapper.1.50.2\lib\net451\Dapper.dll</HintPath>
    </Reference>
    <Reference Include="HydraulicHelper">
      <HintPath>..\Lib\HydraulicHelper.dll</HintPath>
Hydro.HydraulicOptimizer/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="AForge" version="2.2.5" targetFramework="net472" />
  <package id="Dapper" version="1.50.1" targetFramework="net472" />
  <package id="Dapper" version="1.50.2" targetFramework="net472" />
  <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
</packages>
Hydro.Inp/NetWork.cs
@@ -174,20 +174,20 @@
            nozzles.ForEach(nozzle => { AddNozzle(nozzle); });
        }
        private void CheckNodesExist(NodeModel node)
        private void CheckNodesExist(NodeCalcModel node)
        {
            if (Nodes.Any(d => d.ID == node.ID))
                throw new Exception("已存在重复的对象");
        }
        private void CheckLinksExist(LinkModel link)
        private void CheckLinksExist(LinkCalcModel link)
        {
            if (Links.Any(d => d.ID == link.ID))
                throw new Exception("已存在重复的对象");
        }
        public List<NodeModel> Nodes { get; set; } = new List<NodeModel>();
        public List<LinkModel> Links { get; set; } = new List<LinkModel>();
        public List<NodeCalcModel> Nodes { get; set; } = new List<NodeCalcModel>();
        public List<LinkCalcModel> Links { get; set; } = new List<LinkCalcModel>();
        /// <summary>
        /// æ ¹æ®INP文件生成
Hydro.MapBase/GlobalObject.cs
@@ -4,7 +4,7 @@
using System.Text;
using System.Threading.Tasks;
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    public class GlobalObject
    {
Hydro.MapBase/Hydro.MapUI.csproj
@@ -68,11 +68,17 @@
    <Compile Include="ChartPump.Designer.cs">
      <DependentUpon>ChartPump.cs</DependentUpon>
    </Compile>
    <Compile Include="Magnifier\InputBox.cs">
    <Compile Include="WindowsForm\InputBox.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="Magnifier\InputBox.designer.cs">
    <Compile Include="WindowsForm\InputBox.designer.cs">
      <DependentUpon>InputBox.cs</DependentUpon>
    </Compile>
    <Compile Include="WindowsForm\Progress.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="WindowsForm\Progress.designer.cs">
      <DependentUpon>Progress.cs</DependentUpon>
    </Compile>
    <Compile Include="Map\MapViewer.Model.cs" />
    <Compile Include="Map\MapContainer.cs">
@@ -106,10 +112,10 @@
      <DependentUpon>propertyform.cs</DependentUpon>
    </Compile>
    <Compile Include="GlobalObject.cs" />
    <Compile Include="Magnifier\Form_Magnifier.cs">
    <Compile Include="WindowsForm\Form_Magnifier.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="Magnifier\Form_Magnifier.Designer.cs">
    <Compile Include="WindowsForm\Form_Magnifier.Designer.cs">
      <DependentUpon>Form_Magnifier.cs</DependentUpon>
    </Compile>
    <Compile Include="Map\map_old.Model.cs" />
@@ -127,8 +133,11 @@
    <EmbeddedResource Include="ChartPump.resx">
      <DependentUpon>ChartPump.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="Magnifier\InputBox.resx">
    <EmbeddedResource Include="WindowsForm\InputBox.resx">
      <DependentUpon>InputBox.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="WindowsForm\Progress.resx">
      <DependentUpon>Progress.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="Map\MapContainer.resx">
      <DependentUpon>MapContainer.cs</DependentUpon>
@@ -145,7 +154,7 @@
    <EmbeddedResource Include="WindowsForm\propertyform.resx">
      <DependentUpon>propertyform.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="Magnifier\Form_Magnifier.resx">
    <EmbeddedResource Include="WindowsForm\Form_Magnifier.resx">
      <DependentUpon>Form_Magnifier.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="Map\map_old.resx">
Hydro.MapBase/Map/MapContainer.Designer.cs
@@ -1,4 +1,4 @@
namespace CloudWaterNetwork.Map
namespace Hydro.MapUI
{
    partial class MapContainer
    {
Hydro.MapBase/Map/MapContainer.cs
@@ -8,7 +8,7 @@
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CloudWaterNetwork.Map
namespace Hydro.MapUI
{
    public partial class MapContainer : UserControl
    {
Hydro.MapBase/Map/MapViewer.Designer.cs
@@ -1,9 +1,9 @@
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using CloudWaterNetwork.Magnifier;
//using CloudWaterNetwork.Magnifier;
using CommonBase;
using ConfigApp;
//using ConfigApp;
//using DevExpress.Diagram.Core.Layout;
//using DevExpress.DirectX.NativeInterop.Direct2D;
//using DevExpress.Utils.Extensions;
@@ -40,7 +40,7 @@
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
using Cursor = System.Windows.Forms.Cursor;
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    partial class MapViewer
    {
Hydro.MapBase/Map/MapViewer.Model.cs
@@ -1,4 +1,4 @@
using CloudWaterNetwork.Magnifier;
//using CloudWaterNetwork.Magnifier;
//using dict_py_Inner;
using Hydro.MapView;
using Hydro.MapView.Base;
@@ -27,7 +27,7 @@
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
using Cursor = System.Windows.Forms.Cursor;
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    public partial class empty
    {
@@ -67,7 +67,8 @@
        }
        private Template __template = null;
        private Template _Template
        [Browsable (false)]
        public Template _Template
        {
            get { return __template; }
            set
Hydro.MapBase/Map/MapViewer.cs
@@ -1,6 +1,6 @@
using CloudWaterNetwork.Magnifier;
//using CloudWaterNetwork.Magnifier;
using CommonBase;
using ConfigApp;
//using ConfigApp;
//using DevExpress.Diagram.Core.Layout;
//using DevExpress.DirectX.NativeInterop.Direct2D;
//using DevExpress.Utils.Extensions;
@@ -37,7 +37,7 @@
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
using Cursor = System.Windows.Forms.Cursor;
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    public partial class MapViewer : UserControl
    {
Hydro.MapBase/Map/map_old.Designer.cs
@@ -1,4 +1,4 @@
using CloudWaterNetwork.Magnifier;
//using CloudWaterNetwork.Magnifier;
//using dict_py_Inner;
using System;
using System.Collections;
@@ -25,7 +25,7 @@
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
using Cursor = System.Windows.Forms.Cursor;
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    public partial class MapViewer_Old
    {
Hydro.MapBase/Map/map_old.Model.cs
@@ -1,4 +1,4 @@
using CloudWaterNetwork.Magnifier;
//using CloudWaterNetwork.Magnifier;
//using dict_py_Inner;
using Hydro.MapView;
using Hydro.MapView.Base;
@@ -27,7 +27,7 @@
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
using Cursor = System.Windows.Forms.Cursor;
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    public partial class empty
    {
Hydro.MapBase/Map/map_old.cs
@@ -1,6 +1,6 @@
using CloudWaterNetwork.Magnifier;
//using CloudWaterNetwork.Magnifier;
using CommonBase;
using ConfigApp;
//using ConfigApp;
//using DevExpress.Diagram.Core.Layout;
//using DevExpress.DirectX.NativeInterop.Direct2D;
//using DevExpress.Utils.Extensions;
@@ -37,7 +37,7 @@
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
using Cursor = System.Windows.Forms.Cursor;
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    public partial class MapViewer_Old : UserControl
    {
Hydro.MapBase/WindowsForm/Form_EditFloors.Designer.cs
@@ -1,4 +1,4 @@
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    partial class Form_EditFloors
    {
Hydro.MapBase/WindowsForm/Form_EditFloors.cs
@@ -1,5 +1,5 @@
using CommonBase;
using ConfigApp;
//using ConfigApp;
using Hydro.MapView;
//using DevExpress.XtraEditors;
//using DevExpress.XtraGrid.Views.Base;
@@ -15,7 +15,7 @@
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using TRegion = Hydro.MapView.TRegion;
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    public partial class Form_EditFloors : Form
    {
Hydro.MapBase/WindowsForm/Form_Magnifier.Designer.cs
ÎļþÃû´Ó Hydro.MapBase/Magnifier/Form_Magnifier.Designer.cs ÐÞ¸Ä
@@ -1,4 +1,4 @@
namespace CloudWaterNetwork.Magnifier
namespace Hydro.MapUI
{
    partial class Form_Magnifier
    {
Hydro.MapBase/WindowsForm/Form_Magnifier.cs
ÎļþÃû´Ó Hydro.MapBase/Magnifier/Form_Magnifier.cs ÐÞ¸Ä
@@ -10,7 +10,7 @@
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CloudWaterNetwork.Magnifier
namespace Hydro.MapUI
{
    public partial class Form_Magnifier : Form
    {
Hydro.MapBase/WindowsForm/Form_Magnifier.resx
Hydro.MapBase/WindowsForm/Form_importObjs.Designer.cs
@@ -1,4 +1,4 @@
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    partial class Form_importObjs
    {
Hydro.MapBase/WindowsForm/Form_importObjs.cs
@@ -10,7 +10,7 @@
using System.Windows.Forms;
using static Hydro.MapView.MapViewEnum;
using Hydro.MapView.Common;
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    public partial class Form_importObjs : Form
    {
Hydro.MapBase/WindowsForm/InputBox.Designer.cs
ÎļþÃû´Ó Hydro.MapBase/Magnifier/InputBox.Designer.cs ÐÞ¸Ä
@@ -1,5 +1,5 @@

namespace ConfigApp
namespace Hydro.MapUI
{
    partial class InputBox
    {
Hydro.MapBase/WindowsForm/InputBox.cs
ÎļþÃû´Ó Hydro.MapBase/Magnifier/InputBox.cs ÐÞ¸Ä
@@ -8,7 +8,7 @@
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ConfigApp
namespace Hydro.MapUI
{
    public partial class InputBox : Form
    {
Hydro.MapBase/WindowsForm/InputBox.resx
Hydro.MapBase/WindowsForm/Progress.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,159 @@

using CommonBase;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Hydro.MapUI
{
    public partial class ProgressForm_计算 : Form
    {
        private Thread progressThread;
        public ProgressForm_计算()
        {
            InitializeComponent();
        }
        private void ProgressForm_Load(object sender, EventArgs e)
        {
            StartProgressThread();
            this.Activate();
        }
        private void StartProgressThread()
        {
            progressThread = new Thread(UpdateProgress);
            progressThread.IsBackground = true;
            progressThread.Start();
        }
        private void StopProgressThread()
        {
            if (progressThread != null && progressThread.IsAlive)
            {
                progressThread.Abort();
            }
        }
        bool isHided = false;
        //public void reSetProgress()
        //{
        //    BeginInvoke(new Action(() =>
        //    {
        //        progressBar1.Value = 0;
        //    }));
        //}
        private void UpdateProgress()
        {
            while (!GlobalProgress.NeedStop)
            {
                if (GlobalProgress.Hide )
                {
                    BeginInvoke(new Action(() =>
                    {
                        this.Size = new System.Drawing.Size(0,0);
                    }));
                }
                else
                if (!GlobalProgress.Hide)
                {
                    BeginInvoke(new Action(() =>
                    {
                        this.Size = new System.Drawing.Size(419, 178);
                    }));
                }
                string stateText = GlobalProgress.stateText;
                int maxNum = GlobalProgress.MaxNum;
                int currentNum = GlobalProgress.CurrentNum;
                int childmaxNum = GlobalProgress.ChildMaxNum;
                int childcurrentNum = GlobalProgress.ChildCurrentNum;
                string childText = GlobalProgress.ChildText;
                lock (GlobalProgress.Instance)
                {
                     stateText = GlobalProgress.stateText;
                     maxNum = GlobalProgress.MaxNum;
                     currentNum = GlobalProgress.CurrentNum;
                     childmaxNum = GlobalProgress.ChildMaxNum;
                     childcurrentNum = GlobalProgress.ChildCurrentNum;
                }
                // ä½¿ç”¨ Invoke æ–¹æ³•让 UI çº¿ç¨‹æ›´æ–°æŽ§ä»¶
                BeginInvoke(new Action(() =>
                {
                    if (GlobalProgress.mode == 0)
                    {
                        label1.Text = $"{stateText}[{currentNum}/{maxNum}]";
                        progressBar1.Maximum = maxNum * 150;
                        List<int> nums = new List<int>();
                        nums.Add(0);
                        nums.Add(progressBar1.Maximum * 4 / 5);
                        int span = 0;
                        if (maxNum>1) span=(int)( progressBar1.Maximum / 5.0 /(maxNum-1));
                        for (int i = 1; i < maxNum; i++)
                        {
                            nums.Add(nums[i - 1] + span);
                        }
                        if (currentNum < nums.Count && progressBar1.Value < nums[currentNum])
                        {
                            progressBar1.Value = nums[currentNum];
                            progressBar2.Value = 0;
                        }
                        else if (currentNum + 1 < nums.Count && progressBar1.Value < (nums[currentNum + 1]))
                            progressBar1.Value = Math.Min(progressBar1.Value + 2, progressBar1.Maximum);
                        metroLabel1.Text = $"{childText}[{childcurrentNum}/{childmaxNum}]";
                        progressBar2.Maximum = childmaxNum * 100;
                        if (progressBar2.Value < childcurrentNum * 100)
                            progressBar2.Value = childcurrentNum * 100;
                        else if (progressBar2.Value < (childcurrentNum + 1) * 100)
                            progressBar2.Value = Math.Min(progressBar2.Value + 4, progressBar2.Maximum);
                    }
                    else
                    {
                        label1.Text = $"{stateText}[{currentNum}/{maxNum}]";
                        progressBar1.Maximum = maxNum;
                        progressBar1.Value = currentNum;
                    }
                    //this.Activate();
                }));
                Thread.Sleep(100);  // æ¯éš”0.1秒检索一次
            }
            BeginInvoke(new Action(() =>
            {
                this.Hide();
            }));
        }
        private void ProgressForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            StopProgressThread();
        }
        private void label1_Click(object sender, EventArgs e)
        {
        }
    }
}
Hydro.MapBase/WindowsForm/Progress.designer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,116 @@
namespace Hydro.MapUI
{
    partial class ProgressForm_计算
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProgressForm_计算));
            this.progressBar1 = new System.Windows.Forms.ProgressBar();
            this.label1 = new System.Windows.Forms.Label();
            this.progressBar2 = new System.Windows.Forms.ProgressBar();
            this.metroLabel1 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            //
            // progressBar1
            //
            this.progressBar1.Dock = System.Windows.Forms.DockStyle.Top;
            //this.progressBar1.HideProgressText = false;
            this.progressBar1.Location = new System.Drawing.Point(20, 49);
            this.progressBar1.MarqueeAnimationSpeed = 250;
            this.progressBar1.Name = "progressBar1";
            this.progressBar1.Size = new System.Drawing.Size(363, 25);
            this.progressBar1.Step = 1;
            this.progressBar1.TabIndex = 1;
            //
            // label1
            //
            this.label1.Dock = System.Windows.Forms.DockStyle.Top;
            this.label1.Location = new System.Drawing.Point(20, 30);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(363, 19);
            this.label1.TabIndex = 2;
            this.label1.Text = "初始化[1/1]";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            this.label1.Click += new System.EventHandler(this.label1_Click);
            //
            // progressBar2
            //
            this.progressBar2.Dock = System.Windows.Forms.DockStyle.Top;
            this.progressBar2.ForeColor = System.Drawing.SystemColors.GradientActiveCaption;
            //this.progressBar2.HideProgressText = false;
            this.progressBar2.Location = new System.Drawing.Point(20, 93);
            this.progressBar2.MarqueeAnimationSpeed = 250;
            this.progressBar2.Maximum = 4;
            this.progressBar2.Name = "progressBar2";
            this.progressBar2.Size = new System.Drawing.Size(363, 22);
            this.progressBar2.Step = 1;
            //this.progressBar2.Style = MetroFramework.MetroColorStyle.Green;
            this.progressBar2.TabIndex = 1;
            //
            // metroLabel1
            //
            this.metroLabel1.Dock = System.Windows.Forms.DockStyle.Top;
            this.metroLabel1.Location = new System.Drawing.Point(20, 74);
            this.metroLabel1.Name = "metroLabel1";
            this.metroLabel1.Size = new System.Drawing.Size(363, 19);
            this.metroLabel1.TabIndex = 3;
            this.metroLabel1.Text = "分项任务[1/1]";
            this.metroLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            //
            // ProgressForm
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(403, 139);
            this.Controls.Add(this.progressBar2);
            this.Controls.Add(this.metroLabel1);
            this.Controls.Add(this.progressBar1);
            this.Controls.Add(this.label1);
            //this.DisplayHeader = false;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "ProgressForm";
            this.Padding = new System.Windows.Forms.Padding(20, 30, 20, 20);
            //this.Resizable = false;
            this.ShowInTaskbar = false;
            this.Text = "Progress";
            this.TopMost = true;
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ProgressForm_FormClosing);
            this.Load += new System.EventHandler(this.ProgressForm_Load);
            this.ResumeLayout(false);
        }
        #endregion
        public System.Windows.Forms.ProgressBar progressBar1;
        public System.Windows.Forms.Label label1;
        public System.Windows.Forms.ProgressBar progressBar2;
        public System.Windows.Forms.Label metroLabel1;
    }
}
Hydro.MapBase/WindowsForm/Progress.resx
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!--
    Microsoft ResX Schema
    Version 2.0
    The primary goals of this format is to allow a simple XML format
    that is mostly human readable. The generation and parsing of the
    various data types are done through the TypeConverter classes
    associated with the data types.
    Example:
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
    There are any number of "resheader" rows that contain simple
    name/value pairs.
    Each data row contains a name, and value. The row also contains a
    type or mimetype. Type corresponds to a .NET class that support
    text/value conversion through the TypeConverter architecture.
    Classes that don't support this are serialized and stored with the
    mimetype set.
    The mimetype is used for serialized objects, and tells the
    ResXResourceReader how to depersist the object. This is currently not
    extensible. For a given mimetype the value must be set accordingly:
    Note - application/x-microsoft.net.object.binary.base64 is the format
    that the ResXResourceWriter will generate, however the reader can
    read any of the formats listed below.
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAABILAAASCwAAAAAAAAAA
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
        AAAAAAAASD85skg/Of9IPzn/SD85/0g/Of9IPzn/SD85/0g/Of9IPzn/SD85/0g/Of9IPzn/SD85/0g/
        Of9IPzn/SD85skg/Of/t6uj/7ero/+3q6P/t6uj/d2he/+3q6P/t6uj/7ero/+3q6P93aF7/7ero/+3q
        6P/t6uj/7ero/0g/Of9IPzn/5eDc/+Xg3P/l4Nz/5eDc/3doXv/l4Nz/5eDc/+Xg3P/l4Nz/d2he/+Xg
        3P/l4Nz/5eDc/+Xg3P9IPzn/SD85//j39v/49/b/+Pf2//j39v93aF7/+Pf2//j39v/49/b/+Pf2/3do
        Xv/49/b/+Pf2//j39v/49/b/SD85/0g/ObJIPzn/SD85/0g/Of9IPzn/s2EK/7NhCv+zYQr/s2EK/7Nh
        Cv+zYQr/d2he/3doXv93aF7/d2he/0g/Of8AAAAAAAAAAAAAAAAAAAAAAAAAALNhCv/o1q//6Nav/+jW
        r//o1q//s2EK/+3q6P/t6uj/7ero/+3q6P9IPzn/AAAAAAAAAAAAAAAAAAAAAAAAAACzYQr/5tKo/+bS
        qP/m0qj/5tKo/7NhCv/l4Nz/5eDc/+Xg3P/l4Nz/SD85/wAAAAAAAAAAAAAAAAAAAACzYQr/s2EK/7Nh
        Cv/69ez/+vXs//r17P+zYQr/+Pf2//j39v/49/b/+Pf2/0g/Of8AAAAAAAAAAAAAAAAAAAAAs2EK/7Nh
        Cv+zYQr/s2EK/7NhCv+zYQr/s2EK/7NhCv+zYQr/s2EK/7NhCv+zYQr/AAAAAAAAAAAAAAAAAAAAALNh
        Cv+zYQr/s2EK/wAAAAAAAAAAAAAAALNhCv/o1q//6Nav/+jWr//o1q//s2EK/wAAAAAAAAAAAAAAAAAA
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACzYQr/5tKo/+bSqP/m0qj/5tKo/7NhCv8AAAAAAAAAAAAA
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACzYQr/s2EK/7NhCv/69ez/+vXs//r17P+zYQr/AAAAAAAA
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAs2EK/7NhCv+zYQr/s2EK/7NhCv+zYQr/s2EKsgAA
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALNhCv+zYQr/s2EK/wAAAAAAAAAAAAAAAAAA
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
        AAAAAAAAAAAAAP//AAD//wAA//8AAP//AAD//wAAB/8AAAf/AAAP/wAAD/8AAA4/MXcAPzJ3AH8AAAB/
        AAAAcAAAAAAAAA==
</value>
  </data>
</root>
Hydro.MapBase/WindowsForm/propertyform.cs
@@ -14,7 +14,7 @@
using static Hydro.MapView.MapViewEnum;
using Hydro.MapView.Common;
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    
Hydro.MapBase/WindowsForm/propertyform.designer.cs
@@ -1,4 +1,4 @@
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    partial class PropertyForm
    {
Hydro.MapBase/WindowsForm/Ä£°å¹ÜÀí.Designer.cs
@@ -1,4 +1,4 @@
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    partial class æ¨¡æ¿ç®¡ç†
    {
Hydro.MapBase/WindowsForm/Ä£°å¹ÜÀí.cs
@@ -23,7 +23,7 @@
using static Hydro.MapView.MapViewEnum;
using CommonBase;
namespace CloudWaterNetwork
namespace Hydro.MapUI
{
    public partial class æ¨¡æ¿ç®¡ç† : Form
    {
Hydro.MapView/Base/LinkViewModel.cs
@@ -14,7 +14,7 @@
namespace Hydro.MapView
{
    public class LinkViewModel : LinkModel, IBaseViewModel
    public class LinkViewModel : LinkCalcModel, IBaseViewModel
    {
        public LinkViewModel()
        {
@@ -44,7 +44,7 @@
        {
            get
            {
                if (StartNode != null && Node1 != StartNode.ID)
                if (StartNode != null && base.Node1 != StartNode.ID)
                {
                    base.Node1 = StartNode.ID;
                }
@@ -66,7 +66,7 @@
        {
            get
            {
                if (EndNode != null && Node2 != EndNode.ID)
                if (EndNode != null && base.Node2 != EndNode.ID)
                {
                    base.Node2 = EndNode.ID;
                }
Hydro.MapView/Base/NodeViewModel.cs
@@ -14,7 +14,7 @@
namespace Hydro.MapView
{
    public class NodeViewModel : NodeModel, IBaseViewModel
    public class NodeViewModel : NodeCalcModel, IBaseViewModel
    {
        public NodeViewModel()
        {
@@ -227,5 +227,14 @@
            if (this is NozzleViewModel) return true;
            return false;
        }
        public string ToEmitterString()
        {
            if (this is NozzleViewModel n)
            {
                if (n.FlowCoefficient > 0)
                    return $"{ID}\t{n.FlowCoefficient * Math.Pow(10 / 101.972, 0.5) / 1000 * 60}\r\n";
            }
            return null;
        }
    }
}
Hydro.MapView/MapViewNetWork.cs
@@ -28,12 +28,12 @@
        /// <summary>
        /// æ ¸å¿ƒæ‰¿è½½å­—段
        /// </summary>
        public new List<NodeViewModel> Nodes = new List<NodeViewModel>();
        //public new List<NodeViewModel> Nodes = new List<NodeViewModel>();
        /// <summary>
        /// æ ¸å¿ƒæ‰¿è½½å­—段
        /// </summary>
        public new List<LinkViewModel> Links = new List<LinkViewModel>();
        //public new List<LinkViewModel> Links = new List<LinkViewModel>();
        public Dictionary<string, Dataset> dict_dataset;// = new Dictionary<string, Dataset>();
        public HashSet<string> Hash_ID;
@@ -683,10 +683,10 @@
        {
            get
            {
                List<IBaseViewModel> objects = new List<IBaseViewModel>();
                List<BaseModel> objects = new List<BaseModel>();
                objects.AddRange(Nodes);
                objects.AddRange(Links);
                return objects;
                return objects.Select(o=>(IBaseViewModel)o).ToList();
            }
        }
        public void Rename()
Hydro.MapView/MapViewNetWork2Inp.cs
@@ -1,4 +1,5 @@
using Hydro.Core.Model;
using Hydro.MapView.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
@@ -7,6 +8,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using static Hydro.Core.ObjectEnum;
using static Hydro.MapView.RepeaterViewModel;
@@ -854,5 +856,250 @@
        }
        public void BuildToInp(string filePath, string userCoorString = null, string sourcePath = null, bool isReplace = false)
        {
            if (sourcePath == null) sourcePath = filePath;
            string tempString = "";
            if (!isReplace)
            {
                var tempPath = Path.Combine(Directory.GetCurrentDirectory(), @"template\inp\导出模板.inp");
                if (!File.Exists(tempPath))
                {
                    //MessageBox.Show($"模板文件不存在[{tempPath}]");
                    return;
                }
                tempString = File.ReadAllText(tempPath);
            }
            else
            {
                tempString = File.ReadAllText(sourcePath);
            }
            Dictionary<string, string> dictExchange = new Dictionary<string, string>() {
                {"{junctions}","{0}" },
                {"{reservoirs}","{1}" },
                {"{tanks}","{2}" },
                {"{pipes}","{3}" },
                {"{valves}","{4}" },
                {"{pumps}","{5}" },
                {"{coor}","{6}" },
                {"{curve}","{7}" },
            };
            dictExchange.ToList().ForEach(m => tempString = tempString.Replace(m.Key, m.Value));
            StringBuilder junctionStringBuilder = new StringBuilder();
            junctionStringBuilder.AppendLine(";ID                  Elev            Demand          Pattern         Type");
            Nodes.ForEach(o =>
            {
                if (!o.Visible) return;
                if (o is JunctionViewModel j)
                    junctionStringBuilder.AppendLine(j.ToString() + $"{j.Level}\tJunction");
                else if (o is MeterViewModel m)
                    junctionStringBuilder.AppendLine(m.ToString() + $"{o.Level}\tMeter");
                else if (o is NozzleViewModel no)
                    junctionStringBuilder.AppendLine(no.ToString() + $"{o.Level}\tNozzle\t{no.FlowCoefficient}");
            });
            string junctionString = junctionStringBuilder.ToString();
            StringBuilder reservoirStringBuilder = new StringBuilder();
            reservoirStringBuilder.AppendLine(";ID                  Head            Pattern ");
            reservoirs.ForEach(o =>
            {
                if (!o.Visible) return;
                reservoirStringBuilder.AppendLine(o.ToString() + $"{o.Level}\t{o.Elev}");
            });
            string reserverString = reservoirStringBuilder.ToString();
            StringBuilder tankStringBuilder = new StringBuilder();
            tankStringBuilder.AppendLine(";ID                  Elevation       InitLevel       MinLevel        MaxLevel        Diameter        MinVol          VolCurve            Overflow");
            tanks.ForEach(o =>
            {
                if (!o.Visible) return;
                tankStringBuilder.AppendLine(o.ToString() + $"{o.Level}");
            });
            string tankString = tankStringBuilder.ToString();
            StringBuilder pipeStringBuilder = new StringBuilder();
            pipeStringBuilder.AppendLine(";ID                  Node1               Node2               Length          Diameter        Roughness       MinorLoss       Status");
            Links.ForEach(o =>
            {
                if (!o.Visible) return;
                if (o is PipeViewModel p)
                    pipeStringBuilder.AppendLine(p.ToString() + $"{p.Level}");
                else if (o is RepeaterViewModel r)
                    pipeStringBuilder.AppendLine(r.ToString());
            });
            string pipeString = pipeStringBuilder.ToString();
            StringBuilder valveStringBuilder = new StringBuilder();
            valveStringBuilder.AppendLine(";ID                  Node1               Node2               Diameter        Type    Setting         MinorLoss  ");
            valves.ForEach(o =>
            {
                if (!o.Visible) return;
                valveStringBuilder.AppendLine(o.ToString() + $"{o.Level}");
            });
            string valveString = valveStringBuilder.ToString();
            StringBuilder pumpStringBuilder = new StringBuilder();
            pumpStringBuilder.AppendLine(";ID                  Node1               Node2               Diameter        Type    Setting         MinorLoss  ");
            pumps.ForEach(o =>
            {
                if (!o.Visible) return;
                pumpStringBuilder.AppendLine(o.ToString() + $"{o.Level}");
            });
            string pumpString = pumpStringBuilder.ToString();
            StringBuilder curveStringBuilder = new StringBuilder();
            //pumps.ForEach(o =>
            //{
            //    if (!o.Visible || !o.Datasets.ContainsKey("流量扬程曲线")) return;
            //    curveStringBuilder.AppendLine(o.Datasets["流量扬程曲线"].ToString());
            //});
            if (dict_dataset != null)
                foreach (var kp in dict_dataset)
                {
                    curveStringBuilder.AppendLine(kp.Value.ToString());
                }
            string curveString = curveStringBuilder.ToString();
            StringBuilder coorStringBuilder = new StringBuilder();
            if (userCoorString == null)
            {
                coorStringBuilder.AppendLine(";Node                X-Coord               Y-Coord");
                Nodes.ForEach(o => coorStringBuilder.AppendLine(o.ToCoorString()));
            }
            else
            {
                coorStringBuilder.Append(userCoorString);
            }
            string coorString = coorStringBuilder.ToString();
            string output = "";
            StringBuilder emitterStringBuilder = new StringBuilder();
            emitterStringBuilder.AppendLine(";Junction        \tCoefficient");
            Nodes.ForEach(o => emitterStringBuilder.Append(o.ToEmitterString()));
            string emitterString = emitterStringBuilder.ToString();
            StringBuilder statusStringBuilder = new StringBuilder();
            statusStringBuilder.AppendLine(";ID              \tStatus/Setting\r\n");
            Links.ForEach(o => statusStringBuilder.Append(o.ToStatusString()));
            string statusString = statusStringBuilder.ToString();
            output = tempString;
            output = replaceContent(output, "JUNCTIONS", junctionString);
            output = replaceContent(output, "RESERVOIRS", reserverString);
            output = replaceContent(output, "TANKS", tankString);
            output = replaceContent(output, "PIPES", pipeString);
            output = replaceContent(output, "VALVES", valveString);
            output = replaceContent(output, "PUMPS", pumpString);
            output = replaceContent(output, "CURVES", curveString);
            output = replaceContent(output, "COORDINATES", coorString);
            output = replaceContent(output, "EMITTERS", emitterString);
            output = replaceContent(output, "STATUS", statusString);
            string backupFolderPath = Path.Combine(Path.GetDirectoryName(filePath), "bk");
            if (!Directory.Exists(backupFolderPath))
            {
                Directory.CreateDirectory(backupFolderPath);
            }
            string backupFileName = $"{Path.GetFileNameWithoutExtension(filePath)}_{DateTime.Now:yyyyMMddHHmmss}{Path.GetExtension(filePath)}";
            string backupFilePath = Path.Combine(backupFolderPath, backupFileName);
            if (File.Exists(filePath)) File.Copy(filePath, backupFilePath, true);
            // æ£€æŸ¥æ–‡ä»¶æ˜¯å¦å­˜åœ¨
            try
            {
                Global.ClearFileReadOnly(filePath);
                File.WriteAllText(filePath, output);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //MessageBox.Show($"保存成功!");
        }
        private string replaceContent(string text, string content, string replaceString)
        {
            string str = replaceString;
            string replacedText = ReplaceCoordinatesSection(text, content, str);
            return replacedText;
            //Console.WriteLine(replacedText);
        }
        public static string ReplaceCoordinatesSection(string text, string content, string str)
        {
            string pattern = $@"(\[{content}\]).*?(\[|$)";
            string replacedText = Regex.Replace(text, pattern, match =>
            {
                string section = match.Groups[2].Value.Trim();
                if (!string.IsNullOrEmpty(section))
                {
                    return $"{match.Groups[1].Value}\n{str}\n[";
                }
                else
                {
                    return $"{match.Groups[1].Value}\n{str}\n[";
                }
            }, RegexOptions.Singleline);
            return replacedText;
        }
    }
}
Hydro.Revit/RevitNetWork.cs
@@ -31,6 +31,13 @@
        public  void AddTanks(List<WaterTankViewModel> tanks)
        {
            tanks.ForEach(tank => { AddTank(tank); });
            WaterTankViewModel kk=null;
            Nodes.Select(n => (WaterTankViewModel)n).ToList().Sort(o => o.PositionJson);
            WaterTankViewModels
           ((WaterTankViewModel) Nodes[0]).PositionJson
        }
        public  void AddPipe(PipeViewModel pipe)
@@ -85,13 +92,13 @@
            nozzles.ForEach(nozzle => { AddNozzle(nozzle); });
        }
        private void CheckNodesExist(NodeModel node)
        private void CheckNodesExist(NodeCalcModel node)
        {
            if (Nodes.Any(d => d.ID == node.ID))
                throw new Exception("已存在重复的对象");
        }
        private void CheckLinksExist(LinkModel link)
        private void CheckLinksExist(LinkCalcModel link)
        {
            if (Links.Any(d => d.ID == link.ID))
                throw new Exception("已存在重复的对象");
TestForm/Form1.Designer.cs
@@ -28,56 +28,78 @@
        /// </summary>
        private void InitializeComponent()
        {
            Hydro.MapView.Template template1 = new Hydro.MapView.Template();
            Hydro.MapView.MapOption mapOption1 = new Hydro.MapView.MapOption();
            Hydro.MapView.Template template2 = new Hydro.MapView.Template();
            Hydro.MapView.MapOption mapOption2 = new Hydro.MapView.MapOption();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.map = new CloudWaterNetwork.MapViewer();
            this.map = new Hydro.MapUI.MapViewer();
            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
            this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
            this.toolStrip1.SuspendLayout();
            this.SuspendLayout();
            // 
            // map
            // 
            this.map._IsEditMode = true;
            template1.CenterX = 0F;
            template1.CenterY = 0F;
            template1.filePath = null;
            template1.ID = "00000000-0000-0000-0000-000000000000";
            template1.ImportExcelIndex = 0;
            template1.ImportExcelPath = null;
            mapOption1._ShowJunction = true;
            mapOption1._ShowValve = true;
            mapOption1.junction_multiply = 1F;
            mapOption1.Link_multiply = 0.6667F;
            template1.mapOption = mapOption1;
            template1.MaxLevel = 99;
            template1.Node1 = null;
            template1.Node2 = null;
            template1.Regions = null;
            template1.rotation = 0D;
            template1.rotationF = 90D;
            template1.Type = Hydro.MapView.MapViewEnum.TemplateType.全部;
            template1.view = ((Hydro.MapView.MapDimensions)(resources.GetObject("template1.view")));
            template1.Visible = null;
            template1.X = null;
            template1.Y = null;
            template1.zoom = 1F;
            template1.名称 = "临时";
            this.map._newTemplate = template1;
            template2.CenterX = 0F;
            template2.CenterY = 0F;
            template2.filePath = null;
            template2.ID = "00000000-0000-0000-0000-000000000000";
            template2.ImportExcelIndex = 0;
            template2.ImportExcelPath = null;
            mapOption2._ShowJunction = true;
            mapOption2._ShowValve = true;
            mapOption2.junction_multiply = 1F;
            mapOption2.Link_multiply = 0.6667F;
            template2.mapOption = mapOption2;
            template2.MaxLevel = 99;
            template2.Node1 = null;
            template2.Node2 = null;
            template2.Regions = null;
            template2.rotation = 0D;
            template2.rotationF = 90D;
            template2.Type = Hydro.MapView.MapViewEnum.TemplateType.全部;
            template2.view = ((Hydro.MapView.MapDimensions)(resources.GetObject("template2.view")));
            template2.Visible = null;
            template2.X = null;
            template2.Y = null;
            template2.zoom = 1F;
            template2.名称 = "临时";
            this.map._newTemplate = template2;
            this.map._ShowJunction = true;
            this.map._ShowValve = true;
            this.map.BackColor = System.Drawing.Color.Transparent;
            this.map.Dock = System.Windows.Forms.DockStyle.Fill;
            this.map.junction_multiply = 1F;
            this.map.Link_multiply = 1F;
            this.map.Location = new System.Drawing.Point(0, 0);
            this.map.MapCenter = ((System.Drawing.PointF)(resources.GetObject("map.MapCenter")));
            this.map.Location = new System.Drawing.Point(0, 25);
            //this.map.MapCenter = ((System.Drawing.PointF)(resources.GetObject("map.MapCenter")));
            this.map.Name = "map";
            this.map.Rotation = 0D;
            this.map.RotationF = 90D;
            this.map.ShowStatusBar = true;
            this.map.showToolBar = true;
            this.map.Size = new System.Drawing.Size(800, 450);
            this.map.Size = new System.Drawing.Size(800, 425);
            this.map.TabIndex = 0;
            this.map.zoom = 1F;
            //
            // toolStrip1
            //
            this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripButton1});
            this.toolStrip1.Location = new System.Drawing.Point(0, 0);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.Size = new System.Drawing.Size(800, 25);
            this.toolStrip1.TabIndex = 1;
            this.toolStrip1.Text = "toolStrip1";
            //
            // toolStripButton1
            //
            this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
            this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton1.Name = "toolStripButton1";
            this.toolStripButton1.Size = new System.Drawing.Size(52, 22);
            this.toolStripButton1.Text = "计算";
            this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
            // 
            // Form1
            // 
@@ -85,16 +107,22 @@
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(800, 450);
            this.Controls.Add(this.map);
            this.Controls.Add(this.toolStrip1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.toolStrip1.ResumeLayout(false);
            this.toolStrip1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();
        }
        #endregion
        private CloudWaterNetwork.MapViewer map;
        private Hydro.MapUI.MapViewer map;
        private System.Windows.Forms.ToolStrip toolStrip1;
        private System.Windows.Forms.ToolStripButton toolStripButton1;
    }
}
TestForm/Form1.cs
@@ -1,4 +1,6 @@
using CloudWaterNetwork;
using CommonBase;
using Hydro.MapUI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -6,6 +8,7 @@
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -29,5 +32,47 @@
        
        }
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            //var list=map._Template.network.Calc();
            //if (_selectTemp == null) return;
            var _selectTemp = map._Template;
            map.toolStripButton_save_ButtonClick(1, null);
            ProgressForm_计算 progressForm = null;
            progressForm = new ProgressForm_计算();
            progressForm.StartPosition = FormStartPosition.Manual;
            progressForm.Location = new Point(this.Left + this.Width / 2 - progressForm.Width / 2, this.Top + this.Height / 2 - progressForm.Height / 2); // è®¡ç®—新窗口的位置
            new Thread(() =>
            {
                progressForm.ShowDialog();
            }).Start();
            lock (GlobalProgress.Instance)
            {
                GlobalProgress.stateText = "计算中";
                GlobalProgress.MaxNum = 1;
                GlobalProgress.CurrentNum = 0;
                GlobalProgress.Hide = false;
                GlobalProgress.NeedStop = false;
                GlobalProgress.ChildMaxNum = 100;
                GlobalProgress.ChildCurrentNum = 0;
            }
            var net = _selectTemp.network;
            net.Calc(_selectTemp.FullPath);
            lock (GlobalProgress.Instance)
            {
                GlobalProgress.NeedStop = true;
            }
        }
    }
}
TestForm/Form1.resx
@@ -117,24 +117,24 @@
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <data name="template1.view" mimetype="application/x-microsoft.net.object.binary.base64">
  <metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>17, 17</value>
  </metadata>
  <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  <data name="toolStripButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        AAEAAAD/////AQAAAAAAAAAMAgAAAERIeWRyby5NYXBWaWV3LCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1
        cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAwDAAAAUVN5c3RlbS5EcmF3aW5nLCBWZXJzaW9u
        PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49YjAzZjVmN2YxMWQ1MGEzYQUB
        AAAAG0h5ZHJvLk1hcFZpZXcuTWFwRGltZW5zaW9ucwYAAAAXPENlbnRlcj5rX19CYWNraW5nRmllbGQV
        PHpvb20+a19fQmFja2luZ0ZpZWxkGTxyb3RhdGlvbj5rX19CYWNraW5nRmllbGQaPHJvdGF0aW9uRj5r
        X19CYWNraW5nRmllbGQaPFNob3dGbG9vcj5rX19CYWNraW5nRmllbGQaPGlzU2hvd1BpYz5rX19CYWNr
        aW5nRmllbGQEAAAAAAAVU3lzdGVtLkRyYXdpbmcuUG9pbnRGAwAAAAsGBggBAgAAAAX8////FVN5c3Rl
        bS5EcmF3aW5nLlBvaW50RgIAAAABeAF5AAALCwMAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAgFZA
        AAAAgAEL
</value>
  </data>
  <data name="map.MapCenter" mimetype="application/x-microsoft.net.object.binary.base64">
    <value>
        AAEAAAD/////AQAAAAAAAAAMAgAAAFFTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj00LjAuMC4wLCBDdWx0
        dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJh
        d2luZy5Qb2ludEYCAAAAAXgBeQAACwsCAAAAAAAAAAAAAAAL
        iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
        YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJOSURBVHhe7Zu/S1tRHMVjCm/qoiB0EtqtilNBkA4Fobja
        uRQySStOurhbhC7t0n9AyNI/oUORImQK3ZKlU8XBUXmZQkI9B77fR6ENeT/u67v3m/uBw9d7b7gec04y
        PVuRSCQSiUSaIpG5cDyCNqFtmVwvDI+hHagDHcrkmvvmWYVeQG+hD9AXmVxzn+dmWYI2oDfQGTSAfsnk
        mvs85+tMws85q34MdZMkuR2Px9ecXMs+z01+H/yZPiv/s9vtfvsNOLmWfbMt+Cv96XR6xzeA03oLZqav
        WG/BzPQVyy2Ym75itQVz01cstiB3+oq1FuROX7HUgsLpK1ZakCv9fr//XX7MsNCCXOmPRqNhu93GGA1l
        KyP0FuRKv9Pp9HD+g1O2MkJuQaH0cf7ZWgsKpQ+dclppQeH0oQNOKy0ok/6ezOBbUDb95zKDb0HZ9J/I
        DLoFVdJflhl0C6qkT4JuQdX0SdAtqJq+EmQLXKSvBNkCV+krQbXAZfpKUC1wnb4SRAvqSF8JogV1pa94
        3YI601e8bkHZ9J+WkHctKJv+6wryqgVF0//oUI23oGj6qWs13YJc6U8mk5s0TQd1iffLr8r4Hy3IlX6T
        1N2CXOk3Sd0tWIe8TV/5RwvouzIPoC3oHXQOeZe+Ql/0Jz7pl77pvxIPIT7AeAR9hS57vd6Fr6I/8Um/
        9E3/lXkG7UOfIF5+5bHojz7pl76dsAbtQrz0BHrvseiPPumXvp3By/iOvoReeSz6o0+nf7zCZ/tXIF7u
        q+hvYf8HIRKJRCKRSBFarXtukdAAGDXysAAAAABJRU5ErkJggg==
</value>
  </data>
</root>