Quellcode durchsuchen

xls:更正类别信息点接口

xulisong vor 6 Jahren
Ursprung
Commit
4eb4b59c1d

+ 1 - 1
MBI/FirmLib/Com.FirmLib.UI/Manufacturer/WinProductType.xaml.cs

@@ -44,7 +44,7 @@ namespace Com.FirmLib.UI.Manufacturer
             columns.ForEach(c =>
             {
                 DataGridDragCopyOptions.SetCanColumnDragCopy(c, true);
-                c.Width = c.Header.ToString().Length * 16 + 10;
+                c.Width = c.Header.ToString().Length * 16 +40;
                 c.MinWidth = 80;
             });
         }

+ 1 - 1
MBI/FirmLib/Com.FirmLib.UI/Seller/WinSellerInfo.xaml.cs

@@ -125,7 +125,7 @@ namespace Com.FirmLib.UI.Seller
             columns.ForEach(c =>
             {
                 //DataGridDragCopyOptions.SetCanColumnDragCopy(c, true);
-                c.Width = c.Header.ToString().Length * 16+10;
+                c.Width = c.Header.ToString().Length * 16+40;
                 c.IsReadOnly = true;
                 c.MinWidth = 80;
             });

+ 22 - 18
MBI/FirmLib/Com.FirmLib/Bll/EquipmentInfoPointBll.cs

@@ -3,6 +3,8 @@ using Com.FirmLib.Entity;
 using FirmHttpDao;
 using FWindSoft.Net.Http;
 using Newtonsoft.Json.Linq;
+using SAGA.DotNetUtils.Service;
+using SAGA.RevitUtils.Service;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -33,19 +35,20 @@ namespace Com.FirmLib.Bll
         public List<EquipmentInfoPointItem> SaasSysOrEqInfos(string code, string type = "equip")
         {
             List<EquipmentInfoPointItem> items = new List<EquipmentInfoPointItem>();
-            string url = BllHttpSetting.Instance.SaasUri + $"/saas-manage3/app/restTemplateService/queryObjectPropertyMapping2";
-            string app_type = "godhand";
-            JObject jObject = new JObject();
-            jObject.Add("user_id", "default");
-            jObject.Add("code", code);
-            jObject.Add("type", type);
-            jObject.Add("app_type", app_type);
-            //获取所有的信息点
-            jObject.Add("is_all", "1");
+            string url = BllHttpSetting.Instance.EquipmentUri + $"/infocode/query_property?type=" + code;
+            //string app_type = "godhand";
+            //JObject jObject = new JObject();
+            //jObject.Add("user_id", "default");
+            //jObject.Add("code", code);
+            //jObject.Add("type", type);
+            //jObject.Add("app_type", app_type);
+            ////获取所有的信息点
+            //jObject.Add("is_all", "1");
             HttpClient client = HttpClientManager.CreateClient();
-            var result = client.PostJosnAsync(new Uri(url, UriKind.RelativeOrAbsolute), jObject);
-            var stringResult = HandlerTaskResponse(result, new RequestInfo(url,jObject));
-            var flag = HandlerResult(stringResult, 
+            var result = client.GetAsync(new Uri(url, UriKind.RelativeOrAbsolute));
+            var stringResult = HandlerTaskResponse(result, new RequestInfo(url));
+            IInputService inputService = ServiceLocator.Current.GetService<IInputService>();
+            var flag = HandlerResult(stringResult,
                 (jo) => {
                     var content = jo["Content"];
                     foreach (JObject subj in content)
@@ -53,24 +56,25 @@ namespace Com.FirmLib.Bll
                         EquipmentInfoPointItem item = new EquipmentInfoPointItem();
                         item.Category = (string)subj["firstTag"];
                         item.SubCategory = (string)subj["secondTag"];
-                        item.Name = (string)subj["info_point_code"];
-                        item.CodeName = (string)subj["infopoint_code"];
+                        item.Name = (string)subj["infoPointName"];
+                        item.CodeName = (string)subj["infoPointCode"];
                         item.Unit = (string)subj["unit"];
                         item.Type = (string)subj["dataType"];
-                        item.InputType = (string)subj["base_cmpt_code"];
+                        item.InputType = (string)subj["inputMode"];
                         item.EnumSource = subj.GetCheckValue("dataSource");
                         item.Remark = (string)subj["note"];
                         item.Classification = (string)subj["classification"];
-                        item.IsShow = (string)subj["is_mapped"] == "1";
-                        item.CollectionCmptCode = (string)subj["collection_cmpt_code"];
+                        item.IsShow = true;// (string)subj["is_mapped"] == "1";
+                        item.CollectionCmptCode = inputService?.GetInputCode(item.InputType)??item.InputType;//(string)subj["collection_cmpt_code"];
                         items.Add(item);
                     }
-                 
+
                 }
             , (jo) => { this.ErrorMessage = jo["ResultMsg"].ToString(); });
 
             return items;//.Where(i=>i.Classification== "4").ToList();
 
+
         }
         /// <summary>
         /// 获取自定义信息点

+ 10 - 1
MBI/FirmLib/Com.FirmLib/Com.FirmLib.csproj

@@ -131,7 +131,16 @@
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
   </ItemGroup>
-  <ItemGroup />
+  <ItemGroup>
+    <ProjectReference Include="..\..\SAGA.DotNetUtils\SAGA.DotNetUtils.csproj">
+      <Project>{07B73C98-DCB0-4782-81FA-F50A30B563AB}</Project>
+      <Name>SAGA.DotNetUtils</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\SAGA.RevitUtils\SAGA.RevitUtils.csproj">
+      <Project>{D6201677-B7E4-495A-81AB-33C5837121E6}</Project>
+      <Name>SAGA.RevitUtils</Name>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

+ 8 - 0
MBI/MBIResource/Services/Services.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Services>
+  <ServiceConfigItem>
+    <Name></Name>
+    <ClassName>SAGA.MBI.Service.InputService</ClassName>
+    <DllPath>SAGA.MBI.exe</DllPath>
+   </ServiceConfigItem>
+</Services>

+ 3 - 0
MBI/SAGA.DotNetUtils/SAGA.DotNetUtils.csproj

@@ -334,6 +334,9 @@
     <Compile Include="PropertyGrid\XProp.cs" />
     <Compile Include="PropertyGrid\XPropDescriptor.cs" />
     <Compile Include="PropertyGrid\XProps.cs" />
+    <Compile Include="Service\IServiceLocator.cs" />
+    <Compile Include="Service\ServiceConfigItem.cs" />
+    <Compile Include="Service\ServiceLocator.cs" />
     <Compile Include="Utilities\CompressUtil.cs" />
     <Compile Include="Utilities\FileUp.cs" />
     <Compile Include="Utilities\IniOperator.cs" />

+ 33 - 0
MBI/SAGA.DotNetUtils/Service/IServiceLocator.cs

@@ -0,0 +1,33 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:IServiceLocatior
+ * 作者:xulisong
+ * 创建时间: 2019/1/18 9:02:46
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.DotNetUtils.Service
+{
+    public interface IServiceLocator
+    {
+        T GetService<T>() where T : class;
+        object GetService(string serviceName);
+        T GetService<T>(string serviceName) where T : class;
+
+        void RemoveService<T>() where T : class;
+        void Remove(string serviceName);
+        void Remove<T>(string serviceName) where T : class;
+
+        string Register<T>(T service) where T : class;
+        void Register(string serviceName,object service);
+        void Register<T>(string serviceName,T service) where T : class;
+
+        void LoadServices(string configFile);
+        void LoadServices(string configFile, Func<string, string> dllPathSelector);
+    }
+}

+ 48 - 0
MBI/SAGA.DotNetUtils/Service/ServiceConfigItem.cs

@@ -0,0 +1,48 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:ServiceConfigItem
+ * 作者:xulisong
+ * 创建时间: 2019/1/18 9:04:17
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace SAGA.DotNetUtils.Service
+{
+    public class ServiceConfigItem
+    {
+        /// <summary>
+        /// 服务名称
+        /// </summary>
+        public string Name { get; set; }
+        /// <summary>
+        /// 引用类名称
+        /// </summary>
+        public string ClassName { get; set; }
+        /// <summary>
+        /// Dll路径
+        /// </summary>
+        public string DllPath { get; set; }
+    }
+
+    [XmlRoot("Services")]
+    public class ServiceConfigItems : List<ServiceConfigItem>
+    {
+        public static ServiceConfigItems Load(string fileName)
+        {
+            XmlSerializer xml = new XmlSerializer(typeof(ServiceConfigItems), new List<Type>(){typeof(ServiceConfigItem) }.ToArray());
+            XmlDocument doc = new XmlDocument();
+            doc.Load(fileName);
+            XmlReader reader = new XmlNodeReader(doc);
+            reader = XmlReader.Create(reader, new XmlReaderSettings() { IgnoreComments = true, ConformanceLevel = ConformanceLevel.Document, CheckCharacters = false });
+            ServiceConfigItems newObject = xml.Deserialize(reader) as ServiceConfigItems;
+            return newObject;
+        }
+    }
+}

+ 152 - 0
MBI/SAGA.DotNetUtils/Service/ServiceLocator.cs

@@ -0,0 +1,152 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:ServiceLocator
+ * 作者:xulisong
+ * 创建时间: 2019/1/18 9:03:07
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.DotNetUtils.Service
+{
+    public class ServiceLocator : IServiceLocator
+    {
+        private static IServiceLocator m_Current;
+        public static IServiceLocator Current
+        {
+            get
+            {
+                if (m_Current == null)
+                {
+                    m_Current = new ServiceLocator();
+                }
+                return m_Current;
+            }
+        }
+        private ServiceLocator()
+        {
+            m_Services = new Dictionary<string, object>();
+        }
+
+        #region 私有方法
+        private void CheckName(string name)
+        {
+            if (string.IsNullOrWhiteSpace(name))
+                throw new ArgumentException(nameof(name) + "不能为null或空字符串");
+        }
+        private string CreateKey()
+        {
+            return Guid.NewGuid().ToString("N");
+        } 
+        #endregion
+        private readonly Dictionary<string, object> m_Services;
+        public T GetService<T>() where T :class
+        {
+            foreach (var service in m_Services)
+            {
+                var use = service.Value as T;
+                if (use != null)
+                    return use;
+            }
+            return null;
+        }
+
+        public object GetService(string serviceName)
+        {
+            CheckName(serviceName);
+            m_Services.TryGetValue(serviceName, out object result);
+            return result;
+        }
+
+        public T GetService<T>(string serviceName) where T : class
+        {
+            CheckName(serviceName);
+            return GetService(serviceName) as T;
+        }    
+        public string Register<T>(T service) where T : class
+        {
+            var key = CreateKey();
+            this.m_Services[key] = service;
+            return key;
+        }
+        public void Register(string serviceName, object service)
+        {
+            CheckName(serviceName);
+            this.m_Services[serviceName] = service;
+        }
+        public void Register<T>(string serviceName, T service) where T : class
+        {
+            CheckName(serviceName);
+            this.m_Services[serviceName] = service;
+        }
+        public void Remove(string serviceName)
+        {
+            CheckName(serviceName);
+            m_Services.Remove(serviceName);
+        }
+        public void Remove<T>(string serviceName) where T : class
+        {
+            CheckName(serviceName);
+            m_Services.Remove(serviceName);
+        }
+        public void RemoveService<T>() where T : class
+        {
+            string useKey = string.Empty;
+            bool has = false;
+            foreach (var service in m_Services)
+            {
+                var use = service.Value as T;
+                if (use != null)
+                {
+                    useKey = service.Key;
+                    has = true;
+                    break;
+                }
+            }
+            if (has)
+            {
+                m_Services.Remove(useKey);
+            }         
+        }
+
+
+        public void LoadServices(string configFile, Func<string, string> dllPathSelector)
+        {
+            List<ServiceConfigItem> serviceItems = ServiceConfigItems.Load(configFile);
+            foreach (var serviceConfigItem in serviceItems)
+            {
+                try
+                {
+                    string serviceName = serviceConfigItem.Name.Trim();
+                    if (string.IsNullOrWhiteSpace(serviceName))
+                    {
+                        serviceName = CreateKey();
+                    }
+                    string childPath = serviceConfigItem.DllPath.Trim();
+                    var path = dllPathSelector(childPath);
+                    if (File.Exists(path))
+                    {
+                        Assembly tempAsembly = Assembly.LoadFrom(path);
+                        m_Services[serviceName] = (tempAsembly.CreateInstance(serviceConfigItem.ClassName.Trim()));
+                    }
+                }
+                catch (Exception ex)
+                {
+                    Debug.Write(ex.Message);
+                }
+            }
+        }
+        public void LoadServices(string configFile)
+        {
+            string baseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+            LoadServices(configFile, (childPath) => Path.Combine(baseDirectory, childPath));
+        }
+    }
+}

+ 1 - 0
MBI/SAGA.MBI/SAGA.MBI.csproj

@@ -280,6 +280,7 @@
     <Compile Include="RequestData\QRCodeRequest.cs" />
     <Compile Include="RevitModelHandle\RevitParameterUpdate.cs" />
     <Compile Include="RevitReference\RVTNoModeDutyOperate.cs" />
+    <Compile Include="Service\InputService.cs" />
     <Compile Include="ToolsData\DataCheck\SpaceEquipFloorCheck.cs" />
     <Compile Include="ToolsData\DataCheck\SpaceEquipFloorCheckResult.cs" />
     <Compile Include="ToolsData\DelZeroSpace.cs" />

+ 28 - 0
MBI/SAGA.MBI/Service/InputService.cs

@@ -0,0 +1,28 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:InputService
+ * 作者:xulisong
+ * 创建时间: 2019/1/18 10:50:48
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SAGA.MBI.DataArrange;
+using SAGA.RevitUtils.Service;
+
+namespace SAGA.MBI.Service
+{
+    /// <summary>
+    /// 输入服务限定
+    /// </summary>
+    public class InputService : IInputService
+    {
+        public string GetInputCode(string originalCode)
+        {
+           return DalInfoCode.GetInputType(originalCode);
+        }
+    }
+}

+ 1 - 0
MBI/SAGA.RevitUtils/ExtendInterface/RevitEventsBingding.cs

@@ -21,6 +21,7 @@ namespace SAGA.RevitUtils
             CurrentApp = application;
             application.ControlledApplication.DocumentSaved += Application_DocumentSaved;
             AddUpdater();
+            ServiceSetting.LoadServices();
         }
         public static void RemoveEvents(UIControlledApplication application)
         {

+ 34 - 0
MBI/SAGA.RevitUtils/ExtendInterface/ServiceSetting.cs

@@ -0,0 +1,34 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:ServiceSetting
+ * 作者:xulisong
+ * 创建时间: 2019/1/18 11:05:09
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+using SAGA.DotNetUtils;
+using SAGA.DotNetUtils.Service;
+
+namespace SAGA.RevitUtils.ExtendInterface
+{
+    public class ServiceSetting
+    {
+        /// <summary>
+        /// 加载默认服务
+        /// </summary>
+        public static void LoadServices()
+        {
+            string fileName = Path.Combine(AppBaseInfo.AppRunPath, @"MBIResource\Services\Services.xml");
+            if (File.Exists(fileName))
+            {
+                ServiceLocator.Current.LoadServices(fileName);
+            }
+        }
+    }
+}

+ 2 - 0
MBI/SAGA.RevitUtils/SAGA.RevitUtils.csproj

@@ -176,6 +176,7 @@
     <Compile Include="ExtendInterface\IDocumentSaved.cs" />
     <Compile Include="ExtendInterface\RevitEventsSetting.cs" />
     <Compile Include="ExtendInterface\RevitTrigger.cs" />
+    <Compile Include="ExtendInterface\ServiceSetting.cs" />
     <Compile Include="Extends\ArcExtend.cs" />
     <Compile Include="Extends\Configuration.cs" />
     <Compile Include="Extends\CurveArrayExtend.cs" />
@@ -261,6 +262,7 @@
     <Compile Include="RevitDraw\RevitDrawArea.cs" />
     <Compile Include="ExtendInterface\RevitEventsBingding.cs" />
     <Compile Include="RevitHelper.cs" />
+    <Compile Include="Service\IInputService.cs" />
     <Compile Include="StatisticsWireInfor.cs" />
     <Compile Include="Version\DocumentVersionManager.cs" />
     <Compile Include="Windows\CommandInfo.cs" />

+ 20 - 0
MBI/SAGA.RevitUtils/Service/IInputService.cs

@@ -0,0 +1,20 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:IInputService
+ * 作者:xulisong
+ * 创建时间: 2019/1/18 10:46:35
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.RevitUtils.Service
+{
+    public interface IInputService
+    {
+        string GetInputCode(string originalCode);
+    }
+}

+ 1 - 1
MBI/WPG/UserControls/Textbox_DoubleUnit_A2.xaml

@@ -21,7 +21,7 @@
                                        IsReadOnly="{Binding Path=IsReadOnly}" Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type local:PropertyGrid}, ResourceId=TextBoxStyle}}">
                 </my:TextBox_PlusDouble>
                 <Label Grid.Column="1" Padding="0"
-                       VerticalContentAlignment="Top"
+                       VerticalContentAlignment="Center"
                        Content="{Binding Path=TextUnit,Mode=TwoWay, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}"></Label>
             </Grid>
         </Border>