sharepoint 2013访问下一个列表itemid

时间:2015-09-09 15:40:20

标签: sharepoint

Hello以下是我的代码,用于访问内容数据库中列表的下一个项目ID

int listItemId = -1;
            try
            {
                SPWeb web = SPContext.Current.Web;
                Log("web object", TraceSeverity.High, EventSeverity.Error, "God damn it,it before web object creation");
                Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    Log("RunWithElevatedPrivileges", TraceSeverity.High, EventSeverity.Error, "God damn it,RunWithElevatedPrivileges");
                      using (SPSite elevatedSite = new SPSite(web.Site.ID))
                      {
                          Log("elevatedSite", TraceSeverity.High, EventSeverity.Error, "God damn it,elevatedSite");
                          if (elevatedSite.WebApplication.ContentDatabases.Count > 0)
                          {
                              Log("ContentDatabases.Count", TraceSeverity.High, EventSeverity.Error, "God damn it,eContentDatabases.Count");
                              //Get the connection string for the sharepoint database
                              string connString = elevatedSite.WebApplication.ContentDatabases[0].DatabaseConnectionString;
                              Log("connString", TraceSeverity.High, EventSeverity.Error, "God damn it,connString");
                              //Establish a connection
                              SqlConnection con = new SqlConnection(connString);
                              Log("SqlConnection", TraceSeverity.High, EventSeverity.Error, "SqlConnection");
                              try
                              {
                                  con.Open();
                                  Log(" con.Open();", TraceSeverity.High, EventSeverity.Error, " con.Open();");
                                  //Query to get the next item id for a list(Filtering the list by the list id)
                                  SqlCommand com = con.CreateCommand();
                                  Log(" SqlCommand ", TraceSeverity.High, EventSeverity.Error, " SqlCommand ");
                                  //This command is changed by yogesh for sharepoint 2010 to get next avalable ID in a list
                                  //com.CommandText = String.Format("select tp_NextAvailableId from AllLists where tp_ID = '{0}'", listId.ToString());
                                  com.CommandText = String.Format("select NextAvailableId from AllListsAux where ListID = '{0}'", listId.ToString());
                                  Log("com.CommandText ", TraceSeverity.High, EventSeverity.Error, "com.CommandText ");
                                  listItemId = (int)com.ExecuteScalar();
                                  Log("listItemId", TraceSeverity.High, EventSeverity.Error, "listItemId");
                              }
                              finally
                              {
                                  con.Close();
                              }
                          }
                      }
                  });

            }

这段代码工作正常但是当我在PPD中部署我的代码时,它给了我

的错误

下面是堆栈跟踪错误我无法理解问题请尽快帮助我

上帝该死的,它在创建网页对象之前304d2c9d-7d0d-207c-3e44-95108fc65117 09/09/2015 17:07:58.25 w3wp.exe(0x2EC0)0x4250未知RunWithElevatedPrivileges
00000高
该死的,RunWithElevatedPrivileges 304d2c9d-7d0d-207c-3e44-95108fc65117 09/09/2015 17:07:58.25 w3wp.exe(0x2EC0)0x4250 SharePoint Foundation数据库
ahjqp高
[强制由于记录间隙,缓存@ 09/09/2015 17:07:58.24,原始级别:详细] SQL连接时间:0.0291936545007815,数据源= MOC-MHX-SQLC06 \ PPD_BIZAPP2013;初始目录= WSS_Content_PERApplication_new;集成安全性= True; Enlist = False; Pooling = True; Min Pool Size = 0; Max Pool Size = 100; Connect Timeout = 15; Application Name = SharePoint [w3wp] [2] [WSS_Content_PERApplication_new] 304d2c9d-7d0d-207C-3e44-95108fc65117 09/09/2015 17:07:58.25 w3wp.exe(0x2EC0)0x4250 SharePoint Foundation General 6t8j High
[由于记录间隙而强制,原始级别:详细] {0} 304d2c9d-7d0d-207C-3e44-95108fc65117 09/09/2015 17:07:58.25 w3wp.exe(0x2EC0)0x4250未知的elevatedSite
00000高
该死的,抬高了SiteSite 304d2c9d-7d0d-207c-3e44-95108fc65117 09/09/2015 17:07:58.25 w3wp.exe(0x2EC0)0x4250未知ContentDatabases.Count
00000高
该死的,eContentDatabases.Count 304d2c9d-7d0d-207c-3e44-95108fc65117 09/09/2015 17:07:58.25 w3wp.exe(0x2EC0)0x4250未知的connString
00000高
该死的,connString 304d2c9d-7d0d-207c-3e44-95108fc65117 09/09/2015 17:07:58.25 w3wp.exe(0x2EC0)0x4250未知SqlConnection 00000高

SqlConnection 304d2c9d-7d0d-207c-3e44-95108fc65117 09/09/2015 17:07:58.27 w3wp.exe(0x2EC0)0x4250未知con.Open();
00000高
con.Open(); 304d2c9d-7d0d-207C-3e44-95108fc65117 09/09/2015 17:07:58.27 w3wp.exe(0x2EC0)0x4250未知SqlCommand 00000高

SqlCommand 304d2c9d-7d0d-207c-3e44-95108fc65117 09/09/2015 17:07:58.27 w3wp.exe(0x2EC0)0x4250未知com.CommandText 00000高

com.CommandText 304d2c9d-7d0d-207c-3e44-95108fc65117 09/09/2015 17:07:58.33 w3wp.exe(0x2EC0)0x4250 SharePoint Foundation数据库
ahjqp高
[由于记录间隙而强制,缓存@ 09/09/2015 17:07:58.28,原始级别:详细] SQL连接时间:0.0308000039111116(数据源)= MOC-MHX-SQLC06 \ PPD_BIZAPP2013;初始目录= WSS_Content_PERApplication_new;集成安全性= True; Enlist = False; Pooling = True; Min Pool Size = 0; Max Pool Size = 100; Connect Timeout = 15; Application Name = SharePoint [w3wp] [2] [WSS_Content_PERApplication_new] 304d2c9d-7d0d-207C-3e44-95108fc65117 09/09/2015 17:07:58.33 w3wp.exe(0x2EC0)0x4250 SharePoint Foundation General ama7l High
[由于记录间隙而强制,原始级别:详细] SPListItem.AddOrUpdateItem:begin 304d2c9d-7d0d-207C-3e44-95108fc65117 09/09/2015 17:07:58.41 w3wp.exe(0x2EC0)0x4250 SharePoint Foundation Dev事件
ahk8b高
[由于记录间隔而强制,原始级别:详细]为项目{1}上的列表{0}调用ExecuteItemEventReceivers() 304d2c9d-7d0d-207C-3e44-95108fc65117 09/09/2015 17:07:58.50 w3wp.exe(0x2EC0)0x4250 SharePoint Foundation Dev事件
ajekb高
[强制由于记录差距,缓存@ 09/09/2015 17:07:58.43,原始级别:详细]调用EventReceiver - [Id:{0}] 304d2c9d-7d0d-207C-3e44-95108fc65117 09/09/2015 17:07:58.50 w3wp.exe(0x2EC0)0x4250 SharePoint Foundation数据库
8acb高
[由于记录间隙而强制,原始级别:VerboseEx]恢复为进程标识 304d2c9d-7d0d-207C-3e44-95108fc65117 09/09/2015 17:07:58.53 w3wp.exe(0x2EC0)0x47B4 SharePoint Foundation Dev事件
ajbpn中等
将EventFiringDisabled设置为[False]。堆栈跟踪:[在System.Threading.ExecutionContext.RunInternal的Microsoft.SharePoint.Utilities.SPThreadPool.WaitCallbackWrapper(对象状态)中的Microsoft.SharePoint.SPEventManager.HandleEventCallback [ReceiverType,PropertiesType](Object callbackData)(ExecutionContext executionContext,ContextCallback回调, System.Threading.ThreadPoolWorkQueue上System.Threading.QuereadingUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()的System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,Object状态,Boolean preserveSyncCtx)中的对象状态,Boolean preserveSyncCtx。派遣()] 264d2c9d-1dd5-207c-3e44-9aa480fb3752 09/09/2015 17:07:58.57 w3wp.exe(0x2EC0)0x4250 SharePoint Foundation拓扑
ebe8中等
农场帐户的初始化Sid 304d2c9d-7d0d-207c-3e44-95108fc65117

0 个答案:

没有答案