January 25, 2012

Like father like daughter–AKA Alienware is purrty

Filed under: General — Tags: , — Darrin Maidlow @ 8:33 pm

My six month old daughter LOVES my notebook…

SAM_1389

 

 

 

 

 

Maybe when she grows up, she’ll be a nerd and work with her dad – like I grew up to work with mine…

SAM_1391

Technorati Tags:

January 15, 2012

SWTOR Hack–Re-install without the 20GB+ Download

Filed under: Gaming — Tags: — Darrin Maidlow @ 1:24 am

I’ve been having  a lot problem with my notebook since a bit before Christmas.  I’ve had to re-install Windows like 3 times now (and yes I was using RAID and had backups…long store).  Anyhow, the first couple of times I went through the 20GB+ download for Star Wars The Old Republic and my internet out here is not great.  The entire download process takes 12+ hours.  Tonight I was determined to find a better way…

Well I found it.  What you need to do is make a copy of the C:\Program Files (x86)\Electronic Arts\BioWare\Star Wars – The Old Republic folder.  Put it somewhere safe.  Also save a copy of the 37MB installer for SWTOR.   On your fresh Windows install run the SWTOR installer.   This will create all the needed folders and registry keys.  Finally copy the SWTOR program files folder from your backup overtop of the fresh install and you’re all set.  Fire up SWTOR and you didn’t have to download the monstrous pig of a download.  So glad I won’t have to be doing that download anymore!

Technorati Tags:

January 13, 2012

Using Log4Net with Visual Lisp

Filed under: AutoCAD,Development — Tags: , , , — Darrin Maidlow @ 1:07 pm

If you’ve worked with me or talked technical with me in the past there is a good chance you area already very aware that I love .  There is also a really good chance that you know I still have a special place in my heart for .  Not only did I spend what may have been the “best years of my life” buried in VLIDE (or hey, maybe all those 30+ hour days and passing out under my desk were the best years of my life? =)) , I still firmly believe that Lisp is one of the most effective way to bang out even a relatively complex operation in AutoCAD when it comes to data manipulation.  ObjectARX (both original and .NET) is great – but the time and effort overhead is pretty high when you just need to bang out a quick routine.

<3 Visual Lisp

Even the quick routines need a little error handling and logging can make a huge difference in documenting the results or diagnosing problems.  Yes, Visual Lisp comes with file I/O calls and I’m sure most of you reading this have rolled your own logging code.  We had some at Kanotech that is still in use for DraftLogic.  Not for long though :=)  Today I’m here to show you how you could bring your Visual Lisp logging into the 21st century.  Not only will it give you – it will let even complex systems that mix technologies (ie. Visual Lisp, ObjectARX .NET) to bring the logging together into a common set of log files.

Overview

There are two sides to this.  First, in .NET we setup Log4Net and expose it to Visual Lisp.  Over on the Lisp side, we’ll load the vlx, setup an error handler, and issue some logging calls.  As usual I’ve attached a Visual Studio solution with sample code.  I’ve also included a compiled dll that you can just go ahead and use.  The attached project is built using .NET 3.5 as this machine only has AutoCAD 2010 installed.  Log4Net itself is built targeting .NET 1.0 so you can modify the .NET runtimes and ObjectARX references used in the attached project and use this code for pretty much any .NET enabled version of AutoCAD/ObjectARX.

In .NET – Setup Log4Net and Lisp Bindings

The Lisp bindings are pretty straight forward.  Expose your call(s) to AutoCAD as a LispFunction.  I’ve built two exposed calls.  One takes two parameters, and uses the value of the first parameter to determine the log type.  The second parameter is the message to log.  The second call is a LogError call that could be used to just log error type messages.  This call could be duplicated for each type of logging state if desired.

 
   1: /// <summary>
   2: /// Lisp exported Log call.  Expects two parameters in lisp.  First the log type which may be either INFO, WARNING, DEBUG, or ERROR.  The second is a string containing the error / message.
   3: /// </summary>
   4: /// <param name="lispArgs"></param>
   5: /// <returns></returns>
   6: /// <remarks>Lisp syntax (Loggit </remarks>
   7: [LispFunction("Loggit")]
   8: public TypedValue Log(ResultBuffer lispArgs)
   9: {
  10:     //Check that we have the correct number of parameters
  11:     Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
  12:     if (lispArgs == null)
  13:     {
  14:         ed.WriteMessage("\nLoggit - Incorrect number of arguments.  Expected 2 parameters, received none\n");
  15:         return new TypedValue((int)LispDataType.Nil);
  16:     }
  17:     if (lispArgs.AsArray().Length != 2)
  18:     {
  19:         ed.WriteMessage("\nLoggit - Incorrect number of arguments.  Exepected 2 parameters, received " + Convert.ToString(lispArgs.AsArray().Length));
  20:         return new TypedValue((int)LispDataType.Nil);
  21:     }
  22:     
  23:     //params are good.  We expect two strings so rather than test type just convert to string
  24:     String logType = Convert.ToString(lispArgs.AsArray()[0].Value).ToUpper();
  25:     String logMessage = Convert.ToString(lispArgs.AsArray()[1].Value);
  26:  
  27:     switch(logType)
  28:     {
  29:         case "INFO":
  30:             Logger.Current.Info(logMessage);
  31:             break;
  32:         case "WARNING":
  33:         Logger.Current.Warning(logMessage);
  34:             break;
  35:         case "DEBUG":
  36:         Logger.Current.Debug(logMessage);
  37:             break;
  38:         case "ERROR":
  39:             Logger.Current.Error(logMessage);
  40:             break;
  41:     }
  42:     return new TypedValue((int)LispDataType.T_atom);
  43: }
  44:  
  45: //Alternately you could expose individual calls like LogError here.
  46:  
  47: /// <summary>
  48: /// Exposed Lisp function that logs an error directly. Expects a single lisp parameter of type string which is the message to log.
  49: /// </summary>
  50: /// <param name="lispArgs"></param>
  51: /// <returns></returns>
  52: [LispFunction("LogError")]
  53: public TypedValue LogError(ResultBuffer lispArgs)
  54: {
  55:     //Check that we have the correct number of parameters
  56:     Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
  57:     if (lispArgs == null)
  58:     {
  59:         ed.WriteMessage("\nLoggit - Incorrect number of arguments.  Expected 2 parameters, received none\n");
  60:         return new TypedValue((int)LispDataType.Nil);
  61:     }
  62:  
  63:     String logMessage = Convert.ToString(lispArgs.AsArray()[0].Value);
  64:     Logger.Current.Error(logMessage);
  65:  
  66:     return new TypedValue((int)LispDataType.T_atom);
  67: }

 

One awesome little bit of magic exists in the Logger.cs class.  When configuring the logger it loads the assemblies in question using System.Reflection.  Then it checks in the folder of each loaded dll for the log4net.config file.  This means that logging will only actually log if you have a log4net.config file exists in the same folder as the loaded ObjectARX.NET assembly.  With AutoCAD based extensions this is especially important.  I’ve never liked placing my assemblies (vlx, arx, dll) in the AutoCAD folders.  I’ve always been a huge proponent of extending the AutoCAD search path if needed and using my own directory structures.  This configuration searching technique also eliminates the need for hard coded “here is my log config file” stored in the registry or some other config location. 

Compile that dll and you should be able to run with that in Visual Lisp.

Configure the Logging

As mentioned previously we need to create the configuration file to place with our dll.  There are a couple of lines of code that are quite relevant to get the logging working.  First we have a hard coded configuration file name defined in Logger.cs.  You can customize this if you want.

   1: /// <summary>
   2: /// Name of the file name to search for when trying to configure logging.
   3: /// </summary>
   4: public const string ConfigFileName = "log4net.config";

Next is the name of the logger.  This is quite relevant when configuring your logging.  If this value does not match the value in the config file you will be very frustrated trying to get the logging to fire! If desired change the VisualLisp value to whatever you would like.

   1: /// <summary>
   2: /// This logger name is referenced in the log4net configuration
   3: /// </summary>
   4: private ILog _logImplementation = LogManager.GetLogger("VisualLisp");

Next we have a little bit of XML to slough through.

   1: <?xml version="1.0" encoding="UTF-8"?>
   2: <log4net xmlns="urn:log">
   3:   <appender name="GeneralLog" type="log4net.Appender.FileAppender">
   4:     <file value="VisualLisp.log" />
   5:     <appendToFile value="true" />
   6:     <layout type="log4net.Layout.PatternLayout">
   7:         <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
   8:     </layout>
   9: </appender>
  10:   <logger name="VisualLisp">
  11:     <level value="ALL" />
  12:     <appender-ref ref="GeneralLog" />
  13:   </logger>
  14: </log4net>

This is where things can get crazy!  First the appender section.  This is where you define all the different settings for the actual logging.  I’m running with a standard log file appender, but there are so many choices.  Log to file, log to rolling file, log to database, log to e-mail, log to eventlog, log to almost whatever you want.  You can even write your own custom appenders to log to your toaster oven if you really wanted to.  This is one of the many reasons I <3 Log4Net soooo much.   The basics here are straight forward.  Set the file value=”” to the name and optionally path (either full or relative).  One important note., if you do not specify a full path or you use a relative path the logfile the base point used will be the AutoCAD program files folder.   If you are not running with administrative rights the Vista/Windows 7 file system virtualization will kick in and the log file location will be quite confusing.  It’s probably a good idea to specify a full path here.  More details on some Log4Net configurations can be found on the .

Next take a look at the logger element.  You can define multiple loggers, and each can log to multiple appenders.  Or a single logger can log to multiple appenders.   Note the important value of “Visual Lisp”.  This must match the GetLogger value defined in the private ILog above.  You can also specify which “level” of notice to log.  Though our code may log INFO, WARNING, DEBUG and ERROR calls – if your level is set to ERROR – only the actual error level messages will be logged.

In Visual Lisp – Setup an Error Handler and Issue Logging

So now we have an ObjectARX.NET assembly to load.  We have a handle on configuring our logging.  Here is the contents of the included Lisp file.

   1: ;only load the assembly if it has not been loaded once
   2: (if (not (car (atoms-family 1 '("loggit"))))
   3:     (command "netload" "C:/Users/dmaidlow/Documents/Visual Studio 2010/Projects/Log4Net.VisualLisp/bin/debug/Log4Net.VisualLisp.dll")
   4: )
   5:  
   6: (defun new_ErrorHandler (err)
   7:     (if (or (= (substr err 1 4) "quit")
   8:             (= err "Function cancelled")
   9:         )
  10:         (progn
  11:             ;put any function cancelled logic here
  12:             (princ)
  13:         )
  14:         (progn
  15:             ;an actual error happened here..
  16:             ;you could spew some stuff out to the console, or issue an alert..
  17:             ;(prompt (strcat "\nLisp Returned the following error: \"" st "\"\n"))
  18:             ;(alert (strcat "*ERROR*\nLisp returned the following error: \n\t" st))
  19:  
  20:             ;but we're here to log!
  21:             (Loggit "ERROR" (strcat "An error occurred\n" err))
  22:             
  23:         )
  24:     )
  25:     (gc)
  26:     (princ)
  27: )
  28:  
  29: (setq *error* new_ErrorHandler)
  30: (LogError "Oh No an Error!")
  31: (Loggit "INFO" "This is an informational message")

Not much to it.  To prevent some command line spewage if you load the assembly twice we check first to see if the function has already been exported to the environment.  Here we’ve setup a new error handler that differentiates between a function cancellation and an actual error.  At the bottom you can see a couple of examples of the logging.  If you’ve defined your log4net.config file in the same folder as the assembly if you load this lisp file you will see a log file get created.

Summary

So in review – we’ve exposed Log4Net to the Visual Lisp and command line environment inside of AutoCAD.  This will allow you to unify your logging (if you are already using Log4Net) and may even make you a Log4Net enthusiast as well.  As always I’m always interested in your feedback and constructive criticism!

December 14, 2011

Mapguide 6.5 Server Not Found on Hardened Windows 2008 Server

Filed under: Mapguide — Tags: , , , — Darrin Maidlow @ 11:39 am

It seems I’ve become the “go to guy” when it comes to Mapguide 6.5 on modern platforms!   This post builds on my previous post that documents .  In this edition we look at the situation faced on a clients server.   Basically the installation went off without a hitch with one exception.  When attempting to test the Mapguide 6.5 ISAPI the following error occurred:

HTTP Error 500.19 – Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid

Odd – but I realized immediately this server felt different.  I added the Local Computer \ Users group to the folder permissions for the MapAgents folder and gave that group Read and Execute.  This resulted in the page at least rendering.  At this point the listener was active, but the Mapguide server could not be found.

MapGuide Server #1 [Local] Autodesk MapGuide Server could not be found. If you need more assistance, please contact your Autodesk MapGuide Server Administrator.

This looked similar to the that occurred back on XP when you applied Windows XP service pack 2 – but the server service was running.  I checked the DCOM permissions and everything there was correct.  After a bit of messing around I realized that indeed this Windows server was hardened and the permissions has been restricted.  To resolve this problem I had to give the local Users group read and execute permissions to the Mapguide folder.  I had to give the local Users group write access to the logs folder.   After that the mapagent could talk to the server no problem!

Now I admit I screwed up troubleshooting 101 here.  I had a hard stop coming and really needed to get this resolved ASAP.  Instead of doing one thing at a time and testing I added both permissions.  When I tried to undo the permissions to see if I could replicate the problem I could not reproduce it.  It may be possible that I only needed to give the local Users group modify access to the logs folder.  If you encounter this problem and determine this to be the case please let me know!

If you’re having problems with Mapguide 6.5 and could use a little help – feel free to contact me via .

 

Technorati Tags: ,,,

December 9, 2011

Country / State Lookup Tables for Oracle

Filed under: Oracle — Tags: , , , — Darrin Maidlow @ 3:10 pm

The time has come for Country / State-Province lookup tables for Oracle!   Building on my earlier post on I’ve built a new script for Oracle.  This script will create two tables, two sequences for the primary keys, and two triggers to setup the auto-numbering.   Run the script and you should be good to go!

December 8, 2011

Star Wars: The Old Republic Install Download Breakout

Filed under: Gaming — Tags: , — Darrin Maidlow @ 3:59 pm

And now for something completely random!  has gone live for pre-orders today.  Yesterday I was invited to start downloading the client. (Hey this is my “personal” blog – and sometimes I like to play computer games =))  This post is to smash the hopes of those rocking less than awesome internet!  If you’re not rocking fiber or some other insane internet don’t get TOO excited when you first start downloading SWTOR.  Since we moved out of the city we’ve been rocking the – which actually costs a lot more than the fancy high bandwidth you city slickers get!  I get 3MBit burst for 30 seconds then 2.5Mbit sustained and 0.5Mbit up.  As I started my download I settled in for the long haul..  Here is a summary of my download experience – in point a point form list:

  • The initial download brought down a roughly 1.8GB  video file.   Ohh this doesn’t look to bad! 
  • Ok that file is done, Doh, now its downloading an 11GB file.  Ok time for bed.
  • Oooh 6AM conference call.  Up super early.  Mad at guy that scheduled call at 8am EST.  Oh only 3GB left.  Sweet!
  • Oh now we have a 60MB file.  Nice.
  • Oh, shoot, 4GB file.  Great.  At least I’m getting 320KB/s.
  • Oh okay half a dozen small files totaling a couple hundred megs.  Sweet its installed. Only what, 18GB downloaded?

Oh excellent.  Now it’s installed but my account has not yet been activated for pre-release play…Oh well back to work.  Maybe my account will be activated this afternoon? hmmmmm.

swtorinstalled

**Note – in the time it took me to write this post my buddy with Telus Optik downloaded the entire game.

Anyhow – very much looking forward to this game.  Here is a couple screen captures I took from the beta a month ago.  I know you wanted to see them ;)

yea i got me a freakin lightsaberdualLS

November 28, 2011

Put your credit card to work for you – a novel way to generate revenue

Filed under: Small Business — Tags: , — Darrin Maidlow @ 5:04 pm

I’m a huge fan of my    It’s one of those random things that get me excited.   Every year I deposit a significant amount of money into my retirement savings (RRSP) thanks to my credit card.  I thought I would share this technique with you.  These principles should work with any card that gives points that you can redeem for gift certificates or cash back, though this post focuses on the RBC Avion.   With you can get gift certificates for RRSPs, RESPs, or put towards loans or mortgages.

I’m in no way endorsing any particular bank or program here.  RBC’s Avion visa is the program I’m familiar with and I’ve been using for the past six years.  Please feel free to leave a comment describing your experiences with other banks and rewards programs.

Interest kills the entire thing

The very first thing you need to know is that you can NOT carry a balance on your card.  Ever.  These “premium” cards that give points always have a very high interest rate – 19% and up.  Carrying even a tiny balance will eat any potential benefits in no time.  Though I never encourage spending more than you can afford, if one month you over extend yourself, paying off your balance with a lower interest credit  might be your best option.  It’s important to note that if used properly, a credit card is a free loan.  Depending on the timing of your purchase(s) you can get up to a 45 day, interest free loan.  

Use Your Visa for EVERYTHING

The next key step to this process is to use your Visa card for EVERYTHING.  Even if you have cash in your wallet get used to using your Visa exclusively.  Save your cash to pay off your next Visa statement!  Setup as many of your automatic monthly expenses as possible to automatically deduct from your Visa:

  • Cell Phone
  • Home Phone
  • Satellite / Cable TV
  • Internet
  • etc.

This also has the added benefit of making bills a little easier to pay each month as instead of having to pay them individually.   There are several other benefits to this including no debit card fees, better exchange rates than cash when travelling abroad, and you also get all the various benefits of the premium card like insurance and what not.  Sadly my power and gas companies refuse to accept Visa so I have to waste time each month to manually transfer money to each one of these accounts.  (Come on Epcor and Altagas.  Get with the times).

Big ticket items rack up the points quickly.  If you’re planning on buying a new TV or other large items– put it on the card.  We renovated our new home this year and I managed to get 75% of the expenses on my visa.  This significantly increased the points earned for the year.   A lot of times car dealerships will let you make a down payment on a new vehicle using your Visa.  It is unlikely they will let you buy the entire vehicle using your card, as there are costs to vendors when accepting credit cards.  

Let’s consider the new car scenario.  Assume for a minute you have negotiated a price of $10K for a new vehicle.  You have $10K in cash in the bank to pay for your new vehicle.   The dealership will allow you to pay for up to $5000 of your new vehicle using your credit card.   Instead of giving the dealership $10K in cash, you make one payment of $5000 with your Visa, and one payment of $5000 with your cash.  At the end of the month you use the other $5000 to pay off your credit card.  So at this point you’ve spend the same amount of money BUT you gained 5000 points.

Using a credit card this was does take some personal responsibility and care.  Spending on credit as opposed to spending cash can result in EASILY over spending.  Be mindful of this if you’re new to credit cards.   Learn your payment due dates and set calendar reminders for the day before as well as the week before to make sure you pay it on time!

Leverage your business

Companies spend a lot of money.  Especially technology companies!  Software, hardware, books, meals, travel etc – it all adds up.  Ask your bank if you can setup a corporate business card and have the points transfer into your personal card.  RBC let me setup a company Avion card and each month the points are transferred.  I run my business almost exclusively using this card.  With the exception of payroll and the odd strange expense that requires checks – 99% of my company spending happens through my corporate card.  This also makes my accounting significantly simpler and saves me money on bookkeeping and accounting come year end.

Profit from your employer

Years ago when I worked for a company where I was the head of IT in addition to being a software developer.  My boss was really cool back in the day when it came to expenses for the company.  He would let me make purchases (including very significant ones) for the company using my personal card and expense them back to the company.  Not only did this help me build up points – but it also helped me build up a great credit rating.  When I moved on to start my own business I had a personal credit card with a huge limit (tens of thousands) that I paid off every month.  This really helped my personal credit at a critical time in my life.

So if you can spend on behalf of your employer and be reimbursed each month go for it.  Free points == free money!

45 day interest free loan

What the heck I’ll share this little tidbit too.  Find your credit card cutoff date.  This is the date that charges for the current month are stopped and will start to count against the next month.  For example, both my cards (personal and corporate) are synchronized.  The cutoff is the 10th of each month.  So any charges made up to and including the 10th will need to be paid on the 27th of that month.  Anything charged on the 11th or later will need to be paid on the 27th of the following month.  This is significant.  There are not many other ways to get a 45 day interest free loan.

Redeem early.  Redeem often!

This is especially important for rewards going into investment accounts or that go towards paying down mortgages.  I used to wait until the end of the year to cash out my points and do one large deposit into my investment account.  I realized that this was silly.  Now I strive for quarterly deposits.  This lets me try and capitalize on market downturns – buying low!  Also if you’re going for other rewards like mortgage payments – why pay the extra interest with a single deposit?  Instead of depositing say 1000$ once a year, do 250$ quarterly.  This decreases the principle of your loan and in turn the interest paid.

With the it costs 3000 points to redeem 25$ worth of credit.  There is a minimum purchase requirement of 12000 points  which results in a 100$ gift cert.  After that the amount increases in 3000 point increments.  Redeem 60K points, get 500$ gift certificate.

One last benefit to an RRSP contribution is that in addition to the 25$ going into your account – you SHOULD get a ~5$ tax refund on that amount at the end of the year.  This makes the 3000 points actually worth a little bit more.  The same can be said about paying down mortgage principle – you should save money in interest.

Nifty huh? 

So by changing the way you spend money you already spend in life you can gain a number of benefits – free 45 day loans, save money on accounting, save time paying bills and finally – free money!  I’d love to hear about other creative ways to use your credit card to earn reward points.  I’d also love to hear about other banks and credit card programs.  Please feel free to contact me by e-mail, Google+ or leave a comment here!

Technorati Tags: ,,,

November 8, 2011

OracleCommand and parameterized update statements

Filed under: Development,Oracle,RADE — Tags: , , , , — Darrin Maidlow @ 4:07 pm

This week I encountered an irritating situation with Oracle while working on code in the application logic.  In a nutshell I am building dynamically created parameterized insert and update statements based on the RADE metadata and the values entered by the user.  The first call InsertNewRecord works perfectly.  The next call UpdateExistingRecord however was not.  The parameterized SQL was being created.  The parameters were being created and assigned to the .  The ExecuteNonQuery() call was executing without returning an error.  Oracle just would not update.   Even more frustrating – this “just worked” in SQL server.

What were the differences?

The basic logic for insert was this (parts omitted because you probably just don’t care):

  1. Get table metadata
  2. Loop through fields in table
  3. for each field retrieve the value from the UI
  4. Add field to parameterized SQL statement with placeholder
  5. Create new parameter with appropriate name and value.   Add parameter to collection
  6. Loop through parameters in the collection and add to the DbCommand
  7. Finally execute the parameterized SQL statement

As I mentioned this worked great.  Fields were inserted and there was much rejoicing.

The logic for an update was similar but there was one big difference:

  1. Get Table
  2. Loop through fields in table
  3. for each field retrieve the value from the UI
  4. If the field is a key add the placeholder to the where condition, otherwise add the field name and value to the update fields part of the SQL
  5. Create new parameter with appropriate name and value.  Add parameter to collection
  6. Loop through parameters in the collection and add to the DbCommand
  7. Finally execute the parameterized SQL statement.

The branch in step 4 and the if statement ended up causing the problem.

The Problem

defaults to “bind by order” – making the order in which the parameters exist in the SQL statement match the order in which the parameters are added to the OracleCommand. This was happening during the insert because of the structure of an insert statement being so linear. However in the update statement I was building the SQL in a more dynamic way. I was maintaining a list field=value conditions and a separate where condition. In the ended up merging them :

   1: String parameterizedSQL = "UPDATE " + table.Name + " SET " + updateStatement + " WHERE " + whereStatement;

So unless my key field( s) all lined up at the end of the table metadata definitions,  appending that where condition at the end my parameter order got all out of whack in the DbCommand.  So my where condition was actually being set to the wrong value – which could have resulted in the wrong records being updated. Nasty.   Fortunately this can be resolved.

The Fix – BindByName=true

To correct this I had to set the Oracle specific BindByName property to true.  (btw this being the default behavior is just silly.  All the other big data providers default to bind by name and Oracle should too.  That’s a rant for another day though.)   My initial solution was to check if the command is an OracleCommand and if found do a little casting to set the BindByName property then recast it back to DbCommand before executing the query.  Constructive feedback is always welcome!

   1: /// <summary>
   2: /// Execute the parameterized query
   3: /// </summary>
   4: /// <param name="conn">open and active DbConnection</param>
   5: /// <param name="trans">Active DbTransaction</param>
   6: /// <param name="parameterizedSQL">the parameterized SQL</param>
   7: /// <param name="paramList">List of OledDbParameter</param>
   8: /// <returns>DataTable containing the results</returns>
   9: public static void RunParameterizedInsertUpdate(DbConnection conn, DbTransaction trans, String parameterizedSQL, List<DbParameter> paramList)
  10: {
  11:     //create the db command and set the parameterized SQL as a property
  12:     DbCommand command = conn.CreateCommand();
  13:     if(trans != null)
  14:     {
  15:         command.Transaction = trans;
  16:     }
  17:     //hack attack!  By default, Oracle requires its parameters to be placed into the command
  18:     //in the order the parameters appear in the parameterized SQL.  Little hackery here
  19:     //to set the Oracle Command to bind by name
  20:     if (command is Oracle.DataAccess.Client.OracleCommand)
  21:     {
  22:         OracleCommand oraCmd = (OracleCommand) command;
  23:         oraCmd.BindByName = true;
  24:         command = oraCmd;
  25:     }
  26:     command.CommandText = parameterizedSQL;
  27:     command.CommandType = CommandType.Text;
  28:  
  29:     //loop through the params and add them to the command
  30:     foreach (DbParameter parameter in paramList)
  31:     {
  32:         command.Parameters.Add(parameter);
  33:     }
  34:     try
  35:     {
  36:         command.Prepare();
  37:         command.ExecuteNonQuery();
  38:     }
  39:     catch (Exception ex)
  40:     {
  41:         command.Dispose();
  42:         throw;
  43:     }
  44: }

November 4, 2011

Introducing Question of the Week for ObjectARX.NET and Mapguide

Filed under: AutoCAD,Development,Mapguide — Tags: , , , — Darrin Maidlow @ 11:32 pm

Every good developer is constantly evolving and learning new technologies.  This can be a challenge when you’re hard at work in maintenance mode on familiar technology or when your every day needs don’t go as deeply into topics as you would like. 

If you take a step back and look at AutoCAD and – its a huge body of work and it is a challenge to get experience in all the various parts of it.  The recent request I received on how to or the command line and the subsequent research, code and blog post I wrote made me think,  what if I solicited small problems from the AutoCAD community that could make fun little 4 hour research projects.  These would allow me to dig into various portions of ObjectARX.NET once a week, write some fun code, and give me things to write about.  Everybody wins!

I’m looking to spend about 4-6 hours on each question.  I’m hoping to do one question per week, assuming I get enough requests.  I’ll provide the full source and project with each post.  All code will be written in c#.  Some examples of valid requests would be:

  • Submit a Visual Lisp routine to convert to ObjectARX.NET.
  • Request a particular routine that does some sort of drawing clean up or modifies something.
  • Identify some functionality that is missing in AutoCAD.
  • Request a piece of sample code explaining how to use API x of ObjectARX.NET or Mapguide Enterprise/Open Source.

The Do’s

  • Please keep your request realistic.   I’ve only got 4 to 6 hours and you’re not paying me =)
  • Please submit specific functionality along with sample data.
  • Please be available to answer any questions  I might have via e-mail, phone/skype or possibly gotomeeting.
  • Please keep the underlying technology somewhat current.  Don’ t request AutoCAD/Mapguide 2007.
  • Please review my code and comment if you see something wrong or that I could do more efficiently.  This is about me learning and I’m gonna make mistakes.

The Don’ts

  • Don’t expect days worth of work, I just don’t have that much spare time.
  • Don’t ask me to work on your project (unless of course you want to hire my team via ).
  • Please don’t get upset if I don’t pick your question.
  • I did my ten odd years in the trenches writing Visual Lisp – I don’t really want to write any more, so please don’t ask for lisp code.
  • Don’t be a ass.  I don’t have time for asses.

Let’s See What Happens

So I have no idea how this will play out.  I don’t know if 4-6 hours is a reasonable amount of time to allocate each week to do this right.   I don’t know if I will be able to make the time every week.  Maybe I’ll change it from “Question of the Week” to “Question of the Every Second Week”.  I’m going to put this out there and see what happens.   I reserve the right to change anything and everything! s  E-mail your requests to contact ~@~ geospecialling dot com.

November 2, 2011

Remotesoft Protector Runtime Error – yet to handle multiple .NET framework runtime

Filed under: Development — Tags: , , — Darrin Maidlow @ 9:07 pm

Remotesoft protector is one of the out there.  In fact, its pretty much the only one that really works.  Since I moved to .NET 4.0 I’ve been getting an annoying error when attempting to protect my binaries using the 4.0 suite of tools (with the ).  Everything still runs – it just pops up nasty alert boxes on load which is no good :)

Remotesoft Protector Runtime Error – yet to handle multiple .NET framework runtime

One other symptom of this was that .exe files would just blow chunks.  I’ve finally figured out what was causing this!  Most of our products are protected during the nightly builds.  This error however is specific to assemblies protected using the the Remotesoft .NET Explorer UI.  When using this application for the protect or obfuscate functionality it is really just a front end around the protector.exe/obfuscator.exe.  The UI is building the following command line string and tonight it finally dawned on me:Remotesoft .NET Explorer

Command: C:\Program Files (x86)\Remotesoft\Protector\bin\protector.exe -neutral -resource -string -cctor -clrversion v2.0.50727 "C:\temp\SmartInk for Kahua\SmartInk.UI.exe"

The UI was forcing the clr version to .NET 2.0 – when my assemblies are all built against .NET 4.0.  Oops…

After a bit of digging I found that you can set the CLR version in .NET Explorer from the Action / CLR Version menu item.  Unfortunately it has not been updated to support .NET 4.0 – and so has been rendered pretty much useless as a front end for protector.

The Fix

The only solution is to use the command line to execute your protection.   The updated command line ended up looking pretty similar:

"C:\Program Files (x86)\Remotesoft\Protector\bin\protector.exe" -neutral -resource -string  -clrversion v4.0.30319 "C:\temp\SmartInk for Kahua\SmartInk.UI.exe"

There you have it – I can’t believe I missed that…

Older Posts »

Powered by WordPress

Switch to our mobile site