Quellcode durchsuchen

Revert "zhao:上传框架"

This reverts commit 7b65e39427.
master
张剑 vor 3 Jahren
Ursprung
Commit
47faf77b5e
70 geänderte Dateien mit 0 neuen und 49467 gelöschten Zeilen
  1. 0
    110
      Common/AESHelper.cs
  2. 0
    105
      Common/Common.csproj
  3. 0
    174
      Common/Model/DownloadInfoModel.cs
  4. 0
    39
      Common/Properties/AssemblyInfo.cs
  5. 0
    94
      Common/ZB/ClippingBorder.cs
  6. BIN
      Common/dlls/CheckPoint.dll
  7. BIN
      Common/dlls/ICSharpCode.SharpZipLib.dll
  8. BIN
      Common/dlls/NPOI.OOXML.dll
  9. BIN
      Common/dlls/NPOI.OpenXml4Net.dll
  10. BIN
      Common/dlls/NPOI.OpenXmlFormats.dll
  11. BIN
      Common/dlls/NPOI.dll
  12. BIN
      Common/dlls/Newtonsoft.Json.dll
  13. 0
    9144
      Common/dlls/Newtonsoft.Json.xml
  14. BIN
      Common/dlls/RbtBezier.dll
  15. BIN
      Common/dlls/RobotDotMatrix.dll
  16. BIN
      Common/dlls/RobotUsbWrapper.dll
  17. BIN
      Common/dlls/RobotpenGateway.dll
  18. BIN
      Common/dlls/SonixUSB.dll
  19. BIN
      Common/dlls/System.Data.SQLite.dll
  20. BIN
      Common/dlls/TQLComm.dll
  21. BIN
      Common/dlls/TStudy.DigitalPen.dll
  22. BIN
      Common/dlls/TStudyDigitalPen.dll
  23. BIN
      Common/dlls/TStudyDigitalPenInter.dll
  24. BIN
      Common/dlls/TStudyDigitalPenLic.dll
  25. BIN
      Common/dlls/ZYD_SDK_USB.dll
  26. BIN
      Common/dlls/log4net.dll
  27. 0
    31814
      Common/dlls/log4net.xml
  28. 0
    52
      Common/log4net.config
  29. 0
    10
      Common/packages.config
  30. 0
    114
      Common/system/BackgroundWorkerHelper.cs
  31. 0
    304
      Common/system/BlackboardNew.cs
  32. 0
    701
      Common/system/CLeopardZip.cs
  33. 0
    36
      Common/system/DataConvertCommon.cs
  34. 0
    100
      Common/system/DataProvider.cs
  35. 0
    411
      Common/system/DownloadManager.cs
  36. 0
    237
      Common/system/DownloadService.cs
  37. 0
    982
      Common/system/FileToolsCommon.cs
  38. 0
    60
      Common/system/FreeMemoryHelper.cs
  39. 0
    631
      Common/system/HttpHelper.cs
  40. 0
    967
      Common/system/ImageHelper.cs
  41. 0
    64
      Common/system/JsonHelper.cs
  42. 0
    208
      Common/system/KeyboardHookCommon.cs
  43. 0
    25
      Common/system/LogHelper.cs
  44. 0
    95
      Common/system/MouseEventCommon.cs
  45. 0
    18
      Common/system/NumUtil.cs
  46. 0
    88
      Common/system/PdfTrunImage.cs
  47. 0
    166
      Common/system/PrimaryScreen.cs
  48. 0
    92
      Common/system/QueueSync.cs
  49. 0
    1412
      Common/system/RegistryHelper.cs
  50. 0
    104
      Common/system/SplashScreen.cs
  51. 0
    192
      Common/system/XmlUtilHelper.cs
  52. 0
    94
      Common/system/ZJClippingBorder.cs
  53. 0
    242
      XHPZ.Desktop/APP.cs
  54. 0
    6
      XHPZ.Desktop/App.config
  55. 0
    9
      XHPZ.Desktop/App.xaml
  56. 0
    17
      XHPZ.Desktop/App.xaml.cs
  57. BIN
      XHPZ.Desktop/CheckPoint.dll
  58. 0
    12
      XHPZ.Desktop/MainWindow.xaml
  59. 0
    30
      XHPZ.Desktop/MainWindow.xaml.cs
  60. 0
    55
      XHPZ.Desktop/Properties/AssemblyInfo.cs
  61. 0
    70
      XHPZ.Desktop/Properties/Resources.Designer.cs
  62. 0
    117
      XHPZ.Desktop/Properties/Resources.resx
  63. 0
    29
      XHPZ.Desktop/Properties/Settings.Designer.cs
  64. 0
    7
      XHPZ.Desktop/Properties/Settings.settings
  65. 0
    69
      XHPZ.Desktop/Properties/app.manifest
  66. BIN
      XHPZ.Desktop/RobotDotMatrix.dll
  67. BIN
      XHPZ.Desktop/RobotUsbWrapper.dll
  68. BIN
      XHPZ.Desktop/SonixUSB.dll
  69. 0
    130
      XHPZ.Desktop/XHPZ.Desktop.csproj
  70. 0
    31
      XHPZ.sln

+ 0
- 110
Common/AESHelper.cs Datei anzeigen

@@ -1,110 +0,0 @@
1
-using System;
2
-using System.Security.Cryptography;
3
-using System.Text;
4
-
5
-namespace Common
6
-{
7
-    /// <summary>
8
-    /// AES加密
9
-    /// 创建人:赵耀
10
-    /// 创建时间:2020年9月7日
11
-    /// </summary>
12
-    public class AESHelper
13
-    {
14
-        public static string QrcodeLoginKey = "zyyxhlywkdatakey";
15
-
16
-        /// <summary>
17
-        /// AES 加密
18
-        /// </summary>
19
-        /// <param name="content">Need encrypted string</param>
20
-        /// <returns>Encrypted 16 hex string</returns>
21
-        public static string AESEncrypt(string Data)
22
-        {
23
-            string key = QrcodeLoginKey.PadRight(16, '0');
24
-            // 256-AES key      
25
-            byte[] keyArray = UTF8Encoding.ASCII.GetBytes(key);
26
-            byte[] toEncryptArray = UTF8Encoding.ASCII.GetBytes(Data);
27
-
28
-            RijndaelManaged rDel = new RijndaelManaged
29
-            {
30
-                Key = keyArray,
31
-                Mode = CipherMode.ECB,
32
-                Padding = PaddingMode.PKCS7
33
-            };
34
-
35
-            ICryptoTransform cTransform = rDel.CreateEncryptor();
36
-            byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0,
37
-                    toEncryptArray.Length);
38
-
39
-            return BytesToHexString(resultArray);
40
-        }
41
-
42
-        /// <summary>
43
-        /// AES 解密
44
-        /// </summary>
45
-        /// <param name="hexString">Encrypted 16 hex string</param>
46
-        /// <returns>Decrypted string</returns>
47
-        public static string AESDecrypt(string hexString)
48
-        {
49
-            string key = QrcodeLoginKey.PadRight(16, '0');
50
-            // 256-AES key      
51
-            byte[] keyArray = UTF8Encoding.ASCII.GetBytes(key);
52
-            byte[] toEncryptArray = HexStringToBytes(hexString);
53
-
54
-            RijndaelManaged rDel = new RijndaelManaged
55
-            {
56
-                Key = keyArray,
57
-                Mode = CipherMode.ECB,
58
-                Padding = PaddingMode.PKCS7
59
-            };
60
-
61
-            ICryptoTransform cTransform = rDel.CreateDecryptor();
62
-            byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0,
63
-                    toEncryptArray.Length);
64
-
65
-            return UTF8Encoding.ASCII.GetString(resultArray);
66
-        }
67
-
68
-        /// <summary>
69
-        /// Byte array to convert 16 hex string
70
-        /// </summary>
71
-        /// <param name="bytes">byte array</param>
72
-        /// <returns>16 hex string</returns>
73
-        public static string BytesToHexString(byte[] bytes)
74
-        {
75
-            StringBuilder returnStr = new StringBuilder();
76
-            if (bytes != null || bytes.Length == 0)
77
-            {
78
-                for (int i = 0; i < bytes.Length; i++)
79
-                {
80
-                    returnStr.Append(bytes[i].ToString("X2"));
81
-                }
82
-            }
83
-            return returnStr.ToString();
84
-        }
85
-
86
-        /// <summary>
87
-        /// 16 hex string converted to byte array
88
-        /// </summary>
89
-        /// <param name="hexString">16 hex string</param>
90
-        /// <returns>byte array</returns>
91
-        public static byte[] HexStringToBytes(string hexString)
92
-        {
93
-            if (hexString == null || hexString.Equals(""))
94
-            {
95
-                return null;
96
-            }
97
-            int length = hexString.Length / 2;
98
-            if (hexString.Length % 2 != 0)
99
-            {
100
-                return null;
101
-            }
102
-            byte[] d = new byte[length];
103
-            for (int i = 0; i < length; i++)
104
-            {
105
-                d[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
106
-            }
107
-            return d;
108
-        }
109
-    }
110
-}

+ 0
- 105
Common/Common.csproj Datei anzeigen

@@ -1,105 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4
-  <PropertyGroup>
5
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7
-    <ProjectGuid>{808A7075-5AF5-46B3-8EF6-514C0B5FA8D7}</ProjectGuid>
8
-    <OutputType>Library</OutputType>
9
-    <AppDesignerFolder>Properties</AppDesignerFolder>
10
-    <RootNamespace>Common</RootNamespace>
11
-    <AssemblyName>Common</AssemblyName>
12
-    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13
-    <FileAlignment>512</FileAlignment>
14
-    <Deterministic>true</Deterministic>
15
-  </PropertyGroup>
16
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17
-    <DebugSymbols>true</DebugSymbols>
18
-    <DebugType>full</DebugType>
19
-    <Optimize>false</Optimize>
20
-    <OutputPath>bin\Debug\</OutputPath>
21
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
22
-    <ErrorReport>prompt</ErrorReport>
23
-    <WarningLevel>4</WarningLevel>
24
-  </PropertyGroup>
25
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26
-    <DebugType>pdbonly</DebugType>
27
-    <Optimize>true</Optimize>
28
-    <OutputPath>bin\Release\</OutputPath>
29
-    <DefineConstants>TRACE</DefineConstants>
30
-    <ErrorReport>prompt</ErrorReport>
31
-    <WarningLevel>4</WarningLevel>
32
-  </PropertyGroup>
33
-  <ItemGroup>
34
-    <Reference Include="ICSharpCode.SharpZipLib">
35
-      <HintPath>dlls\ICSharpCode.SharpZipLib.dll</HintPath>
36
-    </Reference>
37
-    <Reference Include="log4net">
38
-      <HintPath>dlls\log4net.dll</HintPath>
39
-    </Reference>
40
-    <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
41
-      <SpecificVersion>False</SpecificVersion>
42
-      <HintPath>dlls\Newtonsoft.Json.dll</HintPath>
43
-    </Reference>
44
-    <Reference Include="O2S.Components.PDFRender4NET">
45
-      <HintPath>..\dl\O2S.Components.PDFRender4NET.dll</HintPath>
46
-    </Reference>
47
-    <Reference Include="PresentationCore" />
48
-    <Reference Include="PresentationFramework" />
49
-    <Reference Include="System" />
50
-    <Reference Include="System.Configuration" />
51
-    <Reference Include="System.Core" />
52
-    <Reference Include="System.Data.SQLite">
53
-      <HintPath>dlls\System.Data.SQLite.dll</HintPath>
54
-    </Reference>
55
-    <Reference Include="System.Drawing" />
56
-    <Reference Include="System.Web" />
57
-    <Reference Include="System.Windows.Forms" />
58
-    <Reference Include="System.Xml.Linq" />
59
-    <Reference Include="System.Data.DataSetExtensions" />
60
-    <Reference Include="Microsoft.CSharp" />
61
-    <Reference Include="System.Data" />
62
-    <Reference Include="System.Net.Http" />
63
-    <Reference Include="System.Xml" />
64
-    <Reference Include="WindowsBase" />
65
-    <Reference Include="WindowsFormsIntegration" />
66
-  </ItemGroup>
67
-  <ItemGroup>
68
-    <Compile Include="AESHelper.cs" />
69
-    <Compile Include="Model\DownloadInfoModel.cs" />
70
-    <Compile Include="system\BackgroundWorkerHelper.cs" />
71
-    <Compile Include="system\DataProvider.cs" />
72
-    <Compile Include="system\KeyboardHookCommon.cs" />
73
-    <Compile Include="system\MouseEventCommon.cs" />
74
-    <Compile Include="system\NumUtil.cs" />
75
-    <Compile Include="system\PdfTrunImage.cs" />
76
-    <Compile Include="system\BlackboardNew.cs" />
77
-    <Compile Include="system\CLeopardZip.cs" />
78
-    <Compile Include="system\DataConvertCommon.cs" />
79
-    <Compile Include="system\DownloadManager.cs" />
80
-    <Compile Include="system\DownloadService.cs" />
81
-    <Compile Include="system\FileToolsCommon.cs" />
82
-    <Compile Include="system\FreeMemoryHelper.cs" />
83
-    <Compile Include="system\HttpHelper.cs" />
84
-    <Compile Include="system\ImageHelper.cs" />
85
-    <Compile Include="system\JsonHelper.cs" />
86
-    <Compile Include="system\LogHelper.cs" />
87
-    <Compile Include="system\PrimaryScreen.cs" />
88
-    <Compile Include="Properties\AssemblyInfo.cs" />
89
-    <Compile Include="system\RegistryHelper.cs" />
90
-    <Compile Include="system\SplashScreen.cs" />
91
-    <Compile Include="system\XmlUtilHelper.cs" />
92
-    <Compile Include="system\ZJClippingBorder.cs" />
93
-    <Compile Include="ZB\ClippingBorder.cs" />
94
-  </ItemGroup>
95
-  <ItemGroup>
96
-    <Folder Include="dlls\" />
97
-  </ItemGroup>
98
-  <ItemGroup>
99
-    <None Include="log4net.config">
100
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
101
-    </None>
102
-    <None Include="packages.config" />
103
-  </ItemGroup>
104
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
105
-</Project>

+ 0
- 174
Common/Model/DownloadInfoModel.cs Datei anzeigen

@@ -1,174 +0,0 @@
1
-using System.Collections.Generic;
2
-
3
-namespace Common.Model
4
-{
5
-    /// <summary>
6
-    /// 下载模型
7
-    /// 创建人:赵耀
8
-    /// 创建时间:2018年10月30日
9
-    /// </summary>
10
-    public class DownloadInfoModel
11
-    {
12
-        /// <summary>
13
-        /// 子线程数量
14
-        /// </summary>
15
-        private int _taskCount = 1;
16
-
17
-        /// <summary>
18
-        /// 子线程数量
19
-        /// </summary>
20
-        public int taskCount
21
-        {
22
-            get => _taskCount;
23
-            set => _taskCount = value;
24
-        }
25
-        /// <summary>
26
-        /// 保存的临时文件名
27
-        /// </summary>
28
-        public string tempFileName { get; set; }
29
-        /// <summary>
30
-        /// 是否是新任务,如果不是新任务则通过配置去分配线程
31
-        /// 一开始要设为true,在初始化完成后会被设为true,此时可以对这个 DownloadInfo 进行序列化后保存,进而实现退出程序加载配置继续下载。
32
-        /// </summary>
33
-        private bool _isNewTask = true;
34
-
35
-        /// <summary>
36
-        /// 是否是新任务,如果不是新任务则通过配置去分配线程
37
-        /// 一开始要设为true,在初始化完成后会被设为true,此时可以对这个 DownloadInfo 进行序列化后保存,进而实现退出程序加载配置继续下载。
38
-        /// </summary>
39
-        public bool isNewTask
40
-        {
41
-            get => _isNewTask;
42
-            set => _isNewTask = value;
43
-        }
44
-        /// <summary>
45
-        /// 是否重新下载
46
-        /// </summary>
47
-        private bool _isReStart = false;
48
-
49
-        /// <summary>
50
-        /// 是否重新下载
51
-        /// </summary>
52
-        public bool isReStart
53
-        {
54
-            get => _isReStart;
55
-            set => _isReStart = value;
56
-        }
57
-        /// <summary>
58
-        /// 任务总大小
59
-        /// </summary>
60
-        public long count { get; set; }
61
-        /// <summary>
62
-        /// 保存的目录
63
-        /// </summary>
64
-        public string saveDir { get; set; }
65
-        /// <summary>
66
-        /// 请求方法
67
-        /// </summary>
68
-        private string _method = "get";
69
-
70
-        /// <summary>
71
-        /// 请求方法
72
-        /// </summary>
73
-        public string method
74
-        {
75
-            get => _method;
76
-            set => _method = value;
77
-        }
78
-        /// <summary>
79
-        /// 文件名
80
-        /// </summary>
81
-        public string fileName { get; set; }
82
-
83
-        public List<string> _downloadUrlList;
84
-        /// <summary>
85
-        /// 下载地址,
86
-        /// 这里是列表形式,如果同一个文件有不同来源则可以通过不同来源取数据
87
-        /// 来源的有消息需另外判断
88
-        /// </summary>
89
-        public List<string> downloadUrlList
90
-        {
91
-            get => _downloadUrlList;
92
-
93
-            set
94
-            {
95
-                List<string> UTF8ValueList = new List<string>();
96
-                foreach (string val in value)
97
-                {
98
-                    string path = val.Substring(0, val.LastIndexOf("/") + 1);
99
-                    string name = val.Substring(val.LastIndexOf("/") + 1);
100
-                    string UTF8Name = System.Web.HttpUtility.UrlEncode(name);
101
-                    string UTF8Url = path + UTF8Name;
102
-                    UTF8ValueList.Add(UTF8Url);
103
-                    _downloadUrlList = UTF8ValueList;
104
-                }
105
-                ;
106
-            }
107
-        }
108
-        /// <summary>
109
-        /// 是否支持断点续传
110
-        /// 在任务开始后,如果需要暂停,应先通过这个判断是否支持
111
-        /// 默认设为false
112
-        /// </summary>
113
-        private bool _IsSupportMultiThreading = false;
114
-        /// <summary>
115
-        /// 是否支持断点续传
116
-        /// 在任务开始后,如果需要暂停,应先通过这个判断是否支持
117
-        /// 默认设为false
118
-        /// </summary>
119
-        public bool IsSupportMultiThreading
120
-        {
121
-            get => _IsSupportMultiThreading;
122
-            set => _IsSupportMultiThreading = value;
123
-        }
124
-        /// <summary>
125
-        /// 线程任务列表
126
-        /// </summary>
127
-        public List<TaskInfoModel> TaskInfoList { get; set; }
128
-        /// <summary>
129
-        /// 保存文件名
130
-        /// </summary>
131
-        public string saveFileName { get; set; }
132
-    }
133
-
134
-    /// <summary>
135
-    /// 任务模型
136
-    /// </summary>
137
-    public class TaskInfoModel
138
-    {
139
-        /// <summary>
140
-        /// 请求方法
141
-        /// </summary>
142
-        public string method { get; set; }
143
-        public string downloadUrl { get; set; }
144
-        public string filePath { get; set; }
145
-        /// <summary>
146
-        /// 分片起点
147
-        /// </summary>
148
-        public long fromIndex { get; set; }
149
-        /// <summary>
150
-        /// 分片终点
151
-        /// </summary>
152
-        public long toIndex { get; set; }
153
-        /// <summary>
154
-        /// 分片的总大小
155
-        /// </summary>
156
-        public long count => toIndex - fromIndex + 1;
157
-    }
158
-
159
-    /// <summary>
160
-    /// 解压书模型
161
-    /// </summary>
162
-    public class BookDecompressionModel
163
-    {
164
-        /// <summary>
165
-        /// 书的文件名
166
-        /// </summary>
167
-        public string BookFileName { get; set; }
168
-
169
-        /// <summary>
170
-        /// 解压书籍的控件
171
-        /// </summary>
172
-        public object UcBookCover { get; set; }
173
-    }
174
-}

+ 0
- 39
Common/Properties/AssemblyInfo.cs Datei anzeigen

@@ -1,39 +0,0 @@
1
-using System.Reflection;
2
-using System.Runtime.InteropServices;
3
-
4
-// 有关程序集的一般信息由以下
5
-// 控制。更改这些特性值可修改
6
-// 与程序集关联的信息。
7
-[assembly: AssemblyTitle("Common")]
8
-[assembly: AssemblyDescription("")]
9
-[assembly: AssemblyConfiguration("")]
10
-[assembly: AssemblyCompany("")]
11
-[assembly: AssemblyProduct("Common")]
12
-[assembly: AssemblyCopyright("Copyright ©  2020")]
13
-[assembly: AssemblyTrademark("")]
14
-[assembly: AssemblyCulture("")]
15
-
16
-// 将 ComVisible 设置为 false 会使此程序集中的类型
17
-//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
18
-//请将此类型的 ComVisible 特性设置为 true。
19
-[assembly: ComVisible(false)]
20
-
21
-// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
22
-[assembly: Guid("808a7075-5af5-46b3-8ef6-514c0b5fa8d7")]
23
-
24
-// 程序集的版本信息由下列四个值组成: 
25
-//
26
-//      主版本
27
-//      次版本
28
-//      生成号
29
-//      修订号
30
-//
31
-//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
32
-//通过使用 "*",如下所示:
33
-// [assembly: AssemblyVersion("1.0.*")]
34
-[assembly: AssemblyVersion("1.0.0.0")]
35
-[assembly: AssemblyFileVersion("1.0.0.0")]
36
-
37
-//Log4Net
38
-//[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
39
-[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", ConfigFileExtension = "config", Watch = true)]

+ 0
- 94
Common/ZB/ClippingBorder.cs Datei anzeigen

@@ -1,94 +0,0 @@
1
-using System;
2
-using System.Windows;
3
-using System.Windows.Controls;
4
-using System.Windows.Media;
5
-
6
-namespace Common.ZB
7
-{
8
-    public class ClippingBorder : Border
9
-    {
10
-        private object _oldClip;
11
-
12
-        protected override void OnRender(DrawingContext dc)
13
-        {
14
-            OnApplyChildClip();
15
-            base.OnRender(dc);
16
-        }
17
-
18
-        public override UIElement Child
19
-        {
20
-            get => base.Child;
21
-            set
22
-            {
23
-                if (Child != value)
24
-                {
25
-                    if (Child != null)
26
-                    {
27
-                        Child.SetValue(ClipProperty, _oldClip);
28
-                    }
29
-
30
-                    if (value != null)
31
-                    {
32
-                        _oldClip = value.ReadLocalValue(ClipProperty);
33
-                    }
34
-                    else
35
-                    {
36
-                        // If we dont set it to null we could leak a Geometry object
37
-                        _oldClip = null;
38
-                    }
39
-
40
-                    base.Child = value;
41
-                }
42
-            }
43
-        }
44
-
45
-        protected virtual void OnApplyChildClip()
46
-        {
47
-            UIElement child = Child;
48
-            if (child != null)
49
-            {
50
-                double top = Math.Max(CornerRadius.TopLeft, CornerRadius.TopRight);
51
-                double bottom = Math.Max(CornerRadius.BottomLeft, CornerRadius.BottomRight);
52
-                double max = Math.Max(top, bottom);
53
-                Size size = RenderSize;
54
-                double width = size.Width - (BorderThickness.Left + BorderThickness.Right);
55
-                double height = size.Height - (BorderThickness.Top + BorderThickness.Bottom);
56
-                Geometry result = new RectangleGeometry(new Rect(0, 0, width, height), max, max);
57
-                double halfWidth = width / 2;
58
-                double halfHeight = height / 2;
59
-
60
-                if (CornerRadius.TopLeft == 0)
61
-                {
62
-                    result = new CombinedGeometry(
63
-                        GeometryCombineMode.Union,
64
-                        result,
65
-                        new RectangleGeometry(new Rect(0, 0, halfWidth, halfHeight))
66
-                    );
67
-                }
68
-
69
-                if (CornerRadius.TopRight == 0)
70
-                {
71
-                    result = new CombinedGeometry(GeometryCombineMode.Union, result, new RectangleGeometry
72
-                (new Rect(halfWidth, 0, halfWidth, halfHeight)));
73
-                }
74
-
75
-                if (CornerRadius.BottomLeft == 0)
76
-                {
77
-                    result = new CombinedGeometry
78
-                  (GeometryCombineMode.Union, result, new RectangleGeometry
79
-                  (new Rect(0, halfHeight, halfWidth, halfHeight)));
80
-                }
81
-                if (CornerRadius.BottomRight == 0)
82
-                {
83
-                    result = new CombinedGeometry
84
-                  (
85
-                GeometryCombineMode.Union,
86
-                result,
87
-                new RectangleGeometry(new Rect(halfWidth, halfHeight, halfWidth, halfHeight))
88
-                );
89
-                }
90
-                child.Clip = result;
91
-            }
92
-        }
93
-    }
94
-}

BIN
Common/dlls/CheckPoint.dll Datei anzeigen


BIN
Common/dlls/ICSharpCode.SharpZipLib.dll Datei anzeigen


BIN
Common/dlls/NPOI.OOXML.dll Datei anzeigen


BIN
Common/dlls/NPOI.OpenXml4Net.dll Datei anzeigen


BIN
Common/dlls/NPOI.OpenXmlFormats.dll Datei anzeigen


BIN
Common/dlls/NPOI.dll Datei anzeigen


BIN
Common/dlls/Newtonsoft.Json.dll Datei anzeigen


+ 0
- 9144
Common/dlls/Newtonsoft.Json.xml
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


BIN
Common/dlls/RbtBezier.dll Datei anzeigen


BIN
Common/dlls/RobotDotMatrix.dll Datei anzeigen


BIN
Common/dlls/RobotUsbWrapper.dll Datei anzeigen


BIN
Common/dlls/RobotpenGateway.dll Datei anzeigen


BIN
Common/dlls/SonixUSB.dll Datei anzeigen


BIN
Common/dlls/System.Data.SQLite.dll Datei anzeigen


BIN
Common/dlls/TQLComm.dll Datei anzeigen


BIN
Common/dlls/TStudy.DigitalPen.dll Datei anzeigen


BIN
Common/dlls/TStudyDigitalPen.dll Datei anzeigen


BIN
Common/dlls/TStudyDigitalPenInter.dll Datei anzeigen


BIN
Common/dlls/TStudyDigitalPenLic.dll Datei anzeigen


BIN
Common/dlls/ZYD_SDK_USB.dll Datei anzeigen


BIN
Common/dlls/log4net.dll Datei anzeigen


+ 0
- 31814
Common/dlls/log4net.xml
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 0
- 52
Common/log4net.config Datei anzeigen

@@ -1,52 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8" ?>
2
-  <log4net>
3
-    <!--错误日志类-->
4
-    <logger name="logerror">
5
-      <!--日志类的名字-->
6
-      <level value="ALL" />
7
-      <!--定义记录的日志级别-->
8
-      <appender-ref ref="ErrorAppender" />
9
-      <!--记录到哪个介质中去-->
10
-    </logger>
11
-    <!--信息日志类-->
12
-    <logger name="loginfo">
13
-      <level value="ALL" />
14
-      <appender-ref ref="InfoAppender" />
15
-    </logger>
16
-    <!--错误日志附加介质-->
17
-    <appender name="ErrorAppender" type="log4net.Appender.RollingFileAppender">
18
-      <!-- name属性指定其名称,type则是log4net.Appender命名空间的一个类的名称,意思是,指定使用哪种介质-->
19
-      <param name="File" value="Log\\LogError\\" />
20
-      <!--日志输出到exe程序这个相对目录下-->
21
-      <param name="AppendToFile" value="true" />
22
-      <!--输出的日志不会覆盖以前的信息-->
23
-      <param name="MaxSizeRollBackups" value="100" />
24
-      <!--备份文件的个数-->
25
-      <param name="MaxFileSize" value="10240" />
26
-      <!--当个日志文件的最大大小-->
27
-      <param name="StaticLogFileName" value="false" />
28
-      <!--是否使用静态文件名-->
29
-      <param name="DatePattern" value="yyyyMMdd&quot;.htm&quot;" />
30
-      <!--日志文件名-->
31
-      <param name="RollingStyle" value="Date" />
32
-      <!--文件创建的方式,这里是以Date方式创建-->
33
-      <!--错误日志布局-->
34
-      <layout type="log4net.Layout.PatternLayout">
35
-        <param name="ConversionPattern" value="&lt;HR COLOR=red&gt;%n异常时间:%d [%t] &lt;BR&gt;%n异常级别:%-5p &lt;BR&gt;%n异 常 类:%c [%x] &lt;BR&gt;%n%m &lt;BR&gt;%n &lt;HR Size=1&gt;"  />
36
-      </layout>
37
-    </appender>
38
-    <!--信息日志附加介质-->
39
-    <appender name="InfoAppender" type="log4net.Appender.RollingFileAppender">
40
-      <param name="File" value="Log\\LogInfo\\" />
41
-      <param name="AppendToFile" value="true" />
42
-      <param name="MaxFileSize" value="10240" />
43
-      <param name="MaxSizeRollBackups" value="100" />
44
-      <param name="StaticLogFileName" value="false" />
45
-      <param name="DatePattern" value="yyyyMMdd&quot;.htm&quot;" />
46
-      <param name="RollingStyle" value="Date" />
47
-      <!--信息日志布局-->
48
-      <layout type="log4net.Layout.PatternLayout">
49
-        <param name="ConversionPattern" value="&lt;HR COLOR=blue&gt;%n日志时间:%d [%t] &lt;BR&gt;%n日志级别:%-5p &lt;BR&gt;%n日 志 类:%c [%x] &lt;BR&gt;%n%m &lt;BR&gt;%n &lt;HR Size=1&gt;"  />
50
-      </layout>
51
-    </appender>
52
-  </log4net>

+ 0
- 10
Common/packages.config Datei anzeigen

@@ -1,10 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<packages>
3
-  <package id="AForge" version="2.2.5" targetFramework="net452" />
4
-  <package id="AForge.Controls" version="2.2.5" targetFramework="net452" />
5
-  <package id="AForge.Imaging" version="2.2.5" targetFramework="net452" />
6
-  <package id="AForge.Math" version="2.2.5" targetFramework="net452" />
7
-  <package id="AForge.Video" version="2.2.5" targetFramework="net452" />
8
-  <package id="AForge.Video.DirectShow" version="2.2.5" targetFramework="net452" />
9
-  <package id="VisioForge.DotNet.Core.TRIAL" version="12.0.56" targetFramework="net452" />
10
-</packages>

+ 0
- 114
Common/system/BackgroundWorkerHelper.cs Datei anzeigen

@@ -1,114 +0,0 @@
1
-using System;
2
-using System.ComponentModel;
3
-using System.Threading;
4
-
5
-namespace Common.system
6
-{
7
-    /// <summary>
8
-    /// 后台线程帮助类
9
-    /// </summary>
10
-    public class BackgroundWorkerHelper : IDisposable
11
-    {
12
-        private static BackgroundWorkerHelper backgroundWorkerHelper = null;
13
-
14
-        public static BackgroundWorkerHelper GetInstance()
15
-        {
16
-            if (backgroundWorkerHelper == null)
17
-            {
18
-                backgroundWorkerHelper = new BackgroundWorkerHelper();
19
-            }
20
-            return backgroundWorkerHelper;
21
-        }
22
-
23
-        private BackgroundWorker backWorker = null;
24
-        private Func<object> func = null;
25
-        private Action<object> actionComplate = null;
26
-
27
-        public BackgroundWorkerHelper()
28
-        {
29
-            backWorker = new BackgroundWorker();
30
-            backWorker.DoWork += new DoWorkEventHandler(backWorker_DoWork);
31
-            backWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backWorker_RunWorkerCompleted);
32
-        }
33
-
34
-        private void backWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
35
-        {
36
-            currentThread = null;
37
-
38
-            if (e.Error != null)
39
-            {
40
-                throw e.Error;
41
-            }
42
-            if (actionComplate != null)
43
-            {
44
-                actionComplate(e.Result);
45
-            }
46
-        }
47
-
48
-        private void backWorker_DoWork(object sender, DoWorkEventArgs e)
49
-        {
50
-            currentThread = Thread.CurrentThread;
51
-
52
-            if (func != null)
53
-            {
54
-                if (func != null)
55
-                {
56
-                    e.Result = func();
57
-                }
58
-            }
59
-        }
60
-
61
-        /// <summary>
62
-        /// 启动异步线程
63
-        /// </summary>
64
-        /// <param name="func">在异步执行的方法</param>
65
-        /// <param name="action">方法完成后</param>
66
-        public void RunWorkerAsync(Func<object> func, Action<object> action)
67
-        {
68
-            if (!backWorker.IsBusy)
69
-            {
70
-                this.func = func;
71
-                actionComplate = action;
72
-                backWorker.RunWorkerAsync();
73
-            }
74
-        }
75
-
76
-        private Thread currentThread = null;
77
-
78
-        /// <summary>
79
-        /// 强制中断
80
-        /// </summary>
81
-        public void Abort()
82
-        {
83
-            if (currentThread != null && backWorker.IsBusy)
84
-            {
85
-                currentThread.Abort();
86
-                currentThread = null;
87
-
88
-                backWorker.DoWork -= backWorker_DoWork;
89
-                backWorker.RunWorkerCompleted -= backWorker_RunWorkerCompleted;
90
-                backWorker.Dispose();
91
-
92
-                backWorker = new BackgroundWorker();
93
-                backWorker.DoWork += backWorker_DoWork;
94
-                backWorker.RunWorkerCompleted += backWorker_RunWorkerCompleted;
95
-                func = null;
96
-                actionComplate = null;
97
-            }
98
-        }
99
-
100
-        #region IDisposable 成员
101
-
102
-        /// <summary>
103
-        /// 释放资源
104
-        /// </summary>
105
-        public void Dispose()
106
-        {
107
-            actionComplate = null;
108
-            func = null;
109
-            backWorker.Dispose();
110
-        }
111
-
112
-        #endregion IDisposable 成员
113
-    }
114
-}

+ 0
- 304
Common/system/BlackboardNew.cs Datei anzeigen

@@ -1,304 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Windows;
5
-using System.Windows.Controls;
6
-using System.Windows.Ink;
7
-using System.Windows.Input;
8
-using System.Windows.Media;
9
-
10
-namespace Common.system
11
-{
12
-    internal enum ZPenType : byte
13
-    {
14
-        Pen = 1,
15
-        Erase = 2
16
-    };
17
-
18
-    internal class ZBBPage
19
-    {
20
-        public List<ZBBPageStep> lines { get; set; }
21
-        public List<ZBBPageStep> lines_histoty { get; set; }
22
-
23
-        public ZBBPage()
24
-        {
25
-            lines = new List<ZBBPageStep>();
26
-            lines_histoty = new List<ZBBPageStep>();
27
-        }
28
-    }
29
-
30
-    internal class ZBBPageStep
31
-    {
32
-        public StrokeCollection lines_curr { get; set; }
33
-        public StrokeCollection lines_add { get; set; }
34
-        public StrokeCollection lines_remove { get; set; }
35
-
36
-        public ZBBPageStep()
37
-        {
38
-            lines_curr = new StrokeCollection();
39
-            lines_add = new StrokeCollection();
40
-            lines_remove = new StrokeCollection();
41
-        }
42
-    }
43
-
44
-    public class ZJBlackboardNew
45
-    {
46
-        private InkCanvas m_canvas;
47
-
48
-        //private ZPenType type = ZPenType.Pen;
49
-        private int pagenum = 0;
50
-
51
-        private readonly int erasesize = 64;
52
-        private readonly int pensize = 3;
53
-        private int undoOrRedo = 0; //是否在进行撤销恢复操作
54
-        private Color pencolor;
55
-
56
-        private readonly List<ZBBPage> strokes_page_all = new List<ZBBPage>();
57
-
58
-        // 添加这个变量是因为在用橡皮擦时 一次操作会触发多次StrokesChanged回掉 这里是把多次回掉合并在一起
59
-        private ZBBPageStep step = null;
60
-
61
-        public ZJBlackboardNew(InkCanvas canvas)
62
-        {
63
-            init(canvas, Colors.White);
64
-        }
65
-
66
-        public ZJBlackboardNew(InkCanvas canvas, Color _pencolor)
67
-        {
68
-            init(canvas, _pencolor);
69
-        }
70
-
71
-        private void init(InkCanvas canvas, Color _pencolor)
72
-        {
73
-            m_canvas = canvas;
74
-            pencolor = _pencolor;
75
-            ZBBPage page = new ZBBPage();
76
-            page.lines.Add(new ZBBPageStep());
77
-            strokes_page_all.Add(page);
78
-            if (canvas != null)
79
-            {
80
-                canvas.EditingMode = InkCanvasEditingMode.Ink;
81
-                canvas.UseCustomCursor = true;
82
-                canvas.Cursor = Cursors.Pen;
83
-                DrawingAttributes drawingAttributes = new DrawingAttributes();
84
-                canvas.DefaultDrawingAttributes = drawingAttributes;
85
-                drawingAttributes.Width = pensize;
86
-                drawingAttributes.Height = pensize;
87
-                drawingAttributes.Color = pencolor;
88
-                drawingAttributes.FitToCurve = true;
89
-                drawingAttributes.IgnorePressure = false;
90
-                canvas.Strokes.StrokesChanged += Strokes_StrokesChanged;
91
-                canvas.StrokeCollected += Canvas_StrokeCollected;
92
-                canvas.StrokeErasing += Canvas_StrokeErasing;
93
-                canvas.StrokeErased += Canvas_StrokeErased;
94
-                canvas.MouseUp += Canvas_MouseUp;
95
-            }
96
-        }
97
-
98
-        private void Canvas_StrokeErasing(object sender, InkCanvasStrokeErasingEventArgs e)
99
-        {
100
-            undoOrRedo = 0;
101
-        }
102
-
103
-        private void Canvas_StrokeErased(object sender, RoutedEventArgs e)
104
-        {
105
-        }
106
-
107
-        private void Canvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
108
-        {
109
-        }
110
-
111
-        private void Canvas_MouseUp(object sender, MouseButtonEventArgs e)
112
-        {
113
-            if (step != null)
114
-            {
115
-                ZBBPage page = strokes_page_all[pagenum];
116
-                if (page != null)
117
-                {
118
-                    step.lines_curr.Add(m_canvas.Strokes);
119
-                    page.lines.Add(step);
120
-                    step = null;
121
-                }
122
-            }
123
-        }
124
-
125
-        private void Strokes_StrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
126
-        {
127
-            if (undoOrRedo > 0)
128
-            {
129
-                undoOrRedo -= 1;
130
-                return;
131
-            }
132
-
133
-            if (step == null)
134
-            {
135
-                step = new ZBBPageStep();
136
-            }
137
-
138
-            // 笔模式
139
-            if (e.Added.Count > 0 && e.Removed.Count == 0)
140
-            {
141
-                step.lines_add.Add(e.Added);
142
-            }
143
-            // 橡皮模式 会多次进入回掉
144
-            else if (e.Removed.Count > 0)
145
-            {
146
-                step.lines_add.Add(e.Added);
147
-                for (int i = 0; i < e.Removed.Count; i++)
148
-                {
149
-                    Stroke removeItem = e.Removed[i];
150
-                    try
151
-                    {
152
-                        if (step.lines_add.Contains(removeItem))
153
-                        {
154
-                            step.lines_add.Remove(removeItem);
155
-                        }
156
-                        else
157
-                        {
158
-                            step.lines_remove.Add(removeItem);
159
-                        }
160
-                    }
161
-                    catch (System.Exception ex)
162
-                    {
163
-
164
-                        LogHelper.WriteErrLog("【笔迹添加移除事件】(Strokes_StrokesChanged)" + ex.Message, ex);
165
-                    }
166
-                }
167
-            }
168
-        }
169
-
170
-        // public方法 笔
171
-        public void change_pen(Color _color, int _size)
172
-        {
173
-            //this.type = ZPenType.Pen;
174
-            DrawingAttributes drawingAttributes = new DrawingAttributes();
175
-            m_canvas.DefaultDrawingAttributes = drawingAttributes;
176
-            drawingAttributes.Color = _color;
177
-            drawingAttributes.Width = _size;
178
-            drawingAttributes.Height = _size;
179
-            drawingAttributes.FitToCurve = true;
180
-            drawingAttributes.IgnorePressure = false;
181
-            m_canvas.EditingMode = InkCanvasEditingMode.Ink;
182
-            m_canvas.UseCustomCursor = true;
183
-            m_canvas.Cursor = Cursors.Pen;
184
-        }
185
-
186
-        // 橡皮
187
-        public void change_erase()
188
-        {
189
-            //this.type = ZPenType.Erase;
190
-            m_canvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
191
-            m_canvas.UseCustomCursor = false;
192
-            m_canvas.EraserShape = new EllipseStylusShape(erasesize, erasesize, 0);
193
-        }
194
-
195
-        // 撤销
196
-        public void undo()
197
-        {
198
-            ZBBPage page = strokes_page_all[pagenum];
199
-
200
-            if (page != null && m_canvas.Strokes.Count > 0 && page.lines.Count > 1)
201
-            {
202
-                ZBBPageStep last = page.lines.Last();
203
-                page.lines.Remove(last);
204
-                page.lines_histoty.Add(last);
205
-                if (page.lines.Last().lines_curr.Count > 0)
206
-                {
207
-                    undoOrRedo = 2;
208
-                }
209
-                else
210
-                {
211
-                    undoOrRedo = 1;
212
-                }
213
-
214
-                m_canvas.Strokes.Clear();
215
-                m_canvas.Strokes.Add(page.lines.Last().lines_curr);
216
-            }
217
-        }
218
-
219
-        // 恢复
220
-        public void redo()
221
-        {
222
-            ZBBPage page = strokes_page_all[pagenum];
223
-            if (page != null && page.lines_histoty.Count > 0)
224
-            {
225
-                ZBBPageStep line = page.lines_histoty[page.lines_histoty.Count - 1];
226
-
227
-                page.lines.Add(line);
228
-                page.lines_histoty.Remove(line);
229
-                if (page.lines.Last().lines_curr.Count > 0)
230
-                {
231
-                    undoOrRedo = 2;
232
-                }
233
-                else
234
-                {
235
-                    undoOrRedo = 1;
236
-                }
237
-                m_canvas.Strokes.Clear();
238
-                m_canvas.Strokes.Add(page.lines.Last().lines_curr);
239
-            }
240
-        }
241
-
242
-        // 清空
243
-        public void clear()
244
-        {
245
-            ZBBPage page = strokes_page_all[pagenum];
246
-            int num = page.lines.Count;
247
-            for (int i = 0; i < num; i++)
248
-            {
249
-                page = strokes_page_all[pagenum];
250
-                if (page != null && m_canvas.Strokes.Count > 0 && page.lines.Count > 1)
251
-                {
252
-                    ZBBPageStep last = page.lines.Last();
253
-                    page.lines.Remove(last);
254
-                    page.lines_histoty.Add(last);
255
-                    if (page.lines.Last().lines_curr.Count > 0)
256
-                    {
257
-                        undoOrRedo = 2;
258
-                    }
259
-                    else
260
-                    {
261
-                        undoOrRedo = 1;
262
-                    }
263
-
264
-                    m_canvas.Strokes.Clear();
265
-                    m_canvas.Strokes.Add(page.lines.Last().lines_curr);
266
-                }
267
-            }
268
-        }
269
-
270
-        public void changepage(int mpagenum)
271
-        {
272
-            if (pagenum != mpagenum)
273
-            {
274
-                pagenum = mpagenum;
275
-                if (pagenum >= strokes_page_all.Count)
276
-                {
277
-                    int numadd = pagenum - strokes_page_all.Count + 1;
278
-                    for (int i = 0; i < numadd; i++)
279
-                    {
280
-                        ZBBPage pagetemp = new ZBBPage();
281
-                        pagetemp.lines.Add(new ZBBPageStep());
282
-                        strokes_page_all.Add(pagetemp);
283
-                    }
284
-                }
285
-
286
-                ZBBPage page = strokes_page_all[pagenum];
287
-                if (page != null)
288
-                {
289
-                    if (page.lines.Last().lines_curr.Count > 0)
290
-                    {
291
-                        undoOrRedo += 1;
292
-                    }
293
-                    if (m_canvas.Strokes.Count > 0)
294
-                    {
295
-                        undoOrRedo += 1;
296
-                        m_canvas.Strokes.Clear();
297
-                    }
298
-
299
-                    m_canvas.Strokes.Add(page.lines.Last().lines_curr);
300
-                }
301
-            }
302
-        }
303
-    }
304
-}

+ 0
- 701
Common/system/CLeopardZip.cs Datei anzeigen

@@ -1,701 +0,0 @@
1
-using ICSharpCode.SharpZipLib.Checksums;
2
-using ICSharpCode.SharpZipLib.Zip;
3
-
4
-using System;
5
-using System.Collections.Generic;
6
-using System.IO;
7
-
8
-namespace Common.system
9
-{
10
-    /// <summary>   
11
-    /// 适用与ZIP压缩   
12
-    /// </summary>   
13
-    public class ZipHelper
14
-    {
15
-        #region 压缩
16
-
17
-        /// <summary>   
18
-        /// 递归压缩文件夹的内部方法   
19
-        /// </summary>   
20
-        /// <param name="folderToZip">要压缩的文件夹路径</param>   
21
-        /// <param name="zipStream">压缩输出流</param>   
22
-        /// <param name="parentFolderName">此文件夹的上级文件夹</param>   
23
-        /// <returns></returns>   
24
-        private static bool ZipDirectory(string folderToZip, ZipOutputStream zipStream, string parentFolderName)
25
-        {
26
-            bool result = true;
27
-            string[] folders, files;
28
-            ZipEntry ent = null;
29
-            FileStream fs = null;
30
-            Crc32 crc = new Crc32();
31
-
32
-            try
33
-            {
34
-                ent = new ZipEntry(Path.Combine(parentFolderName, Path.GetFileName(folderToZip) + "/"));
35
-                zipStream.PutNextEntry(ent);
36
-                zipStream.Flush();
37
-
38
-                files = Directory.GetFiles(folderToZip);
39
-                foreach (string file in files)
40
-                {
41
-                    fs = File.OpenRead(file);
42
-
43
-                    byte[] buffer = new byte[fs.Length];
44
-                    fs.Read(buffer, 0, buffer.Length);
45
-                    ent = new ZipEntry(Path.Combine(parentFolderName, Path.GetFileName(folderToZip) + "/" + Path.GetFileName(file)))
46
-                    {
47
-                        DateTime = DateTime.Now,
48
-                        Size = fs.Length
49
-                    };
50
-
51
-                    fs.Close();
52
-
53
-                    crc.Reset();
54
-                    crc.Update(buffer);
55
-
56
-                    ent.Crc = crc.Value;
57
-                    zipStream.PutNextEntry(ent);
58
-                    zipStream.Write(buffer, 0, buffer.Length);
59
-                }
60
-
61
-            }
62
-            catch
63
-            {
64
-                result = false;
65
-            }
66
-            finally
67
-            {
68
-                if (fs != null)
69
-                {
70
-                    fs.Close();
71
-                    fs.Dispose();
72
-                }
73
-                if (ent != null)
74
-                {
75
-                    ent = null;
76
-                }
77
-                GC.Collect();
78
-                GC.Collect(1);
79
-            }
80
-
81
-            folders = Directory.GetDirectories(folderToZip);
82
-            foreach (string folder in folders)
83
-            {
84
-                if (!ZipDirectory(folder, zipStream, folderToZip))
85
-                {
86
-                    return false;
87
-                }
88
-            }
89
-
90
-            return result;
91
-        }
92
-
93
-        /// <summary>   
94
-        /// 压缩文件夹    
95
-        /// </summary>   
96
-        /// <param name="folderToZip">要压缩的文件夹路径</param>   
97
-        /// <param name="zipedFile">压缩文件完整路径</param>   
98
-        /// <param name="password">密码</param>   
99
-        /// <returns>是否压缩成功</returns>   
100
-        public static bool ZipDirectory(string folderToZip, string zipedFile, string password)
101
-        {
102
-            bool result = false;
103
-            if (!Directory.Exists(folderToZip))
104
-            {
105
-                return result;
106
-            }
107
-
108
-            ZipOutputStream zipStream = new ZipOutputStream(File.Create(zipedFile));
109
-            zipStream.SetLevel(6);
110
-            if (!string.IsNullOrEmpty(password))
111
-            {
112
-                zipStream.Password = password;
113
-            }
114
-
115
-            result = ZipDirectory(folderToZip, zipStream, "");
116
-
117
-            zipStream.Finish();
118
-            zipStream.Close();
119
-
120
-            return result;
121
-        }
122
-
123
-        /// <summary>   
124
-        /// 压缩文件夹   
125
-        /// </summary>   
126
-        /// <param name="folderToZip">要压缩的文件夹路径</param>   
127
-        /// <param name="zipedFile">压缩文件完整路径</param>   
128
-        /// <returns>是否压缩成功</returns>   
129
-        public static bool ZipDirectory(string folderToZip, string zipedFile)
130
-        {
131
-            bool result = ZipDirectory(folderToZip, zipedFile, null);
132
-            return result;
133
-        }
134
-
135
-        /// <summary>   
136
-        /// 压缩文件   
137
-        /// </summary>   
138
-        /// <param name="fileToZip">要压缩的文件全名</param>   
139
-        /// <param name="zipedFile">压缩后的文件名</param>   
140
-        /// <param name="password">密码</param>   
141
-        /// <returns>压缩结果</returns>   
142
-        public static bool ZipFile(string fileToZip, string zipedFile, string password)
143
-        {
144
-            bool result = true;
145
-            ZipOutputStream zipStream = null;
146
-            FileStream fs = null;
147
-            ZipEntry ent = null;
148
-
149
-            if (!File.Exists(fileToZip))
150
-            {
151
-                return false;
152
-            }
153
-
154
-            try
155
-            {
156
-                fs = File.OpenRead(fileToZip);
157
-                byte[] buffer = new byte[fs.Length];
158
-                fs.Read(buffer, 0, buffer.Length);
159
-                fs.Close();
160
-
161
-                fs = File.Create(zipedFile);
162
-                zipStream = new ZipOutputStream(fs);
163
-                if (!string.IsNullOrEmpty(password))
164
-                {
165
-                    zipStream.Password = password;
166
-                }
167
-
168
-                ent = new ZipEntry(Path.GetFileName(fileToZip));
169
-                zipStream.PutNextEntry(ent);
170
-                zipStream.SetLevel(6);
171
-
172
-                zipStream.Write(buffer, 0, buffer.Length);
173
-
174
-            }
175
-            catch
176
-            {
177
-                result = false;
178
-            }
179
-            finally
180
-            {
181
-                if (zipStream != null)
182
-                {
183
-                    zipStream.Finish();
184
-                    zipStream.Close();
185
-                }
186
-                if (ent != null)
187
-                {
188
-                    ent = null;
189
-                }
190
-                if (fs != null)
191
-                {
192
-                    fs.Close();
193
-                    fs.Dispose();
194
-                }
195
-            }
196
-            GC.Collect();
197
-            GC.Collect(1);
198
-
199
-            return result;
200
-        }
201
-
202
-        /// <summary>   
203
-        /// 压缩文件   
204
-        /// </summary>   
205
-        /// <param name="fileToZip">要压缩的文件全名</param>   
206
-        /// <param name="zipedFile">压缩后的文件名</param>   
207
-        /// <returns>压缩结果</returns>   
208
-        public static bool ZipFile(string fileToZip, string zipedFile)
209
-        {
210
-            bool result = ZipFile(fileToZip, zipedFile, null);
211
-            return result;
212
-        }
213
-
214
-        /// <summary>   
215
-        /// 压缩文件或文件夹   
216
-        /// </summary>   
217
-        /// <param name="fileToZip">要压缩的路径</param>   
218
-        /// <param name="zipedFile">压缩后的文件名</param>   
219
-        /// <param name="password">密码</param>   
220
-        /// <returns>压缩结果</returns>   
221
-        public static bool Zip(string fileToZip, string zipedFile, string password)
222
-        {
223
-            bool result = false;
224
-            if (Directory.Exists(fileToZip))
225
-            {
226
-                result = ZipDirectory(fileToZip, zipedFile, password);
227
-            }
228
-            else if (File.Exists(fileToZip))
229
-            {
230
-                result = ZipFile(fileToZip, zipedFile, password);
231
-            }
232
-
233
-            return result;
234
-        }
235
-
236
-        /// <summary>   
237
-        /// 压缩文件或文件夹   
238
-        /// </summary>   
239
-        /// <param name="fileToZip">要压缩的路径</param>   
240
-        /// <param name="zipedFile">压缩后的文件名</param>   
241
-        /// <returns>压缩结果</returns>   
242
-        public static bool Zip(string fileToZip, string zipedFile)
243
-        {
244
-            bool result = Zip(fileToZip, zipedFile, null);
245
-            return result;
246
-
247
-        }
248
-
249
-        #endregion
250
-
251
-        #region 解压
252
-
253
-        /// <summary>   
254
-        /// 解压功能(解压压缩文件到指定目录)   
255
-        /// </summary>   
256
-        /// <param name="fileToUnZip">待解压的文件</param>   
257
-        /// <param name="zipedFolder">指定解压目标目录</param>   
258
-        /// <param name="password">密码</param>   
259
-        /// <returns>解压结果</returns>   
260
-        public static bool UnZip(string fileToUnZip, string zipedFolder, string password)
261
-        {
262
-            bool result = true;
263
-            FileStream fs = null;
264
-            ZipInputStream zipStream = null;
265
-            ZipEntry ent = null;
266
-            string fileName;
267
-
268
-            if (!File.Exists(fileToUnZip))
269
-            {
270
-                return false;
271
-            }
272
-
273
-            if (!Directory.Exists(zipedFolder))
274
-            {
275
-                Directory.CreateDirectory(zipedFolder);
276
-            }
277
-
278
-            try
279
-            {
280
-                zipStream = new ZipInputStream(File.OpenRead(fileToUnZip));
281
-                if (!string.IsNullOrEmpty(password))
282
-                {
283
-                    zipStream.Password = password;
284
-                }
285
-
286
-                while ((ent = zipStream.GetNextEntry()) != null)
287
-                {
288
-                    if (!string.IsNullOrEmpty(ent.Name))
289
-                    {
290
-                        fileName = Path.Combine(zipedFolder, ent.Name);
291
-                        fileName = fileName.Replace('/', '\\');//change by Mr.HopeGi   
292
-
293
-                        if (fileName.EndsWith("\\"))
294
-                        {
295
-                            Directory.CreateDirectory(fileName);
296
-                            continue;
297
-                        }
298
-
299
-                        fs = File.Create(fileName);
300
-                        int size = 2048;
301
-                        byte[] data = new byte[size];
302
-                        while (true)
303
-                        {
304
-                            size = zipStream.Read(data, 0, data.Length);
305
-                            if (size > 0)
306
-                            {
307
-                                fs.Write(data, 0, data.Length);
308
-                            }
309
-                            else
310
-                            {
311
-                                break;
312
-                            }
313
-                        }
314
-                    }
315
-                }
316
-            }
317
-            catch
318
-            {
319
-                result = false;
320
-            }
321
-            finally
322
-            {
323
-                if (fs != null)
324
-                {
325
-                    fs.Close();
326
-                    fs.Dispose();
327
-                }
328
-                if (zipStream != null)
329
-                {
330
-                    zipStream.Close();
331
-                    zipStream.Dispose();
332
-                }
333
-                if (ent != null)
334
-                {
335
-                    ent = null;
336
-                }
337
-                GC.Collect();
338
-                GC.Collect(1);
339
-            }
340
-            return result;
341
-        }
342
-
343
-        /// <summary>   
344
-        /// 解压功能(解压压缩文件到指定目录)   
345
-        /// </summary>   
346
-        /// <param name="fileToUnZip">待解压的文件</param>   
347
-        /// <param name="zipedFolder">指定解压目标目录</param>   
348
-        /// <returns>解压结果</returns>   
349
-        public static bool UnZip(string fileToUnZip, string zipedFolder)
350
-        {
351
-            bool result = NewUnZip(fileToUnZip, zipedFolder, null, true);
352
-            return result;
353
-        }
354
-
355
-        /// <summary>
356
-        /// ZIP:解压一个zip文件
357
-        /// </summary>
358
-        /// <param name="ZipFile">需要解压的Zip文件(绝对路径)</param>
359
-        /// <param name="TargetDirectory">解压到的目录</param>
360
-        /// <param name="Password">解压密码</param>
361
-        /// <param name="OverWrite">是否覆盖已存在的文件</param>
362
-        public static bool NewUnZip(string ZipFile, string TargetDirectory, string Password, bool OverWrite = true)
363
-        {
364
-            try
365
-            {
366
-
367
-                //如果解压到的目录不存在,则报错
368
-                if (!System.IO.Directory.Exists(TargetDirectory))
369
-                {
370
-                    throw new System.IO.FileNotFoundException("指定的目录: " + TargetDirectory + " 不存在!");
371
-                }
372
-                //目录结尾
373
-                if (!TargetDirectory.EndsWith("\\")) { TargetDirectory = TargetDirectory + "\\"; }
374
-
375
-                using (ZipInputStream zipfiles = new ZipInputStream(File.OpenRead(ZipFile)))
376
-                {
377
-                    zipfiles.Password = Password;
378
-                    ZipEntry theEntry;
379
-
380
-                    while ((theEntry = zipfiles.GetNextEntry()) != null)
381
-                    {
382
-                        string directoryName = "";
383
-                        string pathToZip = "";
384
-                        pathToZip = theEntry.Name;
385
-
386
-                        if (pathToZip != "")
387
-                        {
388
-                            directoryName = Path.GetDirectoryName(pathToZip) + "\\";
389
-                        }
390
-
391
-                        string fileName = Path.GetFileName(pathToZip);
392
-
393
-                        Directory.CreateDirectory(TargetDirectory + directoryName);
394
-
395
-                        if (fileName != "")
396
-                        {
397
-                            if ((File.Exists(TargetDirectory + directoryName + fileName) && OverWrite) || (!File.Exists(TargetDirectory + directoryName + fileName)))
398
-                            {
399
-                                try
400
-                                {
401
-                                    using (FileStream streamWriter = File.Create(TargetDirectory + directoryName + fileName))
402
-                                    {
403
-                                        int size = 2048;
404
-                                        byte[] data = new byte[2048];
405
-                                        while (true)
406
-                                        {
407
-                                            size = zipfiles.Read(data, 0, data.Length);
408
-
409
-                                            if (size > 0)
410
-                                            {
411
-                                                streamWriter.Write(data, 0, size);
412
-                                            }
413
-                                            else
414
-                                            {
415
-                                                break;
416
-                                            }
417
-                                        }
418
-                                        streamWriter.Close();
419
-                                    }
420
-                                }
421
-                                catch (Exception ex)
422
-                                {
423
-                                    string message = ex.Message;
424
-                                    //解压出错//若文件无损坏则可能为无法覆盖文件
425
-                                }
426
-                            }
427
-                        }
428
-                    }
429
-
430
-                    zipfiles.Close();
431
-                }
432
-                return true;
433
-            }
434
-            catch (Exception)
435
-            {
436
-                return false;
437
-            }
438
-        }
439
-        #endregion
440
-
441
-
442
-        #region 压缩文件
443
-        /// <summary>    
444
-        /// 压缩文件    
445
-        /// </summary>    
446
-        /// <param name="fileNames">要打包的文件列表</param>    
447
-        /// <param name="GzipFileName">目标文件名</param>    
448
-        /// <param name="CompressionLevel">压缩品质级别(0~9)</param>    
449
-        /// <param name="deleteFile">是否删除原文件</param>  
450
-        public static void CompressFile(List<FileInfo> fileNames, string GzipFileName, int CompressionLevel, bool deleteFile)
451
-        {
452
-            ZipOutputStream s = new ZipOutputStream(File.Create(GzipFileName));
453
-            try
454
-            {
455
-                s.SetLevel(CompressionLevel);   //0 - store only to 9 - means best compression    
456
-                foreach (FileInfo file in fileNames)
457
-                {
458
-                    FileStream fs = null;
459
-                    try
460
-                    {
461
-                        fs = file.Open(FileMode.Open, FileAccess.ReadWrite);
462
-                    }
463
-                    catch
464
-                    { continue; }
465
-                    //  方法二,将文件分批读入缓冲区    
466
-                    byte[] data = new byte[2048];
467
-                    int size = 2048;
468
-                    ZipEntry entry = new ZipEntry(Path.GetFileName(file.Name))
469
-                    {
470
-                        DateTime = (file.CreationTime > file.LastWriteTime ? file.LastWriteTime : file.CreationTime)
471
-                    };
472
-                    s.PutNextEntry(entry);
473
-                    while (true)
474
-                    {
475
-                        size = fs.Read(data, 0, size);
476
-                        if (size <= 0)
477
-                        {
478
-                            break;
479
-                        }
480
-
481
-                        s.Write(data, 0, size);
482
-                    }
483
-                    fs.Close();
484
-                    if (deleteFile)
485
-                    {
486
-                        file.Delete();
487
-                    }
488
-                }
489
-            }
490
-            finally
491
-            {
492
-                s.Finish();
493
-                s.Close();
494
-            }
495
-        }
496
-        public static void CompressFile(string fileName, string GzipFileName, int CompressionLevel, bool deleteFile)
497
-        {
498
-            ZipOutputStream s = new ZipOutputStream(File.Create(GzipFileName));
499
-            try
500
-            {
501
-                s.SetLevel(CompressionLevel);   //0 - store only to 9 - means best compression    
502
-                FileInfo file = new FileInfo(fileName);
503
-                FileStream fs = null;
504
-                try
505
-                {
506
-                    fs = file.Open(FileMode.Open, FileAccess.ReadWrite);
507
-                }
508
-                catch
509
-                { return; }
510
-                //  方法二,将文件分批读入缓冲区    
511
-                byte[] data = new byte[2048];
512
-                int size = 2048;
513
-                ZipEntry entry = new ZipEntry(Path.GetFileName(file.Name))
514
-                {
515
-                    DateTime = (file.CreationTime > file.LastWriteTime ? file.LastWriteTime : file.CreationTime)
516
-                };
517
-                s.PutNextEntry(entry);
518
-                while (true)
519
-                {
520
-                    size = fs.Read(data, 0, size);
521
-                    if (size <= 0)
522
-                    {
523
-                        break;
524
-                    }
525
-
526
-                    s.Write(data, 0, size);
527
-                }
528
-                fs.Close();
529
-                if (deleteFile)
530
-                {
531
-                    file.Delete();
532
-                }
533
-            }
534
-            finally
535
-            {
536
-                s.Finish();
537
-                s.Close();
538
-            }
539
-        }
540
-        /// <summary>    
541
-        /// 压缩文件夹    
542
-        /// </summary>    
543
-        /// <param name="dirPath">要打包的文件夹</param>    
544
-        /// <param name="GzipFileName">目标文件名</param>    
545
-        /// <param name="CompressionLevel">压缩品质级别(0~9)</param>    
546
-        /// <param name="deleteDir">是否删除原文件夹</param>  
547
-        public static void CompressDirectory(string dirPath, string GzipFileName, int CompressionLevel, bool deleteDir)
548
-        {
549
-            //压缩文件为空时默认与压缩文件夹同一级目录    
550
-            if (GzipFileName == string.Empty)
551
-            {
552
-                GzipFileName = dirPath.Substring(dirPath.LastIndexOf("//") + 1);
553
-                GzipFileName = dirPath.Substring(0, dirPath.LastIndexOf("//")) + "//" + GzipFileName + ".zip";
554
-            }
555
-            //if (Path.GetExtension(GzipFileName) != ".zip")  
556
-            //{  
557
-            //    GzipFileName = GzipFileName + ".zip";  
558
-            //}  
559
-            using (ZipOutputStream zipoutputstream = new ZipOutputStream(File.Create(GzipFileName)))
560
-            {
561
-                zipoutputstream.SetLevel(CompressionLevel);
562
-                Crc32 crc = new Crc32();
563
-                Dictionary<string, DateTime> fileList = GetAllFies(dirPath);
564
-                foreach (KeyValuePair<string, DateTime> item in fileList)
565
-                {
566
-                    FileStream fs = File.OpenRead(item.Key.ToString());
567
-                    byte[] buffer = new byte[fs.Length];
568
-                    fs.Read(buffer, 0, buffer.Length);
569
-                    ZipEntry entry = new ZipEntry(item.Key.Substring(dirPath.Length))
570
-                    {
571
-                        DateTime = item.Value,
572
-                        Size = fs.Length
573
-                    };
574
-                    fs.Close();
575
-                    crc.Reset();
576
-                    crc.Update(buffer);
577
-                    entry.Crc = crc.Value;
578
-                    zipoutputstream.PutNextEntry(entry);
579
-                    zipoutputstream.Write(buffer, 0, buffer.Length);
580
-                }
581
-            }
582
-            if (deleteDir)
583
-            {
584
-                Directory.Delete(dirPath, true);
585
-            }
586
-        }
587
-        /// <summary>    
588
-        /// 获取所有文件    
589
-        /// </summary>    
590
-        /// <returns></returns>    
591
-        private static Dictionary<string, DateTime> GetAllFies(string dir)
592
-        {
593
-            Dictionary<string, DateTime> FilesList = new Dictionary<string, DateTime>();
594
-            DirectoryInfo fileDire = new DirectoryInfo(dir);
595
-            if (!fileDire.Exists)
596
-            {
597
-                throw new System.IO.FileNotFoundException("目录:" + fileDire.FullName + "没有找到!");
598
-            }
599
-            GetAllDirFiles(fileDire, FilesList);
600
-            GetAllDirsFiles(fileDire.GetDirectories(), FilesList);
601
-            return FilesList;
602
-        }
603
-        /// <summary>    
604
-        /// 获取一个文件夹下的所有文件夹里的文件    
605
-        /// </summary>    
606
-        /// <param name="dirs"></param>    
607
-        /// <param name="filesList"></param>    
608
-        private static void GetAllDirsFiles(DirectoryInfo[] dirs, Dictionary<string, DateTime> filesList)
609
-        {
610
-            foreach (DirectoryInfo dir in dirs)
611
-            {
612
-                foreach (FileInfo file in dir.GetFiles("*.*"))
613
-                {
614
-                    filesList.Add(file.FullName, file.LastWriteTime);
615
-                }
616
-                GetAllDirsFiles(dir.GetDirectories(), filesList);
617
-            }
618
-        }
619
-        /// <summary>    
620
-        /// 获取一个文件夹下的文件    
621
-        /// </summary>    
622
-        /// <param name="dir">目录名称</param>    
623
-        /// <param name="filesList">文件列表HastTable</param>    
624
-        private static void GetAllDirFiles(DirectoryInfo dir, Dictionary<string, DateTime> filesList)
625
-        {
626
-            foreach (FileInfo file in dir.GetFiles("*.*"))
627
-            {
628
-                filesList.Add(file.FullName, file.LastWriteTime);
629
-            }
630
-        }
631
-        #endregion
632
-
633
-        #region 解压缩文件
634
-        /// <summary>    
635
-        /// 解压缩文件    
636
-        /// </summary>    
637
-        /// <param name="GzipFile">压缩包文件名</param>    
638
-        /// <param name="targetPath">解压缩目标路径</param>           
639
-        public static void Decompress(string GzipFile, string targetPath)
640
-        {
641
-            //string directoryName = Path.GetDirectoryName(targetPath + "//") + "//";    
642
-            string directoryName = targetPath;
643
-            if (!Directory.Exists(directoryName))
644
-            {
645
-                Directory.CreateDirectory(directoryName);//生成解压目录    
646
-            }
647
-
648
-            string CurrentDirectory = directoryName;
649
-            byte[] data = new byte[2048];
650
-            int size = 2048;
651
-            ZipEntry theEntry = null;
652
-            using (ZipInputStream s = new ZipInputStream(File.OpenRead(GzipFile)))
653
-            {
654
-                while ((theEntry = s.GetNextEntry()) != null)
655
-                {
656
-                    if (theEntry.IsDirectory)
657
-                    {// 该结点是目录    
658
-                        if (!Directory.Exists(CurrentDirectory + theEntry.Name))
659
-                        {
660
-                            Directory.CreateDirectory(CurrentDirectory + theEntry.Name);
661
-                        }
662
-                    }
663
-                    else
664
-                    {
665
-                        if (theEntry.Name != string.Empty)
666
-                        {
667
-                            //  检查多级目录是否存在  
668
-                            if (theEntry.Name.Contains("\\"))
669
-                            {
670
-                                string parentDirPath = theEntry.Name.Remove(theEntry.Name.LastIndexOf("\\") + 1);
671
-                                if (!Directory.Exists(parentDirPath))
672
-                                {
673
-                                    Directory.CreateDirectory(CurrentDirectory + parentDirPath);
674
-                                }
675
-                            }
676
-
677
-                            //解压文件到指定的目录    
678
-                            using (FileStream streamWriter = File.Create(CurrentDirectory + theEntry.Name))
679
-                            {
680
-                                while (true)
681
-                                {
682
-                                    size = s.Read(data, 0, data.Length);
683
-                                    if (size <= 0)
684
-                                    {
685
-                                        break;
686
-                                    }
687
-
688
-                                    streamWriter.Write(data, 0, size);
689
-                                }
690
-                                streamWriter.Close();
691
-                            }
692
-                        }
693
-                    }
694
-                }
695
-                s.Close();
696
-            }
697
-        }
698
-        #endregion
699
-
700
-    }
701
-}

+ 0
- 36
Common/system/DataConvertCommon.cs Datei anzeigen

@@ -1,36 +0,0 @@
1
-namespace Common.system
2
-{
3
-    /// <summary>
4
-    /// 数据转换帮助类
5
-    /// 创建人:赵耀
6
-    /// 创建时间:2018年10月24日
7
-    /// </summary>
8
-    public class DataConvertCommon
9
-    {
10
-        /// <summary>
11
-        /// 父类向子类赋值
12
-        /// 创建人:赵耀
13
-        /// 创建时间:2018年10月24日
14
-        /// </summary>
15
-        /// <typeparam name="TParent">父类</typeparam>
16
-        /// <typeparam name="TChild">子类</typeparam>
17
-        /// <param name="parent">子数据</param>
18
-        /// <returns></returns>
19
-        public static TChild ParentClassCopy<TParent, TChild>(TParent parent) where TChild : TParent, new()
20
-        {
21
-            TChild child = new TChild();
22
-            System.Type ParentType = typeof(TParent);
23
-            System.Reflection.PropertyInfo[] Properties = ParentType.GetProperties();
24
-            foreach (System.Reflection.PropertyInfo Propertie in Properties)
25
-            {
26
-                //循环遍历属性
27
-                if (Propertie.CanRead && Propertie.CanWrite)
28
-                {
29
-                    //进行属性拷贝
30
-                    Propertie.SetValue(child, Propertie.GetValue(parent, null), null);
31
-                }
32
-            }
33
-            return child;
34
-        }
35
-    }
36
-}

+ 0
- 100
Common/system/DataProvider.cs Datei anzeigen

@@ -1,100 +0,0 @@
1
-using Newtonsoft.Json;
2
-using System;
3
-using System.Collections.Generic;
4
-using System.IO;
5
-using System.Net;
6
-using System.Security.Cryptography;
7
-using System.Text;
8
-
9
-namespace Common.system
10
-{
11
-    public class DataProvider
12
-    {
13
-        ///3DES解密   
14
-        public static string TripleDESDecrypt(string pToDecrypt, string sKey)
15
-        {
16
-            sKey = sKey.Substring(0, 24);
17
-            TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider
18
-            {
19
-                Mode = CipherMode.ECB,
20
-                Padding = PaddingMode.Zeros
21
-            };
22
-            byte[] inputByteArray = new byte[pToDecrypt.Length / 2];
23
-            for (int x = 0; x < pToDecrypt.Length / 2; x++)
24
-            {
25
-                int i = (Convert.ToInt32(pToDecrypt.Substring(x * 2, 2), 16));
26
-                inputByteArray[x] = (byte)i;
27
-            }
28
-
29
-            des.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
30
-            des.IV = new byte[] { 0, 00, 00, 00, 00, 00, 00, 00, };
31
-            MemoryStream ms = new MemoryStream();
32
-            CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write);
33
-            cs.Write(inputByteArray, 0, inputByteArray.Length);
34
-            cs.FlushFinalBlock();
35
-
36
-            StringBuilder ret = new StringBuilder();
37
-
38
-            return System.Text.Encoding.Default.GetString(ms.ToArray()).Replace("\0", "");
39
-        }
40
-        /// <summary>
41
-        /// 返回一个时间戳到秒
42
-        /// </summary>
43
-        /// <returns></returns>
44
-        public static long TimestampTotalSeconds()
45
-        {
46
-            TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
47
-            long timestr = Convert.ToInt64(ts.TotalSeconds);
48
-            return timestr;
49
-        }
50
-        /// <summary>
51
-        /// 将字典类型序列化为json字符串
52
-        /// </summary>
53
-        /// <typeparam name="TKey">字典key</typeparam>
54
-        /// <typeparam name="TValue">字典value</typeparam>
55
-        /// <param name="dict">要序列化的字典数据</param>
56
-        /// <returns>json字符串</returns>
57
-        public static string SerializeDictionaryToJsonString<TKey, TValue>(Dictionary<TKey, TValue> dict)
58
-        {
59
-            if (dict.Count == 0)
60
-            {
61
-                return "";
62
-            }
63
-
64
-            string jsonStr = JsonConvert.SerializeObject(dict);
65
-            return jsonStr;
66
-        }
67
-        /// <summary>
68
-        ///调用Post接口
69
-        /// </summary>
70
-        /// <param name="request"></param>
71
-        /// <returns></returns>
72
-        public static string HttpPost(string body, string Url)
73
-        {
74
-            try
75
-            {
76
-                Encoding encoding = Encoding.UTF8;
77
-
78
-                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
79
-                request.Method = "POST";
80
-                request.Accept = "text/html,application/xhtml+xml,*/*";
81
-                request.ContentType = "application/json";
82
-
83
-                byte[] buffer = encoding.GetBytes(body);
84
-                request.ContentLength = buffer.Length;
85
-                request.GetRequestStream().Write(buffer, 0, buffer.Length);
86
-
87
-                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
88
-                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
89
-                {
90
-                    return reader.ReadToEnd();
91
-                }
92
-            }
93
-            catch (Exception ex)
94
-            {
95
-                // LogHelper.Instance.Debug($"POST接口连接失败,请求参数:{ex.Message}");
96
-                return "POST报错:" + ex.Message;
97
-            }
98
-        }
99
-    }
100
-}

+ 0
- 411
Common/system/DownloadManager.cs Datei anzeigen

@@ -1,411 +0,0 @@
1
-using Common.Model;
2
-
3
-using System;
4
-using System.Collections.Generic;
5
-using System.IO;
6
-using System.Linq;
7
-using System.Threading;
8
-
9
-namespace Common.system
10
-{
11
-    /// <summary>
12
-    /// 下载方法
13
-    /// 创建人:赵耀
14
-    /// 创建时间:2018年10月30日
15
-    /// </summary>
16
-    public class DownloadManager
17
-    {
18
-        private long fromIndex = 0;//开始下载的位置
19
-        private bool isRun = false;//是否正在进行
20
-        private DownloadInfoModel dlInfo;
21
-
22
-        private List<DownloadService> dls = new List<DownloadService>();
23
-        /// <summary>
24
-        /// 开始下载
25
-        /// </summary>
26
-        public event Action OnStart;
27
-        /// <summary>
28
-        /// 停止下载
29
-        /// </summary>
30
-        public event Action OnStop;
31
-        /// <summary>
32
-        /// 下载进度
33
-        /// </summary>
34
-        public event Action<long, long, string> OnDownload;
35
-        /// <summary>
36
-        /// 下载完成
37
-        /// </summary>
38
-        public event Action<string> OnFinsh;
39
-        /// <summary>
40
-        /// 断开网络连接
41
-        /// </summary>
42
-        public event Action<string> OnDisconnect;
43
-
44
-        public DownloadManager(DownloadInfoModel dlInfo)
45
-        {
46
-            this.dlInfo = dlInfo;
47
-        }
48
-        /// <summary>
49
-        /// 暂停
50
-        /// </summary>
51
-        public void Stop()
52
-        {
53
-            isRun = false;
54
-            dls.ForEach(dl => dl.Stop());
55
-            OnStopHandler();
56
-        }
57
-        /// <summary>
58
-        /// 开始下载
59
-        /// </summary>
60
-        public void Start()
61
-        {
62
-            dlInfo.isReStart = false;
63
-            WorkStart();
64
-        }
65
-        /// <summary>
66
-        /// 重新下载
67
-        /// </summary>
68
-        public void ReStart()
69
-        {
70
-            dlInfo.isReStart = true;
71
-            WorkStart();
72
-        }
73
-        /// <summary>
74
-        /// 下载
75
-        /// </summary>
76
-        private void WorkStart()
77
-        {
78
-            new Action(() =>
79
-            {
80
-                if (dlInfo.isReStart)
81
-                {
82
-                    Stop();
83
-                }
84
-
85
-                while (dls.Where(dl => !dl.isStopped).Count() > 0)
86
-                {
87
-                    if (dlInfo.isReStart)
88
-                    {
89
-                        Thread.Sleep(100);
90
-                    }
91
-                    else
92
-                    {
93
-                        return;
94
-                    }
95
-                }
96
-
97
-                isRun = true;
98
-                OnStartHandler();
99
-                //首次任务或者不支持断点续传的进入
100
-                if (dlInfo.isNewTask || (!dlInfo.isNewTask && !dlInfo.IsSupportMultiThreading))
101
-                {
102
-                    try
103
-                    {
104
-                        //第一次请求获取一小块数据,根据返回的情况判断是否支持断点续传
105
-                        using (System.Net.WebResponse rsp = HttpHelper.Download(dlInfo.downloadUrlList[0], 0, 0, dlInfo.method))
106
-                        {
107
-
108
-                            //获取文件名,如果包含附件名称则取下附件,否则从url获取名称
109
-                            string Disposition = rsp.Headers["Content-Disposition"];
110
-                            try
111
-                            {
112
-                                if (Disposition != null)
113
-                                {
114
-                                    dlInfo.fileName = Disposition.Split('=')[1];
115
-                                }
116
-                                else
117
-                                {
118
-                                    dlInfo.fileName = Path.GetFileName(rsp.ResponseUri.AbsolutePath);
119
-                                }
120
-                            }
121
-                            catch (Exception)//无法获取文件名时  使用传入保存名称
122
-                            {
123
-                                dlInfo.fileName = dlInfo.saveFileName;
124
-                            }
125
-
126
-                            //默认给流总数
127
-                            dlInfo.count = rsp.ContentLength;
128
-                            //尝试获取 Content-Range 头部,不为空说明支持断点续传
129
-                            string contentRange = rsp.Headers["Content-Range"];
130
-                            if (contentRange != null)
131
-                            {
132
-                                //支持断点续传的话,就取range 这里的总数
133
-                                dlInfo.count = long.Parse(rsp.Headers["Content-Range"].Split('/')[1]);
134
-                                dlInfo.IsSupportMultiThreading = true;
135
-
136
-                                //生成一个临时文件名
137
-                                //var tempFileName = Convert.ToBase64String(Encoding.UTF8.GetBytes(dlInfo.fileName)).ToUpper();
138
-                                //tempFileName = tempFileName.Length > 32 ? tempFileName.Substring(0, 32) : tempFileName;
139
-                                //dlInfo.tempFileName = "test"; //tempFileName + DateTime.Now.ToString("yyyyMMddHHmmssfff");
140
-                                ///创建线程信息
141
-                                ///
142
-                                GetTaskInfo(dlInfo);
143
-
144
-                            }
145
-                            else
146
-                            {
147
-                                //不支持断点续传则一开始就直接读完整流
148
-                                Save(GetRealFileName(dlInfo), rsp.GetResponseStream());
149
-                                OnFineshHandler();
150
-                            }
151
-                        }
152
-                    }
153
-                    catch (Exception ex)
154
-                    {
155
-                        string ErrMessage = "【下载】(DownloadManager):" + ex.Message;
156
-                        LogHelper.WriteErrLog(ErrMessage, ex);
157
-                        OnDisconnectHandler();
158
-                        return;
159
-                    }
160
-                    dlInfo.isNewTask = false;
161
-                }
162
-                //如果支持断点续传采用这个
163
-                if (dlInfo.IsSupportMultiThreading)
164
-                {
165
-                    StartTask(dlInfo);
166
-
167
-                    //等待合并
168
-                    while (dls.Where(td => !td.isFinish).Count() > 0 && isRun)
169
-                    {
170
-                        Thread.Sleep(100);
171
-                    }
172
-                    if ((dls.Where(td => !td.isFinish).Count() == 0))
173
-                    {
174
-
175
-                        CombineFiles(dlInfo);
176
-                        OnFineshHandler();
177
-                    }
178
-                }
179
-
180
-            }).BeginInvoke(null, null);
181
-        }
182
-        /// <summary>
183
-        /// 合成文件
184
-        /// </summary>
185
-        /// <param name="dlInfo"></param>
186
-        private void CombineFiles(DownloadInfoModel dlInfo)
187
-        {
188
-            string realFilePath = GetRealFileName(dlInfo);
189
-
190
-            //合并数据
191
-            byte[] buffer = new byte[2048];
192
-            int length = 0;
193
-            using (FileStream fileStream = File.Open(realFilePath, FileMode.CreateNew))
194
-            {
195
-                for (int i = 0; i < dlInfo.TaskInfoList.Count; i++)
196
-                {
197
-                    string tempFile = dlInfo.TaskInfoList[i].filePath;
198
-                    using (FileStream tempStream = File.Open(tempFile, FileMode.Open))
199
-                    {
200
-                        while ((length = tempStream.Read(buffer, 0, buffer.Length)) > 0)
201
-                        {
202
-                            fileStream.Write(buffer, 0, length);
203
-                        }
204
-                        tempStream.Flush();
205
-                    }
206
-                    //File.Delete(tempFile);
207
-                }
208
-            }
209
-        }
210
-        /// <summary>
211
-        /// 创建文件
212
-        /// </summary>
213
-        /// <param name="dlInfo"></param>
214
-        /// <returns></returns>
215
-        private static string GetRealFileName(DownloadInfoModel dlInfo)
216
-        {
217
-            //创建正式文件名,如果已存在则加数字序号创建,避免覆盖
218
-            int fileIndex = 0;
219
-            string realFilePath = Path.Combine(dlInfo.saveDir, dlInfo.saveFileName);
220
-            while (File.Exists(realFilePath))
221
-            {
222
-                realFilePath = Path.Combine(dlInfo.saveDir, string.Format("{0}_{1}", fileIndex++, dlInfo.fileName));
223
-            }
224
-
225
-            return realFilePath;
226
-        }
227
-
228
-        private void StartTask(DownloadInfoModel dlInfo)
229
-        {
230
-            dls = new List<DownloadService>();
231
-            if (dlInfo.TaskInfoList != null)
232
-            {
233
-                foreach (TaskInfoModel item in dlInfo.TaskInfoList)
234
-                {
235
-                    DownloadService dl = new DownloadService();
236
-                    dl.OnDownload += OnDownloadHandler;
237
-                    dl.OnDisconnect += OnDisconnectHandler;
238
-                    dls.Add(dl);
239
-                    try
240
-                    {
241
-                        dl.Start(item, dlInfo.isReStart);
242
-                    }
243
-                    catch (Exception ex)
244
-                    {
245
-                        string ErrMessage = "【下载】(DownloadManager):" + ex.Message;
246
-                        LogHelper.WriteErrLog(ErrMessage, ex);
247
-                    }
248
-                }
249
-            }
250
-        }
251
-
252
-        /// <summary>
253
-        /// 创建下载任务
254
-        /// </summary>
255
-        /// <param name="dlInfo"></param>
256
-        private void GetTaskInfo(DownloadInfoModel dlInfo)
257
-        {
258
-            long pieceSize = (dlInfo.count) / dlInfo.taskCount;
259
-            dlInfo.TaskInfoList = new List<TaskInfoModel>();
260
-            Random rand = new Random();
261
-            int urlIndex = 0;
262
-            for (int i = 0; i <= dlInfo.taskCount + 1; i++)
263
-            {
264
-                long from = (i * pieceSize);
265
-
266
-                if (from >= dlInfo.count)
267
-                {
268
-                    break;
269
-                }
270
-
271
-                long to = from + pieceSize;
272
-                if (to >= dlInfo.count)
273
-                {
274
-                    to = dlInfo.count;
275
-                }
276
-
277
-                dlInfo.TaskInfoList.Add(
278
-                    new TaskInfoModel
279
-                    {
280
-                        method = dlInfo.method,
281
-                        downloadUrl = dlInfo.downloadUrlList[urlIndex++],
282
-
283
-                        filePath = Path.Combine(dlInfo.saveDir, dlInfo.tempFileName + ".temp" + i),
284
-                        fromIndex = from,
285
-                        toIndex = to
286
-                    });
287
-                if (urlIndex >= dlInfo.downloadUrlList.Count)
288
-                {
289
-                    urlIndex = 0;
290
-                }
291
-            }
292
-        }
293
-
294
-        /// <summary>
295
-        /// 保存内容
296
-        /// </summary>
297
-        /// <param name="filePath"></param>
298
-        /// <param name="stream"></param>
299
-        private void Save(string filePath, Stream stream)
300
-        {
301
-            try
302
-            {
303
-                using (FileStream writer = File.Open(filePath, FileMode.Append))
304
-                {
305
-                    using (stream)
306
-                    {
307
-                        int repeatTimes = 0;
308
-                        byte[] buffer = new byte[1024];
309
-                        int length = 0;
310
-                        while ((length = stream.Read(buffer, 0, buffer.Length)) > 0 && isRun)
311
-                        {
312
-                            writer.Write(buffer, 0, length);
313
-                            fromIndex += length;
314
-                            if (repeatTimes % 5 == 0)
315
-                            {
316
-                                writer.Flush();//一定大小就刷一次缓冲区
317
-                                OnDownloadHandler();
318
-                            }
319
-                            repeatTimes++;
320
-                        }
321
-                        writer.Flush();
322
-                        OnDownloadHandler();
323
-                    }
324
-                }
325
-            }
326
-            catch (Exception)
327
-            {
328
-                //异常也不影响
329
-            }
330
-        }
331
-
332
-        /// <summary>
333
-        /// 开始下载
334
-        /// </summary>
335
-        private void OnStartHandler()
336
-        {
337
-            new Action(() =>
338
-            {
339
-                OnStart.Invoke();
340
-            }).BeginInvoke(null, null);
341
-        }
342
-        /// <summary>
343
-        /// 暂停下载
344
-        /// </summary>
345
-        private void OnStopHandler()
346
-        {
347
-            new Action(() =>
348
-            {
349
-                OnStop.Invoke();
350
-            }).BeginInvoke(null, null);
351
-        }
352
-        /// <summary>
353
-        /// 下载完成
354
-        /// </summary>
355
-        private void OnFineshHandler()
356
-        {
357
-            new Action(() =>
358
-            {
359
-                for (int i = 0; i < dlInfo.TaskInfoList.Count; i++)
360
-                {
361
-                    string tempFile = dlInfo.TaskInfoList[i].filePath;
362
-                    File.Delete(tempFile);
363
-                }
364
-                OnFinsh.Invoke(dlInfo.saveFileName);
365
-            }).BeginInvoke(null, null);
366
-        }
367
-        /// <summary>
368
-        /// 下载进度
369
-        /// </summary>
370
-        private void OnDownloadHandler()
371
-        {
372
-            new Action(() =>
373
-            {
374
-                long current = GetDownloadLength();
375
-                OnDownload.Invoke(current, dlInfo.count, dlInfo.saveFileName);
376
-            }).BeginInvoke(null, null);
377
-        }
378
-        /// <summary>
379
-        /// 断开网络连接
380
-        /// </summary>
381
-        private void OnDisconnectHandler()
382
-        {
383
-            new Action(() =>
384
-            {
385
-                OnDisconnect.Invoke(dlInfo.saveFileName);
386
-            }).BeginInvoke(null, null);
387
-        }
388
-        /// <summary>
389
-        /// 当前下载进度
390
-        /// </summary>
391
-        /// <returns></returns>
392
-        public long GetDownloadLength()
393
-        {
394
-            if (dlInfo.IsSupportMultiThreading)
395
-            {
396
-                return dls.Sum(dl => dl.GetDownloadedCount());
397
-            }
398
-            else
399
-            {
400
-                return fromIndex;
401
-            }
402
-        }
403
-
404
-        /// <summary>
405
-        /// 获取保存文件名
406
-        /// </summary>
407
-        /// <returns></returns>
408
-        public DownloadInfoModel GetFileInfo => dlInfo;
409
-
410
-    }
411
-}

+ 0
- 237
Common/system/DownloadService.cs Datei anzeigen

@@ -1,237 +0,0 @@
1
-using Common.Model;
2
-
3
-using System;
4
-using System.IO;
5
-using System.Net;
6
-
7
-namespace Common.system
8
-{
9
-    /// <summary>
10
-    /// 下载方法
11
-    /// 创建人:赵耀
12
-    /// 创建时间:2018年10月30日
13
-    /// </summary>
14
-    public class DownloadService
15
-    {
16
-        private string downloadUrl = "";//文件下载地址
17
-        private string filePath = "";//文件保存路径
18
-        private string method = "";//方法
19
-        private long fromIndex = 0;//开始下载的位置
20
-        private long toIndex = 0;//结束下载的位置
21
-        private long count = 0;//总大小
22
-        private long size = 524288;//每次下载大小 512kb
23
-        private bool isRun = false;//是否正在进行
24
-
25
-
26
-        public bool isFinish = false;//是否已下载完成{ get; private set; }
27
-
28
-        public bool isStopped = true;//是否已停止{ get; private set; }
29
-
30
-        /// <summary>
31
-        /// 开始下载
32
-        /// </summary>
33
-        public event Action OnStart;
34
-        /// <summary>
35
-        /// 下载进度
36
-        /// </summary>
37
-        public event Action OnDownload;
38
-        /// <summary>
39
-        /// 完成下载
40
-        /// </summary>
41
-        public event Action OnFinsh;
42
-        /// <summary>
43
-        /// 断开网络连接
44
-        /// </summary>
45
-        public event Action OnDisconnect;
46
-
47
-
48
-        public long GetDownloadedCount()
49
-        {
50
-            return count - toIndex + fromIndex - 1;
51
-        }
52
-
53
-        public void Stop()
54
-        {
55
-            isRun = false;
56
-        }
57
-
58
-        /// <summary>
59
-        /// 开始下载
60
-        /// </summary>
61
-        /// <param name="info"></param>
62
-        /// <param name="isReStart"></param>
63
-        /// <returns></returns>
64
-        public bool Start(TaskInfoModel info, bool isReStart)
65
-        {
66
-            downloadUrl = info.downloadUrl;
67
-            fromIndex = info.fromIndex;
68
-            toIndex = info.toIndex;
69
-            method = info.method;
70
-            filePath = info.filePath;
71
-            count = info.count;
72
-            isStopped = false;
73
-            if (File.Exists(filePath))
74
-            {
75
-                if (isReStart)
76
-                {
77
-                    File.Delete(filePath);
78
-                    File.Create(filePath).Close();
79
-                }
80
-            }
81
-            else
82
-            {
83
-                File.Create(filePath).Close();
84
-            }
85
-            using (FileStream file = File.Open(filePath, FileMode.Open))
86
-            {
87
-                fromIndex = info.fromIndex + file.Length;
88
-            }
89
-            if (fromIndex >= toIndex)
90
-            {
91
-                OnFineshHandler();
92
-                isFinish = true;
93
-                isStopped = true;
94
-                return false;
95
-            }
96
-            OnStartHandler();
97
-            isRun = true;
98
-            new Action(() =>
99
-            {
100
-                WebResponse rsp;
101
-                while (fromIndex < toIndex && isRun)
102
-                {
103
-                    long to;
104
-                    if (fromIndex + size >= toIndex - 1)
105
-                    {
106
-                        to = toIndex - 1;
107
-                    }
108
-                    else
109
-                    {
110
-                        to = fromIndex + size;
111
-                    }
112
-
113
-                    try
114
-                    {
115
-                        using (rsp = HttpHelper.Download(downloadUrl, fromIndex, to, method))
116
-                        {
117
-                            Save(filePath, rsp.GetResponseStream());
118
-                        }
119
-                    }
120
-                    catch (Exception ex)
121
-                    {
122
-                        string ErrMessage = "【下载】(DownloadService):" + ex.Message;
123
-                        LogHelper.WriteErrLog(ErrMessage, ex);
124
-                        OnDisconnectHandler();
125
-                        return;
126
-                    }
127
-                }
128
-                if (!isRun)
129
-                {
130
-                    isStopped = true;
131
-                }
132
-
133
-                if (fromIndex >= toIndex)
134
-                {
135
-                    isFinish = true;
136
-                    isStopped = true;
137
-                    OnFineshHandler();
138
-                }
139
-
140
-            }).BeginInvoke(null, null);
141
-            return true;
142
-        }
143
-        /// <summary>
144
-        /// 保存文件
145
-        /// </summary>
146
-        /// <param name="filePath"></param>
147
-        /// <param name="stream"></param>
148
-        private void Save(string filePath, Stream stream)
149
-        {
150
-            try
151
-            {
152
-                using (FileStream writer = File.Open(filePath, FileMode.Append))
153
-                {
154
-                    using (stream)
155
-                    {
156
-                        int repeatTimes = 0;
157
-                        byte[] buffer = new byte[1024];
158
-                        int length = 0;
159
-                        while ((length = stream.Read(buffer, 0, buffer.Length)) > 0 && isRun)
160
-                        {
161
-                            writer.Write(buffer, 0, length);
162
-                            fromIndex += length;
163
-                            if (repeatTimes % 5 == 0)
164
-                            {
165
-                                OnDownloadHandler();
166
-                            }
167
-                            repeatTimes++;
168
-                        }
169
-                    }
170
-                }
171
-                OnDownloadHandler();
172
-            }
173
-            catch (Exception)
174
-            {
175
-                //异常也不影响
176
-            }
177
-        }
178
-        /// <summary>
179
-        /// 开始下载
180
-        /// </summary>
181
-        private void OnStartHandler()
182
-        {
183
-            new Action(() =>
184
-            {
185
-                if (OnStart != null)
186
-                {
187
-                    OnStart.Invoke();
188
-                }
189
-            }).BeginInvoke(null, null);
190
-        }
191
-        /// <summary>
192
-        /// 完成下载
193
-        /// </summary>
194
-        private void OnFineshHandler()
195
-        {
196
-            new Action(() =>
197
-            {
198
-                if (OnFinsh != null)
199
-                {
200
-                    OnFinsh.Invoke();
201
-                }
202
-
203
-                if (OnDownload != null)
204
-                {
205
-                    OnDownload.Invoke();
206
-                }
207
-            }).BeginInvoke(null, null);
208
-        }
209
-        /// <summary>
210
-        /// 下载进度
211
-        /// </summary>
212
-        private void OnDownloadHandler()
213
-        {
214
-            new Action(() =>
215
-            {
216
-                if (OnDownload != null)
217
-                {
218
-                    OnDownload.Invoke();
219
-                }
220
-            }).BeginInvoke(null, null);
221
-        }
222
-        /// <summary>
223
-        /// 断开网络连接
224
-        /// </summary>
225
-        private void OnDisconnectHandler()
226
-        {
227
-            new Action(() =>
228
-            {
229
-                if (OnDisconnect != null)
230
-                {
231
-                    OnDisconnect.Invoke();
232
-                }
233
-            }).BeginInvoke(null, null);
234
-
235
-        }
236
-    }
237
-}

+ 0
- 982
Common/system/FileToolsCommon.cs Datei anzeigen

@@ -1,982 +0,0 @@
1
-using System;
2
-using System.Configuration;
3
-using System.IO;
4
-using System.Text;
5
-using System.Text.RegularExpressions;
6
-using System.Windows.Forms;
7
-
8
-namespace Common.system
9
-{
10
-    /// <summary>
11
-    /// 文件工具公共方法
12
-    /// 创建人:赵耀
13
-    /// 创建时间:2018年11月6日
14
-    /// </summary>
15
-    public static class FileToolsCommon
16
-    {
17
-        #region 获取文件的绝对路径
18
-
19
-        /// <summary>
20
-        /// 获取文件的绝对路径
21
-        /// </summary>
22
-        /// <param name="Path">相对路径</param>
23
-        /// <returns></returns>
24
-        public static string GetFileAbsolutePath(string Path = "")
25
-        {
26
-            try
27
-            {
28
-                if (!string.IsNullOrWhiteSpace(Path))
29
-                {
30
-                    Path = Path.Replace("\\", "/");
31
-                    if (Path != "/")
32
-                    {
33
-                        if (Path.Substring(1, 1) == ":")
34
-                        {
35
-                            return Path;
36
-                        }
37
-
38
-                        if (Path.Substring(0, 1) != "/")
39
-                        {
40
-                            Path = "/" + Path;
41
-                        }
42
-                    }
43
-                }
44
-                string AbsolutePath = Application.StartupPath.ToString().Replace("\\", "/") + Path;
45
-                return AbsolutePath;
46
-            }
47
-            catch (Exception)
48
-            {
49
-                return Path;
50
-            }
51
-        }
52
-        /// <summary>
53
-        /// 获取合法路径 结尾带/
54
-        /// </summary>
55
-        /// <returns></returns>
56
-        public static string GetLegalPath(string FilePath)
57
-        {
58
-            FilePath = System.IO.Path.Combine(FilePath.Replace("\\", "/"));
59
-            FilePath += (FilePath.Substring(FilePath.Length - 1, 1) == "/" ? "" : "/");
60
-            return FilePath;
61
-        }
62
-        #endregion
63
-
64
-        #region 检测路径是否合法
65
-        /// <summary>
66
-        /// 检测路径是否合法
67
-        /// </summary>
68
-        /// <param name="FilePathName">绝对路径</param>
69
-        /// <param name="ErrMessage">返回错误</param>
70
-        /// <returns></returns>
71
-        public static bool IsLegalPath(string FilePathName, out string ErrMessage)
72
-        {
73
-            string FilePath;
74
-            string FileName;
75
-            ErrMessage = "";
76
-            try
77
-            {
78
-                FilePathName = GetLegalPath(FilePathName);
79
-                FilePath = GetDirectoryName(FilePathName);
80
-                FileName = GetIOFileName(FilePathName);
81
-            }
82
-            catch (Exception)
83
-            {
84
-                ErrMessage = "路径或文件名不合法!";
85
-                return false;
86
-            }
87
-            Regex regex = new Regex(@"^([a-zA-Z]:\\)?[^\/\:\*\?\""\<\>\|\,]*$");
88
-            Match m = regex.Match(FilePath);
89
-            if (!m.Success)
90
-            {
91
-                ErrMessage = "非法的文件保存路径!";
92
-                return false;
93
-            }
94
-            if (!string.IsNullOrWhiteSpace(FileName))
95
-            {
96
-                regex = new Regex(@"^[^\/\:\*\?\""\<\>\|\,]+$");
97
-                m = regex.Match(FileName);
98
-                if (!m.Success)
99
-                {
100
-                    ErrMessage = "非法的文件名!文件名中包含\\ / : * ? \" < > |等字符!";
101
-                    return false;
102
-                }
103
-            }
104
-            return true;
105
-
106
-        }
107
-        #endregion
108
-
109
-        #region 检测指定目录是否存在
110
-        /// <summary>  
111
-        /// 检测指定目录是否存在  
112
-        /// </summary>  
113
-        /// <param name="directoryPath">目录的绝对路径</param>          
114
-        public static bool IsExistDirectory(string directoryPath)
115
-        {
116
-            return Directory.Exists(directoryPath);
117
-        }
118
-        #endregion
119
-
120
-        #region 检测指定文件是否存在
121
-        /// <summary>  
122
-        /// 检测指定文件是否存在,如果存在则返回true。  
123
-        /// </summary>  
124
-        /// <param name="filePath">文件的绝对路径</param>          
125
-        public static bool IsExistFile(string filePath)
126
-        {
127
-            return File.Exists(filePath);
128
-        }
129
-        #endregion
130
-
131
-        #region 检测指定目录是否为空
132
-        /// <summary>  
133
-        /// 检测指定目录是否为空  
134
-        /// </summary>  
135
-        /// <param name="directoryPath">指定目录的绝对路径</param>          
136
-        public static bool IsEmptyDirectory(string directoryPath)
137
-        {
138
-            try
139
-            {
140
-                //判断是否存在文件  
141
-                string[] fileNames = GetFileNames(directoryPath);
142
-                if (fileNames.Length > 0)
143
-                {
144
-                    return false;
145
-                }
146
-
147
-                //判断是否存在文件夹  
148
-                string[] directoryNames = GetDirectories(directoryPath);
149
-                return directoryNames.Length <= 0;
150
-            }
151
-            catch
152
-            {
153
-                return false;
154
-            }
155
-        }
156
-        #endregion
157
-
158
-        #region 检测指定目录中是否存在指定的文件
159
-        /// <summary>  
160
-        /// 检测指定目录中是否存在指定的文件,若要搜索子目录请使用重载方法.  
161
-        /// </summary>  
162
-        /// <param name="directoryPath">指定目录的绝对路径</param>  
163
-        /// <param name="searchPattern">模式字符串,"*"代表0或N个字符,"?"代表1个字符。  
164
-        /// 范例:"Log*.xml"表示搜索所有以Log开头的Xml文件。</param>          
165
-        public static bool Contains(string directoryPath, string searchPattern)
166
-        {
167
-            try
168
-            {
169
-                //获取指定的文件列表  
170
-                string[] fileNames = GetFileNames(directoryPath, searchPattern, false);
171
-
172
-                //判断指定文件是否存在  
173
-                return fileNames.Length != 0;
174
-            }
175
-            catch
176
-            {
177
-                return false;
178
-            }
179
-        }
180
-
181
-        /// <summary>  
182
-        /// 检测指定目录中是否存在指定的文件  
183
-        /// </summary>  
184
-        /// <param name="directoryPath">指定目录的绝对路径</param>  
185
-        /// <param name="searchPattern">模式字符串,"*"代表0或N个字符,"?"代表1个字符。  
186
-        /// 范例:"Log*.xml"表示搜索所有以Log开头的Xml文件。</param>   
187
-        /// <param name="isSearchChild">是否搜索子目录</param>  
188
-        public static bool Contains(string directoryPath, string searchPattern, bool isSearchChild)
189
-        {
190
-            try
191
-            {
192
-                //获取指定的文件列表  
193
-                string[] fileNames = GetFileNames(directoryPath, searchPattern, isSearchChild);
194
-
195
-                //判断指定文件是否存在  
196
-                return fileNames.Length != 0;
197
-            }
198
-            catch
199
-            {
200
-                return false;
201
-            }
202
-        }
203
-        #endregion
204
-
205
-        #region 创建一个目录
206
-        /// <summary>  
207
-        /// 创建一个目录  
208
-        /// </summary>  
209
-        /// <param name="directoryPath">目录的绝对路径</param>  
210
-        public static void CreateDirectory(string directoryPath)
211
-        {
212
-            try
213
-            {
214
-                //如果目录不存在则创建该目录  
215
-                if (!IsExistDirectory(directoryPath))
216
-                {
217
-                    Directory.CreateDirectory(directoryPath);
218
-                }
219
-            }
220
-            catch (Exception ex)
221
-            {
222
-                throw new ApplicationException(ex.Message); //"请使用管理员权限运行!"
223
-            }
224
-        }
225
-        #endregion
226
-
227
-        #region 创建一个文件
228
-        /// <summary>  
229
-        /// 创建一个文件。  
230
-        /// </summary>  
231
-        /// <param name="filePath">文件的绝对路径</param>  
232
-        public static bool CreateFile(string filePath)
233
-        {
234
-            try
235
-            {
236
-                //如果文件不存在则创建该文件  
237
-                if (!IsExistFile(filePath))
238
-                {
239
-                    //创建一个FileInfo对象  
240
-                    FileInfo file = new FileInfo(filePath);
241
-                    //创建文件  
242
-                    FileStream fs = file.Create();
243
-                    //关闭文件流  
244
-                    fs.Close();
245
-                }
246
-            }
247
-            catch
248
-            {
249
-                return false;
250
-            }
251
-
252
-            return true;
253
-        }
254
-
255
-        /// <summary>  
256
-        /// 创建一个文件,并将字节流写入文件。  
257
-        /// </summary>  
258
-        /// <param name="filePath">文件的绝对路径</param>  
259
-        /// <param name="buffer">二进制流数据</param>  
260
-        public static bool CreateFile(string filePath, byte[] buffer)
261
-        {
262
-            try
263
-            {
264
-                //如果文件不存在则创建该文件  
265
-                if (!IsExistFile(filePath))
266
-                {
267
-                    //创建一个FileInfo对象  
268
-                    FileInfo file = new FileInfo(filePath);
269
-
270
-                    //创建文件  
271
-                    FileStream fs = file.Create();
272
-
273
-                    //写入二进制流  
274
-                    fs.Write(buffer, 0, buffer.Length);
275
-
276
-                    //关闭文件流  
277
-                    fs.Close();
278
-                }
279
-            }
280
-            catch
281
-            {
282
-                return false;
283
-            }
284
-            return true;
285
-        }
286
-        #endregion
287
-
288
-        #region 获取文本文件的行数
289
-        /// <summary>  
290
-        /// 获取文本文件的行数  
291
-        /// </summary>  
292
-        /// <param name="filePath">文件的绝对路径</param>          
293
-        public static int GetLineCount(string filePath)
294
-        {
295
-            //将文本文件的各行读到一个字符串数组中  
296
-            string[] rows = File.ReadAllLines(filePath);
297
-
298
-            //返回行数  
299
-            return rows.Length;
300
-        }
301
-        #endregion
302
-
303
-        #region 获取一个文件的长度
304
-        /// <summary>  
305
-        /// 获取一个文件的长度,单位为Byte  
306
-        /// </summary>  
307
-        /// <param name="filePath">文件的绝对路径</param>          
308
-        public static long GetFileSize(string filePath)
309
-        {
310
-            //创建一个文件对象  
311
-            FileInfo fi = new FileInfo(filePath);
312
-
313
-            //获取文件的大小  
314
-            return fi.Length;
315
-        }
316
-
317
-        /// <summary>  
318
-        /// 获取一个文件的长度,单位为KB  
319
-        /// </summary>  
320
-        /// <param name="filePath">文件的路径</param>          
321
-        public static double GetFileSizeByKB(string filePath)
322
-        {
323
-            //创建一个文件对象  
324
-            FileInfo fi = new FileInfo(filePath);
325
-            //double size = fi.Length / 1024;
326
-            double size = Math.Round((fi.Length / 1024.0), 2, MidpointRounding.AwayFromZero);
327
-            //获取文件的大小  
328
-            return size;
329
-        }
330
-
331
-        /// <summary>  
332
-        /// 获取一个文件的长度,单位为MB  
333
-        /// </summary>  
334
-        /// <param name="filePath">文件的路径</param>          
335
-        public static double GetFileSizeByMB(string filePath)
336
-        {
337
-            //创建一个文件对象  
338
-            FileInfo fi = new FileInfo(filePath);
339
-            //double size = fi.Length / 1024 / 1024;
340
-            double size = Math.Round((fi.Length / 1024.0 / 1024.0), 2, MidpointRounding.AwayFromZero);
341
-            //获取文件的大小  
342
-            return size;
343
-        }
344
-        #endregion
345
-
346
-        #region 获取指定目录中的文件列表
347
-        /// <summary>  
348
-        /// 获取指定目录中所有文件列表  
349
-        /// </summary>  
350
-        /// <param name="directoryPath">指定目录的绝对路径</param>          
351
-        public static FileInfo[] GetFileInfos(string directoryPath, string files = null)
352
-        {
353
-            //如果目录不存在,则抛出异常  
354
-            if (!IsExistDirectory(directoryPath))
355
-            {
356
-                return null;//throw new FileNotFoundException();
357
-            }
358
-            DirectoryInfo folder = new DirectoryInfo(directoryPath);
359
-            FileInfo[] fileList;
360
-            if (files == null)
361
-            {
362
-                fileList = folder.GetFiles();
363
-            }
364
-            else
365
-            {
366
-                fileList = folder.GetFiles(files);
367
-            }
368
-            //获取文件列表  
369
-            return fileList;
370
-        }
371
-
372
-        /// <summary>  
373
-        /// 获取指定目录中所有文件列表  
374
-        /// </summary>  
375
-        /// <param name="directoryPath">指定目录的绝对路径</param>          
376
-        public static string[] GetFileNames(string directoryPath)
377
-        {
378
-            //如果目录不存在,则抛出异常  
379
-            if (!IsExistDirectory(directoryPath))
380
-            {
381
-                return null;//throw new FileNotFoundException();
382
-            }
383
-
384
-            //获取文件列表  
385
-            return Directory.GetFiles(directoryPath);
386
-        }
387
-
388
-        /// <summary>  
389
-        /// 获取指定目录及子目录中所有文件列表  
390
-        /// </summary>  
391
-        /// <param name="directoryPath">指定目录的绝对路径</param>  
392
-        /// <param name="searchPattern">模式字符串,"*"代表0或N个字符,"?"代表1个字符。  
393
-        /// 范例:"Log*.xml"表示搜索所有以Log开头的Xml文件。</param>  
394
-        /// <param name="isSearchChild">是否搜索子目录</param>  
395
-        public static string[] GetFileNames(string directoryPath, string searchPattern, bool isSearchChild)
396
-        {
397
-            //如果目录不存在,则抛出异常  
398
-            if (!IsExistDirectory(directoryPath))
399
-            {
400
-                return null;//throw new FileNotFoundException();
401
-            }
402
-
403
-            try
404
-            {
405
-                return Directory.GetFiles(directoryPath, searchPattern, isSearchChild ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
406
-            }
407
-            catch
408
-            {
409
-                return null;
410
-            }
411
-        }
412
-        #endregion
413
-
414
-        #region 获取指定目录中的子目录列表
415
-        /// <summary>  
416
-        /// 获取指定目录中所有子目录列表,若要搜索嵌套的子目录列表,请使用重载方法.  
417
-        /// </summary>  
418
-        /// <param name="directoryPath">指定目录的绝对路径</param>          
419
-        public static string[] GetDirectories(string directoryPath)
420
-        {
421
-            try
422
-            {
423
-                return Directory.GetDirectories(directoryPath);
424
-            }
425
-            catch
426
-            {
427
-                return null;
428
-            }
429
-        }
430
-
431
-        /// <summary>  
432
-        /// 获取指定目录及子目录中所有子目录列表  
433
-        /// </summary>  
434
-        /// <param name="directoryPath">指定目录的绝对路径</param>  
435
-        /// <param name="searchPattern">模式字符串,"*"代表0或N个字符,"?"代表1个字符。  
436
-        /// 范例:"Log*.xml"表示搜索所有以Log开头的Xml文件。</param>  
437
-        /// <param name="isSearchChild">是否搜索子目录</param>  
438
-        public static string[] GetDirectories(string directoryPath, string searchPattern, bool isSearchChild)
439
-        {
440
-            try
441
-            {
442
-                return Directory.GetDirectories(directoryPath, searchPattern, isSearchChild ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
443
-            }
444
-            catch
445
-            {
446
-                return null;//throw
447
-            }
448
-        }
449
-        #endregion
450
-
451
-        #region 向文本文件写入内容
452
-        /// <summary>  
453
-        /// 向文本文件中写入内容  
454
-        /// </summary>  
455
-        /// <param name="filePath">文件的绝对路径</param>  
456
-        /// <param name="content">写入的内容</param>          
457
-        public static void WriteText(string filePath, string content)
458
-        {
459
-            //向文件写入内容  
460
-            File.WriteAllText(filePath, content);
461
-        }
462
-        #endregion
463
-
464
-        #region 向文本文件的尾部追加内容
465
-        /// <summary>  
466
-        /// 向文本文件的尾部追加内容  
467
-        /// </summary>  
468
-        /// <param name="filePath">文件的绝对路径</param>  
469
-        /// <param name="content">写入的内容</param>  
470
-        public static void AppendText(string filePath, string content)
471
-        {
472
-            File.AppendAllText(filePath, content);
473
-        }
474
-        #endregion
475
-
476
-        #region 将现有文件的内容复制到新文件中
477
-        /// <summary>  
478
-        /// 将源文件的内容复制到目标文件中  
479
-        /// </summary>  
480
-        /// <param name="sourceFilePath">源文件的绝对路径</param>  
481
-        /// <param name="destFilePath">目标文件的绝对路径</param>  
482
-        public static void Copy(string sourceFilePath, string destFilePath)
483
-        {
484
-            File.Copy(sourceFilePath, destFilePath, true);
485
-        }
486
-        #endregion
487
-
488
-        #region 将文件移动到指定目录
489
-        /// <summary>  
490
-        /// 将文件移动到指定目录  
491
-        /// </summary>  
492
-        /// <param name="sourceFilePath">需要移动的源文件的绝对路径</param>  
493
-        /// <param name="descDirectoryPath">移动到的目录的绝对路径</param>  
494
-        public static void Move(string sourceFilePath, string descDirectoryPath)
495
-        {
496
-            //获取源文件的名称  
497
-            string sourceFileName = GetFileName(sourceFilePath);
498
-
499
-            if (IsExistDirectory(descDirectoryPath))
500
-            {
501
-                //如果目标中存在同名文件,则删除  
502
-                if (IsExistFile(descDirectoryPath + "\\" + sourceFileName))
503
-                {
504
-                    DeleteFile(descDirectoryPath + "\\" + sourceFileName);
505
-                }
506
-                //将文件移动到指定目录  
507
-                File.Move(sourceFilePath, descDirectoryPath + "\\" + sourceFileName);
508
-            }
509
-        }
510
-        #endregion
511
-
512
-        #region 将流读取到缓冲区中
513
-        /// <summary>  
514
-        /// 将流读取到缓冲区中  
515
-        /// </summary>  
516
-        /// <param name="stream">原始流</param>  
517
-        public static byte[] StreamToBytes(Stream stream)
518
-        {
519
-            try
520
-            {
521
-                //创建缓冲区  
522
-                byte[] buffer = new byte[stream.Length];
523
-
524
-                //读取流  
525
-                stream.Read(buffer, 0, int.Parse(stream.Length.ToString()));
526
-
527
-                //返回流  
528
-                return buffer;
529
-            }
530
-            catch
531
-            {
532
-                return null;
533
-            }
534
-            finally
535
-            {
536
-                //关闭流  
537
-                stream.Close();
538
-            }
539
-        }
540
-        #endregion
541
-
542
-        #region 将文件读取到缓冲区中
543
-        /// <summary>  
544
-        /// 将文件读取到缓冲区中  
545
-        /// </summary>  
546
-        /// <param name="filePath">文件的绝对路径</param>  
547
-        public static byte[] FileToBytes(string filePath)
548
-        {
549
-            //获取文件的大小   
550
-            long fileSize = GetFileSize(filePath);
551
-
552
-            //创建一个临时缓冲区  
553
-            byte[] buffer = new byte[fileSize];
554
-
555
-            //创建一个文件流  
556
-            FileInfo fi = new FileInfo(filePath);
557
-            FileStream fs = fi.Open(FileMode.Open);
558
-
559
-            try
560
-            {
561
-                //将文件流读入缓冲区  
562
-                fs.Read(buffer, 0, (int)fileSize);
563
-
564
-                return buffer;
565
-            }
566
-            catch
567
-            {
568
-                return null;
569
-            }
570
-            finally
571
-            {
572
-                //关闭文件流  
573
-                fs.Close();
574
-            }
575
-        }
576
-        /// <summary>
577
-        /// 读取大文件用,读取文件前面指定长度字节数
578
-        /// </summary>
579
-        /// <param name="filePath">文件路径</param>
580
-        /// <param name="Length">读取长度,单位字节</param>
581
-        /// <returns></returns>
582
-        public static byte[] ReadBigFile(string filePath, int Length)
583
-        {
584
-            FileStream stream = new FileStream(filePath, FileMode.Open);
585
-            byte[] buffer = new byte[Length];
586
-            //stream.Position = startIndex;
587
-            stream.Read(buffer, 0, Length);
588
-            stream.Close();
589
-            stream.Dispose();
590
-            return buffer;
591
-        }
592
-        /// <summary>
593
-        /// 读取指定长度的流
594
-        /// </summary>
595
-        /// <param name="filePath">文件位置</param>
596
-        /// <param name="startIndex">开始位置</param>
597
-        /// <param name="Length">长度</param>
598
-        /// <returns></returns>
599
-        public static byte[] ReadBigFileSpecifyLength(string filePath, long startIndex, int Length)
600
-        {
601
-            FileStream stream = new FileStream(filePath, FileMode.Open);
602
-            if (startIndex + Length + 1 > stream.Length)
603
-            {
604
-                Length = (int)(stream.Length - startIndex);
605
-            }
606
-            byte[] buffer = new byte[Length];
607
-            stream.Position = startIndex;
608
-            stream.Read(buffer, 0, Length);
609
-            stream.Close();
610
-            stream.Dispose();
611
-            return buffer;
612
-        }
613
-        #endregion
614
-
615
-        #region 将文件读取到字符串中
616
-        /// <summary>  
617
-        /// 将文件读取到字符串中  
618
-        /// </summary>  
619
-        /// <param name="filePath">文件的绝对路径</param>  
620
-        public static string FileToString(string filePath)
621
-        {
622
-            //return FileToString(filePath, Encoding.Default); 
623
-            return FileToString(filePath, Encoding.UTF8);
624
-        }
625
-        /// <summary>  
626
-        /// 将文件读取到字符串中  
627
-        /// </summary>  
628
-        /// <param name="filePath">文件的绝对路径</param>  
629
-        /// <param name="encoding">字符编码</param>  
630
-        public static string FileToString(string filePath, Encoding encoding)
631
-        {
632
-            //创建流读取器  
633
-            StreamReader reader = new StreamReader(filePath, encoding);
634
-            try
635
-            {
636
-                //读取流  
637
-                return reader.ReadToEnd();
638
-            }
639
-            catch
640
-            {
641
-                return string.Empty;
642
-            }
643
-            finally
644
-            {
645
-                //关闭流读取器  
646
-                reader.Close();
647
-            }
648
-        }
649
-        /// <summary>
650
-        /// 读取大文件用,读取文件前面指定长度字节的字符串
651
-        /// </summary>
652
-        /// <param name="filePath">文件路径</param>
653
-        /// <param name="Length">读取长度,单位字节</param>
654
-        /// <returns></returns>
655
-        public static string ReadBigFileStr(string filePath, int Length)
656
-        {
657
-            byte[] buffer = ReadBigFile(filePath, Length);
658
-            return Encoding.Default.GetString(buffer);
659
-        }
660
-
661
-        #endregion
662
-
663
-        #region 从文件的绝对路径中获取文件名( 包含扩展名 )
664
-        /// <summary>  
665
-        /// 从文件的绝对路径中获取文件名( 包含扩展名 )  
666
-        /// </summary>  
667
-        /// <param name="filePath">文件的绝对路径</param>          
668
-        public static string GetFileName(string filePath)
669
-        {
670
-            //获取文件的名称  
671
-            FileInfo fi = new FileInfo(filePath);
672
-            return fi.Name;
673
-        }
674
-        /// <summary>  
675
-        /// 使用IO从文件的绝对路径中获取文件名( 包含扩展名 )  
676
-        /// </summary>  
677
-        /// <param name="filePath">文件的绝对路径</param>          
678
-        public static string GetIOFileName(string filePath)
679
-        {
680
-            return Path.GetFileName(filePath);
681
-        }
682
-        #endregion
683
-
684
-        #region 从文件的绝对路径中获取文件名( 不包含扩展名 )
685
-        /// <summary>  
686
-        /// 从文件的绝对路径中获取文件名( 不包含扩展名 )  
687
-        /// </summary>  
688
-        /// <param name="filePath">文件的绝对路径</param>          
689
-        public static string GetFileNameNoExtension(string filePath)
690
-        {
691
-            //获取文件的名称  
692
-            FileInfo fi = new FileInfo(filePath);
693
-            return fi.Name.Split('.')[0];
694
-        }
695
-        /// <summary>  
696
-        /// 使用IO从文件的绝对路径中获取文件名( 不包含扩展名 )  
697
-        /// </summary>  
698
-        /// <param name="filePath">文件的绝对路径</param>          
699
-        public static string GetIOFileNameNoExtension(string filePath)
700
-        {
701
-            return System.IO.Path.GetFileNameWithoutExtension(filePath);
702
-        }
703
-        #endregion
704
-
705
-        #region 从文件的绝对路径中获取扩展名
706
-        /// <summary>  
707
-        /// 从文件的绝对路径中获取扩展名  
708
-        /// </summary>  
709
-        /// <param name="filePath">文件的绝对路径</param>          
710
-        public static string GetExtension(string filePath)
711
-        {
712
-            //获取文件的名称  
713
-            FileInfo fi = new FileInfo(filePath);
714
-            return fi.Extension;
715
-        }
716
-        /// <summary>  
717
-        /// 使用IO从文件的绝对路径中获取扩展名 
718
-        /// </summary>  
719
-        /// <param name="filePath">文件的绝对路径</param>          
720
-        public static string GetIOExtension(string filePath)
721
-        {
722
-            string Extension = System.IO.Path.GetExtension(filePath);
723
-            return Extension;
724
-        }
725
-
726
-        #endregion
727
-
728
-        #region 从文件的绝对路径中获取路径名
729
-        /// <summary>  
730
-        /// 使用IO从文件的绝对路径中获取路径名  
731
-        /// </summary>  
732
-        /// <param name="filePath">文件的绝对路径</param>          
733
-        public static string GetDirectoryName(string filePath)
734
-        {
735
-            string DirectoryName = (System.IO.Path.GetDirectoryName(filePath) + @"/").Replace("\\", "/");
736
-            return DirectoryName;
737
-        }
738
-        #endregion
739
-
740
-        #region 清空指定目录
741
-        /// <summary>  
742
-        /// 清空指定目录下所有文件及子目录,但该目录依然保存.  
743
-        /// </summary>  
744
-        /// <param name="directoryPath">指定目录的绝对路径</param>  
745
-        public static void ClearDirectory(string directoryPath)
746
-        {
747
-            if (IsExistDirectory(directoryPath))
748
-            {
749
-                //删除目录中所有的文件  
750
-                string[] fileNames = GetFileNames(directoryPath);
751
-                foreach (string t in fileNames)
752
-                {
753
-                    DeleteFile(t);
754
-                }
755
-
756
-                //删除目录中所有的子目录  
757
-                string[] directoryNames = GetDirectories(directoryPath);
758
-                foreach (string t in directoryNames)
759
-                {
760
-                    DeleteDirectory(t);
761
-                }
762
-            }
763
-        }
764
-        #endregion
765
-
766
-        #region 清空文件内容
767
-        /// <summary>  
768
-        /// 清空文件内容  
769
-        /// </summary>  
770
-        /// <param name="filePath">文件的绝对路径</param>  
771
-        public static void ClearFile(string filePath)
772
-        {
773
-            //删除文件  
774
-            File.Delete(filePath);
775
-
776
-            //重新创建该文件  
777
-            CreateFile(filePath);
778
-        }
779
-        #endregion
780
-
781
-        #region 删除指定文件
782
-        /// <summary>  
783
-        /// 删除指定文件  
784
-        /// </summary>  
785
-        /// <param name="filePath">文件的绝对路径</param>  
786
-        public static void DeleteFile(string filePath)
787
-        {
788
-            try
789
-            {
790
-                if (IsExistFile(filePath))
791
-                {
792
-                    File.Delete(filePath);
793
-                }
794
-            }
795
-            catch (Exception)
796
-            {
797
-
798
-            }
799
-        }
800
-        #endregion
801
-
802
-        #region 删除指定目录
803
-        /// <summary>  
804
-        /// 删除指定目录及其所有子目录  
805
-        /// </summary>  
806
-        /// <param name="directoryPath">指定目录的绝对路径</param>  
807
-        public static bool DeleteDirectory(string directoryPath)
808
-        {
809
-            try
810
-            {
811
-                if (IsExistDirectory(directoryPath))
812
-                {
813
-                    Directory.Delete(directoryPath, true);
814
-                }
815
-                return true;
816
-            }
817
-            catch (Exception)
818
-            {
819
-                //目录中有文件占用
820
-                return false;
821
-            }
822
-        }
823
-        #endregion
824
-
825
-        #region 获取指定目录大小
826
-        /// <summary>
827
-        /// 获取目录大小
828
-        /// </summary>
829
-        /// <param name="directoryPath">目录地址</param>
830
-        /// <returns> 单位:MB</returns>
831
-        public static double PathSize(string directoryPath)
832
-        {
833
-            DirectoryInfo folder = new DirectoryInfo(directoryPath);
834
-            double DirectorySize = DirSize(folder);
835
-            for (int i = 0; i < 2; i++)
836
-            {
837
-                DirectorySize /= 1024;
838
-            }
839
-            return DirectorySize;
840
-        }
841
-
842
-        /// <summary>
843
-        /// 获取目录大小
844
-        /// </summary>
845
-        /// <param name="d">目录</param>
846
-        /// <returns>字节</returns>
847
-        public static long DirSize(DirectoryInfo d)
848
-        {
849
-            long Size = 0;
850
-            // 所有文件大小.
851
-            FileInfo[] fis = d.GetFiles();
852
-            foreach (FileInfo fi in fis)
853
-            {
854
-                Size += fi.Length;
855
-            }
856
-            // 遍历出当前目录的所有文件夹.
857
-            DirectoryInfo[] dis = d.GetDirectories();
858
-            foreach (DirectoryInfo di in dis)
859
-            {
860
-                Size += DirSize(di);   //这就用到递归了,调用父方法,注意,这里并不是直接返回值,而是调用父返回来的
861
-            }
862
-            return (Size);
863
-        }
864
-        #endregion
865
-
866
-        #region 移动目录
867
-        /// <summary>
868
-        /// 移动目录并重命名
869
-        /// </summary>
870
-        /// <param name="directoryPath">操作目录绝对路径</param>
871
-        /// <param name="newDirectoryPath">目标目录绝对路径</param>
872
-        /// <param name="Message">返回错误消息,成功则为空</param>
873
-        /// <returns></returns>
874
-        public static bool MoveDirectory(string directoryPath, string newDirectoryPath, out string Message)
875
-        {
876
-            Message = "";
877
-            try
878
-            {
879
-                if (!IsExistDirectory(directoryPath))//判断目录是否存在
880
-                {
881
-                    Message = "操作目录不存在!";
882
-                    return false;
883
-                }
884
-                if (IsExistDirectory(newDirectoryPath))
885
-                {
886
-                    Message = "目标目录已存在!";
887
-                    return false;
888
-                }
889
-                Directory.Move(directoryPath, newDirectoryPath);
890
-                return true;
891
-            }
892
-            catch (Exception ex)
893
-            {
894
-                Message = ex.Message;
895
-                return false;
896
-            }
897
-        }
898
-        #endregion
899
-
900
-        #region 操作配置文件
901
-        #region 从配置文件获取Value
902
-        /// <summary>
903
-        /// 从配置文件获取Value
904
-        /// </summary>
905
-        /// <param name="key">配置文件中key字符串</param>
906
-        /// <returns></returns>
907
-        public static string GetConfigValue(string key)
908
-        {
909
-            try
910
-            {
911
-                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
912
-                //获取AppSettings的节点 
913
-                AppSettingsSection appsection = (AppSettingsSection)config.GetSection("appSettings");
914
-                return appsection.Settings[key].Value;
915
-            }
916
-            catch
917
-            {
918
-                return "";
919
-            }
920
-        }
921
-        #endregion
922
-
923
-        #region 设置配置文件
924
-        /// <summary>
925
-        /// 设置配置文件
926
-        /// </summary>
927
-        /// <param name="key">配置文件中key字符串</param>
928
-        /// <param name="value">配置文件中value字符串</param>
929
-        /// <returns></returns>
930
-        public static bool SetConfigValue(string key, string value)
931
-        {
932
-            try
933
-            {
934
-                //打开配置文件 
935
-                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
936
-                //获取AppSettings的节点 
937
-                AppSettingsSection appsection = (AppSettingsSection)config.GetSection("appSettings");
938
-                appsection.Settings[key].Value = value;
939
-                config.Save();
940
-
941
-                return true;
942
-            }
943
-            catch
944
-            {
945
-                return false;
946
-            }
947
-        }
948
-        #endregion
949
-        #endregion
950
-
951
-        #region 获取媒体文件的播放时长
952
-
953
-        #endregion
954
-
955
-        #region 检测是否安装了某个程序
956
-        /// <summary>  
957
-        /// 确认电脑上是否安装有某个程序 
958
-        /// </summary>  
959
-        /// <param name="softWareName">程序安装后的名称</param>
960
-        /// <returns>true: 有安裝, false:沒有安裝</returns>  
961
-        public static bool CheckSoftWartInstallState(string softWareName)
962
-        {
963
-            Microsoft.Win32.RegistryKey uninstallNode =
964
-                Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree, System.Security.AccessControl.RegistryRights.ReadKey);
965
-            foreach (string subKeyName in uninstallNode.GetSubKeyNames())
966
-            {
967
-                Microsoft.Win32.RegistryKey subKey = uninstallNode.OpenSubKey(subKeyName);
968
-                object displayName = subKey.GetValue("DisplayName");
969
-                if (displayName != null)
970
-                {
971
-                    if (displayName.ToString().Contains(softWareName))
972
-                    {
973
-                        return true;
974
-                        // MessageWindow.Show(displayName.ToString());  
975
-                    }
976
-                }
977
-            }
978
-            return false;
979
-        }
980
-        #endregion
981
-    }
982
-}

+ 0
- 60
Common/system/FreeMemoryHelper.cs Datei anzeigen

@@ -1,60 +0,0 @@
1
-using Microsoft.Win32;
2
-
3
-using System;
4
-using System.Runtime.InteropServices;
5
-
6
-namespace Common.system
7
-{
8
-    /// <summary>
9
-    /// 释放内存帮助类 创建人:赵耀 创建时间:2020年8月12日
10
-    /// </summary>
11
-    public class FreeMemoryHelper
12
-    {
13
-        [DllImport("kernel32.dll")]
14
-        private static extern bool SetProcessWorkingSetSize(IntPtr proc, int min, int max);
15
-
16
-        /// <summary>
17
-        /// Close、Hide、最小化页面时调用此方法,释放占用内存并重新分配 将暂时不需要的内容放进虚拟内存,当应用程序重新激活时,会将虚拟内存的内容重新加载到内存。
18
-        /// 不宜过度频繁的调用该方法,频繁调用会降低使使用性能。 创建人:赵耀 创建时间:2020年8月12日
19
-        /// </summary>
20
-        public static void ReallocateMemory()
21
-        {
22
-            GC.Collect();
23
-            GC.WaitForPendingFinalizers();
24
-
25
-            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
26
-            {
27
-                SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
28
-            }
29
-        }
30
-
31
-        /// <summary>
32
-        /// ---屏蔽DevExpress试用信息 与内存释放无关
33
-        /// </summary>
34
-        public static void SetDate()
35
-        {
36
-            CreateKey();
37
-            RegistryKey currentUser = Registry.CurrentUser;
38
-            RegistryKey registryKey = currentUser.OpenSubKey("SOFTWARE\\DevExpress\\Components", writable: true);
39
-            registryKey.GetValue("LastAboutShowedTime");
40
-            string value = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss");
41
-            registryKey.SetValue("LastAboutShowedTime", value);
42
-            currentUser.Dispose();
43
-        }
44
-
45
-        // 摘要: 创建键值
46
-        private static void CreateKey()
47
-        {
48
-            RegistryKey currentUser = Registry.CurrentUser;
49
-            if (currentUser.OpenSubKey("SOFTWARE\\DevExpress\\Components", writable: true) == null)
50
-            {
51
-                RegistryKey registryKey = currentUser.CreateSubKey("SOFTWARE\\DevExpress\\Components");
52
-                registryKey.CreateSubKey("LastAboutShowedTime").SetValue("LastAboutShowedTime", DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"));
53
-                registryKey.CreateSubKey("DisableSmartTag").SetValue("LastAboutShowedTime", false);
54
-                registryKey.CreateSubKey("SmartTagWidth").SetValue("LastAboutShowedTime", 350);
55
-            }
56
-
57
-            currentUser.Dispose();
58
-        }
59
-    }
60
-}

+ 0
- 631
Common/system/HttpHelper.cs Datei anzeigen

@@ -1,631 +0,0 @@
1
-using Newtonsoft.Json.Linq;
2
-
3
-using System;
4
-using System.Collections.Generic;
5
-using System.Collections.Specialized;
6
-using System.IO;
7
-using System.Net;
8
-using System.Net.Security;
9
-using System.Security.Cryptography.X509Certificates;
10
-using System.Text;
11
-using System.Threading;
12
-
13
-namespace Common.system
14
-{
15
-    /// <summary>
16
-    /// HttpHelper
17
-    /// 创建人:赵耀
18
-    /// </summary>
19
-    public class HttpHelper
20
-    {
21
-        public static void init_Request(ref System.Net.HttpWebRequest request)
22
-        {
23
-            request.Accept = "text/json,*/*;q=0.5";
24
-            request.Headers.Add("Accept-Charset", "utf-8;q=0.7,*;q=0.7");
25
-            request.Headers.Add("Accept-Encoding", "gzip, deflate, x-gzip, identity; q=0.9");
26
-            request.AutomaticDecompression = System.Net.DecompressionMethods.GZip;
27
-            request.Timeout = 8000;
28
-        }
29
-
30
-        private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
31
-        {
32
-            return true; //总是接受  
33
-        }
34
-
35
-        public static System.Net.HttpWebRequest GetHttpWebRequest(string url)
36
-        {
37
-            HttpWebRequest request = null;
38
-            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
39
-            {
40
-                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
41
-                request = WebRequest.Create(url) as HttpWebRequest;
42
-                request.ProtocolVersion = HttpVersion.Version10;
43
-            }
44
-            else
45
-            {
46
-                request = WebRequest.Create(url) as HttpWebRequest;
47
-            }
48
-            return request;
49
-        }
50
-        public static WebResponse Download(string downloadUrl, long from, long to, string method)
51
-        {
52
-            for (int i = 0; i < 10; i++)
53
-            {
54
-                try
55
-                {
56
-                    HttpWebRequest request = HttpHelper.GetHttpWebRequest(downloadUrl);
57
-                    HttpHelper.init_Request(ref request);
58
-                    request.Accept = "text/json,*/*;q=0.5";
59
-                    request.AddRange(from, to);
60
-                    request.Headers.Add("Accept-Charset", "utf-8;q=0.7,*;q=0.7");
61
-                    request.Headers.Add("Accept-Encoding", "gzip, deflate, x-gzip, identity; q=0.9");
62
-                    request.AutomaticDecompression = System.Net.DecompressionMethods.GZip;
63
-                    request.Timeout = 120000;
64
-                    request.Method = method;
65
-                    request.KeepAlive = false;
66
-                    request.ContentType = "application/json; charset=utf-8";
67
-                    return request.GetResponse();
68
-                }
69
-                catch (Exception)
70
-                {
71
-                    Thread.Sleep(100);
72
-                }
73
-            }
74
-            throw new Exception("已断开网络!请检查网络连接后重试下载!");
75
-        }
76
-        public static string Get(string url, IDictionary<string, string> param)
77
-        {
78
-            List<string> paramBuilder = new List<string>();
79
-            foreach (KeyValuePair<string, string> item in param)
80
-            {
81
-                paramBuilder.Add(string.Format("{0}={1}", item.Key, item.Value));
82
-            }
83
-            url = string.Format("{0}?{1}", url.TrimEnd('?'), string.Join(",", paramBuilder.ToArray()));
84
-            return Get(url);
85
-        }
86
-        public static string Get(string url)
87
-        {
88
-            try
89
-            {
90
-                HttpWebRequest request = GetHttpWebRequest(url);
91
-                if (request != null)
92
-                {
93
-                    string retval = null;
94
-                    init_Request(ref request);
95
-                    using (WebResponse Response = request.GetResponse())
96
-                    {
97
-                        using (StreamReader reader = new System.IO.StreamReader(Response.GetResponseStream(), System.Text.Encoding.UTF8))
98
-                        {
99
-                            retval = reader.ReadToEnd();
100
-                        }
101
-                    }
102
-                    return retval;
103
-                }
104
-            }
105
-            catch
106
-            {
107
-
108
-            }
109
-            return null;
110
-        }
111
-        public static string Post(string url, string data)
112
-        {
113
-            try
114
-            {
115
-                HttpWebRequest request = GetHttpWebRequest(url);
116
-                if (request != null)
117
-                {
118
-                    string retval = null;
119
-                    init_Request(ref request);
120
-                    request.Method = "POST";
121
-                    request.ServicePoint.Expect100Continue = false;
122
-                    request.ContentType = "application/json; charset=utf-8";
123
-                    request.Timeout = 5000;
124
-                    byte[] bytes = System.Text.UTF8Encoding.UTF8.GetBytes(data);
125
-                    request.ContentLength = bytes.Length;
126
-                    using (Stream stream = request.GetRequestStream())
127
-                    {
128
-                        stream.Write(bytes, 0, bytes.Length);
129
-                    }
130
-                    using (WebResponse response = request.GetResponse())
131
-                    {
132
-                        using (StreamReader reader = new System.IO.StreamReader(response.GetResponseStream()))
133
-                        {
134
-                            retval = reader.ReadToEnd();
135
-                        }
136
-                    }
137
-                    return retval;
138
-                }
139
-            }
140
-            catch
141
-            {
142
-
143
-            }
144
-            return null;
145
-        }
146
-
147
-        /// <summary>
148
-        ///调用Post接口
149
-        /// </summary>
150
-        /// <param name="request"></param>
151
-        /// <returns></returns>
152
-        public static string HttpPost(string body, string Url)
153
-        {
154
-            try
155
-            {
156
-                Encoding encoding = Encoding.UTF8;
157
-
158
-                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
159
-                request.Method = "POST";
160
-                request.Accept = "text/html,application/xhtml+xml,*/*";
161
-                request.ContentType = "application/json";
162
-
163
-                byte[] buffer = encoding.GetBytes(body);
164
-                request.ContentLength = buffer.Length;
165
-                request.GetRequestStream().Write(buffer, 0, buffer.Length);
166
-
167
-                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
168
-                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
169
-                {
170
-                    return reader.ReadToEnd();
171
-                }
172
-            }
173
-            catch (Exception ex)
174
-            {
175
-                // LogHelper.Instance.Debug($"POST接口连接失败,请求参数:{ex.Message}");
176
-                return "POST报错:" + ex.Message;
177
-            }
178
-        }
179
-        /// <summary>
180
-        /// Post Http请求
181
-        /// </summary>
182
-        /// <param name="url">请求地址</param>
183
-        /// <param name="postData">传输数据</param>
184
-        /// <param name="timeout">超时时间</param>
185
-        /// <param name="contentType">媒体格式</param>
186
-        /// <param name="encode">编码</param>
187
-        /// <returns>泛型集合</returns>
188
-        public static T PostAndRespSignle<T>(string url, int timeout = 5000, string postData = "", string contentType = "application/json;", string encode = "UTF-8") where T : class
189
-        {
190
-            if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(encode) && !string.IsNullOrEmpty(contentType) && postData != null)
191
-            {
192
-                // webRequest.Headers.Add("Authorization", "Bearer " + "SportApiAuthData");
193
-                HttpWebResponse webResponse = null;
194
-                Stream responseStream = null;
195
-                Stream requestStream = null;
196
-                StreamReader streamReader = null;
197
-                try
198
-                {
199
-                    string respstr = GetStreamReader(url, responseStream, requestStream, streamReader, webResponse, timeout, encode, postData, contentType);
200
-                    return JsonHelper.JsonToObj<T>(respstr);
201
-                }
202
-                catch (Exception)
203
-                {
204
-                }
205
-                finally
206
-                {
207
-                    if (responseStream != null)
208
-                    {
209
-                        responseStream.Dispose();
210
-                    }
211
-
212
-                    if (webResponse != null)
213
-                    {
214
-                        webResponse.Close();
215
-                    }
216
-
217
-                    if (requestStream != null)
218
-                    {
219
-                        requestStream.Dispose();
220
-                    }
221
-
222
-                    if (streamReader != null)
223
-                    {
224
-                        streamReader.Dispose();
225
-                    }
226
-                }
227
-            }
228
-            return default(T);
229
-        }
230
-        private static string GetStreamReader(string url, Stream responseStream, Stream requestStream, StreamReader streamReader, WebResponse webResponse, int timeout, string encode, string postData, string contentType)
231
-        {
232
-            try
233
-            {
234
-                byte[] data = Encoding.GetEncoding(encode).GetBytes(postData);
235
-                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
236
-                webRequest.Method = "POST";
237
-                webRequest.ContentType = contentType + ";" + encode;
238
-                webRequest.ContentLength = data.Length;
239
-                webRequest.Timeout = timeout;
240
-                requestStream = webRequest.GetRequestStream();
241
-                requestStream.Write(data, 0, data.Length);
242
-                webResponse = (HttpWebResponse)webRequest.GetResponse();
243
-                responseStream = webResponse.GetResponseStream();
244
-                if (responseStream == null) { return ""; }
245
-                streamReader = new StreamReader(responseStream, Encoding.GetEncoding(encode));
246
-                return streamReader.ReadToEnd();
247
-            }
248
-            catch (Exception)
249
-            {
250
-                return null;
251
-            }
252
-        }
253
-        /// <summary>
254
-        /// Cookie
255
-        /// </summary>
256
-        public static CookieContainer cc = new CookieContainer();
257
-        /// <summary>
258
-        /// Get请求
259
-        /// </summary>
260
-        /// <param name="serviceaddress">请求地址</param>
261
-        /// <param name="strcontent">头</param>
262
-        /// <param name="contenttype">参数</param>
263
-        /// <param name="header">token</param>
264
-        /// <returns></returns>
265
-        public static JObject GetFunction(string serviceaddress, string strcontent, string contenttype, string header, int Timeout = 5000)
266
-        {
267
-            try
268
-            {
269
-                string serviceAddress = serviceaddress + strcontent;
270
-                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceAddress);
271
-                WebHeaderCollection myWebHeaderCollection = request.Headers;
272
-                request.CookieContainer = cc;
273
-                if (header != "")
274
-                {
275
-                    myWebHeaderCollection.Add("access_token:" + header);
276
-                }
277
-
278
-                request.Method = "GET";
279
-                request.ContentType = contenttype;
280
-                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
281
-
282
-                string encoding = response.ContentEncoding;
283
-                if (encoding == null || encoding.Length < 1)
284
-                {
285
-                    encoding = "UTF-8"; //默认编码  
286
-                }
287
-                StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
288
-                string retString = reader.ReadToEnd();
289
-
290
-                //解析josn
291
-                JObject jo = JObject.Parse(retString);
292
-                return jo;
293
-            }
294
-            catch (Exception)
295
-            {
296
-                return null;
297
-            }
298
-        }
299
-
300
-        /// <summary>
301
-        /// Post请求
302
-        /// </summary>
303
-        /// <param name="serviceaddress">请求地址</param>
304
-        /// <param name="contenttype">头 application/x-www-form-urlencoded</param>
305
-        /// <param name="strcontent">参数</param>
306
-        /// <param name="header">token</param>
307
-        /// <returns></returns>
308
-        public static JObject PostFunction(string serviceaddress, string contenttype, string strcontent, string header, int Timeout = 5000)
309
-        {
310
-            try
311
-            {
312
-                string serviceAddress = serviceaddress;
313
-                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceAddress);
314
-                WebHeaderCollection myWebHeaderCollection = request.Headers;
315
-
316
-                request.CookieContainer = cc;
317
-                //myWebHeaderCollection.Add("Accept", "*/*");
318
-                if (header != "")
319
-                {
320
-                    myWebHeaderCollection.Add("access_token:" + header);
321
-                }
322
-                request.Timeout = Timeout;
323
-                request.Method = "POST";
324
-                request.ContentType = contenttype;
325
-
326
-                string strContent = strcontent;
327
-                using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream()))
328
-                {
329
-                    dataStream.Write(strContent);
330
-                    dataStream.Close();
331
-                }
332
-                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
333
-                string encoding = response.ContentEncoding;
334
-                if (encoding == null || encoding.Length < 1)
335
-                {
336
-                    encoding = "UTF-8"; //默认编码  
337
-                }
338
-                StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
339
-                string retString = reader.ReadToEnd();
340
-                retString = retString.Replace("\\r\\n", "");
341
-
342
-                //解析josn
343
-                JObject jo = JObject.Parse(retString);
344
-                return jo;
345
-            }
346
-            catch (Exception ex)
347
-            {
348
-                LogHelper.WriteErrLog("请求失败(若网络无问题,请重置winsock,解决方法:以管理员方式打开cmd执行 netsh winsock reset 后重启)", ex);
349
-                return null;
350
-            }
351
-
352
-        }
353
-
354
-        /// <summary>
355
-        ///  上传方法
356
-        /// </summary>
357
-        /// <param name="url">webapi地址</param>
358
-        /// <param name="files">本地文件路径,单文件默认为string[0]</param>
359
-        /// <param name="token"></param>
360
-        /// <param name="formFields">参数可不传</param>
361
-        /// <returns></returns>
362
-        public static JObject UploadFilesToRemoteUrl(string url, string[] files, string token, NameValueCollection formFields = null)
363
-        {
364
-            string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x");
365
-            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
366
-            request.ContentType = "multipart/form-data; boundary=" +
367
-                                    boundary;
368
-            request.Method = "POST";
369
-            request.KeepAlive = true;
370
-
371
-            Stream memStream = new System.IO.MemoryStream();
372
-
373
-            byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" +
374
-                                                                    boundary + "\r\n");
375
-            byte[] endBoundaryBytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" +
376
-                                                                        boundary + "--");
377
-            WebHeaderCollection myWebHeaderCollection = request.Headers;
378
-            request.CookieContainer = cc;
379
-            if (token != "")
380
-            {
381
-                myWebHeaderCollection.Add("access_token:" + token);
382
-            }
383
-
384
-            string formdataTemplate = "\r\n--" + boundary +
385
-                                        "\r\nContent-Disposition: form-data; name=\"{0}\";\r\n\r\n{1}";
386
-            if (formFields != null)
387
-            {
388
-                foreach (string key in formFields.Keys)
389
-                {
390
-                    string formitem = string.Format(formdataTemplate, key, formFields[key]);
391
-                    byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
392
-                    memStream.Write(formitembytes, 0, formitembytes.Length);
393
-                }
394
-            }
395
-
396
-            string headerTemplate =
397
-                "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n" +
398
-                "Content-Type: application/octet-stream\r\n\r\n";
399
-
400
-            for (int i = 0; i < files.Length; i++)
401
-            {
402
-                memStream.Write(boundarybytes, 0, boundarybytes.Length);
403
-                string header = string.Format(headerTemplate, "file", files[i]);
404
-                byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
405
-
406
-                memStream.Write(headerbytes, 0, headerbytes.Length);
407
-
408
-                using (FileStream fileStream = new FileStream(files[i], FileMode.Open, FileAccess.Read))
409
-                {
410
-                    byte[] buffer = new byte[1024];
411
-                    int bytesRead = 0;
412
-                    while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
413
-                    {
414
-                        memStream.Write(buffer, 0, bytesRead);
415
-                    }
416
-                }
417
-            }
418
-
419
-            //memStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
420
-            request.ContentLength = memStream.Length;
421
-
422
-            using (Stream requestStream = request.GetRequestStream())
423
-            {
424
-                memStream.Position = 0;
425
-                byte[] tempBuffer = new byte[memStream.Length];
426
-                memStream.Read(tempBuffer, 0, tempBuffer.Length);
427
-                memStream.Close();
428
-                requestStream.Write(tempBuffer, 0, tempBuffer.Length);
429
-            }
430
-
431
-            using (WebResponse response = request.GetResponse())
432
-            {
433
-                Stream stream2 = response.GetResponseStream();
434
-                StreamReader reader2 = new StreamReader(stream2);
435
-                JObject a = JObject.Parse(reader2.ReadToEnd());
436
-                return a;
437
-            }
438
-        }
439
-
440
-        /// <summary>
441
-        /// HttpWebRequest 下载
442
-        /// </summary>
443
-        /// <param name="url">URI</param>
444
-        /// <returns></returns>
445
-        public static bool GetDataGetHtml(string url, string filePath, string header)
446
-        {
447
-            try
448
-            {
449
-                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
450
-
451
-                //httpWebRequest.ContentType = "application/x-www-form-urlencoded";
452
-                httpWebRequest.Method = "GET";
453
-                //httpWebRequest.ContentType = "image/jpeg";
454
-                //对发送的数据不使用缓存
455
-                httpWebRequest.AllowWriteStreamBuffering = false;
456
-                //httpWebRequest.Timeout = 300000;
457
-                httpWebRequest.ServicePoint.Expect100Continue = false;
458
-
459
-                WebHeaderCollection myWebHeaderCollection = httpWebRequest.Headers;
460
-                //myWebHeaderCollection.Add("Accept", "*/*");
461
-                if (header != "")
462
-                {
463
-                    myWebHeaderCollection.Add("access_token:" + header);
464
-                }
465
-
466
-                HttpWebResponse webRespon = (HttpWebResponse)httpWebRequest.GetResponse();
467
-                Stream webStream = webRespon.GetResponseStream();
468
-                long length = webRespon.ContentLength;
469
-                if (webStream == null)
470
-                {
471
-                    return false;
472
-                }
473
-                int lengthint = Convert.ToInt32(length);
474
-                //int num = lengthint / 1024;
475
-                //int count = 0;
476
-                //M_DownloadInfo.totalCount = lengthint / 1024;
477
-                //M_DownloadInfo.downloadCount = 0;
478
-
479
-                Stream stream = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
480
-                byte[] bArr = new byte[1024];
481
-                int size = webStream.Read(bArr, 0, bArr.Length);
482
-                while (size > 0)
483
-                {
484
-                    stream.Write(bArr, 0, size);
485
-                    size = webStream.Read(bArr, 0, bArr.Length);
486
-                    //M_DownloadInfo.downloadCount = M_DownloadInfo.downloadCount + 1;
487
-                }
488
-                webRespon.Close();
489
-                stream.Close();
490
-                webStream.Close();
491
-                return true;
492
-            }
493
-            catch (Exception)
494
-            {
495
-                //LogHelper.WriteErrLog("请求失败:" + ex.Message, ex);
496
-                return false;
497
-            }
498
-        }
499
-
500
-        /// <summary>
501
-        /// 上传文件流
502
-        /// 创建人:赵耀
503
-        /// 创建时间:2020年9月5日
504
-        /// </summary>
505
-        /// <param name="url">URL</param>
506
-        /// <param name="databyte">文件数据流</param>
507
-        /// <param name="filename">文件名</param>
508
-        /// <param name="formFields">参数 可不传</param>
509
-        public static JObject UploadRequestflow(string url, byte[] databyte, string filename, NameValueCollection formFields = null)
510
-        {
511
-            JObject jobResult = null;
512
-            // 时间戳,用做boundary
513
-            string boundary = "-----" + DateTime.Now.Ticks.ToString("x");
514
-            byte[] boundarybytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
515
-
516
-            //根据uri创建HttpWebRequest对象
517
-            HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(new Uri(url));
518
-            httpReq.ContentType = "multipart/form-data; boundary=" + boundary;
519
-            httpReq.Method = "POST";
520
-            httpReq.KeepAlive = true;
521
-            //httpReq.Timeout = 300000;
522
-            //httpReq.AllowWriteStreamBuffering = false; //对发送的数据不使用缓存
523
-            httpReq.Credentials = CredentialCache.DefaultCredentials;
524
-
525
-            try
526
-            {
527
-                Stream postStream = httpReq.GetRequestStream();
528
-                //参数
529
-                const string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
530
-                if (formFields != null)
531
-                {
532
-                    foreach (string key in formFields.Keys)
533
-                    {
534
-                        postStream.Write(boundarybytes, 0, boundarybytes.Length);
535
-                        string formitem = string.Format(formdataTemplate, key, formFields[key]);
536
-                        byte[] formitembytes = Encoding.UTF8.GetBytes(formitem);
537
-                        postStream.Write(formitembytes, 0, formitembytes.Length);
538
-                    }
539
-                }
540
-                postStream.Write(boundarybytes, 0, boundarybytes.Length);
541
-
542
-                const string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: application/octet-stream\r\n\r\n";
543
-
544
-                //文件头
545
-                string header = string.Format(headerTemplate, "file", filename);
546
-                byte[] headerbytes = Encoding.UTF8.GetBytes(header);
547
-                postStream.Write(headerbytes, 0, headerbytes.Length);
548
-
549
-                //文件流
550
-                postStream.Write(databyte, 0, databyte.Length);
551
-
552
-                //结束边界
553
-                byte[] boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
554
-                postStream.Write(boundaryBytes, 0, boundaryBytes.Length);
555
-                postStream.Close();
556
-
557
-                //获取服务器端的响应
558
-                using (HttpWebResponse response = (HttpWebResponse)httpReq.GetResponse())
559
-                {
560
-                    Stream receiveStream = response.GetResponseStream();
561
-                    StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
562
-                    string returnValue = readStream.ReadToEnd();
563
-                    jobResult = JObject.Parse(returnValue);
564
-                    response.Close();
565
-                    readStream.Close();
566
-                    //MessageWindow.Show(returnValue);
567
-                    //LogHelper.WriteInfoLog("【文件上传】" + returnValue);
568
-                }
569
-                return jobResult;
570
-            }
571
-            catch (Exception ex)
572
-            {
573
-                LogHelper.WriteErrLog("【文件上传】" + ex.Message, ex);
574
-                return null;
575
-            }
576
-            finally
577
-            {
578
-                httpReq = null;
579
-            }
580
-        }
581
-        /// <summary>
582
-        /// Post Http请求
583
-        /// </summary>
584
-        /// <param name="url"></param>
585
-        /// <param name="postData"></param>
586
-        /// <param name="timeout"></param>
587
-        /// <param name="contentType"></param>
588
-        /// <param name="encode"></param>
589
-        /// <returns>响应流字符串</returns>
590
-        public static string PostAndRespStr(string url, string postData = "", int timeout = 5000, string contentType = "application/json;", string encode = "UTF-8")
591
-        {
592
-            if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(encode) && !string.IsNullOrEmpty(contentType) && postData != null)
593
-            {
594
-                HttpWebResponse webResponse = null;
595
-                Stream responseStream = null;
596
-                Stream requestStream = null;
597
-                StreamReader streamReader = null;
598
-                try
599
-                {
600
-                    return GetStreamReader(url, responseStream, requestStream, streamReader, webResponse, timeout, encode, postData, contentType);
601
-                }
602
-                catch (Exception)
603
-                {
604
-                }
605
-                finally
606
-                {
607
-                    if (responseStream != null)
608
-                    {
609
-                        responseStream.Dispose();
610
-                    }
611
-
612
-                    if (webResponse != null)
613
-                    {
614
-                        webResponse.Close();
615
-                    }
616
-
617
-                    if (requestStream != null)
618
-                    {
619
-                        requestStream.Dispose();
620
-                    }
621
-
622
-                    if (streamReader != null)
623
-                    {
624
-                        streamReader.Dispose();
625
-                    }
626
-                }
627
-            }
628
-            return null;
629
-        }
630
-    }
631
-}

+ 0
- 967
Common/system/ImageHelper.cs Datei anzeigen

@@ -1,967 +0,0 @@
1
-using System;
2
-using System.Drawing;
3
-using System.Drawing.Imaging;
4
-using System.IO;
5
-using System.Text;
6
-using System.Threading;
7
-using System.Windows;
8
-using System.Windows.Media;
9
-using System.Windows.Media.Imaging;
10
-
11
-namespace Common.system
12
-{
13
-    /// <summary>
14
-    /// 图片帮助类
15
-    /// 创建人:赵耀
16
-    /// 创建时间:2018年11月1日
17
-    /// </summary>
18
-    public class ImageHelper
19
-    {
20
-        /// <summary>
21
-        /// 通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件
22
-        /// </summary>
23
-        /// <param name="path">图片位置</param>
24
-        /// <returns></returns>
25
-        public static Bitmap ReadBitmapFile(string path)
26
-        {
27
-            try
28
-            {
29
-                if (File.Exists(path))
30
-                {
31
-                    FileStream fs = File.OpenRead(path); //OpenRead
32
-                    int filelength = 0;
33
-                    filelength = (int)fs.Length; //获得文件长度 
34
-                    byte[] image = new byte[filelength]; //建立一个字节数组 
35
-                    fs.Read(image, 0, filelength); //按字节流读取 
36
-                    System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
37
-                    fs.Close();
38
-                    Bitmap bit = new Bitmap(result);
39
-                    return bit;
40
-                }
41
-                else
42
-                {
43
-                    return null;
44
-                }
45
-            }
46
-            catch (Exception)
47
-            {
48
-                return null;
49
-            }
50
-        }
51
-        /// <summary>
52
-        /// 通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件
53
-        /// </summary>
54
-        /// <param name="path">图片位置</param>
55
-        /// <returns></returns>
56
-        public static Image ReadImageFile(string path)
57
-        {
58
-            try
59
-            {
60
-                if (File.Exists(path))
61
-                {
62
-                    FileStream fs = File.OpenRead(path); //OpenRead
63
-                    int filelength = 0;
64
-                    filelength = (int)fs.Length; //获得文件长度 
65
-                    byte[] image = new byte[filelength]; //建立一个字节数组 
66
-                    fs.Read(image, 0, filelength); //按字节流读取 
67
-                    System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
68
-                    fs.Close();
69
-                    return result;
70
-                }
71
-                else
72
-                {
73
-                    return null;
74
-                }
75
-            }
76
-            catch (Exception)
77
-            {
78
-                return null;
79
-            }
80
-        }
81
-        #region 截屏指定UI控件
82
-        /// <summary>
83
-        /// 保存图片
84
-        /// </summary>
85
-        /// <param name="ui">需要截图的UI控件</param>
86
-        /// <param name="filePathName">图片保存地址 命名 1.png</param>
87
-        /// <param name="width">保存宽</param>
88
-        /// <param name="height">保存高</param>
89
-        public static void SaveUIToImage(FrameworkElement ui, string filePathName, int width, int height)
90
-        {
91
-            try
92
-            {
93
-                System.IO.FileStream fs = new System.IO.FileStream(filePathName, System.IO.FileMode.Create);
94
-                //在位图中呈现UI元素
95
-                RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, 96d, 96d,
96
-                System.Windows.Media.PixelFormats.Pbgra32);
97
-                bmp.Render(ui);
98
-                BitmapEncoder encoder = new PngBitmapEncoder();
99
-                encoder.Frames.Add(BitmapFrame.Create(bmp));
100
-                encoder.Save(fs);
101
-                fs.Close();
102
-            }
103
-            catch (Exception ex)
104
-            {
105
-                LogHelper.WriteErrLog("【UI生成图片】(SaveUIToImage)" + ex.Message, ex);
106
-                //Console.WriteLine(ex.Message);
107
-            }
108
-        }
109
-        #endregion
110
-        /// <summary>
111
-        /// 通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件
112
-        /// </summary>
113
-        /// <param name="path">图片位置</param>
114
-        /// <returns></returns>
115
-        public static BitmapImage ReadBitmapImageFile(string path)
116
-        {
117
-            BitmapImage bitmap = new BitmapImage();
118
-            try
119
-            {
120
-                using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(path)))
121
-                {
122
-                    bitmap = new BitmapImage
123
-                    {
124
-                        DecodePixelHeight = 100
125
-                    };
126
-                    bitmap.BeginInit();
127
-                    bitmap.CacheOption = BitmapCacheOption.OnLoad;//设置缓存模式
128
-                    bitmap.StreamSource = ms;//通过StreamSource加载图片
129
-                    bitmap.EndInit();
130
-                    bitmap.Freeze();
131
-                }
132
-                return bitmap;
133
-            }
134
-            catch (Exception)
135
-            {
136
-                return null;
137
-            }
138
-        }
139
-        #region 获取RGB
140
-
141
-        private static Bitmap _Bitmap = null;
142
-        private static StringBuilder sb = new StringBuilder();
143
-
144
-        public static string GetRGB(int x, int y)
145
-        {
146
-            sb = new StringBuilder();
147
-            try
148
-            {
149
-                System.Drawing.Color color = _Bitmap.GetPixel(x, y);
150
-
151
-                sb.Append("RGB:(");
152
-                sb.Append(color.R.ToString());
153
-                sb.Append(",");
154
-                sb.Append(color.G.ToString());
155
-                sb.Append(",");
156
-                sb.Append(color.B.ToString());
157
-                sb.Append(")");
158
-            }
159
-            catch (Exception ex)
160
-            {
161
-                LogHelper.WriteErrLog("ImageHelper(GetRGB)" + ex.Message, ex);
162
-            }
163
-
164
-            return sb.ToString();
165
-        }
166
-
167
-        #endregion 获取RGB
168
-
169
-        #region 截图统一方法
170
-        /// <summary>
171
-        /// 截图通用方法 创建人:赵耀 创建时间:2020年8月11日
172
-        /// </summary>
173
-        /// <param name="ScreenSize">截图的区域,设置new Rectangle(0, 0, 0, 0)为截全屏</param>
174
-        /// <param name="ImageSavePath">图片存储路径,为空或null则保存到临时文件夹</param>
175
-        /// <param name="IsRetImg">是否返回图片</param>
176
-        /// <param name="bitmapimg">图片</param>
177
-        /// <param name="level">压缩等级,0到100,0 最差质量,100 最佳</param>
178
-        /// <returns></returns>
179
-        public static bool GetScreenshot(Rectangle ScreenSize, string ImageSavePath, bool IsRetImg, out BitmapImage bitmapimg, long level = -1)
180
-        {
181
-            bitmapimg = null;
182
-            try
183
-            {
184
-                System.Drawing.Size bounds = PrimaryScreen.DESKTOP;
185
-                if (string.IsNullOrEmpty(ImageSavePath))
186
-                {
187
-                    ImageSavePath = GetTempImagePath();//如果为空则指定临时存储路径
188
-                }
189
-                double scaleWidth = (bounds.Width * 1.0) / SystemParameters.PrimaryScreenWidth;
190
-                double scaleHeight = (bounds.Height * 1.0) / SystemParameters.PrimaryScreenHeight;
191
-                int width = bounds.Width;
192
-                int height = bounds.Height;
193
-                if (ScreenSize.Size != new System.Drawing.Size(0, 0))
194
-                {
195
-                    width = (int)(ScreenSize.Size.Width * scaleWidth);
196
-                    height = (int)(ScreenSize.Size.Height * scaleHeight);
197
-                }
198
-                int l = (int)(ScreenSize.X * scaleWidth);
199
-                int t = (int)(ScreenSize.Y * scaleHeight);
200
-                if (_Bitmap != null)
201
-                {
202
-                    _Bitmap.Dispose();
203
-                }
204
-                _Bitmap = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
205
-                using (Graphics g = Graphics.FromImage(_Bitmap))
206
-                {
207
-                    g.CopyFromScreen(l, t, 0, 0, _Bitmap.Size, CopyPixelOperation.SourceCopy);
208
-                    Compress(_Bitmap, ImageSavePath, level);
209
-                }
210
-                if (IsRetImg)
211
-                {
212
-
213
-                    Uri uri = new Uri(ImageSavePath, UriKind.Absolute);
214
-                    bitmapimg = new BitmapImage(uri);
215
-                }
216
-                GC.Collect();
217
-                return true;
218
-            }
219
-            catch (Exception ex)
220
-            {
221
-                LogHelper.WriteErrLog("【截图】(GetBitmapSource)截图失败," + ex.Message, ex);
222
-                return false;
223
-            }
224
-        }
225
-        /// <summary>
226
-        /// 获取临时图片保存位置
227
-        /// </summary>
228
-        /// <returns></returns>
229
-        public static string GetTempImagePath()
230
-        {
231
-            TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
232
-
233
-            string TempPath = FileToolsCommon.GetFileAbsolutePath("/temp/Screenshot/");
234
-            FileToolsCommon.CreateDirectory(TempPath);
235
-            TempPath += Convert.ToInt64(ts.TotalMilliseconds).ToString() + ".jpg";
236
-            return TempPath;
237
-        }
238
-        #endregion 截图统一方法
239
-
240
-        #region 图片压缩
241
-
242
-        /// <summary>
243
-        /// 图片压缩(降低质量以减小文件的大小) 创建人:赵耀 创建时间:2020年8月11日
244
-        /// </summary>
245
-        /// <param name="srcBitMap">传入的Bitmap对象</param>
246
-        /// <param name="destFile">压缩后的图片保存路径</param>
247
-        /// <param name="level">压缩等级,-1为config配置的值,0到100,0 最差质量,100 最佳</param>
248
-        public static void Compress(Bitmap srcBitMap, string destFile, long level)
249
-        {
250
-            if (level <= -1)
251
-            {
252
-                int ImageCompressionLevel = int.Parse(FileToolsCommon.GetConfigValue("ImageCompressionLevel"));
253
-                level = ImageCompressionLevel;
254
-            }
255
-            Stream s = new FileStream(destFile, FileMode.Create);
256
-            Compress(srcBitMap, s, level);
257
-            s.Close();
258
-        }
259
-
260
-        /// <summary>
261
-        /// 图片压缩(降低质量以减小文件的大小) 创建人:赵耀 创建时间:2020年8月11日
262
-        /// </summary>
263
-        /// <param name="srcBitmap">传入的Bitmap对象</param>
264
-        /// <param name="destStream">压缩后的Stream对象</param>
265
-        /// <param name="level">压缩等级,0到100,0 最差质量,100 最佳</param>
266
-        public static void Compress(Bitmap srcBitmap, Stream destStream, long level)
267
-        {
268
-            ImageCodecInfo myImageCodecInfo;
269
-            System.Drawing.Imaging.Encoder myEncoder;
270
-            EncoderParameter myEncoderParameter;
271
-            EncoderParameters myEncoderParameters;
272
-
273
-            //获取表示jpeg编解码器的imagecodecinfo对象
274
-            myImageCodecInfo = GetEncoderInfo("image/jpeg");
275
-
276
-            myEncoder = System.Drawing.Imaging.Encoder.Quality;
277
-
278
-            myEncoderParameters = new EncoderParameters(1);
279
-
280
-            myEncoderParameter = new EncoderParameter(myEncoder, level);
281
-            myEncoderParameters.Param[0] = myEncoderParameter;
282
-            srcBitmap.Save(destStream, myImageCodecInfo, myEncoderParameters);
283
-        }
284
-
285
-        /// <summary>
286
-        /// 获取解码器 创建人:赵耀 创建时间2020年8月11日
287
-        /// </summary>
288
-        /// <param name="mimeType"></param>
289
-        /// <returns></returns>
290
-        private static ImageCodecInfo GetEncoderInfo(string mimeType)
291
-        {
292
-            int j;
293
-            ImageCodecInfo[] encoders;
294
-            encoders = ImageCodecInfo.GetImageEncoders();
295
-            for (j = 0; j < encoders.Length; ++j)
296
-            {
297
-                if (encoders[j].MimeType == mimeType)
298
-                {
299
-                    return encoders[j];
300
-                }
301
-            }
302
-            return null;
303
-        }
304
-
305
-        /// <summary>
306
-        /// 压缩图片 -测试方法 待完善 暂无用
307
-        /// </summary>
308
-        /// <param name="_bitmap">原图片</param>
309
-        /// <param name="dFile">压缩后保存图片地址</param>
310
-        /// <param name="flag">压缩质量(数字越小压缩率越高)1-100</param>
311
-        /// <param name="size">压缩后图片的最大大小</param>
312
-        /// <param name="sfsc">是否是第一次调用</param>
313
-        /// <returns></returns>
314
-        public static bool CompressImage(Bitmap _bitmap, string dFile, int flag = 90, int size = 300)
315
-        {
316
-            ////如果是第一次调用,原始图像的大小小于要压缩的大小,则直接复制文件,并且返回true
317
-            //FileInfo firstFileInfo = new FileInfo(sFile);
318
-            //if (sfsc == true && firstFileInfo.Length < size * 1024)
319
-            //{
320
-            //    firstFileInfo.CopyTo(dFile);
321
-            //    return true;
322
-            //}
323
-            //Image iSource = Image.FromFile(sFile);
324
-            Image iSource = _bitmap;
325
-            ImageFormat tFormat = iSource.RawFormat;
326
-            int dHeight = iSource.Height / 2;
327
-            int dWidth = iSource.Width / 2;
328
-            int sW, sH;
329
-            //按比例缩放
330
-            System.Drawing.Size tem_size = new System.Drawing.Size(iSource.Width, iSource.Height);
331
-            if (tem_size.Width > dHeight || tem_size.Width > dWidth)
332
-            {
333
-                if ((tem_size.Width * dHeight) > (tem_size.Width * dWidth))
334
-                {
335
-                    sW = dWidth;
336
-                    sH = (dWidth * tem_size.Height) / tem_size.Width;
337
-                }
338
-                else
339
-                {
340
-                    sH = dHeight;
341
-                    sW = (tem_size.Width * dHeight) / tem_size.Height;
342
-                }
343
-            }
344
-            else
345
-            {
346
-                sW = tem_size.Width;
347
-                sH = tem_size.Height;
348
-            }
349
-
350
-            Bitmap ob = new Bitmap(dWidth, dHeight);
351
-            Graphics g = Graphics.FromImage(ob);
352
-
353
-            g.Clear(System.Drawing.Color.WhiteSmoke);
354
-            g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
355
-            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
356
-            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
357
-
358
-            g.DrawImage(iSource, new Rectangle((dWidth - sW) / 2, (dHeight - sH) / 2, sW, sH), 0, 0, iSource.Width, iSource.Height, GraphicsUnit.Pixel);
359
-
360
-            g.Dispose();
361
-
362
-            //以下代码为保存图片时,设置压缩质量
363
-            EncoderParameters ep = new EncoderParameters();
364
-            long[] qy = new long[1];
365
-            qy[0] = flag;//设置压缩的比例1-100
366
-            EncoderParameter eParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, qy);
367
-            ep.Param[0] = eParam;
368
-
369
-            try
370
-            {
371
-                ImageCodecInfo[] arrayICI = ImageCodecInfo.GetImageEncoders();
372
-                ImageCodecInfo jpegICIinfo = null;
373
-                for (int x = 0; x < arrayICI.Length; x++)
374
-                {
375
-                    if (arrayICI[x].FormatDescription.Equals("JPEG"))
376
-                    {
377
-                        jpegICIinfo = arrayICI[x];
378
-                        break;
379
-                    }
380
-                }
381
-                if (jpegICIinfo != null)
382
-                {
383
-                    if (flag > 0)
384
-                    {
385
-                        ob.Save(dFile, jpegICIinfo, ep);//dFile是压缩后的新路径
386
-                        FileInfo fi = new FileInfo(dFile);
387
-                        if (fi.Length > 1024 * size)
388
-                        {
389
-                            flag -= 10;
390
-                            CompressImage(_bitmap, dFile, flag, size);
391
-                        }
392
-                    }
393
-                    //ob.Save(dFile, jpegICIinfo, ep);
394
-                    //FileInfo fi = new FileInfo(dFile);
395
-                    //bool IsAgain = false;
396
-                    //if (fi.Length > 1024 * size)
397
-                    //{
398
-                    //    fi.CopyTo(dFile + fi.Length);
399
-                    //    fi.Delete();
400
-                    //    Bitmap newbitmap = ReadImageFile(dFile + fi.Length);
401
-                    //    CompressImage(newbitmap, dFile, flag, size);
402
-                    //    FileToolsCommon.DeleteFile(dFile + fi.Length);
403
-                    //}
404
-                }
405
-                else
406
-                {
407
-                    ob.Save(dFile, tFormat);
408
-                }
409
-                return true;
410
-            }
411
-            catch
412
-            {
413
-                return false;
414
-            }
415
-            finally
416
-            {
417
-                iSource.Dispose();
418
-                ob.Dispose();
419
-            }
420
-        }
421
-        #endregion 图片压缩
422
-
423
-        #region 截屏指定UI控件
424
-        /// <summary>
425
-        /// 保存图片
426
-        /// </summary>
427
-        /// <param name="ui">需要截图的UI控件</param>
428
-        /// <param name="filePathName">图片保存地址 命名 1.png</param>
429
-        /// <param name="width">图片宽</param>
430
-        /// <param name="height">图片高</param>
431
-        /// <param name="ImgWidth">转换后高</param>
432
-        /// <param name="ImgHeight">转换后高</param>
433
-        public static void SaveUI(FrameworkElement ui, string filePathName, int width, int height, int ImgWidth, int ImgHeight)
434
-        {
435
-            try
436
-            {
437
-                //在位图中呈现UI元素
438
-                RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
439
-                bmp.Render(ui);
440
-
441
-                //定义切割矩形
442
-                var cut = new Int32Rect(0, 0, width, height);
443
-                //计算Stride
444
-                var stride = bmp.Format.BitsPerPixel * cut.Width / 8;
445
-                //声明字节数组
446
-                byte[] data = new byte[cut.Height * stride];
447
-
448
-                //调用CopyPixels
449
-                bmp.CopyPixels(cut, data, stride, 0);
450
-                new Thread(new ThreadStart(new Action(() =>
451
-                {
452
-                    BitmapSource bitmapSource = BitmapSource.Create(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Bgr32, null, data, stride);
453
-
454
-                    BitmapEncoder encoder = new PngBitmapEncoder();
455
-                    encoder.Frames.Add(BitmapFrame.Create(bitmapSource));
456
-                    if (ImgWidth > 0)
457
-                    {
458
-                        Bitmap Img = new Bitmap(ImgWidth, ImgHeight);
459
-                        try
460
-                        {
461
-                            //MemoryStream memoryStream = new MemoryStream(data);
462
-                            //Bitmap bit = (Bitmap)Image.FromStream(memoryStream);
463
-
464
-                            MemoryStream memoryStream = new MemoryStream();
465
-                            encoder.Save(memoryStream);
466
-                            Bitmap bit = new Bitmap(memoryStream, true);
467
-                            if (ImgWidth - 2 < bit.Width)
468
-                            {
469
-                                try
470
-                                {
471
-                                    Graphics g = Graphics.FromImage(Img);
472
-                                    g.DrawImage(bit, new Rectangle(0, 0, ImgWidth, ImgHeight), new Rectangle(0, 0, bit.Width, bit.Height), GraphicsUnit.Pixel);
473
-                                    g.Dispose();
474
-                                }
475
-                                catch
476
-                                {
477
-                                    Img = bit;
478
-                                }
479
-                            }
480
-                            else
481
-                            {
482
-                                Img = bit;
483
-                            }
484
-                            Img.Save(filePathName);
485
-                            memoryStream.Dispose();
486
-                            Img.Dispose();
487
-                            bit.Dispose();
488
-                        }
489
-                        catch (Exception)
490
-                        {
491
-                            using (var stream = new FileStream(filePathName, FileMode.Create))
492
-                            {
493
-                                encoder.Save(stream);
494
-                            }
495
-                        }
496
-                    }
497
-                    else
498
-                    {
499
-                        using (var stream = new FileStream(filePathName, FileMode.Create))
500
-                        {
501
-                            encoder.Save(stream);
502
-                        }
503
-                    }
504
-                }))).Start();
505
-            }
506
-            catch (Exception)
507
-            {
508
-
509
-            }
510
-        }
511
-
512
-        /// <summary>
513
-        /// 保存图片
514
-        /// </summary>
515
-        /// <param name="ui">需要截图的UI控件</param>
516
-        /// <param name="filePathName">图片保存地址 命名 1.png</param>
517
-        /// <param name="width">窗口宽</param>
518
-        /// <param name="height">窗口高</param>
519
-        /// <param name="ImgWidth">图片高</param>
520
-        /// <param name="ImgHeight">图片高</param>
521
-        public static void SaveUIToImage(FrameworkElement ui, string filePathName, int width, int height, int ImgWidth, int ImgHeight)
522
-        {
523
-            try
524
-            {
525
-                //在位图中呈现UI元素
526
-                RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
527
-                bmp.Render(ui);
528
-                BitmapEncoder encoder = new PngBitmapEncoder();
529
-                encoder.Frames.Add(BitmapFrame.Create(bmp));
530
-                if (ImgWidth > 0)
531
-                {
532
-                    Bitmap Img = new Bitmap(ImgWidth, ImgHeight);
533
-                    try
534
-                    {
535
-                        MemoryStream memoryStream = new MemoryStream();
536
-                        encoder.Save(memoryStream);
537
-                        new Thread(new ThreadStart(new Action(() =>
538
-                        {
539
-                            //System.Drawing.Image img = System.Drawing.Image.FromStream(memoryStream);
540
-                            Bitmap bit = new Bitmap(memoryStream);
541
-                            if (ImgWidth - 2 < bit.Width)
542
-                            {
543
-                                try
544
-                                {
545
-                                    Graphics g = Graphics.FromImage(Img);
546
-                                    //g.InterpolationMode = InterpolationMode.HighQualityBicubic;
547
-                                    g.DrawImage(bit, new Rectangle(0, 0, ImgWidth, ImgHeight), new Rectangle(0, 0, bit.Width, bit.Height), GraphicsUnit.Pixel);
548
-                                    g.Dispose();
549
-                                }
550
-                                catch
551
-                                {
552
-                                    Img = bit;
553
-                                }
554
-                            }
555
-                            else
556
-                            {
557
-                                Img = bit;
558
-                            }
559
-                            Img.Save(filePathName);
560
-                            //Bitmap bitmap = CutImageWhitePart(Img);
561
-                            //FileToolsCommon.DeleteFile(filePathName);
562
-                            //bitmap.Save(filePathName);
563
-                            //bitmap.Dispose();
564
-                            memoryStream.Dispose();
565
-                            Img.Dispose();
566
-                            bit.Dispose();
567
-                        }))).Start();
568
-                    }
569
-                    catch (Exception)
570
-                    {
571
-
572
-                    }
573
-                }
574
-                else
575
-                {
576
-                    //SaveImageModel sim = new SaveImageModel();
577
-                    //sim.encoder = new PngBitmapEncoder();
578
-                    //sim.encoder = new PngBitmapEncoder();
579
-                    //BitmapFrame test= encoder.Frames[0];
580
-                    //sim.encoder.Frames.Add(BitmapFrame.Create(test));
581
-                    ////sim.encoder.Frames[0].CopyTo(encoder.Frames[0]);
582
-                    ////sim.encoder.CopyTo(encoder);
583
-                    ////encoder.CopyTo(sim.encoder);
584
-                    //sim.FilePath = filePathName;
585
-                    ////sim.bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
586
-                    ////bmp.CopyTo(sim.bmp);
587
-                    //Thread t1 = new Thread(SaveImage);
588
-                    //t1.Start(sim);
589
-
590
-                    System.IO.FileStream fs = new System.IO.FileStream(filePathName, System.IO.FileMode.Create);
591
-                    encoder.Save(fs);
592
-                    fs.Close();
593
-                }
594
-            }
595
-            catch (Exception ex)
596
-            {
597
-                LogHelper.WriteErrLog("【UI生成图片】(SaveUIToImage)" + ex.Message, ex);
598
-                //Console.WriteLine(ex.Message);
599
-            }
600
-        }
601
-        public static void SaveUI1(FrameworkElement ui, string filePathName, int width, int height, int ImgWidth, int ImgHeight)
602
-        {
603
-            try
604
-            {
605
-                //在位图中呈现UI元素
606
-                RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
607
-                bmp.Render(ui);
608
-
609
-                //BitmapEncoder encoder = new PngBitmapEncoder();
610
-                //encoder.Frames.Add(BitmapFrame.Create(bmp));
611
-
612
-                //BitmapSource bitmapSource= bmp.Clone();
613
-
614
-
615
-
616
-                //定义切割矩形
617
-                var cut = new Int32Rect(0, 0, width, height);
618
-                //计算Stride
619
-                var stride = bmp.Format.BitsPerPixel * cut.Width / 8;
620
-                //声明字节数组
621
-                byte[] data = new byte[cut.Height * stride];
622
-
623
-                //调用CopyPixels
624
-                bmp.CopyPixels(cut, data, stride, 0);
625
-                new Thread(new ThreadStart(new Action(() =>
626
-                {
627
-                    BitmapSource bitmapSource = BitmapSource.Create(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Bgr32, null, data, stride);
628
-
629
-                    BitmapEncoder encoder = new PngBitmapEncoder();
630
-                    encoder.Frames.Add(BitmapFrame.Create(bitmapSource));
631
-
632
-                    using (var stream = new FileStream(filePathName, FileMode.Create))
633
-                    {
634
-                        encoder.Save(stream);
635
-                    }
636
-                }))).Start();
637
-                //SaveModel saveModel = new SaveModel();
638
-                //saveModel.ImgWidth = ImgWidth;
639
-                //saveModel.ImgHeight = ImgHeight;
640
-                //saveModel.filePathName = filePathName;
641
-                //saveModel.bmp = bmp;
642
-                //saveModel.encoder =new PngBitmapEncoder();
643
-                //foreach (BitmapFrame eitem in encoder.Frames)
644
-                //{
645
-                //    saveModel.encoder = new PngBitmapEncoder();
646
-                //    saveModel.encoder.Frames.Add( eitem );
647
-                //}
648
-
649
-                //Thread myThread = new Thread(SaveImage);
650
-                //myThread.Start(saveModel);
651
-            }
652
-            catch (Exception)
653
-            {
654
-
655
-            }
656
-
657
-        }
658
-        public static void SaveImage(object model)
659
-        {
660
-            try
661
-            {
662
-                SaveModel saveModel = (SaveModel)model;
663
-                int ImgWidth = saveModel.ImgWidth;
664
-                int ImgHeight = saveModel.ImgHeight;
665
-                //BitmapEncoder encoder = saveModel.encoder;
666
-                RenderTargetBitmap bmp = saveModel.bmp;
667
-                BitmapEncoder encoder = new PngBitmapEncoder();
668
-                encoder.Frames.Add(BitmapFrame.Create(bmp));
669
-                string filePathName = saveModel.filePathName;
670
-                if (ImgWidth > 0)
671
-                {
672
-                    Bitmap Img = new Bitmap(ImgWidth, ImgHeight);
673
-                    try
674
-                    {
675
-                        MemoryStream memoryStream = new MemoryStream();
676
-                        encoder.Save(memoryStream);
677
-                        new Thread(new ThreadStart(new Action(() =>
678
-                        {
679
-                        //System.Drawing.Image img = System.Drawing.Image.FromStream(memoryStream);
680
-                        Bitmap bit = new Bitmap(memoryStream);
681
-                            if (ImgWidth - 2 < bit.Width)
682
-                            {
683
-                                try
684
-                                {
685
-                                    Graphics g = Graphics.FromImage(Img);
686
-                                //g.InterpolationMode = InterpolationMode.HighQualityBicubic;
687
-                                g.DrawImage(bit, new Rectangle(0, 0, ImgWidth, ImgHeight), new Rectangle(0, 0, bit.Width, bit.Height), GraphicsUnit.Pixel);
688
-                                    g.Dispose();
689
-                                }
690
-                                catch
691
-                                {
692
-                                    Img = bit;
693
-                                }
694
-                            }
695
-                            else
696
-                            {
697
-                                Img = bit;
698
-                            }
699
-                            Img.Save(filePathName);
700
-                        //Bitmap bitmap = CutImageWhitePart(Img);
701
-                        //FileToolsCommon.DeleteFile(filePathName);
702
-                        //bitmap.Save(filePathName);
703
-                        //bitmap.Dispose();
704
-                        memoryStream.Dispose();
705
-                            Img.Dispose();
706
-                            bit.Dispose();
707
-                        }))).Start();
708
-                    }
709
-                    catch (Exception)
710
-                    {
711
-
712
-                    }
713
-                }
714
-                else
715
-                {
716
-                    //SaveImageModel sim = new SaveImageModel();
717
-                    //sim.encoder = new PngBitmapEncoder();
718
-                    //sim.encoder = new PngBitmapEncoder();
719
-                    //BitmapFrame test= encoder.Frames[0];
720
-                    //sim.encoder.Frames.Add(BitmapFrame.Create(test));
721
-                    ////sim.encoder.Frames[0].CopyTo(encoder.Frames[0]);
722
-                    ////sim.encoder.CopyTo(encoder);
723
-                    ////encoder.CopyTo(sim.encoder);
724
-                    //sim.FilePath = filePathName;
725
-                    ////sim.bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
726
-                    ////bmp.CopyTo(sim.bmp);
727
-                    //Thread t1 = new Thread(SaveImage);
728
-                    //t1.Start(sim);
729
-
730
-                    System.IO.FileStream fs = new System.IO.FileStream(filePathName, System.IO.FileMode.Create);
731
-                    encoder.Save(fs);
732
-                    fs.Close();
733
-                }
734
-            }
735
-            catch (Exception)
736
-            {
737
-
738
-            }
739
-        }
740
-        /// <summary>
741
-        /// 截图转换成bitmap
742
-        /// </summary>
743
-        /// <param name="element"></param>
744
-        /// <param name="width">默认控件宽度</param>
745
-        /// <param name="height">默认控件高度</param>
746
-        /// <param name="x">默认0</param>
747
-        /// <param name="y">默认0</param>
748
-        /// <returns></returns>
749
-        public static Bitmap ToBitmap(FrameworkElement element, string filePathName, int width = 0, int height = 0, int x = 0, int y = 0)
750
-        {
751
-            if (width == 0) width = (int)element.ActualWidth;
752
-            if (height == 0) height = (int)element.ActualHeight;
753
-
754
-            var rtb = new RenderTargetBitmap(width, height, x, y, System.Windows.Media.PixelFormats.Default);
755
-            rtb.Render(element);
756
-            var bit = BitmapSourceToBitmap(rtb);
757
-
758
-            //测试代码
759
-            DirectoryInfo d = new DirectoryInfo(System.IO.Path.Combine(Directory.GetCurrentDirectory(), "Cache"));
760
-            if (!d.Exists) d.Create();
761
-            bit.Save(System.IO.Path.Combine(d.FullName, "控件截图.png"));
762
-
763
-            return bit;
764
-        }
765
-
766
-        /// <summary>
767
-        /// BitmapSource转Bitmap
768
-        /// </summary>
769
-        /// <param name="source"></param>
770
-        /// <returns></returns>
771
-        public static Bitmap BitmapSourceToBitmap(BitmapSource source)
772
-        {
773
-            return BitmapSourceToBitmap(source, source.PixelWidth, source.PixelHeight);
774
-        }
775
-
776
-        /// <summary>
777
-        /// Convert BitmapSource to Bitmap
778
-        /// </summary>
779
-        /// <param name="source"></param>
780
-        /// <returns></returns>
781
-        public static Bitmap BitmapSourceToBitmap(BitmapSource source, int width, int height)
782
-        {
783
-            Bitmap bmp = null;
784
-            try
785
-            {
786
-                System.Drawing.Imaging.PixelFormat format = System.Drawing.Imaging.PixelFormat.Format24bppRgb;
787
-                /*set the translate type according to the in param(source)*/
788
-                switch (source.Format.ToString())
789
-                {
790
-                    case "Rgb24":
791
-                    case "Bgr24": format = System.Drawing.Imaging.PixelFormat.Format24bppRgb; break;
792
-                    case "Bgra32": format = System.Drawing.Imaging.PixelFormat.Format32bppPArgb; break;
793
-                    case "Bgr32": format = System.Drawing.Imaging.PixelFormat.Format32bppRgb; break;
794
-                    case "Pbgra32": format = System.Drawing.Imaging.PixelFormat.Format32bppArgb; break;
795
-                }
796
-                bmp = new Bitmap(width, height, format);
797
-                BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size),
798
-                    ImageLockMode.WriteOnly,
799
-                    format);
800
-                source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
801
-                bmp.UnlockBits(data);
802
-            }
803
-            catch
804
-            {
805
-                if (bmp != null)
806
-                {
807
-                    bmp.Dispose();
808
-                    bmp = null;
809
-                }
810
-            }
811
-
812
-            return bmp;
813
-        }
814
-        private static void SaveImage1(object obj)
815
-        {
816
-            SaveImageModel sim = (SaveImageModel)obj;
817
-            //RenderTargetBitmap bmp = sim.bmp;
818
-            //BitmapEncoder encoder = new PngBitmapEncoder();
819
-            //encoder.Frames.Add(BitmapFrame.Create(bmp));
820
-            BitmapEncoder encoder = sim.encoder;
821
-            string filePathName = sim.FilePath;
822
-            System.IO.FileStream fs = new System.IO.FileStream(filePathName, System.IO.FileMode.Create);
823
-            encoder.Save(fs);
824
-            fs.Close();
825
-        }
826
-
827
-        #endregion
828
-
829
-        #region 去掉白边
830
-        /// <summary>
831
-        /// 裁剪图片(去掉白边)
832
-        /// </summary>
833
-        /// <param name="FilePath"></param>
834
-        public static Bitmap CutImageWhitePart(Bitmap bmp)
835
-        {
836
-            //Bitmap bmp = new Bitmap(FilePath);
837
-            //上左右下
838
-            int top = 0, left = 0, right = bmp.Width, bottom = bmp.Height;
839
-
840
-            //寻找最上面的标线,从左(0)到右,从上(0)到下
841
-            for (int i = 0; i < bmp.Height; i++)//行
842
-            {
843
-                bool find = false;
844
-                for (int j = 0; j < bmp.Width; j++)//列
845
-                {
846
-                    System.Drawing.Color c = bmp.GetPixel(j, i);
847
-                    if (!IsWhite(c))
848
-                    {
849
-                        top = i;
850
-                        find = true;
851
-                        break;
852
-                    }
853
-                }
854
-                if (find)
855
-                {
856
-                    break;
857
-                }
858
-            }
859
-            //寻找最左边的标线,从上(top位)到下,从左到右
860
-            for (int i = 0; i < bmp.Width; i++)//列
861
-            {
862
-                bool find = false;
863
-                for (int j = top; j < bmp.Height; j++)//行
864
-                {
865
-                    System.Drawing.Color c = bmp.GetPixel(i, j);
866
-                    if (!IsWhite(c))
867
-                    {
868
-                        left = i;
869
-                        find = true;
870
-                        break;
871
-                    }
872
-                }
873
-                if (find)
874
-                {
875
-                    break;
876
-                }
877
-            }
878
-            //寻找最下边标线,从下到上,从左到右
879
-            for (int i = bmp.Height - 1; i >= 0; i--)//行
880
-            {
881
-                bool find = false;
882
-                for (int j = left; j < bmp.Width; j++)//列
883
-                {
884
-                    System.Drawing.Color c = bmp.GetPixel(j, i);
885
-                    if (!IsWhite(c))
886
-                    {
887
-                        bottom = i;
888
-                        find = true;
889
-                        break;
890
-                    }
891
-                }
892
-                if (find)
893
-                {
894
-                    break;
895
-                }
896
-            }
897
-            //寻找最右边的标线,从上到下,从右往左
898
-            for (int i = bmp.Width - 1; i >= 0; i--)//列
899
-            {
900
-                bool find = false;
901
-                for (int j = 0; j <= bottom; j++)//行
902
-                {
903
-                    System.Drawing.Color c = bmp.GetPixel(i, j);
904
-                    if (!IsWhite(c))
905
-                    {
906
-                        right = i;
907
-                        find = true;
908
-                        break;
909
-                    }
910
-                }
911
-                if (find)
912
-                {
913
-                    break;
914
-                }
915
-            }
916
-
917
-            if (right - left <= 0)//zxyceshi
918
-            {
919
-                //克隆位图对象的一部分。
920
-                System.Drawing.Rectangle cloneRect = new System.Drawing.Rectangle(left, top, 1, bottom - top);
921
-                Bitmap cloneBitmap = bmp.Clone(cloneRect, bmp.PixelFormat);
922
-                bmp.Dispose();
923
-                //cloneBitmap.Save(@"d:\123.png", ImageFormat.Png);
924
-                return cloneBitmap;
925
-            }
926
-            else
927
-            {
928
-                //克隆位图对象的一部分。
929
-                System.Drawing.Rectangle cloneRect = new System.Drawing.Rectangle(left, top, right - left, bottom - top);
930
-                Bitmap cloneBitmap = bmp.Clone(cloneRect, bmp.PixelFormat);
931
-                bmp.Dispose();
932
-                //cloneBitmap.Save(@"d:\123.png", ImageFormat.Png);
933
-                return cloneBitmap;
934
-            }
935
-
936
-        }
937
-
938
-        /// <summary>
939
-        /// 判断是否白色和纯透明色(10点的容差)
940
-        /// </summary>
941
-        public static bool IsWhite(System.Drawing.Color c)
942
-        {
943
-            //纯透明也是白色,RGB都为255为纯白
944
-            if (c.A < 10 || (c.R > 245 && c.G > 245 && c.B > 245))
945
-            {
946
-                return true;
947
-            }
948
-
949
-            return false;
950
-        }
951
-        #endregion
952
-    }
953
-    public class SaveImageModel
954
-    {
955
-        public string FilePath { get; set; }
956
-        public BitmapEncoder encoder { get; set; }
957
-        //public RenderTargetBitmap bmp { get; set; }
958
-    }
959
-    public class SaveModel
960
-    {
961
-        public int ImgWidth { get; set; }
962
-        public int ImgHeight { get; set; }
963
-        public BitmapEncoder encoder { get; set; }
964
-        public string filePathName { get; set; }
965
-        public RenderTargetBitmap bmp { get; set; }
966
-    }
967
-}

+ 0
- 64
Common/system/JsonHelper.cs Datei anzeigen

@@ -1,64 +0,0 @@
1
-using Newtonsoft.Json;
2
-
3
-using System.Collections.Generic;
4
-using System.IO;
5
-
6
-namespace Common.system
7
-{
8
-    public class JsonHelper
9
-    {
10
-        #region Method
11
-
12
-        /// <summary>
13
-        /// 类对像转换成json格式
14
-        /// </summary>
15
-        /// <returns></returns>
16
-        public static string ToJson(object t)
17
-        {
18
-            return JsonConvert.SerializeObject(
19
-                t, Newtonsoft.Json.Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Include }
20
-                );
21
-        }
22
-        /// <summary>
23
-        /// 类对像转换成json格式
24
-        /// </summary>
25
-        /// <param name="t"></param>
26
-        /// <param name="HasNullIgnore">是否忽略NULL值</param>
27
-        /// <returns></returns>
28
-        public static string ToJson(object t, bool HasNullIgnore)
29
-        {
30
-            if (HasNullIgnore)
31
-            {
32
-                return JsonConvert.SerializeObject(t, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
33
-            }
34
-            else
35
-            {
36
-                return ToJson(t);
37
-            }
38
-        }
39
-
40
-        /// <summary>
41
-        /// json格式转换
42
-        /// </summary>
43
-        /// <typeparam name="T"></typeparam>
44
-        /// <param name="strJson"></param>
45
-        /// <returns></returns>
46
-        public static T JsonToObj<T>(string strJson) where T : class
47
-        {
48
-            if (strJson != null && strJson != "") { return JsonConvert.DeserializeObject<T>(strJson); }
49
-
50
-            return null;
51
-        }
52
-
53
-        internal static List<T> JsonToList<T>(string respstr)
54
-        {
55
-            JsonSerializer serializer = new JsonSerializer();
56
-            StringReader sr = new StringReader(respstr);
57
-            object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
58
-            List<T> list = o as List<T>;
59
-            return list;
60
-        }
61
-
62
-        #endregion Method
63
-    }
64
-}

+ 0
- 208
Common/system/KeyboardHookCommon.cs Datei anzeigen

@@ -1,208 +0,0 @@
1
-using System;
2
-using System.Runtime.InteropServices;
3
-using System.Windows.Forms;
4
-
5
-namespace Common.system
6
-{
7
-    /// <summary>
8
-    /// 键盘钩子
9
-    /// 创建人:赵耀
10
-    /// 创建时间:2020年9月11日
11
-    /// </summary>
12
-    public class KeyboardHookCommon
13
-    {
14
-        /// <summary>
15
-        /// 全局按键按下
16
-        /// </summary>
17
-        public event KeyEventHandler KeyDownEvent;
18
-        /// <summary>
19
-        /// 窗口按键按下
20
-        /// </summary>
21
-        public event KeyPressEventHandler KeyPressEvent;
22
-        /// <summary>
23
-        /// 全局按键抬起
24
-        /// </summary>
25
-        public event KeyEventHandler KeyUpEvent;
26
-
27
-        public delegate int HookProc(int nCode, int wParam, IntPtr lParam);
28
-
29
-        private static int hKeyboardHook = 0; //声明键盘钩子处理的初始值
30
-                                              //值在Microsoft SDK的Winuser.h里查询
31
-        /// <summary>
32
-        /// 线程键盘钩子监听鼠标消息设为2,全局键盘监听鼠标消息设为13
33
-        /// </summary>
34
-        public const int WH_KEYBOARD_LL = 13;
35
-
36
-        /// <summary>
37
-        /// 声明KeyboardHookProcedure作为HookProc类型
38
-        /// </summary>
39
-        private HookProc KeyboardHookProcedure;
40
-
41
-        /// <summary>
42
-        /// 自己创建窗口按键 
43
-        /// </summary>
44
-        private const int WM_KEYDOWN = 0x100;//KEYDOWN
45
-        /// <summary>
46
-        /// 窗口按键抬起
47
-        /// </summary>
48
-        private const int WM_KEYUP = 0x101;//KEYUP
49
-        /// <summary>
50
-        /// 全局系统按键
51
-        /// </summary>
52
-        private const int WM_SYSKEYDOWN = 0x104;//SYSKEYDOWN
53
-        /// <summary>
54
-        /// 全局按键抬起
55
-        /// </summary>
56
-        private const int WM_SYSKEYUP = 0x105;//SYSKEYUP
57
-
58
-        //键盘结构
59
-        [StructLayout(LayoutKind.Sequential)]
60
-        public class KeyboardHookStruct
61
-        {
62
-            public int vkCode;  //定一个虚拟键码。该代码必须有一个价值的范围1至254
63
-            public int scanCode; // 指定的硬件扫描码的关键
64
-            public int flags;  // 键标志
65
-            public int time; // 指定的时间戳记的这个讯息
66
-            public int dwExtraInfo; // 指定额外信息相关的信息
67
-        }
68
-        //使用此功能,安装了一个钩子
69
-        [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
70
-        public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);
71
-
72
-
73
-        //调用此函数卸载钩子
74
-        [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
75
-        public static extern bool UnhookWindowsHookEx(int idHook);
76
-
77
-
78
-        //使用此功能,通过信息钩子继续下一个钩子
79
-        [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
80
-        public static extern int CallNextHookEx(int idHook, int nCode, int wParam, IntPtr lParam);
81
-
82
-        // 取得当前线程编号(线程钩子需要用到)
83
-        [DllImport("kernel32.dll")]
84
-        private static extern int GetCurrentThreadId();
85
-
86
-        //使用WINDOWS API函数代替获取当前实例的函数,防止钩子失效
87
-        [DllImport("kernel32.dll")]
88
-        public static extern IntPtr GetModuleHandle(string name);
89
-
90
-        //ToAscii职能的转换指定的虚拟键码和键盘状态的相应字符或字符
91
-        [DllImport("user32")]
92
-        public static extern int ToAscii(int uVirtKey, //[in] 指定虚拟关键代码进行翻译。
93
-                                         int uScanCode, // [in] 指定的硬件扫描码的关键须翻译成英文。高阶位的这个值设定的关键,如果是(不压)
94
-                                         byte[] lpbKeyState, // [in] 指针,以256字节数组,包含当前键盘的状态。每个元素(字节)的数组包含状态的一个关键。如果高阶位的字节是一套,关键是下跌(按下)。在低比特,如果设置表明,关键是对切换。在此功能,只有肘位的CAPS LOCK键是相关的。在切换状态的NUM个锁和滚动锁定键被忽略。
95
-                                         byte[] lpwTransKey, // [out] 指针的缓冲区收到翻译字符或字符。
96
-                                         int fuState); // [in] Specifies whether a menu is active. This parameter must be 1 if a menu is active, or 0 otherwise.
97
-
98
-        //获取按键的状态
99
-        [DllImport("user32")]
100
-        public static extern int GetKeyboardState(byte[] pbKeyState);
101
-
102
-
103
-        [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
104
-        private static extern short GetKeyState(int vKey);
105
-
106
-        public void Start()
107
-        {
108
-            // 安装键盘钩子
109
-            if (hKeyboardHook == 0)
110
-            {
111
-                KeyboardHookProcedure = new HookProc(KeyboardHookProc);
112
-                hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProcedure, GetModuleHandle(System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName), 0);
113
-                //hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProcedure, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0);
114
-                //************************************
115
-                //键盘线程钩子
116
-                //SetWindowsHookEx( 2,KeyboardHookProcedure, IntPtr.Zero, GetCurrentThreadId());//指定要监听的线程idGetCurrentThreadId(),
117
-                //键盘全局钩子,需要引用空间(using System.Reflection;)
118
-                //SetWindowsHookEx( 13,MouseHookProcedure,Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]),0);
119
-                //
120
-                //关于SetWindowsHookEx (int idHook, HookProc lpfn, IntPtr hInstance, int threadId)函数将钩子加入到钩子链表中,说明一下四个参数:
121
-                //idHook 钩子类型,即确定钩子监听何种消息,上面的代码中设为2,即监听键盘消息并且是线程钩子,如果是全局钩子监听键盘消息应设为13,
122
-                //线程钩子监听鼠标消息设为7,全局钩子监听鼠标消息设为14。lpfn 钩子子程的地址指针。如果dwThreadId参数为0 或是一个由别的进程创建的
123
-                //线程的标识,lpfn必须指向DLL中的钩子子程。 除此以外,lpfn可以指向当前进程的一段钩子子程代码。钩子函数的入口地址,当钩子钩到任何
124
-                //消息后便调用这个函数。hInstance应用程序实例的句柄。标识包含lpfn所指的子程的DLL。如果threadId 标识当前进程创建的一个线程,而且子
125
-                //程代码位于当前进程,hInstance必须为NULL。可以很简单的设定其为本应用程序的实例句柄。threaded 与安装的钩子子程相关联的线程的标识符
126
-                //如果为0,钩子子程与所有的线程关联,即为全局钩子
127
-                //************************************
128
-                //如果SetWindowsHookEx失败
129
-                if (hKeyboardHook == 0)
130
-                {
131
-                    Stop();
132
-                    throw new Exception("安装键盘钩子失败");
133
-                }
134
-            }
135
-        }
136
-        public void Stop()
137
-        {
138
-            bool retKeyboard = true;
139
-
140
-
141
-            if (hKeyboardHook != 0)
142
-            {
143
-                retKeyboard = UnhookWindowsHookEx(hKeyboardHook);
144
-                hKeyboardHook = 0;
145
-            }
146
-            try
147
-            {
148
-
149
-                if (!(retKeyboard))
150
-                {
151
-                    throw new Exception("卸载钩子失败!");
152
-                }
153
-            }
154
-            catch (Exception)
155
-            {
156
-
157
-            }
158
-        }
159
-        ////接收SetWindowsHookEx返回值  
160
-        //private static int _hHookValue = 0;
161
-        private int KeyboardHookProc(int nCode, int wParam, IntPtr lParam)
162
-        {
163
-            // 侦听键盘事件
164
-            if ((nCode >= 0) && (KeyDownEvent != null || KeyUpEvent != null || KeyPressEvent != null))
165
-            {
166
-                KeyboardHookStruct MyKeyboardHookStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct));
167
-                // raise KeyDown
168
-                if (KeyDownEvent != null && (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN))
169
-                {
170
-                    Keys keyData = (Keys)MyKeyboardHookStruct.vkCode;
171
-                    KeyEventArgs e = new KeyEventArgs(keyData);
172
-                    KeyDownEvent(this, e);
173
-                }
174
-
175
-                //键盘按下
176
-                if (KeyPressEvent != null && wParam == WM_KEYDOWN)
177
-                {
178
-                    byte[] keyState = new byte[256];
179
-                    GetKeyboardState(keyState);
180
-
181
-                    byte[] inBuffer = new byte[2];
182
-                    if (ToAscii(MyKeyboardHookStruct.vkCode, MyKeyboardHookStruct.scanCode, keyState, inBuffer, MyKeyboardHookStruct.flags) == 1)
183
-                    {
184
-                        KeyPressEventArgs e = new KeyPressEventArgs((char)inBuffer[0]);
185
-                        KeyPressEvent(this, e);
186
-                    }
187
-                }
188
-
189
-                // 键盘抬起
190
-                if (KeyUpEvent != null && (wParam == WM_KEYUP || wParam == WM_SYSKEYUP))
191
-                {
192
-                    Keys keyData = (Keys)MyKeyboardHookStruct.vkCode;
193
-                    KeyEventArgs e = new KeyEventArgs(keyData);
194
-                    KeyUpEvent(this, e);
195
-                }
196
-
197
-            }
198
-            //如果返回1,则结束消息,这个消息到此为止,不再传递。
199
-            //如果返回0或调用CallNextHookEx函数则消息出了这个钩子继续往下传递,也就是传给消息真正的接受者
200
-            return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);
201
-        }
202
-        ~KeyboardHookCommon()
203
-        {
204
-            Stop();
205
-        }
206
-
207
-    }
208
-}

+ 0
- 25
Common/system/LogHelper.cs Datei anzeigen

@@ -1,25 +0,0 @@
1
-using System;
2
-
3
-namespace Common.system
4
-{
5
-    public class LogHelper
6
-    {
7
-        public static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo");
8
-        public static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror");
9
-        public static void WriteInfoLog(string info)
10
-        {
11
-            if (loginfo.IsInfoEnabled)
12
-            {
13
-                loginfo.Info(info);
14
-            }
15
-        }
16
-
17
-        public static void WriteErrLog(string info, Exception ex)
18
-        {
19
-            if (logerror.IsErrorEnabled)
20
-            {
21
-                logerror.Error("[V " + FileToolsCommon.GetConfigValue("VersionName") + "]"+info, ex);
22
-            }
23
-        }
24
-    }
25
-}

+ 0
- 95
Common/system/MouseEventCommon.cs Datei anzeigen

@@ -1,95 +0,0 @@
1
-using System.Runtime.InteropServices;
2
-
3
-namespace Common.system
4
-{
5
-    public class MouseEventCommon
6
-    {
7
-        //[DllImport("user32.dll")]
8
-        //static extern void mouse_event(MouseEventFlag flags, int dx, int dy, uint data, UIntPtr extraInfo);
9
-
10
-        [DllImport("user32")]
11
-        private static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
12
-        /// <summary>
13
-        /// 设置鼠标的坐标 
14
-        /// </summary>
15
-        /// <param name="x">横坐标</param>
16
-        /// <param name="y">纵坐标</param>
17
-        /// <returns></returns>
18
-        [DllImport("user32.dll")]
19
-        public static extern int SetCursorPos(int x, int y);
20
-
21
-        /// <summary>   
22
-        /// 获取鼠标的坐标   
23
-        /// </summary>   
24
-        /// <param name="lpPoint">传址参数,坐标point类型</param>   
25
-        /// <returns>获取成功返回真</returns>   
26
-
27
-
28
-        [DllImport("user32.dll", CharSet = CharSet.Auto)]
29
-        public static extern bool GetCursorPos(out POINT pt);
30
-
31
-        /// <summary>
32
-        /// 鼠标点击左键
33
-        /// </summary>
34
-        /// <param name="dx">坐标x</param>
35
-        /// <param name="dy">坐标Y</param>
36
-        /// <param name="data"></param>
37
-        public static void MouseLefClickEvent(int dx, int dy, int data)
38
-        {
39
-            GetCursorPos(out POINT pointRecord);
40
-            mouse_event((int)MouseEventFlag.MiddleDown, pointRecord.X, pointRecord.Y, data, 0);
41
-            mouse_event((int)MouseEventFlag.MiddleUp, pointRecord.X, pointRecord.Y, data, 0);
42
-        }
43
-        public static void MouseText(int dx, int dy)
44
-        {
45
-            mouse_event((int)MouseEventFlag.LeftDown, dx, dy, 0, 0);
46
-            mouse_event((int)MouseEventFlag.LeftUp, dx, dy, 0, 0);
47
-        }
48
-        /// <summary>
49
-        /// 鼠标点击中中键
50
-        /// </summary>
51
-        /// <param name="data"></param>
52
-        public static void MouseMiddleClickEvent(int data)
53
-        {
54
-            GetCursorPos(out POINT pointRecord);
55
-            mouse_event((int)MouseEventFlag.MiddleDown, pointRecord.X, pointRecord.Y, data, 0);
56
-            mouse_event((int)MouseEventFlag.MiddleUp, pointRecord.X, pointRecord.Y, data, 0);
57
-        }
58
-
59
-        public struct POINT
60
-        {
61
-            public int X;
62
-            public int Y;
63
-            public POINT(int x, int y)
64
-            {
65
-                this.X = x;
66
-                this.Y = y;
67
-            }
68
-
69
-        }
70
-
71
-        enum MouseEventFlag : uint
72
-        {
73
-            //移动鼠标 
74
-            Move = 0x0001,
75
-            //模拟鼠标左键按下 
76
-            LeftDown = 0x0002,
77
-            //模拟鼠标左键抬起 
78
-            LeftUp = 0x0004,
79
-            //模拟鼠标右键按下 
80
-            RightDown = 0x0008,
81
-            //模拟鼠标右键抬起 
82
-            RightUp = 0x0010,
83
-            //模拟鼠标中键按下 
84
-            MiddleDown = 0x0020,
85
-            //模拟鼠标中键抬起 
86
-            MiddleUp = 0x0040,
87
-            XDown = 0x0080,
88
-            XUp = 0x0100,
89
-            Wheel = 0x0800,
90
-            VirtualDesk = 0x4000,
91
-            //标示是否采用绝对坐标 
92
-            Absolute = 0x8000
93
-        }
94
-    }
95
-}

+ 0
- 18
Common/system/NumUtil.cs Datei anzeigen

@@ -1,18 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Text;
5
-using System.Threading.Tasks;
6
-
7
-namespace Common.system
8
-{
9
-    public class NumUtil
10
-    {
11
-        public static int unixTime()
12
-        {
13
-            double ms = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds;
14
-            int msl = (int)ms;
15
-            return msl;
16
-        }
17
-    }
18
-}

+ 0
- 88
Common/system/PdfTrunImage.cs Datei anzeigen

@@ -1,88 +0,0 @@
1
-using O2S.Components.PDFRender4NET;
2
-
3
-using System.Collections.Generic;
4
-using System.Drawing;
5
-using System.Drawing.Imaging;
6
-using System.IO;
7
-
8
-namespace Common.system
9
-{
10
-    /// <summary>
11
-    /// 
12
-    /// Class to convert a pdf to an image using GhostScript DLL
13
-    /// Credit for this code go to:Rangel Avulso
14
-    /// i only fix a little bug and refactor a little
15
-    /// http://www.hrangel.com.br/index.php/2006/12/04/converter-pdf-para-imagem-jpeg-em-c/
16
-    /// </summary>
17
-    /// <seealso cref="http://www.hrangel.com.br/index.php/2006/12/04/converter-pdf-para-imagem-jpeg-em-c/"/>
18
-    public class PdfTrunImage
19
-    {
20
-        public enum Definition
21
-        {
22
-            One = 1, Two = 2, Three = 3, Four = 4, Five = 5, Six = 6, Seven = 7, Eight = 8, Nine = 9, Ten = 10
23
-        }
24
-
25
-        /// <summary>
26
-        /// 将PDF文档转换为图片的方法
27
-        /// </summary>
28
-        /// <param name="pdfInputPath">PDF文件路径</param>
29
-        /// <param name="imageOutputPath">图片输出路径</param>
30
-        /// <param name="imageName">生成图片的名字</param>
31
-        /// <param name="startPageNum">从PDF文档的第几页开始转换</param>
32
-        /// <param name="endPageNum">从PDF文档的第几页开始停止转换</param>
33
-        /// <param name="imageFormat">设置所需图片格式</param>
34
-        /// <param name="definition">设置图片的清晰度,数字越大越清晰</param>
35
-        public static List<string> ConvertPDF2Image(string pdfInputPath, string imageOutputPath,
36
-            string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, Definition definition)
37
-        {
38
-            List<string> images = new List<string>();
39
-            try
40
-            {
41
-                PDFFile pdfFile = PDFFile.Open(pdfInputPath);
42
-
43
-                if (!Directory.Exists(imageOutputPath))
44
-                {
45
-                    Directory.CreateDirectory(imageOutputPath);
46
-                }
47
-
48
-                // validate pageNum
49
-                if (startPageNum <= 0)
50
-                {
51
-                    startPageNum = 1;
52
-                }
53
-
54
-                if (endPageNum == 0 || endPageNum > pdfFile.PageCount)
55
-                {
56
-                    endPageNum = pdfFile.PageCount;
57
-                }
58
-                if (startPageNum > endPageNum)
59
-                {
60
-                    int tempPageNum = startPageNum;
61
-                    startPageNum = endPageNum;
62
-                    endPageNum = startPageNum;
63
-                }
64
-
65
-                // start to convert each page
66
-                for (int i = startPageNum; i <= endPageNum; i++)
67
-                {
68
-                    Bitmap pageImage = pdfFile.GetPageImage(i - 1, 56 * (int)definition);
69
-                    string imgPath = imageOutputPath + imageName + i.ToString() + "." + imageFormat.ToString();
70
-                    pageImage.Save(imgPath, imageFormat);
71
-                    images.Add(imgPath);
72
-                    // 返回的图片绝对路径集合
73
-                    pageImage.Dispose();
74
-                }
75
-
76
-                pdfFile.Dispose();
77
-                return images;
78
-            }
79
-            catch (System.Exception ex)
80
-            {
81
-                LogHelper.WriteErrLog("PDF转图片" +
82
-                    "【PdfTrunImage】" + ex.Message, ex);
83
-                images = new List<string>();
84
-                return images;
85
-            }
86
-        }
87
-    }
88
-}

+ 0
- 166
Common/system/PrimaryScreen.cs Datei anzeigen

@@ -1,166 +0,0 @@
1
-using System;
2
-using System.Drawing;
3
-using System.Runtime.InteropServices;
4
-
5
-namespace Common.system
6
-{
7
-    /// <summary>
8
-    /// 获取系统DPI缩放倍数和真实大小
9
-    /// </summary>
10
-    public class PrimaryScreen
11
-    {
12
-        #region Win32 API
13
-        [DllImport("user32.dll")]
14
-        private static extern IntPtr GetDC(IntPtr ptr);
15
-        [DllImport("gdi32.dll")]
16
-        private static extern int GetDeviceCaps(
17
-       IntPtr hdc, // handle to DC
18
-       int nIndex // index of capability
19
-       );
20
-        [DllImport("user32.dll", EntryPoint = "ReleaseDC")]
21
-        private static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDc);
22
-        #endregion
23
-        #region DeviceCaps常量
24
-        /// <summary>
25
-        /// 屏幕的宽度(像素);
26
-        /// </summary>
27
-        private const int HORZRES = 8;
28
-
29
-        /// <summary>
30
-        /// 屏幕的高度
31
-        /// </summary>
32
-        private const int VERTRES = 10;
33
-
34
-        /// <summary>
35
-        /// 沿屏幕宽度每逻辑英寸的像素数,在多显示器系统中,该值对所显示器相同
36
-        /// </summary>
37
-        private const int LOGPIXELSX = 88;
38
-
39
-        /// <summary>
40
-        /// 沿屏幕高度每逻辑英寸的像素数,在多显示器系统中,该值对所显示器相同;
41
-        /// </summary>
42
-        private const int LOGPIXELSY = 90;
43
-
44
-        /// <summary>
45
-        /// Windows NT:可视桌面的以像素为单位的高度。
46
-        /// </summary>
47
-        private const int DESKTOPVERTRES = 117;
48
-
49
-        /// <summary>
50
-        /// DESKTOPHORZRES:Windows NT:可视桌面的以像素为单位的宽度。如果设备支持一个可视桌面或双重显示则此值可能大于VERTRES;
51
-        /// </summary>
52
-        private const int DESKTOPHORZRES = 118;
53
-        #endregion
54
-
55
-        #region 属性
56
-        /// <summary>
57
-        /// 获取屏幕分辨率当前物理大小 设置缩放后
58
-        /// </summary>
59
-        public static Size WorkingArea
60
-        {
61
-            get
62
-            {
63
-                IntPtr hdc = GetDC(IntPtr.Zero);
64
-                Size size = new Size
65
-                {
66
-                    Width = GetDeviceCaps(hdc, HORZRES),
67
-                    Height = GetDeviceCaps(hdc, VERTRES)
68
-                };
69
-                ReleaseDC(IntPtr.Zero, hdc);
70
-                return size;
71
-            }
72
-        }
73
-        /// <summary>
74
-        /// 当前系统DPI_X 大小 一般为96
75
-        /// </summary>
76
-        public static int DpiX
77
-        {
78
-            get
79
-            {
80
-                IntPtr hdc = GetDC(IntPtr.Zero);
81
-                int DpiX = GetDeviceCaps(hdc, LOGPIXELSX);
82
-                ReleaseDC(IntPtr.Zero, hdc);
83
-                return DpiX;
84
-            }
85
-        }
86
-        /// <summary>
87
-        /// 当前系统DPI_Y 大小 一般为96
88
-        /// </summary>
89
-        public static int DpiY
90
-        {
91
-            get
92
-            {
93
-                IntPtr hdc = GetDC(IntPtr.Zero);
94
-                int DpiX = GetDeviceCaps(hdc, LOGPIXELSY);
95
-                ReleaseDC(IntPtr.Zero, hdc);
96
-                return DpiX;
97
-            }
98
-        }
99
-        /// <summary>
100
-        /// 获取真实设置的桌面分辨率大小
101
-        /// </summary>
102
-        public static Size DESKTOP
103
-        {
104
-            get
105
-            {
106
-                IntPtr hdc = GetDC(IntPtr.Zero);
107
-                Size size = new Size
108
-                {
109
-                    Width = GetDeviceCaps(hdc, DESKTOPHORZRES),
110
-                    Height = GetDeviceCaps(hdc, DESKTOPVERTRES)
111
-                };
112
-                ReleaseDC(IntPtr.Zero, hdc);
113
-                return size;
114
-            }
115
-        }
116
-
117
-        /// <summary>
118
-        /// 获取宽度缩放百分比
119
-        /// </summary>
120
-        public static float ScaleX
121
-        {
122
-            get
123
-            {
124
-                IntPtr hdc = GetDC(IntPtr.Zero);
125
-                /*int t = */
126
-                GetDeviceCaps(hdc, DESKTOPHORZRES);
127
-                /* int d = */
128
-                GetDeviceCaps(hdc, HORZRES);
129
-                float ScaleX = GetDeviceCaps(hdc, DESKTOPHORZRES) / (float)GetDeviceCaps(hdc, HORZRES);
130
-                ReleaseDC(IntPtr.Zero, hdc);
131
-                return ScaleX;
132
-            }
133
-        }
134
-        /// <summary>
135
-        /// 获取高度缩放百分比
136
-        /// </summary>
137
-        public static float ScaleY
138
-        {
139
-            get
140
-            {
141
-                IntPtr hdc = GetDC(IntPtr.Zero);
142
-                float ScaleY = (float)GetDeviceCaps(hdc, DESKTOPVERTRES) / GetDeviceCaps(hdc, VERTRES);
143
-                ReleaseDC(IntPtr.Zero, hdc);
144
-                return ScaleY;
145
-            }
146
-        }
147
-
148
-        /// <summary>
149
-        /// 缩放后的大小
150
-        /// </summary>
151
-        /// <returns></returns>
152
-        public static SizeF ScaleScreenSize => new SizeF(DESKTOP.Width / (DpiX / 96f), DESKTOP.Height / (DpiY / 96f));
153
-        /// <summary>
154
-        /// 获取缩放后的工作区域大小
155
-        /// </summary>
156
-        public static RectangleF ScaleWorkingAreaSize
157
-        {
158
-            get
159
-            {
160
-                RectangleF rect = System.Windows.Forms.Screen.GetWorkingArea(new System.Drawing.Point((int)ScaleScreenSize.Width, (int)ScaleScreenSize.Height));
161
-                return new RectangleF(((float)rect.X) / (DpiX / 96f), ((float)rect.Y) / (DpiX / 96f), ((float)rect.Width) / (DpiX / 96f), ((float)rect.Height) / (DpiY / 96f));
162
-            }
163
-        }
164
-        #endregion
165
-    }
166
-}

+ 0
- 92
Common/system/QueueSync.cs Datei anzeigen

@@ -1,92 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Text;
5
-using System.Threading.Tasks;
6
-
7
-namespace Common.system
8
-{
9
-    /// <summary>
10
-    /// 队列操作类 默认队列数1000
11
-    /// 创建人:赵耀
12
-    /// 创建时间:2019年8月22日
13
-    /// </summary>
14
-    /// <typeparam name="T"></typeparam>
15
-    public class QueueSync<T>
16
-    {
17
-        int _maxcount = 10000;
18
-        Queue<T> _queue = new Queue<T>();
19
-        /// <summary>
20
-        /// 获取该队列包含的元素数
21
-        /// </summary>
22
-        public int Count
23
-        {
24
-            get
25
-            {
26
-                if (_queue == null)
27
-                {
28
-                    return 0;
29
-                }
30
-                else
31
-                {
32
-                    return _queue.Count;
33
-                }
34
-            }
35
-        }
36
-
37
-        /// <summary>
38
-        /// 默认1000
39
-        /// </summary>
40
-        public QueueSync() : this(1000) { }
41
-
42
-        /// <summary>
43
-        /// 定义一个指定容量的队列
44
-        /// </summary>
45
-        /// <param name="maxcount"></param>
46
-        public QueueSync(int maxcount)
47
-        {
48
-            //_maxcount = Math.Max(maxcount, _maxcount);
49
-            _maxcount = maxcount;
50
-        }
51
-
52
-        /// <summary>
53
-        /// 入队列
54
-        /// </summary>
55
-        /// <param name="obj"></param>
56
-        /// <returns></returns>
57
-        public bool Enqueue(T obj)
58
-        {
59
-            bool result = false;
60
-            lock (this)
61
-            {
62
-                if (_queue.Count > _maxcount)
63
-                {
64
-                    _queue.Dequeue();
65
-                }
66
-                _queue.Enqueue(obj);
67
-                result = true;
68
-            }
69
-            return result;
70
-        }
71
-        /// <summary>
72
-        /// 出队列
73
-        /// </summary>
74
-        /// <returns></returns>
75
-        public T Dequeue()
76
-        {
77
-            T obj = default(T);
78
-            lock (this)
79
-            {
80
-                try
81
-                {
82
-                    obj = _queue.Dequeue();
83
-                }
84
-                catch
85
-                {
86
-
87
-                }
88
-            }
89
-            return obj;
90
-        }
91
-    }
92
-}

+ 0
- 1412
Common/system/RegistryHelper.cs
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 0
- 104
Common/system/SplashScreen.cs Datei anzeigen

@@ -1,104 +0,0 @@
1
-using System;
2
-using System.Reflection;
3
-using System.Threading;
4
-using System.Windows.Forms;
5
-
6
-namespace Common.system
7
-{
8
-    /// <summary>
9
-    /// 解决闪屏  加载等待 
10
-    /// 创建人:赵耀
11
-    /// 创建时间:2018年11月27日
12
-    /// </summary>
13
-    public class SplashScreen
14
-    {
15
-        private static object _obj = new object();
16
-
17
-        private static Form _SplashForm = null;
18
-
19
-        private static Thread _SplashThread = null;
20
-
21
-        private delegate void ChangeFormTextdelegate(string s);
22
-
23
-        public static void Show(Type splashFormType)
24
-        {
25
-            if (_SplashThread != null)
26
-            {
27
-                return;
28
-            }
29
-
30
-            if (splashFormType == null)
31
-            {
32
-                throw (new Exception());
33
-            }
34
-
35
-            _SplashThread = new Thread(new ThreadStart(delegate ()
36
-            {
37
-                CreateInstance(splashFormType);
38
-                Application.Run(_SplashForm);
39
-            }))
40
-            {
41
-                IsBackground = true
42
-            };
43
-            _SplashThread.SetApartmentState(ApartmentState.STA);
44
-            _SplashThread.Start();
45
-        }
46
-
47
-        public static void ChangeTitle(string status)
48
-        {
49
-            ChangeFormTextdelegate de = new ChangeFormTextdelegate(ChangeText);
50
-            _SplashForm.Invoke(de, status);
51
-        }
52
-
53
-
54
-
55
-        public static void Close()
56
-        {
57
-            if (_SplashThread == null || _SplashForm == null)
58
-            {
59
-                return;
60
-            }
61
-
62
-            try
63
-            {
64
-                _SplashForm.Invoke(new MethodInvoker(_SplashForm.Close));
65
-            }
66
-            catch (Exception)
67
-            {
68
-            }
69
-            _SplashThread = null;
70
-            _SplashForm = null;
71
-        }
72
-
73
-        private static void ChangeText(string title)
74
-        {
75
-            _SplashForm.Text = title.ToString();
76
-        }
77
-
78
-
79
-
80
-        private static void CreateInstance(Type FormType)
81
-        {
82
-            if (_SplashForm == null)
83
-            {
84
-                lock (_obj)
85
-                {
86
-                    object obj = FormType.InvokeMember(null,
87
-                                        BindingFlags.DeclaredOnly |
88
-                                        BindingFlags.Public | BindingFlags.NonPublic |
89
-                                        BindingFlags.Instance | BindingFlags.CreateInstance, null, null, null);
90
-                    _SplashForm = obj as Form;
91
-                    _SplashForm.TopMost = true;
92
-                    _SplashForm.ShowInTaskbar = false;
93
-                    _SplashForm.BringToFront();
94
-                    _SplashForm.StartPosition = FormStartPosition.CenterScreen;
95
-                    if (_SplashForm == null)
96
-                    {
97
-                        throw (new Exception());
98
-                    }
99
-                }
100
-            }
101
-        }
102
-
103
-    }
104
-}

+ 0
- 192
Common/system/XmlUtilHelper.cs Datei anzeigen

@@ -1,192 +0,0 @@
1
-using System;
2
-using System.Data;
3
-using System.IO;
4
-using System.Xml;
5
-using System.Xml.Serialization;
6
-
7
-namespace Common.system
8
-{
9
-
10
-    /// <summary>
11
-    /// 通用XML序列化和反序列化工具类
12
-    /// 创建人:赵耀
13
-    /// 创建时间:2018年11月16日
14
-    /// </summary>
15
-    public static class XmlUtilHelper
16
-    {
17
-        #region 反序列化
18
-        /// <summary>
19
-        /// 反序列化
20
-        /// </summary>
21
-        /// <param name="type">类型</param>
22
-        /// <param name="xml">XML字符串</param>
23
-        /// <returns></returns>
24
-        public static object Deserialize(Type type, string xml)
25
-        {
26
-            try
27
-            {
28
-                using (StringReader sr = new StringReader(xml))
29
-                {
30
-                    XmlSerializer xmldes = new XmlSerializer(type);
31
-                    return xmldes.Deserialize(sr);
32
-                }
33
-            }
34
-            catch (Exception)
35
-            {
36
-                return null;
37
-            }
38
-        }
39
-        /// <summary>
40
-        /// 反序列化
41
-        /// </summary>
42
-        /// <param name="type"></param>
43
-        /// <param name="xml"></param>
44
-        /// <returns></returns>
45
-        public static object Deserialize(Type type, Stream stream)
46
-        {
47
-            XmlSerializer xmldes = new XmlSerializer(type);
48
-
49
-            return xmldes.Deserialize(stream);
50
-        }
51
-        /// <summary>
52
-        /// 反序列化实体
53
-        /// </summary>
54
-        /// <typeparam name="T"></typeparam>
55
-        /// <param name="strXML"></param>
56
-        /// <returns></returns>
57
-        public static T DESerializer<T>(string strXML) where T : class
58
-        {
59
-            try
60
-            {
61
-                using (StringReader sr = new StringReader(strXML))
62
-                {
63
-                    XmlSerializer serializer = new XmlSerializer(typeof(T));
64
-                    return serializer.Deserialize(sr) as T;
65
-                }
66
-            }
67
-            catch (Exception)
68
-            {
69
-                return null;
70
-            }
71
-        }
72
-
73
-        /// <summary>  
74
-        /// 从xml序列中反序列化  
75
-        /// </summary>  
76
-        /// <param name="objname"></param>  
77
-        /// <returns></returns>  
78
-        public static object Deserailize(Type type, string filename)
79
-        {
80
-            try
81
-            {
82
-                object obj;
83
-                if (!System.IO.File.Exists(filename))
84
-                {
85
-                    throw new Exception("指定文件不存在");
86
-                }
87
-                //Xml格式反序列化  
88
-                using (Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
89
-                {
90
-                    XmlSerializer formatter = new XmlSerializer(type);
91
-                    obj = formatter.Deserialize(stream);
92
-                    stream.Close();
93
-                }
94
-                return obj;
95
-            }
96
-            catch (Exception)
97
-            {
98
-                //Logger.Log4NetHelp.Error("反序列化失败:", e);
99
-                return null;
100
-            }
101
-        }
102
-
103
-        /// <summary>
104
-        /// 将xml转为Datable
105
-        /// </summary>
106
-        public static DataTable XmlToDataTable(string xmlStr)
107
-        {
108
-            if (!string.IsNullOrEmpty(xmlStr))
109
-            {
110
-                StringReader StrStream = null;
111
-                XmlTextReader Xmlrdr = null;
112
-                try
113
-                {
114
-                    DataSet ds = new DataSet();
115
-                    //读取字符串中的信息  
116
-                    StrStream = new StringReader(xmlStr);
117
-                    //获取StrStream中的数据  
118
-                    Xmlrdr = new XmlTextReader(StrStream);
119
-                    //ds获取Xmlrdr中的数据                 
120
-                    ds.ReadXml(Xmlrdr);
121
-                    return ds.Tables[0];
122
-                }
123
-                catch (Exception)
124
-                {
125
-                    return null;
126
-                }
127
-                finally
128
-                {
129
-                    //释放资源  
130
-                    if (Xmlrdr != null)
131
-                    {
132
-                        Xmlrdr.Close();
133
-                        StrStream.Close();
134
-                        StrStream.Dispose();
135
-                    }
136
-                }
137
-            }
138
-            return null;
139
-        }
140
-
141
-        #endregion
142
-
143
-        #region 序列化
144
-        /// <summary>
145
-        /// 实体类转XML
146
-        /// </summary>
147
-        /// <typeparam name="T"></typeparam>
148
-        /// <param name="obj"></param>
149
-        /// <returns></returns>
150
-        public static string XmlSerialize<T>(T obj)
151
-        {
152
-            using (StringWriter sw = new StringWriter())
153
-            {
154
-                Type t = obj.GetType();
155
-                XmlSerializer serializer = new XmlSerializer(obj.GetType());
156
-                serializer.Serialize(sw, obj);
157
-                sw.Close();
158
-                return sw.ToString();
159
-            }
160
-        }
161
-        /// <summary>
162
-        /// 序列化
163
-        /// </summary>
164
-        /// <param name="type">类型</param>
165
-        /// <param name="obj">对象</param>
166
-        /// <returns></returns>
167
-        public static string Serializer(Type type, object obj)
168
-        {
169
-            MemoryStream Stream = new MemoryStream();
170
-            XmlSerializer xml = new XmlSerializer(type);
171
-            try
172
-            {
173
-                //序列化对象
174
-                xml.Serialize(Stream, obj);
175
-            }
176
-            catch (InvalidOperationException)
177
-            {
178
-                //Logger.Log4NetHelp.Error("序列化失败:", ex);
179
-            }
180
-            Stream.Position = 0;
181
-            StreamReader sr = new StreamReader(Stream);
182
-            string str = sr.ReadToEnd();
183
-
184
-            sr.Dispose();
185
-            Stream.Dispose();
186
-
187
-            return str;
188
-        }
189
-
190
-        #endregion
191
-    }
192
-}

+ 0
- 94
Common/system/ZJClippingBorder.cs Datei anzeigen

@@ -1,94 +0,0 @@
1
-using System;
2
-using System.Windows;
3
-using System.Windows.Controls;
4
-using System.Windows.Media;
5
-
6
-namespace Common.system
7
-{
8
-    public class ZJClippingBorder : Border
9
-    {
10
-        private object _oldClip;
11
-
12
-        protected override void OnRender(DrawingContext dc)
13
-        {
14
-            OnApplyChildClip();
15
-            base.OnRender(dc);
16
-        }
17
-
18
-        public override UIElement Child
19
-        {
20
-            get => base.Child;
21
-            set
22
-            {
23
-                if (Child != value)
24
-                {
25
-                    if (Child != null)
26
-                    {
27
-                        Child.SetValue(ClipProperty, _oldClip);
28
-                    }
29
-
30
-                    if (value != null)
31
-                    {
32
-                        _oldClip = value.ReadLocalValue(ClipProperty);
33
-                    }
34
-                    else
35
-                    {
36
-                        // If we dont set it to null we could leak a Geometry object
37
-                        _oldClip = null;
38
-                    }
39
-
40
-                    base.Child = value;
41
-                }
42
-            }
43
-        }
44
-
45
-        protected virtual void OnApplyChildClip()
46
-        {
47
-            UIElement child = Child;
48
-            if (child != null)
49
-            {
50
-                double top = Math.Max(CornerRadius.TopLeft, CornerRadius.TopRight);
51
-                double bottom = Math.Max(CornerRadius.BottomLeft, CornerRadius.BottomRight);
52
-                double max = Math.Max(top, bottom);
53
-                Size size = RenderSize;
54
-                double width = size.Width - (BorderThickness.Left + BorderThickness.Right);
55
-                double height = size.Height - (BorderThickness.Top + BorderThickness.Bottom);
56
-                Geometry result = new RectangleGeometry(new Rect(0, 0, width, height), max, max);
57
-                double halfWidth = width / 2;
58
-                double halfHeight = height / 2;
59
-
60
-                if (CornerRadius.TopLeft == 0)
61
-                {
62
-                    result = new CombinedGeometry(
63
-                        GeometryCombineMode.Union,
64
-                        result,
65
-                        new RectangleGeometry(new Rect(0, 0, halfWidth, halfHeight))
66
-                    );
67
-                }
68
-
69
-                if (CornerRadius.TopRight == 0)
70
-                {
71
-                    result = new CombinedGeometry(GeometryCombineMode.Union, result, new RectangleGeometry
72
-                (new Rect(halfWidth, 0, halfWidth, halfHeight)));
73
-                }
74
-
75
-                if (CornerRadius.BottomLeft == 0)
76
-                {
77
-                    result = new CombinedGeometry
78
-                  (GeometryCombineMode.Union, result, new RectangleGeometry
79
-                  (new Rect(0, halfHeight, halfWidth, halfHeight)));
80
-                }
81
-                if (CornerRadius.BottomRight == 0)
82
-                {
83
-                    result = new CombinedGeometry
84
-                  (
85
-                GeometryCombineMode.Union,
86
-                result,
87
-                new RectangleGeometry(new Rect(halfWidth, halfHeight, halfWidth, halfHeight))
88
-                );
89
-                }
90
-                child.Clip = result;
91
-            }
92
-        }
93
-    }
94
-}

+ 0
- 242
XHPZ.Desktop/APP.cs Datei anzeigen

@@ -1,242 +0,0 @@
1
-using Common.system;
2
-
3
-using System;
4
-using System.Collections.Generic;
5
-using System.Diagnostics;
6
-using System.IO;
7
-using System.Linq;
8
-using System.Reflection;
9
-using System.Security.Principal;
10
-using System.Text;
11
-using System.Threading;
12
-using System.Threading.Tasks;
13
-using System.Windows;
14
-using System.Windows.Threading;
15
-
16
-using TStudyDigitalPen.HID;
17
-
18
-namespace XHPZ.Desktop
19
-{
20
-    public partial class APP : Application
21
-    {
22
-        #region 全局变量
23
-        /// <summary>
24
-        /// 后台线程帮助类
25
-        /// </summary>
26
-        public static BackgroundWorkerHelper BackgroundWorkerHelper => BackgroundWorkerHelper.GetInstance();
27
-
28
-        #region 点阵笔
29
-        /// <summary>
30
-        /// 点阵笔
31
-        /// </summary>
32
-        public static DigitalPenHID digitalPen;
33
-        /// <summary>
34
-        /// 笔序号
35
-        /// </summary>
36
-        public static string PenSerial;
37
-        /// <summary>
38
-        /// 笔状态,是否已连接
39
-        /// </summary>
40
-        public static bool PenStatus = false;
41
-        /// <summary>
42
-        /// 手写板状态,是否已连接
43
-        /// </summary>
44
-        public static bool BoardStatus = false;
45
-        #endregion
46
-        #region 腾千里手写笔
47
-        ///// <summary>
48
-        ///// 腾千里手写笔事件
49
-        ///// </summary>
50
-        //public static PenEvents TQLPenevents;
51
-        ///// <summary>
52
-        ///// 腾千里手写笔是否已连接
53
-        ///// </summary>
54
-        //public static bool TQLPenStatus = false;
55
-        #endregion
56
-        #region 页面
57
-        /// <summary>
58
-        /// 批注
59
-        /// </summary>
60
-        //public static PracticeWindow W_PracticeWindow = null;
61
-        #endregion
62
-        #endregion
63
-
64
-        [STAThread]
65
-        private static void Main()
66
-        {
67
-            StopSameProcess();
68
-            try
69
-            {
70
-                #region 强制以管理员方式运行 修改人:赵耀 修改时间:2020年9月7日
71
-                WindowsIdentity identity = WindowsIdentity.GetCurrent();
72
-                WindowsPrincipal principal = new WindowsPrincipal(identity);
73
-                //判断当前登录用户是否为管理员
74
-                //if (principal.IsInRole(WindowsBuiltInRole.Administrator))
75
-                //{
76
-                //    //如果是管理员,则直接运行
77
-                //    W_CreateAMicroLessonWindow = new CreateAMicroLessonWindow();
78
-                //    // 定义Application对象作为整个应用程序入口
79
-                //    Application app = new Application();
80
-                //    app.Run(W_CreateAMicroLessonWindow);
81
-                //    //Application.Run(W_CreateAMicroLessonWindow);
82
-                //}
83
-                //else
84
-                //{
85
-                //    //创建启动对象
86
-                //    System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo
87
-                //    {
88
-                //        UseShellExecute = true,
89
-                //        WorkingDirectory = Environment.CurrentDirectory,
90
-                //        FileName = Assembly.GetExecutingAssembly().Location,
91
-                //        //设置启动动作,确保以管理员身份运行
92
-                //        Verb = "runas"
93
-                //    };
94
-                //    try
95
-                //    {
96
-                //        System.Diagnostics.Process.Start(startInfo);
97
-                //    }
98
-                //    catch
99
-                //    {
100
-                //        return;
101
-                //    }
102
-                //    //退出
103
-                //    //Current.Shutdown();
104
-                //    Environment.Exit(0);
105
-
106
-                //}
107
-                #endregion
108
-
109
-                try
110
-                {
111
-                    if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "temp"))//清除临时文件
112
-                    {
113
-                        Directory.Delete(AppDomain.CurrentDomain.BaseDirectory + "temp", true);
114
-                    }
115
-                }
116
-                catch (Exception)
117
-                {
118
-                }
119
-
120
-                if (principal.IsInRole(WindowsBuiltInRole.Administrator))
121
-                {
122
-                    //如果是管理员,则直接运行
123
-                    MainWindow mainWindow = new MainWindow();
124
-                    // 定义Application对象作为整个应用程序入口
125
-                    Application app = new Application();
126
-                    app.Run(mainWindow);
127
-                }
128
-                else
129
-                {
130
-                    //创建启动对象
131
-                    System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo
132
-                    {
133
-                        UseShellExecute = true,
134
-                        WorkingDirectory = Environment.CurrentDirectory,
135
-                        FileName = Assembly.GetExecutingAssembly().Location,
136
-                        //设置启动动作,确保以管理员身份运行
137
-                        Verb = "runas"
138
-                    };
139
-                    try
140
-                    {
141
-                        System.Diagnostics.Process.Start(startInfo);
142
-                    }
143
-                    catch
144
-                    {
145
-                        return;
146
-                    }
147
-                    //退出
148
-                    //Current.Shutdown();
149
-                    Environment.Exit(0);
150
-
151
-                }
152
-            }
153
-            catch (Exception ex)
154
-            {
155
-
156
-                string ErrMessage = "【进程】(Main):进程意外关闭。 " + ex.Message;
157
-                LogHelper.WriteErrLog(ErrMessage, ex);
158
-            }
159
-        }
160
-
161
-        #region 杀死已存在的进程
162
-        /// <summary>
163
-        /// 结束已运行的程序
164
-        /// </summary>
165
-        private static void StopSameProcess()
166
-        {
167
-            Process current = Process.GetCurrentProcess();
168
-            Process[] processList = Process.GetProcesses();
169
-            foreach (Process process in processList)
170
-            {
171
-                if (process.ProcessName.ToUpper() == "星火批注")
172
-                {
173
-                    if (process.Id != current.Id) //忽略当前进程
174
-                    {
175
-                        try
176
-                        {
177
-                            process.Kill(); //结束进程
178
-                        }
179
-                        catch (Exception)
180
-                        {
181
-                        }
182
-                    }
183
-                }
184
-            }
185
-        }
186
-        /// <summary>
187
-        /// 杀死正在运行的ffmpeg
188
-        /// </summary>
189
-        public static void Killffmpeg()
190
-        {
191
-            Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
192
-            foreach (Process KillProcess in KillProcessArray)
193
-            {
194
-                KillProcess.Kill();
195
-            }
196
-        }
197
-        #endregion
198
-
199
-        /// <summary>
200
-        /// 错误处理
201
-        /// </summary>
202
-        /// <param name="sender"></param>
203
-        /// <param name="e"></param>
204
-        private void MyApp_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
205
-        {
206
-            LogHelper.WriteErrLog("未标示错误:" + e.Exception.Message, e.Exception);
207
-            //MessageWindow.Show("程序异常." + Environment.NewLine + e.Exception.Message);
208
-            e.Handled = true;
209
-        }
210
-
211
-
212
-        #region 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
213
-        /// <summary>
214
-        /// 内存释放压缩
215
-        /// </summary>
216
-        /// <param name="e"></param>
217
-        protected override void OnStartup(StartupEventArgs e)
218
-        {
219
-            //private LierdaCracker cracker = new LierdaCracker();
220
-            //cracker.Cracker(5000);//间隔时间
221
-            //base.OnStartup(e);
222
-            new Thread(o =>
223
-            {
224
-                while (true)
225
-                {
226
-                    try
227
-                    {
228
-                        //FreeMemoryHelper.SetDate();
229
-                        FreeMemoryHelper.ReallocateMemory();
230
-                        Thread.Sleep(20000);//暂定每20秒释放一次
231
-                    }
232
-                    catch (Exception ex)
233
-                    {
234
-                        LogHelper.WriteErrLog("【释放内存(MyApp)" + ex.Message, ex);
235
-                    }
236
-                }
237
-            }).Start();
238
-        }
239
-
240
-        #endregion 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
241
-    }
242
-}

+ 0
- 6
XHPZ.Desktop/App.config Datei anzeigen

@@ -1,6 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8" ?>
2
-<configuration>
3
-    <startup> 
4
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5
-    </startup>
6
-</configuration>

+ 0
- 9
XHPZ.Desktop/App.xaml Datei anzeigen

@@ -1,9 +0,0 @@
1
-<Application x:Class="XHPZ.Desktop.App"
2
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
-             xmlns:local="clr-namespace:XHPZ.Desktop"
5
-             StartupUri="MainWindow.xaml">
6
-    <Application.Resources>
7
-         
8
-    </Application.Resources>
9
-</Application>

+ 0
- 17
XHPZ.Desktop/App.xaml.cs Datei anzeigen

@@ -1,17 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Configuration;
4
-using System.Data;
5
-using System.Linq;
6
-using System.Threading.Tasks;
7
-using System.Windows;
8
-
9
-namespace XHPZ.Desktop
10
-{
11
-    /// <summary>
12
-    /// App.xaml 的交互逻辑
13
-    /// </summary>
14
-    public partial class App : Application
15
-    {
16
-    }
17
-}

BIN
XHPZ.Desktop/CheckPoint.dll Datei anzeigen


+ 0
- 12
XHPZ.Desktop/MainWindow.xaml Datei anzeigen

@@ -1,12 +0,0 @@
1
-<Window x:Class="XHPZ.Desktop.MainWindow"
2
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
-        xmlns:local="clr-namespace:XHPZ.Desktop"
7
-        mc:Ignorable="d"
8
-        Title="MainWindow" Height="450" Width="800">
9
-    <Grid>
10
-        
11
-    </Grid>
12
-</Window>

+ 0
- 30
XHPZ.Desktop/MainWindow.xaml.cs Datei anzeigen

@@ -1,30 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Text;
5
-using System.Threading.Tasks;
6
-using System.Windows;
7
-using System.Windows.Controls;
8
-using System.Windows.Data;
9
-using System.Windows.Documents;
10
-using System.Windows.Input;
11
-using System.Windows.Media;
12
-using System.Windows.Media.Imaging;
13
-using System.Windows.Navigation;
14
-using System.Windows.Shapes;
15
-using Common.system;
16
-
17
-namespace XHPZ.Desktop
18
-{
19
-    /// <summary>
20
-    /// MainWindow.xaml 的交互逻辑
21
-    /// </summary>
22
-    public partial class MainWindow : Window
23
-    {
24
-        public MainWindow()
25
-        {
26
-            InitializeComponent();
27
-            LogHelper.WriteInfoLog("启动");
28
-        }
29
-    }
30
-}

+ 0
- 55
XHPZ.Desktop/Properties/AssemblyInfo.cs Datei anzeigen

@@ -1,55 +0,0 @@
1
-using System.Reflection;
2
-using System.Resources;
3
-using System.Runtime.CompilerServices;
4
-using System.Runtime.InteropServices;
5
-using System.Windows;
6
-
7
-// 有关程序集的一般信息由以下
8
-// 控制。更改这些特性值可修改
9
-// 与程序集关联的信息。
10
-[assembly: AssemblyTitle("XHPZ.Desktop")]
11
-[assembly: AssemblyDescription("")]
12
-[assembly: AssemblyConfiguration("")]
13
-[assembly: AssemblyCompany("")]
14
-[assembly: AssemblyProduct("XHPZ.Desktop")]
15
-[assembly: AssemblyCopyright("Copyright ©  2021")]
16
-[assembly: AssemblyTrademark("")]
17
-[assembly: AssemblyCulture("")]
18
-
19
-// 将 ComVisible 设置为 false 会使此程序集中的类型
20
-//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
21
-//请将此类型的 ComVisible 特性设置为 true。
22
-[assembly: ComVisible(false)]
23
-
24
-//若要开始生成可本地化的应用程序,请设置
25
-//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
26
-//例如,如果您在源文件中使用的是美国英语,
27
-//使用的是美国英语,请将 <UICulture> 设置为 en-US。  然后取消
28
-//对以下 NeutralResourceLanguage 特性的注释。  更新
29
-//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
30
-
31
-//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32
-
33
-
34
-[assembly: ThemeInfo(
35
-    ResourceDictionaryLocation.None, //主题特定资源词典所处位置
36
-                                     //(未在页面中找到资源时使用,
37
-                                     //或应用程序资源字典中找到时使用)
38
-    ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
39
-                                              //(未在页面中找到资源时使用,
40
-                                              //、应用程序或任何主题专用资源字典中找到时使用)
41
-)]
42
-
43
-
44
-// 程序集的版本信息由下列四个值组成: 
45
-//
46
-//      主版本
47
-//      次版本
48
-//      生成号
49
-//      修订号
50
-//
51
-//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
52
-//通过使用 "*",如下所示:
53
-// [assembly: AssemblyVersion("1.0.*")]
54
-[assembly: AssemblyVersion("1.0.0.0")]
55
-[assembly: AssemblyFileVersion("1.0.0.0")]

+ 0
- 70
XHPZ.Desktop/Properties/Resources.Designer.cs Datei anzeigen

@@ -1,70 +0,0 @@
1
-//------------------------------------------------------------------------------
2
-// <auto-generated>
3
-//     此代码由工具生成。
4
-//     运行时版本: 4.0.30319.42000
5
-//
6
-//     对此文件的更改可能导致不正确的行为,如果
7
-//     重新生成代码,则所做更改将丢失。
8
-// </auto-generated>
9
-//------------------------------------------------------------------------------
10
-
11
-
12
-namespace XHPZ.Desktop.Properties
13
-{
14
-    /// <summary>
15
-    ///   强类型资源类,用于查找本地化字符串等。
16
-    /// </summary>
17
-    // 此类是由 StronglyTypedResourceBuilder
18
-    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
19
-    // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
20
-    // (以 /str 作为命令选项),或重新生成 VS 项目。
21
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
22
-    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
23
-    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
24
-    internal class Resources
25
-    {
26
-
27
-        private static global::System.Resources.ResourceManager resourceMan;
28
-
29
-        private static global::System.Globalization.CultureInfo resourceCulture;
30
-
31
-        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32
-        internal Resources()
33
-        {
34
-        }
35
-
36
-        /// <summary>
37
-        ///   返回此类使用的缓存 ResourceManager 实例。
38
-        /// </summary>
39
-        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
40
-        internal static global::System.Resources.ResourceManager ResourceManager
41
-        {
42
-            get
43
-            {
44
-                if ((resourceMan == null))
45
-                {
46
-                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("XHPZ.Desktop.Properties.Resources", typeof(Resources).Assembly);
47
-                    resourceMan = temp;
48
-                }
49
-                return resourceMan;
50
-            }
51
-        }
52
-
53
-        /// <summary>
54
-        ///   重写当前线程的 CurrentUICulture 属性,对
55
-        ///   使用此强类型资源类的所有资源查找执行重写。
56
-        /// </summary>
57
-        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
58
-        internal static global::System.Globalization.CultureInfo Culture
59
-        {
60
-            get
61
-            {
62
-                return resourceCulture;
63
-            }
64
-            set
65
-            {
66
-                resourceCulture = value;
67
-            }
68
-        }
69
-    }
70
-}

+ 0
- 117
XHPZ.Desktop/Properties/Resources.resx Datei anzeigen

@@ -1,117 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<root>
3
-  <!-- 
4
-    Microsoft ResX Schema 
5
-    
6
-    Version 2.0
7
-    
8
-    The primary goals of this format is to allow a simple XML format 
9
-    that is mostly human readable. The generation and parsing of the 
10
-    various data types are done through the TypeConverter classes 
11
-    associated with the data types.
12
-    
13
-    Example:
14
-    
15
-    ... ado.net/XML headers & schema ...
16
-    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
-    <resheader name="version">2.0</resheader>
18
-    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
-    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
-    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
-    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
-    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
-        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
-    </data>
25
-    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
-        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
-        <comment>This is a comment</comment>
28
-    </data>
29
-                
30
-    There are any number of "resheader" rows that contain simple 
31
-    name/value pairs.
32
-    
33
-    Each data row contains a name, and value. The row also contains a 
34
-    type or mimetype. Type corresponds to a .NET class that support 
35
-    text/value conversion through the TypeConverter architecture. 
36
-    Classes that don't support this are serialized and stored with the 
37
-    mimetype set.
38
-    
39
-    The mimetype is used for serialized objects, and tells the 
40
-    ResXResourceReader how to depersist the object. This is currently not 
41
-    extensible. For a given mimetype the value must be set accordingly:
42
-    
43
-    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
-    that the ResXResourceWriter will generate, however the reader can 
45
-    read any of the formats listed below.
46
-    
47
-    mimetype: application/x-microsoft.net.object.binary.base64
48
-    value   : The object must be serialized with 
49
-            : System.Serialization.Formatters.Binary.BinaryFormatter
50
-            : and then encoded with base64 encoding.
51
-    
52
-    mimetype: application/x-microsoft.net.object.soap.base64
53
-    value   : The object must be serialized with 
54
-            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
-            : and then encoded with base64 encoding.
56
-
57
-    mimetype: application/x-microsoft.net.object.bytearray.base64
58
-    value   : The object must be serialized into a byte array 
59
-            : using a System.ComponentModel.TypeConverter
60
-            : and then encoded with base64 encoding.
61
-    -->
62
-  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
-    <xsd:element name="root" msdata:IsDataSet="true">
64
-      <xsd:complexType>
65
-        <xsd:choice maxOccurs="unbounded">
66
-          <xsd:element name="metadata">
67
-            <xsd:complexType>
68
-              <xsd:sequence>
69
-                <xsd:element name="value" type="xsd:string" minOccurs="0" />
70
-              </xsd:sequence>
71
-              <xsd:attribute name="name" type="xsd:string" />
72
-              <xsd:attribute name="type" type="xsd:string" />
73
-              <xsd:attribute name="mimetype" type="xsd:string" />
74
-            </xsd:complexType>
75
-          </xsd:element>
76
-          <xsd:element name="assembly">
77
-            <xsd:complexType>
78
-              <xsd:attribute name="alias" type="xsd:string" />
79
-              <xsd:attribute name="name" type="xsd:string" />
80
-            </xsd:complexType>
81
-          </xsd:element>
82
-          <xsd:element name="data">
83
-            <xsd:complexType>
84
-              <xsd:sequence>
85
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
86
-                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
87
-              </xsd:sequence>
88
-              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
89
-              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
90
-              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
91
-            </xsd:complexType>
92
-          </xsd:element>
93
-          <xsd:element name="resheader">
94
-            <xsd:complexType>
95
-              <xsd:sequence>
96
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
97
-              </xsd:sequence>
98
-              <xsd:attribute name="name" type="xsd:string" use="required" />
99
-            </xsd:complexType>
100
-          </xsd:element>
101
-        </xsd:choice>
102
-      </xsd:complexType>
103
-    </xsd:element>
104
-  </xsd:schema>
105
-  <resheader name="resmimetype">
106
-    <value>text/microsoft-resx</value>
107
-  </resheader>
108
-  <resheader name="version">
109
-    <value>2.0</value>
110
-  </resheader>
111
-  <resheader name="reader">
112
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
113
-  </resheader>
114
-  <resheader name="writer">
115
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
-  </resheader>
117
-</root>

+ 0
- 29
XHPZ.Desktop/Properties/Settings.Designer.cs Datei anzeigen

@@ -1,29 +0,0 @@
1
-//------------------------------------------------------------------------------
2
-// <auto-generated>
3
-//     This code was generated by a tool.
4
-//     Runtime Version:4.0.30319.42000
5
-//
6
-//     Changes to this file may cause incorrect behavior and will be lost if
7
-//     the code is regenerated.
8
-// </auto-generated>
9
-//------------------------------------------------------------------------------
10
-
11
-
12
-namespace XHPZ.Desktop.Properties
13
-{
14
-    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
16
-    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
17
-    {
18
-
19
-        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
20
-
21
-        public static Settings Default
22
-        {
23
-            get
24
-            {
25
-                return defaultInstance;
26
-            }
27
-        }
28
-    }
29
-}

+ 0
- 7
XHPZ.Desktop/Properties/Settings.settings Datei anzeigen

@@ -1,7 +0,0 @@
1
-<?xml version='1.0' encoding='utf-8'?>
2
-<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
3
-  <Profiles>
4
-    <Profile Name="(Default)" />
5
-  </Profiles>
6
-  <Settings />
7
-</SettingsFile>

+ 0
- 69
XHPZ.Desktop/Properties/app.manifest Datei anzeigen

@@ -1,69 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3
-  <assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
4
-  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
5
-    <security>
6
-      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7
-        <!-- UAC 清单选项
8
-             如果想要更改 Windows 用户帐户控制级别,请使用
9
-             以下节点之一替换 requestedExecutionLevel 节点。n
10
-        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
11
-        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
12
-        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />
13
-
14
-            指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
15
-            如果你的应用程序需要此虚拟化来实现向后兼容性,则删除此
16
-            元素。
17
-        -->
18
-        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
19
-      </requestedPrivileges>
20
-      <applicationRequestMinimum>
21
-        <defaultAssemblyRequest permissionSetReference="Custom" />
22
-        <PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
23
-      </applicationRequestMinimum>
24
-    </security>
25
-  </trustInfo>
26
-  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
27
-    <application>
28
-      <!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
29
-           Windows 版本的列表。取消评论适当的元素,
30
-           Windows 将自动选择最兼容的环境。 -->
31
-      <!-- Windows Vista -->
32
-      <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
33
-      <!-- Windows 7 -->
34
-      <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
35
-      <!-- Windows 8 -->
36
-      <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
37
-      <!-- Windows 8.1 -->
38
-      <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
39
-      <!-- Windows 10 -->
40
-      <!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
41
-    </application>
42
-  </compatibility>
43
-  <!-- 指示该应用程序可以感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
44
-       自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
45
-       选择加入。选择加入此设置的 Windows 窗体应用程序(目标设定为 .NET Framework 4.6 )还应
46
-       在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。-->
47
-  <!--
48
-  <application xmlns="urn:schemas-microsoft-com:asm.v3">
49
-    <windowsSettings>
50
-      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
51
-    </windowsSettings>
52
-  </application>
53
-  -->
54
-  <!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
55
-  <!--
56
-  <dependency>
57
-    <dependentAssembly>
58
-      <assemblyIdentity
59
-          type="win32"
60
-          name="Microsoft.Windows.Common-Controls"
61
-          version="6.0.0.0"
62
-          processorArchitecture="*"
63
-          publicKeyToken="6595b64144ccf1df"
64
-          language="*"
65
-        />
66
-    </dependentAssembly>
67
-  </dependency>
68
-  -->
69
-</assembly>

BIN
XHPZ.Desktop/RobotDotMatrix.dll Datei anzeigen


BIN
XHPZ.Desktop/RobotUsbWrapper.dll Datei anzeigen


BIN
XHPZ.Desktop/SonixUSB.dll Datei anzeigen


+ 0
- 130
XHPZ.Desktop/XHPZ.Desktop.csproj Datei anzeigen

@@ -1,130 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4
-  <PropertyGroup>
5
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7
-    <ProjectGuid>{82B6341B-3566-4E1A-8B0C-5CAA90C30005}</ProjectGuid>
8
-    <OutputType>WinExe</OutputType>
9
-    <RootNamespace>XHPZ.Desktop</RootNamespace>
10
-    <AssemblyName>星火批注</AssemblyName>
11
-    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12
-    <FileAlignment>512</FileAlignment>
13
-    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14
-    <WarningLevel>4</WarningLevel>
15
-    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16
-    <Deterministic>true</Deterministic>
17
-  </PropertyGroup>
18
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19
-    <PlatformTarget>AnyCPU</PlatformTarget>
20
-    <DebugSymbols>true</DebugSymbols>
21
-    <DebugType>full</DebugType>
22
-    <Optimize>false</Optimize>
23
-    <OutputPath>bin\Debug\</OutputPath>
24
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
25
-    <ErrorReport>prompt</ErrorReport>
26
-    <WarningLevel>4</WarningLevel>
27
-  </PropertyGroup>
28
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29
-    <PlatformTarget>AnyCPU</PlatformTarget>
30
-    <DebugType>pdbonly</DebugType>
31
-    <Optimize>true</Optimize>
32
-    <OutputPath>bin\Release\</OutputPath>
33
-    <DefineConstants>TRACE</DefineConstants>
34
-    <ErrorReport>prompt</ErrorReport>
35
-    <WarningLevel>4</WarningLevel>
36
-  </PropertyGroup>
37
-  <PropertyGroup>
38
-    <TargetZone>LocalIntranet</TargetZone>
39
-  </PropertyGroup>
40
-  <PropertyGroup>
41
-    <GenerateManifests>false</GenerateManifests>
42
-  </PropertyGroup>
43
-  <PropertyGroup>
44
-    <ApplicationManifest>Properties\app.manifest</ApplicationManifest>
45
-  </PropertyGroup>
46
-  <ItemGroup>
47
-    <Reference Include="log4net">
48
-      <HintPath>..\Common\dlls\log4net.dll</HintPath>
49
-    </Reference>
50
-    <Reference Include="System" />
51
-    <Reference Include="System.Data" />
52
-    <Reference Include="System.Xml" />
53
-    <Reference Include="Microsoft.CSharp" />
54
-    <Reference Include="System.Core" />
55
-    <Reference Include="System.Xml.Linq" />
56
-    <Reference Include="System.Data.DataSetExtensions" />
57
-    <Reference Include="System.Net.Http" />
58
-    <Reference Include="System.Xaml">
59
-      <RequiredTargetFramework>4.0</RequiredTargetFramework>
60
-    </Reference>
61
-    <Reference Include="TQLComm">
62
-      <HintPath>..\Common\dlls\TQLComm.dll</HintPath>
63
-    </Reference>
64
-    <Reference Include="TStudy.DigitalPen">
65
-      <HintPath>..\Common\dlls\TStudy.DigitalPen.dll</HintPath>
66
-    </Reference>
67
-    <Reference Include="WindowsBase" />
68
-    <Reference Include="PresentationCore" />
69
-    <Reference Include="PresentationFramework" />
70
-  </ItemGroup>
71
-  <ItemGroup>
72
-    <Page Include="MainWindow.xaml">
73
-      <Generator>MSBuild:Compile</Generator>
74
-      <SubType>Designer</SubType>
75
-    </Page>
76
-    <Compile Include="APP.cs" />
77
-    <Compile Include="MainWindow.xaml.cs">
78
-      <DependentUpon>MainWindow.xaml</DependentUpon>
79
-      <SubType>Code</SubType>
80
-    </Compile>
81
-  </ItemGroup>
82
-  <ItemGroup>
83
-    <Compile Include="Properties\AssemblyInfo.cs">
84
-      <SubType>Code</SubType>
85
-    </Compile>
86
-    <Compile Include="Properties\Resources.Designer.cs">
87
-      <AutoGen>True</AutoGen>
88
-      <DesignTime>True</DesignTime>
89
-      <DependentUpon>Resources.resx</DependentUpon>
90
-    </Compile>
91
-    <Compile Include="Properties\Settings.Designer.cs">
92
-      <AutoGen>True</AutoGen>
93
-      <DependentUpon>Settings.settings</DependentUpon>
94
-      <DesignTimeSharedInput>True</DesignTimeSharedInput>
95
-    </Compile>
96
-    <EmbeddedResource Include="Properties\Resources.resx">
97
-      <Generator>ResXFileCodeGenerator</Generator>
98
-      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
99
-    </EmbeddedResource>
100
-    <None Include="Properties\app.manifest" />
101
-    <None Include="Properties\Settings.settings">
102
-      <Generator>SettingsSingleFileGenerator</Generator>
103
-      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
104
-    </None>
105
-  </ItemGroup>
106
-  <ItemGroup>
107
-    <None Include="App.config" />
108
-  </ItemGroup>
109
-  <ItemGroup>
110
-    <ProjectReference Include="..\Common\Common.csproj">
111
-      <Project>{808a7075-5af5-46b3-8ef6-514c0b5fa8d7}</Project>
112
-      <Name>Common</Name>
113
-    </ProjectReference>
114
-  </ItemGroup>
115
-  <ItemGroup>
116
-    <EmbeddedResource Include="CheckPoint.dll">
117
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
118
-    </EmbeddedResource>
119
-    <EmbeddedResource Include="RobotDotMatrix.dll">
120
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
121
-    </EmbeddedResource>
122
-    <EmbeddedResource Include="RobotUsbWrapper.dll">
123
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
124
-    </EmbeddedResource>
125
-    <EmbeddedResource Include="SonixUSB.dll">
126
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
127
-    </EmbeddedResource>
128
-  </ItemGroup>
129
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
130
-</Project>

+ 0
- 31
XHPZ.sln Datei anzeigen

@@ -1,31 +0,0 @@
1
-
2
-Microsoft Visual Studio Solution File, Format Version 12.00
3
-# Visual Studio Version 16
4
-VisualStudioVersion = 16.0.30804.86
5
-MinimumVisualStudioVersion = 10.0.40219.1
6
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XHPZ.Desktop", "XHPZ.Desktop\XHPZ.Desktop.csproj", "{82B6341B-3566-4E1A-8B0C-5CAA90C30005}"
7
-EndProject
8
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{808A7075-5AF5-46B3-8EF6-514C0B5FA8D7}"
9
-EndProject
10
-Global
11
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
12
-		Debug|Any CPU = Debug|Any CPU
13
-		Release|Any CPU = Release|Any CPU
14
-	EndGlobalSection
15
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
16
-		{82B6341B-3566-4E1A-8B0C-5CAA90C30005}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17
-		{82B6341B-3566-4E1A-8B0C-5CAA90C30005}.Debug|Any CPU.Build.0 = Debug|Any CPU
18
-		{82B6341B-3566-4E1A-8B0C-5CAA90C30005}.Release|Any CPU.ActiveCfg = Release|Any CPU
19
-		{82B6341B-3566-4E1A-8B0C-5CAA90C30005}.Release|Any CPU.Build.0 = Release|Any CPU
20
-		{808A7075-5AF5-46B3-8EF6-514C0B5FA8D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21
-		{808A7075-5AF5-46B3-8EF6-514C0B5FA8D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
22
-		{808A7075-5AF5-46B3-8EF6-514C0B5FA8D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
23
-		{808A7075-5AF5-46B3-8EF6-514C0B5FA8D7}.Release|Any CPU.Build.0 = Release|Any CPU
24
-	EndGlobalSection
25
-	GlobalSection(SolutionProperties) = preSolution
26
-		HideSolutionNode = FALSE
27
-	EndGlobalSection
28
-	GlobalSection(ExtensibilityGlobals) = postSolution
29
-		SolutionGuid = {FC5F78D4-21FE-44F0-952C-9F5C358214C6}
30
-	EndGlobalSection
31
-EndGlobal

Laden…
Abbrechen
Speichern