diff --git a/SWSDBSchemeUpgradeTool/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/SWSDBSchemeUpgradeTool/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 28eef7d0..88c5aa17 100644 Binary files a/SWSDBSchemeUpgradeTool/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/SWSDBSchemeUpgradeTool/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/newFront/c#前端/DI-Electrical/ViewModels/ConfigViewModel.cs b/newFront/c#前端/DI-Electrical/ViewModels/ConfigViewModel.cs index 07afadc1..7d2da8e9 100644 --- a/newFront/c#前端/DI-Electrical/ViewModels/ConfigViewModel.cs +++ b/newFront/c#前端/DI-Electrical/ViewModels/ConfigViewModel.cs @@ -69,9 +69,9 @@ namespace DI_Electrical.ViewModels MessageBox.Show("本地文件目录不存在。"); return; } - var data = _configService.parser.ReadFile(_configService.path); + //var data = _configService.parser.ReadFile(_configService.path); - _configService._httpService.Init(address, port); + //_configService._httpService.Init(address, port); IsBusy = true; BusyContent = "保存中..."; var testRes = await _LoginService.Login("1", "11"); @@ -85,10 +85,17 @@ namespace DI_Electrical.ViewModels { address = address.Replace("https://", "").Replace("http://", ""); } - data["Profile"]["Address"] = address; - data["Profile"]["Port"] = port.ToString(); - data["Profile"]["Directory"] = _directory; - _configService.parser.WriteFile(_configService.path, data); + //data["Profile"]["Address"] = address; + //data["Profile"]["Port"] = port.ToString(); + //data["Profile"]["Directory"] = _directory; + //_configService.parser.WriteFile(_configService.path, data); + + //IniHelper.WriteValueFromIniFile("Profile", "strIPAddress", address); + //IniHelper.WriteValueFromIniFile("Profile", "nPort", port.ToString()); + //IniHelper.WriteValueFromIniFile("Profile", "strLocalWorkDir", _directory); + _configService.Save("Profile", "strIPAddress", address); + _configService.Save("Profile", "nPort", port.ToString()); + _configService.Save("Profile", "strLocalWorkDir", _directory); GlobalObject.isConfigIniCreateBySys = false; GlobalObject.SetLocalFileDirectory(_directory); diff --git a/newFront/c#前端/DI-Electrical/ViewModels/LoginViewModel.cs b/newFront/c#前端/DI-Electrical/ViewModels/LoginViewModel.cs index fe30495a..c9610ede 100644 --- a/newFront/c#前端/DI-Electrical/ViewModels/LoginViewModel.cs +++ b/newFront/c#前端/DI-Electrical/ViewModels/LoginViewModel.cs @@ -72,9 +72,9 @@ namespace DI_Electrical.ViewModels Command_Config = new DelegateCommand(onConfig); containerProvider = container; if (GlobalObject.isConfigIniCreateBySys) - { - var config= container.Resolve(); - config.ShowDialog(); + { + var config = container.Resolve(); + config.ShowDialog(); } UserName = _configService.Read(nameof(ConfigIni.UserName)); @@ -91,14 +91,14 @@ namespace DI_Electrical.ViewModels { sPASSWORD = GlobalObject.userInfo.userPs; } - curServer = "当前服务器: " + _configService.Read(nameof(ConfigIni.Address)) + ":" + _configService.Read(nameof(ConfigIni.Port)); + curServer = "当前服务器: " + _configService.Read("strIPAddress") + ":" + _configService.Read("nPort"); } public void onConfig(object o) { var config = containerProvider.Resolve(); config.ShowDialog(); - curServer = "当前服务器: " + _configService.Read(nameof(ConfigIni.Address)) + ":" + _configService.Read(nameof(ConfigIni.Port)); + curServer = "当前服务器: " + _configService.Read("strIPAddress") + ":" + _configService.Read("nPort"); } public override async void ExecuteOKCommandAsync(object obj) @@ -116,7 +116,7 @@ namespace DI_Electrical.ViewModels else { IsBusy = true; BusyContent = "登录中..."; - var res = await _Service.Login(UserName, Userpass); + var res = await _Service.Login(UserName, Userpass); IsBusy = false; if (string.IsNullOrEmpty(res)) { diff --git a/newFront/c#前端/SWS.CAD.Base/bin/Debug/INIFileParser.dll b/newFront/c#前端/SWS.CAD.Base/bin/Debug/INIFileParser.dll deleted file mode 100644 index d19e920f..00000000 Binary files a/newFront/c#前端/SWS.CAD.Base/bin/Debug/INIFileParser.dll and /dev/null differ diff --git a/newFront/c#前端/SWS.CAD.Base/bin/Debug/INIFileParser.xml b/newFront/c#前端/SWS.CAD.Base/bin/Debug/INIFileParser.xml deleted file mode 100644 index 7d5e96bc..00000000 --- a/newFront/c#前端/SWS.CAD.Base/bin/Debug/INIFileParser.xml +++ /dev/null @@ -1,1181 +0,0 @@ - - - - INIFileParser - - - - - Asserts that a strings has no blank spaces. - - The string to be checked. - - - - - Represents an INI data parser for files. - - - - - Ctor - - - - - Ctor - - - - - - Implements reading ini data from a file. - - - Uses codification for the file. - - - Path to the file - - - - - Implements reading ini data from a file. - - - Path to the file - - - File's encoding. - - - - - Saves INI data to a file. - - - Creats an ASCII encoded file by default. - - - Path to the file. - - - IniData to be saved as an INI file. - - - - - Writes INI data to a text file. - - - Path to the file. - - - IniData to be saved as an INI file. - - - Specifies the encoding used to create the file. - - - - - Represents all data from an INI file - - - - - Represents all sections from an INI file - - - - - Initializes an empty IniData instance. - - - - - Initializes a new IniData instance using a previous - . - - - object containing the - data with the sections of the file - - - - - Configuration used to write an ini file with the proper - delimiter characters and data. - - - If the instance was created by a parser, - this instance is a copy of the used - by the parser (i.e. different objects instances) - If this instance is created programatically without using a parser, this - property returns an instance of - - - - - Global sections. Contains key/value pairs which are not - enclosed in any section (i.e. they are defined at the beginning - of the file, before any section. - - - - - Gets the instance - with the specified section name. - - - - - Gets or sets all the - for this IniData instance. - - - - - Used to mark the separation between the section name and the key name - when using . - - - Defaults to '.'. - - - - - Creates a new object that is a copy of the current instance. - - - A new object that is a copy of this instance. - - - - - See property for more information. - - - - - Deletes all comments in all sections and key values - - - - - Merges the other iniData into this one by overwriting existing values. - Comments get appended. - - - IniData instance to merge into this. - If it is null this operation does nothing. - - - - - Attempts to retrieve a key, using a single string combining section and - key name. - - - The section and key name to retrieve, separated by . - - If key contains no separator, it is treated as a key in the section. - - Key may contain no more than one separator character. - - - If true is returned, is set to the value retrieved. Otherwise, is set - to an empty string. - - - True if key was found, otherwise false. - - - key contained multiple separators. - - - - - Retrieves a key using a single input string combining section and key name. - - - The section and key name to retrieve, separated by . - - If key contains no separator, it is treated as a key in the section. - - Key may contain no more than one separator character. - - - The key's value if it was found, otherwise null. - - - key contained multiple separators. - - - - - Merge the sections into this by overwriting this sections. - - - - - Merges the given global values into this globals by overwriting existing values. - - - - - Information associated to a key from an INI file. - Includes both the value and the comments associated to the key. - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class - from a previous instance of . - - - Data is deeply copied - - - The instance of the class - used to create the new instance. - - - - - Gets or sets the comment list associated to this key. - - - - - Gets or sets the value associated to this key. - - - - - Gets or sets the name of the key. - - - - - Creates a new object that is a copy of the current instance. - - - A new object that is a copy of this instance. - - - - - Represents a collection of Keydata. - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class with a given - search comparer - - - Search comparer used to find the key by name in the collection - - - - - Initializes a new instance of the class - from a previous instance of . - - - Data from the original KeyDataCollection instance is deeply copied - - - The instance of the class - used to create the new instance. - - - - - Gets or sets the value of a concrete key. - - - If we try to assign the value of a key which doesn't exists, - a new key is added with the name and the value is assigned to it. - - - Name of the key - - - The string with key's value or null if the key was not found. - - - - - Return the number of keys in the collection - - - - - - Adds a new key to the collection - - - KeyData instance. - - - true if the key was added false if a key with the same name already exist - in the collection - - - - - Adds a new key with the specified name and value to the collection - - - Name of the new key to be added. - - - Value associated to the key. - - - true if the key was added false if a key with the same name already exist - in the collection. - - - - - Clears all comments of this section - - - - - Gets if a specifyed key name exists in the collection. - - Key name to search - true if a key with the specified name exists in the collectoin - false otherwise - - - - Retrieves the data for a specified key given its name - - Name of the key to retrieve. - - A instance holding - the key information or null if the key wasn't found. - - - - - Deletes all keys in this collection. - - - - - Deletes a previously existing key, including its associated data. - - The key to be removed. - - true if a key with the specified name was removed - false otherwise. - - - - - Sets the key data associated to a specified key. - - The new for the key. - - - - Allows iteration througt the collection. - - A strong-typed IEnumerator - - - - Implementation needed - - A weak-typed IEnumerator. - - - - Creates a new object that is a copy of the current instance. - - - A new object that is a copy of this instance. - - - - - Collection of KeyData for a given section - - - - - Information associated to a section in a INI File - Includes both the value and the comments associated to the key. - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class - from a previous instance of . - - - Data is deeply copied - - - The instance of the class - used to create the new instance. - - - Search comparer. - - - - - Deletes all comments in this section and key/value pairs - - - - - Deletes all the key-value pairs in this section. - - - - - Merges otherSection into this, adding new keys if they don't exists - or overwriting values if the key already exists. - Comments get appended. - - - Comments are also merged but they are always added, not overwritten. - - - - - - Gets or sets the name of the section. - - - The name of the section - - - - - Gets or sets the comment list associated to this section. - - - A list of strings. - - - - - Gets or sets the keys associated to this section. - - - A collection of KeyData objects. - - - - - Creates a new object that is a copy of the current instance. - - - A new object that is a copy of this instance. - - - - - Represents a collection of SectionData. - - - - - Initializes a new instance of the class. - - - - - Initializes a new instance of the class. - - - StringComparer used when accessing section names - - - - - Initializes a new instance of the class - from a previous instance of . - - - Data is deeply copied - - - The instance of the class - used to create the new instance. - - - - Returns the number of SectionData elements in the collection - - - - - Gets the key data associated to a specified section name. - - An instance of as class - holding the key data from the current parsed INI data, or a null - value if the section doesn't exist. - - - - Creates a new section with empty data. - - - If a section with the same name exists, this operation has no effect. - - Name of the section to be created - true if the a new section with the specified name was added, - false otherwise - If the section name is not valid. - - - - Adds a new SectionData instance to the collection - - Data. - - - - Removes all entries from this collection - - - - - Gets if a section with a specified name exists in the collection. - - Name of the section to search - - true if a section with the specified name exists in the - collection false otherwise - - - - - Returns the section data from a specify section given its name. - - Name of the section. - - An instance of a class - holding the section data for the currently INI data - - - - - Sets the section data for given a section name. - - - The new instance. - - - - - - - true if the section with the specified name was removed, - false otherwise - - - - Returns an enumerator that iterates through the collection. - - - A that can be used to iterate through the collection. - - - - - Returns an enumerator that iterates through a collection. - - - An object that can be used to iterate through the collection. - - - - - Creates a new object that is a copy of the current instance. - - - A new object that is a copy of this instance. - - - - - Data associated to this section - - - - - Configuration used to write an ini file with the proper - delimiter characters and data. - - - If the instance was created by a parser, - this instance is a copy of the used - by the parser (i.e. different objects instances) - If this instance is created programatically without using a parser, this - property returns an instance of - - - - - Formats a IniData structure to an string - - - - - Produces an string given - - The data to string. - Ini data. - - - - Configuration used by this formatter when converting IniData - to an string - - - - - Represents all data from an INI file exactly as the - class, but searching for sections and keys names is done with - a case insensitive search. - - - - - Initializes an empty IniData instance. - - - - - Initializes a new IniData instance using a previous - . - - - object containing the - data with the sections of the file - - - - - Copies an instance of the class - - Original - - - - Defines data for a Parser configuration object. - - With a configuration object you can redefine how the parser - will detect special items in the ini file by defining new regex - (e.g. you can redefine the comment regex so it just treat text as - a comment iff the comment caracter is the first in the line) - or changing the set of characters used to define elements in - the ini file (e.g. change the 'comment' caracter from ';' to '#') - You can also define how the parser should treat errors, or how liberal - or conservative should it be when parsing files with "strange" formats. - - - - Default values used if an instance of - is created without specifying a configuration. - - - By default the various delimiters for the data are setted: - ';' for one-line comments - '[' ']' for delimiting a section - '=' for linking key / value pairs - - An example of well formed data with the default values: - - ;section comment
- [section] ; section comment
-
- ; key comment
- key = value ;key comment
-
- ;key2 comment
- key2 = value
-
-
-
-
- - - Copy ctor. - - - Original instance to be copied. - - - - - Sets the char that defines the start of a section name. - - - Defaults to character '[' - - - - - Sets the char that defines the end of a section name. - - - Defaults to character ']' - - - - - Retrieving section / keys by name is done with a case-insensitive - search. - - - Defaults to false (case sensitive search) - - - - - Sets the char that defines the start of a comment. - A comment spans from the comment character to the end of the line. - - - Defaults to character ';' - - - - - Sets the string that defines the start of a comment. - A comment spans from the mirst matching comment string - to the end of the line. - - - Defaults to string ";" - - - - - Gets or sets the string to use as new line string when formating an IniData structure using a - IIniDataFormatter. Parsing an ini-file accepts any new line character (Unix/windows) - - - This allows to write a file with unix new line characters on windows (and vice versa) - - Defaults to value Environment.NewLine - - - - Sets the char that defines a value assigned to a key - - - Defaults to character '=' - - - - - Sets the string around KeyValuesAssignmentChar - - - Defaults to string ' ' - - - - - Allows having keys in the file that don't belong to any section. - i.e. allows defining keys before defining a section. - If set to false and keys without a section are defined, - the will stop with an error. - - - Defaults to true. - - - - - If set to false and the finds duplicate keys in a - section the parser will stop with an error. - If set to true, duplicated keys are allowed in the file. The value - of the duplicate key will be the last value asigned to the key in the file. - - - Defaults to false. - - - - - Only used if is also true - If set to true when the parser finds a duplicate key, it overrites - the previous value, so the key will always contain the value of the - last key readed in the file - If set to false the first readed value is preserved, so the key will - always contain the value of the first key readed in the file - - - Defaults to false. - - - - - Gets or sets a value indicating whether duplicate keys are concatenate - together by . - - - Defaults to false. - - - - - If true the instance will thrown an exception - if an error is found. - If false the parser will just stop execution and return a null value. - - - Defaults to true. - - - - - If set to false and the finds a duplicate section - the parser will stop with an error. - If set to true, duplicated sections are allowed in the file, but only a - element will be created in the - collection. - - - Defaults to false. - - - - - If set to false, the stop with a error if you try - to access a section that was not created previously and the parser will stop with an error. - If set to true, inexistents sections are created, always returning a valid - element. - - - Defaults to false. - - - - - Creates a new object that is a copy of the current instance. - - - A new object that is a copy of this instance. - - 2 - - - - - Responsible for parsing an string from an ini file, and creating - an structure. - - - - - Ctor - - - The parser uses a by default - - - - - Ctor - - - Parser's instance. - - - - - Configuration that defines the behaviour and constraints - that the parser must follow. - - - - - True is the parsing operation encounter any problem - - - - - Returns the list of errors found while parsing the ini file. - - - If the configuration option ThrowExceptionOnError is false it can contain one element - for each problem found while parsing; otherwise it will only contain the very same - exception that was raised. - - - - - Parses a string containing valid ini data - - - String with data - - - An instance with the data contained in - the correctly parsed an structured. - - - Thrown if the data could not be parsed - - - - - Checks if a given string contains a comment. - - - String with a line to be checked. - - - true if any substring from s is a comment, false otherwise. - - - - - Checks if a given string represents a section delimiter. - - - The string to be checked. - - - true if the string represents a section, false otherwise. - - - - - Checks if a given string represents a key / value pair. - - - The string to be checked. - - - true if the string represents a key / value pair, false otherwise. - - - - - Removes a comment from a string if exist, and returns the string without - the comment substring. - - - The string we want to remove the comments from. - - - The string s without comments. - - - - - Processes one line and parses the data found in that line - (section or key/value pair who may or may not have comments) - - The string with the line to process - - - - Proccess a string which contains an ini section. - - - The string to be processed - - - - - Processes a string containing an ini key/value pair. - - - The string to be processed - - - - - Extracts the key portion of a string containing a key/value pair.. - - - The string to be processed, which contains a key/value pair - - - The name of the extracted key. - - - - - Extracts the value portion of a string containing a key/value pair.. - - - The string to be processed, which contains a key/value pair - - - The name of the extracted value. - - - - - Abstract Method that decides what to do in case we are trying to add a duplicated key to a section - - - - - Adds a key to a concrete instance, checking - if duplicate keys are allowed in the configuration - - - Key name - - - Key's value - - - collection where the key should be inserted - - - Name of the section where the is contained. - Used only for logging purposes. - - - - - Temp list of comments - - - - - Tmp var with the name of the seccion which is being process - - - - - Represents an INI data parser for streams. - - - - - This instance will handle ini data parsing and writing - - - - - Ctor - - - - - Ctor - - - - - - Reads data in INI format from a stream. - - Reader stream. - - And instance with the readed ini data parsed. - - - Thrown if is null. - - - - - Writes the ini data to a stream. - - A write stream where the ini data will be stored - An instance. - - Thrown if is null. - - - - - Writes the ini data to a stream. - - A write stream where the ini data will be stored - An instance. - Formaterr instance that controls how the ini data is transformed to a string - - Thrown if is null. - - - - - Represents an INI data parser for strings. - - - - This class is deprecated and kept for backwards compatibility. - It's just a wrapper around class. - Please, replace your code. - - - - - This instance will handle ini data parsing and writing - - - - - Ctor - - - - - Ctor - - - - - - Parses a string containing data formatted as an INI file. - - The string containing the data. - - A new instance with the data parsed from the string. - - - - - Creates a string from the INI data. - - An instance. - - A formatted string with the contents of the - instance object. - - - - - Represents an error ococcurred while parsing data - - -
-
diff --git a/newFront/c#前端/SWS.CAD/SWS.CAD.csproj.user b/newFront/c#前端/SWS.CAD/SWS.CAD.csproj.user index 9d7dd50e..baf72ccc 100644 --- a/newFront/c#前端/SWS.CAD/SWS.CAD.csproj.user +++ b/newFront/c#前端/SWS.CAD/SWS.CAD.csproj.user @@ -5,6 +5,6 @@ D:\Program Files\KunHeng\KunHengCAD V21 zh_CN\kunhengcad.exe - ShowAllFiles + ProjectFiles \ No newline at end of file diff --git a/newFront/c#前端/SWS.CAD/ViewModels/ConfigViewModel.cs b/newFront/c#前端/SWS.CAD/ViewModels/ConfigViewModel.cs index 184e0c69..06b2c33c 100644 --- a/newFront/c#前端/SWS.CAD/ViewModels/ConfigViewModel.cs +++ b/newFront/c#前端/SWS.CAD/ViewModels/ConfigViewModel.cs @@ -70,7 +70,6 @@ namespace SWS.CAD.ViewModels Application.ShowAlertDialog("本地文件目录不存在。"); return; } - var data = _configService.parser.ReadFile(_configService.path); _configService._httpService.Init(address, port); IsBusy = true; @@ -85,10 +84,14 @@ namespace SWS.CAD.ViewModels { address = address.Replace("https://", "").Replace("http://", ""); } - data["Profile"]["Address"] = address; - data["Profile"]["Port"] = port.ToString(); - data["Profile"]["Directory"] = _directory; - _configService.parser.WriteFile(_configService.path, data); + //var data = _configService.parser.ReadFile(_configService.path); + //data["Profile"]["Address"] = address; + //data["Profile"]["Port"] = port.ToString(); + //data["Profile"]["Directory"] = _directory; + //_configService.parser.WriteFile(_configService.path, data); + _configService.Save("Profile", "strIPAddress", address); + _configService.Save("Profile", "nPort", port.ToString()); + _configService.Save("Profile", "strLocalWorkDir", _directory); GlobalObject.isConfigIniCreateBySys = false; GlobalObject.SetLocalFileDirectory(_directory); diff --git a/newFront/c#前端/SWS.CAD/ViewModels/LoginViewModel.cs b/newFront/c#前端/SWS.CAD/ViewModels/LoginViewModel.cs index 70478749..3abf8b69 100644 --- a/newFront/c#前端/SWS.CAD/ViewModels/LoginViewModel.cs +++ b/newFront/c#前端/SWS.CAD/ViewModels/LoginViewModel.cs @@ -92,7 +92,7 @@ namespace SWS.CAD.ViewModels { sPASSWORD = GlobalObject.userInfo.userPs; } - curServer = "当前服务器: " + _configService.Read(nameof(ConfigIni.Address)) + ":" + _configService.Read(nameof(ConfigIni.Port)); + curServer = "当前服务器: " + _configService.Read("strIPAddress") + ":" + _configService.Read("nPort"); } public override async void ExecuteOKCommandAsync(object obj) { diff --git a/newFront/c#前端/SWS.CAD/Views/Style/CustomStyles.xaml b/newFront/c#前端/SWS.CAD/Views/Style/CustomStyles.xaml index 05ccc353..223f6291 100644 --- a/newFront/c#前端/SWS.CAD/Views/Style/CustomStyles.xaml +++ b/newFront/c#前端/SWS.CAD/Views/Style/CustomStyles.xaml @@ -1455,10 +1455,9 @@ - + - + diff --git a/newFront/c#前端/SWS.Commons/GlobalObject.cs b/newFront/c#前端/SWS.Commons/GlobalObject.cs index 98d8e17e..274ac651 100644 --- a/newFront/c#前端/SWS.Commons/GlobalObject.cs +++ b/newFront/c#前端/SWS.Commons/GlobalObject.cs @@ -154,10 +154,11 @@ namespace SWS.Commons { if (string.IsNullOrEmpty(_LocalFileDirectory)) { - string path = configPath; - FileIniDataParser parser = new FileIniDataParser(); - var data = parser.ReadFile(path); - _LocalFileDirectory = data["Profile"]["strLocalWorkDir"]; + //string path = configPath; + //FileIniDataParser parser = new FileIniDataParser(); + //var data = parser.ReadFile(path); + //_LocalFileDirectory = data["Profile"]["strLocalWorkDir"]; + _LocalFileDirectory = IniHelper.ReadValueFromIniFile("Profile", "strLocalWorkDir"); return _LocalFileDirectory; } else diff --git a/newFront/c#前端/SWS.Commons/Helper/IniHelper.cs b/newFront/c#前端/SWS.Commons/Helper/IniHelper.cs new file mode 100644 index 00000000..aab824ef --- /dev/null +++ b/newFront/c#前端/SWS.Commons/Helper/IniHelper.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace SWS.Commons +{ + public static class IniHelper + { + [DllImport("kernel32", CharSet = CharSet.Unicode)] + private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); + [DllImport("kernel32", CharSet = CharSet.Unicode)] + private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); + + /// + ///读取ini文件数据 + /// + /// 段 + /// 键名 + /// 默认值 + /// 文件路径 + /// 读出内容 + public static string ReadValueFromIniFile(string Section, string Key, string def=null, string filePath= null) + { + if (def == null) + { def = ""; } + if (filePath == null) + { + filePath = GlobalObject.configPath; + } + StringBuilder temp = new StringBuilder(4096); + int i = GetPrivateProfileString(Section, Key, def, temp, 4096, filePath); + return temp.ToString(); + } + + /// + /// 写入数据到ini文件 + /// + /// 段 + /// 键名 + /// 键值 + /// 文件路径 + public static void WriteValueFromIniFile(string Section, string Key, string Value, string filePath = null) + { + if (filePath == null) + { + filePath = GlobalObject.configPath; + } + WritePrivateProfileString(Section, Key, Value, filePath); + } + } +} diff --git a/newFront/c#前端/SWS.Commons/Helper/LoggerHelper.cs b/newFront/c#前端/SWS.Commons/Helper/LoggerHelper.cs index 4079da72..fde9743d 100644 --- a/newFront/c#前端/SWS.Commons/Helper/LoggerHelper.cs +++ b/newFront/c#前端/SWS.Commons/Helper/LoggerHelper.cs @@ -24,6 +24,8 @@ namespace SWS.Commons string dllPath = codeBase.Replace("file:///", ""); dllPath = Path.GetDirectoryName(dllPath); logPath = Path.Combine(dllPath, "Logs\\"); + if (!Directory.Exists(logPath)) + { Directory.CreateDirectory(logPath); } var configFile = new FileInfo(Path.Combine(dllPath, "log4net.config")); log4net.Config.XmlConfigurator.ConfigureAndWatch(configFile); } diff --git a/newFront/c#前端/SWS.Commons/SWS.Commons.csproj b/newFront/c#前端/SWS.Commons/SWS.Commons.csproj index 64cae859..a025facf 100644 --- a/newFront/c#前端/SWS.Commons/SWS.Commons.csproj +++ b/newFront/c#前端/SWS.Commons/SWS.Commons.csproj @@ -110,6 +110,7 @@ + diff --git a/newFront/c#前端/SWS.Commons/SWS.Commons.csproj.user b/newFront/c#前端/SWS.Commons/SWS.Commons.csproj.user index a607660d..0b246432 100644 --- a/newFront/c#前端/SWS.Commons/SWS.Commons.csproj.user +++ b/newFront/c#前端/SWS.Commons/SWS.Commons.csproj.user @@ -1,6 +1,6 @@ - ShowAllFiles + ProjectFiles \ No newline at end of file diff --git a/newFront/c#前端/SWS.Electrical/GlobalObj.cs b/newFront/c#前端/SWS.Electrical/GlobalObj.cs index 7e9f6642..33f5af5c 100644 --- a/newFront/c#前端/SWS.Electrical/GlobalObj.cs +++ b/newFront/c#前端/SWS.Electrical/GlobalObj.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.IO; using System.Linq; using System.Net; using System.Net.Http; @@ -11,6 +12,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Media; using IniParser; +using IniParser.Model; using Newtonsoft.Json; using Prism.Ioc; using SWS.Commons; @@ -41,17 +43,29 @@ namespace SWS.Electrical { try { - var data = configIni.ReadFile(GlobalObject.configPath); - string token = data["LoginInfo"]["LoginToken"]; - string loginkey = data["LoginInfo"]["LoginMark"]; - string curProjId = data["LoginInfo"]["CurProjId"]; - LocalWorkDir= data["Profile"]["strLocalWorkDir"]; - string address = data["Profile"]["strIPAddress"]; - string port = data["Profile"]["nPort"]; - string dbType = data["Profile"]["nConType"]; + //var parser = new FileIniDataParser(); + //string[] lines = File.ReadAllLines(GlobalObject.configPath); + //IniData data = parser.Parser.Parse(File.ReadAllText(GlobalObject.configPath)); + //var data = configIni.ReadFile(GlobalObject.configPath); + //string token = data["LoginInfo"]["LoginToken"]; + //string loginkey = data["LoginInfo"]["LoginMark"]; + //string curProjId = data["LoginInfo"]["CurProjId"]; + //LocalWorkDir= data["Profile"]["strLocalWorkDir"]; + //string address = data["Profile"]["strIPAddress"]; + //string port = data["Profile"]["nPort"]; + //string dbType = data["Profile"]["nConType"]; + //string domain= data["Profile"]["strDomainName"]; + string token = IniHelper.ReadValueFromIniFile("LoginInfo", "LoginToken"); + string loginkey = IniHelper.ReadValueFromIniFile("LoginInfo", "LoginMark"); + string curProjId = IniHelper.ReadValueFromIniFile("LoginInfo", "CurProjId"); + LocalWorkDir = IniHelper.ReadValueFromIniFile("Profile", "strLocalWorkDir"); + string address = IniHelper.ReadValueFromIniFile("Profile", "strIPAddress"); + string port = IniHelper.ReadValueFromIniFile("Profile", "nPort"); + string dbType = IniHelper.ReadValueFromIniFile("Profile", "nConType"); + string domain = IniHelper.ReadValueFromIniFile("Profile", "strDomainName"); if (dbType == "1") { - string strDomain = data["Profile"]["strDomainName"]; + string strDomain = domain; GlobalObject.client = new HttpClient() { BaseAddress = new Uri($"{strDomain}/api/"), diff --git a/newFront/c#前端/SWS.Electrical/SWS.Electrical.csproj b/newFront/c#前端/SWS.Electrical/SWS.Electrical.csproj index 088f77c2..49271b7a 100644 --- a/newFront/c#前端/SWS.Electrical/SWS.Electrical.csproj +++ b/newFront/c#前端/SWS.Electrical/SWS.Electrical.csproj @@ -153,6 +153,7 @@ + diff --git a/newFront/c#前端/SWS.Electrical/ViewModels/DialogAutoArrangeLayoutViewModel.cs b/newFront/c#前端/SWS.Electrical/ViewModels/DialogAutoArrangeLayoutViewModel.cs index 1a86e4f3..28e9954f 100644 --- a/newFront/c#前端/SWS.Electrical/ViewModels/DialogAutoArrangeLayoutViewModel.cs +++ b/newFront/c#前端/SWS.Electrical/ViewModels/DialogAutoArrangeLayoutViewModel.cs @@ -130,6 +130,7 @@ namespace SWS.Electrical.ViewModels if (value != this._selectRange) { this._selectRange = value; + RangeChange(value); RaisePropertyChanged(nameof(selectRange)); } } @@ -167,6 +168,22 @@ namespace SWS.Electrical.ViewModels } } } + private ObservableCollection _listValue; + /// + /// 输入值 列表 + /// + public ObservableCollection listValue + { + get { return this._listValue; } + set + { + if (value != this._listValue) + { + this._listValue = value; + RaisePropertyChanged(nameof(listValue)); + } + } + } private string _inputValue = ""; /// /// 输入值 @@ -195,11 +212,15 @@ namespace SWS.Electrical.ViewModels EnginedataService _ServiceEnginedata; ObjectTypeService _ServiceObjectType; ProjectSettingsService _ServiceProjectSettings; + DataItemService _ServiceDataItem; List listTagNumberSucc = new List(); private bool isSearch = false;//是否正在查询 private bool isDrawing = false;//是否正在画图 private string dwgName = string.Empty; private List listLibraryTagName = new List();//元件图纸上的位号属性名称, + private List listDeck=new List();//甲板号值列表 + private List listArea = new List();//区域值列表 + private List listSystem = new List();//所属系统值列表 public DialogAutoArrangeLayoutViewModel() { Command_StartDrawing = new DelegateCommand(onStartDrawing); @@ -215,6 +236,7 @@ namespace SWS.Electrical.ViewModels _ServiceEnginedata = GlobalObject.container.Resolve(); _ServiceObjectType = GlobalObject.container.Resolve(); _ServiceProjectSettings = GlobalObject.container.Resolve(); + _ServiceDataItem= GlobalObject.container.Resolve(); listDrawings = new ObservableCollection(); listBasePoint = new ObservableCollection(); listMsg = new ObservableCollection(); @@ -223,7 +245,6 @@ namespace SWS.Electrical.ViewModels list.Add(new KeyValueModel { Key = "区域", Value = "区域" }); list.Add(new KeyValueModel { Key = "所属系统", Value = "所属系统" }); listRange = new ObservableCollection(list); - selectRange = listRange[0]; listOperator = new ObservableCollection() { new KeyValueModel { Key = "等于", Value = "=" } }; @@ -243,7 +264,33 @@ namespace SWS.Electrical.ViewModels { } - + private List GetChildNodes(TreeModel treeModel) + { + List listModel = new List(); + if (treeModel.ChildNodes != null && treeModel.ChildNodes.Any()) + { + foreach (var item in treeModel.ChildNodes) + { + if (item.NodeType == "1") + { + listModel.Add(item); + } + else + { + var list = GetChildNodes(item); + if (list.Any()) + { + listModel.AddRange(list); + } + } + } + return listModel; + } + else + { + return listModel; + } + } public async void OnDialogOpened(IDialogParameters parameters) { try @@ -259,8 +306,19 @@ namespace SWS.Electrical.ViewModels if (item.NodeType == "1") { listDrawings.Add(new DtoDrawing() { DrawingFileID = item.ID, DrawingFileName = item.Text }); - ec_drawing_file dwgFile = JsonConvert.DeserializeObject(model.NodeExtData.ToString()); - + } + else + { + if (item.Text == "封面、目录、设计说明" || item.Text == "材料表") + { continue; } + var list = GetChildNodes(item); + if (list.Any()) + { + foreach (var dto in list) + { + listDrawings.Add(new DtoDrawing() { DrawingFileID = dto.ID, DrawingFileName = dto.Text }); + } + } } } } @@ -289,14 +347,24 @@ namespace SWS.Electrical.ViewModels if (item.NodeType == "1") { listDrawings.Add(new DtoDrawing() { DrawingFileID = item.ID, DrawingFileName = item.Text }); - ec_drawing_file dwgFile = JsonConvert.DeserializeObject(model.NodeExtData.ToString()); - + } + else + { + if (item.Text == "封面、目录、设计说明" || item.Text == "材料表") + { continue; } + var list = GetChildNodes(item); + if (list.Any()) + { + foreach (var dto in list) + { + listDrawings.Add(new DtoDrawing() { DrawingFileID = dto.ID, DrawingFileName = dto.Text }); + } + } } } } } AddMsg($"布置图列表加载完成!"); - } var settingModel = await _ServiceProjectSettings.GetEntity("布置图图例显示位号名称"); if (settingModel == null) @@ -304,16 +372,48 @@ namespace SWS.Electrical.ViewModels listLibraryTagName.Add("位号");//默认 } else { listLibraryTagName = settingModel.SettingValue.Split(',').ToList(); } - + //区域下拉框对应值列表 + var listDetail = await _ServiceDataItem.GetDetails("Area"); + if (listDetail != null && listDetail.Any()) + { + foreach (var item in listDetail) + { listArea.Add(new KeyValueModel() { Key=item.DataItemName, Value=item.DataItemName }); } + } + //甲板号下拉框对应值列表 + listDetail = await _ServiceDataItem.GetDetails("甲板号"); + if (listDetail != null && listDetail.Any()) + { + foreach (var item in listDetail) + { listDeck.Add(new KeyValueModel() { Key = item.DataItemName, Value = item.DataItemName }); } + } + //所属系统下拉框对应值列表 + listDetail = await _ServiceDataItem.GetDetails("Be_DrawingSystem"); + if (listDetail != null && listDetail.Any()) + { + foreach (var item in listDetail) + { listSystem.Add(new KeyValueModel() { Key = item.DataItemName, Value = item.DataItemName }); } + } + selectRange = listRange[0]; } catch (Exception ex) { MessageBox.Show("DialogOpened异常:" + ex.Message); } - //selectRange = listRange[2]; - //inputValue = "声力电话"; } - + /// + /// 下拉值列表绑定 + /// + /// + private void RangeChange(KeyValueModel model) + { + inputValue = ""; + if (model.Value == "甲板号") + { listValue = new ObservableCollection(listDeck); } + else if (model.Value == "区域") + { listValue = new ObservableCollection(listArea); } + else if (model.Value == "所属系统") + { listValue = new ObservableCollection(listSystem); } + } /// /// 获取基点信息 /// diff --git a/newFront/c#前端/SWS.Electrical/Views/DialogAutoArrangeLayout.xaml b/newFront/c#前端/SWS.Electrical/Views/DialogAutoArrangeLayout.xaml index 31ec28f3..f466f2f8 100644 --- a/newFront/c#前端/SWS.Electrical/Views/DialogAutoArrangeLayout.xaml +++ b/newFront/c#前端/SWS.Electrical/Views/DialogAutoArrangeLayout.xaml @@ -178,13 +178,22 @@ FontSize="16" ItemsSource="{Binding listOperator}" SelectedItem="{Binding selectOperator, Mode=TwoWay}" /> - - + // 此代码由工具生成。 @@ -85,7 +85,7 @@ namespace SWS.Electrical.Views { #line hidden - #line 211 "..\..\..\Views\DialogAutoArrangeLayout.xaml" + #line 219 "..\..\..\Views\DialogAutoArrangeLayout.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.DataGrid dgTag; diff --git a/newFront/c#前端/SWS.Electrical/obj/Debug/Views/DialogAutoArrangeLayout.g.i.cs b/newFront/c#前端/SWS.Electrical/obj/Debug/Views/DialogAutoArrangeLayout.g.i.cs index 48c6c684..d70c25de 100644 --- a/newFront/c#前端/SWS.Electrical/obj/Debug/Views/DialogAutoArrangeLayout.g.i.cs +++ b/newFront/c#前端/SWS.Electrical/obj/Debug/Views/DialogAutoArrangeLayout.g.i.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\..\Views\DialogAutoArrangeLayout.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "8006F31A06196293D0E58F4239B97FC4F768BCF414C1B4C2472A1C22D26CF0B1" +#pragma checksum "..\..\..\Views\DialogAutoArrangeLayout.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "55992553F782D436B236E9D0626B49AE48376927B5906F253898CDC4189B1D22" //------------------------------------------------------------------------------ // // 此代码由工具生成。 @@ -85,7 +85,7 @@ namespace SWS.Electrical.Views { #line hidden - #line 211 "..\..\..\Views\DialogAutoArrangeLayout.xaml" + #line 220 "..\..\..\Views\DialogAutoArrangeLayout.xaml" [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] internal System.Windows.Controls.DataGrid dgTag; diff --git a/newFront/c#前端/SWS.Electrical/配置说明.docx b/newFront/c#前端/SWS.Electrical/配置说明.docx new file mode 100644 index 00000000..71cbefd5 --- /dev/null +++ b/newFront/c#前端/SWS.Electrical/配置说明.docx @@ -0,0 +1,10 @@ + + +第1步:把文件拷贝到D盘文件夹[SWS.Electrical]里面 +第2步:在坤恒CAD的安装目录里,找到文件:on_start.lsp ,用记事本打开 + + +第3步:把下面一行命令,添加到最下面 +(command "netload" "D:\\SWS.Electrical\\SWS.Electrical.dll") + +PS:存放文件夹路径可以自己定 diff --git a/newFront/c#前端/SWS.Service/ConfigService.cs b/newFront/c#前端/SWS.Service/ConfigService.cs index 7c2c292f..4d2b4110 100644 --- a/newFront/c#前端/SWS.Service/ConfigService.cs +++ b/newFront/c#前端/SWS.Service/ConfigService.cs @@ -2,6 +2,7 @@ using SWS.Commons; using System; using System.IO; +using static System.Collections.Specialized.BitVector32; namespace SWS.Service { @@ -16,13 +17,12 @@ namespace SWS.Service void SetDefaultConfigValue() { if (!File.Exists(path)) - {//默认值 + { + //默认值 var data = parser.Parser.Parse(""); data["Profile"]["strIPAddress"] = "1.117.161.11"; data["Profile"]["nPort"] = "8080"; string userProfilePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - - data["Profile"]["strLocalWorkDir"] = $"{userProfilePath}\\AppData\\Roaming\\BricsCAD Electrical"; Directory.CreateDirectory(Path.GetDirectoryName(path)); parser.WriteFile(path, data); @@ -40,17 +40,21 @@ namespace SWS.Service string address; int port; string locDrawingPath; - Read(out address, out port,out locDrawingPath); + Read(out address, out port, out locDrawingPath); _httpService.Init(address, port); - } + } public void Read(out string address, out int port, out string directory) { - var data = parser.ReadFile(path); - address = data["Profile"]["strIPAddress"]; - port = int.Parse(data["Profile"]["nPort"]); - directory = data["Profile"]["strLocalWorkDir"]; + //var data = parser.ReadFile(path); + //address = data["Profile"]["strIPAddress"]; + //port = int.Parse(data["Profile"]["nPort"]); + //directory = data["Profile"]["strLocalWorkDir"]; + + address = IniHelper.ReadValueFromIniFile("Profile", "strIPAddress"); + port = int.Parse(IniHelper.ReadValueFromIniFile("Profile", "nPort")); + directory = IniHelper.ReadValueFromIniFile("Profile", "strLocalWorkDir"); } - + /// /// 查询某个 /// @@ -58,8 +62,11 @@ namespace SWS.Service /// public string Read(string keyName) { - var data = parser.ReadFile(path); - return data["Profile"][keyName]; + //var data = parser.ReadFile(path); + //return data["Profile"][keyName]; + + var data = IniHelper.ReadValueFromIniFile("Profile", keyName); + return data; } /// /// 查询某个 @@ -67,14 +74,17 @@ namespace SWS.Service /// 节点 /// key名称 /// - public string Read(string session,string keyName) + public string Read(string session, string keyName) { try - { - var data = parser.ReadFile(path); - return data[session][keyName]; + { + //var data = parser.ReadFile(path); + //return data[session][keyName]; + + var data = IniHelper.ReadValueFromIniFile(session, keyName); + return data; } - catch + catch { return null; } @@ -86,9 +96,10 @@ namespace SWS.Service /// public void Save(string keyName, string value) { - var data = parser.ReadFile(path); - data["Profile"][keyName] = value; - parser.WriteFile(path, data); + //var data = parser.ReadFile(path); + //data["Profile"][keyName] = value; + //parser.WriteFile(path, data); + IniHelper.WriteValueFromIniFile("Profile", keyName, value); } /// /// 保存某个值 @@ -98,9 +109,11 @@ namespace SWS.Service /// 值 public void Save(string session, string keyName, string value) { - var data = parser.ReadFile(path); - data[session][keyName] = value; - parser.WriteFile(path, data); + //var data = parser.ReadFile(path); + //data[session][keyName] = value; + //parser.WriteFile(path, data); + + IniHelper.WriteValueFromIniFile(session, keyName, value); } } } diff --git a/newFront/c#前端/SWS.WPF/Style/CustomStyles.xaml b/newFront/c#前端/SWS.WPF/Style/CustomStyles.xaml index 8e4af90a..583627d5 100644 --- a/newFront/c#前端/SWS.WPF/Style/CustomStyles.xaml +++ b/newFront/c#前端/SWS.WPF/Style/CustomStyles.xaml @@ -1,10 +1,10 @@  @@ -579,7 +579,7 @@ - +