Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangorcy committed Aug 6, 2019
1 parent d289bf8 commit fb6b59e
Show file tree
Hide file tree
Showing 131 changed files with 1,509 additions and 71,336 deletions.
Binary file modified Utility基础类大全/.vs/Common.Utility/v16/.suo
Binary file not shown.
Binary file not shown.
Binary file not shown.
30 changes: 30 additions & 0 deletions Utility基础类大全/Common.Utility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@
<EmbedInteropTypes>False</EmbedInteropTypes>
<HintPath>bin\Debug\Microsoft.Office.Interop.Owc11.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ReportViewer.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.150.1358.0\lib\net40\Microsoft.ReportViewer.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ReportViewer.Design, Version=15.3.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.150.1358.0\lib\net40\Microsoft.ReportViewer.Design.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ReportViewer.WebDesign, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.150.1358.0\lib\net40\Microsoft.ReportViewer.WebDesign.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.ReportingServices.ReportViewerControl.WebForms.150.1358.0\lib\net40\Microsoft.ReportViewer.WebForms.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SqlServer.Types, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.SqlServer.Types.14.0.314.76\lib\net40\Microsoft.SqlServer.Types.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>packages\Newtonsoft.Json.11.0.1-beta3\lib\net40\Newtonsoft.Json.dll</HintPath>
Expand Down Expand Up @@ -120,6 +135,8 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="RDLC直接打印帮助类\PrintHelper.cs" />
<Compile Include="SqlServerTypes\Loader.cs" />
<Compile Include="其他\BasePage.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
Expand Down Expand Up @@ -607,6 +624,19 @@
<Content Include="packages\WebGrease.1.3.0\lib\Antlr3.Runtime.dll" />
<Content Include="packages\WebGrease.1.3.0\lib\WebGrease.dll" />
<Content Include="ResourceManager\Sample.xml" />
<Content Include="SqlServerTypes\readme.htm" />
<Content Include="SqlServerTypes\x64\msvcr120.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="SqlServerTypes\x64\SqlServerSpatial140.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="SqlServerTypes\x86\msvcr120.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="SqlServerTypes\x86\SqlServerSpatial140.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="异步线程\线程使用说明.txt" />
<Content Include="日志\日志使用说明.txt" />
<Content Include="网站安全\使用说明.txt" />
Expand Down
42 changes: 19 additions & 23 deletions Utility基础类大全/RDLC直接打印帮助类/PrintHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
using System.Linq;
using System.Web;
using System.IO;

using Microsoft.Reporting.WebForms;
using System.Drawing.Printing;
using System.Drawing.Imaging;
using System.Text;
using System.Data;
using Microsoft.Reporting.WinForms;
/// <summary>
/// 打印帮助类
/// </summary>
public class PrintHelper
{
//用来记录当前打印到第几页了
private int m_currentPageIndex;
private IList<Stream> m_streams;
private int pos;

/// <summary>
/// 报表直接打印
Expand Down Expand Up @@ -65,12 +69,6 @@ private void Export(LocalReport report)
}
}

private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
{
Stream stream = new FileStream(name + DateTime.Now.Millisecond + "." + fileNameExtension, FileMode.Create);
m_streams.Add(stream);
return stream;
}
private void Print(string printerName)
{
if (m_streams == null || m_streams.Count == 0) return;
Expand All @@ -90,32 +88,25 @@ private void Print(string printerName)
if (!printDoc.PrinterSettings.IsValid)
{
string msg = string.Format("找不到打印机:{0}", printerName);
LogUtil.Log(msg);
// LogUtil.Log(msg);
return;
}
printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
printDoc.Print();
}

private void PrintPage(object sender, PrintPageEventArgs ev)
{
Metafile pageImage = new Metafile(m_streams[m_currentPageIndex]);
ev.Graphics.DrawImage(pageImage, 0, 0, 827, 1169);//像素
m_currentPageIndex++;
ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
}
//初始化报表信息
private void SetReportInfo(string reportPath, string sourceName, DataTable dataSource, bool isFengPi)
{
if (!File.Exists(reportPath))
{
MessageBox.Show("报表文件:" + reportPath + " 不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
// MessageBox.Show("报表文件:" + reportPath + " 不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}

if (dataSource == null || dataSource.Rows.Count == 0)
{
MessageBox.Show("没有找到案卷号为:" + txtArchiveNum.Text.Trim() + "的相关目录信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
// MessageBox.Show("没有找到案卷号为:" + txtArchiveNum.Text.Trim() + "的相关目录信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
pos = 1;
Expand Down Expand Up @@ -150,9 +141,14 @@ private void SetReportInfo(string reportPath, string sourceName, DataTable dataS
report1.Render("Image", deviceInfo, CreateStream, out warnings);
}

private string GetArchiveTypeName()
{
throw new NotImplementedException();
}

//声明一个Stream对象的列表用来保存报表的输出数据
//LocalReport对象的Render方法会将报表按页输出为多个Stream对象。
// private List<Stream> m_streams;
// private List<Stream> m_streams;
//用来提供Stream对象的函数,用于LocalReport对象的Render方法的第三个参数。
private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)

Expand All @@ -164,8 +160,8 @@ private Stream CreateStream(string name, string fileNameExtension, Encoding enco
return stream;
}

//用来记录当前打印到第几页了
private int m_currentPageIndex;



#region 打印报表
private void Print()
Expand All @@ -181,7 +177,7 @@ private void Print()
//判断指定的打印机是否可用
if (!printDoc.PrinterSettings.IsValid)
{
MessageBox.Show("没有找到打印机!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
//MessageBox.Show("没有找到打印机!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
pos = 5;
Expand Down Expand Up @@ -219,9 +215,9 @@ private void PrintPage(object sender, PrintPageEventArgs ev)
//打印封皮
private void btPrint_Click(object sender, EventArgs e)
{
string reportPath = Application.StartupPath + "\\Files\\ReportEnvelop.rdlc";
SetReportInfo(reportPath, "DataSet1", GetDataSource(true), true);
Print();
//string reportPath = Application.StartupPath + "\\Files\\ReportEnvelop.rdlc";
//SetReportInfo(reportPath, "DataSet1", GetDataSource(true), true);
//Print();

}
}
45 changes: 45 additions & 0 deletions Utility基础类大全/SqlServerTypes/Loader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.IO;
using System.Runtime.InteropServices;

namespace SqlServerTypes
{
/// <summary>
/// Utility methods related to CLR Types for SQL Server
/// </summary>
public class Utilities
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr LoadLibrary(string libname);

/// <summary>
/// Loads the required native assemblies for the current architecture (x86 or x64)
/// </summary>
/// <param name="rootApplicationPath">
/// Root path of the current application. Use Server.MapPath(".") for ASP.NET applications
/// and AppDomain.CurrentDomain.BaseDirectory for desktop applications.
/// </param>
public static void LoadNativeAssemblies(string rootApplicationPath)
{
var nativeBinaryPath = IntPtr.Size > 4
? Path.Combine(rootApplicationPath, @"SqlServerTypes\x64\")
: Path.Combine(rootApplicationPath, @"SqlServerTypes\x86\");

LoadNativeAssembly(nativeBinaryPath, "msvcr120.dll");
LoadNativeAssembly(nativeBinaryPath, "SqlServerSpatial140.dll");
}

private static void LoadNativeAssembly(string nativeBinaryPath, string assemblyName)
{
var path = Path.Combine(nativeBinaryPath, assemblyName);
var ptr = LoadLibrary(path);
if (ptr == IntPtr.Zero)
{
throw new Exception(string.Format(
"Error loading {0} (ErrorCode: {1})",
assemblyName,
Marshal.GetLastWin32Error()));
}
}
}
}
61 changes: 61 additions & 0 deletions Utility基础类大全/SqlServerTypes/readme.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<html lang="en-US">
<head>
<meta charset="utf-8" />
<title>Microsoft.SqlServer.Types</title>
<style>
body {
background: #fff;
color: #505050;
margin: 20px;
}

#main {
background: #efefef;
padding: 5px 30px;
}
</style>
</head>
<body>
<div id="main">
<h1>Action required to load native assemblies</h1>
<p>
To deploy an application that uses spatial data types to a machine that does not have 'System CLR Types for SQL Server' installed you also need to deploy the native assembly SqlServerSpatial140.dll. Both x86 (32 bit) and x64 (64 bit) versions of this assembly have been added to your project under the SqlServerTypes\x86 and SqlServerTypes\x64 subdirectories. The native assembly msvcr120.dll is also included in case the C++ runtime is not installed.
</p>
<p>
You need to add code to load the correct one of these assemblies at runtime (depending on the current architecture).
</p>
<h2>ASP.NET Web Sites</h2>
<p>
For ASP.NET Web Sites, add the following block of code to the code behind file of the Web Form where you have added Report Viewer Control:
<pre>
Default.aspx.cs:

public partial class _Default : System.Web.UI.Page
{
static bool _isSqlTypesLoaded = false;

public _Default()
{
if (!_isSqlTypesLoaded)
{
SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~"));
_isSqlTypesLoaded = true;
}

}
}
</pre>
</p>
<h2>ASP.NET Web Applications</h2>
<p>
For ASP.NET Web Applications, add the following line of code to the Application_Start method in Global.asax.cs:
<pre> SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));</pre>
</p>
<h2>Desktop Applications</h2>
<p>
For desktop applications, add the following line of code to run before any spatial operations are performed:
<pre> SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);</pre>
</p>
</div>
</body>
</html>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit fb6b59e

Please sign in to comment.