Hi guys,
Yesterday I was unpleasantly surprised with an error trying to view a list:
"Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.
Correlation ID: ....."
After drilling down the log, some investigation, coffee and googling, I found out that this problem is caused by a Windows update, to be more specific; KB2844286. It's a security update but it renders your list (and listview webparts) inaccessible if you've got any custom XSLT going on in there. Uninstalling the update and performing an IISreset on the WFE solved the issue.
Keywords
administration
(2)
AJAX
(1)
arrays
(1)
asp
(2)
ASP.NET
(2)
assembly
(2)
automation
(1)
BCS
(1)
bindings
(1)
C#
(10)
cell click
(1)
cell value
(1)
clientside
(2)
connection string
(1)
content types
(2)
CSS
(1)
csv
(1)
datagrid
(2)
delegates
(1)
design patterns
(1)
Dialog
(4)
Dictionary
(1)
domain controller
(1)
domain member
(1)
dropdown list
(2)
endpoints
(1)
enum
(1)
error
(1)
event handlers
(1)
Excel
(1)
exporting
(1)
feature event receiver
(2)
File
(1)
formatting code
(1)
forms
(2)
Function
(1)
gac
(1)
hotfolder
(1)
HTML
(2)
inheritance
(1)
javascript
(4)
keyvalue
(1)
layoutspagebase
(1)
LINQ
(2)
lists
(3)
machine account password
(1)
moss
(1)
namespaces
(1)
ObjectDataSource
(1)
objects
(1)
office
(1)
OleDbConnection
(1)
pairs
(1)
permissions
(1)
pivot
(1)
postback
(1)
powershell
(2)
radconfirm
(1)
registry
(1)
resources
(1)
role definitions
(1)
rowclick
(1)
serialization
(2)
serverside
(4)
sharepoint
(15)
site columns
(3)
snapshot
(1)
SPList
(2)
sql
(1)
sql server
(2)
string
(1)
t-sql
(2)
Telerik
(3)
TFS
(1)
Timer
(1)
timerjob
(1)
transpose
(1)
txt
(2)
update
(1)
VBA
(2)
ViewState
(2)
Visual Studio
(1)
web.config
(1)
webparts
(4)
webservices
(1)
XDocument
(1)
xml
(2)
Wednesday, July 17, 2013
Thursday, July 4, 2013
Implementing a simple custom Timer Job in SharePoint 2010
Simple implementation of an SPTimerJob which moves all files in a specified folder to another, prefixing the filenames with a timestamp. The interval is set to every minute.
1. Create a new empty SharePoint 2010 project
2. Create the following class (make sure the folders specified have been created:
4. Add an event receiver to it and define the activated/deactivated methods as follows:
6. Deploy and see the magic happen
1. Create a new empty SharePoint 2010 project
2. Create the following class (make sure the folders specified have been created:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint.Administration; using System.IO; namespace HotFolderJob { public class FileMoverJob : SPJobDefinition { #region Constructors //Constructor public FileMoverJob() : base() { } //Constructor public FileMoverJob(string name, SPWebApplication webApp) : base(name, webApp, null, SPJobLockType.ContentDatabase) { this.Title = "Hotfolder Timer Job"; } #endregion Constructors #region Methods - Overridden public override void Execute(Guid targetInstanceId) { const string sourcePath = @"C:\TimerJob\DropFolder"; const string targetPath = @"C:\TimerJob\TargetFolder"; if (System.IO.Directory.Exists(sourcePath)) { string[] fullPathFiles = System.IO.Directory.GetFiles(sourcePath); foreach (string fullPathfile in fullPathFiles) { var originalFileName = Path.GetFileName(fullPathfile); var destFile = Path.Combine(targetPath, (string.Format("{0:yyMMdd_Hmmss}_", DateTime.Now) + originalFileName)); File.Move(fullPathfile, destFile); //File.Copy(fullPathfile, destFile); } } } #endregion Methods - Overridden } }3. Add a feature, name it as you please
4. Add an event receiver to it and define the activated/deactivated methods as follows:
using System; using System.Runtime.InteropServices; using System.Security.Permissions; using Microsoft.SharePoint; using Microsoft.SharePoint.Security; using Microsoft.SharePoint.Administration; namespace HotFolderJob.Features.HotfolderFeature { [Guid("a2bb921d-dda5-4f0c-923c-da8004a4b09a")] public class HotfolderFeatureEventReceiver : SPFeatureReceiver { const string JOB_NAME = "HotFolderJob"; public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name == JOB_NAME) job.Delete(); } FileMoverJob fileMoverJob = new FileMoverJob(JOB_NAME, site.WebApplication); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 1; fileMoverJob.Schedule = schedule; fileMoverJob.Update(); } public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name == JOB_NAME) job.Delete(); } } //public override void FeatureInstalled(SPFeatureReceiverProperties properties) //{ //} //public override void FeatureUninstalling(SPFeatureReceiverProperties properties) //{ //} //public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters) //{ //} } }5. Set the feature scope to Site (applies for this example)
6. Deploy and see the magic happen
Subscribe to:
Posts (Atom)