lch
2024-08-10 4eebf2a18c475d1fcf5374a96ed26ce7e5f1e5b1
添加项目文件。
已添加34个文件
10305 ■■■■■ 文件已修改
App.config 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataexchangeServer.csproj 202 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DataexchangeServer.sln 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HandleData/AE_MES_ERP.cs 4716 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HandleData/Allocation.cs 319 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HandleData/XkyApiHelper.cs 155 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Helper/JSONHelper.cs 123 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Helper/SQLHelper.cs 698 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Program.cs 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Properties/AssemblyInfo.cs 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Properties/Resources.Designer.cs 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Properties/Resources.resx 117 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Properties/Settings.Designer.cs 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Properties/Settings.settings 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StringHelper.cs 1263 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StringSecurity.cs 308 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReference/Reference.cs 293 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReference/Reference.map 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReference/UserServiceImplService.wsdl 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReference/api.xsd 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReference/resp.datasource 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReferenceLD/Reference.cs 293 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReferenceLD/Reference.map 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReferenceLD/UserServiceImplService.wsdl 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReferenceLD/api.xsd 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReferenceLD/resp.datasource 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReferenceLD1/Reference.cs 293 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReferenceLD1/Reference.map 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReferenceLD1/UserServiceImplService.wsdl 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReferenceLD1/api.xsd 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web References/WebReferenceLD1/resp.datasource 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
frmMain.Designer.cs 371 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
frmMain.cs 472 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
frmMain.resx 178 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
App.config
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="DataexchangeServer.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
    </sectionGroup>
  </configSections>
  <connectionStrings>
    <!--广深数据库-->
    <add name="conn" connectionString="INmsaZ0Y6+ekR8JM34oAHBcXIuD3t5rWBUFmemwZikW+clLEnIhheyI9aDZpB5dtgt7HjRKSd7/JG1aw85eLYaVDcU5ow92mnyIK/L3M/9rT0bgjY1QHNB67lWZoKtMBhnjAJftvaWr2C35ra+0bjsB6pFGr5Zm81nskO8+tve5u+Zj2R4tm1Nt9LVvAcPJkusDAkv5imdq58D2xn//H/yxHzjIERtK6v+OQypjQQ8w="/>
  </connectionStrings>
  <appSettings>
    <!--<add key="ExecutionTime" value="5" />-->
    <add key="TimingMailInterval" value="10000"/>
    <add key="MaxThreads" value="15"/>
    <add key="MinThreads" value="5"/>
    <add key="thisText" value="[广深数据同步服务]"/>
    <!--<add key="notifyText" value="5" />-->
    <add key="ClientSettingsProvider.ServiceUri" value=""/>
  </appSettings>
  <applicationSettings>
    <DataexchangeServer.Properties.Settings>
      <setting name="DataexchangeServer_WebReference_UserServiceImplService"
        serializeAs="String">
        <value>http://36.134.102.119:8888/ykd/api</value>
      </setting>
      <setting name="DataexchangeServer_WebReferenceLD_UserServiceImplService"
        serializeAs="String">
        <value>http://36.134.102.119:9998/ykd/api</value>
      </setting>
      <setting name="DataexchangeServer_WebReferenceLD1_UserServiceImplService"
        serializeAs="String">
        <value>http://36.134.102.119:9998/ykd/api</value>
      </setting>
    </DataexchangeServer.Properties.Settings>
  </applicationSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/></startup></configuration>
DataexchangeServer.csproj
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,202 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{2B281C03-2092-46E5-A6C3-6FA26B463A18}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>DataexchangeServer</RootNamespace>
    <AssemblyName>DataexchangeServer</AssemblyName>
    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <IsWebBootstrapper>false</IsWebBootstrapper>
    <PublishUrl>发布\</PublishUrl>
    <Install>true</Install>
    <InstallFrom>Disk</InstallFrom>
    <UpdateEnabled>false</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateInterval>7</UpdateInterval>
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
    <UpdatePeriodically>false</UpdatePeriodically>
    <UpdateRequired>false</UpdateRequired>
    <MapFileExtensions>true</MapFileExtensions>
    <ApplicationRevision>0</ApplicationRevision>
    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
    <UseApplicationTrust>false</UseApplicationTrust>
    <BootstrapperEnabled>true</BootstrapperEnabled>
    <TargetFrameworkProfile />
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>bin\Debug\Newtonsoft.Json.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Core" />
    <Reference Include="System.EnterpriseServices" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Web.Extensions" />
    <Reference Include="System.Web.Services" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Deployment" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="frmMain.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="frmMain.Designer.cs">
      <DependentUpon>frmMain.cs</DependentUpon>
    </Compile>
    <Compile Include="HandleData\AE_MES_ERP.cs" />
    <Compile Include="HandleData\Allocation.cs" />
    <Compile Include="HandleData\XkyApiHelper.cs" />
    <Compile Include="Helper\JSONHelper.cs" />
    <Compile Include="Helper\SQLHelper.cs" />
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="StringHelper.cs" />
    <Compile Include="StringSecurity.cs" />
    <Compile Include="Web References\WebReferenceLD1\Reference.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Reference.map</DependentUpon>
    </Compile>
    <Compile Include="Web References\WebReference\Reference.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Reference.map</DependentUpon>
    </Compile>
    <EmbeddedResource Include="frmMain.resx">
      <DependentUpon>frmMain.cs</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <Compile Include="Properties\Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
      <DesignTime>True</DesignTime>
    </Compile>
    <None Include="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
    <Compile Include="Properties\Settings.Designer.cs">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
    <None Include="Web References\WebReferenceLD1\api.xsd">
      <SubType>Designer</SubType>
    </None>
    <None Include="Web References\WebReferenceLD1\Reference.map">
      <Generator>MSDiscoCodeGenerator</Generator>
      <LastGenOutput>Reference.cs</LastGenOutput>
    </None>
    <None Include="Web References\WebReferenceLD1\resp.datasource">
      <DependentUpon>Reference.map</DependentUpon>
    </None>
    <None Include="Web References\WebReferenceLD1\UserServiceImplService.wsdl" />
    <None Include="Web References\WebReference\api.xsd">
      <SubType>Designer</SubType>
    </None>
    <None Include="Web References\WebReference\Reference.map">
      <Generator>MSDiscoCodeGenerator</Generator>
      <LastGenOutput>Reference.cs</LastGenOutput>
    </None>
    <None Include="Web References\WebReference\resp.datasource">
      <DependentUpon>Reference.map</DependentUpon>
    </None>
    <None Include="Web References\WebReference\UserServiceImplService.wsdl" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config">
      <SubType>Designer</SubType>
    </None>
  </ItemGroup>
  <ItemGroup>
    <WCFMetadata Include="Service References\" />
  </ItemGroup>
  <ItemGroup>
    <BootstrapperPackage Include=".NETFramework,Version=v4.5">
      <Visible>False</Visible>
      <ProductName>Microsoft .NET Framework 4.5 %28x86 å’Œ x64%29</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
  </ItemGroup>
  <ItemGroup>
    <WebReferences Include="Web References\" />
  </ItemGroup>
  <ItemGroup>
    <WebReferenceUrl Include="http://36.134.102.119:8888/ykd/api%3fwsdl">
      <UrlBehavior>Dynamic</UrlBehavior>
      <RelPath>Web References\WebReference\</RelPath>
      <UpdateFromURL>http://36.134.102.119:8888/ykd/api%3fwsdl</UpdateFromURL>
      <ServiceLocationURL>
      </ServiceLocationURL>
      <CachedDynamicPropName>
      </CachedDynamicPropName>
      <CachedAppSettingsObjectName>Settings</CachedAppSettingsObjectName>
      <CachedSettingsPropName>DataexchangeServer_WebReference_UserServiceImplService</CachedSettingsPropName>
    </WebReferenceUrl>
    <WebReferenceUrl Include="http://36.134.102.119:9998/ykd/api%3fwsdl">
      <UrlBehavior>Dynamic</UrlBehavior>
      <RelPath>Web References\WebReferenceLD1\</RelPath>
      <UpdateFromURL>http://36.134.102.119:9998/ykd/api%3fwsdl</UpdateFromURL>
      <ServiceLocationURL>
      </ServiceLocationURL>
      <CachedDynamicPropName>
      </CachedDynamicPropName>
      <CachedAppSettingsObjectName>Settings</CachedAppSettingsObjectName>
      <CachedSettingsPropName>DataexchangeServer_WebReferenceLD1_UserServiceImplService</CachedSettingsPropName>
    </WebReferenceUrl>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>
DataexchangeServer.sln
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33414.496
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataexchangeServer", "DataexchangeServer.csproj", "{2B281C03-2092-46E5-A6C3-6FA26B463A18}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Release|Any CPU = Release|Any CPU
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {2B281C03-2092-46E5-A6C3-6FA26B463A18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {2B281C03-2092-46E5-A6C3-6FA26B463A18}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {2B281C03-2092-46E5-A6C3-6FA26B463A18}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {2B281C03-2092-46E5-A6C3-6FA26B463A18}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
    GlobalSection(ExtensibilityGlobals) = postSolution
        SolutionGuid = {E6ED8877-2A2A-460C-AA1B-BC07F4D63A4C}
    EndGlobalSection
EndGlobal
HandleData/AE_MES_ERP.cs
¶Ô±ÈÐÂÎļþ
ÎļþÌ«´ó
HandleData/Allocation.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,319 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace DataexchangeServer
{
    public delegate void WriteLogHandle(string msg);
    #region ç±»çš„状态 enum State
    /// <summary>
    /// ç±»çš„状态
    /// </summary>
    public enum State
    {
        Alive, //激活
        Finish,//完成
        Sleep //睡眠
    }
    #endregion
    public class Allocation
    {
        public State state { get; set; }
        public string Name { get; set; }
        public string ID { get; set; }
        public string task_id { get; set; }
        public DataTable tbQueue;
        private SQLHelper _sqlHelper;
        private DataSet dsTemp = new DataSet();
        public DateTime strStartTime { get; set; }
        /// <summary>
        /// å½“消息有变化的时候将消息通过事件传输
        /// </summary>
        private string ConsoleMessage { get; set; }
        public event WriteLogHandle WriteLog;
        public event WriteLogHandle WriteErrorLog;
        #region çº¿ç¨‹ç±»Allocation()
        /// <summary>
        /// çº¿ç¨‹ç±»
        /// </summary>
        public Allocation()
        {
            string conn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
            conn = SecurityHelper.Decrypt(conn);
            _sqlHelper = new SQLHelper(conn);
            //_sqlHelper =
                       //new SQLHelper(
                       //    Encoding.Default.GetString(
                       //        Convert.FromBase64String(ConfigurationManager.ConnectionStrings["conn"].ConnectionString)));
            tbQueue = new DataTable();
            string SqlStr = string.Format(@"Select top 0 * from SYSDEC (nolock) where 1<>1");
            tbQueue = _sqlHelper.ExecuteDataTable(SqlStr);
            tbQueue.TableName = "SYSDEC";
            tbQueue.PrimaryKey = new[] { tbQueue.Columns["task_id"] };
            state = State.Sleep;
        }
        #endregion
        #region æ‰§è¡Œè°ƒç”¨void Execute(object obj)
        /// <summary>
        /// æ‰§è¡Œè°ƒç”¨
        /// </summary>
        public void Execute(object obj)
        {
            string data = "";
            string taskId = "";
            string docType = "";
            //string inputXml = "";
            string operatype = "";
            string msg = "";
            string data_inserted = "";
            string flag = "0";
            //lock (ID) ;
            try
            {
                state = State.Alive;
                DataRow[] rowArray = tbQueue.Select("", "create_time");
                if (rowArray.Length == 0) return;
                AE_MES_ERP Client = new AE_MES_ERP();
                foreach (DataRow row in rowArray)
                {
                    if (object.Equals(null, row["data_inserted"]))
                    {
                        row["msg"] = "插入的数据为空,请检查程序!";
                        row["states"] = "FAIL";
                        row["retry_times"] = Convert.ToInt16(row["retry_times"].ToString() == "" ? "0" : row["retry_times"].ToString()) + 15;
                        row["execute_time"] = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        continue;
                    }
                    taskId = row["task_id"].ToString();
                    data = row["data"].ToString();
                    docType = row["task_name"].ToString();
                    data_inserted = row["data_inserted"].ToString();
                    operatype = row["operatype"].ToString();
                    ConsoleMessage = string.Format("线程:{0},{1}执行内容:{2} æŽ¨é€Data:{3} æ‰§è¡Œæ—¶é—´ï¼š{4}",
                                                    Name,
                                                    row["creator"].ToString(),
                                                    row["descript"].ToString(),
                                                    row["data"].ToString(),
                                                    System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    if (WriteLog != null) { WriteLog(ConsoleMessage); }
                    //DataTable tbTemp = JSONHelper.JsonToDataTable(data_inserted);
                    if ((!docType.Contains("TB_MESTOERP")&& (!docType.Contains("XKY"))))
                    {
                        if (operatype!="DELETE")
                        {
                            JsonSerializerSettings settings = new JsonSerializerSettings();
                            settings.Converters.Add(new ReadAheadDataSetConverter());
                            dsTemp = JsonConvert.DeserializeObject<DataSet>(data_inserted, settings);
                            // dsTemp = JsonConvert.DeserializeObject(data_inserted, typeof(DataSet)) as DataSet;
                            if (dsTemp == null || dsTemp.Tables.Count == 0)
                            {
                                row["msg"] = "接口存在无效字符";
                                row["states"] = "FAIL";
                                row["retry_times"] = Convert.ToInt16(row["retry_times"].ToString() == "" ? "0" : row["retry_times"].ToString()) + 15;
                                row["execute_time"] = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                                continue;
                            }
                        }
                        else
                        {
                            operatype = data;
                        }
                    }
                    //dsTemp.Tables.Clear();
                    //dsTemp.Tables.Add(tbTemp);
                    //inputXml = dsTemp.GetXml();
                    msg = "";
                    //Thread.Sleep(3000);
                    //DataexchangeServer.IMS.WebServiceClient Client = new DataexchangeServer.IMS.WebServiceClient();
                    if (Client.ErpToMesData(docType, dsTemp, operatype, row, ref msg,ref flag, taskId) == true)
                    {
                        if (flag=="0")
                        {
                            row["msg"] = msg;
                            row["states"] = "FAIL";
                            row["retry_times"] = Convert.ToInt16(row["retry_times"].ToString() == "" ? "0" : row["retry_times"].ToString()) + 1;
                            row["execute_time"] = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            if (WriteErrorLog != null)
                            {
                                WriteErrorLog(msg);
                            }
                        }
                        else
                        {
                            row["msg"] = msg;
                            row["remark"] = "OK";
                            row["states"] = "SUCCESS";
                            row["execute_time"] = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        }
                    }
                    else
                    {
                        row["msg"] = msg;
                        row["states"] = "FAIL";
                        row["retry_times"] = Convert.ToInt16(row["retry_times"].ToString() == "" ? "0" : row["retry_times"].ToString()) + 1;
                        row["execute_time"] = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        if (WriteErrorLog != null)
                        {
                            WriteErrorLog(msg);
                        }
                    }
                }
                _sqlHelper.SaveDataToDB(tbQueue);
                tbQueue.AcceptChanges();
            }
            catch (Exception ex)
            {
                //state = State.Finish;
                //throw (ex);
                //MessageBox.Show("当前错误信息如下:" + ex);
                ConsoleMessage = string.Format(@"task_id:{0},{1}异常信息:" + ex.Message, taskId, DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss"));
                bool result = JSONHelper.WriteToFile(ConsoleMessage);
                ConsoleMessage = string.Format(@"Save {0},ID:{1} å‡ºçŽ°å¼‚å¸¸ä¿¡æ¯ï¼Œè¯·åœ¨è¿è¡Œç›®å½•ä¸‹æŸ¥çœ‹ã€‚\log\", result, data);
                if (WriteErrorLog != null)
                {
                    WriteErrorLog(ConsoleMessage);
                }
            }
            finally
            {
                state = State.Finish;
            }
            if (tbQueue.Rows.Count > 0)
            {
                ConsoleMessage = string.Format("线程:{0}任务结束。时间:{1}", Name, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss "));
                if (WriteLog != null) { WriteLog(ConsoleMessage); }
                //state = State.Finish;
            }
        }
        #endregion
        public class ReadAheadDataSetConverter : JsonConverter
        {
            public override bool CanConvert(Type objectType)
            {
                return objectType == typeof(DataSet);
            }
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                JObject jObject = JObject.Load(reader);
                return BuildDataSet(jObject);
            }
            private DataSet BuildDataSet(JObject jObject)
            {
                DataSet dsResult = new DataSet();
                foreach (JProperty propds in jObject.Properties())
                {
                    DataTable table = new DataTable(propds.Name);
                    var dataTypes = new Dictionary<string, Type>();
                    foreach (JObject item in propds.Value.Children<JObject>())
                    {
                        foreach (JProperty prop in item.Properties())
                        {
                            Type currentType = GetDataType(prop.Value.Type);
                            if (currentType != null)
                            {
                                Type previousType;
                                if (!dataTypes.TryGetValue(prop.Name, out previousType) ||
                                    (previousType == typeof(long) && currentType == typeof(decimal)))
                                {
                                    dataTypes[prop.Name] = currentType;
                                }
                                else if (previousType == typeof(decimal) && currentType == typeof(long))
                                {
                                    dataTypes[prop.Name] = previousType;
                                }
                                else if (previousType != currentType)
                                {
                                    dataTypes[prop.Name] = typeof(string);
                                }
                            }
                        }
                    }
                    foreach (var kvp in dataTypes)
                    {
                        table.Columns.Add(kvp.Key, kvp.Value);
                    }
                    foreach (JObject itemdr in propds.Value.Children<JObject>())
                    {
                        DataRow row = table.NewRow();
                        foreach (JProperty prop in itemdr.Properties())
                        {
                            if (prop.Value.Type != JTokenType.Null)
                            {
                                Type dataType = dataTypes[prop.Name];
                                row[prop.Name] = prop.Value.ToObject(dataType);
                            }
                        }
                        table.Rows.Add(row);
                    }
                    dsResult.Tables.Add(table);
                }
                return dsResult;
            }
            private Type GetDataType(JTokenType tokenType)
            {
                switch (tokenType)
                {
                    case JTokenType.Null:
                        return null;
                    case JTokenType.String:
                        return typeof(string);
                    case JTokenType.Integer:
                        return typeof(long);
                    case JTokenType.Float:
                        return typeof(decimal);
                    case JTokenType.Boolean:
                        return typeof(bool);
                    case JTokenType.Date:
                        return typeof(DateTime);
                    case JTokenType.TimeSpan:
                        return typeof(TimeSpan);
                    case JTokenType.Guid:
                        return typeof(Guid);
                    case JTokenType.Bytes:
                        return typeof(byte[]);
                    case JTokenType.Array:
                    case JTokenType.Object:
                        throw new JsonException("This converter does not support complex types");
                    default:
                        return typeof(string);
                }
            }
            public override bool CanWrite
            {
                get { return false; }
            }
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                throw new NotImplementedException();
            }
        }
    }
}
HandleData/XkyApiHelper.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,155 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
using System.Web.Script.Serialization;
namespace DataexchangeServer.Helper
{
    /// SignUnit ç­¾åå±žæ€§å¸¸é‡ç±»
    public class SignConst
    {
        public SignConst()
        {
            //this.appKey = "270ea37852e8f7cced1c2a7198b818b1";
           // this.operateCompanyCode = "40373154";
           // this.ownerCompanyCode = "40373154";
           // this.appSecret = "d74b514466f3dac0136b5672b914176a";
            this.appKey = "86d3ae868978beff0d39948c420ec4ff";
            this.operateCompanyCode = "52265397";
            this.ownerCompanyCode = "52265397";
            this.appSecret = "978f5b950aefc3c1e0d4a56a562b0f8c";
          //  this.appKey = "56d6b68cd8fff627bf3203b44d9c8821";
          //  this.operateCompanyCode = "19378112";
          //  this.ownerCompanyCode = "19378112";
          //  this.appSecret = "4b26874c9d7ee95c3de85390d96dbbaf";
            this.version = "1.0";
        }
        public string appKey { get; set; }
        public string version { get; set; }
        public string operateCompanyCode { get; set; }
        public string ownerCompanyCode { get; set; }
        public string appSecret { get; set; }
    }
}
namespace DataexchangeServer.Helper
{
    /// API相关参数定义的全局类
    public partial class ApiGlobal
    {
        public ApiGlobal() { }
        /// åˆå§‹åŒ–
        public static void Init()
        {
            signConst = new SignConst();
        }
        public static SignConst signConst { get; set; }
    }
}
namespace DataexchangeServer.Helper
{
    /// SignUtils ç­¾åå·¥å…·ç±»
    public class SignUtils
    {
        public static MD5 md5 = MD5.Create();
        private static IEnumerator<KeyValuePair<string, string>> dem;
        public static object buildCurrentSign(IDictionary<string, string> parameters, String appSecret)
        {
            try
            {
                string secret = ":" + appSecret;
                IDictionary<string, string> sortedParams = new SortedDictionary<string, string>(parameters, StringComparer.Ordinal);
            //    IEnumerator < KeyValuePair<string, string> & Gt;
                dem = sortedParams.GetEnumerator();
                StringBuilder query = new StringBuilder();
                while (dem.MoveNext())
                {
                    string key = dem.Current.Key;
                    string value = dem.Current.Value;
                    if (key == "sign")
                    {
                        continue;
                    }
                    if (!string.IsNullOrEmpty(key))
                    {
                        query.Append(value).Append(":");
                    }
                }
                string strvalue = query.ToString().TrimEnd(':') + secret;
                return MD5Encrypt32(strvalue);
            }
            catch (Exception)
            {
                throw new Exception("签名异常!");
            }
        }
        public static string MD5Encrypt32(string text)
        {
            string pwd = "";
            // åŠ å¯†åŽæ˜¯ä¸€ä¸ªå­—èŠ‚ç±»åž‹çš„æ•°ç»„ï¼Œè¿™é‡Œè¦æ³¨æ„ç¼–ç UTF8/Unicode的选择 
            byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(text));
            // é€šè¿‡ä½¿ç”¨å¾ªçŽ¯ï¼Œå°†å­—èŠ‚ç±»åž‹çš„æ•°ç»„è½¬æ¢ä¸ºå­—ç¬¦ä¸²ï¼Œæ­¤å­—ç¬¦ä¸²æ˜¯å¸¸è§„å­—ç¬¦æ ¼å¼åŒ–æ‰€å¾—
            for (int i = 0; i < s.Length; i++)
            {
                //将得到的字符串使用十六进制类型格式。格式后的字符是小写的字母,如果使用大写(X)则格式后的字符是大写字符
                pwd = pwd + s[i].ToString("x2");
            }
            return pwd.ToString().ToLower();
        }
        public static long GetTimestamp(DateTime d)
        {
            TimeSpan ts = d.ToUniversalTime() - new DateTime(1970, 1, 1);
            return (long)ts.TotalSeconds;     //精确到秒
        }
    }
}
namespace DataexchangeServer.Helper
{
    /// ApiCommonParam API请求对应的Common参数类
    public class ApiCommonParam
    {
        public ApiCommonParam() { }
        public ApiCommonParam(string appKey, string version, string operateCompanyCode, string ownerCompanyCode, long timestamps)
        {
            this.appKey = appKey;
            this.version = version;
            this.operateCompanyCode = operateCompanyCode;
            this.ownerCompanyCode = ownerCompanyCode;
            this.timestamps = timestamps;
        }
        public string appKey { get; set; }//appKey
        public string version { get; set; }//接口版本
        public string ownerCompanyCode { get; set; }//数据所属公司编码
        public string operateCompanyCode { get; set; }//操作者所属公司编码
        public string sign { get; set; }//签名
        public long timestamps { get; set; }//请求的时间戳
     //   public object reserver { get; set; }//扩展字段
        /// æž„造对象
        public static ApiCommonParam NewApiCommon()
        {
            //构造对象
            ApiCommonParam param = new ApiCommonParam(ApiGlobal.signConst.appKey, ApiGlobal.signConst.version, ApiGlobal.signConst.operateCompanyCode, ApiGlobal.signConst.ownerCompanyCode, SignUtils.GetTimestamp(DateTime.Now));
            //计算签名&赋值
            JavaScriptSerializer json = new JavaScriptSerializer();
            string jsonParam = json.Serialize(param);
            var paramDict = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonParam);
            param.sign = (string)SignUtils.buildCurrentSign(paramDict, ApiGlobal.signConst.appSecret);
            return param;
        }
    }
}
Helper/JSONHelper.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace DataexchangeServer
{
    /// <summary>
    /// JSON帮助方法
    /// </summary>
    public class JSONHelper
    {
        /// <summary>
        /// å°†json转换为DataTable
        /// </summary>
        /// <param name="strJson">得到的json</param>
        /// <returns></returns>
        public static DataTable JsonToDataTable(string strJson)
        {
            DataTable tb = null;
            if (strJson.IndexOf("\"|") > -1 || strJson.IndexOf("\"#+#") > -1)
            {
                return tb;
            }
            strJson = strJson.Replace("\",", "\"|").Replace("\":", "\"#+#").ToString();
            //取出表名
            var rg = new Regex(@"(?<={)[^:]+(?=:\[)", RegexOptions.IgnoreCase);
            string strName = rg.Match(strJson).Value;
            //去除表名
            strJson = strJson.Substring(strJson.IndexOf("[") + 1);
            strJson = strJson.Substring(0, strJson.IndexOf("]"));
            //获取数据
            rg = new Regex(@"(?<={)[^}]+(?=})");
            MatchCollection mc = rg.Matches(strJson);
            for (int i = 0; i < mc.Count; i++)
            {
                string strRow = mc[i].Value;
                string[] strRows = strRow.Split('|');
                //创建表
                if (tb == null)
                {
                    tb = new DataTable();
                    tb.TableName = strName;
                    foreach (string str in strRows)
                    {
                        var dc = new DataColumn();
                        string[] strCell = str.Split(new string[] { "#+#" }, StringSplitOptions.None);
                        if (strCell[0].Substring(0, 1) == "\"")
                        {
                            int a = strCell[0].Length;
                            dc.ColumnName = strCell[0].Substring(1, a - 2);
                        }
                        else
                        {
                            dc.ColumnName = strCell[0];
                        }
                        tb.Columns.Add(dc);
                    }
                    tb.AcceptChanges();
                }
                //增加内容
                DataRow dr = tb.NewRow();
                for (int r = 0; r < strRows.Length; r++)
                {
                    dr[r] = strRows[r].Split(new string[] { "#+#" }, StringSplitOptions.None)[1].Trim().Replace(",", ",").Replace(":", ":").Replace("\"", "");
                }
                tb.Rows.Add(dr);
                tb.AcceptChanges();
            }
            return tb;
        }
        static object obj = new object();
        /// <summary>
        /// å†™å…¥æ–‡ä»¶
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static bool WriteToFile(string msg)
        {
            if (msg.Trim() == "") return true;
            try
            {
                lock (obj)
                {
                    string fileFolder = Environment.CurrentDirectory + @"\log\";
                    if (!Directory.Exists(fileFolder))
                    {
                        DirectoryInfo directoryInfo = new DirectoryInfo(fileFolder);
                        directoryInfo.Create();
                    }
                    string path = fileFolder + DateTime.Now.ToString("yyyyMMdd HH-mm") + ".txt";
                    using (FileStream fs = new FileStream(path, FileMode.Append, FileAccess.Write))
                    {
                        byte[] bytes = Encoding.Default.GetBytes(msg);
                        //fs.WriteTimeout = 10000;
                        fs.Write(bytes, 0, bytes.Length);
                        fs.Close();
                    }
                    return true;
                }
            }
            catch (Exception ex)
            {
                return false;
            }
        }
    }
}
Helper/SQLHelper.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,698 @@
using System.Collections.Generic;
namespace DataexchangeServer
{
    using System;
    using System.Collections;
    using System.Collections.Specialized;
    using System.Data;
    using System.Data.Sql;
    using System.Data.SqlClient;
    using System.Text.RegularExpressions;
    public class SQLHelper : ICloneable, IDisposable
    {
        private SqlConnection _connection4Tran;
        private readonly string _connectionString;
        private SqlTransaction _transaction;
        private readonly Queue<SqlTask> _transactionTaskList;
        public SQLHelper(string connectionString)
        {
            _transactionTaskList = new Queue<SqlTask>();
            this._connectionString = connectionString;
        }
        public SQLHelper(string server, string userID, string password, string database)
        {
            _transactionTaskList = new Queue<SqlTask>();
            if (database == string.Empty)
            {
                this._connectionString = "Data Source=" + server + ";User ID=" + userID + ";Password=" + password;
            }
            else
            {
                this._connectionString = "Data Source=" + server + ";User ID=" + userID + ";Password=" + password + ";Initial Catalog=" + database;
            }
        }
        public void BeginTransaction(IsolationLevel isolationLevel)
        {
            if ((this._transaction != null) || (this._connection4Tran != null))
            {
                throw new Exception("要开始一个新的事务,请先完成当前事务!");
            }
            this._connection4Tran = new SqlConnection(this._connectionString);
            this._connection4Tran.Open();
            this._transaction = this._connection4Tran.BeginTransaction(isolationLevel);
            _transactionTaskList.Clear();
        }
        public void CancelTransaction()
        {
            if (this._transaction != null)
            {
                this._transaction.Dispose();
            }
            if (this._connection4Tran != null)
            {
                this._connection4Tran.Close();
            }
            if (this._connection4Tran != null)
            {
                this._connection4Tran.Dispose();
            }
            this._transaction = null;
            this._connection4Tran = null;
        }
        public object Clone()
        {
            return new SQLHelper(this._connectionString);
        }
        public void CommitTransaction()
        {
            try
            {
                if (_transactionTaskList.Count > 0)
                {
                    foreach (SqlTask sqlTask in _transactionTaskList)
                    {
                        using (var command = new SqlCommand(sqlTask.Text, _connection4Tran))
                        {
                            command.CommandType = sqlTask.CommandType;
                            if (sqlTask.Parameters != null)
                            {
                                foreach (SqlParameter parameter in sqlTask.Parameters)
                                {
                                    command.Parameters.Add(parameter);
                                }
                            }
                            command.Transaction = _transaction;
                            command.ExecuteNonQuery();
                        }
                    }
                }
                this._transaction.Commit();
            }
            catch (Exception)
            {
                this._transaction.Rollback();
            }
            finally
            {
                if (this._transaction != null)
                {
                    this._transaction.Dispose();
                }
                if (this._connection4Tran != null)
                {
                    this._connection4Tran.Close();
                }
                if (this._connection4Tran != null)
                {
                    this._connection4Tran.Dispose();
                }
                this._transaction = null;
                this._connection4Tran = null;
            }
        }
        public DataSet ExecuteDataSet(string sql)
        {
            return this.ExecuteDataSet(sql, CommandType.Text, null);
        }
        public DataSet ExecuteDataSet(string sql, CommandType commandType)
        {
            return this.ExecuteDataSet(sql, commandType, null);
        }
        public DataSet ExecuteDataSet(string sql, CommandType commandType, SqlParameter[] parameters)
        {
            DataSet dataSet = new DataSet(Guid.NewGuid().ToString());
            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.CommandType = commandType;
                    if (parameters != null)
                    {
                        foreach (SqlParameter parameter in parameters)
                        {
                            command.Parameters.Add(parameter);
                        }
                    }
                    new SqlDataAdapter(command).Fill(dataSet);
                }
            }
            return dataSet;
        }
        public DataTable ExecuteDataTable(string sql)
        {
            return this.ExecuteDataTable(sql, CommandType.Text, null);
        }
        public DataTable ExecuteDataTable(string sql, CommandType commandType)
        {
            return this.ExecuteDataTable(sql, commandType, null);
        }
        public DataTable ExecuteDataTable(string sql, CommandType commandType, SqlParameter[] parameters)
        {
            DataTable dataTable = new DataTable(Guid.NewGuid().ToString());
            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.CommandType = commandType;
                    if (parameters != null)
                    {
                        foreach (SqlParameter parameter in parameters)
                        {
                            command.Parameters.Add(parameter);
                        }
                    }
                    new SqlDataAdapter(command).Fill(dataTable);
                }
            }
            return dataTable;
        }
        public int ExecuteNonQuery(string sql)
        {
            return this.ExecuteNonQuery(sql, CommandType.Text, null);
        }
        public int ExecuteNonQuery(string sql, CommandType commandType)
        {
            return this.ExecuteNonQuery(sql, commandType, null);
        }
        public int ExecuteNonQuery(string sql, CommandType commandType, SqlParameter[] parameters)
        {
            return this.ExecuteNonQuery(sql, commandType, parameters, false);
        }
        public int ExecuteNonQuery(string sql, CommandType commandType, SqlParameter[] parameters, bool joinTransaction)
        {
            int num;
            SqlCommand command;
            if (joinTransaction)
            {
                if ((this._transaction == null) || (this._connection4Tran == null))
                {
                    throw new Exception("事务未初始化!");
                }
                _transactionTaskList.Enqueue(new SqlTask(sql, commandType, parameters));
            }
            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                using (command = new SqlCommand(sql, connection))
                {
                    command.CommandType = commandType;
                    if (parameters != null)
                    {
                        foreach (SqlParameter parameter in parameters)
                        {
                            command.Parameters.Add(parameter);
                        }
                    }
                    connection.Open();
                    num = command.ExecuteNonQuery();
                }
            }
            return num;
        }
        public SqlDataReader ExecuteReader(string sql)
        {
            return this.ExecuteReader(sql, CommandType.Text, null);
        }
        public SqlDataReader ExecuteReader(string sql, CommandType commandType)
        {
            return this.ExecuteReader(sql, commandType, null);
        }
        public SqlDataReader ExecuteReader(string sql, CommandType commandType, SqlParameter[] parameters)
        {
            SqlConnection connection = new SqlConnection(this._connectionString);
            SqlCommand command = new SqlCommand(sql, connection)
            {
                CommandType = commandType
            };
            if (parameters != null)
            {
                foreach (SqlParameter parameter in parameters)
                {
                    command.Parameters.Add(parameter);
                }
            }
            connection.Open();
            return command.ExecuteReader(CommandBehavior.CloseConnection);
        }
        public object ExecuteScalar(string sql)
        {
            return this.ExecuteScalar(sql, CommandType.Text, null);
        }
        public object ExecuteScalar(string sql, CommandType commandType)
        {
            return this.ExecuteScalar(sql, commandType, null);
        }
        public object ExecuteScalar(string sql, CommandType commandType, SqlParameter[] parameters)
        {
            object obj2;
            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.CommandType = commandType;
                    if (parameters != null)
                    {
                        foreach (SqlParameter parameter in parameters)
                        {
                            command.Parameters.Add(parameter);
                        }
                    }
                    connection.Open();
                    obj2 = command.ExecuteScalar();
                }
            }
            return obj2;
        }
        public DataTable GetDatabases()
        {
            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                connection.Open();
                return connection.GetSchema("Databases");
            }
        }
        public static ArrayList GetServerList()
        {
            ArrayList list = new ArrayList();
            foreach (DataRow row in SqlDataSourceEnumerator.Instance.GetDataSources().Rows)
            {
                list.Add(row[0].ToString());
            }
            return list;
        }
        public DataTable GetTables()
        {
            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                connection.Open();
                return connection.GetSchema("Tables");
            }
        }
        public bool SaveDataToDB(DataSet dataSet)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(this._connectionString))
                {
                    foreach (DataTable table in dataSet.Tables)
                    {
                        using (SqlCommand command = new SqlCommand("SELECT * FROM " + table.TableName + " WHERE 1<1", connection))
                        {
                            SqlDataAdapter adapter = new SqlDataAdapter(command);
                            SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
                            adapter.UpdateBatchSize = 100;
                            DataTable tbchange = table.GetChanges();
                            if (tbchange != null)
                                adapter.Update(table.GetChanges());
                        }
                    }
                }
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
        public bool SaveDataToDB(DataTable dataTable)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(this._connectionString))
                {
                    using (SqlCommand command = new SqlCommand("select top 0 * from " + dataTable.TableName, connection))
                    {
                        SqlDataAdapter adapter = new SqlDataAdapter(command);
                        SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
                        adapter.UpdateBatchSize = 100;
                        DataTable tbchange = dataTable.GetChanges();
                        if (tbchange != null)
                            adapter.Update(dataTable);
                    }
                }
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
        public bool SaveDataToDB(DataSet oldDataSet, DataSet newDataSet)
        {
            //bool flag;
            oldDataSet.Merge(newDataSet, false);
            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                connection.Open();
                SqlTransaction transaction = connection.BeginTransaction();
                try
                {
                    foreach (DataTable table in oldDataSet.Tables)
                    {
                        using (SqlCommand command = new SqlCommand("SELECT * FROM " + table.TableName + " WHERE 1<1", connection, transaction))
                        {
                            SqlDataAdapter adapter = new SqlDataAdapter(command);
                            SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
                            adapter.UpdateBatchSize = 500;
                            adapter.Update(table);
                        }
                    }
                    transaction.Commit();
                    return true;
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    throw;
                }
                finally
                {
                    if (transaction != null)
                    {
                        transaction.Dispose();
                    }
                }
            }
            //return flag;
        }
        public bool SaveDataToDB(DataTable oldDataTable, DataTable newDataTable)
        {
            bool flag;
            oldDataTable.Merge(newDataTable, false);
            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                using (SqlCommand command = new SqlCommand("SELECT * FROM " + oldDataTable.TableName + " WHERE 1<1", connection))
                {
                    SqlDataAdapter adapter = new SqlDataAdapter(command);
                    SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
                    adapter.UpdateBatchSize = 100;
                    adapter.Update(oldDataTable);
                    flag = true;
                }
            }
            return flag;
        }
        public bool TestConnection()
        {
            bool flag;
            try
            {
                using (SqlConnection connection = new SqlConnection(this._connectionString))
                {
                    connection.Open();
                    connection.Close();
                    flag = true;
                }
            }
            catch (Exception)
            {
                flag = false;
            }
            return flag;
        }
        #region IDisposable æˆå‘˜
        public void Dispose()
        {
            _connection4Tran = null;
            _transaction = null;
        }
        #endregion
        private class SqlTask
        {
            public string Text { get; private set; }
            public CommandType CommandType { get; private set; }
            public SqlParameter[] Parameters { get; private set; }
            public SqlTask(string text, CommandType commandType, SqlParameter[] paras)
            {
                Text = text;
                CommandType = commandType;
                Parameters = paras;
            }
        }
        //public bool Save(DataTable Table, bool UpdateTableStatus, bool UseTransaction, bool ShowMsg)
        //{
        //    //如果不需要保存则退出。
        //    if (Table == null  )
        //        return true;
        //    SqlDataAdapter dataAdapter = new SqlDataAdapter();
        //        dataAdapter.UpdateCommand = GetUpdateCmd(Table);
        //        dataAdapter.InsertCommand = GetInsertCmd(Table);
        //        dataAdapter.DeleteCommand = GetDeleteCmd(Table);
        //    if (DBTransaction != null)
        //    {
        //        if (dataAdapter.SelectCommand != null) dataAdapter.SelectCommand.Transaction = DBTransaction;
        //        if (dataAdapter.DeleteCommand != null) dataAdapter.DeleteCommand.Transaction = DBTransaction;
        //        if (dataAdapter.InsertCommand != null) dataAdapter.InsertCommand.Transaction = DBTransaction;
        //        if (dataAdapter.UpdateCommand != null) dataAdapter.UpdateCommand.Transaction = DBTransaction;
        //    }
        //    //更新数据
        //    try
        //    {
        //        //启动事务
        //        if (UseTransaction == true)
        //            StartTransaction();
        //        DataTable tb_changes = Table.GetChanges();
        //        if (tb_changes != null)
        //            dataAdapter.Update(tb_changes);
        //        else if (HandCreateCmd == true)
        //            dataAdapter.Update(Table);
        //        //提交事务
        //        if (UseTransaction == true)
        //            CommitTransaction();
        //        //修改表状态 å¦‚果前面的处理出错,那么这里也不会执行,Datatable将继续保留状态.
        //        if (UpdateTableStatus == true)
        //            Table.AcceptChanges();
        //        ExecuteExcetion = null;
        //    }
        //    catch (Exception e)
        //    {
        //        string errorMsg = "";
        //        //2627表示主键重复,才需要重取单号。
        //        if (e is SqlException)
        //        {
        //            SqlException sqlExcept = e as SqlException;
        //            SaveKeyExist = (sqlExcept.Number == 2627);
        //            if (sqlExcept.Number == 2627)
        //                errorMsg = "当前数据表已有此记录,请确认后再保存!";
        //            else
        //                errorMsg = ((SqlException)e).Message;
        //        }
        //        if (e is DBConcurrencyException)
        //        {
        //            DBConcurrencyException dbexception = (e as DBConcurrencyException);
        //            errorMsg = dbexception.Row.RowError;
        //            if (errorMsg.Contains("影响") == true && dbexception.Row.RowState == DataRowState.Deleted)
        //                errorMsg = "当前数据行已删除,请重新查询!";
        //            if (errorMsg.Contains("影响") == true && dbexception.Row.RowState == DataRowState.Modified)
        //                errorMsg = "当前数据行已修改,请重新查询!";
        //        }
        //        //
        //        ShowMsg = ShowMsg || ShowMsgWhenSaveChildTableOnError;
        //        ExecuteExcetion = e;
        //        //保存失败回滚事务
        //        if (UseTransaction == true)
        //            RollbackTransaction();
        //        errorMsg = (errorMsg == "") ? GetErrorMsg(e) : errorMsg;
        //        WriteLog(Format("保存{0}失败,错误信息如下:{1}", Table.TableName, errorMsg), ShowMsg);
        //        return false;
        //    }
        //    finally
        //    {
        //        Table.State = OptionState.Browse;
        //    }
        //    if (ShowMsg == true || MustSaveLog == true)
        //    {
        //        /* å…³äºŽShowMsg参数的使用说明:
        //         * A方法:Save(bool UseTransaction, bool ShowMsg);
        //         * B方法:Save(DataTableExt Table,bool UpdateTableStatus, bool UseTransaction, bool ShowMsg);
        //         *
        //         * A方法调用B方法时,是不需要提示"保存成功"的信息,所以A方法传的ShowMsg=false,但A希望在调用B方法出错时,
        //         * æç¤ºé”™è¯¯ä¿¡æ¯"保存**失败..",所以原来B方法Catch中硬编码 ShowMsg=true;在执行改方法时,不管是否需要提示,系统都会提示信息(这有违背方法本意)。
        //         *
        //         * çŽ°åœ¨å¸Œæœ›èƒ½åˆ©æ­£ç¡®ä½¿ç”¨ShowMsg参数,所以引入了ShowMsgWhenSaveChildTableOnError属性(默认True)。
        //         * å½“ShowMsgWhenSaveChildTableOnError等于True或ShowMsg等于True时,Catch中就会提示错误信息。
        //         *
        //         * å•据类BillClass保存时,由于特殊处理,希望过程中不提示错误信息,所以在保存时Save(UseTransaction, ShowMsg==false)和设置ShowMsgWhenSaveChildTableOnError=false。
        //         */
        //        WriteLog(string.Format("保存{0}成功!", Table.TableName), ShowMsg);
        //    }
        //    return true;
        //}
        // <summary>
        // å¾—到更新命令
        // </summary>
        // <returns></returns>
        //public SqlCommand GetUpdateCmd(DataTable MyTable, SqlConnection DBConn)
        //{
        //    ç”Ÿæˆæ›´æ–°è¯­å¥
        //    string strSQL = string.Format("Update {0} Set ", MyTable.TableName);
        //    foreach (DataColumn col in MyTable.Columns)
        //    {
        //        strSQL = string.Format("{0} {1}=@{1},", strSQL, col.ColumnName);
        //    }
        //    strSQL = strSQL.Substring(0, strSQL.Length - 1);
        //    StringCollection KeyList = new StringCollection();
        //    KeyList.Add("taskid");
        //    æ ¹æ®ä¸»é”®è®¾ç½®Where条件
        //    string strWhere = "";
        //    foreach (string Key in KeyList)
        //    {
        //        strWhere = strWhere == "" ? string.Format("{0}=@{0}", Key) : string.Format("{0} and {1}=@{1}", strWhere, Key);
        //    }
        //    strSQL = string.Format("{0} where {1}", strSQL, strWhere);
        //    SqlCommand updateCmd = new SqlCommand(strSQL, DBConn);
        //    æ·»åŠ å‚æ•°
        //    foreach (DataColumn col in MyTable.Columns)
        //    {
        //        æŽ’除不用保存字段。
        //        SqlDbType SQLType = DataTypeMap.CSTypeToSqlType(col.DataType.Name);
        //        int Size = (col.MaxLength > 0) ? col.MaxLength : 100;
        //        updateCmd.Parameters.Add("@" + col.ColumnName, SQLType, Size, col.ColumnName);
        //    }
        //    return updateCmd;
        //}
        ///// <summary>
        ///// å¾—到插入命令
        ///// </summary>
        ///// <returns></returns>
        //public SqlCommand GetInsertCmd(DataTable MyTable)
        //{
        //    //取得主键
        //    List<string> KeyList = new List<string>();
        //    KeyList.AddRange(MyTable.KeyField.Split(';'));
        //    if (KeyList.Count <= 0)
        //        return null;
        //    //取得不需要更新的字段列表
        //    StringCollection NotSaveFields = new StringCollection();
        //    NotSaveFields.AddRange(MyTable.NotSaveFields.Split(';'));
        //    //生成字段列表和值列表
        //    string strFieldList = "";
        //    string strValueList = "";
        //    foreach (DataColumn col in MyTable.Columns)
        //    {
        //        //排除主键和不用保存字段。
        //        if (NotSaveFields.Contains(col.ColumnName) == true)
        //            continue;
        //        strFieldList = strFieldList == "" ? col.ColumnName : string.Format("{0},{1}", strFieldList, col.ColumnName);
        //        strValueList = strValueList == "" ? "@" + col.ColumnName : string.Format("{0},@{1}", strValueList, col.ColumnName);
        //    }
        //    string strSQL = string.Format("Insert Into {0} ({1}) Values({2})", MyTable.UpdateTable, strFieldList, strValueList);
        //    //创建命令
        //    SqlCommand InsertCmd = new SqlCommand(strSQL, DBConn);
        //    //添加参数
        //    foreach (DataColumn col in MyTable.Columns)
        //    {
        //        //排除主键和不用保存字段。
        //        if (NotSaveFields.Contains(col.ColumnName) == true)
        //            continue;
        //        SqlDbType SQLType = DataTypeMap.CSTypeToSqlType(col.DataType.Name);
        //        int Size = (col.MaxLength > 0) ? col.MaxLength : 100;
        //        InsertCmd.Parameters.Add("@" + col.ColumnName, SQLType, Size, col.ColumnName);
        //    }
        //    return InsertCmd;
        //}
        ///// <summary>
        ///// å¾—到删除命令
        ///// </summary>
        ///// <returns></returns>
        //public SqlCommand GetDeleteCmd(DataTable MyTable)
        //{
        //    //取得主键
        //    List<string> KeyList = new List<string>();
        //    KeyList.AddRange(MyTable.KeyField.Split(';'));
        //    if (KeyList.Count <= 0)
        //        return null;
        //    //生成更新语句
        //    string strSQL = string.Format("Delete {0} ", MyTable.UpdateTable);
        //    //根据主键设置Where条件
        //    string strWhere = "";
        //    foreach (string Key in KeyList)
        //    {
        //        strWhere = strWhere == "" ? string.Format("{0}=@{0}", Key) : string.Format("{0} and {1}=@{1}", strWhere, Key);
        //    }
        //    strSQL = string.Format("{0} where {1}", strSQL, strWhere);
        //    SqlCommand DeleteCmd = new SqlCommand(strSQL, DBConn);
        //    //添加参数
        //    foreach (string Key in KeyList)
        //    {
        //        DataColumn col = MyTable.Columns[Key];
        //        SqlDbType SQLType = DataTypeMap.CSTypeToSqlType(col.DataType.Name);
        //        int Size = (col.MaxLength > 0) ? col.MaxLength : 100;
        //        DeleteCmd.Parameters.Add("@" + col.ColumnName, SQLType, Size, col.ColumnName);
        //    }
        //    return DeleteCmd;
        //}
    }
}
Program.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DataexchangeServer
{
    static class Program
    {
        /// <summary>
        /// åº”用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());
        }
    }
}
Properties/AssemblyInfo.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// æœ‰å…³ç¨‹åºé›†çš„常规信息通过以下
// ç‰¹æ€§é›†æŽ§åˆ¶ã€‚更改这些特性值可修改
// ä¸Žç¨‹åºé›†å…³è”的信息。
[assembly: AssemblyTitle("DataexchangeServer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("DataexchangeServer")]
[assembly: AssemblyCopyright("Copyright Â© Microsoft 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// å°† ComVisible è®¾ç½®ä¸º false ä½¿æ­¤ç¨‹åºé›†ä¸­çš„类型
// å¯¹ COM ç»„件不可见。  å¦‚果需要从 COM è®¿é—®æ­¤ç¨‹åºé›†ä¸­çš„类型,
// åˆ™å°†è¯¥ç±»åž‹ä¸Šçš„ ComVisible ç‰¹æ€§è®¾ç½®ä¸º true。
[assembly: ComVisible(false)]
// å¦‚果此项目向 COM å…¬å¼€ï¼Œåˆ™ä¸‹åˆ— GUID ç”¨äºŽç±»åž‹åº“çš„ ID
[assembly: Guid("32078dd5-fe6e-467b-8868-2533df57928b")]
// ç¨‹åºé›†çš„版本信息由下面四个值组成:
//
//      ä¸»ç‰ˆæœ¬
//      æ¬¡ç‰ˆæœ¬
//      ç”Ÿæˆå·
//      ä¿®è®¢å·
//
// å¯ä»¥æŒ‡å®šæ‰€æœ‰è¿™äº›å€¼ï¼Œä¹Ÿå¯ä»¥ä½¿ç”¨â€œç”Ÿæˆå·â€å’Œâ€œä¿®è®¢å·â€çš„默认值,
// æ–¹æ³•是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Properties/Resources.Designer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
//     æ­¤ä»£ç ç”±å·¥å…·ç”Ÿæˆã€‚
//     è¿è¡Œæ—¶ç‰ˆæœ¬:4.0.30319.42000
//
//     å¯¹æ­¤æ–‡ä»¶çš„æ›´æ”¹å¯èƒ½ä¼šå¯¼è‡´ä¸æ­£ç¡®çš„行为,并且如果
//     é‡æ–°ç”Ÿæˆä»£ç ï¼Œè¿™äº›æ›´æ”¹å°†ä¼šä¸¢å¤±ã€‚
// </auto-generated>
//------------------------------------------------------------------------------
namespace DataexchangeServer.Properties {
    using System;
    /// <summary>
    ///   ä¸€ä¸ªå¼ºç±»åž‹çš„资源类,用于查找本地化的字符串等。
    /// </summary>
    // æ­¤ç±»æ˜¯ç”± StronglyTypedResourceBuilder
    // ç±»é€šè¿‡ç±»ä¼¼äºŽ ResGen æˆ– Visual Studio çš„工具自动生成的。
    // è‹¥è¦æ·»åŠ æˆ–ç§»é™¤æˆå‘˜ï¼Œè¯·ç¼–è¾‘ .ResX æ–‡ä»¶ï¼Œç„¶åŽé‡æ–°è¿è¡Œ ResGen
    // (以 /str ä½œä¸ºå‘½ä»¤é€‰é¡¹),或重新生成 VS é¡¹ç›®ã€‚
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    internal class Resources {
        private static global::System.Resources.ResourceManager resourceMan;
        private static global::System.Globalization.CultureInfo resourceCulture;
        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        internal Resources() {
        }
        /// <summary>
        ///   è¿”回此类使用的缓存的 ResourceManager å®žä¾‹ã€‚
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Resources.ResourceManager ResourceManager {
            get {
                if (object.ReferenceEquals(resourceMan, null)) {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DataexchangeServer.Properties.Resources", typeof(Resources).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }
        }
        /// <summary>
        ///   é‡å†™å½“前线程的 CurrentUICulture å±žæ€§ï¼Œå¯¹
        ///   ä½¿ç”¨æ­¤å¼ºç±»åž‹èµ„源类的所有资源查找执行重写。
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Globalization.CultureInfo Culture {
            get {
                return resourceCulture;
            }
            set {
                resourceCulture = value;
            }
        }
    }
}
Properties/Resources.resx
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!--
    Microsoft ResX Schema
    Version 2.0
    The primary goals of this format is to allow a simple XML format
    that is mostly human readable. The generation and parsing of the
    various data types are done through the TypeConverter classes
    associated with the data types.
    Example:
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
    There are any number of "resheader" rows that contain simple
    name/value pairs.
    Each data row contains a name, and value. The row also contains a
    type or mimetype. Type corresponds to a .NET class that support
    text/value conversion through the TypeConverter architecture.
    Classes that don't support this are serialized and stored with the
    mimetype set.
    The mimetype is used for serialized objects, and tells the
    ResXResourceReader how to depersist the object. This is currently not
    extensible. For a given mimetype the value must be set accordingly:
    Note - application/x-microsoft.net.object.binary.base64 is the format
    that the ResXResourceWriter will generate, however the reader can
    read any of the formats listed below.
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with
            : System.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
</root>
Properties/Settings.Designer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,56 @@
//------------------------------------------------------------------------------
// <auto-generated>
//     æ­¤ä»£ç ç”±å·¥å…·ç”Ÿæˆã€‚
//     è¿è¡Œæ—¶ç‰ˆæœ¬:4.0.30319.42000
//
//     å¯¹æ­¤æ–‡ä»¶çš„æ›´æ”¹å¯èƒ½ä¼šå¯¼è‡´ä¸æ­£ç¡®çš„行为,并且如果
//     é‡æ–°ç”Ÿæˆä»£ç ï¼Œè¿™äº›æ›´æ”¹å°†ä¼šä¸¢å¤±ã€‚
// </auto-generated>
//------------------------------------------------------------------------------
namespace DataexchangeServer.Properties {
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")]
    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
        public static Settings Default {
            get {
                return defaultInstance;
            }
        }
        [global::System.Configuration.ApplicationScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)]
        [global::System.Configuration.DefaultSettingValueAttribute("http://36.134.102.119:8888/ykd/api")]
        public string DataexchangeServer_WebReference_UserServiceImplService {
            get {
                return ((string)(this["DataexchangeServer_WebReference_UserServiceImplService"]));
            }
        }
        [global::System.Configuration.ApplicationScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)]
        [global::System.Configuration.DefaultSettingValueAttribute("http://36.134.102.119:9998/ykd/api")]
        public string DataexchangeServer_WebReferenceLD_UserServiceImplService {
            get {
                return ((string)(this["DataexchangeServer_WebReferenceLD_UserServiceImplService"]));
            }
        }
        [global::System.Configuration.ApplicationScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)]
        [global::System.Configuration.DefaultSettingValueAttribute("http://36.134.102.119:9998/ykd/api")]
        public string DataexchangeServer_WebReferenceLD1_UserServiceImplService {
            get {
                return ((string)(this["DataexchangeServer_WebReferenceLD1_UserServiceImplService"]));
            }
        }
    }
}
Properties/Settings.settings
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,15 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="DataexchangeServer.Properties" GeneratedClassName="Settings">
  <Profiles />
  <Settings>
    <Setting Name="DataexchangeServer_WebReference_UserServiceImplService" Type="(Web Service URL)" Scope="Application">
      <Value Profile="(Default)">http://36.134.102.119:8888/ykd/api</Value>
    </Setting>
    <Setting Name="DataexchangeServer_WebReferenceLD_UserServiceImplService" Type="(Web Service URL)" Scope="Application">
      <Value Profile="(Default)">http://36.134.102.119:9998/ykd/api</Value>
    </Setting>
    <Setting Name="DataexchangeServer_WebReferenceLD1_UserServiceImplService" Type="(Web Service URL)" Scope="Application">
      <Value Profile="(Default)">http://36.134.102.119:9998/ykd/api</Value>
    </Setting>
  </Settings>
</SettingsFile>
StringHelper.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,1263 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Text;
using System.Text.RegularExpressions;
namespace DataexchangeServer
{
    /// <summary>
    /// å­—符串函数辅助类。
    /// </summary>
    public class StringHelper
    {
        /// <summary>
        /// SQL表达式分解表达式中的特殊参数,包括参数、父记录、记录、全局变量等。
        /// ä¾‹ï¼šå°†è¡¨è¾¾å¼
        ///     ç”Ÿäº§æ•°>90 AND å·¥å·=para:P0123 OR DMA002=parent:DMA001 OR åç§°=field:D01 OR AA=@@01
        ///     ä¸­çš„特殊参数查找出来:para:P0123,parent:DMA001,field:D01,@@01
        /// </summary>
        public const string Rggex_SqlExpression = @"\w+[><=]\w*((para|parent|field|@@)([:]*)+\w*)";
        private static Regex RegexBr = new Regex(@"(\r\n)", RegexOptions.IgnoreCase);
        /// <summary>
        /// å¾—到正则编译参数设置
        /// </summary>
        /// <returns></returns>
        public static RegexOptions GetRegexCompiledOptions()
        {
            #if NET1
               return RegexOptions.Compiled;
            #else
               return RegexOptions.None;
            #endif
        }
        /// <summary>
        /// è¿”回字符串真实长度, 1个汉字长度为2。
        /// </summary>
        /// <returns></returns>
        public static int GetStringLength(string str)
        {
            return Encoding.Default.GetBytes(str).Length;
        }
        /// <summary>
        /// åˆ¤æ–­å­—符串的包含关系。
        /// </summary>
        /// <param name="str">被包含的字符串。</param>
        /// <param name="stringArray">以指定分隔符描述的字符串数组。</param>
        /// <param name="stringSplit">字符串数组的分隔符。</param>
        /// <returns>如果被包含的字符串在指定字符串数组中,则返回true,否则返回false。</returns>
        public static bool IsCompriseString(string str, string stringArray, string stringSplit)
        {
            if (stringArray == "" || stringArray == null)
            {
                return false;
            }
            str = str.ToLower();
            string[] array = SafeSplitString(stringArray.ToLower(), stringSplit);
            for (int i = 0; i < stringArray.Length; i++)
            {
                //string t1 = str;
                //string t2 = stringArray[i];
                if (str.IndexOf(array[i]) > -1)
                {
                    return true;
                }
            }
            return false;
        }
        /// <summary>
        /// åˆ¤æ–­æŒ‡å®šå­—符串在指定字符串数组中的位置。
        /// </summary>
        /// <param name="strSearch">待搜索的字符串。</param>
        /// <param name="stringArray">字符串数组。</param>
        /// <param name="caseInsensetive">是否不区分大小写, true为不区分, false为区分。</param>
        /// <returns>字符串在指定字符串数组中的位置, å¦‚不存在则返回-1。</returns>
        public static int GetIndexInArray(string strSearch, string[] stringArray, bool caseInsensetive)
        {
            for (int i = 0; i < stringArray.Length; i++)
            {
                if (caseInsensetive)
                {
                    if (strSearch.ToLower() == stringArray[i].ToLower())
                    {
                        return i;
                    }
                }
                else
                {
                    if (strSearch == stringArray[i])
                    {
                        return i;
                    }
                }
            }
            return -1;
        }
        /// <summary>
        /// åˆ¤æ–­æŒ‡å®šå­—符串在指定字符串数组中的位置。
        /// </summary>
        /// <param name="strSearch">字符串。</param>
        /// <param name="stringArray">字符串数组。</param>
        /// <returns>字符串在指定字符串数组中的位置, å¦‚不存在则返回-1。</returns>
        public static int GetIndexInArray(string strSearch, string[] stringArray)
        {
            return GetIndexInArray(strSearch, stringArray, true);
        }
        /// <summary>
        /// åˆ¤æ–­æŒ‡å®šå­—符串是否属于指定字符串数组中的一个元素。
        /// </summary>
        /// <param name="strSearch">待搜索的字符串。</param>
        /// <param name="stringArray">字符串数组。</param>
        /// <param name="caseInsensetive">是否不区分大小写, true为不区分, false为区分。</param>
        /// <returns>判断结果。</returns>
        public static bool IsInArray(string strSearch, string[] stringArray, bool caseInsensetive)
        {
            return GetIndexInArray(strSearch, stringArray, caseInsensetive) >= 0;
        }
        /// <summary>
        /// åˆ¤æ–­æŒ‡å®šå­—符串是否属于指定字符串数组中的一个元素。
        /// </summary>
        /// <param name="str">待搜索的字符串。</param>
        /// <param name="stringArray">字符串数组。</param>
        /// <returns>判断结果。</returns>
        public static bool IsInArray(string str, string[] stringArray)
        {
            return IsInArray(str, stringArray, false);
        }
        /// <summary>
        /// åˆ¤æ–­æŒ‡å®šå­—符串是否属于指定字符串数组中的一个元素。
        /// </summary>
        /// <param name="str">待搜索的字符串。</param>
        /// <param name="stringArray">内部以分号分割单词的字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsInArray(string str, string stringArray)
        {
            return IsInArray(str, SafeSplitString(stringArray, ";"), false);
        }
        /// <summary>
        /// åˆ¤æ–­æŒ‡å®šå­—符串是否属于指定字符串数组中的一个元素。
        /// </summary>
        /// <param name="str">待搜索的字符串</param>
        /// <param name="stringArray">内部以指定分割符分割单词的字符串。</param>
        /// <param name="stringSplit">分割字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsInArray(string str, string stringArray, string stringSplit)
        {
            return IsInArray(str, SafeSplitString(stringArray, stringSplit), false);
        }
        /// <summary>
        /// åˆ¤æ–­æŒ‡å®šå­—符串是否属于指定字符串数组中的一个元素。
        /// </summary>
        /// <param name="str">待搜索的字符串</param>
        /// <param name="stringArray">内部以指定分割符分割单词的字符串。</param>
        /// <param name="stringSplit">分割字符串。</param>
        /// <param name="caseInsensetive">是否不区分大小写, true为不区分, false为区分。</param>
        /// <returns>判断结果。</returns>
        public static bool IsInArray(string str, string stringArray, string stringSplit, bool caseInsensetive)
        {
            return IsInArray(str, SafeSplitString(stringArray, stringSplit), caseInsensetive);
        }
        /// <summary>
        /// åˆ é™¤å­—符串尾部的回车/换行/空格符号。
        /// </summary>
        /// <param name="str">待处理的字符串。</param>
        /// <returns>处理后的字符串。</returns>
        public static string RTrim(string str)
        {
            for (int i = str.Length; i >= 0; i--)
            {
                if (str[i].Equals(" ") || str[i].Equals("\r") || str[i].Equals("\n"))
                {
                    str.Remove(i, 1);
                }
            }
            return str;
        }
        /// <summary>
        /// æ¸…除给定字符串中的回车及换行符。
        /// </summary>
        /// <param name="str">要清除的字符串。</param>
        /// <returns>处理后的字符串。</returns>
        public static string SafeClearBR(string str)
        {
            Match m = null;
            for (m = RegexBr.Match(str); m.Success; m = m.NextMatch())
            {
                str = str.Replace(m.Groups[0].ToString(), "");
            }
            return str;
        }
        /// <summary>
        /// ä»Žå­—符串的指定位置截取指定长度的子字符串。
        /// </summary>
        /// <param name="str">原字符串。</param>
        /// <param name="startIndex">子字符串的起始位置。</param>
        /// <param name="length">子字符串的长度。</param>
        /// <returns>子字符串。</returns>
        public static string SafeCutString(string str, int startIndex, int length)
        {
            if (startIndex >= 0)
            {
                if (length < 0)
                {
                    length = length * -1;
                    if (startIndex - length < 0)
                    {
                        length = startIndex;
                        startIndex = 0;
                    }
                    else
                    {
                        startIndex = startIndex - length;
                    }
                }
                if (startIndex > str.Length)
                {
                    return "";
                }
            }
            else
            {
                if (length < 0)
                {
                    return "";
                }
                else
                {
                    if (length + startIndex > 0)
                    {
                        length = length + startIndex;
                        startIndex = 0;
                    }
                    else
                    {
                        return "";
                    }
                }
            }
            if (str.Length - startIndex < length)
            {
                length = str.Length - startIndex;
            }
            return str.Substring(startIndex, length);
        }
        /// <summary>
        /// ä»Žå­—符串的指定位置开始截取到字符串结尾的了符串。
        /// </summary>
        /// <param name="str">原字符串。</param>
        /// <param name="startIndex">子字符串的起始位置。</param>
        /// <returns>子字符串。</returns>
        public static string SafeCutString(string str, int startIndex)
        {
            return SafeCutString(str, startIndex, str.Length);
        }
        /// <summary>
        /// int型转换为string型。
        /// </summary>
        /// <returns>转换后的string类型结果。</returns>
        public static string FromInt(int intValue)
        {
            //
            return Convert.ToString(intValue);
        }
        /// <summary>
        /// å–指定长度的字符串,并在截取时考虑双语字符,当字符串如果操过指定长度则将超出的部分用指定字符串代替。
        /// </summary>
        /// <param name="srcString">要检查的字符串。</param>
        /// <param name="length">指定长度。</param>
        /// <param name="tailString">用于替换的字符串。</param>
        /// <returns>截取后的字符串。</returns>
        public static string GetSubString(string srcString, int length, string tailString)
        {
            return GetSubString(srcString, 0, length, tailString);
        }
        /// <summary>
        /// å–指定长度的字符串,并在截取时考虑双语字符,当字符串如果操过指定长度则将超出的部分用指定字符串代替。
        /// </summary>
        /// <param name="srcString">要检查的字符串。</param>
        /// <param name="startIndex">起始位置。</param>
        /// <param name="length">指定长度。</param>
        /// <param name="tailString">用于替换的字符串。</param>
        /// <returns>截取后的字符串。</returns>
        public static string GetSubString(string srcString, int startIndex, int length, string tailString)
        {
            string myResult = srcString;
            //当是日文或韩文时(注:中文的范围:\u4e00 - \u9fa5, æ—¥æ–‡åœ¨\u0800 - \u4e00, éŸ©æ–‡ä¸º\xAC00-\xD7A3)
            if (System.Text.RegularExpressions.Regex.IsMatch(srcString, "[\u0800-\u4e00]+") ||
                System.Text.RegularExpressions.Regex.IsMatch(srcString, "[\xAC00-\xD7A3]+"))
            {
                //当截取的起始位置超出字段串长度时
                if (startIndex >= srcString.Length)
                {
                    return "";
                }
                else
                {
                    return srcString.Substring(startIndex,
                                                   ((length + startIndex) > srcString.Length) ? (srcString.Length - startIndex) : length);
                }
            }
            if (length >= 0)
            {
                byte[] bsSrcString = Encoding.Default.GetBytes(srcString);
                //当字符串长度大于起始位置
                if (bsSrcString.Length > startIndex)
                {
                    int endIndex = bsSrcString.Length;
                    //当要截取的长度在字符串的有效长度范围内
                    if (bsSrcString.Length > (startIndex + length))
                    {
                        endIndex = length + startIndex;
                    }
                    else
                    {   //当不在有效范围内时,只取到字符串的结尾
                        length = bsSrcString.Length - startIndex;
                        tailString = "";
                    }
                    int nRealLength = length;
                    int[] anResultFlag = new int[length];
                    byte[] bsResult = null;
                    int nFlag = 0;
                    for (int i = startIndex; i < endIndex; i++)
                    {
                        if (bsSrcString[i] > 127)
                        {
                            nFlag++;
                            if (nFlag == 3)
                            {
                                nFlag = 1;
                            }
                        }
                        else
                        {
                            nFlag = 0;
                        }
                        anResultFlag[i] = nFlag;
                    }
                    if ((bsSrcString[endIndex - 1] > 127) && (anResultFlag[length - 1] == 1))
                    {
                        nRealLength = length + 1;
                    }
                    bsResult = new byte[nRealLength];
                    Array.Copy(bsSrcString, startIndex, bsResult, 0, nRealLength);
                    myResult = Encoding.Default.GetString(bsResult);
                    myResult = myResult + tailString;
                }
            }
            return myResult;
        }
        /// <summary>
        /// è‡ªå®šä¹‰çš„æ›¿æ¢å­—符串函数。
        /// </summary>
        /// <param name="sourceString">源字符串。</param>
        /// <param name="searchString">待替换的字符串</param>
        /// <param name="replaceString">替换后的字符串</param>
        /// <param name="caseInsensetive">是否不区分大小写, true为不区分, false为区分。</param>
        /// <returns>处理后的字符串。</returns>
        public static string SafeReplaceString(string sourceString, string searchString, string replaceString, bool caseInsensetive)
        {
            return Regex.Replace(sourceString, Regex.Escape(searchString), replaceString, caseInsensetive ? RegexOptions.IgnoreCase : RegexOptions.None);
        }
        /// <summary>
        /// æ£€æµ‹æ˜¯å¦ç¬¦åˆemail地址格式。
        /// </summary>
        /// <param name="strEmail">要判断的email字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsValidEmail(string strEmail)
        {
            return Regex.IsMatch(strEmail, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
        }
        /// <summary>
        /// æ£€æµ‹æ˜¯å¦ç¬¦åˆemail址中域名格式。
        /// </summary>
        /// <param name="strEmail">要判断的email字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsValidEmailDomain(string strEmail)
        {
            return Regex.IsMatch(strEmail, @"^@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
        }
        /// <summary>
        /// æ£€æµ‹æ˜¯å¦ç¬¦åˆUrl格式。
        /// </summary>
        /// <param name="strUrl">要判断的Url。</param>
        /// <returns>判断结果。</returns>
        public static bool IsUrl(string strUrl)
        {
            return Regex.IsMatch(strUrl, @"^(http|https)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{1,10}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$");
        }
        /// <summary>
        /// æ£€æµ‹æ˜¯å¦ä¸ºbase64字符串。
        /// </summary>
        /// <param name="str">要判断的字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsBase64String(string str)
        {
            //A-Z, a-z, 0-9, +, /, =
            return Regex.IsMatch(str, @"[A-Za-z0-9\+\/\=]");
        }
        /// <summary>
        /// æ£€æµ‹æ˜¯å¦æœ‰Sql危险字符。
        /// </summary>
        /// <param name="str">要判断字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsSafeSqlString(string str)
        {
            return !Regex.IsMatch(str, @"[-|;|,|\/|\(|\)|\[|\]|\}|\{|%|@|\*|!|\']");
        }
        /// <summary>
        /// æ£€æµ‹æ˜¯å¦æœ‰å±é™©çš„可能用于链接的字符串。
        /// </summary>
        /// <param name="str">要判断字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsSafeUserInfoString(string str)
        {
            return !Regex.IsMatch(str, @"^\s*$|^c:\\con\\con$|[%,\*" + "\"" + @"\s\t\<\>\&]|游客|^Guest");
        }
        /// <summary>
        /// æ¸…理字符串。
        /// </summary>
        /// <param name="input">输入的字符串。</param>
        /// <returns>处理结果</returns>
        public static string SafeCleanInput(string input)
        {
            return Regex.Replace(input.Trim(), @"[^\w\.@-]", "");
        }
        /// <summary>
        /// æ£€æµ‹æ˜¯å¦ä¸ºæ—¶é—´å­—符串。
        /// </summary>
        /// <param name="str">待判断的时间字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsTime(string str)
        {
            return Regex.IsMatch(str, @"^((([0-1]?[0-9])|(2[0-3])):([0-5]?[0-9])(:[0-5]?[0-9])?)$");
        }
        /*
        /// <summary>
        /// å°†å­—符串转换为简体中文。
        /// (([^"']|^)\[xui:+\w+\.+\w+\.+\w+\])+(\.+\w*)+(\[\d\])?
        /// [xui:form1.bysv.ss].value[102]=="[xui:form1.bysv.ss]" and [xui:form2.bysv.ss].value==c or [ps:0.1]==d
        /// </summary>
        /// <param name="str">待转换的字符串。</param>
        /// <returns>转换结果。</returns>
        public static string ToSimplifiedChinese(string str)
        {
            return Strings.StrConv(str, VbStrConv.SimplifiedChinese, 0);
        }
        /// <summary>
        /// å°†å­—符串转换为繁体中文。
        /// </summary>
        /// <param name="str">待转换的字符串。</param>
        /// <returns>转换结果。</returns>
        public static string ToTChinese(string str)
        {
            return Strings.StrConv(str, VbStrConv.TraditionalChinese, 0);
        }
         * */
        /// <summary>
        /// åˆ†å‰²å­—符串。
        /// </summary>
        /// <param name="srcString">待分割的源字符串。</param>
        /// <param name="stringSplit">分割符。</param>
        /// <returns>分割后的字符串数组。</returns>
        public static string[] SafeSplitString(string srcString, string stringSplit)
        {
            if (srcString.IndexOf(stringSplit) < 0)
            {
                string[] tmp = { srcString };
                return tmp;
            }
            return Regex.Split(srcString, Regex.Escape(stringSplit), RegexOptions.IgnoreCase);
        }
        /// <summary>
        /// åˆ†å‰²å­—符串。
        /// </summary>
        /// <param name="srcString">待分割的源字符串。</param>
        /// <param name="stringSplit">分割符。</param>
        /// <param name="length">返回字符串数据的长度,如果不足则以空字符串填充。</param>
        /// <returns>分割后的字符串数组。</returns>
        public static string[] SafeSplitString(string srcString, string stringSplit, int length)
        {
            string[] result = new string[length];
            string[] splited = SafeSplitString(srcString, stringSplit);
            for (int i = 0; i < length; i++)
            {
                if (i < splited.Length)
                    result[i] = splited[i];
                else
                    result[i] = string.Empty;
            }
            return result;
        }
        /// <summary>
        /// ä½¿ç”¨æ­£åˆ™è¡¨è¾¾å¼åŒ¹é…å­—符串,找出每个符合条件的第一组数据。
        /// </summary>
        /// <param name="regx"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        /// <remarks>通常用于替换表达式中的特殊标记。</remarks>
        public static string[] SafeMatchString(string regx, string source)
        {
            Regex r = new Regex(regx, RegexOptions.IgnoreCase);
            Match m = r.Match(source);
            List<string> s = new List<string>();
            while (m.Success)
            {
                s.Add(m.Groups[1].Value);
                m = m.NextMatch();
            }
            return s.ToArray();
        }
        /// <summary>
        /// è¿›è¡ŒæŒ‡å®šçš„æ›¿æ¢(脏字过滤)。
        /// </summary>
        /// <param name="str">待处理的字符串。</param>
        /// <param name="bantext">待过滤的字符串(脏字)。</param>
        /// <returns>处理结果。</returns>
        public static string Filter(string str, string bantext)
        {
            string text1 = "";
            string text2 = "";
            string[] textArray1 = SafeSplitString(bantext, "\r\n");
            for (int num1 = 0; num1 < textArray1.Length; num1++)
            {
                text1 = textArray1[num1].Substring(0, textArray1[num1].IndexOf("="));
                text2 = textArray1[num1].Substring(textArray1[num1].IndexOf("=") + 1);
                str = str.Replace(text1, text2);
            }
            return str;
        }
        /// <summary>
        /// è®¡ç®—字节数大小并返回最匹配单位的相应的字符串。
        /// </summary>
        /// <param name="size">字节大小。</param>
        /// <returns>最匹配单位的相应的字符串。</returns>
        public static string FormatBytesString(int size)
        {
            if (size > 1073741824)
            {
                return ((double)(size / 1073741824)).ToString("0") + "G";
            }
            if (size > 1048576)
            {
                return ((double)(size / 1048576)).ToString("0") + "M";
            }
            if (size > 1024)
            {
                return ((double)(size / 1024)).ToString("0") + "K";
            }
            return size.ToString() + "Bytes";
        }
        /// <summary>
        /// æ£€æµ‹æ˜¯å¦ç¬¦åˆIP地址格式(IPv4)。
        /// </summary>
        /// <param name="strIp">要判断的IP字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsIP(string strIp)
        {
            return Regex.IsMatch(strIp, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
        }
        /// <summary>
        /// æ£€æµ‹æ˜¯å¦æ˜¯IP地址段(IPv4)。
        /// </summary>
        /// <param name="strIp">要判断的IP字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsIPSect(string strIp)
        {
            return Regex.IsMatch(strIp, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){2}((2[0-4]\d|25[0-5]|[01]?\d\d?|\*)\.)(2[0-4]\d|25[0-5]|[01]?\d\d?|\*)$");
        }
        /// <summary>
        /// å°†å…¨è§’数字转换为数字。
        /// </summary>
        /// <param name="SBCCase">全角数字。</param>
        /// <returns>处理结果。</returns>
        public static string SBCCaseToNumberic(string SBCCase)
        {
            char[] c = SBCCase.ToCharArray();
            for (int i = 0; i < c.Length; i++)
            {
                byte[] b = System.Text.Encoding.Unicode.GetBytes(c, i, 1);
                if (b.Length == 2)
                {
                    if (b[1] == 255)
                    {
                        b[0] = (byte)(b[0] + 32);
                        b[1] = 0;
                        c[i] = System.Text.Encoding.Unicode.GetChars(b)[0];
                    }
                }
            }
            return new string(c);
        }
        /// <summary>
        /// åˆ é™¤æœ€åŽä¸€ä¸ªå­—符。
        /// </summary>
        /// <param name="str">待处理的字符串。</param>
        /// <returns>处理结果。</returns>
        public static string SafeClearLastChar(string str)
        {
            if (str == "")
                return "";
            else
                return str.Substring(0, str.Length - 1);
        }
        /// <summary>
        /// å°†å­—符串转换为Color。
        /// </summary>
        /// <param name="color">颜色字符串,颜色可以是颜色名,也可以是RGB值或标准颜色值。</param>
        /// <returns>处理结果。</returns>
        public static Color ToColor(string color)
        {
            int red, green, blue = 0;
            char[] rgb;
            color = color.TrimStart('#');
            color = Regex.Replace(color.ToLower(), "[g-zG-Z]", "");
            switch (color.Length)
            {
                case 3:
                    rgb = color.ToCharArray();
                    red = Convert.ToInt32(rgb[0].ToString() + rgb[0].ToString(), 16);
                    green = Convert.ToInt32(rgb[1].ToString() + rgb[1].ToString(), 16);
                    blue = Convert.ToInt32(rgb[2].ToString() + rgb[2].ToString(), 16);
                    return Color.FromArgb(red, green, blue);
                case 6:
                    rgb = color.ToCharArray();
                    red = Convert.ToInt32(rgb[0].ToString() + rgb[1].ToString(), 16);
                    green = Convert.ToInt32(rgb[2].ToString() + rgb[3].ToString(), 16);
                    blue = Convert.ToInt32(rgb[4].ToString() + rgb[5].ToString(), 16);
                    return Color.FromArgb(red, green, blue);
                default:
                    return Color.FromName(color);
            }
        }
        /// <summary>
        /// æ£€æµ‹å­—符串是否是日期字符串。
        /// </summary>
        /// <param name="str">待判断字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsDateString(string str)
        {
            return Regex.IsMatch(str, @"(\d{4})-(\d{1,2})-(\d{1,2})");
        }
        /// <summary>
        /// æ£€æµ‹æ˜¯å¦ä¸ºæ­£æ•´æ•°ã€‚
        /// </summary>
        /// <param name="str">待判断字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsPlusInt(string str)
        {
            return Regex.IsMatch(str, @"^[0-9]*$");
        }
        /// <summary>
        /// æ£€æµ‹ç»™å®šçš„字符串数组(strNumber)中的数据是不是都为数值型。
        /// </summary>
        /// <param name="strNumber">要确认的字符串数组。</param>
        /// <returns>判断结果。</returns>
        public static bool IsNumericArray(string[] strNumber)
        {
            if (strNumber == null)
            {
                return false;
            }
            if (strNumber.Length < 1)
            {
                return false;
            }
            foreach (string id in strNumber)
            {
                if (!IsNumeric(id))
                {
                    return false;
                }
            }
            return true;
        }
        /// <summary>
        /// æ£€æµ‹å­—符串是否为Int32类型的数字。
        /// </summary>
        /// <param name="str">待判断的字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsNumeric(string  str)
        {
            if (str.Length > 0 && str.Length <= 11 && Regex.IsMatch(str, @"^[-]?[0-9]*[.]?[0-9]*$"))
            {
                if ((str.Length < 10) || (str.Length == 10 && str[0] == '1') || (str.Length == 11 && str[0] == '-' && str[1] == '1'))
                {
                    return true;
                }
            }
            return false;
        }
        /// <summary>
        /// æ£€æµ‹å­—符串是否为Double类型的数字。
        /// </summary>
        /// <param name="str">待判断的字符串。</param>
        /// <returns>判断结果。</returns>
        public static bool IsDouble(string str)
        {
                return Regex.IsMatch(str, @"^([0-9])[0-9]*(\.\w*)?$");
        }
        /// <summary>
        /// string型转换为bool型。
        /// </summary>
        /// <param name="str">待转换的字符串。</param>
        /// <param name="defaultValue">缺省值。</param>
        /// <returns>转换后的bool类型结果。</returns>
        public static bool ToBool(string str, bool defaultValue)
        {
            if (str != null)
            {
                if (string.Compare(str, "true", true) == 0)
                {
                    return true;
                }
                else if (string.Compare(str, "false", true) == 0)
                {
                    return false;
                }
            }
            return defaultValue;
        }
        /// <summary>
        /// å°†å­—符串转换为Int32类型。
        /// </summary>
        /// <param name="str">待转换的字符串。</param>
        /// <param name="defaultValue">缺省值。</param>
        /// <returns>转换后的int类型结果。</returns>
        public static int ToInt(string  str, int defaultValue)
        {
            if (str != null)
            {
                if (str.Length > 0 && str.Length <= 11 && Regex.IsMatch(str, @"^[-]?[0-9]*$"))
                {
                    if ((str.Length < 10) || (str.Length == 10 && str[0] == '1') || (str.Length == 11 && str[0] == '-' && str[1] == '1'))
                    {
                        return Convert.ToInt32(str);
                    }
                }
            }
            return defaultValue;
        }
        /// <summary>
        /// string型转换为float型。
        /// </summary>
        /// <param name="str">待转换的字符串。</param>
        /// <param name="defaultValue">缺省值。</param>
        /// <returns>转换后的int类型结果。</returns>
        public static float ToFloat(string str, float defaultValue)
        {
            if ((str == null) || (str.Length > 10))
            {
                return defaultValue;
            }
            float intValue = defaultValue;
            if (str != null)
            {
                bool IsFloat = Regex.IsMatch(str.ToString(), @"^([-]|[0-9])[0-9]*(\.\w*)?$");
                if (IsFloat)
                {
                    intValue = Convert.ToSingle(str);
                }
            }
            return intValue;
        }
        /// <summary>
        /// å°†å­—符串转换为Int32类型
        /// </summary>
        /// <param name="str">待转换的字符串。</param>
        /// <returns>转换后的Int32类型结果。</returns>
        public static int ToInt32(string  str)
        {
            if (str == null)
            {
                return 0;
            }
            string strNum = str;
            if (IsNumeric(strNum))
            {
                if (strNum.ToString().Length > 9)
                {
                    if (strNum.StartsWith("-"))
                    {
                        return int.MinValue;
                    }
                    else
                    {
                        return int.MaxValue;
                    }
                }
                return Int32.Parse(strNum);
            }
            else
            {
                return 0;
            }
        }
        /// <summary>
        /// å°†å­—符串转换为Base64类型
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static  string ToBase64String(string str)
        {
            byte[] data = System.Text.Encoding.Unicode.GetBytes(str);
            return Convert.ToBase64String(data);
        }
        /// <summary>
        /// FromBase64String
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static  string FromBase64String(string str)
        {
            byte[] data = Convert.FromBase64String(str);
            return System.Text.Encoding.Unicode.GetString(data);
        }
        /// <summary>
        /// åŽ‹ç¼©å­—ç¬¦ä¸²
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string ToCompressionString(string str)
        {
            return str;
        }
        /// <summary>
        /// è§£åŽ‹å­—ç¬¦ä¸²
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string FromCompressionString(string str)
        {
            return str;
        }
        /// <summary>
        /// æŠŠå­—符串数据转化为字符
        /// </summary>
        /// <param name="array"></param>
        /// <param name="separator"></param>
        /// <returns></returns>
        public static string FromStringArray(string[] array, string separator)
        {
            string s = string.Empty;
            foreach (string t in array)
                s += separator + t;
            if (s.Length > separator.Length)
                s = s.Substring(separator.Length);
            return s;
        }
        /// <summary>
        /// å°†å­—典转换为字符串表达式。
        /// </summary>
        /// <param name="dic"></param>
        /// <returns></returns>
        public static string FromDictionary(Dictionary<string, string> dic)
        {
            if (dic.Count == 0)
                return string.Empty;
            string rstr = string.Empty;
            foreach (string key in dic.Keys)
            {
                rstr += ";" + key + "=" + dic[key];
            }
            if (rstr.Length > 1)
                rstr = rstr.Substring(1);
            return rstr;
        }
        /// <summary>
        /// å°†æ•°ç»„转换为字符串表达式。
        /// </summary>
        /// <param name="array"></param>
        /// <param name="dictionary">是否转化为字典样式</param>
        /// <returns></returns>
        public static string FromArray(string[] array,bool dictionary)
        {
            if (array.Length == 0)
                return string.Empty;
            string rstr = string.Empty;
            foreach (string key in array)
            {
                if(dictionary)
                    rstr += ";" + key + "=" + key;
                else
                    rstr += ";" + key ;
            }
            if (rstr.Length > 1)
                rstr = rstr.Substring(1);
            return rstr;
        }
        /// <summary>
        /// å°†å­—符串解析为字典,要求字符串的格式为:键=值;键=值
        /// </summary>
        /// <param name="str">字符串。</param>
        /// <returns></returns>
        public static Dictionary<string, string> ToDictionary(string str)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            if (str == null || str == string.Empty)
                return dic;
            string[] items = str.Split(new char[1] { ';' });
            for (int i = 0; i <= items.Length - 1; i++)
            {
                if (!items[i].Contains("="))
                    continue;
                string[] item = items[i].Split(new char[1] { '=' });
                dic.Add(item[0], item[1]);
            }
            return dic;
        }
        /*
        public static string FromNamedValueCollection(NamedValueItemCollection dic)
        {
            if (dic.Count == 0)
                return string.Empty;
            string rstr = string.Empty;
            foreach (NamedValueItem item in dic)
            {
                rstr += ";" + item.Name + "=" + item.StringValue;
            }
            if (rstr.Length > 1)
                rstr = rstr.Substring(1);
            return rstr;
        }
        public static NamedValueItemCollection ToNamedValueCollection(string str)
        {
            NamedValueItemCollection dic = new  NamedValueItemCollection();
            if (str == null || str == string.Empty)
                return dic;
            string[] items = str.Split(new char[1] { ';' });
            for (int i = 0; i <= items.Length - 1; i++)
            {
                if (!items[i].Contains("="))
                    continue;
                string[] item = items[i].Split(new char[1] { '=' });
                dic.Add(item[0], item[1]);
            }
            return dic;
        }
        */
        /// <summary>
        /// è¡¨è¾¾å¼å€¼äº¤æ¢ï¼Œå³å°†å€¼è¡¨è¾¾å¼ä¸­çš„值按名称替换到源表达式中。
        /// </summary>
        /// <param name="srcExpr">源表达式,格式为 åç§°=值表达式名称;名称=值表达式名称</param>
        /// <param name="valExpr">值表达式,格式为值表达式名称=值;格式为值表达式名称=值</param>
        /// <returns>返回后表达式为 åç§°=值;名称=值</returns>
        public static string ExpressionValueExchange(string srcExpr, string valExpr)
        {
            string rstr = string.Empty;
            string[] src = srcExpr.Split(new char[1] { ';' });
            string[] val = valExpr.Split(new char[1] { ';' });
            Dictionary<string, string> dval = new Dictionary<string, string>();
            for (int i = 0; i <= val.Length - 1; i++)
            {
                int p = val[i].IndexOf("=");
                dval.Add(val[i].Substring(0, p), val[i].Substring(p + 1));
            }
            for (int i = 0; i <= src.Length - 1; i++)
            {
                int p = src[i].IndexOf("=");
                string sn = src[i].Substring(0, p);
                string sv = src[i].Substring(p+1);
                if (dval.ContainsKey(sv))
                    sv = dval[sv];
                else
                    sv = string.Empty;
                if (rstr == string.Empty)
                    rstr = sn + "=" + sv;
                else
                    rstr = rstr+";"+sn + "=" + sv;
            }
            return rstr;
        }
        /// <summary>
        /// æ ¼å¼åŒ–字符串。
        /// </summary>
        /// <param name="formatText">格式化字符串,中间不能包括逗号。格式为:格式化字符串,参数字段名1,,参数字段名2</param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static  string FormatString(string formatText, DataRow parameters)
        {
            if (parameters == null)
                return formatText;
            string[] fsParts = formatText.Split(new char[1] { ',' });
            string[] fparas = new string[fsParts.Length - 1];
            for (int i = 1; i <= fsParts.Length - 1; i++)
            {
                if (parameters.Table.Columns.Contains(fsParts[i]))
                    fparas[i - 1] = parameters[fsParts[i]].ToString();
                else
                    fparas[i - 1] = string.Empty;
            }
            string s = string.Format(fsParts[0], fparas);
            return s;
        }
        /// <summary>
        /// èŽ·å–åˆ†éš”å­—ç¬¦ä¸²æ•°ç»„;如将"[DBB004]=DAB004;[DBB005]=DAB005;[DBB006]=[DAB009]"分隔字符数组:DBB004,DAB004,DBB005,DAB005,DBB006,DAB009
        /// </summary>
        /// <param name="strValue">映射字符</param>
        /// <returns>字符串数组</returns>
        public static string[] GetSplitString(string strValue)
        {
            if (strValue == null)
                return null;
            if (strValue.Length == 0)
                return null;
            strValue = strValue.Replace("[", "").Replace("]", "");
            string[] strArray = strValue.Split(new char[2] { ';', '=' });
            return strArray;
        }
        /// <summary>
        /// å¯¹æ–‡æœ¬,分隔的字符进行添加单引号,对于条件是in的时候进行添加单引号
        /// x022,x023,x025===>'x022','x023','x025'
        /// </summary>
        /// <param name="strText">传入的字符串</param>
        /// <returns>返回添加单引号的字符</returns>
        public static string AddSingleQuote(string strText)
        {
            string[] value = strText.Split(new char[1] { ',' });
            for (int i = 0; i < value.Length; i++)
            {
                string para = value[i];
                if (para.StartsWith("'"))
                    para = para.Substring(1);
                if (para.EndsWith("'"))
                    para = para.Substring(0, para.Length - 1);
                value[i] = "'" + para + "'";
            }
            string str = string.Join(",", value);
            return str;
        }
        /// <summary>
        /// Gets the express string.
        /// </summary>
        /// <param name="strValue">The STR value.</param>
        /// <returns></returns>
        public static string[] GetExpressString(string strValue)
        {
            string[] strs = strValue.Split(new char[2] { '=', ' ' });
            List<string> strList = new List<string>();
            foreach (string str in strs)
            {
                if (str.Contains("["))
                    strList.Add(str);
            }
            return strList.ToArray();
            //return strs.Where(c => c.Contains('[')).ToArray();
        }
        /// <summary>
        /// æ£€éªŒä¸¤ä¸ªæ•°å­—是否相等
        /// </summary>
        /// <param name="x">第一个数字</param>
        /// <param name="y">第二个数字</param>
        /// <returns>返回true;false</returns>
        public static bool AboutEqual(double x, double y)
        {
            double epsilon = Math.Max(Math.Abs(x), Math.Abs(y)) * 1E-15;
            return Math.Abs(x - y) <= epsilon;
        }
        /// <summary>
        /// æ£€éªŒæ•°å­—数组是否全部相等
        /// é‡‡ç”¨ç›¸ç­‰ä¼ é€’的方法,验证一轮即可
        /// </summary>
        /// <param name="douArrs"></param>
        /// <returns></returns>
        public static bool AboutEqual(params double[] douArrs)
        {
            double dbFirst = douArrs[0];
            for (int t = 1; t < douArrs.Length; t++)
            {
                if (!AboutEqual(dbFirst, douArrs[t]))
                    return false;
            }
            return true;
        }
        /// <summary>
        /// å­—符数组验证是否有为空或者null
        /// </summary>
        /// <param name="objs"></param>
        /// <returns></returns>
        public static bool ExistsEmptyOrNull(params object[] objs)
        {
            if (objs == null || objs.Length == 0)
                return true;
            foreach (object obj in objs)
            {
                if (IsNullOrEmptyReturnZero<string>(obj) == "")
                    return true;
            }
            return false;
        }
        /// <summary>
        /// æ³›åž‹è½¬æ¢ä¸ºæ•°å€¼ç±»åž‹
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static T IsNullOrEmptyReturnZero<T>(object obj)
        {
            if (Equals(obj, null) || Equals(DBNull.Value, obj))
            {
                if (typeof(T).FullName == "System.String")
                    return (T)Convert.ChangeType("", typeof(T));
                return default(T);
            }
            try
            {
                return (T)Convert.ChangeType(obj, typeof(T));
            }
            catch
            {
                return default(T);
            }
        }
    }
}
StringSecurity.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,308 @@
using System;
using System.Text;
using System.IO;
using System.Security.Cryptography;
namespace DataexchangeServer
{
    /// <summary>
    /// å­—符串加密解密类
    /// </summary>
    public sealed class StringSecurity
    {
        private StringSecurity() { }
        #region SHA1 åР坆
        /// <summary>
        /// ä½¿ç”¨SHA1加密字符串。
        /// </summary>
        /// <param name="inputString">输入字符串。</param>
        /// <returns>加密后的字符串。(40个字符)</returns>
        public static string StringToSHA1Hash(string inputString)
        {
            SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
            byte[] encryptedBytes = sha1.ComputeHash(Encoding.ASCII.GetBytes(inputString));
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < encryptedBytes.Length; i++)
            {
                sb.AppendFormat("{0:x2}", encryptedBytes[i]);
            }
            return sb.ToString();
        }
        #endregion
        #region DES åР坆/解密
        private static byte[] key = ASCIIEncoding.ASCII.GetBytes("uiertysd");
        private static byte[] iv = ASCIIEncoding.ASCII.GetBytes("99008855");
        /// <summary>
        /// DES加密。
        /// </summary>
        /// <param name="inputString">输入字符串。</param>
        /// <returns>加密后的字符串。</returns>
        public static string DESEncrypt(string inputString)
        {
            MemoryStream ms = null;
            CryptoStream cs = null;
            StreamWriter sw = null;
            DESCryptoServiceProvider des = new DESCryptoServiceProvider();
            try
            {
                ms = new MemoryStream();
                cs = new CryptoStream(ms, des.CreateEncryptor(key, iv), CryptoStreamMode.Write);
                sw = new StreamWriter(cs);
                sw.Write(inputString);
                sw.Flush();
                cs.FlushFinalBlock();
                return Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length);
            }
            finally
            {
                if (sw != null) sw.Close();
                if (cs != null) cs.Close();
                if (ms != null) ms.Close();
            }
        }
        /// <summary>
        /// DES解密。
        /// </summary>
        /// <param name="inputString">输入字符串。</param>
        /// <returns>解密后的字符串。</returns>
        public static string DESDecrypt(string inputString)
        {
            MemoryStream ms = null;
            CryptoStream cs = null;
            StreamReader sr = null;
            DESCryptoServiceProvider des = new DESCryptoServiceProvider();
            try
            {
                ms = new MemoryStream(Convert.FromBase64String(inputString));
                cs = new CryptoStream(ms, des.CreateDecryptor(key, iv), CryptoStreamMode.Read);
                sr = new StreamReader(cs);
                return sr.ReadToEnd();
            }
            finally
            {
                if (sr != null) sr.Close();
                if (cs != null) cs.Close();
                if (ms != null) ms.Close();
            }
        }
        #endregion
    }
    /// <summary>
    /// å®‰å…¨å‡½æ•°è¾…助类。
    /// </summary>
    public class SecurityHelper
    {
        #region å¯¹å¤–公布的加密码算法
        /// <summary>
        /// AES加密码的Key
        /// </summary>
        private static readonly string EncryptKey = "1234567891234569123456789123";
        /// <summary>
        /// åР坆
        /// </summary>
        /// <param name="strPassword">需要加密的字符串。</param>
        /// <returns>返回加密后的字符串,如果加密码失败返回空。</returns>
        public static string Encrypt(string strPassword)
        {
            string Password = AESEncrypt(strPassword, EncryptKey);
            return strPassword == Password ? strPassword : Password;
        }
        /// <summary>
        /// è§£å¯†
        /// </summary>
        /// <param name="strPassword">加密码字符串</param>
        /// <returns>返回解密后的字符串,如果解密码失败返回空。</returns>
        public static string Decrypt(string strPassword)
        {
            string Password = AESDecrypt(strPassword, EncryptKey);
            return strPassword == Password ? strPassword : Password;
        }
        #endregion
        //默认DES密钥向量
        //private static byte[] DES_IV = {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};
        //默认AES密钥向量
        private static byte[] AES_IV =
            {
                0x41, 0x72, 0x65, 0x79, 0x6F, 0x75, 0x6D, 0x79, 0x53, 0x6E, 0x6F, 0x77, 0x6D,
                0x61, 0x6E, 0x3F
            };
        //private const string RSASign_HashAlgorithmName = "MD5";
        //private const string RSAEncryptXml_KeyName = "key";
        #region Hashcode
        /// <summary>
        /// MD5函数。
        /// </summary>
        /// <param name="str">原始字符串。</param>
        /// <returns>MD5结果。</returns>
        public static string MD5(string str)
        {
            byte[] b = Encoding.UTF8.GetBytes(str);
            byte[] hash = MD5(b);
            string ret = "";
            for (int i = 0; i < hash.Length; i++)
                ret += hash[i].ToString("x").PadLeft(2, '0');
            return ret;
        }
        /// <summary>
        /// MD5函数。
        /// </summary>
        /// <param name="data">原始数据流。</param>
        /// <returns>MD5结果。</returns>
        public static byte[] MD5(byte[] data)
        {
            return new MD5CryptoServiceProvider().ComputeHash(data);
        }
        /// <summary>
        /// SHA256函数。
        /// </summary>
        /// /// <param name="str">原始字符串。</param>
        /// <returns>SHA256结果。</returns>
        public static string SHA256(string str)
        {
            byte[] SHA256Data = Encoding.UTF8.GetBytes(str);
            return Convert.ToBase64String(SHA256(SHA256Data)); //返回长度为44字节的字符串
        }
        /// <summary>
        /// SHA256函数。
        /// </summary>
        /// /// <param name="data">原始数据流。</param>
        /// <returns>SHA256结果。</returns>
        public static byte[] SHA256(byte[] data)
        {
            SHA256Managed Sha256 = new SHA256Managed();
            return Sha256.ComputeHash(data);
        }
        #endregion
        #region AES对称加密解密
        /// <summary>
        /// AES加密。
        /// </summary>
        /// <param name="encryptString">待加密的字符串。</param>
        /// <param name="encryptKey">加密密钥,要求为32位。</param>
        /// <returns>加密成功返回加密后的字符串,失败返回源串。</returns>
        private static string AESEncrypt(string encryptString, string encryptKey)
        {
            try
            {
                byte[] inputData = Encoding.UTF8.GetBytes(encryptString);
                return Convert.ToBase64String(AESEncrypt(inputData, encryptKey));
            }
            catch
            {
                return encryptString;
            }
        }
        /// <summary>
        /// AES加密。
        /// </summary>
        /// <param name="data">待加密的数据。</param>
        /// <param name="encryptKey">加密密钥,要求为32位。</param>
        /// <returns>加密成功返回加密后的数据,失败返回空字符串。</returns>
        private static byte[] AESEncrypt(byte[] data, string encryptKey)
        {
            try
            {
                encryptKey = StringHelper.GetSubString(encryptKey, 32, "");
                encryptKey = encryptKey.PadRight(32, ' ');
                RijndaelManaged rijndaelProvider = new RijndaelManaged();
                rijndaelProvider.Key = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 32));
                rijndaelProvider.IV = AES_IV;
                ICryptoTransform rijndaelEncrypt = rijndaelProvider.CreateEncryptor();
                byte[] inputData = data;
                byte[] encryptedData = rijndaelEncrypt.TransformFinalBlock(inputData, 0, inputData.Length);
                return encryptedData;
            }
            catch (Exception e)
            {
                //Instance.WriteLog(e.Message, false);
                return data;
            }
        }
        /// <summary>
        /// AES解密。
        /// </summary>
        /// <param name="decryptString">待解密的字符串。</param>
        /// <param name="decryptKey">解密密钥,要求为32位,和加密密钥相同。</param>
        /// <returns>解密成功返回解密后的字符串,失败返回空字符串。</returns>
        private static string AESDecrypt(string decryptString, string decryptKey)
        {
            try
            {
                byte[] inputData = Convert.FromBase64String(decryptString);
                return Encoding.UTF8.GetString(AESDecrypt(inputData, decryptKey));
            }
            catch
            {
                return decryptString;
            }
        }
        /// <summary>
        /// AES解密。
        /// </summary>
        /// <param name="data">待解密的数据。</param>
        /// <param name="decryptKey">解密密钥,要求为32位,和加密密钥相同。</param>
        /// <returns>解密成功返回解密后的数据流,失败返回源数据。</returns>
        private static byte[] AESDecrypt(byte[] data, string decryptKey)
        {
            try
            {
                decryptKey = StringHelper.GetSubString(decryptKey, 32, "");
                decryptKey = decryptKey.PadRight(32, ' ');
                RijndaelManaged rijndaelProvider = new RijndaelManaged();
                rijndaelProvider.Key = Encoding.UTF8.GetBytes(decryptKey);
                rijndaelProvider.IV = AES_IV;
                ICryptoTransform rijndaelDecrypt = rijndaelProvider.CreateDecryptor();
                byte[] inputData = data;
                byte[] decryptedData = rijndaelDecrypt.TransformFinalBlock(inputData, 0, inputData.Length);
                return decryptedData;
            }
            catch
            {
                return data;
            }
        }
        #endregion
    }
}
Web References/WebReference/Reference.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,293 @@
//------------------------------------------------------------------------------
// <auto-generated>
//     æ­¤ä»£ç ç”±å·¥å…·ç”Ÿæˆã€‚
//     è¿è¡Œæ—¶ç‰ˆæœ¬:4.0.30319.42000
//
//     å¯¹æ­¤æ–‡ä»¶çš„æ›´æ”¹å¯èƒ½ä¼šå¯¼è‡´ä¸æ­£ç¡®çš„行为,并且如果
//     é‡æ–°ç”Ÿæˆä»£ç ï¼Œè¿™äº›æ›´æ”¹å°†ä¼šä¸¢å¤±ã€‚
// </auto-generated>
//------------------------------------------------------------------------------
//
// æ­¤æºä»£ç æ˜¯ç”± Microsoft.VSDesigner 4.0.30319.42000 ç‰ˆè‡ªåŠ¨ç”Ÿæˆã€‚
//
#pragma warning disable 1591
namespace DataexchangeServer.WebReference {
    using System.Diagnostics;
    using System;
    using System.Xml.Serialization;
    using System.ComponentModel;
    using System.Web.Services.Protocols;
    using System.Web.Services;
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="UserServiceImplPortBinding", Namespace="K3cloudInterface")]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(BodyResponse))]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(Body))]
    public partial class UserServiceImplService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        private System.Threading.SendOrPostCallback BodyOperationCompleted;
        private bool useDefaultCredentialsSetExplicitly;
        /// <remarks/>
        public UserServiceImplService() {
            this.Url = global::DataexchangeServer.Properties.Settings.Default.DataexchangeServer_WebReference_UserServiceImplService;
            if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
                this.UseDefaultCredentials = true;
                this.useDefaultCredentialsSetExplicitly = false;
            }
            else {
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        public new string Url {
            get {
                return base.Url;
            }
            set {
                if ((((this.IsLocalFileSystemWebService(base.Url) == true)
                            && (this.useDefaultCredentialsSetExplicitly == false))
                            && (this.IsLocalFileSystemWebService(value) == false))) {
                    base.UseDefaultCredentials = false;
                }
                base.Url = value;
            }
        }
        public new bool UseDefaultCredentials {
            get {
                return base.UseDefaultCredentials;
            }
            set {
                base.UseDefaultCredentials = value;
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        /// <remarks/>
        public event BodyCompletedEventHandler BodyCompleted;
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="K3cloudInterface", ResponseNamespace="K3cloudInterface", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        [return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public resp Body([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] user arg0) {
            object[] results = this.Invoke("Body", new object[] {
                        arg0});
            return ((resp)(results[0]));
        }
        /// <remarks/>
        public void BodyAsync(user arg0) {
            this.BodyAsync(arg0, null);
        }
        /// <remarks/>
        public void BodyAsync(user arg0, object userState) {
            if ((this.BodyOperationCompleted == null)) {
                this.BodyOperationCompleted = new System.Threading.SendOrPostCallback(this.OnBodyOperationCompleted);
            }
            this.InvokeAsync("Body", new object[] {
                        arg0}, this.BodyOperationCompleted, userState);
        }
        private void OnBodyOperationCompleted(object arg) {
            if ((this.BodyCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.BodyCompleted(this, new BodyCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        /// <remarks/>
        public new void CancelAsync(object userState) {
            base.CancelAsync(userState);
        }
        private bool IsLocalFileSystemWebService(string url) {
            if (((url == null)
                        || (url == string.Empty))) {
                return false;
            }
            System.Uri wsUri = new System.Uri(url);
            if (((wsUri.Port >= 1024)
                        && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
                return true;
            }
            return false;
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="K3cloudInterface")]
    public partial class user {
        private string categoryField;
        private string dataField;
        private string opField;
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string category {
            get {
                return this.categoryField;
            }
            set {
                this.categoryField = value;
            }
        }
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string data {
            get {
                return this.dataField;
            }
            set {
                this.dataField = value;
            }
        }
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string op {
            get {
                return this.opField;
            }
            set {
                this.opField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="K3cloudInterface")]
    public partial class BodyResponse {
        private resp returnField;
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public resp @return {
            get {
                return this.returnField;
            }
            set {
                this.returnField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="K3cloudInterface")]
    public partial class resp {
        private int codeField;
        private object dataField;
        private string msgField;
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public int code {
            get {
                return this.codeField;
            }
            set {
                this.codeField = value;
            }
        }
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public object data {
            get {
                return this.dataField;
            }
            set {
                this.dataField = value;
            }
        }
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string msg {
            get {
                return this.msgField;
            }
            set {
                this.msgField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="K3cloudInterface")]
    public partial class Body {
        private user arg0Field;
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public user arg0 {
            get {
                return this.arg0Field;
            }
            set {
                this.arg0Field = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")]
    public delegate void BodyCompletedEventHandler(object sender, BodyCompletedEventArgs e);
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public partial class BodyCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        private object[] results;
        internal BodyCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
                base(exception, cancelled, userState) {
            this.results = results;
        }
        /// <remarks/>
        public resp Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((resp)(this.results[0]));
            }
        }
    }
}
#pragma warning restore 1591
Web References/WebReference/Reference.map
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<DiscoveryClientResultsFile xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Results>
    <DiscoveryClientResult referenceType="System.Web.Services.Discovery.ContractReference" url="http://36.134.102.119:8888/ykd/api?wsdl" filename="UserServiceImplService.wsdl" />
    <DiscoveryClientResult referenceType="System.Web.Services.Discovery.SchemaReference" url="http://36.134.102.119:8888/ykd/api?xsd=1" filename="api.xsd" />
  </Results>
</DiscoveryClientResultsFile>
Web References/WebReference/UserServiceImplService.wsdl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="K3cloudInterface" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="UserServiceImplService" targetNamespace="K3cloudInterface" xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <xsd:schema>
      <xsd:import schemaLocation="http://36.134.102.119:8888/ykd/api?xsd=1" namespace="K3cloudInterface" />
    </xsd:schema>
  </types>
  <message name="Body">
    <part name="parameters" element="tns:Body" />
  </message>
  <message name="BodyResponse">
    <part name="parameters" element="tns:BodyResponse" />
  </message>
  <portType name="UserServiceImpl">
    <operation name="Body">
      <input wsam:Action="K3cloudInterface/UserServiceImpl/BodyRequest" message="tns:Body" />
      <output wsam:Action="K3cloudInterface/UserServiceImpl/BodyResponse" message="tns:BodyResponse" />
    </operation>
  </portType>
  <binding name="UserServiceImplPortBinding" type="tns:UserServiceImpl">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <operation name="Body">
      <soap:operation soapAction="" />
      <input>
        <soap:body use="literal" />
      </input>
      <output>
        <soap:body use="literal" />
      </output>
    </operation>
  </binding>
  <service name="UserServiceImplService">
    <port name="UserServiceImplPort" binding="tns:UserServiceImplPortBinding">
      <soap:address location="http://36.134.102.119:8888/ykd/api" />
    </port>
  </service>
</definitions>
Web References/WebReference/api.xsd
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="K3cloudInterface" targetNamespace="K3cloudInterface" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Body" type="tns:Body" />
  <xs:element name="BodyResponse" type="tns:BodyResponse" />
  <xs:complexType name="Body">
    <xs:sequence>
      <xs:element minOccurs="0" name="arg0" type="tns:user" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="user">
    <xs:sequence>
      <xs:element minOccurs="0" name="category" type="xs:string" />
      <xs:element minOccurs="0" name="data" type="xs:string" />
      <xs:element minOccurs="0" name="op" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="BodyResponse">
    <xs:sequence>
      <xs:element minOccurs="0" name="return" type="tns:resp" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="resp">
    <xs:sequence>
      <xs:element name="code" type="xs:int" />
      <xs:element minOccurs="0" name="data" type="xs:anyType" />
      <xs:element minOccurs="0" name="msg" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
</xs:schema>
Web References/WebReference/resp.datasource
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
    This file is automatically generated by Visual Studio .Net. It is
    used to store generic object data source configuration information.
    Renaming the file extension or editing the content of this file may
    cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="resp" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
   <TypeInfo>DataexchangeServer.WebReference.resp, Web References.WebReference.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>
Web References/WebReferenceLD/Reference.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,293 @@
//------------------------------------------------------------------------------
// <auto-generated>
//     æ­¤ä»£ç ç”±å·¥å…·ç”Ÿæˆã€‚
//     è¿è¡Œæ—¶ç‰ˆæœ¬:4.0.30319.42000
//
//     å¯¹æ­¤æ–‡ä»¶çš„æ›´æ”¹å¯èƒ½ä¼šå¯¼è‡´ä¸æ­£ç¡®çš„行为,并且如果
//     é‡æ–°ç”Ÿæˆä»£ç ï¼Œè¿™äº›æ›´æ”¹å°†ä¼šä¸¢å¤±ã€‚
// </auto-generated>
//------------------------------------------------------------------------------
//
// æ­¤æºä»£ç æ˜¯ç”± Microsoft.VSDesigner 4.0.30319.42000 ç‰ˆè‡ªåŠ¨ç”Ÿæˆã€‚
//
#pragma warning disable 1591
namespace DataexchangeServer.WebReferenceLD {
    using System.Diagnostics;
    using System;
    using System.Xml.Serialization;
    using System.ComponentModel;
    using System.Web.Services.Protocols;
    using System.Web.Services;
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="UserServiceImplPortBinding", Namespace="K3cloudInterface")]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(BodyResponse))]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(Body))]
    public partial class UserServiceImplService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        private System.Threading.SendOrPostCallback BodyOperationCompleted;
        private bool useDefaultCredentialsSetExplicitly;
        /// <remarks/>
        public UserServiceImplService() {
            this.Url = global::DataexchangeServer.Properties.Settings.Default.DataexchangeServer_WebReferenceLD_UserServiceImplService;
            if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
                this.UseDefaultCredentials = true;
                this.useDefaultCredentialsSetExplicitly = false;
            }
            else {
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        public new string Url {
            get {
                return base.Url;
            }
            set {
                if ((((this.IsLocalFileSystemWebService(base.Url) == true)
                            && (this.useDefaultCredentialsSetExplicitly == false))
                            && (this.IsLocalFileSystemWebService(value) == false))) {
                    base.UseDefaultCredentials = false;
                }
                base.Url = value;
            }
        }
        public new bool UseDefaultCredentials {
            get {
                return base.UseDefaultCredentials;
            }
            set {
                base.UseDefaultCredentials = value;
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        /// <remarks/>
        public event BodyCompletedEventHandler BodyCompleted;
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="K3cloudInterface", ResponseNamespace="K3cloudInterface", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        [return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public resp Body([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] user arg0) {
            object[] results = this.Invoke("Body", new object[] {
                        arg0});
            return ((resp)(results[0]));
        }
        /// <remarks/>
        public void BodyAsync(user arg0) {
            this.BodyAsync(arg0, null);
        }
        /// <remarks/>
        public void BodyAsync(user arg0, object userState) {
            if ((this.BodyOperationCompleted == null)) {
                this.BodyOperationCompleted = new System.Threading.SendOrPostCallback(this.OnBodyOperationCompleted);
            }
            this.InvokeAsync("Body", new object[] {
                        arg0}, this.BodyOperationCompleted, userState);
        }
        private void OnBodyOperationCompleted(object arg) {
            if ((this.BodyCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.BodyCompleted(this, new BodyCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        /// <remarks/>
        public new void CancelAsync(object userState) {
            base.CancelAsync(userState);
        }
        private bool IsLocalFileSystemWebService(string url) {
            if (((url == null)
                        || (url == string.Empty))) {
                return false;
            }
            System.Uri wsUri = new System.Uri(url);
            if (((wsUri.Port >= 1024)
                        && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
                return true;
            }
            return false;
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="K3cloudInterface")]
    public partial class user {
        private string categoryField;
        private string dataField;
        private string opField;
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string category {
            get {
                return this.categoryField;
            }
            set {
                this.categoryField = value;
            }
        }
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string data {
            get {
                return this.dataField;
            }
            set {
                this.dataField = value;
            }
        }
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string op {
            get {
                return this.opField;
            }
            set {
                this.opField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="K3cloudInterface")]
    public partial class BodyResponse {
        private resp returnField;
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public resp @return {
            get {
                return this.returnField;
            }
            set {
                this.returnField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="K3cloudInterface")]
    public partial class resp {
        private int codeField;
        private object dataField;
        private string msgField;
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public int code {
            get {
                return this.codeField;
            }
            set {
                this.codeField = value;
            }
        }
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public object data {
            get {
                return this.dataField;
            }
            set {
                this.dataField = value;
            }
        }
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string msg {
            get {
                return this.msgField;
            }
            set {
                this.msgField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="K3cloudInterface")]
    public partial class Body {
        private user arg0Field;
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public user arg0 {
            get {
                return this.arg0Field;
            }
            set {
                this.arg0Field = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")]
    public delegate void BodyCompletedEventHandler(object sender, BodyCompletedEventArgs e);
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public partial class BodyCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        private object[] results;
        internal BodyCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
                base(exception, cancelled, userState) {
            this.results = results;
        }
        /// <remarks/>
        public resp Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((resp)(this.results[0]));
            }
        }
    }
}
#pragma warning restore 1591
Web References/WebReferenceLD/Reference.map
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<DiscoveryClientResultsFile xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Results>
    <DiscoveryClientResult referenceType="System.Web.Services.Discovery.SchemaReference" url="http://36.134.102.119:9998/ykd/api?xsd=1" filename="api.xsd" />
    <DiscoveryClientResult referenceType="System.Web.Services.Discovery.ContractReference" url="http://36.134.102.119:9998/ykd/api?wsdl" filename="UserServiceImplService.wsdl" />
  </Results>
</DiscoveryClientResultsFile>
Web References/WebReferenceLD/UserServiceImplService.wsdl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="K3cloudInterface" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="UserServiceImplService" targetNamespace="K3cloudInterface" xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <xsd:schema>
      <xsd:import schemaLocation="http://36.134.102.119:9998/ykd/api?xsd=1" namespace="K3cloudInterface" />
    </xsd:schema>
  </types>
  <message name="Body">
    <part name="parameters" element="tns:Body" />
  </message>
  <message name="BodyResponse">
    <part name="parameters" element="tns:BodyResponse" />
  </message>
  <portType name="UserServiceImpl">
    <operation name="Body">
      <input wsam:Action="K3cloudInterface/UserServiceImpl/BodyRequest" message="tns:Body" />
      <output wsam:Action="K3cloudInterface/UserServiceImpl/BodyResponse" message="tns:BodyResponse" />
    </operation>
  </portType>
  <binding name="UserServiceImplPortBinding" type="tns:UserServiceImpl">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <operation name="Body">
      <soap:operation soapAction="" />
      <input>
        <soap:body use="literal" />
      </input>
      <output>
        <soap:body use="literal" />
      </output>
    </operation>
  </binding>
  <service name="UserServiceImplService">
    <port name="UserServiceImplPort" binding="tns:UserServiceImplPortBinding">
      <soap:address location="http://36.134.102.119:9998/ykd/api" />
    </port>
  </service>
</definitions>
Web References/WebReferenceLD/api.xsd
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="K3cloudInterface" targetNamespace="K3cloudInterface" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Body" type="tns:Body" />
  <xs:element name="BodyResponse" type="tns:BodyResponse" />
  <xs:complexType name="Body">
    <xs:sequence>
      <xs:element minOccurs="0" name="arg0" type="tns:user" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="user">
    <xs:sequence>
      <xs:element minOccurs="0" name="category" type="xs:string" />
      <xs:element minOccurs="0" name="data" type="xs:string" />
      <xs:element minOccurs="0" name="op" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="BodyResponse">
    <xs:sequence>
      <xs:element minOccurs="0" name="return" type="tns:resp" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="resp">
    <xs:sequence>
      <xs:element name="code" type="xs:int" />
      <xs:element minOccurs="0" name="data" type="xs:anyType" />
      <xs:element minOccurs="0" name="msg" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
</xs:schema>
Web References/WebReferenceLD/resp.datasource
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
    This file is automatically generated by Visual Studio .Net. It is
    used to store generic object data source configuration information.
    Renaming the file extension or editing the content of this file may
    cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="resp" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
   <TypeInfo>DataexchangeServer.WebReferenceLD.resp, Web References.WebReferenceLD.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>
Web References/WebReferenceLD1/Reference.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,293 @@
//------------------------------------------------------------------------------
// <auto-generated>
//     æ­¤ä»£ç ç”±å·¥å…·ç”Ÿæˆã€‚
//     è¿è¡Œæ—¶ç‰ˆæœ¬:4.0.30319.42000
//
//     å¯¹æ­¤æ–‡ä»¶çš„æ›´æ”¹å¯èƒ½ä¼šå¯¼è‡´ä¸æ­£ç¡®çš„行为,并且如果
//     é‡æ–°ç”Ÿæˆä»£ç ï¼Œè¿™äº›æ›´æ”¹å°†ä¼šä¸¢å¤±ã€‚
// </auto-generated>
//------------------------------------------------------------------------------
//
// æ­¤æºä»£ç æ˜¯ç”± Microsoft.VSDesigner 4.0.30319.42000 ç‰ˆè‡ªåŠ¨ç”Ÿæˆã€‚
//
#pragma warning disable 1591
namespace DataexchangeServer.WebReferenceLD1 {
    using System.Diagnostics;
    using System;
    using System.Xml.Serialization;
    using System.ComponentModel;
    using System.Web.Services.Protocols;
    using System.Web.Services;
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="UserServiceImplPortBinding", Namespace="K3cloudInterface")]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(BodyResponse))]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(Body))]
    public partial class UserServiceImplService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        private System.Threading.SendOrPostCallback BodyOperationCompleted;
        private bool useDefaultCredentialsSetExplicitly;
        /// <remarks/>
        public UserServiceImplService() {
            this.Url = global::DataexchangeServer.Properties.Settings.Default.DataexchangeServer_WebReferenceLD1_UserServiceImplService;
            if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
                this.UseDefaultCredentials = true;
                this.useDefaultCredentialsSetExplicitly = false;
            }
            else {
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        public new string Url {
            get {
                return base.Url;
            }
            set {
                if ((((this.IsLocalFileSystemWebService(base.Url) == true)
                            && (this.useDefaultCredentialsSetExplicitly == false))
                            && (this.IsLocalFileSystemWebService(value) == false))) {
                    base.UseDefaultCredentials = false;
                }
                base.Url = value;
            }
        }
        public new bool UseDefaultCredentials {
            get {
                return base.UseDefaultCredentials;
            }
            set {
                base.UseDefaultCredentials = value;
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        /// <remarks/>
        public event BodyCompletedEventHandler BodyCompleted;
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="K3cloudInterface", ResponseNamespace="K3cloudInterface", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        [return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public resp Body([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] user arg0) {
            object[] results = this.Invoke("Body", new object[] {
                        arg0});
            return ((resp)(results[0]));
        }
        /// <remarks/>
        public void BodyAsync(user arg0) {
            this.BodyAsync(arg0, null);
        }
        /// <remarks/>
        public void BodyAsync(user arg0, object userState) {
            if ((this.BodyOperationCompleted == null)) {
                this.BodyOperationCompleted = new System.Threading.SendOrPostCallback(this.OnBodyOperationCompleted);
            }
            this.InvokeAsync("Body", new object[] {
                        arg0}, this.BodyOperationCompleted, userState);
        }
        private void OnBodyOperationCompleted(object arg) {
            if ((this.BodyCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.BodyCompleted(this, new BodyCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        /// <remarks/>
        public new void CancelAsync(object userState) {
            base.CancelAsync(userState);
        }
        private bool IsLocalFileSystemWebService(string url) {
            if (((url == null)
                        || (url == string.Empty))) {
                return false;
            }
            System.Uri wsUri = new System.Uri(url);
            if (((wsUri.Port >= 1024)
                        && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
                return true;
            }
            return false;
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="K3cloudInterface")]
    public partial class user {
        private string categoryField;
        private string dataField;
        private string opField;
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string category {
            get {
                return this.categoryField;
            }
            set {
                this.categoryField = value;
            }
        }
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string data {
            get {
                return this.dataField;
            }
            set {
                this.dataField = value;
            }
        }
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string op {
            get {
                return this.opField;
            }
            set {
                this.opField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="K3cloudInterface")]
    public partial class BodyResponse {
        private resp returnField;
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public resp @return {
            get {
                return this.returnField;
            }
            set {
                this.returnField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="K3cloudInterface")]
    public partial class resp {
        private int codeField;
        private object dataField;
        private string msgField;
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public int code {
            get {
                return this.codeField;
            }
            set {
                this.codeField = value;
            }
        }
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public object data {
            get {
                return this.dataField;
            }
            set {
                this.dataField = value;
            }
        }
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string msg {
            get {
                return this.msgField;
            }
            set {
                this.msgField = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.4084.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="K3cloudInterface")]
    public partial class Body {
        private user arg0Field;
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public user arg0 {
            get {
                return this.arg0Field;
            }
            set {
                this.arg0Field = value;
            }
        }
    }
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")]
    public delegate void BodyCompletedEventHandler(object sender, BodyCompletedEventArgs e);
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.4084.0")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    public partial class BodyCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        private object[] results;
        internal BodyCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
                base(exception, cancelled, userState) {
            this.results = results;
        }
        /// <remarks/>
        public resp Result {
            get {
                this.RaiseExceptionIfNecessary();
                return ((resp)(this.results[0]));
            }
        }
    }
}
#pragma warning restore 1591
Web References/WebReferenceLD1/Reference.map
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<DiscoveryClientResultsFile xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Results>
    <DiscoveryClientResult referenceType="System.Web.Services.Discovery.SchemaReference" url="http://36.134.102.119:9998/ykd/api?xsd=1" filename="api.xsd" />
    <DiscoveryClientResult referenceType="System.Web.Services.Discovery.ContractReference" url="http://36.134.102.119:9998/ykd/api?wsdl" filename="UserServiceImplService.wsdl" />
  </Results>
</DiscoveryClientResultsFile>
Web References/WebReferenceLD1/UserServiceImplService.wsdl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="K3cloudInterface" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="UserServiceImplService" targetNamespace="K3cloudInterface" xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <xsd:schema>
      <xsd:import schemaLocation="http://36.134.102.119:9998/ykd/api?xsd=1" namespace="K3cloudInterface" />
    </xsd:schema>
  </types>
  <message name="Body">
    <part name="parameters" element="tns:Body" />
  </message>
  <message name="BodyResponse">
    <part name="parameters" element="tns:BodyResponse" />
  </message>
  <portType name="UserServiceImpl">
    <operation name="Body">
      <input wsam:Action="K3cloudInterface/UserServiceImpl/BodyRequest" message="tns:Body" />
      <output wsam:Action="K3cloudInterface/UserServiceImpl/BodyResponse" message="tns:BodyResponse" />
    </operation>
  </portType>
  <binding name="UserServiceImplPortBinding" type="tns:UserServiceImpl">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <operation name="Body">
      <soap:operation soapAction="" />
      <input>
        <soap:body use="literal" />
      </input>
      <output>
        <soap:body use="literal" />
      </output>
    </operation>
  </binding>
  <service name="UserServiceImplService">
    <port name="UserServiceImplPort" binding="tns:UserServiceImplPortBinding">
      <soap:address location="http://36.134.102.119:9998/ykd/api" />
    </port>
  </service>
</definitions>
Web References/WebReferenceLD1/api.xsd
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="K3cloudInterface" targetNamespace="K3cloudInterface" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Body" type="tns:Body" />
  <xs:element name="BodyResponse" type="tns:BodyResponse" />
  <xs:complexType name="Body">
    <xs:sequence>
      <xs:element minOccurs="0" name="arg0" type="tns:user" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="user">
    <xs:sequence>
      <xs:element minOccurs="0" name="category" type="xs:string" />
      <xs:element minOccurs="0" name="data" type="xs:string" />
      <xs:element minOccurs="0" name="op" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="BodyResponse">
    <xs:sequence>
      <xs:element minOccurs="0" name="return" type="tns:resp" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="resp">
    <xs:sequence>
      <xs:element name="code" type="xs:int" />
      <xs:element minOccurs="0" name="data" type="xs:anyType" />
      <xs:element minOccurs="0" name="msg" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
</xs:schema>
Web References/WebReferenceLD1/resp.datasource
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
    This file is automatically generated by Visual Studio .Net. It is
    used to store generic object data source configuration information.
    Renaming the file extension or editing the content of this file may
    cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="resp" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
   <TypeInfo>DataexchangeServer.WebReferenceLD1.resp, Web References.WebReferenceLD1.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>
frmMain.Designer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,371 @@
namespace DataexchangeServer
{
    partial class frmMain
    {
        /// <summary>
        /// å¿…需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;
        /// <summary>
        /// æ¸…理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
        #region Windows çª—体设计器生成的代码
        /// <summary>
        /// è®¾è®¡å™¨æ”¯æŒæ‰€éœ€çš„æ–¹æ³• - ä¸è¦
        /// ä½¿ç”¨ä»£ç ç¼–辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
            this.timer = new System.Windows.Forms.Timer(this.components);
            this.showInTaskbar = new System.Windows.Forms.ToolStripMenuItem();
            this.lblTotalTimes = new System.Windows.Forms.Label();
            this.lsbErrorMsg = new System.Windows.Forms.ListBox();
            this.label5 = new System.Windows.Forms.Label();
            this.nudminThreads = new System.Windows.Forms.NumericUpDown();
            this.label1 = new System.Windows.Forms.Label();
            this.nudmaxThreads = new System.Windows.Forms.NumericUpDown();
            this.label2 = new System.Windows.Forms.Label();
            this.timeInterval = new System.Windows.Forms.NumericUpDown();
            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.exitWindow = new System.Windows.Forms.ToolStripMenuItem();
            this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
            this.rtbStatus = new System.Windows.Forms.ListBox();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.btnStop = new System.Windows.Forms.Button();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.lsbPoolState = new System.Windows.Forms.ListBox();
            this.btnStart = new System.Windows.Forms.Button();
            this.groupBox3 = new System.Windows.Forms.GroupBox();
            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
            ((System.ComponentModel.ISupportInitialize)(this.nudminThreads)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.nudmaxThreads)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.timeInterval)).BeginInit();
            this.contextMenuStrip1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.groupBox1.SuspendLayout();
            this.groupBox3.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
            this.splitContainer1.Panel1.SuspendLayout();
            this.splitContainer1.Panel2.SuspendLayout();
            this.splitContainer1.SuspendLayout();
            this.SuspendLayout();
            //
            // timer
            //
            this.timer.Interval = 5000;
            //
            // showInTaskbar
            //
            this.showInTaskbar.Name = "showInTaskbar";
            this.showInTaskbar.Size = new System.Drawing.Size(108, 24);
            this.showInTaskbar.Text = "显示";
            //
            // lblTotalTimes
            //
            this.lblTotalTimes.AutoSize = true;
            this.lblTotalTimes.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.lblTotalTimes.Location = new System.Drawing.Point(21, 101);
            this.lblTotalTimes.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
            this.lblTotalTimes.Name = "lblTotalTimes";
            this.lblTotalTimes.Size = new System.Drawing.Size(88, 15);
            this.lblTotalTimes.TabIndex = 11;
            this.lblTotalTimes.Text = "TotalTime";
            //
            // lsbErrorMsg
            //
            this.lsbErrorMsg.FormattingEnabled = true;
            this.lsbErrorMsg.ItemHeight = 15;
            this.lsbErrorMsg.Location = new System.Drawing.Point(8, 130);
            this.lsbErrorMsg.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.lsbErrorMsg.Name = "lsbErrorMsg";
            this.lsbErrorMsg.Size = new System.Drawing.Size(580, 109);
            this.lsbErrorMsg.TabIndex = 10;
            //
            // label5
            //
            this.label5.AutoSize = true;
            this.label5.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label5.Location = new System.Drawing.Point(411, 75);
            this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(87, 15);
            this.label5.TabIndex = 2;
            this.label5.Text = "最小线程数";
            //
            // nudminThreads
            //
            this.nudminThreads.Enabled = false;
            this.nudminThreads.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.nudminThreads.Location = new System.Drawing.Point(508, 70);
            this.nudminThreads.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.nudminThreads.Name = "nudminThreads";
            this.nudminThreads.Size = new System.Drawing.Size(81, 25);
            this.nudminThreads.TabIndex = 3;
            this.nudminThreads.Value = new decimal(new int[] {
            5,
            0,
            0,
            0});
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label1.Location = new System.Drawing.Point(411, 108);
            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(87, 15);
            this.label1.TabIndex = 4;
            this.label1.Text = "最大线程数";
            //
            // nudmaxThreads
            //
            this.nudmaxThreads.Enabled = false;
            this.nudmaxThreads.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.nudmaxThreads.Location = new System.Drawing.Point(508, 101);
            this.nudmaxThreads.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.nudmaxThreads.Name = "nudmaxThreads";
            this.nudmaxThreads.Size = new System.Drawing.Size(81, 25);
            this.nudmaxThreads.TabIndex = 5;
            this.nudmaxThreads.Value = new decimal(new int[] {
            15,
            0,
            0,
            0});
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label2.Location = new System.Drawing.Point(393, 44);
            this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(107, 15);
            this.label2.TabIndex = 6;
            this.label2.Text = "执行频率(ms)";
            //
            // timeInterval
            //
            this.timeInterval.Enabled = false;
            this.timeInterval.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.timeInterval.Location = new System.Drawing.Point(508, 39);
            this.timeInterval.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.timeInterval.Maximum = new decimal(new int[] {
            10000,
            0,
            0,
            0});
            this.timeInterval.Name = "timeInterval";
            this.timeInterval.Size = new System.Drawing.Size(81, 25);
            this.timeInterval.TabIndex = 7;
            this.timeInterval.Value = new decimal(new int[] {
            10000,
            0,
            0,
            0});
            //
            // contextMenuStrip1
            //
            this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.showInTaskbar,
            this.exitWindow});
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.Size = new System.Drawing.Size(109, 52);
            //
            // exitWindow
            //
            this.exitWindow.Name = "exitWindow";
            this.exitWindow.Size = new System.Drawing.Size(108, 24);
            this.exitWindow.Text = "退出";
            //
            // notifyIcon1
            //
            this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
            this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
            this.notifyIcon1.Text = "技研新阳新技电子有限公司";
            this.notifyIcon1.Visible = true;
            //
            // rtbStatus
            //
            this.rtbStatus.Dock = System.Windows.Forms.DockStyle.Fill;
            this.rtbStatus.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.rtbStatus.FormattingEnabled = true;
            this.rtbStatus.ItemHeight = 17;
            this.rtbStatus.Location = new System.Drawing.Point(4, 22);
            this.rtbStatus.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.rtbStatus.Name = "rtbStatus";
            this.rtbStatus.Size = new System.Drawing.Size(1087, 387);
            this.rtbStatus.TabIndex = 2;
            //
            // groupBox2
            //
            this.groupBox2.Controls.Add(this.rtbStatus);
            this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.groupBox2.Location = new System.Drawing.Point(0, 0);
            this.groupBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.groupBox2.Size = new System.Drawing.Size(1095, 413);
            this.groupBox2.TabIndex = 9;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "线程执行状态";
            //
            // btnStop
            //
            this.btnStop.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.btnStop.Location = new System.Drawing.Point(195, 24);
            this.btnStop.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.btnStop.Name = "btnStop";
            this.btnStop.Size = new System.Drawing.Size(145, 56);
            this.btnStop.TabIndex = 9;
            this.btnStop.Text = "停    æ­¢(&S)";
            this.btnStop.UseVisualStyleBackColor = true;
            //
            // groupBox1
            //
            this.groupBox1.Controls.Add(this.lsbPoolState);
            this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
            this.groupBox1.Location = new System.Drawing.Point(594, 0);
            this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.groupBox1.Size = new System.Drawing.Size(501, 198);
            this.groupBox1.TabIndex = 8;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "线程池状态";
            //
            // lsbPoolState
            //
            this.lsbPoolState.Dock = System.Windows.Forms.DockStyle.Fill;
            this.lsbPoolState.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.lsbPoolState.FormattingEnabled = true;
            this.lsbPoolState.ItemHeight = 17;
            this.lsbPoolState.Location = new System.Drawing.Point(4, 22);
            this.lsbPoolState.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.lsbPoolState.Name = "lsbPoolState";
            this.lsbPoolState.Size = new System.Drawing.Size(493, 172);
            this.lsbPoolState.TabIndex = 8;
            //
            // btnStart
            //
            this.btnStart.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.btnStart.Location = new System.Drawing.Point(24, 25);
            this.btnStart.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.btnStart.Name = "btnStart";
            this.btnStart.Size = new System.Drawing.Size(141, 56);
            this.btnStart.TabIndex = 8;
            this.btnStart.Text = "启    åЍ(&B)";
            this.btnStart.UseVisualStyleBackColor = true;
            //
            // groupBox3
            //
            this.groupBox3.Controls.Add(this.lblTotalTimes);
            this.groupBox3.Controls.Add(this.lsbErrorMsg);
            this.groupBox3.Controls.Add(this.label5);
            this.groupBox3.Controls.Add(this.nudminThreads);
            this.groupBox3.Controls.Add(this.label1);
            this.groupBox3.Controls.Add(this.nudmaxThreads);
            this.groupBox3.Controls.Add(this.label2);
            this.groupBox3.Controls.Add(this.timeInterval);
            this.groupBox3.Controls.Add(this.btnStop);
            this.groupBox3.Controls.Add(this.btnStart);
            this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill;
            this.groupBox3.Location = new System.Drawing.Point(0, 0);
            this.groupBox3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.groupBox3.Name = "groupBox3";
            this.groupBox3.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.groupBox3.Size = new System.Drawing.Size(594, 198);
            this.groupBox3.TabIndex = 9;
            this.groupBox3.TabStop = false;
            this.groupBox3.Text = "服务设置";
            //
            // splitContainer1
            //
            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
            this.splitContainer1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.splitContainer1.Name = "splitContainer1";
            this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
            //
            // splitContainer1.Panel1
            //
            this.splitContainer1.Panel1.Controls.Add(this.groupBox3);
            this.splitContainer1.Panel1.Controls.Add(this.groupBox1);
            //
            // splitContainer1.Panel2
            //
            this.splitContainer1.Panel2.Controls.Add(this.groupBox2);
            this.splitContainer1.Size = new System.Drawing.Size(1095, 616);
            this.splitContainer1.SplitterDistance = 198;
            this.splitContainer1.SplitterWidth = 5;
            this.splitContainer1.TabIndex = 1;
            //
            // frmMain
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(1095, 616);
            this.Controls.Add(this.splitContainer1);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.Name = "frmMain";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "广深数据交换服务";
            ((System.ComponentModel.ISupportInitialize)(this.nudminThreads)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.nudmaxThreads)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.timeInterval)).EndInit();
            this.contextMenuStrip1.ResumeLayout(false);
            this.groupBox2.ResumeLayout(false);
            this.groupBox1.ResumeLayout(false);
            this.groupBox3.ResumeLayout(false);
            this.groupBox3.PerformLayout();
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
            this.splitContainer1.ResumeLayout(false);
            this.ResumeLayout(false);
        }
        #endregion
        private System.Windows.Forms.Timer timer;
        private System.Windows.Forms.ToolStripMenuItem showInTaskbar;
        private System.Windows.Forms.Label lblTotalTimes;
        private System.Windows.Forms.ListBox lsbErrorMsg;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.NumericUpDown nudminThreads;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.NumericUpDown nudmaxThreads;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.NumericUpDown timeInterval;
        private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
        private System.Windows.Forms.ToolStripMenuItem exitWindow;
        private System.Windows.Forms.NotifyIcon notifyIcon1;
        private System.Windows.Forms.ListBox rtbStatus;
        private System.Windows.Forms.GroupBox groupBox2;
        private System.Windows.Forms.Button btnStop;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.ListBox lsbPoolState;
        private System.Windows.Forms.Button btnStart;
        private System.Windows.Forms.GroupBox groupBox3;
        private System.Windows.Forms.SplitContainer splitContainer1;
    }
}
frmMain.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,472 @@
using DataexchangeServer.Helper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
namespace DataexchangeServer
{
    public  delegate void AppendTextCallBack(string text);
    public partial class frmMain : Form
    {
        private SQLHelper _sqlHelper;
        public List<Allocation> ListCount = new List<Allocation>();
        public DateTime startTime;
        #region é»˜è®¤èµ·åŠ¨è½¯ä»¶frmMain()
        /// <summary>
        /// é»˜è®¤èµ·åŠ¨è½¯ä»¶
        /// </summary>
        public frmMain()
        {
            InitializeComponent();
            this.FormClosing += frmMain_FormClosing;
            this.SizeChanged += frmMain_SizeChanged;
            btnStart.Click += btnStart_Click;
            btnStop.Click += btnStop_Click;
            timer.Tick += timer_Tick;
            notifyIcon1.DoubleClick += notifyIcon1_DoubleClick;
            contextMenuStrip1.ItemClicked += contextMenuStrip1_ItemClicked;
            Initialize();
            //btnStart_Click(null, null);
        }
        void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("你确定要退出吗?", "广深软件", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
            {
                btnStop_Click(null, null);
                System.Environment.Exit(0);   //退出所有的线程
            }
            else
                e.Cancel = true;
        }
        #endregion
        #region åˆå§‹åŒ–数据 Initialize
        /// <summary>
        /// åˆå§‹åŒ–数据
        /// </summary>
        void Initialize()
        {
            try
            {
                //BASE64加解密方式
                //_sqlHelper = new SQLHelper(
                //    Encoding.Default.GetString(Convert.FromBase64String(
                //    ConfigurationManager.ConnectionStrings["conn"].ConnectionString)));
                //Int32 TimingMailInterval =Convert.ToInt32(ConfigurationManager.AppSettings["TimingMailInterval"]);
                //Int16 MaxThreads = Convert.ToInt16(ConfigurationManager.AppSettings["MaxThreads"]);
                //Int16 MinThreads = Convert.ToInt16(ConfigurationManager.AppSettings["MinThreads"]);
                string conn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
                conn = SecurityHelper.Decrypt(conn);
                _sqlHelper = new SQLHelper(conn);
                Int32 TimingMailInterval = Convert.ToInt32(ConfigurationManager.AppSettings["TimingMailInterval"]);
                Int16 MaxThreads = Convert.ToInt16(ConfigurationManager.AppSettings["MaxThreads"]);
                Int16 MinThreads = Convert.ToInt16(ConfigurationManager.AppSettings["MinThreads"]);
                string conText = ConfigurationManager.AppSettings["thisText"];
                this.Text = conText;
                notifyIcon1.Text = conText;
                nudminThreads.Value = MinThreads;
                nudmaxThreads.Value = MaxThreads;
                timeInterval.Value = TimingMailInterval;
                timer.Interval = TimingMailInterval;
                //一定要先设定最小线程池,再设置最大线程池,否则设置无效
                ThreadPool.SetMinThreads(MinThreads, MinThreads);
                ThreadPool.SetMaxThreads(MaxThreads, MaxThreads);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                Application.Exit();
            }
        }
        #endregion
        #region è½®è¯¢æ‰§è¡Œvoid timer_Tick(object sender, EventArgs e)
        /// <summary>
        /// è½®è¯¢æ‰§è¡Œ
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void timer_Tick(object sender, EventArgs e)
        {
            if (btnStop.Enabled)
            {
                AllocationThread();
                int Sleep = ListCount.Count(a => a.state == State.Sleep);
                int Alive = ListCount.Count(a => a.state == State.Alive);
                int Finish = ListCount.Count(a => a.state == State.Finish);
                AddThreadPoolState(string.Format("排队的队列数量:{0},正在执行的队列:{1},已完成的队列:{2}", Sleep, Alive, Finish));
                var _list = ListCount.Where(a => a.state == State.Finish).ToList<Allocation>();
                if (_list.Count > 500)
                    ListCount.RemoveAll(a => a.state == State.Finish);
                TimeSpan ts = DateTime.Now - startTime;
                lblTotalTimes.Text = string.Format(@"Total Times : {0}天{1}时{2}分{3}秒", ts.Days, ts.Hours, ts.Minutes, ts.Seconds);
            }
        }
        #endregion
        #region è°ƒç”¨çº¿ç¨‹æ–¹æ³• void AllocationThread()
        /// <summary>
        /// è°ƒç”¨çº¿ç¨‹æ–¹æ³•
        /// </summary>
        public void AllocationThread()
        {
            //long s =(DateTime.Now - preTime).Seconds;
            var _list = ListCount.Where(a => a.state == State.Alive || a.state == State.Sleep).ToList<Allocation>();
            if (_list.Count > 0) return;
            string msg = string.Empty;
            try
            {
                msg = "query data 1 ;";
                //preTime = DateTime.Now;
                string sqlstr = string.Format(@";with cte as (
                                                        select top 1000
                                                        case when task_name in ('TB_ERPTOMES_BM',
                                                                                'TB_ERPTOMES_GW',
                                                                                'TB_ERPTOMES_RY',
                                                                                'TB_ERPTOMES_WF',
                                                                                'TB_ERPTOMES_WL',
                                                                                'TB_ERPTOMES_KH',
                                                                                'TB_ERPTOMES_GYS',
                                                                                'TB_ERPTOMES_CK',
                                                                                'TB_ERPTOMES_GX',
                                                                                'TB_ERPTOMES_BOM',
                                                                                'TB_ERPTOMES_TDL') then 1
                                                             when task_name in ('TB_ERPTOMES_XCK',
                                                                                'TB_ERPTOMES_QCK',
                                                                                'TB_ERPTOMES_TH',
                                                                                'TB_ERPTOMES_CG',
                                                                                'TB_ERPTOMES_FHTZ',
                                                                                'TB_ERPTOMES_WW',
                                                                                'TB_ERPTOMES_TL',
                                                                                'TB_ERPTOMES_DW',
                                                                                'TB_ERPTOMES_TH_CONFIRM',
                                                                                'TB_ERPTOMES_GDRK',
                                                                                'TB_ERPTOMES_WCK',
                                                                                'TB_ERPTOMES_CGDH',
                                                                                'TB_ERPTOME_KHWL') then 2
                                                             when task_name in ('TB_MESTOERP_WGRK',
                                                                                'TB_MESTOERP_WWRK',
                                                                                'TB_MESTOERP_QTRK',
                                                                                'TB_MESTOERP_CPRK',
                                                                                'TB_MESTOERP_CGRK',
                                                                                'TB_MESTOERP_XSCK',
                                                                                'TB_MESTOERP_DD',
                                                                                'TB_MESTOERP_PYPK',
                                                                                'TB_MESTOERP_LL',
                                                                                'TB_MESTOERP_SCTL',
                                                                                'TB_MESTOERP_WGTL',
                                                                                'TB_MESTOERP_WGTL',
                                                                                'TB_MESTOERP_GDRK',
                                                                                'TB_MESTOERP_ICMO',
                                                                                'TB_MESTOERP_SLSH',
                                                                                'TB_MESTOERP_SCDDXD',
                                                                                'TB_MESTOERP_WLQDBB',
                                                                                'TB_MESTOERP_TransferIn'
                                                                                ) then 3
                                                                else 4 end gp,*
                                                        from SYSDEC  WITH(nolock) where states='NEW'  AND   descript IN ('高冲物料变更','物料信息表','仓库信息表','部门信息表','员工信息表','部门信息表','领料单','成品入库单','采购入库单','生产订单下达','物料客户对应表','采购订单','发货通知单','销售出库单','生产领料单','分步调入单','生产退料单','直接调拨单','生产补料单','委外订单','其他入库单','其他出库单')
                                                                --and task_name='TB_ERPTOMES_CG'
                                                        order by create_time
                                                        union all
                                                          select top 10
                                                       3 gp,*
                                                        from SYSDEC  WITH(nolock) where task_id IN  ( SELECT task_ID
FROM (
    SELECT task_ID, data, task_name, create_time,
    ROW_NUMBER() OVER (PARTITION BY data, task_name ORDER BY create_time DESC) AS rn
    FROM sysdec where  states='NEW' AND   descript IN ('生产投料单')
) AS SubQuery
WHERE rn = 1)
                                                        union all
                                                        select top 1000
                                                        case when task_name in ('TB_ERPTOMES_BM',
                                                                                'TB_ERPTOMES_GW',
                                                                                'TB_ERPTOMES_RY',
                                                                                'TB_ERPTOMES_WF',
                                                                                'TB_ERPTOMES_WL',
                                                                                'TB_ERPTOMES_KH',
                                                                                'TB_ERPTOMES_GYS',
                                                                                'TB_ERPTOMES_CK',
                                                                                'TB_ERPTOMES_GX',
                                                                                'TB_ERPTOMES_BOM',
                                                                                'TB_ERPTOMES_TDL') then 1
                                                             when task_name in ('TB_ERPTOMES_XCK',
                                                                                'TB_ERPTOMES_QCK',
                                                                                'TB_ERPTOMES_TH',
                                                                                'TB_ERPTOMES_CG',
                                                                                'TB_ERPTOMES_FHTZ',
                                                                                'TB_ERPTOMES_WW',
                                                                                'TB_ERPTOMES_TL',
                                                                                'TB_ERPTOMES_DW',
                                                                                'TB_ERPTOMES_TH_CONFIRM',
                                                                                'TB_ERPTOMES_GDRK',
                                                                                'TB_ERPTOMES_WCK',
                                                                                'TB_ERPTOMES_CGDH',
                                                                                'TB_ERPTOME_KHWL') then 2
                                                             when task_name in ('TB_MESTOERP_WGRK',
                                                                                'TB_MESTOERP_WWRK',
                                                                                'TB_MESTOERP_QTRK',
                                                                                'TB_MESTOERP_CPRK',
                                                                                'TB_MESTOERP_CGRK',
                                                                                'TB_MESTOERP_XSCK',
                                                                                'TB_MESTOERP_DD',
                                                                                'TB_MESTOERP_PYPK',
                                                                                'TB_MESTOERP_LL',
                                                                                'TB_MESTOERP_SCTL',
                                                                                'TB_MESTOERP_GDRK',
                                                                                'TB_MESTOERP_ICMO',
                                                                                'TB_MESTOERP_SLSH',
                                                                                'TB_MESTOERP_SCDDXD',
                                                                                'TB_MESTOERP_WLQDBB',
                                                                                'TB_MESTOERP_TransferIn') then 3
                                                                else 4 end gp,*
                                                        from SYSDEC  WITH(nolock) where states='FAIL' and retry_times<1 and CREATE_TIME>'2024-06-14 13:13:34'  AND descript IN ('高冲物料变更','物料信息表','仓库信息表','部门信息表','员工信息表','生产投料单','部门信息表','领料单','成品入库单','采购入库单','生产订单下达','物料客户对应表','采购订单','发货通知单','销售出库单','分步调入单','生产领料单','生产退料单','生产补料单')
                                                                            and task_name not in ('TB_MESTOERP_WGRK',
                                                                                                    'TB_MESTOERP_WWRK',
                                                                                                    'TB_MESTOERP_QTRK',
                                                                                                    'TB_MESTOERP_CPRK',
                                                                                                    'TB_MESTOERP_CGRK',
                                                                                                    'TB_MESTOERP_XSCK',
                                                                                                    'TB_MESTOERP_DD',
                                                                                                    'TB_MESTOERP_PYPK',
                                                                                                    'TB_MESTOERP_LL',
                                                                                                    'TB_MESTOERP_SCTL',
                                                                                                    'TB_MESTOERP_ICMO',
                                                                                                    'TB_MESTOERP_GDRK',
                                                                                                    'TB_MESTOERP_SLSH',
                                                                                                    'TB_MESTOERP_WLQDBB',
                                                                                                    'TB_MESTOERP_TransferIn')
                                                    )
                                                    select rtrim(gp)+'-'+rtrim(rank() over(partition by gp order by data)) gcp,* from cte
                                                    order by 1,create_time");
                DataTable tbThread = _sqlHelper.ExecuteDataTable(sqlstr);
                DataTable tbgroup = tbThread.DefaultView.ToTable(true, new string[1] { "gcp" }); //对线程ID进行分组
                msg = msg + "begin to allocation thread 2 ; ";
                foreach (DataRow r in tbgroup.Rows)
                {
                    string gcp = r["gcp"].ToString();
                    Allocation EQ = new Allocation();
                    //EQ.task_id = r["task_id"].ToString();
                    //EQ.ID = r["data"].ToString();
                    EQ.strStartTime = DateTime.Now;
                    EQ.Name = gcp;
                    EQ.WriteLog += AddStatusText;
                    EQ.WriteErrorLog += AddErrorText;
                    SetTableByThreadID(gcp, tbThread, ref EQ.tbQueue);
                    EQ.tbQueue.AcceptChanges();
                    ListCount.Add(EQ);
                    ThreadPool.QueueUserWorkItem(EQ.Execute);
                }
            }
            catch (Exception ex)
            {
                JSONHelper.WriteToFile(msg + " è°ƒç”¨çº¿ç¨‹æ—¶å¼‚常:" + ex.Message);
                AddErrorText(msg + " è°ƒç”¨çº¿ç¨‹æ—¶å¼‚常:" + ex.Message);
            }
        }
        #endregion
        #region æ•°æ®è¡Œå¤åˆ¶åˆ°æ•°æ®è¡¨ä¸­void SetTableByThreadID(string tid, DataTable dataTb, ref DataTable target)
        /// <summary>
        /// æ•°æ®è¡Œå¤åˆ¶åˆ°æ•°æ®è¡¨ä¸­
        /// </summary>
        /// <param name="tid"></param>
        /// <param name="dataTb"></param>
        /// <param name="target"></param>
        private void SetTableByThreadID(string tid, DataTable dataTb, ref DataTable target)
        {
            DataRow[] rowsArray = dataTb.Select("gcp='" + tid + "'", "create_time");
            if (rowsArray.Length == 0)
                return;
            target.Rows.Clear();
            foreach (DataRow row in rowsArray)
            {
                DataRow newrow = target.NewRow();
                foreach (DataColumn dc in dataTb.Columns)
                {
                    if ("gcp;gp".Contains(dc.ColumnName))
                        continue;
                    newrow[dc.ColumnName] = row[dc.ColumnName];
                }
                target.Rows.Add(newrow);
            }
        }
        #endregion
        #region å¯åŠ¨æœåŠ¡void btnStart_Click(object sender, EventArgs e)
        /// <summary>
        /// å¯åŠ¨æœåŠ¡
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStart_Click(object sender, EventArgs e)
        {
            ApiGlobal.Init();
            AllocationThread();
            btnStop.Enabled = true;
            btnStart.Enabled = false;
            timer.Enabled = false;
            timer.Start();
            startTime = DateTime.Now;
        }
        #endregion
        #region åœæ­¢æœåŠ¡void btnStop_Click(object sender, EventArgs e)
        /// <summary>
        /// åœæ­¢æœåŠ¡
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStop_Click(object sender, EventArgs e)
        {
            btnStop.Enabled = false;
            btnStart.Enabled = true;
            timer.Stop();
        }
        #endregion
        #region å¢žåŠ çº¿ç¨‹æ± ä¿¡æ¯void AddThreadPoolState(string message)
        /// <summary>
        /// å¢žåŠ çº¿ç¨‹æ± ä¿¡æ¯
        /// </summary>
        /// <param name="message"></param>
        private void AddThreadPoolState(string message)
        {
            if (lsbPoolState.InvokeRequired)
            {
                AppendTextCallBack method = AddThreadPoolState;
                base.Invoke(method, new object[] { message });
            }
            else
            {
                if (lsbPoolState.Items.Count > 10)
                {
                    lsbPoolState.Items.Clear();
                }
                //lsbPoolState.Items.Add(string.Format(message));
                lsbPoolState.Items.Insert(0, string.Format(message));
                lsbPoolState.Width = 350;
                lsbPoolState.ItemHeight = 10;
            }
        }
        #endregion
        #region å¢žåŠ çº¿ç¨‹ä¿¡æ¯void AddStatusText(string message)
        /// <summary>
        /// å¢žåŠ çº¿ç¨‹ä¿¡æ¯
        /// </summary>
        /// <param name="message"></param>
        private void AddStatusText(string message)
        {
            if (rtbStatus.InvokeRequired)
            {
                AppendTextCallBack method = AddStatusText;
                base.Invoke(method, new object[] { message });
            }
            else
            {
                if (rtbStatus.Items.Count > 30)
                {
                    rtbStatus.Items.Clear();
                }
                //rtbStatus.Items.Add(string.Format(message));
                rtbStatus.Items.Insert(0, string.Format(message));
                rtbStatus.Width = 600;
                rtbStatus.ItemHeight = 100;
            }
        }
        #endregion
        #region å¢žåŠ é”™è¯¯ä¿¡æ¯void AddErrorText(string message)
        /// <summary>
        /// å¢žåŠ é”™è¯¯ä¿¡æ¯
        /// </summary>
        /// <param name="message"></param>
        private void AddErrorText(string message)
        {
            if (lsbErrorMsg.InvokeRequired)
            {
                AppendTextCallBack method = AddErrorText;
                base.Invoke(method, new object[] { message });
            }
            else
            {
                if (lsbErrorMsg.Items.Count > 6)
                {
                    lsbErrorMsg.Items.Clear();
                }
                //lsbErrorMsg.Items.Add(string.Format(message));
                lsbErrorMsg.Items.Insert(0, message);//string.Format(message)
                lsbErrorMsg.Width = 600;
                lsbErrorMsg.ItemHeight = 30;
            }
        }
        #endregion
        #region        æ‰˜ç›˜ç¨‹åº
        void frmMain_SizeChanged(object sender, EventArgs e)
        {
            if(WindowState == FormWindowState.Minimized)
            {
                this.ShowInTaskbar = false;
                notifyIcon1.Visible = true;
            }
        }
        void notifyIcon1_DoubleClick(object sender, EventArgs e)
        {
            if(WindowState == FormWindowState.Minimized)
            {
                WindowState = FormWindowState.Normal;
                this.Activate();
                this.ShowInTaskbar = true;
                notifyIcon1.Visible = false;
            }
        }
        void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if(e.ClickedItem == showInTaskbar)
            {
                if (WindowState == FormWindowState.Minimized)
                {
                    WindowState = FormWindowState.Normal;
                    this.Activate();
                    this.ShowInTaskbar = true;
                    notifyIcon1.Visible = false;
                }
            }
            else if (e.ClickedItem == exitWindow)
            {
                btnStop_Click(null, null);
                System.Environment.Exit(0);   //退出所有的线程
            }
        }
        #endregion
    }
}
frmMain.resx
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,178 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!--
    Microsoft ResX Schema
    Version 2.0
    The primary goals of this format is to allow a simple XML format
    that is mostly human readable. The generation and parsing of the
    various data types are done through the TypeConverter classes
    associated with the data types.
    Example:
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
    There are any number of "resheader" rows that contain simple
    name/value pairs.
    Each data row contains a name, and value. The row also contains a
    type or mimetype. Type corresponds to a .NET class that support
    text/value conversion through the TypeConverter architecture.
    Classes that don't support this are serialized and stored with the
    mimetype set.
    The mimetype is used for serialized objects, and tells the
    ResXResourceReader how to depersist the object. This is currently not
    extensible. For a given mimetype the value must be set accordingly:
    Note - application/x-microsoft.net.object.binary.base64 is the format
    that the ResXResourceWriter will generate, however the reader can
    read any of the formats listed below.
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.
    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <metadata name="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>25, 12</value>
  </metadata>
  <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>108, 12</value>
  </metadata>
  <metadata name="notifyIcon1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>273, 12</value>
  </metadata>
  <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  <data name="notifyIcon1.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAMMOAADDDgAAAAAAAAAA
        AAD///////////z8/P/8/Pz///////z8/P+QkJD/BAQE/46Ojv//////+/v7///////9/f3//Pz8////
        //////////////z8/P/+/v7//////7u7u/8oKCj/AAAA/wAAAP9ycnL//////4uLi/+hoaH///////7+
        /v/8/Pz///////7+/v//////1dXV/0dHR/8AAAD/IiIi/7Kysv8ODg7/bGxs//////9YWFj/AAAA/0dH
        R//U1NT///////7+/v//////eXl5/wAAAP8EBAT/gICA//z8/P/9/f3/DQ0N/2lpaf//////W1tb/wAA
        AP8FBQX/AAAA/3x8fP//////+/v7/xoaGv8qKir/39/f///////g4OD/R0dH/wAAAP+JiYn//////1RU
        VP8ICAj/3d3d/zg4OP8YGBj//Pz8//////8ZGRn/a2tr//////+enp7/AAAA/xYWFv+5ubn/////////
        //9UVFT/EBAQ//////9wcHD/FxcX////////////GRkZ/2VlZf//////bm5u/1paWv//////lpaW/6ys
        rP//////Wlpb/xISEv//////cXFx/xUVFf///////////xwcHP9qamr///////f39///////4ODg/wAA
        AP95eXn//////+rq5v+vr67//////3Z2df8WFhb///////////8hISH/ampq///////29vb/g4OD/wMD
        A/8SEhX/u7u9///////u7vz/9vb7//////93d3r/GBgY////////////JCQk/2dnZ//Gxsb/Ghoa/wAA
        AP9iYmP/9PTu//7+//+UlPf/Cwvu/0RE7P/5+f//hIR9/xkZGv///////////zk5Of8AAAD/AAAA/ysr
        Lf/Pz8v//////8HB+v8nJ+//AADu/zEx8f8AAOr/ISH//z4+lf8kJCL//v7///////87Ozv/AAAB/52d
        mf//////5OT//05O8f8AAOv/Ly/x/7+/+///////z8/8/zk58v8AAO7/Y2PK/////P//////xsbH/9zc
        2v/7+///fHz1/w0N7P8eHvD/pKT5//z8////////mpr4/7Cw+v//////ubn6//Pz//////////////39
        ////////1NT5/x8f7/8AAO3/XV30///////i4v3/R0fz/wAA7P9ERPP//Pz////////9/f3/////////
        ///9/f3//Pz9///////29v7/fn72/wQE7v8lJfH/Fhbv/xER7/+hofn///////7+///8/P///v7/////
        ///////////////////+/v///f3////////MzPz/JSXx/1BQ8//r6/7///////39////////////////
        ////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
        AAAAAAAAAAAAAA==
</value>
  </data>
  <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAMMOAADDDgAAAAAAAAAA
        AAD///////////z8/P/8/Pz///////z8/P+QkJD/BAQE/46Ojv//////+/v7///////9/f3//Pz8////
        //////////////z8/P/+/v7//////7u7u/8oKCj/AAAA/wAAAP9ycnL//////4uLi/+hoaH///////7+
        /v/8/Pz///////7+/v//////1dXV/0dHR/8AAAD/IiIi/7Kysv8ODg7/bGxs//////9YWFj/AAAA/0dH
        R//U1NT///////7+/v//////eXl5/wAAAP8EBAT/gICA//z8/P/9/f3/DQ0N/2lpaf//////W1tb/wAA
        AP8FBQX/AAAA/3x8fP//////+/v7/xoaGv8qKir/39/f///////g4OD/R0dH/wAAAP+JiYn//////1RU
        VP8ICAj/3d3d/zg4OP8YGBj//Pz8//////8ZGRn/a2tr//////+enp7/AAAA/xYWFv+5ubn/////////
        //9UVFT/EBAQ//////9wcHD/FxcX////////////GRkZ/2VlZf//////bm5u/1paWv//////lpaW/6ys
        rP//////Wlpb/xISEv//////cXFx/xUVFf///////////xwcHP9qamr///////f39///////4ODg/wAA
        AP95eXn//////+rq5v+vr67//////3Z2df8WFhb///////////8hISH/ampq///////29vb/g4OD/wMD
        A/8SEhX/u7u9///////u7vz/9vb7//////93d3r/GBgY////////////JCQk/2dnZ//Gxsb/Ghoa/wAA
        AP9iYmP/9PTu//7+//+UlPf/Cwvu/0RE7P/5+f//hIR9/xkZGv///////////zk5Of8AAAD/AAAA/ysr
        Lf/Pz8v//////8HB+v8nJ+//AADu/zEx8f8AAOr/ISH//z4+lf8kJCL//v7///////87Ozv/AAAB/52d
        mf//////5OT//05O8f8AAOv/Ly/x/7+/+///////z8/8/zk58v8AAO7/Y2PK/////P//////xsbH/9zc
        2v/7+///fHz1/w0N7P8eHvD/pKT5//z8////////mpr4/7Cw+v//////ubn6//Pz//////////////39
        ////////1NT5/x8f7/8AAO3/XV30///////i4v3/R0fz/wAA7P9ERPP//Pz////////9/f3/////////
        ///9/f3//Pz9///////29v7/fn72/wQE7v8lJfH/Fhbv/xER7/+hofn///////7+///8/P///v7/////
        ///////////////////+/v///f3////////MzPz/JSXx/1BQ8//r6/7///////39////////////////
        ////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
        AAAAAAAAAAAAAA==
</value>
  </data>
</root>