¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | 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 |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | //} |
| | | } |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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()); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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")] |
¶Ô±ÈÐÂÎļþ |
| | |
| | | //------------------------------------------------------------------------------ |
| | | // <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; |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | //------------------------------------------------------------------------------ |
| | | // <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"])); |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 |
| | | |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | //------------------------------------------------------------------------------ |
| | | // <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 |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | //------------------------------------------------------------------------------ |
| | | // <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 |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | //------------------------------------------------------------------------------ |
| | | // <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 |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |