Friday, May 28, 2010
Applying a SharePoint Designer Workflow to multiple Lists
Thursday, April 15, 2010
Delete ContentType from a Library
Monday, March 22, 2010
Code Snippets
Wednesday, March 17, 2010
STSADM Commands
Monday, March 15, 2010
TimerJob, Feature Receiver, Feature and Batch Files to Install Timer Job
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace PubFormLibraryTimer {
public class FormLibraryTimerJob : SPJobDefinition
{
private const string Event_Source = "FormLibraryTimerJob";
public FormLibraryTimerJob () : base() { }
public FormLibraryTimerJob(string jobName, SPService service, SPServer server, SPJobLockType targetType) : base (jobName, service, server, targetType) { }
public FormLibraryTimerJob(string jobName, SPWebApplication webApplication) : base (jobName, webApplication, null, SPJobLockType.ContentDatabase)
{ this.Title = jobName; }
public override void Execute(Guid targetInstanceId)
{
DateTime fromTime = DateTime.Now.AddMinutes(-5);
DateTime toTime = DateTime.Now;
SPWebApplication webApplication = this.Parent as SPWebApplication;
SPContentDatabase contentDb = webApplication.ContentDatabases[targetInstanceId];
SPList formsLibraryList = contentDb.Sites[0].RootWeb.Lists["YourFormLibrary"];
SPQuery oQuery = new SPQuery();
oQuery.Query = "
SPListItemCollection collListItems = formsLibraryList.GetItems(oQuery);
this.LogEventMessage(collListItems.Count);
}
private void LogEventMessage(int count)
{
if (!EventLog.SourceExists(Event_Source))
{ EventLog.CreateEventSource(Event_Source, "Application"); }
EventLog.WriteEntry(Event_Source, "Your Form Library Modified Forms Count In Last 5 mins - " + count.ToString(), EventLogEntryType.Information);
}
}
}
Feature Receiver:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace YourFormLibraryTimer
{
public class FormsLibraryTimerJobFeatureReceiver : SPFeatureReceiver
{
private const string LOGGER_JOB_NAME = "FormLibraryTimerJob"; public override void FeatureInstalled (SPFeatureReceiverProperties properties) { } public override void FeatureUninstalling (SPFeatureReceiverProperties properties) { } public override void FeatureActivated (SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name == LOGGER_JOB_NAME) job.Delete(); } FormLibraryTimerJob loggerJob = new FormLibraryTimerJob(LOGGER_JOB_NAME, site.WebApplication); SPMinuteSchedule schedule = new SPMinuteSchedule(); schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 5; loggerJob.Schedule = schedule; loggerJob.Update(); } public override void FeatureDeactivating (SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name == LOGGER_JOB_NAME) job.Delete(); } } } } Feature: ?xml version="1.0" encoding="utf-8" ? Feature Id="{DD1D417C-746B-4793-BA4E-A95F156E1E30}" Title="Form Library Timer Job" Description="Installs Form Library Timer Job" Version="1.0.0.0" Scope="Site" ReceiverAssembly="YourFormLibraryTimer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=68d32dec24dfb1a9"ReceiverClass="YourFormLibraryTimer.FormsLibraryTimerJobFeatureReceiver" xmlns="http://schemas.microsoft.com/sharepoint/" / Installing Timer Job in Batch Files: @SET TEMPLATEDIR="c:\program files\common files\microsoft shared\web server extensions\12\Template" @SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm" @SET GACUTIL="C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe" Echo Installing PubFormLibraryTimer.dll in GAC %GACUTIL% -if bin\debug\YourFormLibraryTimer.dll Echo Copying files to TEMPLATE directory xcopy /e /y TEMPLATE\* %TEMPLATEDIR% %STSADM% -o installfeature -filename FormLibraryTimerJob\feature.xml -force %STSADM% -o activatefeature -filename FormLibraryTimerJob\feature.xml -force -url http://localhost:91IISRESET
Thursday, March 4, 2010
Adding Columns to a List Programatically
Wednesday, March 3, 2010
Return Items from a List
Wednesday, February 24, 2010
What's New in Infopath 2010
Stay tuned for more details on our new and improved form design features!
Layout your Forms Using Pre-built Page and Section Layouts
Laying out your form and making it look more attractive is now easier than ever. Insert one of our pre-built page layouts to give your form structure. Then, insert some section layouts into the page layout to start building your form.
Page and Section Layouts in InfoPath Designer:
New and Improved Controls
We’ve added some new controls and narrowed the feature gap between client and browser forms, ensuring a more consistent form filling experience for all our users.
Tuesday, February 23, 2010
Batch Files to Retract, Deploy WSPs
Monday, February 22, 2010
Count Forms in each List in a Document Library
Create New Sharepoint Web Service
(2)To create an ASP.NET Web service
a)In Visual Studio, click File, point to New, and then select Web Site. b)In the Templates box of the New Web Site dialog box, select ASP.NET Web Service, select File System in the Location box, select a programming language and location for the project, and then click OK.
C) Within the new Web service solution, create a separate class library project to contain the Web service logic.
[ To create the project, click File, point to New, and then select Project.] In the New Project dialog box, select a language in the Project types box, select Class Library in the Templates box, provide a name and location for the project, select Add to Solution in the Solution box, and then click OK.
D)Add a reference to the System.Web.Services namespace in the class library project. And also Microsoft.SharePoint
E)Replace the default class file in the class library project with the default service class file that Visual Studio provides in the App_Code folder of the Web service. [To replace the class file with the service class file ] In Solution Explorer, drag Service.cs or Service.vb to the top node in the class library project. Delete the Class1.cs or Class1.vb file, and also delete the Service.cs or Service.vb file that remains in the App_Code folder.
F)Create a strong name for the class library:
In Solution Explorer, right-click the class library project, and then click Properties.
In the Properties dialog box, click Signing, select Sign the assembly, and then select
G) To build only the class library project, right-click the project in Solution Explorer, and then click Build.
H) To add your assembly to the global assembly cache (GAC), you can either drag the assembly into the % windows%\assembly directory using 2 instances of Windows Explorer, or use the command line utility gacutil.exe that is installed with the Microsoft .NET Framework SDK 2.0.
To use gacutil.exe to copy the class library DLL into the GAC
To open the Visual Studio command prompt, click Start, point to All Programs, point to Microsoft Visual Studio 2005, point to Visual Studio Tools, and click Visual Studio 2005 Command Prompt.
At the command prompt type a command in the following form, and press ENTER:
gacutil.exe -if "
I) Now you are ready to modify the assembly information in the default Service.asmx file of the Web service with information for the DLL from the GAC. To get information from the GAC, open the %windows% \assembly directory in Windows Explorer, right-click your assembly, and click Properties.
J) To open Service.asmx in Solution Explorer, right-click the file and click Open. Remove the CodeBehind attribute from the page directive in Service.asmx, and modify the contents of the Class attribute so that the directive matches the following format, where the assembly name "NewAssembly" and the public key token are values specified in the Properties dialog box that you opened in step 10: <%@ WebService Language="C#" Class="Service,NewAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8f2dca3c0f2d0131" %>
K)Rename your .asmx file appropriately, and then save your changes.
3)Generate Static discovery and WSDL files.
In Windows Explorer, copy the .asmx file of your Web service to \\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS.
4)Reset IIS for the DLLs in assembly to take effect.
5)Type in http://Server/_layouts/Service.asmx for the Service and its methods in it.
