2008年11月3日 星期一

AppendDocLink 在 Script 不 working,的情況一:

AppendDocLink 在 Script 不 working,的情況範例 一 :

[範例來源:developerWorks > Lotus > Forums & community > Notes/Domino 6 and 7 Forum ]

也是我自己所遇過的情形之一:

問題:

AppendDocLink in Script not working
Posted by F1 Help on 12.Jul.07 at 上午 07:02 using a Web browser
Category: Domino DesignerRelease: 6.5.4Platform: Windows XP


Hi There,

I have a script library, and in there i would like to send a mail with a doc link to the relevent document. here is the code in the script :


Sub SendEmail(w,uidoc,strstatus)
'declare variables
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim maildoc As NotesDocument
Dim strStatusDesc As String

'Set the variables

Set db = s.CurrentDatabase
Set doc = uidoc.document
Set maildoc = New NotesDocument(db)
Set rtitem = New NotesRichTextItem(maildoc, "Body")
'Assign a User-Friendly quote to the status number
If strstatus = "5" Then
strStatusDesc = "Awaiting Quote."
Elseif strstatus = "10" Then
strStatusDesc = "Awaiting Authorisation."
Elseif strStatus = "15" Then
strStatusDesc = "Order Placed."
Elseif strstatus = "20" Then
strStatusDesc = "Order Delivered"
Elseif strstatus = "25" Then
strStatusDesc = "Order Dispatched"
End If
'Prepare subject and body text

maildoc.subject = "Your I.T. Order is at status : " & strStatusDesc
maildoc.SendTo = doc.UName(0)
maildoc.Body = "Hello"
'Attach DocLink
Call rtitem.AppendDocLink(doc,"Your Order","")

'Send Mail

maildoc.Send(False)
End Sub

----

解決方式 :

Check in your database no Default view are there ....
untill unless have one difault view to send doclink

因為在資料庫中 沒有 預設的視界 ;只要再將資料庫的重新設定「預設的視界」,即可運作。

2008年10月19日 星期日

Notes To Word可以避免『文字字串太長』的作法



MS Word String Too Long
-----------------------------
透過Word的「插入\功能變數」+「插入\書籤」的方法:
如圖(一):
然後在Word上建立『Introduction』這欄位,並且定義書籤「插入\書籤」如圖(二);即可準確的讓Notes文字資料轉至Word上。
-----------------------------
You could try this:

1. Create a text field in Word (using the form toolbar).
2. Double click on it to display a dialog box
3. Specify a Bookmark name under Field Settings
4. If the field on the Notes document is called "Introduction" and the Bookmark in Word is called "Introduction" the following code should work for you irrespective of the length of the string in the field:

'DECLARATIONS
Dim ws as New NotesUIWorkspace
Dim uidoc as NotesUIDocument
Dim doc as NotesDocument
Dim word As Variant
Dim wordoc As Variant
Dim temp as string

'GET A HANDLE ON THE NOTES DOCUMENT TO BE EXPORTED
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document

'CREATE THE WORD OBJECT
Set word = CreateObject("Word.Application")
Call word.documents.add ( "c:\worddoc.doc" )
Set worddoc = word.activedocument

'WRITE OUT THE FIELD VALUE TO WORD
If doc.Introduction(0) <> "" Then
temp = doc.Introduction(0)
WordDoc.Bookmarks("Introduction").Select
Call Word.Selection.TypeText(temp)

Else
temp = ""
WordDoc.Bookmarks("Introduction").Select
Call Word.Selection.TypeText(temp)
End If


2008年9月3日 星期三

建立如何將Lotus Notes的資料傳送MS Project,而產生甘特圖

=============================================
Create "MSProject Demo" document to see the demo.
=============================================
這個資料庫是透過 "MSProjectLib" 這程式庫模組將進度項目從Lotus Notes的進度項目 匯到MS Project 來產生甘特圖。

這程式庫包含以下三個函數:

1. CreateModule.
2. CreateActivity
3. CloseModule.

模組參數型態:
1. ModuleName String

進度項目參數:
1. ActivityName String
2. StartDate Date/Time
3. EndDate Date/Time
4. IsFirstActivity Integer                  (1 for true 0 for false)
---資料來源 IBM  網站 Lotus Sandbox 

2008年9月1日 星期一

LS遞回函數

%REM
功能:呼叫自己,可應用在數值累加的計算
參數:theNum%
限制:32K的限制
%ENDREM
Function Facto# (theNum%)
' Calculate theNum% factorial and make it
' the return value of Facto#.
If theNum% <= 0 Then
Facto# = 0
ElseIf theNum% = 1 Then
Facto# = 1
Else
Facto# = theNum% * Facto#(theNum% -1)
End If
End Function
----取自Lotus Domino Designer help

2008年8月25日 星期一

欄位『轉譯的公式』的應用。

請問可以因條件而改變欄位屬性嗎?
目的:在於讓欄位可以『計算』並且也可以讓使用者,填入資料

透過「輸入要轉譯的公式」可以達到這個要求,但使用者仍可進入該欄編輯。

寫在B欄位的「輸入要轉譯的公式」;範例如下:

//--------------------------------

@If(A="yes";@ThisValue;<計算公式>)

//--------------------------------------------

2008年8月19日 星期二

如何得資料庫中到某個role中所有人員名單(陣列)

取得資料庫中到某個role中所有人員名單函數
------------------------------------

Function getRoleUsersOnDB( RoleName As String , ndb As notesDatabase ) As Variant


%REM
功能:取得某角色在資料庫上的所有使用者名稱
參數:
RoleName:要查詢的角色名稱
ndb:要查詢的資料庫物件
傳回值:符合RoleName的所有人員陣列
%END REM

Dim tacl As NotesACL
Dim taclEntry As NotesACLEntry
Dim tmpArray As Variant , hasRolesInACL As Boolean
Dim arr1 As Variant, i As Integer

On Error Goto SubHander

hasRolesInACL = False
Redim arr1(0) As String
getRoleUsersOnDB = arr1

If RoleName = "" Then Exit Function

If ndb Is Nothing Then Exit Function


If Not( ndb.IsOpen ) Then If Not( ndb.Open( ndb.Server , ndb.FilePath ) ) Then Exit Function

Set tacl = ndb.ACL

For i = Lbound( tacl.Roles ) To Ubound( tacl.Roles )
If Lcase( tacl.Roles( i ) ) = Lcase( RoleName ) Then
hasRolesInACL = True
RoleName = tacl.Roles( i )
Exit For
End If
Next

If hasRolesInACL Then
Set taclEntry = tacl.GetFirstEntry
While Not( taclEntry Is Nothing )
If taclEntry.Isroleenabled( RoleName ) Then
If Not Isarray( tmpArray ) Then
Redim tmpArray( 0 ) As String
Else
Redim Preserve tmpArray( Ubound( tmpArray ) + 1 ) As String
End If
tmpArray( Ubound( tmpArray ) ) = taclEntry.Name
End If
Set taclEntry = tacl.GetNextEntry( taclEntry )
Wend
End If
getRoleUsersOnDB = tmpArray

Exit Function
SubHander:

Exit Function
End Function
---來源臭氧層 Notes 討論區

使用者名稱的比對函數

這範例可以『作 一個使用者名稱的比對』,當 FindMatch = TRUE 時 針對該使用者做出警示工作內容上為完成部分,或是更多的權限控管。
----------------------------------------
%Include "LSCONST.LSS"
' Declare an array of Strings and initialize it with some
' names.
Dim theNames(1 to 6) As String
theNames(1) = "Alex"
theNames(2) = "Leah"
theNames(3) = "Monica"
theNames(4) = "Martin"
theNames(5) = "Elizabeth"
theNames(6) = "Don"

Function FindMatch(yourName As String) As Boolean
Static callCounter As Integer ' To count the number of
' calls to FindMatch.
Dim counter As Integer ' Loop counter.
FindMatch = FALSE
For counter% = 1 to 6
If yourName$ = theNames(counter%) Then
FindMatch = TRUE
Exit For ' Exit from the For loop now.
End If
Next

' If the user enters an invalid name,
' increment callCounter%.
If FindMatch = False Then callCounter% = callCounter% + 1
' After three consecutive invalid names, terminate the script.
If callCounter% = 3 Then
Print "Go away, friend."
End ' Terminate execution.
End If
End Function
--來源 Lotus Notes Designer Help

取得資料庫使用者名稱

下面這一個範例是『取得使用者名稱』;當可以取得使用者名稱後,可以針對『使用者』加以限制,他的閱讀權限。可以應用在編輯介面與閱讀介面的切換;又或是在『審核過程中』後配合使用者名稱,加以控管『目前審核者』,所擁有的權限。
---------------------------------------
Dim ws As New NotesUIWorkspace
Dim sess As New NotesSession
Dim db As NotesDatabase '目前資料庫
Set db = ws.CurrentDatabase.Database
'以下是宣告ACL,準備讀取角色
Dim acl As NotesACL
Dim entry As NotesACLEntry
Set acl = db.ACL
Set entry = acl.GetEntry( sess.CommonUserName )
If entry Is Nothing Then
Set entry = acl.GetEntry( sess.UserName )
End If
If entry Is Nothing Then
Messagebox _
"No entry for " & sess.CommonUserName & _
" or " & sess.UserName,, "No entry"
Exit Sub
End If
---來源 Lotus Notes Designer Help

2008年7月3日 星期四

Setup An Odbc Connection Automatically

This script show you how to setup an ODBC connection without any user
intervention. The script uses the Windows Registry and works on Windows
95/98/NT

Code

Declaration Event:
Public Const REG_SZ = 1 'Unicode nul terminated string
Public Const REG_DWORD = 4 '32-bit number
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const SYNCHRONIZE = &H100000
Public Const STANDARD_RIGHTS_ALL = &H1F0000
Public Const STANDARD_RIGHTS_READ = &H20000
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_NOTIFY = &H10
Public Const KEY_CREATE_LINK = &H20
Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or
KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or
KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or
KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
Public Const ERROR_SUCCESS = 0&

Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (Byval
hKey As Long, Byval lpSubKey As String, Byval ulOptions As Long, Byval
samDesired As Long, phkResult As Long) As Long
Declare Function RegCloseKey Lib "advapi32.dll" (Byval hKey As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA"
(Byval hKey As Long, Byval lpValueName As String, Byval lpReserved As Long,
lpType As Long, Byval lpData As String, lpcbData As Long) As Long
Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (Byval
hKey As Long, Byval lpValueName As String, Byval Reserved As Long, Byval dwType
As Long, Byval lpData As String, Byval cbData As Long) As Long
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (Byval
hKey As Long, Byval lpSubKey As String, phkResult As Long) As Long
Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (Byval
hKey As Long, Byval dwIndex As Long, Byval lpValueName As String, lpcbValueName
As Long, Byval lpReserved As Long, lpType As Long, lpData As Any, lpcbData As
Long) As Long



Sub Initialize()
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim hKeyHandle As Long
Dim RetType As Long
Dim RetSize As Long
Dim lValueLen As Long
Dim lDataLen As Long
Dim lpReturnedString As String*127

RetSize = 126
lngCurIdx = 0
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWAREODBCODBCINST.INIODBC Drivers" , 0, KEY_READ, hKeyHandle)

'Check if an ODBC Driver exist on the user workstation
Do
lValueLen = 2000
strValue = String(lValueLen, 0)
lDataLen = 2000
lResult = RegEnumValue(hKeyHandle, lngCurIdx, Byval strValue,
lValueLen, 0&, REG_DWORD, Byval lngData, lDataLen)
lngCurIdx = lngCurIdx + 1

If Instr(1, strValue, "Lotus NotesSQL") Then
lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWAREODBCODBCINST.INI" & strValue, 0, KEY_READ, hKeyHandle)
lResult = RegQueryValueEx(hKeyHandle, "Driver", 0, RetType,
lpReturnedString, RetSize)

'Specified the User DSN parameters
DataSourceName = db.Title
DatabaseName = db.FilePath
DriverPath = lpReturnedString
KeepTempIdx = "0"
MapSpecialChars = "Y"
MaxLongVarcharLen = "512"
MaxRels = "20"
MaxStmtLen = "4096"
MaxSubquery = "20"
MaxVarcharLen = "254"
Server = db.Server
ShowImplicitFlds = "0"
ThreadTimeout = "60"
DriverName = strValue

'Add the new ODBC connection key
lResult = RegCreateKey(HKEY_CURRENT_USER,
"SOFTWAREODBCODBC.INI" & DataSourceName, hKeyHandle)
lResult = RegSetValueEx(hKeyHandle, "Database", 0&, REG_SZ,
Byval DatabaseName, Len(DatabaseName))
lResult = RegSetValueEx(hKeyHandle, "Driver", 0&, REG_SZ, Byval &LTWHA

From http://searchdomino.techtarget.com/tip/1,289483,sid4_gci489320,00.html

2008年7月2日 星期三

FreeBSD6.1 安裝教學

ubject:一起來瘋FreeBSD6.1
Author:琳富(Felix)+錦昌(Rondo)+士玉(Shryu)
Editor:夢想起飛的地方
(http://www.wretch.cc/blog/shryu206)
20060928 first edition
20061003 second edition

{{琳富兄關於FreeBSD管理的文章}}
http://dyna.hcc.edu.tw/dyna/menu/index.php?account=freebsd

{{錦昌兄關於CentOS管理的文章}}
http://apt.nc.hcc.edu.tw/web/student_server_centos4/student_server_centos.html


{{安裝的硬體環境:}}
Intel伺服器(Xeon 2.4G)+ RAID卡"HighPaint RocketRAID 1820A" F+
Westen SATA的硬碟(300G*5顆)+ Ram 1G

"HighPaint RocketRAID 1820A"RAID卡
在 FreeBSD 5.x以後在安裝過程爭
就以後可以直接抓到這張卡片
這張卡最多可支援到8顆硬碟的磁碟陣列

特別注意:CentOS4.4及MagicOSS 20060911尚不直接支援這張Raid卡喔!!


{{ISO 檔下載}}
ftp://freebsd.csie.nctu.edu.tw/pub/releases/i386/ISO-IMAGES/6.1/
6.1-RELEASE-i386-disc1.iso
6.1-RELEASE-i386-disc2.iso


Topic 1基本安裝

{{安裝流程}}
圖文安裝流程請參考
http://dyna.hcc.edu.tw/dyna/menu/main.php?id=45
------------------------------------------------

將FreeBSD光碟片至於光碟機,改BIOS以光碟機開機,
Country Selection--請選209 Taiwan
System Console Keymap---請選擇USA ISO


sysinstall main menu--安裝方式選擇Custom模式


Partition(Allocate Disk Space For FreeBSD)--要配置多少硬碟空間給FreeBSD
請配置整個空間給FreeBSD-->(A)
並記得要設成Bootable-->(S)

開機管理程式,請選擇安裝Standard (沒有開機管理程式)

Label(Label allocated disk partitions)---實際要配置邏輯磁碟區

<以下是我的label(邏輯磁碟區)規劃>
swap 1024MB
/usr 300G(/usr/local/www 自行安裝(Tarball安裝)的路經多在此--school+Dyna+Moodle)
/home 450G
/ 剩下的所有空間


PS.現在的記憶體這麼大為什麼我們還要保留1GB左右的swap區呢?
--->目前還是有許多程式在編寫的時候習慣用到寫入swap區暫存
--->因此即使我們有高達數Giga的記憶體但如果沒有設定swap區
--->還是可能會造成若干程式無法執行的窘境!!

Distribution
選擇安裝的套件
選擇Kern-Developer(所有程式、文件、與 Kernel Source)

......

media
選擇安裝來源為CD/DVD

Commit
選擇確定安裝

做最後確認

開始進行安裝

安裝完後會問--是否要編修系統組態,請選是(Yes)

選擇時區(Timezone)
是否為格林威治時間,請選否
請選亞洲(5 Asia)
請選台灣(42 Taiwan)

設定網路組態(Networking)
選擇 Interfaces 按空白鍵
選擇欲設定的網卡
是否以IPv6做設定,請選否
是否以DHCP自動分配組態,請選否
輸入相關的網路資料
-----這只是範例(請依貴校的狀況設定)---------------
Host:bsd.eces.hcc.edu.tw
Domain:eces.hcc.edu.tw
IPv4 Gateway:192.168.1.254
Name server:163.19.1.1
Netmask:255.255.255.0
--------------------------------------------------
是否要作用這張網卡,請選是


逐層回到選單的最上頁
選擇[X Exit Install]

系統提示將重新開機

重新開機

儘快取出光碟片


{{第一次登入BSD}}
第一次登入BSD是不需要密碼的

所以我們要趕快設定系統老大root密碼

passwd
(設定root密碼)

cd /boot
sysinstall
#與Fedora下的setup有異曲同工之妙
PS.早期的BSD是執行/stand/sysinstall滴喔

進入圖形介面
Configure(Do post-install configuration of FreeBSD)
[Select]
>>
Packages (Install pre-packaged software for FreeBSD)
>>FTP(Install from an FTP server)
>>URL(Specify some other ftp site by URL)
ftp://freebsd.csie.nctu.edu.tw/pub

net--- [X]cvsup-without-gui-16.1h_2(用空白鍵來選擇[X])

security(System Security Software)ssh2-3.2.9.1_5(用空白鍵來選擇[X])
//[安裝ssh2]--bsd剛安裝完之後ssh其實是還沒安裝滴


sysutils(Various system utilities)--[X]portupgrade-2.0.1_1 (用空白鍵來選擇[X])
//目的--升級Port Tree用


[Install]


{{套件管理}}

其實利用ftp的方式安裝就相當於是"pkg_add 套件名稱"的方法來進行以編譯軟體的安裝
我們之後可以用"pkg_delete 套件名稱"的方法來進行移除

pkg_info |more
//顯示已安裝過的套件


reboot


{{第二次登入BSD}}

adduser
Username:sysadm(增加一個管理帳號)
...


vi /etc/group
wheel:*:0:root,sysadm
(讓sysadm這個帳號可以有su的權利)


vi /etc/rc.conf
在最後面加入
sshd_enable="YES"
(這是要讓Super Daemon(inetd)啟動sshd服務的方法)
(FreeBSD中Super Daemon(inetd)要啟動相關的子服務都是要透過"/etc/rc.conf")
(和我以前的認知有蠻大的不同滴.....)


[推薦使用pietty來進行SSH遠端管理我們的FreeBSD]
下載網址
http://w.csie.org/~piaip/pietty/

[Super Daemon:inetd(目前在linux下好像變成xinetd)]
(FreeBSD中Super Daemon(inetd)要啟動相關的子服務都是要透過"/etc/rc.conf")


[只允許管理者使用 ssh 登入]
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
vi /etc/ssh/sshd_config
------------以下是sshd_config的修改重點(本行請不要複製)------
AllowUsers sysadm

#在檔案最後面加上這一行,這樣就只有 sysadm 可以使用 ssh 連線了
#若要設定多人,就用空格隔開:AllowUsers sysadm sysadm2
-------------------------------------------------------------------


reboot
#重新開機後ssh才會重讀這個設定檔


我們已經可以用pietty來遠端管理我們的FreeBSD囉!!



{{中文顯示環境及修改預設shell }}

本段原作 :ADJ網路實驗室
service@adj.idv.tw
http://www.adj.idv.tw/server/linux_freebsd.php


* 安裝bash
cd /boot
sysinstall
#與Fedora下的setup有異曲同工之妙
PS.早期的BSD是執行/stand/sysinstall滴喔

進入圖形介面
Configure(Do post-install configuration of FreeBSD)
[Select]
>>
Packages (Install pre-packaged software for FreeBSD)
>>FTP(Install from an FTP server)
>>URL(Specify some other ftp site by URL)
ftp://freebsd.csie.nctu.edu.tw/pub

shells--- [X]bash-3.1.10_1(用空白鍵來選擇[X])

[Install]


* 使用者環境設定 :

中文顯示環境
要能夠顯示中文是很重要的...^^
以bash為例說明Sad因為adj習慣用bash...QQ)

bash的相關設定檔
系統性的:/etc/profile
應該不會有使用者不想要顯示中文吧...所以設定在系統性的檔案,

vi /etc/profile
在檔案中新增以下三行
ENABLE_STARTUP_LOCALE=zh_TW.Big5; export ENABLE_STARTUP_LOCALE
LC_CTYPE=is_IS.ISO_8859-1; export LC_CTYPE
LANG=zh_TW.Big5; export LANG

再加上:
PS1="\u@\h[\w]\$ "

加上常用的 alias:
alias dir="ls -alh"
alias cls="clear"
alias locate.updatedb='/usr/libexec/locate.updatedb'

說明:
\u --> 顯示使用者帳號
\h --> 顯示系統的hostname(機器名)
\w --> 完整路徑
\$ --> 以#表示root,以$表示一般使用者

存檔離開後...重新登入即可生效...



* 修改預設shell :

因為系統預設採用csh為root的shell,所以每次我們要用剛剛設定的bash,
還需要額外輸入指令 bash 來啟動bash shell,太麻煩了。

透過幾個步驟:
確認bash的執行檔絕對位置。
which bash --> 察看bash這個指令的位置,位於/usr/loca/bin/bash
利用vipw 指令修改/etc/passwd中root預設的shell位置。
從原先的預設的/bin/csh
變更為 /usr/local/bin/bash

或是用下指令的形式:
# pw usermod user -s /usr/local/bin/bash

實例
pw usermod sysadm -s /usr/local/bin/bash

PS.士玉測試中文顯示的結果--還是亂碼!!



########################################################################################

Topic 2
{ports-tree更新}

士玉的問題:
1.如何在crontab裡設定來讓ports-tree自動更新?
2.felix習慣先將Port Tree砍掉 再到網站下載重裝,but how ?


##以下這個動作可省略(因為我們已經用sysinstall的方式安裝過了)
cd /usr/ports/net/cvsup-without-gui
make install clean

##以下這個動作可省略(因為我們已經用sysinstall的方式安裝過了)
cd /usr/ports/sysutils/portupgrade
make install clean



##修改make.conf##

mv /etc/make.conf /etc/make.conf.bak
vi /etc/make.conf

------make.conf的內容(本行請不要複製)-----------------------------------------
SUP_UPDATE= yes
SUP= /usr/local/bin/cvsup
SUPFLAGS= -g -L 2
#
# SUPHOST 代表要到哪台 CVSup,請改成離您比較近的 Server。
# cvsup[1-9].tw.FreeBSD.org
SUPHOST= cvsup.tw.FreeBSD.org
#
# 如果您是用 -stable,請用 stable-supfile (目前的 -stable 是 4.3)
# 如果您是用 -current,請用 standard-supfile (目前的 -current 是 5.0)
SUPFILE= /usr/share/examples/cvsup/stable-supfile
PORTSSUPFILE= /usr/share/examples/cvsup/ports-supfile
DOCSUPFILE= /usr/share/examples/cvsup/doc-supfile
# 國內主要的 FreeBSD distfiles mirror 站台
MASTER_SITE_BACKUP?= \
ftp://freebsd.csie.nctu.edu.tw/pub/distfiles/${DIST_SUBDIR}/\
ftp://ftp.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp2.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}
-------------------(本行請不要複製)------------------------------------------

------make.conf(current)的內容(本行請不要複製)-----------------------------------
MASTER_SITE_OVERRIDE?=\
ftp://freebsd.csie.nctu.edu.tw/pub/distfiles/${DIST_SUBDIR}/\
ftp://ftp.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp2.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
#MAKE_RSAINTL=YES
#USA_RESIDENT=NO
-------------------(本行請不要複製)------------------------------------------






##ports-tree更新##

cd /usr/ports
cp /usr/share/examples/cvsup/ports-supfile .

vi ports-supfile
將 default host由原先的CHANGE_THIS.FreeBSD.org改成freebsd.csie.nctu.edu.tw

cvsup -g -L 2 ports-supfile
//felix說之後要更新ports-tree只要下這個指令即可


##定期更新ports-tree(HOW?)##
vi /etc/crontab


##搜尋某一個port##

cd /usr/ports
make search key="popper" | more
make search name="php"
make search key="libiconv" | grep Path: | grep libiconv



##升級以port安裝的程式##

用 ports 安裝的軟體,遇有該軟體版本更新時如何處置?
請先做「ports-tree的更新」的動作,之後再分別執行下列三道指令:
portsdb -Uu
//執行 portsdb -Uu 時,會有令人覺得當機的味道。別耽心,耐心的稍等一下下就好。

pkgdb -F

portupgrade -acCv
/*安裝過程出現圖形介面,請直接按OK
過程蠻久的說......
*/

##其他指令##
make install : 安裝所選定的 Port
make deinstall : 移除已安裝的 Port
make reinstall : 移除之後再安裝一次
make clean : 安裝完畢後移除 make 資料夾下的檔案
make distclean : 移除安裝後的原始檔案,以節省磁碟空間
make rmconfig : 移除之前安裝過程中組態選項的設定

-------------------------------------------------------------------------------

################################################################################


Topic 3 建置AMP環境(Apache22+Mysql51+PHP5環境)

特別注意:
http://dyna.hcc.edu.tw/dyna/menu/main.php?id=60
這篇文章需要修改不然會有問題喔!!

AMP的安裝順序
可以是MAP也可以是AMP
反正只要記得PHP一定要在最後才裝就對了!!


一、安裝 MySQL:
cd /usr/ports/databases/mysql51-server
make install clean



cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf
##以my.cnf作為以後MySQL設定檔

/usr/local/bin/mysql_install_db
##需要於安裝後啟動 MySQL 之前執行,且只需執行一次即可。若執行二次(含)以上,後面的安裝就可能會有問題)


vi /etc/rc.conf
請加入
mysql_enable="YES"


/*小插曲
mysql_install_db
結果出現command not found的尷尬情形
felix建議我使用whereis指令來查詢mysql_install_db命令檔的執行路徑
whereis mysql_install_db
嘿嘿!!找到了==>/usr/local/bin/mysql_install_db
*/


cd /var/db/
chown -R mysql:mysql mysql


請紀錄我們安裝的mysql版本
mysql-server-5.1.11
mysql-client-5.1.11


二、安裝 Apache:
cd /usr/ports/security/openssl
make install clean

cd /usr/ports/www/apache22
make install clean
出現畫面請加選
cgi-bin模組
直接按OK即可

vi /etc/rc.conf
請加入
apache22_enable="YES"
##沒有加入這行是無法啟動apache的服務滴!!



請注意我們安裝的是apache-2.2.3


三、安裝 PHP:

cd /usr/ports/lang/php5/
make install clean
出現畫面請直接按OK即可


cd /usr/ports/lang/php5-extensions
make install clean
請選擇支援
GD、GETTEXT(處理Native Locale有關--舉例gallery2想要選擇介面操作的語系就需要這個模組)
、ICONV、MBSTRING、MySQL、ZIP 模組



{{想重裝php5-extension以加選GD、GETTEXT、ICONV、MBSTRING、MySQL、ZIP ....模組}}

-----想重裝php5-extension來加選GD、GETTEXT、ICONV、MBSTRING、MySQL、ZIP... 模組--------

請做以下動作
cd /usr/ports/lang/php5-extensions
make clean
//安裝完畢後移除 make 資料夾下的檔案

make rmconfig
//可以移除編譯PHP時所選的選項

make distclean
//移除安裝後的原始檔案,以節省磁碟空間

make deinstall
//移除已安裝的 Port

make install clean

就可以加選GD、GETTEXT、ICONV、MBSTRING、MySQL、ZIP... 模組喔


/usr/local/etc/rc.d/apache22.sh restart
#安裝完後要記得重新啟動apache


-------------專題文章:重裝~結束------------------------------------------------------

四、修改並檢查設定檔
vi /usr/local/etc/apache22/httpd.conf

212行
DirectoryIndex index.html 修改成-->DirectoryIndex index.php index.htm index.html

353行後加入這兩行(vi o模式下附加)
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps


reboot

五、測試

網站的根目錄是在
/usr/local/www/apache22/data

測試http://192.168.1.2/
看看是否可以看到網頁(It works!)


vi /usr/local/www/apache22/data/phpinfo.php

phpinfo();
?>

測試網址
http://192.168.1.2/phpinfo.php


/usr/local/etc/rc.d/apache22.sh restart
#重新啟動apache的服務

六、安裝phpMyAdmin
cd /usr/ports/databases/phpmyadmin
make install clean
出現畫面請直接按OK即可


---------安裝最後提醒的訊息------------------------------------------------
phpMyAdmin-2.7.0.2 has been installed into:
/usr/local/www/phpMyAdmin(安裝的路徑有問題喔--我們要把它移到網站資料夾內)

Please edit config.inc.php to suit your needs.

To make phpMyAdmin available through your web site,
I sugges that you add the following to httpd.conf:

Alias /phpmyadmin/ "/usr/local/www/phpMyAdmin/"(Alias的路徑也需要修正)
-----------------------------------------------------------------------------


cd /usr/local/www
mv phpMyAdmin /usr/local/www/apache22/data
#安裝的路徑有問題--我們要把它移到網站資料夾內


vi /usr/local/etc/apache22/httpd.conf
請加上
Alias /phpmyadmin/ "/usr/local/www/apache22/data/phpMyAdmin/"

cd /usr/local/www/data/phpMyAdmin

mv config.inc.php config.inc.php.bak
cp config.default.php config.inc.php

vi config.inc.php
#修改phpMyAdmin的設定檔

31 行 $cfg['PmaAbsoluteUri'] = ''; 修改成--> $cfg['PmaAbsoluteUri'] = 'http://192.168.1.2/phpmyadmin/';
71 行 $cfg['Servers'][$i]['auth_type'] = 'config'; 修改成--> $cfg['Servers'][$i]['auth_type'] = 'http';


/usr/local/etc/rc.d/apache22.sh restart
#重新啟動apache的服務

測試:http://192.168.1.2/phpMyAdmin/,帳號 root,密碼空白

點選「權限」,然後點選「root」這兩行後面的「編輯權限」圖示,更改密碼



七、忘了MySQL root密碼
(1)停止MySQL服務
/usr/local/etc/rc.d/mysql-server.sh stop
(2)以安全模式啟動
/usr/local/bin/mysqld_safe --skip-grant-table&
(3)進入mysql
mysql mysql
mysql>UPDATE user SET password=password('newpassword') WHERE user='root';
(4)重新再跑MySQL
mysqladmin -uroot -p shutdown

八、讓學生可以使用網頁

vi /usr/local/etc/apache22/httpd.conf
移除第435行(左右)的#字註解符號-->請改成
Include etc/apache22/extra/httpd-userdir.conf


vi /usr/local/etc/apache22/extra/httpd-userdir.conf
第10行
UserDir public_html-->請改成UserDir www
第16行
-->請改成


##建立個人網頁資料夾、範本檔##

mkdir /etc/skel/www
echo "Under construction..." > /etc/skel/www/index.html


/usr/local/etc/rc.d/apache22.sh restart
#重新啟動apache的服務

測試

mkdir /home/sysadm/www
echo "Under construction..." > /home/sysadm/www/index.html

http://192.168.1.2/~sysadm


/usr/local/etc/rc.d/apache22.sh restart
#重新啟動apache的服務

我把/usr/local/etc/apache22/httpd.conf 第83行註解掉
#LoadModule ssl_module libexec/apache22/mod_ssl.so
這行是要載入ssl_module-->但我好像沒裝好!!
所以再/usr/local/etc/rc.d/apache22.sh restart出現Error
因此不得不就把它註解掉!!


{{如何上傳網頁到 /usr/local/www/apache22/data}}

底下使用 link 的方式將 /usr/local/www/apache22/data 資料夾連結到 /home/sysadm/web,
這樣我們就可以用 sysadm 帳號上傳網頁了

chmod 755 /home/sysadm
mkdir /home/sysadm/web
chown sysadm:sysadm /home/sysadm/web
cp -rpf /usr/local/www/apache22/data/* /home/sysadm/web/
mv /usr/local/www/apache22/data /usr/local/www/apache22/data.bak
ln -s /home/sysadm/web /usr/local/www/apache22/data


################################################################################


Topic 4 檔案傳輸伺服器

楔子:BSD內建的fptd及原來在Linux下常用vsftpd,沒想到我竟然都啟動不起來!!
所以向琳富求救,琳富推薦我使用功能超極強大的pure-ftpd,果然好用!!
只是這段文字並不是由士玉等人撰寫的
而是由網路上轉寄過來的文件一字不漏的轉貼上來
(如果有知道作者的人請和我聯絡!!)

本段文字若有侵權請來函通知
p16sys@mail.nc.hcc.edu.tw(周士玉)

{{pure-ftpd (Felix)}}


一、安裝
cd /usr/ports/ftp/pure-ftpd
make WITH_LANG=traditional-chinese
make install

-----------------------安裝後的訊息提示----------------------------------------
Now you need to examine /usr/local/share/examples/pure-ftpd/pam/pure-ftpd
and add the relevant PAM configuration lines to your /etc/pam.conf file.
===> Compressing manual pages for pure-ftpd-1.0.20_2
===> Registering installation for pure-ftpd-1.0.20_2
===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/sbin/pure-ftpd
/usr/local/sbin/pure-authd

This port has installed the following startup scripts which may cause
these network services to be started at boot time.
/usr/local/etc/rc.d/pure-ftpd.sh

If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.

For more information, and contact details about the security
status of this software, see the following webpage:
http://www.pureftpd.org/
---------------------------------------------------------------------------------


二、設定
(1)修改設定檔
cd /usr/local/etc
cp pure-ftpd.conf.sample pure-ftpd.conf
chmod u+w pure-ftpd.conf
vi pure-ftpd.conf

(2)基本設定
pure-ftpd 可設定的功能選項非常多,下面介紹幾個常用的參數:
# 所有人都 chroot 只有屬於管理群組 GID
# (下面的設定要讓所有人只能連線到自己的根目錄底下 只有 GID=1001的群組
# (假設這個-管理群姐是sysadm ) 的人可以切換到其他目錄(才不chroot)
ChrootEveryone yes
TrustedGID 1001
# 最多的連線數
MaxClientsNumber 50
# 同一個 IP 能夠連線的最高數量
MaxClientsPerIP 8
# 匿名 FTP 上載/下載的比率
# AnonymousRatio 1 10
# 所有用戶 上載/下載的比率
# UserRatio 1 10
# anonymous 使用者的頻寬速限,單位 KB/s
# AnonymousBandwidth 8
# 所有使用者(包括 anonymous) 的頻寬速限, 單位 KB/s
# UserBandwidth 8
# 如果要使用 PureDB user database 來建立虛擬帳號就加入下面這行
# 詳細的說明可以參考 README.Virtual-Users
# PureDB /usr/local/etc/pureftpd.pdb

(3)自動執行設定
vi /etc/rc.conf 加入
pureftpd_enable="YES"

(4)匿名FTP設定
要讓 pure-ftpd 能夠提供匿名的 FTP 服務 (Anonymous FTP),
首先要先建立好要給 FTP 使用的群組、帳號及目錄,
下面我們準備一個群組叫 ftpuser ,一個帳號叫 ftp ,
並使用 /home/ftp 來放給訪客下載的檔案,執行底下的指令:

pw groupadd ftpuser -g 21
pw useradd ftp -u 21 -g ftpuser -c "Anoymous FTP user" -d /home/ftp -s /sbin/nologin
mkdir /home/ftp
chown ftp:ftpuser /home/ftp
修改設定檔,在 pure-ftpd.conf 中和匿名的 FTP 服務有關的選項至少要設定:
NoAnonymous no
AnonymousCanCreateDirs no
AnonymousCantUpload no
如果想管制訪客下載的頻寬則可以設定 AnonymousBandwidth 的大小,其它設定自己研究囉!


(5)連線記錄
假設我們希望 pure-ftpd 的連線記錄都寫入 /var/log/pureftpd.log,就執行下面的指令來產生空白的檔案:
touch /var/log/pureftpd.log
修改 syslogd.conf
系統記錄是由 syslod 來總管,pure-ftpd 的連線記錄該寫至何處也是由它來控制,
所以我們要修改 /etc/syslogd.conf ,不然,沒修改之前,所有 pure-ftpd 的記錄都寫到 /var/log/messages 中了。
以編輯器開啟 syslogd.conf 來修改:
vi /etc/syslogd.conf
在裡面找到這下面這行:
cron.* /var/log/cron
然後在它的下面新增一行:
ftp.* /var/log/pureftpd.log
通知 syslogd 重新讀取 /etc/syslogd.conf 中的設定
kill -HUP `cat /var/run/syslogd`
如果以後想要使用 web 的流量分析程式來分析 FTP 記錄,就在 pure-ftpd.conf 中加入下面這行:
AltLog clf:/var/log/pureftpd.log

(6)虛擬帳號的使用
有時候,可能為了辦活動臨時想開一些可以透過 FTP 上載資料的帳號,FreeBSD 內建的 ftpd 綁在系統中,
開了帳號如果沒有特別設定,可能該帳號也能使用其它網路資源,稍嫌麻煩,pure-ftpd 提供了虛擬帳號的功能,
這部份的帳號只有 pure-ftpd 知道,和系統的其它服務基本上是沒有關係的。
pure-ftpd 的虛擬帳號可以選擇儲存常見的資料庫軟體中,如 MySQL , PostgresSQL 或是 LDAP,
如果帳號不多,不想那麼麻煩,它也提供儲存在 PureDB user database 中,下面簡單的試一下 PureDB 。
帳號管理工具:/usr/local/bin/pure-pw
帳號資料檔:
/usr/local/etc/pureftpd.passwd
/usr/local/etc/pureftpd.pdb

5-1 建立虛擬帳號共用的系統帳號
當我們要利用 pure-ftpd 附的工具 pure-pw 來建立虛擬帳號時,它會要我們指定一個系統帳號及群組,
所以要先建一個系統帳號及群組,假設我們要使用 ftpuser 的帳號及 ftpgroup 群組,就執行:
pw groupadd ftpgroup
pw useradd ftpuser -g ftpgroup -c "FTP visual user" -d /dev/null -s /sbin/nologin

注意:前述的系統帳號不要使用和 Anonymous FTP 一樣的帳號、群組。

5-2 建立虛擬帳號
pure-ftpd 虛擬帳號的管理是利用 pure-pw 這個工具,它用起來和 FreeBSD 的 pw 類似,
只是可設定的選項更多了,有興趣可以 man pure-pw ,下面我們先建立一個測試的帳號 hello:

pure-pw useradd hello -u ftpuser -d /home/ftpuser/hello -m

指令輸入完,按完 Enter 鍵,pure-pw 會要求輸入密碼並再確認一次,設定好,帳號即新增完畢了。

參數說明:

useradd:表示要執行新增帳號的程序。後面接要新增的帳號 hello。
-u ftpuser:ftpuser 為前一個步驟所建立的,可以讓所有的虛擬帳號都使用這個。
-d /hme/ftpuser/hello:設定要給這個帳號存放檔案的目錄。
-m:帳號新增完後順便把資料轉入資料庫 (/usr/local/etc/pureftpd.pdb) 中。
如果沒有加這個參數就要自己執行 pure-pw mkdb 來轉檔。
pure-ftpd 的虛擬帳號還有很多的選項可設定,例如,可以管制傳輸的速度、quota、
可連線 IP ...... 等,看看 pureftpd.passwd 中所使用的欄位:

:::::::::::::::::

2008年3月19日 星期三

11.從文件中以單一Key取得視界中所有的文件內容範例

若你想從這一份文件的的某一欄位當Key 而從視界中尋找與 該Key相關的文件,
可以從下面範例來修改,而從視界取得與該Key相關文件相關內容。
'-------------------------------------------------------------------------------
Sub Click(Source As Button)
'We are accessing a document in the same database the script lies.
'Therfore, get the session, the the current database.
Dim s As notessession
Set s=New notessession
Dim db As notesdatabase
Set db=s.currentdatabase

'get the front end document
Dim w As notesuiworkspace
Set w=New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc=w.currentdocument
'宣告ODBC connect
Dim conP As New ODBCConnection
Dim conC As New ODBCConnection
Dim qryP As New ODBCQuery
Dim qryC As New ODBCQuery
Dim resultP As New ODBCResultSet
Dim resultC As New ODBCResultSet
'
'Add code here
'
'get backend document of the current document
Dim doc As notesdocument
Set doc=uidoc.document
'將主文件資料存至Oracle
Set qryP.Connection = conP
Set qryC.Connection=conC
Set resultP.Query = qryP
Set resultC.Query=qryC
Call conP.ConnectTo("cerp","ymh","hedl26")
Call conC.ConnectTo("cerp","ymh","hedl26")
qryP.SQL = "SELECT * FROM scheduleoutline"
qryC.SQL="SELECT * FROM scheduleevent"
'----新增進度大綱資訊到Oracle scheduleoutlineTable-------------------------
resultP.Execute
resultP.addrow
Call resultP.setvalue("sitecode",Trim(uidoc.FieldGetText("sitecode")))
Call resultP.setvalue("sitelabel",Trim(uidoc.FieldGetText("sitelabel")))
Call resultP.setvalue("socode",Trim(uidoc.FieldGetText("socode")))
Call resultP.setvalue("rescode",Trim(uidoc.FieldGetText("rescode")))
Call resultP.setvalue("soname",Trim(uidoc.FieldGetText("soname")))
Call resultP.setvalue("soworkday",Trim(uidoc.FieldGetText("soworkday")))
Call resultP.setvalue("sostartdate",Trim(uidoc.FieldGetText("sostartdate")))
Call resultP.setvalue("sofinishdate",Trim(uidoc.FieldGetText("sofinishdate")))
Call resultP.setvalue("sorate",Trim(uidoc.FieldGetText("sorate")))
Call resultP.setvalue("somoney",Trim(uidoc.FieldGetText("somoney")))
Call resultP.setvalue("ndunid",Trim(uidoc.FieldGetText("unid")))
resultP.updaterow
'--------------------------------------------------------------------------
'---------取得進度項目資訊套表的進度項目文件轉入Oracle purchaseitem Table-------
Dim viewkey As String
Dim subnview As NotesView

Dim subndoc As NotesDocument

Set subnview=db.GetView("(ColScheduleoutlineR)")
Set subndoc=subnview.GetFirstDocument
viewkey=Trim(doc.socode(0)) 'Key請購單號

Do Until subndoc Is Nothing
If (subndoc.socode(0)=viewkey) Then
resultC.Execute
resultC.addrow
Call resultc.setvalue("sitecode",Trim(subndoc.sitecode(0)))
Call resultc.setvalue("socode",Trim(subndoc.socode(0)))
Call resultc.setvalue("rescode",Trim(subndoc.rescode(0)))
Call resultc.setvalue("resname",Trim(subndoc.resname(0)))
Call resultc.setvalue("seworkday",Trim(subndoc.seworkday(0)))
Call resultc.setvalue("sestartdate",Trim(subndoc.sestartdate(0)))
Call resultc.setvalue("sefinishdate",Trim(subndoc.sefinishdate(0)))
Call resultc.setvalue("serate",Trim(subndoc.serate(0)))
Call resultc.setvalue("semoney",Trim(subndoc.semoney(0)))
Call resultc.setvalue("ndpunid",Trim(subndoc.UnidParent(0)))
Call resultc.setvalue("ndcunid",Trim(subndoc.Unid(0)))
resultC.updaterow
End If
Set subndoc = subnview.GetNextDocument(subndoc)
Loop
'---------------------------------------------------------

resultP.close(DB_CLOSE)
conP.disconnect
resultC.close(DB_CLOSE)
conC.disconnect
End Sub
'-------------------------------------------------------------------------------

2008年3月18日 星期二

電腦突然無法進入windows下列檔案遺漏或損毀,無法啟動windows:c:\windows\system32\config\system

一、在正式解決問題前,希望你和我一起溫習一下在「修復主控台」裡會用到好久不見的「DOS」指令:
這些指令的用法都可以透過「 /?」的參數來獲得解答。
1、「cd /?」,按「Enter」鍵。
2、「dir /?」指令,按「Enter」鍵。
3、「attrib /?」指令,按「Enter」鍵。
4、「copy /?」,按「Enter」鍵。
5、「map /?」,按「Enter」鍵。
因為上面這些指令等一下都會用到,所以最少要弄懂「cd」和「copy」, 不然你可能沒有辦法將遺漏或損毀的檔案順利地拷貝回去正確的位置。

二、進入正題,因為你現在的硬碟已經沒有辦法順利進入 Windows XP或是 Windows 2000 了,我們打算進入「修復主控台」來解決。 所以,請先準備好可以光碟開機的 XP 光碟。

1、進入主機板的 BIOS 將光碟設為第一開機選項。
把光碟片放入光碟機裡存檔離開,
然後當我們看到「Press any key to boot from CD...」的提示時,
趕快隨便按任意鍵由光碟開機。
2、看到這個畫面按「R」進入「修復主控台」。
3、看到這個畫面按「1」按,「Enter」鍵。
4、如果你當年「Adinsitor」帳戶有設密碼請鍵入正確密碼,按「Enter」; 如果當年「Adinsitor」帳戶沒有設密碼請直接按「Enter」。
5、終於能進入「C:\WINNT」或「C:\WINDOWS」下了。
6、於「C:\WINNT>」下輸入「map」,然後按「Enter」。
請記下您含有 Windows xp 安裝光碟的光碟機代號,例如圖示裡光碟機代號是「E」和「F」。
備註:這個動作不是必要的,只是萬一將來有可能需要從光碟片拷貝某些檔案出來用。
7、於「C:\WINNT>」下輸入「cd system32」,然後按「Enter」,進入「C:\WINNT\SYSTEM32>」。
8、於「C:\WINNT\SYSTEM32>」下輸入「cd config」,然後按「Enter」,進入「C:\WINNT\SYSTEM32\CONFIG>」
9、於「C:\WINNT\SYSTEM32\CONFIG>」下輸入「attrib -s -r -a -h system」,然後按「Enter」,
這指令意思是:把這個資料夾的「system」檔解除「唯讀、保存、系統、隱藏,等屬性」,
主要目的是為了避免沒有辦法從其他地方拷貝「system」檔案到「C:\WINNT\SYSTEM32\CONFIG>」資料夾裡。
10、連續鍵入下列指令「cd ..」或是「cd /..」,直到回到根目錄「C:\>」。
11、於「C:\>」下鍵入「cd winnt」,按 Enter,到「C:\WINNT>」目錄。
12、於「C:\WINNT>」下鍵入「cd repair」,按 Enter,進入「C:\WINNT\REPAIR>」目錄。
13、於「C:\WINNT\REPAIR>」下鍵入「copy system C:\WINNT\system32\config\」,按 Enter。
14、如果系統提示您是否要覆蓋此檔案,輸入「Y」然後按「Enter」。
15、接著鍵入「EXIT」,按 Enter,重新啟動系統測試是否正常。
16、如果經過上述努力若還無法進入視窗,那就可能必須重灌了。

備註3:其實上述步驟有很多可以合併成一個步驟,慢慢來的原因是希望,我們能很清楚地知道,我們到底想做什麼?
例如7和8可以合併成於「C:\WINNT>」下輸入「cd "system32\config"」
備註4:萬一遇到檔案具備唯讀、隱藏等屬性,而又沒對該檔下「attrib -r -h」指令,可會沒有辦法覆蓋哦!
備註5:挑選正確版本的檔案來拷貝COPY也是很重要的,例如下圖發生的原因是:
她原本安裝時的光碟片是XP SP1,但經過多年使用早已更新到SP2,但偏偏用了SP1版本來覆蓋回去..... !剛剛的努力真是付諸流水啊!

三、馬後砲!
我個人的實務經驗是,很多人習慣把東西丟到桌面上,
「桌 面」「Desktop」的東西其實就是「C:\Documents and Settings\UserNames\Desktop」, 日積月累的結果把「C」塞爆了,例如下圖用 DOS 版的 GHOST來檢查,「C」快滿了,所以檔案在沒中毒的狀況下會莫名奇妙消失。
參考資料 http://www.horngjyi.com.tw/sphpblog/index.php?entry=entry070620-022750

2008年3月13日 星期四

10.利用LS複製MsExcel工作表的方法。

請使用以下範例或是語法:
這範例是用在有一個固定表格時,將此表格當為範本,
然後使用 這各複製的方法來建立 格式 並將資料填入格式中。
'--------------------------------------

xlapp.Application.Worksheets(1).Cells.Copy
xlapp.Application.Worksheets.Add
xlapp.Range("A1").Select
xlapp.ActiveSheet.Paste
'-----------------------------------------------------------

09.利用LS取得Excel目前正在使用中的工作表。

在LS取得目前Excel的工作或是將資料Focus到某個工作表,
可以使用以下方式設定。
'-------------------------------------------------------


Set XlSheet = XlWbk.Worksheets(2) '設定工作表
Call XlSheet.Activate '設定為目前正在使用的工作表

'-------------------------------------------------------

08.透過LS增加Excel的工作表範例語法。

可以使用以下範例語法:
'------------------------------------------------------


Set xlApp = CreateObject("Excel.Application")
' expression.Add(Before, After, Count, Type)
' "Before" is null 增加在目前工作表前面的參數
' "After" is the last sheet that currently exists
' "Count" is null 增加在目前工作表後面的參數
' "Type" is xlWorksheet which the Excel Object Browser shows is -4167
xlApp.Worksheets.Add ,xlApp.Worksheets(xlApp.Worksheets.Count), , -4167
'------------------------------------------------------

07.我要將Excel資料匯入Notes中,但只更新Notes中已存在文件的部份欄位資料,要如何修改程式碼

這各範例我還沒有測試過,不過我找到了有這方式可以是..提供給大家測試。
'-------------------------------------------------------------------------

Sub Click(Source As Button)
Dim s As notessession
Dim ws As notesuiworkspace
Dim db As notesdatabase
Dim doc As notesdocument
Dim xl As Variant
Dim xlwbk As Variant
Dim xlsht As Variant
Dim selected As Variant
Dim filename As String
Dim row As Integer
Set ws = New notesuiworkspace
selected = ws.openfiledialog(False,"請選擇你要匯入的人員 / 評量表對照檔", "Microsoft Excel|*.xls", "")
If Isempty(selected) Then
Messagebox "您沒有選擇要匯入的檔案", 16, "訊息"
Exit Sub
End If
filename = selected(0)
Set xl = createobject("Excel.Application")
xl.visible = False
xl.workbooks.open filename
Set xlwbk = xl.activeworkbook
Set xlsht = xlwbk.activesheet
row = 2
Set s = New notessession
Set db = s.currentdatabase
Set view = db.getview("(allpeoplebyempno)")
Do Until Cstr(Trim(xlsht.cells(row, 1).value)) = ""
keystr = Ucase(Cstr(Trim(xlsht.cells(row, 1).value)))
Set doc = view.getdocumentbykey(Ucase(Cstr(Trim(xlsht.cells(row, 1).value))), False)
If Not(doc Is Nothing) Then
idnostr = doc.idno(0)
doc.category = Ucase(Cstr(Trim(xlsht.cells(row, 6).value)))
doc.execute = "Yes"
Call doc.save(False, False)
End If
row = row + 1
Loop
Call ws.viewrefresh
Messagebox "評量表對應檔匯入完成", 64, "訊息"
End Sub

'-------------------------------------------------------------------------