7

I have a Sharepoint 2010 farm in which is deployed my solution. This solution provides some "data mantain" of some content types. Let me explain:

Suppose I add a file in a document library: when I put it in the folder X, it write on the item that X is his father and has some particular properties.

This works fine, jumping around 4 event:

  • Item Adding
  • Item Adding
  • Item CheckedIn
  • Item Updated

Now I'm facing a problem: I have a 3rd party component that permits the move of the document from a document library to another, carrying every metadata of the item.

Suppose Item is in X, so it has Item[Field1] = XField1, Item[Fied2] = Xfield2.

I use this plugin, I move Item to Y. Now Item must have Item[Field1] = YField1, Item[Fied2] = Yfield2.

And now comes the problems, 'cause there are more than one event handler that works on my item:

  • Plugin EH wants to put XField1 in Field1
  • My EH wants to put YField1 in Field1

The result? It depends on the order:

  • Came first Plugin EH?

Does my EH face the problem of the modified Item => Plugin EH wins (not correct)

No facing of the problem => My EH wins (correct)

And viceversa.

I cannot put my hands on Plugin Code so I'm asking: is there any way to know if an Item is being used by someone?

If in my code I can say: "Ok, so Plugin is running on it, I must wait" I'll get the right result.

I tried with Item.File.CheckOutStatus but always figures as NONE

Does anybody have an idea?

I tried also to trap the exception in my code and this works but when my EH cames first the exception occurs on the "black box Plugin side" so I cannot mess with..

7
  • My initial thoughts are only if the file is checked out and checked in by the program?
    – Hugh Wood
    Commented Nov 13, 2012 at 16:56
  • 1
    Shouldn't you be able to determine the SequenceNumber for the plugin and then give your event receiver a higher value?
    – Kit Menke
    Commented Nov 13, 2012 at 20:25
  • @Kit Menke it depends totally how this 3rd party plugin works. Does the plugin run from an event receiver or workflow? Or is it a separate process that works from the COM on a timer, for example?
    – Hugh Wood
    Commented Nov 14, 2012 at 9:27
  • 1
    @HughWood Agreed. I was assuming it was also an event receiver since Ziba said "Plugin EH". Probably not a safe assumption> :)
    – Kit Menke
    Commented Nov 14, 2012 at 17:20
  • 1
    When using the Sharepoint Event Receivers, always put your executing code within a lock statement. that way, another thread cannot execute. Read here msdn.microsoft.com/en-us/library/ff650316.aspx
    – Fox
    Commented Dec 19, 2012 at 7:57

1 Answer 1

2

What about checking out file before modifying properties? You check if file is available:

  • if true, you check out file, do changes and check it back in.

  • if file is already checked out you just wait (random amount of time) and then get file status again - after this you have available file or wait again.

There is no need to modify the file, but you can use check in/check out as a lock.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.