2010-12-16 17 views
0

私はこのことを実行することができないようです。私はそれが主にApplicationIdの最初のパラメータに関係していると思います。私はどのIDを入力するか把握できません。私は悪いIDを意味する4の戻り値を得ます。そこにあるすべてのサンプルは2007年用であり、SearchContextを使用しており、推奨されていません。誰でも?SharePoint 2010(2007ではなく)のAPI経由でオーディエンスをコンパイル

public void CompileAudience(SPServiceContext serviceContext, AudienceManager audienceMgr, string AudienceName) 
    { 
     try 
     { 
      int RunJob = -1; 

      CustomMaintenanceTimerJobLogging.LogInfo(CustomMaintenanceTimerJobLogging.CategoryType.AudienceCompile, String.Format("Started compiling the audience '{0}' at {1}", AudienceName, DateTime.Now.ToShortTimeString())); 

      SPSecurity.RunWithElevatedPrivileges(delegate() 
      { 
       // Access the service proxy instance of search application proxy. 
       SearchServiceApplicationProxy searchApplicationProxy = serviceContext.GetDefaultProxy(typeof(SearchServiceApplicationProxy)) as SearchServiceApplicationProxy; 

       // Service Application Info object to retrieve the application id for the search service. 
       SearchServiceApplicationInfo searchApplicationInfo = searchApplicationProxy.GetSearchServiceApplicationInfo(); 

       string[] args = new string[4]; 
       args[0] = searchApplicationInfo.SearchServiceApplicationId.ToString(); 
       args[1] = "1"; // 1=Start compile, 0=Stop 
       args[2] = "1"; // 1=Full, 0=Incremental 
       args[3] = AudienceName; 

       RunJob = AudienceJob.RunAudienceJob(args); 
      }); 

      CustomMaintenanceTimerJobLogging.LogInfo(CustomMaintenanceTimerJobLogging.CategoryType.AudienceCompile, String.Format("Completed compiling the audience '{0}' at {1} with a Result Code of {2} (0 means no errors)", AudienceName, DateTime.Now.ToShortTimeString(), RunJob)); 
     } 
     catch (Exception ex) 
     { 
      CustomMaintenanceTimerJobLogging.LogError(CustomMaintenanceTimerJobLogging.CategoryType.AudienceCompile, ex); 
     } 
    } 

答えて

0

私のブログ記事:http://blog.repsaj.nl/?p=258をご覧ください。それはあなたがそこに着くのに必要なすべてです。渡す必要のあるアプリケーションIDは、検索サービスIDではなく、ユーザープロファイルIDです。そのIDを見つけるにはある程度の反省が必要です。

関連する問題