This post was moved to my real blog: VS2010: “The project type is not supported by this installation.”
This blog is a placeholder for my real blog notes (used to share my drafts).
Please visit Dll Shepherd.Net
Please don't reference any of this posts because they might be moved or deleted!
Thursday, November 8, 2012
Monday, May 14, 2012
Silverlight: Binding Resource to DataGridTextColumn.Header
In the last two days, since it’s the end of our block I have decided to do some minor work (that way a check in won’t really effect the block). One of the changes I thought of was replacing all the free text in our Silverlight application with text from a resource file.
Everything worked like a charm except for the Header of DataGridTextColumn. My original Data Binding looked like this:
- <slData:DataGridTextColumn Header="{Binding Path=Type, Source={StaticResource StringsRes}}" Binding="{Binding Title}"/>
But the DataGrid columns in the application looked like this:
In the end I found the solution here:
- <slData:DataGridTextColumn Binding="{Binding TypeString}" >
- <sdk:DataGridTextColumn.HeaderStyle>
- <Style TargetType="primitives:DataGridColumnHeader" >
- <Setter Property="ContentTemplate">
- <Setter.Value>
- <DataTemplate>
- <TextBlock Text="{Binding Path=Type, Source={StaticResource StringsRes}}"/>
- </DataTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </sdk:DataGridTextColumn.HeaderStyle>
- </slData:DataGridTextColumn>
Though I am still searching for a generic solution and not something I have to copy paste for each DataGrid Column…
//TODO: Check if this was fixed in SL5. If so post the elegant solution
Wednesday, May 9, 2012
A day without the Debugger
This post was moved to my real blog: A day without the Debugger
Tuesday, May 1, 2012
Polyline wrong coordinates
We have been developing for a long time on a single oracle DB Server (Development stage) and recently added a new integration server. Because of time constraints we decided to just copy the data from the Dev server using SQL (out DBA did that part), and since we moved to SDO_GEOMETRY the data can be transferred without the use of ArcDesktop utilities.
So the data was moved correctly and the registration went without a glitch. But when we tried to create a new line in the layer its coordinates moved from (35.5, 32.7) (in x,y) to (–324.4, 32.7). The first thing I checked was my code but there were no changes done and in the old environment everything worked fine.
Looking at the Layers table in the SDE schema that table looked like:
EFLAGS | LAYER_MASK | GSIZE1 | GSIZE2 | GSIZE3 | MINX | MINY | MAXX | MAXY | LAYER_CONFIG |
138674317 | 128 | -2 | 0 | 0 | -400 | -400 | 471.3916 | 471.3916 | SDO_GEOMETRY |
My first thought was that the –400 somehow affected the data being inserted but the same values were in the old DB and they worked.
After many actions of unregister and register of that layer the problem was solved.
TODO: Add table border, it looks bad in the site
Tuesday, March 6, 2012
Notes: Order of posts to complete – 6/3/2012
As I said before this is not my real blog just a place holder for the drafts for my real blog. Subscribers should note that the blog posts are being updated on the fly, so use a feed reader that can handle this (Google Reader will not mark the post differently for updated posts).
I am sure some of you are wondering why I don’t post some of the more complete posts and for those posts I simply would like to post them in a certain order. It’s like writing a story I can’t really post on FluentMigrator before I write about the SDE or ArcObjects (since extending FluentMigrator is all about using ArcObjects to deploy the SDE).
Since at this point in time I have 55 draft posts I decided to add categories to the posts:
- ????? – haven’t reviewed the post
- Title Draft – only has a title and lots of TODOs
- Draft – has some text but the text is rough
- Beta – almost ready: spelling, ordering, checking the grammar…
- Post In Wait – waiting for another post before posting
I have also decided to post the exceptions/error solving posts without waiting for background posts (if they are ready). Since they are mostly posts I am not going to edit.
I have decided to write here the order of the Notes’ drafts I am going to work on:
- Unit Tests: What to Test? - Draft: code, go over all the cases, add my Resharper template, TODOs
- Unit Test Code Coverage – Title Draft: even the TODOs are rough…
- To Rhino or not to Rhino? – Draft: code, font, the explanations are too short
- Tracking down a simple bug - Draft: code, font, draw the examples
- TODO: ArcObjects: WorkspaceUtils
- File GeoDatabase: Getting the Workspace – Draft: might need to split to 2 posts
- Multithreading with ArcObjects – Draft: font, code, TODOs
- Refactoring ESRI: Making the Examples Readable, Part 1 – Draft: continue the example, maybe remove the first refactor result ( just keep the number of lines), to many text strings in the end code – move to consts
- Mocking ESRI (testing wise) – Title Draft: even the TODOs are rough… Though the title is just right!
- TODO: SQL
- TODO: SQL Server
- ArcSDE–Connection to the Geodatabase – Draft: write how to get the service number, images in old style, remove del tags
- TODO: ArcSDE: Different DB types
- SDE – A look at the layer table structure – Draft: images, font, write about deleting features and triggers
- Reading SDE queries – Draft: images, font, weird characters, SQL, del tags, grammer
- Deleting SDE left over tables – Draft: images, font, SQL, rewrite query
- TODO: WorkspaceProvider
- TODO: WorkspaceUtils
- Working with CAD files in ArcObjects – Draft: code, links, font
- Upgrading the code base from ArcGIS 9.3.1 to 10 – Beta: images, code, del tags
- Rename Polyline layer – Beta: code, font
- ArcSDE–Adding domains from code – Beta: refactor the code
- Simplify and the ArcEngine license – Draft: code, font, images, name should be different
- ESRI License error – Draft: code, font, images, name should be different
- TODO: ArcGIS Server Introduction
- TODO: ArcGIS Server Publish mxd
- ArcGIS Server layer problem (DB is down) – Beta: font, images, post clearing cache first, del tags ***
- Restart ArcGIS Server service – Beta: font, images, del tags ***
- Calling ArcGIS Server service model - Beta: font, images, del tags ***
- Address Locator Style: Introduction – Draft: finish a working style before posting this
- Address Locator Style: Customizing Guide – Draft: finish a working style before posting this
- Address Locator Style: Testing – Draft: finish a working style before posting this
- FluentMigrator: Understanding the Framework Code – Draft: TODOs
- FluentMigrator: Extending the Framework – Draft: not finished
- ArcSDE/SQL Server Tables–What is Sde’s and what is Regular – Beta: SQL query, del tags, post after FM
- Stuck Database – the JOY! – Beta: font, images, maybe add a conclusion, post after intro to FM
- VS2010: “The project type is not supported by this... – Beta: cut the post (won’t continue to work on it), images, font ***
- Silverlight Memory Leak, Part 3 – ?????
- Silverlight Memory Leak, Part 4 – ?????
I have some more posts to which I haven’t decided the order:
- Coded UI testing for Silverlight application – Draft: really rough, font, images
- Silverlight ESRI App - IIS is dead–Error 5011 – Draft: TODOs, wrong date, del tags
- IntelliTrace: – Draft: still rough
- TODO: Using DotTrace
- Silverlight error connecting to WCF – ?????
- Rebuild All failed without any errors (Silverlight), Part 2 – ?????
- TODO: Probability, Why do I need it?
- Linq2Sql: Changing the Database Schema at Runtime (without XMLs) – Draft: still waiting for a solution
- Silverlight: Adding Google Streets View, part 2 – ?????
- LINQ and WCF – ?????
- Game Programming with XNA – ????
- HTTP Error 503. The service is unavailable. – ?????
- Combining WMV Videos – ????
Posts that I might not post:
- Writing a Windows Live Writer Plugin – Draft: didn’t write one…, images, del tags, ice tags
- Windows Live Writer: Tag providers, Part 2 – need to go over all the tag providers and need to get a response from some of them so it might take some time, Technorati is still giving me hard times.
- Offline Blog Writing Applications - Draft
- The Library example – Haven’t decided on posting this or not might change it to sheep and shepherds…
- Python – Introduction – Draft: just not written well
- Silverlight 4 – more for me…
I think that’s enough for now…
Refactoring ESRI: Making the Examples Readable, Part 1
This is the refactor for ESRI example for creating an Address Locator in a Personal GeoDatabase:
- public void AddressLocatorPersonalGDBViaArcObjects()
- {
- // Open the default local locator workspace to get the locator style.
- System.Object obj = Activator.CreateInstance(Type.GetTypeFromProgID(
- "esriLocation.LocatorManager"));
- ILocatorManager2 locatorManager2 = obj as ILocatorManager2;
- ILocatorWorkspace locatorWorkspace = locatorManager2.GetLocatorWorkspaceFromPath
- ("");
- // Get the locator style to base the new locator.
- ILocatorStyle locatorStyle = locatorWorkspace.GetLocatorStyle(
- "US Address - Dual Ranges");
- // Open the feature class to use as reference data.
- IWorkspaceFactory2 workspaceFactory2 = new AccessWorkspaceFactoryClass();
- IWorkspace workspace = workspaceFactory2.OpenFromFile(
- @"D:\workspace\arcobjects\location\redlands.mdb",
- 0);
- IFeatureWorkspace featureWorkspace = (IFeatureWorkspace) workspace;
- IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("Streets");
- // Set the feature class as the primary reference data table for the locator.
- IDataset dataset = (IDataset) featureClass;
- IReferenceDataTables referenceDataTables = (IReferenceDataTables) locatorStyle;
- IEnumReferenceDataTable enumReferenceDataTable = referenceDataTables.Tables;
- enumReferenceDataTable.Reset();
- IReferenceDataTable referenceDataTable = enumReferenceDataTable.Next();
- IReferenceDataTableEdit referenceDataTableEdit = (IReferenceDataTableEdit)
- referenceDataTable;
- IName name = dataset.FullName;
- referenceDataTableEdit.Name_2 = (ITableName) name;
- // Store the new locator in the same workspace as the reference data.
- if (referenceDataTables.HasEnoughInfo)
- {
- locatorWorkspace = locatorManager2.GetLocatorWorkspaceFromPath(
- @"D:\workspace\arcobjects\location\redlands.mdb");
- ILocator locator = locatorWorkspace.AddLocator("New Redlands Locator",
- (ILocator) locatorStyle, "", null);
- }
- }
The first order of business is refactoring this method.
The first thing to go was this:
- IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("Streets");
- // Set the feature class as the primary reference data table for the locator.
- IDataset dataset = (IDataset) featureClass;
To:
- IDataset dataset = (IDataset)featureWorkspace.OpenFeatureClass("Streets");
There was a few other things like: referenceDataTable->referenceDataTableEdit,
The end result was:
- public void AddressLocatorPersonalGDBViaArcObjects()
- {
- // Open the default local locator workspace to get the locator style.
- System.Object obj = Activator.CreateInstance(Type.GetTypeFromProgID(
- "esriLocation.LocatorManager"));
- var locatorManager2 = obj as ILocatorManager2;
- var locatorWorkspace = locatorManager2.GetLocatorWorkspaceFromPath
- ("");
- // Get the locator style to base the new locator.
- var locatorStyle = locatorWorkspace.GetLocatorStyle(
- "US Address - Dual Ranges");
- // Open the feature class to use as reference data.
- IWorkspaceFactory2 workspaceFactory2 = new AccessWorkspaceFactoryClass();
- var featureWorkspace = (IFeatureWorkspace)workspaceFactory2.OpenFromFile(
- @"D:\workspace\arcobjects\location\redlands.mdb",
- 0);
- // Set the feature class as the primary reference data table for the locator.
- var dataset = (IDataset)featureWorkspace.OpenFeatureClass("Streets");
- var referenceDataTables = (IReferenceDataTables)locatorStyle;
- var enumReferenceDataTable = referenceDataTables.Tables;
- enumReferenceDataTable.Reset();
- var referenceDataTableEdit = (IReferenceDataTableEdit) enumReferenceDataTable.Next();
- referenceDataTableEdit.Name_2 = (ITableName)dataset.FullName;
- // Store the new locator in the same workspace as the reference data.
- if (referenceDataTables.HasEnoughInfo)
- {
- locatorWorkspace = locatorManager2.GetLocatorWorkspaceFromPath(
- @"D:\workspace\arcobjects\location\redlands.mdb");
- locatorWorkspace.AddLocator("New Redlands Locator",
- (ILocator) locatorStyle, "", null);
- }
- }
39 lines without any loss of readability, not that it says much – it still not readable!
The next thing to look at is creating the ILocatorManager2, I don’t know about you but I prefer getting an exception about converting than about Null reference:
- (ILocatorManager2)Activator.CreateInstance(Type.GetTypeFromProgID("esriLocation.LocatorManager"));
(that also solved the problem of the ‘obj’ variable naming)
The next part is creating a Utils class for LocatorWorkspace:
- public class LocatorWorkspaceUtils
- {
- private readonly ILocatorManager2 _locatorManager;
- #region Singleton
- private static readonly LocatorWorkspaceUtils instance = new LocatorWorkspaceUtils();
- // Explicit static constructor to tell C# compiler
- // not to mark type as beforefieldinit
- static LocatorWorkspaceUtils()
- {
- }
- private LocatorWorkspaceUtils()
- {
- _locatorManager =
- (ILocatorManager2)Activator.CreateInstance(Type.GetTypeFromProgID("esriLocation.LocatorManager"));
- }
- public static LocatorWorkspaceUtils Instance
- {
- get { return instance; }
- }
- #endregion
It’s singleton with ILocatorManager already set, now the only thing we use it for is:
- private ILocatorWorkspace GetLocatorWorkspace(string fileLocation)
- {
- return _locatorManager.GetLocatorWorkspaceFromPath(fileLocation);
- }
Getting the style:
- public ILocatorStyle GetLocatorStyle(string styleName)
- {
- return GetLocatorStyle(styleName, "");
- }
- public ILocatorStyle GetLocatorStyle(string styleName, string fileLocation)
- {
- var locatorWorkspace = GetLocatorWorkspace(fileLocation);
- // Get the locator style to base the new locator.
- return locatorWorkspace.GetLocatorStyle(styleName);
- }
Adding the locator style:
- public void AddLocatorStyle(string styleName, string fileLocation, ILocator locatorStyle)
- {
- var locatorWorkspace = GetLocatorWorkspace(fileLocation);
- locatorWorkspace.AddLocator(styleName, locatorStyle, "", null);
- }
Setting the dataset name in the locator:
- public void SetLocatorDatasetName(IName datasetName, ILocatorStyle locatorStyle)
- {
- var referenceDataTables = (IReferenceDataTables)locatorStyle;
- var enumReferenceDataTable = referenceDataTables.Tables;
- enumReferenceDataTable.Reset();
- var referenceDataTableEdit = (IReferenceDataTableEdit)enumReferenceDataTable.Next();
- //var name = new TableNameClass {Name = datasetName};
- referenceDataTableEdit.Name_2 = (ITableName)datasetName;
- }
Checking if the locator is good to be saved:
- public bool IsLocatorValidForSave(ILocatorStyle locatorStyle)
- {
- return ((IReferenceDataTables)locatorStyle).HasEnoughInfo;
- }
Now the code looks like:
- public void AddressLocatorPersonalGDBViaArcObjects()
- {
- // Get the locator style to base the new locator.
- var locatorStyle = LocatorWorkspaceUtils.Instance.GetLocatorStyle("US Address - Dual Ranges");
- // Open the feature class to use as reference data.
- IWorkspaceFactory2 workspaceFactory2 = new AccessWorkspaceFactoryClass();
- var featureWorkspace = (IFeatureWorkspace)workspaceFactory2.OpenFromFile(
- @"D:\workspace\arcobjects\location\redlands.mdb",
- 0);
- // Set the feature class as the primary reference data table for the locator.
- var dataset = (IDataset)featureWorkspace.OpenFeatureClass("Streets");
- LocatorWorkspaceUtils.Instance.SetLocatorDatasetName(dataset.FullName, locatorStyle);
- if (LocatorWorkspaceUtils.Instance.IsLocatorValidForSave(locatorStyle))
- {
- LocatorWorkspaceUtils.Instance.AddLocatorStyle("New Redlands Locator",
- @"D:\workspace\arcobjects\location\redlands.mdb",
- (ILocator)locatorStyle);
- }
- }
Now something seems a bit off here, the only reason we open the workspace for the MDB file is to get the dataset FullName, WTF?!? Why not just pass the name as a… wait for it… string?
TODO: continue this
Keywords: ESRI, ArcObjects, refactor
Bug: Using TimeStamp with Time Zone in (Oracle) Entity Framework
For the past week I have been working on the problem of correctly saving TimeStamp with Time Zone in (Oracle) Entity Framework. The problem is both DateTime and OffsetDateTime when saved in that field in the DB are missing a critical info – the location offset given to them. They always save the field with the offset of the client, in my case +02:00.
In the beginning I was sure it was something that will be easily fixed, simply because I came through this StackOverFlow question/answer which talked about changing the numeric data type so that bool is number(1,0). So I was sure it was a generic interface, well its not!
Looking into Oracle’s EFOracleProviderServices decompiled source (using JetBrains’s dotPeek) I tried looking for config values but instead found the bug in Oracle:
- new OracleParameter(name, (object) ((DateTimeOffset) value).DateTime))
Meaning that although you might have gone into the trouble of creating a DateTimeOffset (with no trouble at all), Oracle just knows what’s best and will convert it to DateTime (plus enable a boolean that will later convert it back to offset).
I have tried using Open Source Providers but so far no luck (had problem finding the provider or it wasn’t in .net 4.0), I will try again tomorrow.
http://eforacleodpprovider.codeplex.com
http://archive.msdn.microsoft.com/EFOracleProvider/Release/ProjectReleases.aspx?ReleaseId=1395
//TODO: Continue this
Resources:
StackOverFlow: Where do I put Oracle EntityFramework Mapping settings for LinqPad?
Sunday, March 4, 2012
Selecting Distinct Rows
This post was moved to my real blog: Selecting Distinct Rows
Saturday, March 3, 2012
SQL Server 2008–Forget a user/password
Tuesday, February 14, 2012
Oracle arcSde view small integer bug
I am writing this here just as a reminder.
ArcSde with Oracle (11g maybe all) has a bug where when you create a Feature layer with a small integer column and then create a view out of that table, the view will now have the column as integer.
I have not found a solution for this, except rewriting the code…
You can see it in ArcGis Server:
For SQL Server 2008 table: Type: esriFieldTypeSmallInteger
For Oracle 11g view: Type: esriFieldTypeInteger