Don't create audit if only DTS changes for an item

Outlook Library
This commit is contained in:
Rich 2012-04-26 22:01:40 +00:00
parent 42af3e3e76
commit 1f9f65ae18
3 changed files with 303 additions and 1 deletions

View File

@ -1676,3 +1676,28 @@ from vefn_SiblingAndChildrenItems(@DocVersionList, @UnitPrefix) ZZ
where ZZ.ContentID in (select ContentID from vefn_FindText(@DocVersionList,@SearchString,@CaseSensitive,@IncludeLinks,@IncludeRtfFormatting,@IncludeSpecialCharacters,@StepTypeList))
order by DvPath,OrdinalPath
GO
/****** Object: Trigger [dbo].[tr_tblItems_Update] Script Date: 04/25/2012 14:09:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object: Trigger [tr_tblItems_Update] ******/
ALTER trigger [dbo].[tr_tblItems_Update] on [dbo].[tblItems] for update as
begin
if exists (select * from inserted)
begin
if update(PreviousID) or update(ContentID) or update(UserID) or update(DeleteStatus)
begin
insert into ItemAudits(ItemID,PreviousID,ContentID,DTS,UserID,DeleteStatus)
select dd.ItemID,dd.PreviousID,dd.ContentID,dd.DTS,dd.UserID,dd.DeleteStatus from deleted dd
inner join inserted ii on dd.ItemID = ii.ItemID
where dd.deletestatus = 0 or ii.deletestatus != 0
end
end
end
GO
-- Display the status of Trigger alter
IF (@@Error = 0) PRINT 'Trigger alteration: tr_tblItems_Update Succeeded'
ELSE PRINT 'Trigger alteration: tr_tblItems_Update Error on Alteration'
GO

View File

@ -0,0 +1,256 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace LBOutlookLibrary
{
public abstract partial class LBComObject
{
private Object _Item;
internal Object Item
{
get { return _Item; }
set
{
_Item = value;
if (value != null) _MyType = _Item.GetType();
}
}
private Type _MyType;
public Type MyType
{
get { return _MyType; }
set { _MyType = value; }
}
protected LBComObject() { }
protected LBComObject(string ProgID)
{
Type objClassType;
objClassType = Type.GetTypeFromProgID(ProgID);
Item = Activator.CreateInstance(objClassType);
}
protected LBComObject(Object item)
{
Item = item;
}
private Object DoInvokeMember(string name, Object[] parameters, BindingFlags bf, Binder b)
{
try
{
return _MyType.InvokeMember(name, bf, b, _Item, parameters);
}
catch (Exception ex)
{
throw new Exception(string.Format("LBComObject.DoInvokeMember {0}.{1}", _MyType.Name, name), ex);
}
return null;
}
protected void SetProperty(string propertyName, params Object[] parameters)
{
DoInvokeMember(propertyName, parameters, BindingFlags.SetProperty, null);
}
protected Object GetProperty(string propertyName)
{
return DoInvokeMember(propertyName, null, BindingFlags.GetProperty, null);
}
protected Object GetProperty(string propertyName, params Object[] parameters)
{
return DoInvokeMember(propertyName, parameters, BindingFlags.GetProperty, null);
}
protected Object InvokeMethod(string methodName, params Object[] parameters)
{
if (parameters != null)
FixParameters(parameters);
return DoInvokeMember(methodName, parameters, BindingFlags.InvokeMethod, null);
}
private void FixParameters(object[] parameters)
{
// Loop through parameters checking to make sure that none of them are LBComObjects
for (int i = 0; i < parameters.Length; i++)
if (parameters[i] is LBComObject)
parameters[i] = (parameters[i] as LBComObject).Item;
}
protected Object InvokeMethod(string methodName)
{
return InvokeMethod(methodName, null);
}
}
public class LBComObjectList<TList, TItem> : LBComObject
where TList : LBComObjectList<TList, TItem>
where TItem : LBComObject, new()
{
//public new(Object item):base(item){}
public TItem Add()
{
TItem tmp = new TItem();
tmp.Item = InvokeMethod("Add");
return tmp;
}
//public TItem this[int item]
//{
// get
// {
// TItem tmp = new TItem();
// tmp.Item = GetProperty("Item", item);
// return tmp;
// }
//}
}
public partial class LBApplicationClass : LBComObject
{
public LBApplicationClass() : base("Outlook.Application") { }
public LBApplicationClass(Object item) : base(item) { }
public System.Object CreateItem(LBOlItemType ItemType)
{
return InvokeMethod("CreateItem", ItemType);
}
public void Quit()
{
InvokeMethod("Quit");
}
}
public enum LBOlItemType
{
olMailItem = 0,
olAppointmentItem = 1,
olContactItem = 2,
olTaskItem = 3,
olJournalItem = 4,
olNoteItem = 5,
olPostItem = 6,
olDistributionListItem = 7
}
public partial class LBMailItem : LBComObject
{
public LBMailItem() { }
public LBMailItem(Object item) : base(item) { }
}
public partial class LBMailItemClass : LBComObject
{
public LBMailItemClass() { }
public LBMailItemClass(Object item) : base(item) { }
public String Body
{
get { return (GetProperty("Body").ToString()); }
set { SetProperty("Body", value); }
}
public LBOlBodyFormat BodyFormat
{
get { return (LBOlBodyFormat)GetProperty("BodyFormat"); }
set { SetProperty("BodyFormat", value); }
}
public LBAttachments Attachments
{
get { return new LBAttachments(GetProperty("Attachments")); }
}
public String Subject
{
get { return (GetProperty("Subject").ToString()); }
set { SetProperty("Subject", value); }
}
public LBRecipients Recipients
{
get { return new LBRecipients(GetProperty("Recipients")); }
}
public String To
{
get { return (GetProperty("To").ToString()); }
set { SetProperty("To", value); }
}
public void Send()
{
InvokeMethod("Send");
}
}
public enum LBOlBodyFormat
{
olFormatUnspecified = 0,
olFormatPlain = 1,
olFormatHTML = 2,
olFormatRichText = 3
}
public partial class LBAttachments : LBComObject
{
public LBAttachments() { }
public LBAttachments(Object item) : base(item) { }
public int Count
{
get { return (GetProperty("Count") as int? ?? 0); }
}
public LBAttachment Item
{
get { return new LBAttachment(GetProperty("Item")); }
}
public LBAttachment Add(object Source)
{
return new LBAttachment(InvokeMethod("Add", Source, Missing.Value, Missing.Value, Missing.Value));
}
public LBAttachment Add(object Source, object Type, object Position, object DisplayName)
{
return new LBAttachment(InvokeMethod("Add", Source, Type, Position, DisplayName));
}
public void Remove(int Index)
{
InvokeMethod("Remove", Index);
}
}
public partial class LBRecipients : LBComObject
{
public LBRecipients() { }
public LBRecipients(Object item) : base(item) { }
public int Count
{
get { return (GetProperty("Count") as int? ?? 0); }
}
public LBRecipient Item
{
get { return new LBRecipient(GetProperty("Item")); }
}
public LBRecipient Add(string Name)
{
return new LBRecipient(InvokeMethod("Add", Name));
}
public void Remove(int Index)
{
InvokeMethod("Remove", Index);
}
public Boolean ResolveAll()
{
return InvokeMethod("ResolveAll") as Boolean? ?? false;
}
}
public partial class LBAttachment : LBComObject
{
public LBAttachment() { }
public LBAttachment(Object item) : base(item) { }
public LBOlAttachmentType Type
{
get { return (LBOlAttachmentType)GetProperty("Type"); }
}
}
public partial class LBRecipient : LBComObject
{
public LBRecipient() { }
public LBRecipient(Object item) : base(item) { }
public String Address
{
get { return (GetProperty("Address").ToString()); }
}
public String Name
{
get { return (GetProperty("Name").ToString()); }
}
public Boolean Resolve()
{
return InvokeMethod("Resolve") as Boolean? ?? false;
}
}
public enum LBOlAttachmentType
{
olByValue = 1,
olByReference = 4,
olEmbeddeditem = 5,
olOLE = 6
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace LBOutlookLibrary
{
public partial class LBApplicationClass
{
public LBMailItemClass CreateMailItem()
{
return new LBMailItemClass(CreateItem(LBOlItemType.olMailItem));
}
}
public partial class LBMailItemClass
{
public void AddAttachment(string filename)
{
Attachments.Add(filename, LBOlAttachmentType.olByValue, Type.Missing, Type.Missing);
}
}
}