if(CKEDITOR.instances['<% = me.txtContent.ClientId %>'].getData() == ''){
CKEDITOR.instances['<% = me.txtContent.ClientId %>'].setData('<img src="' + oRes.msg + '" alt="" />');
}
else{
CKEDITOR.instances['<% = me.txtContent.ClientId %>'].insertHtml('<img src="' + oRes.msg + '" alt="" />');
}
$(document).ready(function () {
CKEDITOR.replace('<% = me.txtContent.ClientId %>', {
on: {
instanceReady: function (ev) {
this.dataProcessor.writer.setRules('p', {
indent: false, //縮排
breakBeforeOpen: true, // <P>之前是否換行
breakAfterOpen: true, // <P>之後是否換行
breakBeforeClose: false, // </P>之前是否換行
breakAfterClose: true // </P>之後是否換行
});
}
},
toolbar: 'basic'
});
});
$(document).ready(function () {
if (parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1]) >= 12) {
function bindPasteInCK() {
$("iframe").contents().find("body").bind('paste', imagePasteOnPaste);
}
CKEDITOR.instances.<% = me.txtContent.ClientId %>.on("instanceReady", bindPasteInCK);
}
});
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="/Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(window).bind("paste", function () {
if (event.clipboardData) {
var clipboardData, found;
found = false;
clipboardData = event.clipboardData;
Array.prototype.forEach.call(clipboardData.items, function (item, i) {
if (item.type.indexOf("image") !== -1) {
var blob = clipboardData.items[i].getAsFile();
var URL = window.URL || window.webkitURL;
var source = URL.createObjectURL(blob);
pastedImage = new Image();
pastedImage.src = source;
pastedImage.onload = function () {
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
canvas.width = pastedImage.width;
canvas.height = pastedImage.height;
ctx.drawImage(pastedImage, 0, 0);
var base64 = canvas.toDataURL();
base64 = base64.substring(base64.indexOf("iVBOR"));
$.ajax({
url: "/API/AddTaskImages.aspx",
async: false,
type: "POST",
data: ({
Image: base64
}),
dataType: "html",
success: function (msg) {
var oRes;
try {
oRes = eval(msg);
}
catch (err) {
alert("無法解析傳回資料 !");
alert(msg);
alert(err);
}
if (oRes.success) {
alert("Upload Success..");
//alert(oRes.msg);
$("#MyImageDataLoadDemo").attr("src", oRes.msg);
} else {
alert(oRes.msg);
}
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
})
};
return false;
}
});
}
});
});
</script>
</head>
<body>
<div id="hold">
<div id="imgHold"><img src="" id="MyImageDataLoadDemo"></div>
<div>Click on the area above and ctrl+p an image to paste</div>
</div>
</body>
</html>
Partial Class API_AddTaskImages
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
'DB.sysconfig.Path.TaskAttachment
Dim Base64 As String = Me.Request("Image")
'UW.JSON.WriteErrorMessage(Base64)
'Return
Dim imageBytes As Byte() = Convert.FromBase64String(Me.Request("Image"))
Dim ms As System.IO.MemoryStream = New System.IO.MemoryStream(imageBytes, 0, imageBytes.Length)
ms.Write(imageBytes, 0, imageBytes.Length)
Dim image As System.Drawing.Image = System.Drawing.Image.FromStream(ms, True)
Dim map As Bitmap
Dim Filename As String = Now.ToString("yyyyMMddHHmmssfff") & ".png"
Try
System.IO.Directory.CreateDirectory(DB.sysconfig.Path.TaskAttachment & "UploadImages")
image.Save(DB.sysconfig.Path.TaskAttachment & "UploadImages\" & Filename, System.Drawing.Imaging.ImageFormat.Png)
UW.JSON.WriteSuccessMessage(DB.sysconfig.URL.TaskAttachment & "UploadImages/" & Filename)
Catch ex As Exception
UW.JSON.WriteErrorMessage(ex.ToString)
End Try
End Sub
End Class
Imports System.Drawing.Printing
Namespace X
Partial Public Class PrintSomething
Dim PD As PrintDocumentDim ppc As New Printing.PreviewPrintController()
Dim TotalPage As Int32 = 0
''' <summary>
''' 第幾次列印, 用來控制寫出的圖檔
''' </summary>
''' <remarks></remarks>
Dim PrintCount As Int32 = 1Dim PageCount As Int32 = 1
:
:
:
Sub New(ByVal oPM As DB.PackingListMain, ByVal dtDetail As DataTable, dtUsedCoupon As DataTable)
'初始化資料
:
:
:
End SubSub InitPrintDocument()
'在這裡設定 PrintDocument 的紙張, 印表機, 邊界, 橫印或直印PD = New PrintDocument
:
:
:End Sub
Sub print()
InitPrintDocument()PD.PrintController = ppc
' 第一次先把列印結果存在 Printing.PreviewPrintController 中
AddHandler PD.PrintPage, AddressOf GeneratePreview'再來儲存圖片
AddHandler PD.EndPrint, AddressOf SaveImagePD.Print()
End Sub
Dim ppi() As Printing.PreviewPageInfo
Dim PrintPage As Int32 = 0Sub SaveImage(ByVal sender As Object, ByVal ev As PrintEventArgs)
PrintDebug("Save Image Start, " & Now.ToString("yyyy-MM-dd HH:mm:ss.fff"))
'把圖檔存起來
Dim TF As String = Now.ToString("yyyyMMddHHmmss") ' DB.SysConfig.Path.LocalDataRoot
Dim PathLocal As String = "C:\PrintLog\" & TF.Substring(0, 4) & "-" & TF.Substring(4, 2) & "\"
Dim PathPackingListSheetImage As String = DB.SysConfig.PackingListSheetImage & TF.Substring(0, 4) & "-" & TF.Substring(4, 2) & "\"System.IO.Directory.CreateDirectory(PathLocal)
System.IO.Directory.CreateDirectory(PathPackingListSheetImage)Dim LatestImages As String = ""
ppi = ppc.GetPreviewPageInfo()For x As Integer = 0 To ppi.Length - 1
Dim Filename As String = TF & "_" & Me.oPM.Id & "_" & x & ".png"ppi(x).Image.Save(PathLocal & Filename, System.Drawing.Imaging.ImageFormat.Png)
Next
'把圖檔印出來
For x As Integer = 0 To ppi.Length - 1
'建立新的 PrintDocument
InitPrintDocument()If CST.WebConfig.Server_NAME = "測試主機" Then
UW.WU.DebugWriteLine("PrinterName: " & Me.PD.PrinterSettings.PrinterName)
UW.WU.DebugWriteLine("PaperSize: " & PD.DefaultPageSettings.PaperSize.PaperName)PD.DocumentName = "PackingList"
PD.PrinterSettings.PrintFileName = "C:\PDF\PackingList" & Now.ToString("yyyyMMddHHmmss") & "_" & PrintPage & ".prn"
PD.PrinterSettings.PrintToFile = True'PD.PrinterSettings.
End If'很奇怪, 這裡不會分頁, 所以要一張一張印
AddHandler PD.PrintPage, AddressOf pd_PrintPage2
PD.Print()
PrintPage += 1Next
End SubPrivate Sub pd_PrintPage2(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
'很奇怪, 這裡不會分頁, 所以要一張一張印
ev.Graphics.DrawImage(ppi(PrintPage).Image, 0, 0)
ev.HasMorePages = False
End Sub
Private Sub GeneratePreview(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
' 列印內容
End SubEnd Class
End ClassEnd Namespace
http://nani.uwinfo.com.tw/?p=197
http://ssorc.tw/rewrite.php/read-631.html
安裝 GeoIP:
安裝 Perl 模組
在 cmd 下, 輸入 "ppm install Geo-IP-PurePerl"
下載 Data:
1. Install Perl module. Open your Perl Package Manager which is stand for ppm.bat in bin folder.
2. Install Geo-IP-PurePerl and Geo-IPfree module.
3. Download the GeoIP data from, http://www.maxmind.com/download/geoip/database/. (要 dat 的格式, 不要 csv 的)
4. Extract the data and place it to C:\Perl\lib\Geo\IP folder.
5. Open the awstats.base.conf(C:\awstats\wwwroot\cgi-bin) and paste the following command.
LoadPlugin="geoip GEOIP_STANDARD C:\Perl\lib\Geo\IP\GeoIP.dat"
6. You have done and you will see the result in next update.
當principal DB異常時,若無見證DB,可以手動執行下面指令,讓mirror DB可以正常運作
ALTER DATABASE [ReikoTEST] SET PARTNER OFF
RESTORE DATABASE [ReikoTEST] WITH RECOVERY
刪除資料庫
DROP DATABASE name;
SQL版本查詢
SELECT SERVERPROPERTY('productversion')
SELECT SERVERPROPERTY ('productlevel')
SELECT SERVERPROPERTY ('edition')
with(nolock, index(IX_NTA_StayingRoomSales))
Select * From Table with(nolock, index(IX_NTA_StayingRoomSales)) Where AAAAA
Principal(來源), Mirror(鏡像), Witness(見證,非必要,系統出現錯誤時,自動切換資料庫)
上方三個資料庫需使用相同版本
/*查資料庫版本號*/
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'),SERVERPROPERTY ('edition')
參考資料:
MS SQL Server 2008_容錯轉移_資料庫鏡像實作
Simple Step by Step Database Mirroring
SQL Server 2008 的執行個體之間傳送登入和密碼
Troubleshooting Database Mirroring Error 1418
Microsoft SQL 2008 SERVER -- Fix : Error: 1418 Mirroring
/*
DB: Principal
Step 1, 備份來源資料庫
*/
backup database reikoTest to disk='D:\MirrorTEST_Full.bak'
with format
go
backup log reikoTest to disk='D:\MirrorTEST_log.bak'
go
/*
DB: Mirror
Step 2, 建立mirror資料庫
*/
Create database ReikoTEST
go
restore database ReikoTEST from disk='D:\MirrorTEST_Full.bak'
with replace, norecovery
go
restore log ReikoTESt from disk='D:\MirrorTEST_log.bak'
with norecovery
go
/*
DB: Principal
Step 3, 建立SQL Server 2008 的執行個體之間傳送登入和密碼
注意 這個指令碼會在 master 資料庫中建立兩個預存程序。這兩個預存程序名為 sp_hexadecimal 預存程序和 sp_help_revlogin 預存程序。
※第一次建立mirror時(預存程序不存在時),才需執行本指令
*/
SQL指令碼
/*
DB: Principal
Step 4, 查詢傳送登入帳號和密碼
sp_help_revlogin 預存程序所產生的輸出指令碼是登入指令碼。這個登入指令碼會建立具有原始「安全性識別碼」(SID) 和原始密碼的登入。
*/
EXEC sp_help_revlogin
/*
執行後,複製要使用的帳號,至mirror資料庫執行
ex.
-- Login:reiko
CREATE LOGIN [reiko] WITH PASSWORD = 0x010036D88E850F3F29E70120CB4CD2DEE7CBAD1AB83AA4A6A927 HASHED, SID = 0x495A943A23B12C48A43C39776B879A49, DEFAULT_DATABASE = [master], CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF
*/
/*
DB: Mirror
Step 5, 建立傳送登入帳號和密碼
刪掉DEFAULT_DATABASE = [master],(上方紅字部份)
ex.
-- Login:reiko
CREATE LOGIN [reiko] WITH PASSWORD = 0x010036D88E850F3F29E70120CB4CD2DEE7CBAD1AB83AA4A6A927 HASHED, SID = 0x495A943A23B12C48A43C39776B879A49, CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF
*/
-- Login:reiko
CREATE LOGIN [reiko] WITH PASSWORD = 0x010036D88E850F3F29E70120CB4CD2DEE7CBAD1AB83AA4A6A927 HASHED, SID = 0x495A943A23B12C48A43C39776B879A49, CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF