Add Digital Signature to Documents in a Document Library ?(sptechytalks.blogspot.com)
submitted by
Freddy_Khalaf(35) 2 years, 11 months ago
I had a problem which is , how to add a digital signature to word documents uploaded on a document library
when the document is approved?
and i found the solution , and its design is :
1. catch the update events (by writing ItemUpdated event handlers ) ( for more info about event handlers
implementation see the previous post ).
2.Make a copy of your file that is approved in the document library to a temporary folder on the server.
3.Add the digital signature to your own copied file on the server.
4.Write the file again to your document library then remove the temporary copy on the server.
5.if the file isnot signed the approval status of the document will be converted into rejected.
and the following code implements the previous steps.
The Strings Class is a class that contains all the strings used in my code.
Strings Class , that contains all strings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace DGEventReciever
{
public class Strings
{
// The general keys .
#region
public const string TemporaryFolderKey = @"C:\TempFolder";
public const string ApprovalColumnKey = "Approval Status";
#endregion
//Other Strings.
#region
public const string InDraftStatus = "0";
public const string DateFormat = "yyyyyMMddhhmmss";
public const string IDColumn = "ID";
public const string NameColumn = "Name";
public const string DocxExtension = ".docx";
public const string DocExtension = ".doc";
#endregion
}
}
The Main Class that handles the events:
//the namespaces that are used
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.SharePoint;
using System.IO;
using Microsoft.Office.Core;
namespace DGEventReciever
{
public class DGEventHandler:SPItemEventReceiver
{
//All the Public Used Variables .
#region
public string TemporaryFolder = string.Empty;
public string ApprovalColumnName = string.Empty;
#endregion
public override void ItemUpdated(SPItemEventProperties properties)
{
EventHandlerConstructor();
if (properties.ListItem[ApprovalColumnName].ToString() == Strings.InDraftStatus)
{
DownloadItem(properties);
}
}
private void EventHandlerConstructor()
{
TemporaryFolder = Strings.TemporaryFolderKey;
ApprovalColumnName = Strings.ApprovalColumnKey;
|category: ASP.NET
|Views: 6
tags:
ASP.NET another
Everyones tags:
Your Tags: