顯示具有 MOSS 標籤的文章。 顯示所有文章
顯示具有 MOSS 標籤的文章。 顯示所有文章

2009年11月5日 星期四

客製化MOSS ALERT的EMAIL內容

I am trying to customize the alert notifications for a task list. I got to remove the “Description” field content and the “Title” field content from the email notifications that is being sent when a task is changed or assigned to somebody. I did the following steps for accomplishing the same:

1. I took a copy of the alerttemplates.xml and copied c:\temp folder in the server.

2. I added the field name “Description” in both the tags “ImmediateNotificationExcludedFields” and “DigestNotificationExcludedFields” under the SPAlertTemplateType.Tasks.

ID;Author;Title;Description;Editor;Modified_x0020_By;Created_x0020_By;_UIVersionString;ContentType;TaskGroup;IsCurrent;Attachments;NumComments;

ID;Author;Title;Description;Editor;Modified_x0020_By;Created_x0020_By;_UIVersionString;ContentType;TaskGroup;IsCurrent;Attachments;NumComments;

3. I did the above changes, saved the file, did an IISRESET and ran the command updatealerttemplates command using STSADM.exe.

4. I changed an item in a task and saved it.

5. The email that I received was not having the title in it, but the content in the “Description” field is still appearing and I need to exclude the same from the email notifications.

I tried this quite a number of times, but no luck. I am still seeing the Description field content in the email notifications that I receive.

I searched for all the possible options but could not get any beak through in this. If possible, I would like to help me out with this and also let me know, if there is any constraints in implementing this. Thanks in advance.

Sharepoint Server 2007(MOSS) Alert Email Troubleshoting--Part II

其他詳細步驟

1. Open the command window, go to the BIN folder and get the property of
Alerts-enabled to make sure the alerts are enabled for the timer service:
C:\Program Files\Common Files\Microsoft Shared\web server
extensions\12\BIN>stsadm.exe -o getproperty -url -pn
alerts-enabled
The expected output is


2. Open the MOSS Central Administration page, click Operations--Timer Job Status,
make sure the following two jobs are showing "success" and 100%
Change Log
Immediate Alerts


3. Make sure the account running the SharePoint Timer service is the account which has the administrator Full Control permission over the site and the full permission over the content database. Restart the timer service if required.

4. 檢查資料庫:
在content db中,timerlock
Open SQL Query Analyzer, connect to the content database of problematic site.
Run the following query and copy the result out.
Select * from timerlock
Let me know the server name seen in the LockedBy column is the same one of this SPS
server. This server is responsible for processing the timer service.

1. Run the following query against the content database of problematic site
select * from eventcache where EventData is not null
(找出尚未送出的ALERT,若完成寄送,EventData 會被設為null)
This will out put all fo the subscritions which have not been processed yet. We can see if there are some alerts which are not processed

2. select * from eventlog where ListID = 'xxx'
()
You can get the ListID from the EventCache table by running
Select * from EventCache and check the documents which correspond to the problematic list.

3. If you cannot find any record in the step 1, please perform the following tests:
Put filemon on the SPS server and we can see if the Timer service picks up the alert template during the whole process.
a. Upload a new document to the document library which is supposed to have the alerts. Begin running the filemon.
b. Run
select * from eventcache order by EventTime DESC
Check if the latest log is the one corresponds to your uploaded document. Make sure the EventData and ACL columns are not NULL.
c. After 5 minutes or more minutes, check the EventCache table again to see if the EventData and ACL columns are NULLed.
d. If so, stop filemon after the EventData and ACL columns are NULLed

Sharepoint Server 2007(MOSS) Alert Email Troubleshoting

0. 先檢查/解決MOSS本身傳送EMAIL的設定
至MOSS管理中心 > 作業 > 外寄電子郵件設定 設定相關資料
測試: 先找一個文件庫或清單,新增一個ALERT,若能收到設定完成的通知信,表示MOSS本身傳送EMAIL設定OK


以下針對當異動/新增發生時,無法收到ALERT EMAIL的狀況:
1. 先察看Timer Job的設定,因為ALERT是Timer Job來負責發送的,Timer Job是以SERVICE方式執行(Windows Sharepoint Service Timer)
先檢查SERVICE是否啟動
Made sure the account running the SharePoint Timer service is the account which has the administrator Full Control permission over the site and the full permission over the content database. Then we restarted the timer service.

2. 並檢查JOB的執行狀況
Opened the MOSS Central Administration page, clicked on Operations--Timer Job Status, made sure the following two jobs were showing "success" and 100%:
Change Log
Immediate Alerts

3. 再檢查設定:
Opened the command window, navigated to the BIN folder and got the property of Alerts-enabled to make sure the alerts are enabled for the timer service:
C:\Program Files\Common Files\Microsoft Shared\web server
extensions\12\BIN>stsadm.exe -o getproperty -url -pn alerts-enabled
The expected output is


4. 檢查content db的內容(參考以下的詳細步驟)
We found EventData and ACL are not NULL for the specific content database. This seems to be the key to the problem.

5. We checked the property job-immediate-alerts schedule
C:\Program Files\Common Files\Microsoft Shared\web server
extensions\12\BIN>stsadm.exe -o getproperty -url <http://server/> -pn
job-immediate-alerts
it showed Property Exist="No" for that specific site.

6. We used the following command to re-set the schedule
stsadm.exe -o setproperty -url -pn job-immediate-alerts -pv
"every 5 minutes between 0 and 59"

Alerts began to work.

如果發現有未執行的JOB,但是設定都正常,則需要重啟TIMER SERVICE,若是重啟失敗,則只有RESET SERVER了。

2009年10月29日 星期四

How to Query SQL Database with a MOSS 2007 WebPart

There are a lot of articles out there that will show you how to create a basic WebPart in MOSS 2007 but I haven't yet seen one that will show you how to really do anything with that WebPart. I wanted to create a simple walk-through that will at least give you the foundation that you need to create a WebPart with some controls and connect to a SQL Database to retrieve some data and add it to a list.

As many of you have undoubtedly figured out by now, there is no way to visually design a WebPart in Visual Studio. For those of you who have written custom controls we would use the same technique to programmatically add the controls to the page at run time. In this example I will create WebPart that consists of a Button used to refresh that data in a SharePoint List and a Label to display a message to the user. The purpose of this WebPart is to populate a SharePoint list with items that are running low in our inventory.

Step 1: Creating the U.I.
In order to create the UI of our WebPart we have to add our controls to the page at run time. This is done by Overriding the CreateChildControls method of the WebPart class. You then use the Controls.Add() method to add new controls to the page. You also need to create the Event Handlers. The resulting code would look like this.

protected override void CreateChildControls()
{
Controls.Add(new LiteralControl("")); Controls.Add(new LiteralControl(" ")); Controls.Add(new LiteralControl("")); Controls.Add(new LiteralControl(" ")); Controls.Add(new LiteralControl(" ")); Controls.Add(new LiteralControl("")); Controls.Add(new LiteralControl(" ")); Controls.Add(new LiteralControl("
"));
cmdRefresh = new Button();
cmdRefresh.ID = "cmdRefresh";
cmdRefresh.Text = "Refresh";
cmdRefresh.ToolTip = "Click here to refresh Out of Stock Items.";
this.cmdRefresh.Click += new EventHandler(cmdRefresh_Click);
Controls.Add(cmdRefresh);
Controls.Add(new LiteralControl("
"));
txtMessage = new Label();
txtMessage.ID = "txtMessage";
txtMessage.Visible = true;
txtMessage.ForeColor = System.Drawing.Color.Red;
Controls.Add(txtMessage);
Controls.Add(new LiteralControl("
"));

base.CreateChildControls();
}

Step 2. Adding Connectin String to Web.Config
Next we need to set up a connection to our database. This of course means we need a web.config file to add our connection string to. Open the web.config file located in the virtual directory of your website. I recommend you make a back up of this first just in case. The file will be located at: C:\Inetpub\wwwroot\wss\VirtualDirectories\. -NOTE- this may be a port number.

To add your connection string to the web.config you first need to add the proper section to the config file. Scroll all the way to the bottom of your config file and you will see the following line: . Just after this line, and before the line, add the following section with your connection string. Save and close.





Now you are ready to build your Data access class.

Step 3. Creating the Data Access class
I created a new class called ListManager and added functionality to handle the retrieval of data from the database and us it to update the SharePoint list. In the constructor of the class I added the following code to set the connection string.

public ListManager()
{
System.Configuration.AppSettingsReader rdr = new AppSettingsReader();
connStr = ConfigurationManager.ConnectionStrings["DBConn"].ToString();
}

I created a method to get the out of stock items form the database just like we would in any other .NET application. The code looks like this:

private void GetOutOfStockItemsDataSet()
{
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(connStr);

cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "usp_SelectOutOfStockItems";
SqlDataAdapter da = new SqlDataAdapter(cmd);

try
{
da.Fill(ds);
}
finally
{
da.Dispose();
}
}
Now we just want to iterate through the items in the DataSet adding the new items and delete the old ones from the list as needed

2009年7月1日 星期三

SharePoint 2007書籍

1. Microsoft SharePoint 2007 Development Unleashed
by Kevin Hoffman‧Robert Foster
悅知有出翻譯版 : http://www.delightpress.com.tw/book.aspx?book_id=SKTP00022
某些章節可以一讀,或是先看這本,然後再詳讀下一本

2. Inside Microsoft Windows SharePoint Services 3.0
by Ted Pattison; Daniel Larson
非常詳盡的說明SharePoint的架構與客製的作法,值得一讀

2008年7月14日 星期一