Tuesday, January 3, 2012

SSIS Conditional Flow Constraints. (How to do an IF-THEN-ELSE flow like a normal flowchart)

This explains how to achieve a standard IF-THEN-ELSE style flow control so that it behaves the same way as you would expect if you had drawn a normal flowchart.  I just found this out so I wanted to share it as soon as possible so the explanation is very much straight to the point, so I hope it is still useful.

Here is another blog that I found after writing my own that describes the same thing. 


The aim:  We have a simple flow where we want to run A and C always, but if a certain condition (i.e. User:Id == 1) is true then we want to run B before C.  This "apparently" simple sequence is shown below.  When we run the flow below with User::Id == 1 then A runs, then B and then C, so all is fine so far.  However, when we run with User:Id == 0 then A runs but C will never run because it requires B to run with success as well.


The problem: With the default connectors, the condition for C to run is a logical AND of the constraints/conditions of its two input connectors. When you edit one of the connectors connecting to C you will see in the Multiple Constraints section that "Logical AND" is selected.  This is the problem that prevents C from running if B doesn't run as well.



The solution: Select the "Logical OR" option so that C will run if either of its input connectors conditions/expressions are true.  This will turn both the connectors joining to C into dotted lines as shown in the figure below.


Hope this helps! 



By the way. I found another solution here that uses Sequence Containers.

Saturday, January 15, 2011

How to write a file to Android filesystem using Adobe AIR

The other night I ended up banging my head against the wall wondering why I couldn't write a file (or even create a directory for that matter) to my Samsung Galaxy S filesystem using a Flex application running on Adobe AIR.


The code was simple enough and apparently the code should have worked on my mobile without any additional changes.  However, when things didn't work I was left stumped.


The code:
 private function saveFile() : void {  
      var myFile:File = File.documentsDirectory.resolvePath("Test Folder/test.txt");  
      var fs:FileStream = new FileStream();  
      fs.open(myFile,FileMode.WRITE);  
      fs.writeUTFBytes("blah blah");  
      fs.close();  
  }  


Using the code above nothing was written to the filesystem.  WTF?? I tried to figure out the paths of the special directories to see if was trying to write the file in a weird directory somewhere.  


The debug code below:
 debugText += File.applicationDirectory.nativePath + "\n";  
 debugText += File.applicationStorageDirectory.nativePath + "\n";  
 debugText += File.documentsDirectory.nativePath + "\n";  
 debugText += File.userDirectory.nativePath + "\n";  
resulted in the following output:

    /data/data/air.TestApp.debug/TestApp.debug/Local Store
   /mnt/sdcard
   /mnt/sdcard
   /


So it should have correctly written to the internal SD card on my Galaxy S but there wasn't a file or directory in sight.  The next thing I tried to do was create a directory using the code below, while checking for any errors.


 var file:File = File.documentsDirectory.resolvePath("Test Folder");  
 try {  
      file.createDirectory();  
 } catch (e:Error) {  
      debugText += e.message;  
 }  

This resulted in "error #3001" which means "File or directory access denied."
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/runtimeErrors.html

Why was access being denied since the "/mnt/sdcard/" folder had read and write access? The answer lied in the security permissions for an android application as described on the android developer guide.
http://developer.android.com/guide/topics/security/security.html

By default, an android application doesn't have permission to write to external storage so in order to write to my Samsung Galaxy S's internal SD card ("/mnt/sdcard/") I needed to set the WRITE_EXTERNAL_STORAGE permission to my applications XML descriptor file ("TestApp-app.xml").

 <android>  
   <manifestAdditions><![CDATA[  
      <manifest>  
           <!-- See the Adobe AIR documentation for more information about setting    Google Android permissions -->  
           ...  
         ...  
           <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>  
         ...  
         ...  
      </manifest>  
 ]]></manifestAdditions>  
  </android>  


After adding this line everything worked like a charm.  Such relief.



Tuesday, January 11, 2011

SSL Certificate or Code Signing Certificate for ClickOnce Deployment

I am using ClickOnce deployment to deploy an Excel Com Addin and was wondering if I could sign the installer with an SSL Certificate and kill two birds with one stone.


The short answer is NO, they are different!


So what is the difference between an SSL and Code Signing certificate?
It seems that the only difference is the value of the purpose field in the certificate. The issuer of the certificate chooses for what purpose the certificate is created.  Applications that do the signing and verifying check the purpose field of the certificate.
In short:
  • An SSL Certificate is used for authentication of your website/application server.
  • A Code Signing Certificate is used for integrity/authentication of the exe,dll,... you deliver.

Here is a great little thread I found resulting from someone asking the same question as me

How to Control Alt Delete (Ctrl Alt Delete) on Remote Desktop

To perform a  "Control+Alt+Delete" on Remote Desktop press Control+Alt+End (Ctrl+Alt+End)

It's one of those things that also seems to escape my mind, so I am finally putting it up.

Short and sweet.  What a great first blog!