소스 검색

mxg:拆分http配置文件存放地址,修正BWHPP-DWPP,BANC-BACU 族编码未修改不可识别问题

mengxiangge 6 년 전
부모
커밋
5f392518dc

+ 7 - 0
MBI/MBIResource/Config/HttpSetting.ini

@@ -0,0 +1,7 @@
+[Configure]
+DataPlatformLocalHost = http://service.sagacloud.cn:28888/
+GoodHandLocalHost = http://service.sagacloud.cn:28888/godhand/
+ScanBuildingLocalHost = http://mbi.sagacloud.cn:8080/ScanBuilding/
+OssClientFileKey = files/revit/
+SaasLocalHost = http://mbi.sagacloud.cn:8080/
+ImageServiceLocalHost = http://service.sagacloud.cn:28888/

+ 2 - 2
MBI/SAGA.DotNetUtils/Logger/DocumentChangedLog.cs

@@ -26,8 +26,8 @@ namespace SAGA.DotNetUtils.Logger
         {
             var fileName = "Revit.log";
             string path = Path.Combine(AppBaseInfo.AppTempFilePath, "MBI");
-            string projectId = IniOperator.GetData("CurProject", "ID");
-            string workPath = IniOperator.GetData("ProjectDir", projectId);
+            string projectId = IniOperator.Instance().GetData("CurProject", "ID");
+            string workPath = IniOperator.Instance().GetData("ProjectDir", projectId);
             if (workPath.IsNotNullEmpty())
                 path = Path.Combine(workPath, projectId);
             if (!Directory.Exists(path)) Directory.CreateDirectory(path);

+ 59 - 34
MBI/SAGA.DotNetUtils/Utilities/IniOperator.cs

@@ -8,44 +8,64 @@ using IniParser;
 using IniParser.Model;
 using Utilities;
 
-namespace SAGA.DotNetUtils.Utilities {
-    public static class IniOperator {
-        static IniOperator() {
-            if (!File.Exists(IniPath)) {
-                Directory.CreateDirectory(Path.Combine(AppBaseInfo.AppTempFilePath, "Settings"));
-                var fileStream = File.Create(IniPath);
-                fileStream.Dispose();
+namespace SAGA.DotNetUtils.Utilities
+{
+    public class IniOperator
+    {
+        private IniOperator()
+        {
+            if (!File.Exists(IniPath))
+            {
+                FileInfo fileInfo = new FileInfo(IniPath);
+                if (!fileInfo.Exists)
+                {
+                    var parentDir = fileInfo.Directory;
+                    if (parentDir != null)
+                    {
+                        if (!parentDir.Exists)
+                        {
+                            parentDir.Create();
+                        }
+                        var fileStream = File.Create(IniPath);
+                        fileStream.Dispose();
+                    }
+                }
             }
         }
-        private static string IniPath = Path.Combine(AppBaseInfo.AppTempFilePath, "Settings\\Settings.ini");
-      
-        public static void SaveTemp(string key, string value) {
-            SetData("TempData", key, value);
-        }
+        private static string IniPath { get; set; }
+        private static string DefaultPath = Path.Combine(AppBaseInfo.AppTempFilePath, "Settings\\Settings.ini");
 
-        public static string GetTempData(string key) {
-            return GetData("TempData", key);
+        public static IniOperator Instance(string path)
+        {
+            IniPath = path;
+            return new IniOperator();
         }
 
-        public static string GetRevtiDir() {
-            return GetData("ComputerSetting", "RevitDir");
+        public static IniOperator Instance()
+        {
+            return Instance(DefaultPath);
         }
 
-        public static void SetSetting(string key, string value) {
+
+
+        public void SetSetting(string key, string value)
+        {
             SetData("Settings", key, value);
         }
-        public static string GetSetting(string key) {
+        public string GetSetting(string key)
+        {
             return GetData("Settings", key);
         }
 
-        public static void SetData(string section, string key, string value) {
+        public void SetData(string section, string key, string value)
+        {
             var parser = new FileIniDataParser();
             IniData data = parser.ReadFile(IniPath);
-           if(string.IsNullOrEmpty(section)||string.IsNullOrEmpty(key))return;
+            if (string.IsNullOrEmpty(section) || string.IsNullOrEmpty(key)) return;
 
 
             data[section][key] = value + "";
-           
+
             parser.WriteFile(IniPath, data);
         }
         /// <summary>
@@ -53,9 +73,9 @@ namespace SAGA.DotNetUtils.Utilities {
         /// </summary>
         /// <param name="section"></param>
         /// <returns></returns>
-        public static Dictionary<string,string> GetData(string section)
+        public Dictionary<string, string> GetData(string section)
         {
-            Dictionary<string,string> dic=new Dictionary<string, string>();
+            Dictionary<string, string> dic = new Dictionary<string, string>();
             var parser = new FileIniDataParser();
             IniData data = parser.ReadFile(IniPath);
             if (string.IsNullOrEmpty(section)) return dic;
@@ -64,7 +84,8 @@ namespace SAGA.DotNetUtils.Utilities {
             return dic;
         }
 
-        public static string GetData(string section, string key) {
+        public string GetData(string section, string key)
+        {
             var parser = new FileIniDataParser();
             IniData data = parser.ReadFile(IniPath);
             if (string.IsNullOrEmpty(section) || string.IsNullOrEmpty(key)) return "";
@@ -72,20 +93,24 @@ namespace SAGA.DotNetUtils.Utilities {
             return data[section][key];
         }
 
-        public static void SaveData<T>(T t) {
+        public void SaveData<T>(T t)
+        {
             var parser = new FileIniDataParser();
             IniData data = parser.ReadFile(IniPath);
             Type type = t.GetType();
             var className = type.Name;
             System.Reflection.PropertyInfo[] propertyInfos = type.GetProperties();
-            foreach (var propertyInfo in propertyInfos) {
+            foreach (var propertyInfo in propertyInfos)
+            {
                 var name = propertyInfo.Name;
                 var value = propertyInfo.GetValue(t);
                 //if (propertyInfo.PropertyType == typeof(List<string>))
-                if (value is List<string> strList) {
+                if (value is List<string> strList)
+                {
                     data[className][name] = string.Join(",", strList);
                 }
-                else {
+                else
+                {
                     data[className][name] = value + "";
                 }
 
@@ -93,7 +118,7 @@ namespace SAGA.DotNetUtils.Utilities {
             parser.WriteFile(IniPath, data);
         }
 
-        public static T GetData<T>() where  T:class,new()
+        public T GetData<T>() where T : class, new()
         {
             var parser = new FileIniDataParser();
             IniData data = parser.ReadFile(IniPath);
@@ -101,7 +126,7 @@ namespace SAGA.DotNetUtils.Utilities {
             Assembly asm = type.Assembly;
             var obj = asm.CreateInstance(type.FullName);
             var className = type.Name;
-           PropertyInfo[] propertyInfos = type.GetProperties();
+            PropertyInfo[] propertyInfos = type.GetProperties();
             foreach (var propertyInfo in propertyInfos)
             {
                 var name = propertyInfo.Name;
@@ -109,22 +134,22 @@ namespace SAGA.DotNetUtils.Utilities {
 
                 if (propertyInfo.PropertyType == typeof(List<string>))
                 {
-                    List<string> d=new List<string>();
+                    List<string> d = new List<string>();
                     string v = data[className][name];
                     if (!string.IsNullOrEmpty(v))
                     {
                         d.AddRange(v.Split(','));
                         value = d;
                     }
-                    
+
                 }
                 else
                 {
-                   value= data[className][name];
+                    value = data[className][name];
                 }
                 propertyInfo.SetValue(obj, value);
             }
-           
+
             return obj as T;
         }
     }

+ 5 - 0
MBI/SAGA.MBI/Common/CommonTool.cs

@@ -192,6 +192,11 @@ namespace SAGA.MBI.Common
         public static MEquipmentFamily GetEquipFamily(string familyCode)
         {
             var codeTb = MBIControl.EquipmentFamilys.FirstOrDefault(t => t.EquipmentTypes.FirstOrDefault(tt => tt.Code == familyCode) != null);
+            if (codeTb == null)
+            {
+                familyCode = EquipmentCodeMap.GetOriginCode(familyCode);
+                codeTb = MBIControl.EquipmentFamilys.FirstOrDefault(t => t.EquipmentTypes.FirstOrDefault(tt => tt.Code == familyCode) != null);
+            }
             return (codeTb);
         }
         /// <summary>

+ 13 - 14
MBI/SAGA.MBI/Common/MBIConst.cs

@@ -22,8 +22,7 @@ namespace SAGA.MBI.Common
     {
         public static readonly string ManageCur = "ManageCurLocalize.json";
         public static readonly string MBIAssistDBName = "MBIAssistData.db";
-
-        public static readonly string MBISettingPath = Path.Combine(AppBaseInfo.AppTempFilePath, "MBI\\Settings");
+        
         public static readonly string MBITempSettingPath = Path.Combine(AppBaseInfo.AppTempFilePath, "MBI\\SettingsTemp");
 
         public static readonly string MBIImagePath = AppBaseInfo.ImagePath;
@@ -40,7 +39,7 @@ namespace SAGA.MBI.Common
             {
                 string key = nameof(SaasLocalHost);
                 string url = ProjectDirOperate.GetConfigureInfo(key);
-                //if (url.IsNullOrEmpty())
+                if (url.IsNullOrEmpty())
                 {
                     //url = "http://192.168.30.96:8080/";
                     url = "http://mbi.sagacloud.cn:8080/";
@@ -56,7 +55,7 @@ namespace SAGA.MBI.Common
             {
                 string key = nameof(DataPlatformLocalHost);
                 string url = ProjectDirOperate.GetConfigureInfo(key);
-                //if (url.IsNullOrEmpty())
+                if (url.IsNullOrEmpty())
                 {
                     //url = "http://192.168.20.225:8080/";
                     url = "http://service.sagacloud.cn:28888/";
@@ -75,7 +74,7 @@ namespace SAGA.MBI.Common
             {
                 string key = nameof(ImageServiceLocalHost);
                 string url = ProjectDirOperate.GetConfigureInfo(key);
-                //if (url.IsNullOrEmpty())
+                if (url.IsNullOrEmpty())
                 {
                     //url = "http://192.168.20.225:8080/";
                     url = "http://service.sagacloud.cn:28888/";
@@ -90,7 +89,7 @@ namespace SAGA.MBI.Common
             {
                 string key = nameof(GoodHandLocalHost);
                 string url = ProjectDirOperate.GetConfigureInfo(key);
-                //if (url.IsNullOrEmpty())
+                if (url.IsNullOrEmpty())
                 {
                     //url = "http://192.168.20.225:8080/godhand/";
                     url = "http://service.sagacloud.cn:28888/godhand/";
@@ -105,7 +104,7 @@ namespace SAGA.MBI.Common
             {
                 string key = nameof(ScanBuildingLocalHost);
                 string url = ProjectDirOperate.GetConfigureInfo(key);
-                //if (url.IsNullOrEmpty())
+                if (url.IsNullOrEmpty())
                 {
                     // url = "http://172.16.0.141:8080/ScanBuilding/";
                     url = "http://mbi.sagacloud.cn:8080/ScanBuilding/";
@@ -121,7 +120,7 @@ namespace SAGA.MBI.Common
             {
                 string key = nameof(Html5DetailLocalHost);
                 string url = ProjectDirOperate.GetConfigureInfo(key);
-                //if (url.IsNullOrEmpty())
+                if (url.IsNullOrEmpty())
                 {
                     //    url = "http://172.16.0.181:8889/#/";
                     url = "http://mbi.sagacloud.cn:8889/#/";
@@ -136,7 +135,7 @@ namespace SAGA.MBI.Common
             {
                 string key = nameof(Html5ImageLocalHost);
                 string url = ProjectDirOperate.GetConfigureInfo(key);
-                //if (url.IsNullOrEmpty())
+                if (url.IsNullOrEmpty())
                 {
                     // url = "http://172.16.0.181:8890/";
                     url = "http://mbi.sagacloud.cn:8890/";
@@ -151,7 +150,7 @@ namespace SAGA.MBI.Common
             {
                 string key = nameof(Html5ScanLocalHost);
                 string url = ProjectDirOperate.GetConfigureInfo(key);
-                //if (url.IsNullOrEmpty())
+                if (url.IsNullOrEmpty())
                 {
                     //     url = "http://172.16.0.181:8888/#/";
                     url = "http://mbi.sagacloud.cn:8888/#/";
@@ -169,7 +168,7 @@ namespace SAGA.MBI.Common
             {
                 string key = nameof(GplotViewHost); 
                 string url = ProjectDirOperate.GetConfigureInfo(key);
-                //if (url.IsNullOrEmpty())
+                if (url.IsNullOrEmpty())
                 {
                     url = "http://mbi.sagacloud.cn:8888/#/";
                     ProjectDirOperate.SaveConfigureInfo(key, url);
@@ -178,7 +177,7 @@ namespace SAGA.MBI.Common
             }
         }
         public static readonly string ProjectManageSecret = "A123456";
-        public static readonly string ProjectSecret = MBIControl.ProjectCur.Password;
+        public static string ProjectSecret => MBIControl.ProjectCur.Password;
 
         //revit文件服务器id和密码
         public static readonly string RevitServiceId = "revit";
@@ -202,7 +201,7 @@ namespace SAGA.MBI.Common
             {
                 string key = nameof(OssClientFileKey);
                 string url = ProjectDirOperate.GetConfigureInfo(key);
-                //if (url.IsNullOrEmpty())
+                if (url.IsNullOrEmpty())
                 {
                     //     url = "test/files/revit/";
                     url = "files/revit/";
@@ -214,7 +213,7 @@ namespace SAGA.MBI.Common
         /// <summary>
         /// 拓扑图文件存放文件夹地址
         /// </summary>
-        public static string OssGplotFilePrefix => $"test/files/revit/GplotData/{ IniOperator.GetData("CurProject", "ID")}";
+        public static string OssGplotFilePrefix => $"test/files/revit/GplotData/{ MBIControl.ProjectCur.Id}";
 
         //信标族名称
         public static string BeaconFamilyName = "Beacon";

+ 0 - 1
MBI/SAGA.MBI/DataArrange/DalCommon.cs

@@ -97,7 +97,6 @@ namespace SAGA.MBI.DataArrange
                     else
                     {
                         string familyCode = fi.GetFamilyCode();
-                        equipment.RevitCode = familyCode;
                         //Code的位数为4,判定为设备,6位是部件
                         if (familyCode.IsNotNullEmptyExt())
                         {

+ 2 - 2
MBI/SAGA.MBI/DataArrange/DalUploadFloor.cs

@@ -265,7 +265,7 @@ namespace SAGA.MBI.DataArrange
                         var tempGriphs = new List<MTopologyGriph>(topologyGriphs);
                         foreach (IGrouping<string, DocumentChangedLogMode> logGroup in floorLogsGroupByBimId)
                         {
-                            DocumentChangedLogMode log = logGroup.FirstOrDefault();
+                            DocumentChangedLogMode log = logGroup.LastOrDefault();
                             if (log == null) continue;
                             var bimId = CommonTool.GetCloudBIMId(log.DocName, log.Id);
                             var elem = document.GetElement(log.Id.ToInt());
@@ -405,7 +405,7 @@ namespace SAGA.MBI.DataArrange
             {
                 //本地编码不可识别,删除服务器数据
                 //xls 新编码和旧编码一致,则不处理数据
-                if (EquipmentCodeMap.GetOriginCode(mode.EquipClassCode) == EquipmentCodeMap.GetOriginCode(tempmode.RevitCode))
+                if (EquipmentCodeMap.GetOriginCode(mode.EquipClassCode) == EquipmentCodeMap.GetOriginCode(tempmode.EquipClassCode))
                 {
                     mode.Operator = DocumentChangedOperator.Modified;
                 }

+ 1 - 0
MBI/SAGA.MBI/Extend/ElementExtend.cs

@@ -162,6 +162,7 @@ namespace SAGA.MBI.Tools
             //return (new JArray(jObject)).ToString();
             return xyz;
         }
+
         /// <summary>
         /// 获取设备的种族类型编码 ATFC
         /// 族名称的命名规则:ATFC-风机盘管

+ 14 - 13
MBI/SAGA.MBI/FileStream/ProjectDirOperate.cs

@@ -23,6 +23,7 @@ namespace SAGA.MBI.FileStream
     /// </summary>
     public class ProjectDirOperate
     {
+        private static readonly string m_HttpSettingPath = Path.Combine(MBIConst.MBIResourcePath, "Config\\HttpSetting.ini");
         #region ProjectLast
 
         /// <summary>
@@ -32,7 +33,7 @@ namespace SAGA.MBI.FileStream
         /// <param name="value"></param>
         public static void SaveProjectLastInfo(string key, string value)
         {
-            IniOperator.SetData("ProjectLast", key, value);
+            IniOperator.Instance().SetData("ProjectLast", key, value);
         }
 
         /// <summary>
@@ -42,7 +43,7 @@ namespace SAGA.MBI.FileStream
         /// <returns></returns>
         public static string GetProjectLastInfo(string key)
         {
-            return IniOperator.GetData("ProjectLast", key);
+            return IniOperator.Instance().GetData("ProjectLast", key);
         }
 
         #endregion
@@ -56,7 +57,7 @@ namespace SAGA.MBI.FileStream
         /// <param name="value"></param>
         public static void SaveConfigureInfo(string key, string value)
         {
-            IniOperator.SetData("Configure", key, value); 
+            IniOperator.Instance(m_HttpSettingPath).SetData("Configure", key, value); 
         }
 
         /// <summary>
@@ -66,7 +67,7 @@ namespace SAGA.MBI.FileStream
         /// <returns></returns>
         public static string GetConfigureInfo(string key)
         {
-            return IniOperator.GetData("Configure", key);
+            return IniOperator.Instance(m_HttpSettingPath).GetData("Configure", key);
         }
 
         #endregion
@@ -81,7 +82,7 @@ namespace SAGA.MBI.FileStream
         /// <param name="value"></param>
         public static void SavePhoneNumber(string value)
         {
-            IniOperator.SetData("Login", "Phone", value);
+            IniOperator.Instance().SetData("Login", "Phone", value);
         }
 
         /// <summary>
@@ -91,7 +92,7 @@ namespace SAGA.MBI.FileStream
         /// <returns></returns>
         public static string GetPhoneNumber()
         {
-            return IniOperator.GetData("Login", "Phone");
+            return IniOperator.Instance().GetData("Login", "Phone");
         }
 
         #endregion
@@ -105,7 +106,7 @@ namespace SAGA.MBI.FileStream
         /// <param name="path"></param>
         public static void SaveProjectDir(string projectId, string path)
         {
-            IniOperator.SetData("ProjectDir", projectId, path);
+            IniOperator.Instance().SetData("ProjectDir", projectId, path);
         }
 
         /// <summary>
@@ -115,7 +116,7 @@ namespace SAGA.MBI.FileStream
         /// <returns></returns>
         public static string GetProjectDir(string projectId)
         {
-            return IniOperator.GetData("ProjectDir", projectId);
+            return IniOperator.Instance().GetData("ProjectDir", projectId);
         }
 
         /// <summary>
@@ -124,7 +125,7 @@ namespace SAGA.MBI.FileStream
         /// <returns></returns>
         public static List<string> GetProjectDirs()
         {
-            var dic = IniOperator.GetData("ProjectDir");
+            var dic = IniOperator.Instance().GetData("ProjectDir");
 
             List<string> strs = dic.Where(t => t.Value.IsNotNullEmpty()).Select(t => t.Value).ToList();
             return strs;
@@ -138,7 +139,7 @@ namespace SAGA.MBI.FileStream
         /// <returns></returns>
         public static void LocalizeCurProject()
         {
-            IniOperator.SetData("CurProject", "ID", MBIControl.ProjectCur.Id);
+            IniOperator.Instance().SetData("CurProject", "ID", MBIControl.ProjectCur.Id);
             //使用序列化项目类的方法保存,有一些数据没法恢复,采用只保存项目名称,重新从云平台加载数据
             //string filePath = MBIConst.MBITempSettingPath;
             //string fileName = MBIConst.ProjectCurName;
@@ -154,7 +155,7 @@ namespace SAGA.MBI.FileStream
             //string fileName = MBIConst.ProjectCurName;
             //MProject project = FileOperateBase.Deserialize<MProject>(filePath, fileName);
             //project.LoadUseControl();
-            string id= IniOperator.GetData("CurProject", "ID");
+            string id= IniOperator.Instance().GetData("CurProject", "ID");
             MProject project = ModeFileConvert.GetProjectInfo(id);
             
             return project;
@@ -190,7 +191,7 @@ namespace SAGA.MBI.FileStream
         /// <param name="path"></param>
         public static void SaveShowModeFileManageSate(bool isShow)
         {
-            IniOperator.SetData("ShowModeFileManageSate", "IsShow", isShow.ToString());
+            IniOperator.Instance().SetData("ShowModeFileManageSate", "IsShow", isShow.ToString());
         }
 
         /// <summary>
@@ -200,7 +201,7 @@ namespace SAGA.MBI.FileStream
         /// <returns></returns>
         public static bool ReadShowModeFileManageSate(string projectId)
         {
-            string isShow= IniOperator.GetData("ShowModeFileManageSate", "IsShow");
+            string isShow= IniOperator.Instance().GetData("ShowModeFileManageSate", "IsShow");
             return isShow.ToBool();
         }
 

+ 0 - 6
MBI/SAGA.MBI/Model/MRevitEquipBase.cs

@@ -32,12 +32,6 @@ namespace SAGA.MBI.Model
     /// </summary>
     public class MRevitEquipBase : CloudDataBase
     {
-        #region 附加参数 xls
-        /// <summary>
-        /// revit族信息获取的编码
-        /// </summary>
-        public string RevitCode { get; set; }
-        #endregion
 
         #region ModefileDelProperty
 

+ 6 - 7
MBI/SAGA.MBI/RequestData/UpLoadFileRequest.cs

@@ -119,22 +119,21 @@ namespace SAGA.MBI.RequestData
             {
                 string bucketName = MBIConst.BucketName;
 
-                var getObjectRequest = new GetObjectRequest(bucketName, key);
                 ShowDownloadWindow(tuple.Item3, fullPath, count, cur);
 
+                var getObjectRequest = new GetObjectRequest(bucketName, key);
                 getObjectRequest.StreamTransferProgress += DownStreamProgressCallback;
-                var ossObject = client.GetObject(getObjectRequest);
+                OssObject ossObject = client.GetObject(getObjectRequest);
+                //设置下载超时时间
+                ossObject.ResponseStream.ReadTimeout = 20*60*1000;
                 using (var stream = ossObject.Content)
                 {
                     var buffer = new byte[1024 * 1024];
-                    var bytesTotal = 0;
-                    var bytesRead = 0;
-                    //默认为512M,可以使用MemoryStream(1000*1024*1024)扩大
                     using (var fs = new System.IO.MemoryStream())
                     {
-                        while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
+                        var bytesRead = 0;
+                        while (( bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
                         {
-                            bytesTotal += bytesRead;
                             // Process read data
                             // TODO
                             fs.Write(buffer, 0, bytesRead);

+ 1 - 1
MBI/SAGA.Models/StaticData.cs

@@ -20,7 +20,7 @@ namespace SAGA.Models {
         {
             get
             {
-                string projectId = IniOperator.GetData("CurProject", "ID");
+                string projectId = IniOperator.Instance().GetData("CurProject", "ID");
                 return Path.Combine(Path.GetTempPath(),"Revit", projectId);
             }
         }