2018年11月29日 星期四

[SERVER 2016] [SERVER 2012] [SERVER 2008] Share and Storage Management 檔案伺服器資源管理員

使用Windows Server 作各部門資料夾的分享時,我們會使用到Share and Storage Management 檔案伺服器資源管理員,這個在Server的Share Folder管理上很方便,可以看到誰正在開啟檔案,可以強制對方關閉檔案,釋放檔案讀寫的佔用

[Server 2008]

開啟StorageMgmt可以列出所有開啟分享的資料夾,選擇Manage Open Files 可以管理開啟中的檔案,此管理程式在Server 2012後就更換管理位置了,但你還是可以安裝這個程式去連接其他台 2008 的Server



左側點選要關閉的檔案後 ,右側點選Close Selected


[Server 2012]

要安裝StorageMgmt 可以從伺服器管理員中安裝,但Server 2016 就沒有看到這個選項了
Server manager> Add Roles and Features Wizard> go to Features option and choose below settings.
Remote Server Administrative Tools
Roles Administration Tools
Files services Tools
Share and Storage Management Tool



Server 2012 管理方式改在Computer Management (compmgmt.msc),可以看到開啟中的檔案,也能強制關閉使用中的檔案















2018年11月27日 星期二

[My Project] 自我實現 - 超實用FTP -測試FTP連線




目前進度

[左側本地目錄]
1.本地目錄點一下可以啟動檔案總管來指定目錄
2.可以詳列出目錄,顯示畫面雷同檔案總管
  2.1 顯示目錄與檔案名稱
  2.2 顯示檔案大小



此區待修改項目
1.顯示資料夾圖示
2.Size 顯示計算要再調整計算公式,盡量計算方法與檔案總管相同
3.使用List View 研究能否以欄位來達到排序
4.將FTP連線成功的目錄顯示在右側遠端目錄中


[FTP功能]
1.可以成功連接FTP
2.可以取得遠端檔案目錄


此區待修改項目
1.無法手動切斷連線
2.將FTP模組化



[計算檔案大小]
    Public Function GetFileSize(ByVal TheSize As ULong) As String

        Dim SizeType As String = ""

        Try
            Select Case TheSize
                Case Is >= 1099511627776
                    DoubleBytes = CDbl(TheSize / 1099511627776) 'TB
                    Return FormatNumber(DoubleBytes, 2) & " TB"
                Case 1073741824 To 1099511627775
                    DoubleBytes = CDbl(TheSize / 1073741824) 'GB
                    Return FormatNumber(DoubleBytes, 2) & " GB"
                Case 1048576 To 1073741823
                    DoubleBytes = CDbl(TheSize / 1048576) 'MB
                    Return FormatNumber(DoubleBytes, 2) & " MB"
                Case 1024 To 1048575
                    DoubleBytes = CDbl(TheSize / 1024) 'KB
                    Return FormatNumber(DoubleBytes, 2) & " KB"
                Case 0 To 1023
                    DoubleBytes = TheSize ' bytes
                    Return FormatNumber(DoubleBytes, 2) & " bytes"
                Case Else
                    Return ""
            End Select
        Catch
            Return ""
        End Try
    End Function



[檢查資料夾是否存在]

Imports System.IO

    Private Function Check_Folder(ByVal folderPath As String) As Boolean
        If Directory.Exists(folderPath) Then
            Return True
        Else

            Return False
        End If
    End Function


參考文件:
如何:以 FTP 列出目錄內容

FtpWebRequest Class



2018年11月22日 星期四

[VB.NET] 常用VB.NET字串處理


當字串長度是固定的時候,取出時可指定位置,Substring是由0開始

Sample:
Dim stringReader As String = "ABCDEFG"
Dim StrtNO As String = stringReader.Substring(2, 3)

Result:
StrtNO ="CDE"



當字串長度是不固定時,從右側取出指定位數
Sample:
Dim stringReader As String = "ABCDEFG"
Dim StrtNO As String = stringReader.Substring(stringReader .Length - 3)

Result:
StrtNO = "EFG"

2018年11月20日 星期二

[My Project] 自我實現 - 超實用FTP -實現關閉程式時儲存控制項狀



發現很多軟體都可以做到關閉程式時,能記住上次所選擇的文字
就跟網頁一樣,可以節省一些設定
查了一下才發現原來這麼好用






[Code]

    Private Sub SelfFTPMain_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
        ' 在 FormClosing 事件撰寫儲存設定程式碼
        My.Settings.StringtxtLocal = Me.txtLocal.Text

    End Sub

    Private Sub SelfFTPMain_Load(sender As Object, e As EventArgs) Handles Me.Load
        ' 在 Load 事件撰寫讀取設定程式碼
        txtLocal.Text = My.Settings.StringtxtLocal
    End Sub


[完成畫面]






參考文章:

如何在開發 Windows Forms 程式中,實現關閉程式時儲存控制項狀態

[My Project] 自我實現 - 超實用FTP

覺得市面上好用的FTP有幾個,我想列一下優缺點,好方便加入自己的設計在其中

Client 端
      ※FileZilla(Client)
          優:可管理FTPsite
          缺:無法排程

      ※TurboFTP(Client)
          優:可管理FTPsite、可有超高自由度排程傳送

Server 端
      ※FileZilla(Server)
          優: 架站容易,快
          缺:很多設定太複雜,不易了解,可能導致設定錯誤

      ※TurboFTP(Server)
          優:可管理FTPsite、可有超高自由度排程傳送、可使用AD 認證、可以使用Service


我想要設計一款超方便又簡易可排程,可單次連線的FTP軟體
列出重要功能,再來一步一步實現

※免資料庫管理方式整理FTP清單
※文字檔(XML)讀取、匯入 FTP 管理清單
※單次使用FTP
※支援各式FTP連線(SFTP....等)
※支援排程上傳、下載檔案
※支援Service執行(電腦免登入)


暫時命名為: Self-FTP

希望每天可以有一點點小進展 😆



今日進度:
1.畫面設計
2.決定使用元件:我希望使用內建的,避免使用到他人的設計
3.本地端可以開啟指定位置

2018年11月16日 星期五

PowerShell學習- 呼叫執行Powershell


利用.bat去呼叫 Windows PowerShell

直接輸入powershell 檔案位置



PowerShell 學習 - 本機使用者無法執行PowerShell





有時候會遇到要讓使用者電腦設定值相同
這時候用PowerShell來執行其實還蠻方便的
不過有時候還是會遇到無法執行PowerShell的電腦
這時候用下面這段執行後就可以執行


Set-ExecutionPolicy RemoteSigned



執行必須注意:
1.使用最高權限開啟PowerShell

2.輸入"Set-ExecutionPolicy RemoteSigned" 後,再寫"Y" 確認執行






執行指令參考文章有說明到,「執行原則」有下列 4 種:
Restricted :關閉腳本檔的執行功能,這是預設的設定值。
AllSigned :只允許執行受信任發行者簽署過的腳本檔。
RemoteSigned :在本機電腦所撰寫的腳本檔,不需要簽署就可執行;但是從網際網路(例如:email、MSN Messenger)下載的腳本檔就必須經過受信任發行者的簽署才能執行。
Unrestricted :任何腳本檔皆可被執行,但是於執行網際網路下載的腳本檔時,會先出現警告的提示視窗。

參考文章:
Windows PowerShell 基本操作 - 執行 Windows PowerShell 腳本










2018年11月8日 星期四

在SQL Server 2012 or SQL Server 2016 設定連結的伺服器(Linked Server)






我在使用Linked Server主要用途在方便不同DB Server 之間 使用 CREATE VIEW來連結資料
使用Linked Server 可以使用多個連線方式,且可以使用Windows 認證(Windows Authentication) or Local SQL User連線

增加位置[Server Objects]-[Linked Servers]


在[Linked Servers]上右鍵選擇[New Linked Server...]




在Linked server 寫上IP(open TCP/IP and port) 或者是Server Name(open Named Pipes)



使用Windows 認證(Windows Authentication) 選擇 Be made using the login's current security context
使用SQL 認證(SQL Authentication) 選擇 Be made using this security context







參考連結:
https://docs.microsoft.com/en-us/sql/relational-databases/linked-servers/create-linked-servers-sql-server-database-engine?view=sql-server-2017