Domanda

I am developing a SharePoint 2010 timer job in C# which updates employee status (whether they are currently available or away from work) information retrieved from an SQL database to be updated and stored in an Employees SharePoint list (the desired approach is to be able to access any list I chose, not just one specified/hard coded list). I created a SharePoint empty project whose sole feature is the timer job with my event receiver class with custom code in the FeatureActivated and FeatureDeactived methods. The timer job class's Execute method gets the data using SqlClient and stores it into a dictionary object whose key value is the Employee ID and whose value is the status. The dictionary is then used to retrieve the employee records in the Employees SharePoint list and update the status.

My problem is, no matter what scope I have chosen for the timer job, I cannot access any SharePoint list I desire. I have tried to hard code in URLs for the lists, using the SPWeb and SPSite, just about anything. I have checked the sitecollection for my site, and I have 2 site collections ("/", "testsitecollection"), and the second one is not used at all.

For example" SPWeb web = site.OpenWeb(); SPList list = web.Lists["Employees"];

An exception is thrown: "List "Employees" cannot be found at http://www.mysite"

I was wondering if anyone had any input on the matter. In terms of source code, I followed the many examples on the web such as this: http://www.andrewconnell.com/blog/articles/CreatingCustomSharePointTimerJobs.aspx

All of the examples I found on the web for custom timer jobs update lists on the front site such as the Tasks list.

Thanks to anyone who adds input.

È stato utile?

Soluzione

I have the same problem and I found it worked for me: You should restart OWSTimer.exe (window service in control panel--> administrative tools --> services). It is possible that you are applying the change but laest code is not yet picked up by Sharepoint timer service

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top