2013-07-17 50 views
1

我創建了一個計時器作業並將wsp部署到中央管理員。該功能安裝並正常啓動。我沒有得到任何錯誤。但是我無法在中央管理中的計時器作業列表中看到計時器作業。我沒有看到網站集功能中的功能。計時器作業未出現sharepoint 2007

1)我確實使用STSADM命令安裝並激活了這些功能。 2)Timer作業未出現在sharepoint manager的作業定義下。該功能也不過根據特徵定義出現在SharePoint經理

的web應用有三個網站集和每個網站集都有一個單獨的數據庫的數據庫

我沒有得到任何錯誤,而安裝或激活該功能。

MY code is as follows 
using System; 
using System.Collections.Generic; 
using System.Text; 
using System.Data.SqlClient; 
using Microsoft.SharePoint; 
using Microsoft.SharePoint.Administration; 
namespace TestTimer 
{ 
    public class TestTimerJob:SPJobDefinition 
    { 
     public TestTimerJob() : base() 
     { 


    } 
    public TestTimerJob(string jobName, SPService service, SPServer server, SPJobLockType targetType) 
     : base(jobName, service, server, targetType) 
    { 
     this.Title = "Test Timer Job"; 

    } 
    public TestTimerJob(string jobName, SPWebApplication webApplication) 
     : base(jobName, webApplication, null, SPJobLockType.Job) 
    { 
     this.Title = "Test Timer Job"; 
    } 

    public override void Execute(Guid targetInstanceId) 
    { 
     try 
     { 
      SendEmail(); 
     } 
     catch (Exception ex) 
     { 
      LogError(ex.InnerException.ToString(), ex.StackTrace + ex.Source); 
     } 
    } 
    private void SendEmail() 
    { 
     try 
     { 
      System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); 

      //msg.To.Add(ToEmailAddress); 
      msg.To.Add("****"); 
      msg.From = new System.Net.Mail.MailAddress(""********";"); 
      msg.Subject = "Subject"; 

      msg.IsBodyHtml = true; 
      string EmailBody = " <b>Welcome to Send an Email!!</b><p> Example.<BR>"; 
      msg.Body = EmailBody; 
      string smtp = "***"; 
      System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(smtp); 
      System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential(); 
      NetworkCred.UserName = "********"; 
      NetworkCred.Password = "********"; 
      NetworkCred.Domain = "********"; 
      client.Credentials = NetworkCred; 
      client.Send(msg); 
     } 
     catch (Exception ex) 
     { 

      LogError(ex.InnerException.ToString(), ex.StackTrace); 
     } 





    } 


} 

}

Feature Reciever code below 
using System; 
using System.Collections.Generic; 
using System.Text; 
using Microsoft.SharePoint; 
using Microsoft.SharePoint.Administration; 
using System.Data.SqlClient; 
namespace TestTimer 
{ 
    class TestTimerReceiver : SPFeatureReceiver 
    { 
     const string SYNC_JOB_NAME = "My_Timer_Job"; 
     public override void FeatureActivated(SPFeatureReceiverProperties properties) 
     { 
      try 
      { 
       SPWebApplication webapp = (SPWebApplication)properties.Feature.Parent; 
       foreach (SPJobDefinition job in webapp.JobDefinitions) 
       { 
        if (job.Name.ToLower()==SYNC_JOB_NAME.ToLower()) 
        { 
         job.Delete(); 
        } 
       } 

      TestTimerJob timerJob = new TestTimerJob(SYNC_JOB_NAME, webapp); 
      SPMinuteSchedule schedule = new SPMinuteSchedule(); 
      schedule.BeginSecond = 0; 
      schedule.EndSecond = 59; 
      schedule.Interval = 5; 
      timerJob.Schedule = schedule; 
      timerJob.Update(); 
     } 
     catch (Exception ex) 
     { 

     } 
    } 

    public override void FeatureDeactivating(SPFeatureReceiverProperties properties) 
    { 
     try 
     { 
      SPWebApplication webapp = (SPWebApplication)properties.Feature.Parent; 
      foreach (SPJobDefinition job in webapp.JobDefinitions) 
      { 
       if (job.Name.ToLower()==SYNC_JOB_NAME.ToLower()) 
       { 
        job.Delete(); 
       } 
      } 
     } 
     catch (Exception ex) 
     { 

     } 
    } 

    public override void FeatureInstalled(SPFeatureReceiverProperties properties) 
    { 

    } 

     public override void FeatureUninstalling(SPFeatureReceiverProperties properties) 
     { 

     } 
    } 
} 

和功能.XML下面

<?xml version="1.0" encoding="utf-8"?> 
<Feature Id="b4fa9cf0-dba9-4206-a37c-e707af6199f9" 
      Title="TestTimerReceiver" 
      Description="Description for TestTimerReceiver" 
      Version="12.0.0.0" 
      Hidden="FALSE" 
      Scope="Site" 
      DefaultResourceFile="core" 
      ReceiverAssembly="TestTimer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7f9249145d98c2ad" 
      ReceiverClass="TestTimer.TestTimerReceiver" 



      xmlns="http://schemas.microsoft.com/sharepoint/"> 
    <ElementManifests> 
    <ElementManifest Location="elements.xml"/> 
    </ElementManifests> 
</Feature> 
+0

在Web服務器上嘗試一個IISRESET。 – gurkan

+0

我做過IISRESET –

+0

嘗試重新啓動SharePoint Timer服務(sptimerv3)。你可以從命令行執行:net stop SPTimerV3/net start SPTimerV3 – gurkan

回答

0

也可以嘗試清除SharePoint服務器緩存

相關問題