|
POST
|
Thanks, I will give it a try, all online examples show this technique. But would it work even if the command has not been added to the CommandBar - because the example tries to find the command by ICommandBars.Find(). oooh not sure. I've always implemented an IToolBarDef class, so I am unsure of success in doing what you are attempting. Hopefully someone who has experienced this can jump in and explain.
... View more
02-28-2011
05:59 AM
|
0
|
0
|
1543
|
|
POST
|
I have developed a command that implements ICommand and ITool. This command is registered in the ESRI MX Commands category. How can I execute this command programmatically without having to add it to a toolbar or a commandbar? Not totally sure you can do this, but if it's registered already then you should be able to execute it via it's GUID just like any other registered command. For example, this code would initiate the Sketch Tool: 'set the current tool to be the editor Sketch tool Dim pCommandItem As ESRI.ArcGIS.Framework.ICommandItem Dim pUID As New ESRI.ArcGIS.esriSystem.UID pUID.value = "esriCore.SketchTool" pCommandItem = m_pApp.Document.CommandBars.Find(pUID) m_pApp.CurrentTool = pCommandItem m_pEditEvents = pEditor
... View more
02-28-2011
05:27 AM
|
0
|
0
|
1543
|
|
POST
|
I don't understand why "Nothing" is put there on the last line. Would someone please explain about it and how to complete the macro for it to run well? Not totally sure, but I believe that the ITable.Sort method accepts a parameter of ITrackCancel, which is why you just specify "Nothing" on: pTableSort.Sort Nothing I don't think it should affect your success or not and I am usure of why you are getting the behavior you seem to be experiencing. What version of ArcGIS are you running? Unless I am missing something obvious, I don't necessarily think anything is wrong with your code. Anyway, here is exact code sample from the EDN site: http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriGeoDatabase/ITableSort.htm
... View more
02-22-2011
09:36 AM
|
0
|
0
|
947
|
|
POST
|
I'll do my best to ask my question. I develop a number of COM-based libraries for use within custom arcmap dlls (using ArcGIS 9.3.1 SP2, .NET 2008 C#). These would include a custom arcobjects "helper" library. The issue is how best to deploy and manage these common dlls. The safest way seems to have the setup program create a folder for each application and have it include all of the supporting dlls needed for that application. This has been successful for years but I wonder if this is the best practice for COM-based libraries? On a deployment PC, there would be multiple copies of the custom "helper" library (for example), some with different versions but so far, the same GUID and strong-named. Is it possible (or even advisable) to use a single deployment of common dll? If I can be pointed to an article or white paper or something that talks about this, that would be great too. Thanks. Steve, if I am undertstanding your requirements correctly... FWIW, I have a couple of deployed ArcGIS COM applications that reference several other assemblies that reside on a network shared drive. Honestly, I am uncertain if this is an "advisable" approach, but as long as my users have access to those shared drives on the network, I have had zero issues with multiple users/installs accessing the objects that get created and destroyed in these assemblies. These assemblies are typical middle/end layers in a larger n-Tier architecture. So, for example the presentation tier is representative of the COM assemblies that install on the users machine and run as ArcGIS extensions/toolbars. These assemblies are the presentation portion within the architecture, so typical windows forms and UserControls are what they consist of. the Business and DataAccess layers are more traditional conceptualized portions of a data management application. Anyway -- hope this helps.
... View more
02-22-2011
06:01 AM
|
0
|
0
|
609
|
|
POST
|
As I understand it, Arc 10 will no longer support the use of Crystal reports. I am trying to find out if the arc reports has anything like the flexibility of Crystal. It seems that none of the developers care if we can report. I have several COM applications (written in VB.NET) running in ArcGISv10 that utilize custom CrystalReports objects. I have built the series of reports in their own assembly and the assemblies that run in ArcGIS simply reference these. It all works great and provides a ton of scalability, visually rich reports, and a means to develop and deploy new reports without having to re-deploy the assemblies for ArcGIS. Depending upon the requirements, you can get highly complex yet great performing report generation integrated into your ArcGIS apps by way of using StoredProcedures and the ADO.NET libraries.
... View more
02-22-2011
05:55 AM
|
0
|
0
|
814
|
|
POST
|
Jason, I don't have a direct answer to your question, so sorry, and this is probably not what you'd like to get into --- but wanted to mention that I have had some good success in implementing CrystalReports into my ArcGIS/Map customizations. I realize that CR is a whole other beast to tame, and it can be a big undertaking, but there is a ton of flexibility when utilizing CR because I can mix/mash data coming in from all kinds of sources (typically, I will have a report consisting of selected features and non-spatial SQL Server db's). Essentially it boils down to utilizing ADO.NET DataSets/DataTables and setting up the CR report with these. I've added an item to the Arcscripts/CodeGallery that shows how to convert a FeatureClass into an ADO.NET DataTable -- but would need to be modified to use the selected features: http://resources.arcgis.com/gallery/file/arcobjects-net-api/details?entryID=675318D8-1422-2418-8814-772B0A56383D (If you do use, please leave a comment!) Again, not sure just how much you are willing to dive into this stuff as it can get overwhelming --- especially if you are under a time-crunch. In which case, hopefully someone can point you in the right direction on how to harvest the existing functionality of the native Report generation in ArcGIS.
... View more
01-13-2011
02:50 AM
|
0
|
0
|
551
|
|
POST
|
The solution in that link is pretty much the same thing as the code I posted except they're putting the installer class in its own project. They then add new custom actions to the installer project to call this installer class. I used the same installer class that I had been using just so that I wouldn't have to remove the old custom actions and add new ones (not that it would take any real effort to do so). The big difference between their solution and mine is how the installer class get the path to your assembly. In my code, I'm using the Reflection namespace to get the needed path. It's easy and it works. Their solution is getting the path through a property you have to set inside your installer project. This is what they're doing in the walkthrough when they are setting the CustomActionData property in the custom action properties dialog. If you use this solution, you'll have to change this so that it uses the location of the assembly you want to register. I haven't tried it but you'll probably need to change the value to something like this: /arg1="[TARGETDIR]\yourAssemblyName.dll". This is assuming you're installing the assembly directly to the target directory. Othewise you'll also have to append whatever subdirectory path you're installing to before the assembly filename. I'd rather just use your approach -- I am all about simplicity. Thanks again for your comments, I appreciate it. james
... View more
01-12-2011
09:30 AM
|
0
|
0
|
382
|
|
POST
|
Yes, exclude all of the ESRI references. The code I posted is in C# and I don't have a VB.NET version. This is an untested conversion of the first routine: myBase.OnAfterInstall(savedState);
Dim regAsmPath As String = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles), "ArcGIS\bin\ESRIRegAsm.exe")
Dim appPath As String = System.Reflection.Assembly.GetExecutingAssembly().Location
Dim args As String = """" & appPath & """ /p:Desktop /s"
Dim startInfo As System.Diagnostics.ProcessStartInfo = new System.Diagnostics.ProcessStartInfo()
startInfo.FileName = regAsmPath
startInfo.Arguments = args
System.Diagnostics.Process.Start(startInfo)
Well, I was a bit impatient and attempted to build the Setup package --- I found this, http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_deploy_a_custom_component_using_a_setup_project/00010000016r000000/ Which says to add an entirely NEW assembly/project soley for the purpose of adding the Installer Class file (instead of just having it inside of the target assembly that I want to register/install) -- the code they suggest is about midway down that page: Imports System.ComponentModel
Imports System.Configuration.Install
Public Class Installer1
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
'Add initialization code after the call to InitializeComponent.
End Sub
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
MyBase.Install(stateSaver)
'Register the custom component.
'-----------------------------
'The default location of the ESRIRegAsm utility.
'Note how the whole string is embedded in quotes because of the spaces in the path.
Dim cmd1 As String = """" + Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles) + "\ArcGIS\bin\ESRIRegAsm.exe" + """"
'Obtain the input argument (via the CustomActionData Property) in the setup project.
'An example CustomActionData property that is passed through might be something like:
'/arg1="[ProgramFilesFolder]\[ProductName]\bin\ArcMapClassLibrary_Implements.dll",
'which translates to the following on a default install:
'C:\Program Files\MyGISApp\bin\ArcMapClassLibrary_Implements.dll.
Dim part1 As String = Me.Context.Parameters.Item("arg1")
'Add the appropriate command line switches when invoking the ESRIRegAsm utility.
'In this case: /p:Desktop = means the ArcGIS Desktop product, /s = means a silent install.
Dim part2 As String = " /p:Desktop /s"
'It is important to embed the part1 in quotes in case there are any spaces in the path.
Dim cmd2 As String = """" + part1 + """" + part2
'Call the routing that will execute the ESRIRegAsm utility.
Dim exitCode As Integer = ExecuteCommand(cmd1, cmd2, 10000)
End Sub
Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
MyBase.Uninstall(savedState)
'Unregister the custom component.
'---------------------------------
'The default location of the ESRIRegAsm utility.
'Note how the whole string is embedded in quotes because of the spaces in the path.
Dim cmd1 As String = """" + Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles) + "\ArcGIS\bin\ESRIRegAsm.exe" + """"
'Obtain the input argument (via the CustomActionData Property) in the setup project.
'An example CustomActionData property that is passed through might be something like:
'/arg1="[ProgramFilesFolder]\[ProductName]\bin\ArcMapClassLibrary_Implements.dll",
'which translates to the following on a default install:
'C:\Program Files\MyGISApp\bin\ArcMapClassLibrary_Implements.dll.
Dim part1 As String = Me.Context.Parameters.Item("arg1")
'Add the appropriate command line switches when invoking the ESRIRegAsm utility.
'In this case: /p:Desktop = means the ArcGIS Desktop product, /u = means unregister the Custom Component, /s = means a silent install.
Dim part2 As String = " /p:Desktop /u /s"
'It is important to embed the part1 in quotes in case there are any spaces in the path.
Dim cmd2 As String = """" + part1 + """" + part2
'Call the routing that will execute the ESRIRegAsm utility.
Dim exitCode As Integer = ExecuteCommand(cmd1, cmd2, 10000)
End Sub
Public Shared Function ExecuteCommand(ByVal Command1 As String, ByVal Command2 As String, ByVal Timeout As Integer) As Integer
'Set up a ProcessStartInfo using your path to the executable (Command1) and the command line arguments (Command2).
Dim ProcessInfo As ProcessStartInfo = New ProcessStartInfo(Command1, Command2)
ProcessInfo.CreateNoWindow = True
ProcessInfo.UseShellExecute = False
'Invoke the process.
Dim Process As Process = Process.Start(ProcessInfo)
Process.WaitForExit(Timeout)
'Finish.
Dim ExitCode As Integer = Process.ExitCode
Process.Close()
Return ExitCode
End Function
End Class However, I didn't see how this related to the code you provided. Well, actually, I didn't put much effort into attempting to modify it because I thought this would actually perform the register for me. But it doesn't do as expected --- I ran the Setup.exe on a workstation and everything installed just fine! BUT! It did not register the .dll(s) with ArcGIS/Map -- and I had to select the "add from file" command from the Customize menu. And this actually did add the new toolbar. Anyway -- Thanks for your help and I'll attempt to alter the Installer class with the translated VB.NET code you've provided. Thanks!!!!! james EDIT: I think I will re-try with the entirely different Assembly that contains the new Installer class. I was a bit confused on whether or not I could just use the existing one in my target assembly and just replace/update the code in the Installer class file. Probably something really simple was left out.
... View more
01-12-2011
08:10 AM
|
0
|
0
|
2081
|
|
POST
|
That is correct, the old Install/Uninstall code is no longer needed. I commented out that code and added the code I posted earlier. I used the same Installer class so that I wouldn't have to add new Custom Actions for a new Installer class. Neil, I just finally had an opportunity to get going on this and have re-built and tested my .NET assembly on the dev workstation that has ArcGIS10 installed -- everything is working great! So, now I am on to creating the Setup.exe and just had a quick observation/concern.... After adding the original Setup.exe project the solution (.sln), I noticed 2 new things in the Detected Dependencies list: 1. ESRI.ArcGIS.Search.dll is new and not excluded. Should this be excluded like all of the others (SystemUI, Editor, Geometery, etc)??? 2. Should I just start with a brand new Setup assembly? Also: the code you posted is C#, correct? Is there a VB.NET version? Thanks again for your help on this! Take Care, james
... View more
01-12-2011
04:53 AM
|
0
|
0
|
2081
|
|
POST
|
That is correct, the old Install/Uninstall code is no longer needed. I commented out that code and added the code I posted earlier. I used the same Installer class so that I wouldn't have to add new Custom Actions for a new Installer class. Perfect! I really appreciate your help on this. Take Care, James
... View more
01-04-2011
02:04 PM
|
0
|
0
|
2081
|
|
POST
|
Neil, Thanks for the detailed reply -- very helpful. I am fairly sure about what to do, but just to clarify something.... There is no longer a need to have that Installer Component/Class that contains Uninstall/Install Subs to register/unregister the assembly and instead I should replace those Subs with the esriRegAsm code you posted? Don't mean to be redundant, just wanted to verify I am understanding correctly. Thanks again. james I chose the option to modify the project file to call esriRegAsm.exe instead of using the Add from File option. The project I migrated used a standard Visual Studio Deployment project to create the installer. I removed the code in the Installer class to register my classes with the ESRI component categories. I then added code to call esriRegAsm to perform the category component registration. This is the code I added to the OnAfterInstall event in the installer class: protected override void OnAfterInstall(IDictionary savedState)
{
base.OnAfterInstall(savedState);
string regAsmPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles), "ArcGIS\\bin\\ESRIRegAsm.exe");
string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
string args = "\"" + appPath + "\" /p:Desktop /s";
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = regAsmPath;
startInfo.Arguments = args;
System.Diagnostics.Process.Start(startInfo);
} This is the code I added to the OnBeforeUninstall event: protected override void OnBeforeUninstall(IDictionary savedState)
{
base.OnBeforeUninstall(savedState);
string regAsmPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles), "ArcGIS\\bin\\ESRIRegAsm.exe");
string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
string args = "\"" + appPath + "\" /p:Desktop /u /s";
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = regAsmPath;
startInfo.Arguments = args;
System.Diagnostics.Process.Start(startInfo);
}
... View more
01-04-2011
11:45 AM
|
0
|
0
|
2081
|
|
POST
|
Ok, I am having diffiuclty locating an answer on this and hope someone could help. I have several applications that I maintain/support across an organizations IT infrastructure, all are developed with .NET Framewrok 3.5 SP1 and are all ICommand/ITooblar interfaces that run in ArcGIS Desktop 9.3/9.3.1 versions. Will these need modification to be installed with ArcGIS Desktop 10? 1. Will I need to bind these components to ArcGIS? For ex, will I need to include: 'Insert this line before invoking any ArcObjects to bind Engine runtime.
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop) 2. Will my existing Setup.exe packages still function? Do they need modification? Thanks for any input. james
... View more
01-03-2011
08:35 AM
|
0
|
12
|
4170
|
|
POST
|
Here's an idea to make certain layer names in the TOC are unique and correspond to the items found in your ComboBox. Honestly, I don't see a "good" scenario where I would allow the user to have duplicate layer names loaded, even though they are the same Dataset.Name from the datasource. If this isn't a good solution, perhaps you could utilize some of it to fit your needs. This could be added to the Load event of the Form: Dim theListOfLayers As List(Of String) = GetLayerList()
pDoc = m_pApp.Document
pMap = pDoc.FocusMap
For l = 0 To pMap.LayerCount - 1
For x = 0 To theListOfLayers.Count - 1
Dim indxOrig As Integer = theListOfLayers.IndexOf(theListOfLayers(x).Trim)
Dim indx As Integer = theListOfLayers.LastIndexOf(theListOfLayers(x).Trim)
If indxOrig <> indx Then
pMap.Layer(l).Name = theListOfLayers(x).Trim & "2"
theListOfLayers(x) = theListOfLayers(x).Trim & "2"
End If
Next
Exit For
Next
'update the TOC
pDoc.UpdateContents()
'add the list of layernames to the ComboBox
cboLayerList.DataSource = theListOfLayers Add this private function to the form to build the List(Of String) of Layer names loaded in the TOC: Private Function GetLayerList() As List(Of String)
Dim LayerList As New List(Of String)
Dim pDoc As ESRI.ArcGIS.ArcMapUI.IMxDocument
Dim pMap As ESRI.ArcGIS.Carto.IMap
pDoc = m_pApp.Document
pMap = pDoc.FocusMap
For i = 0 To pMap.LayerCount - 1
LayerList.Add(pMap.Layer(i).Name)
Next
Return LayerList
End Function
... View more
12-08-2010
07:16 AM
|
0
|
0
|
932
|
|
POST
|
You could add your values to a List(Of T), sort that, then set your ComboBox's Datasource to this list. Dim cboValueList As New List(Of String)
Set featCursor = featClass.Search(Nothing, False)
Set pFeature = featCursor.NextFeature
Do While Not pFeature Is Nothing
cboValueList.Add(UCase$(pFeature.Value(pFeature.fields.FindField(cb oField.Text))))
Set pFeature = featCursor.NextFeature
Loop
cboValueList.Sort()
ComboBox1.DataSource = cboValueList
... View more
12-05-2010
05:50 AM
|
0
|
0
|
675
|
|
POST
|
Follow up with some code. Here is a function I have in a DataAccessLayer(DAL) Class for one of my solutions/implementations that integrates a non-spatial SQLServer2005 database that is basically acting as complex attribtutes for a parcel layer. This particular function is updating that non-spatial SQLServer database (which again is related to parcels by way of the "GISPID" or "PID" fields). What you'll see here is that I am passing in a DataTable "inDT" which is then used in the DataAdapter.Update(inDT) method. What is important to note is that the SELECT Command of the DataAdapter produces what is found in the DataTable being passed in. You'll also see that I have manually setup the INSERT/UPDATE/SELECT/DELETE Commands because I am utilizing StoredProcedures I have written specifically for each of those Commands. The ADO.NET DataSet/DataTable keeps track of any modifications you make to it, so if you are doing updates/deletes on the DataTable the .Update on the DataAdapter will handle updating the database. Anyway, this is for SQLServer I know, but shouldn't be that much different for Oracle and you'll just need to setup your DataAdapter a bit differently (as I've already posted above). The main reason why all of this might be faster doing the updating is because of as agray1 mentioned: no need to Start/Stop and Edit Session. Again this all hinges on simply updating attributes and not the features themselves though! Good Luck, hope this helps. Public Function UpdateIgnoreRecs(ByVal inDT As DataTable) As DataTable
Dim Selcmd As SqlCommand = New SqlCommand()
Selcmd.CommandText = "Storms_Excps_IgnoreRec_Get"
Selcmd.CommandType = CommandType.StoredProcedure
'setup INSERT Command for DataAdapter
Dim ins_Cmd As SqlCommand = New SqlCommand()
ins_Cmd.CommandText = "sido.Storms_Excps_InsertIgnoreRec"
ins_Cmd.CommandType = CommandType.StoredProcedure
ins_Cmd.Parameters.Add("@ParcelID", SqlDbType.NVarChar, 15, "ParcelID")
ins_Cmd.Parameters.Add("@ExcpType", SqlDbType.NVarChar, 50, "ExcpType")
ins_Cmd.Connection = Me.sqlCn
Dim paramPkIDupd As New SqlParameter()
paramPkIDupd.ParameterName = "@PkID"
paramPkIDupd.SqlDbType = SqlDbType.Int
paramPkIDupd.Direction = ParameterDirection.Input
paramPkIDupd.SourceColumn = "PkID"
paramPkIDupd.SourceVersion = DataRowVersion.Original
'setup UPDATE Command for DataAdapter
Dim upd_Cmd As SqlCommand = New SqlCommand()
upd_Cmd.CommandText = "sido.Storms_Excps_UpdateIgnoreRec"
upd_Cmd.CommandType = CommandType.StoredProcedure
upd_Cmd.Parameters.Add("@ParcelID", SqlDbType.NVarChar, 15, "ParcelID")
upd_Cmd.Parameters.Add("@ExcpType", SqlDbType.NVarChar, 50, "ExcpType")
upd_Cmd.Parameters.Add(paramPkIDupd)
upd_Cmd.Connection = Me.sqlCn
paramPkIDupd = New SqlParameter()
paramPkIDupd.ParameterName = "@PkID"
paramPkIDupd.SqlDbType = SqlDbType.Int
paramPkIDupd.Direction = ParameterDirection.Input
paramPkIDupd.SourceColumn = "PkID"
paramPkIDupd.SourceVersion = DataRowVersion.Original
'setup DELETE Command
Dim del_Cmd As SqlCommand = New SqlCommand()
del_Cmd.CommandText = "sido.Storms_Excps_DeleteIgnoreRec"
del_Cmd.CommandType = CommandType.StoredProcedure
del_Cmd.Parameters.Add("@ParcelID", SqlDbType.NVarChar, 15, "ParcelID")
del_Cmd.Parameters.Add("@ExcpType", SqlDbType.NVarChar, 50, "ExcpType")
del_Cmd.Parameters.Add(paramPkIDupd)
del_Cmd.Connection = Me.sqlCn
Dim ds As New DataSet()
Dim da As New SqlDataAdapter
da.SelectCommand = Selcmd
da.UpdateCommand = upd_Cmd
da.InsertCommand = ins_Cmd
da.DeleteCommand = del_Cmd
Try
Using Selcmd
Selcmd.Connection = Me.sqlCn
da.Fill(ds)
End Using
Dim rct As Integer = CInt(ds.Tables(0).Rows.Count)
da.Update(inDT)
rct = CInt(ds.Tables(0).Rows.Count)
Me.CloseConnection()
da.Dispose()
connSvc.Dispose()
Return ds.Tables(0)
Catch ex As Exception
MsgBox(ex.ToString)
connSvc.Dispose()
Return Nothing
End Try
End Function
... View more
11-16-2010
10:24 AM
|
0
|
0
|
1072
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-17-2020 10:47 AM | |
| 1 | 10-25-2022 11:46 AM | |
| 1 | 08-08-2022 01:40 PM | |
| 1 | 02-15-2019 08:21 AM | |
| 2 | 08-14-2023 07:14 AM |
| Online Status |
Offline
|
| Date Last Visited |
01-22-2025
02:28 PM
|