修改在SharePoint項目中,我有事件接收器非常重要,直到現在爲項目部署了7個版本的客戶端。這些版本之一是如此不穩定和緩慢。我的意思是有時更新一個項目它sticks.and這隨機發生。處理錯誤的最佳方法:文件'FileName'已被SHAREPOINT system
注意:他們的網絡速度是好的,問題是在項目中。
我檢查了代碼,並發現有錯誤文件「文件名」特惠服務SHAREPOINT \系統進行了改造導致一個循環的方式,sometimes.this是ItemUpdated
和ItemAdded
事件接收器來更新代碼SPListItem
:
base.EventFiringEnabled = false;
bool tryAgain = false; //used to handle "The file has been modified by SHAREPOINT\system"
do
{
tryAgain = false;
try
{
try
{
if (_item.File.CheckOutType == SPFile.SPCheckOutType.Online || _item.File.CheckOutType == SPFile.SPCheckOutType.Offline)
{
try
{
_item.File.CheckIn("prevent checkout/locked error");
}
catch (Exception ex) { }
}
_item.SystemUpdate(true);
}
catch (Exception ex)
{
throw ex; //-- used to handle "The file has been modified by SHAREPOINT\system"
}
}
catch (Exception ex) //-- used to handle "The file has been modified by SHAREPOINT\system"
{
if (ex.Message.ToLower().Contains("has been modified by"))
{
System.Threading.Thread.Sleep(1000 * 2);
tryAgain = true;
}
else
{
this.HandleException(ex, "");
}
}
} while (tryAgain == true);
這個while循環有以下狀態:
1項被更新的第一次,而且也沒有例外
2更新原因提到的異常,它會在迭代幾次後更新
3更新原因提到的異常,並且它在一個循環中停留,即使在200次迭代後也不會更新。
這個問題的情況下,項目是不穩定的,有時工作如此緩慢。什麼是處理這種情況的最佳方式?
謝謝,但同步使它慢!我的問題是速度! –