Import - Current Project

3122
6
04-19-2010 10:57 AM
JoshHandler
New Contributor
Does anyone have a quick sample for inserting an order into the current projects Orders Inbox.  I have searched and can't find anything.  I have successfully gotten this to work from external application (ExternalAddData), but am having a hard time following how to code for current project through a plug-in.

Thanks,
Josh H
0 Kudos
6 Replies
JoshHandler
New Contributor
I am attaching the code I have so far.  I am just looking to get it working with the hardcoded values, because then I will loop through the individual records I need to import through a dataset.  Any help on this is greatly appreciated, and I'm sorry for if the help is something I should have seen myself.
0 Kudos
JeffWickstrom
Esri Contributor
Hello Josh,

Here is a sample project attached that adds an order to Order Inbox based on what you had started.  Probably the main thing you were missing was bracketing the edit in BeginModification/FinishModification calls.  The geocoder needed to be initialized as well.   I also added Try/Catch around the edits and validating the order which are generally good things to do for editing.

If at all possible with your work flow, it will be easier for you if you can have the user create the new routing folder in ArcLogistics.  This will take care of copying all of the Vehicle templates to Routes which is non-trivial (we should really have a helper method for this).  Then enable your Plug-In when a Routing Folder is selected and do your import into the selected routing folder. 

I also changed OnDestroy() since we have evolved how we do that a bit.  It is better to not call WaitForPendingFinalizers() since that will hang when you have more than one Plug-In within the same project (they will all be waiting for each other).  We also call Marshall.ReleaseComObject(m_app).

Please let us know if this is enough to get you going or feel free to ask more questions.

Jeff
0 Kudos
JoshHandler
New Contributor
Jeff,
   First off, I want to say THANK YOU THANK YOU  VERY MUCH.  I have already used the sample you gave me and added a dialog that I will need and it worked flawless.  I was briefly looking through the code, and didn't see anywhere that you specified the orders inbox.  I am assuming that if a routing folder is not specified, then the order is added just to the inbox itself?  We are constantly moving orders in and out between folders, so I think the way it is setup right now will work perfect for our workflow, but I may need to do the routing folder direct insert in the future.  I also have another question in regards to the amount of adds/edits/deletes that we do on a daily basis.  This is in regards to the gdb size itself.  Can I ask you that question in this thread, or should I create a new thread for that.

Thank you again for all your help,
Josh
0 Kudos
JeffWickstrom
Esri Contributor
Hello Josh,

If you get the Orders collection from the Project, these are the Order Inbox orders.  If you were to get the UnassignedOrders from the Routing Folder, these would be in that collection.  Or you can get the Orders for a Route.  At least I think that is how it works.  Going the other direction, given any particular order, you could get its Parent property and check whether or not it is an IALProject, an IALRoutingFolder or an IALRoute.  I think it is the "Is" operator in vb.net you use to do this "Query Interface" as we would call it in the old COM ways. 

Lets us know if you get stuck.

Regarding amount of edits, I don't think there is a hard limit.  Generally the database size is unlimited.  It would be a good idea to click the save button before there are too many just in case something bad happens so you don't lose work.  Also it is a good idea to make new projects once in a while and use prior projects as templates as a way to backup and/or "compact" the project databases.

Regards,
Jeff
0 Kudos
JoshHandler
New Contributor
Jeff,
   Thanks as always for the direction.  I wish I knew more about the ins and outs of COM, would probably be a huge help for me. 

In regards to the database, what we are trying to do is automate the process of either compacting the database, or as you referenced, copying the database.  It looks like there are methods available to compact the database (IDatabaseCompact) that I am actually trying to create an app right now to utilize.  Is it possible to create a new database via copy without using the app, but more through a custom program?

Thanks,
Josh
0 Kudos
DanielShaffer
New Contributor III
Josh, did you ever get IDatabaseCompact to work?

I seem to be running into a basic flaw (either with the object or my understanding of it - more likely).

The Example for IDatabaseCompact shows the following:

Set pWorkspaceFactory = New AccessWorkspaceFactory
  Set pWorkspace = pWorkspaceFactory.OpenFromFile("C:\arcgis\ArcTutor\BuildingaGeodatabase\Montgomery.mdb", 0)
 
  Dim pDatabaseCompact As IDatabaseCompact
  If TypeOf pWorkspace Is IDatabaseCompact Then
    Set pDatabaseCompact = pWorkspace
    If pDatabaseCompact.CanCompact Then
      pDatabaseCompact.Compact
    End If
  End If

But it dies on Compact as the database is open and has a lock on it.  I'm told to try again when the DB is available.

How do you get around this?

Any help would be greatly appreciated.

Dan
0 Kudos