UWInfo Blog
發表新文章
[Join] | [忘記密碼] | [Login]
搜尋

搜尋意見
文章分類-#Author#
[所有文章分類]
所有文章分類
  • ASP.NET (48)
  • ASP.NET2.0 (15)
  • ASP.NET4.0 (34)
  • JavaScript (49)
  • jQuery (26)
  • FireFox (4)
  • UW系統設定 (3)
  • SQL (39)
  • SQL 2008 (25)
  • mirror (4)
  • SVN (4)
  • IE (9)
  • IIS (20)
  • IIS6 (1)
  • 閒聊 (7)
  • W3C (6)
  • 作業系統 (9)
  • C# (24)
  • CSS (12)
  • FileServer (1)
  • HTML 5 (11)
  • CKEditor (3)
  • UW.dll (13)
  • Visual Studio (16)
  • Browser (8)
  • SEO (1)
  • Google Apps (3)
  • 網站輔助系統 (4)
  • DNS (5)
  • SMTP (4)
  • 網管 (11)
  • 社群API (3)
  • SSL (4)
  • App_Inventor (1)
  • URLRewrite (2)
  • 開發工具 (6)
  • JSON (1)
  • Excel2007 (1)
  • 試題 (3)
  • LINQ (1)
  • bootstrap (0)
  • Vue (3)
  • IIS7 (3)
  • foodpanda (2)
  • 編碼 (2)
  • 資安 (3)
  • Sourcetree (1)
  • MAUI (1)
  • CMD (1)
  • my sql (1)
最新回應
  • Newtonsoft.Json.JsonConvert.DeserializeObject 失敗的情況
    test...more
  • dotnet ef dbcontext scaffold
    ...more
  • [ASP.NET] 利用 aspnet_regiis 加密 web.config
    ...more
  • IIS ARR (reverse proxy) 服務安裝
    ...more
  • [錯誤訊息] 請加入 ScriptResourceMapping 命名的 jquery (區分大小寫)
    ...more
  • 用 Javascript 跨網頁讀取 cookie (Cookie cross page, path of cookie)
    ...more
  • 線上客服 - MSN
    本人信箱被盜用以致資料外洩,是否可以請貴平台予以協助刪除該信箱之使用謝謝囉...more
  • 插入文字到游標或選取處
    aaaaa...more
  • IIS 配合 AD (Active Directory) 認証, 使用 .Net 6.0
    太感謝你了~~~你救了我被windows 認證卡了好幾天QQ...more
  • PostgreSQL 的 monitor trigger
    FOR EACH ROW 可能要改為 FOR EACH STATEMENT ...more
標籤
  • boeOMZUV
  • .
  • net
  • 檔案
  • JPEG
  • skype
  • write
  • 874
  • USER
  • IDENTITY21
  • 528
  • a
  • -8048 UNIO
  • mod
  • uw
  • -2576 ORDE
  • mssql
  • ad
  • hm.com
  • -2484 UNIO
  • [u2]
  • grpstkizsh
  • cBbJFYKo
  • CROS
  • xml appcmd
  • length
  • profiler
  • css
  • active
  • jquery XSS
  • 安裝
  • CS21211211
  • 12
  • 716
  • dm_exec_sq
  • 634
  • 812
  • 882
  • 108
  • 424
  • 262
  • exception
  • groupby
  • ip21211211
  • 308
  • 0
  • ie8
  • editor
  • 1
  • windows
頁數 1 / 2 下一頁
搜尋 yyy 結果:
PrintDocument 另存成 PDF
如果列印主機是 windows server 主機,通常會有 "Microsoft Print to PDF" 名稱的印表機
那使用 Print Document 物件另存成 PDF code 如下
pd.PrinterSettings.PrinterName = "Microsoft Print to PDF";
pd.PrinterSettings.PrintToFile = true;
pd.PrinterSettings.PrintFileName = @"C:\TEMP\XPS\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf";
More...
darren, 2025/5/12 下午 04:36:12
把 yyyymmdd 轉換成 yyyy-mm-dd 的神奇 javascript
試試這個:
"20190101".replace(/(\d{4})(\d{2})(\d{2})/g, '$1-$2-$3')

取得 yyyyMMdd 的方法
var D = new Date();
D.toISOString().slice(0,10).replace(/-/g,"");
More...
Bike, 2019/8/21 下午 04:47:55
Vue 初學者筆記 v-if v-for @click :class methods
相關參考
https://vuejs.org/v2/guide/

1.
加入vue.js

2.
先"包裹"一層 要用到Vue的元素
個人覺得有點想原本習慣的<!--Content-->
但這次只要放入標籤(我是用Id)
像是範例為 vMain   
然後宣告js 物件 我是取名也叫做 vMain 不知道會不會有撞名問題
所以我的el: 就是 #vMain

3.
再來加入變數
{{Creat_Date}}  兩個括號 桃紅色的
如果data 這個物件裡面有一個叫Creat_Date 的資料他就會被放進去

這樣第一個app 就完成了。

其中 Vue 裡面包含幾樣東西 
el >> 標示 這個Vue 的標籤
data >> 裡面存放的資料變數
created >> 生命週期的
methods>>包含各種功能function

這次的列表頁需要用到以前用的 List Item 跟 Pager
對應到vue 會使用到
v-for for 迴圈
v-for" item in dt  ">> dt 為data中的一個array陣列 (此範例中 為PD 中的 DT)
item 則是在這裡的區域變數

有些要顯示有些要隱藏
v-if
v-if" pager.currentPage  > 1" pager 為data 中的一個物件 裡面有包含 currentPage 的變數

還有要傳ajax 回去要資料
所以要在 vue 中的 methods 建立 function
已這次的例子 getList就是目前的function 可以用到一些 data 裡面的資料
回傳成功之後資料也可以回寫在data上面

以及之前會在各種事件的觸發 
@click 觸發點擊事件
在標籤上加上 @click 可以觸發 類似 onclick 的事件 
但是是調用methods裡面function

日期格式
由於之前的套件PD 回傳的日期資料會是 yyyy-MM-ddTHH:mm:ss 這樣的格式
所以使用了 map  將 dt 裡面的日期 轉換成為我要的格式

v.dt.map(function (obj) {
      var rObj = obj;
      rObj["Create_Date"] = $.datepicker.formatDate('yy-mm-dd', new Date(obj["Create_Date"]));
      return rObj;
});





More...
sean, 2019/5/8 下午 01:08:34
用 sqlcmd 把查詣結果匯出 csv 檔
sqlcmd -S 192.168.XXX.YYY -d EmailKeeper -U sa -P xxxxxx -Q "Select distinct Email, EncEmail from EmailEnc"  -o "EmailEnc.csv" -h -1 -s,

-h: 不要 header
-1; 不用第一行的 -----------
-s,: 用 "," 來分隔欄位.
More...
Bike, 2018/10/7 下午 09:26:44
幫輸出的 Excel 加上表頭 (NPOI, UW.ExcelPOI.DTToExcelAndWriteToClient)
我想大家一定會遇到要把資料匯出成 Excel 的需求. 以現有的工具, 大家想到作法大概都是先把資料放到一個 datatable 之中, 後叫用 UW.ExcelPOI.DTToExcelAndWriteToClient 就結束了.

前兩天遇到一個需求, 輸出的 Excel 要加上表頭, 如下圖



於是乎把  UW.ExcelPOI.DTToExcelAndWriteToClient 做了一些擴充, (其實應該說是幫 DTToWorkSheet 做了擴充), 過程如下.

1. 需求: 一個可以快速填入欄位的 Sub (method or function)
A. 每一個 Cell 可以設定內容(文字), 字型大小, 跨欄數, 對齊方式. (其它的未來再來擴充, 例如顔色).
B. 每一個 Row 由 Cell 組成, 由左到右.
C. 一次可以填多個 Row

2. 實作:
A. 先定義 Cell
    Public Class Cell
        Public Content As String
        Public Colspan As Int32 = 1
        Public Alignment As NPOI.SS.UserModel.HorizontalAlignment
        Public FontHeightInPoints As Int32 = 0

        Sub New(Content As String, Optional Colspan As Int32 = 1,
                Optional Alignment As NPOI.SS.UserModel.HorizontalAlignment = NPOI.SS.UserModel.HorizontalAlignment.General,
                Optional FontHeightInPoints As Int32 = 0)
            Me.Content = Content
            Me.Colspan = Colspan
            Me.Alignment = Alignment
            Me.FontHeightInPoints = FontHeightInPoints
        End Sub
    End Class


B. Row 的格式: 我想最直的覺的就是 List(of Cell) 了吧.

C. 多個 Row 的表示法: List(Of List(Of Cell))

D. 來把 Cell 填入 WorkSheet  吧, 
Public Shared Sub AddRows(WS As HSSFSheet, ltRows As List(Of List(Of Cell)), ByRef StartRow As Int32)

共有三個參數: WS  和 ltRows 應該不用解釋了. 最後一個 StartRow 用來指定插入資料的開始 Row.

E.  完整程式碼: (程式碼不看沒關係, 但要跳到 F. 重點講解哦)
Public Shared Sub AddRows(WS As HSSFSheet, ltRows As List(Of List(Of Cell)), ByRef StartRow As Int32)
        Dim WR As HSSFRow
        If ltRows IsNot Nothing Then
            For Each ltRow As List(Of Cell) In ltRows
                WR = WS.CreateRow(StartRow)
                Dim C As Int32 = 0
                For Each cell As Cell In ltRow
                    Dim ic As NPOI.SS.UserModel.ICell = WR.CreateCell(C)
                    ic.SetCellValue(cell.Content)

                    Dim cs As NPOI.SS.UserModel.ICellStyle = WS.Workbook.CreateCellStyle()
                    cs.Alignment = cell.Alignment
                    If cell.FontHeightInPoints > 0 Then
                        Dim oFont As NPOI.SS.UserModel.IFont = WS.Workbook.CreateFont()
                        oFont.FontHeightInPoints = cell.FontHeightInPoints
                        cs.SetFont(oFont)
                    End If

                    ic.CellStyle = cs

                    If cell.Colspan > 1 Then
                        WS.AddMergedRegion(New CellRangeAddress(StartRow, StartRow, C, C + cell.Colspan - 1))
                        C += cell.Colspan - 1
                    End If
                    C += 1
                Next

                StartRow += 1
            Next
        End If
    End Sub


F. 重點講解:
這個 function 在實作時有兩個卡點:
1. 如何合併欄: 
WS.AddMergedRegion(New CellRangeAddress(StartRow, StartRow, C, C + cell.Colspan - 1))

2. 如何設定字型大小和對齊方式:
                    Dim cs As NPOI.SS.UserModel.ICellStyle = WS.Workbook.CreateCellStyle()
                    cs.Alignment = cell.Alignment
                    If cell.FontHeightInPoints > 0 Then
                        Dim oFont As NPOI.SS.UserModel.IFont = WS.Workbook.CreateFont()
                        oFont.FontHeightInPoints = cell.FontHeightInPoints
                        cs.SetFont(oFont)
                    End If

                    ic.CellStyle = cs


這裡有件有有趣的事, 我一開始是這樣寫的.
ic.CellStyle.Alignment = cell.Alignment

結果是整個 WorkSheet 的對齊方式都被改了. 我猜當 WorkSheet 初建立時, CellStyle 都是用同一個. 所以改任一個 cell 的 CellStyle 會同時改到所有 cell 的.

G. 使用方式:
        Dim ltHeader As New List(Of List(Of UW.ExcelPOI.Cell))
        Dim ltLine As New List(Of UW.ExcelPOI.Cell)
        ltLine.Add(New UW.ExcelPOI.Cell(DB.SysConfig.SYSTEM_NAME & "應收明細表", 16,
                                        NPOI.SS.UserModel.HorizontalAlignment.Center, 28))
        ltHeader.Add(ltLine)

        '第二行
        ltLine = New List(Of UW.ExcelPOI.Cell)
        ltLine.Add(New UW.ExcelPOI.Cell("期間: " & Me.txtbl_date_s.Text & " ~ " & Me.txtbl_date_e.Text, 10,
                                        NPOI.SS.UserModel.HorizontalAlignment.Left, 20))
        ltLine.Add(New UW.ExcelPOI.Cell("製表日期: " & Now.ToString("yyyy-MM-dd"), 6,
                                        NPOI.SS.UserModel.HorizontalAlignment.Right, 20))
        ltHeader.Add(ltLine)

        UW.ExcelPOI.DTToExcelAndWriteToClient(newdt, ltHeader:=ltHeader)
More...
Bike, 2017/6/4 下午 07:19:27
Server端的時區轉換
之前作的 MaskQueen專案 以及現在 UNT的TR獨立專案
都牽涉到後台使用者及前台User看訂單時間錯誤問題
因為系統時間是TW的時間而操作者是外國的使用者 這就需要有個方便模組來轉換系統時間以及user的時間顯示

這部分我以 Extension Method 方式來處理
in VB
Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic
 
Public Module DateTimeExtension
 
    ''' <summary>
    ''' 將系統時間轉為當地的時間並轉為字串
    ''' </summary>
    ''' <param name="dtSystem"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <Extension()> _
    Public Function ToCountryDateTimeString(ByVal dtSystem As DateTime) As String
 
        If dtSystem = DateTime.MinValue Then
            Return "n/a"
        End If
        Dim cstTime As DateTime = dtSystem.ToCountryDateTime()
        ' tr-TR -> dd.MM.yyyy HH:mm:ss
        Dim langCode As String = SHOPUNT.DB.SysConfig.GetSysConfig("DefaultLangCode")
        Dim culture As New System.Globalization.CultureInfo(langCode)
        If cstTime.AddMonths(6) < Now Then
            Return cstTime.ToString("dd.MM.yyyy HH:mm", culture)
        Else
            Return cstTime.ToString("dd.MMM HH:mm", culture)
        End If
 
    End Function
 
    ''' <summary>
    ''' 將系統時間轉為當地的時間
    ''' </summary>
    ''' <param name="dtSystem"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <Extension()> _
    Public Function ToCountryDateTime(ByVal dtSystem As DateTime) As DateTime
        Dim cstZone As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(SHOPUNT.DB.SysConfig.GetSysConfig("DefaultTimeZone"))
        Dim localZone As TimeZoneInfo = TimeZoneInfo.Local
        Dim cstTime As DateTime = TimeZoneInfo.ConvertTime(dtSystem, localZone, cstZone)
        Return cstTime
    End Function
 
    ''' <summary>
    ''' 將使用者輸入的時間轉為系統時間
    ''' </summary>
    ''' <param name="dtCountry"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <Extension()> _
    Public Function ToSystemDateTime(ByVal dtCountry As DateTime) As DateTime
        Dim cstZone As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(SHOPUNT.DB.SysConfig.GetSysConfig("DefaultTimeZone"))
        Dim localZone As TimeZoneInfo = TimeZoneInfo.Local
        Dim sysTime As DateTime = TimeZoneInfo.ConvertTime(dtCountry, cstZone, localZone)
        Return sysTime
    End Function
 
End Module
使用上 只要
DateTime.Now.ToCountryDateTime() 就可以把系統時間轉換成user時間
相反的也有把 user時間轉換成系統時間的功能 ToSystemDateTime()

英國的TimeZone: GMT Stanard Time
Turkey的TimeZone: Turkey Stanard Time
以上的值可以用 TimeZoneInfo.GetSystemTimeZones() 找出來
More...
darren, 2014/5/2 下午 12:27:18
Optional 參數使用 Date 格式所使用的預設值
VB.NET 時間類別因為沿襲自 VB,所以可以用 Date 型別宣告時間變數
實際上在 .NET 他等於 System.DateTime (C# 沒有 Date型別, 只有System.DateTime)
VB.NET 的 Date 可以設定常數,例如 #12/30/2014# (注意!格式是 MM/dd/yyyy, 用 #包起來),這是C#沒有的 
VB.NET 的 Date 也可以等於 Nothing (Nothing = #12:00:00 AM#)
C# 的 DateTime 可以指定為 default(DateTime) 但是不能 = null

由於 optional 參數必須指定預設值,因此當使用 Date 當作 optional 參數時就要設定以上說的值


Public Sub AddNewCustomer(customer As Customer, Optional dateAdded As Date = Nothing)
     If dateAdded = Nothing Then dateAdded = Now


// C# 4.0 以後的 function 已經可以使用 optional 參數
public void AddNewCustomer(Customer customer, DateTime dateAdded = default(DateTime))
     {
         if (dateAdded == default(DateTime)) dateAdded = DateTime.Now;
         ......


Public Sub AddNewCustomer(customer As Customer, Optional dateAdded As Date = #12/30/1899#)

 
More...
darren, 2014/4/1 下午 02:07:31
[程式片段][前台]VB預設
    
    Inherits Master
    Protected Sub Page_PreLoad(sender As Object, e As EventArgs) Handles Me.PreLoad
    End Sub

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        HandleAction()
    End Sub

    Sub HandleAction()
        If UW.WU.IsNonEmptyFromQueryStringOrForm("Action") Then
            Dim Action As String = UW.WU.GetValueFromQueryStringOrForm("Action")
            Select Case Action
            End Select
        End If
    End Sub

    Protected Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender
        LoadPageContext()
    End Sub

    Sub LoadPageContext()

    End Sub

    Sub JSONWriteToClient(ByVal TrueorFalse As Boolean, Optional ByVal msg As String = "", Optional ByVal Title As String = "", Optional ByVal Content As String = "", Optional ByVal Content2 As String = "", Optional ByVal Content3 As String = "")
        Dim TF As String = Now.ToString("yyyyMMddHHmmss")
        Dim oJ As UW.JSON
        oJ = New UW.JSON(TrueorFalse, msg)
        oJ.add("Title", Title)
        oJ.add("Content", Content)
        oJ.add("Content2", Content2)
        oJ.add("Content3", Content3)
        oJ.add("TF", TF)
        oJ.WriteToClient()
        Response.End()
    End Sub
More...
Doug, 2014/1/6 下午 12:25:22
網頁端不同時區之時間顯示

由於網站的user來自全世界各地,而我們網站產生的時間卻是Server的時間
因此需要使用javascript來做一些轉換,讓user看到是他當地的時間

1. Server端產生具有時區的時間字串,用特定的span + class把它包起來, 時間格式 DateTime.ToUniversalTime().ToString("r")
     
<span class="timeString">Fri, 31 Aug 2012 10:57:04 GMT</span>

2. Client端利用jQuery於網頁load的時候將所有時間轉換成當地時間
    這個地方我用了  date.format.js 來轉換成當地時間 (參考  http://blog.stevenlevithan.com/archives/date-time-format  )
   

     $(".timeString").each(function () {
            var content = $(this).text();
            var d = new Date(content);
            if (!isNaN(d)) $(this).text(d.format("yyyy-mm-dd hh:MM tt"));
        }); 
   

這樣user看到的時間就不會錯了
More...
darren, 2012/6/19 下午 04:14:57
在 Chrome 中, 直接把剪貼簿(Clipboard)中的圖片用貼上的方式上傳到 Server
Client Side 的 HTML 如下: (若要在 CKEditor 中使用, 請參考: CKEditor 中貼上剪貼簿(clipboard) 中的圖片)
<!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>



Server Side 的程式碼如下:

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
More...
Bike, 2012/6/3 上午 02:33:36
|< 12 >|
頁數 1 / 2 下一頁
~ Uwinfo ~