IIS Manager MMC could not create the snap-in

May 1st, 2009

image

 

From the Command Line run

“regsvr32 %windir%\system32\inetsrv\inetmgr.dll”

image

Greg Uncategorized

Using WebOrb as a Web Service Proxy when CrossDomain.xml is not available

April 16th, 2009

So you have the CrossDomain.xml blues. I had the same issue and I need to grab an RSS Feed to display in my Flex App.

A simple demonstration can be seen here http://gregjessup.net/marketevents/

image

The Latest Market News is actually an RSS request from yahoo finance top stories, which would return XML but when done directly using HTTPService (seen below)…

<mx:HTTPService result="gotData(event)" showBusyCursor="true" id="RSSfeed"  
url="http://finance.yahoo.com/rss/topstories" resultFormat="object" />

you’d get the god forsaken Security Sandbox Error because the request is not trusted by finance.yahoo.com … ( see for yourself http://finance.yahoo.com/crossdomain.xml )

So the fix is to use a proxy. I’ve seen some stuff out on the net that allows you to do it with PHP, but I am a WebOrb fanatic, and it allows me to stick with C#, and not have to worry about another environment. To be honest, once you learn WebOrb…you’ll never look back.

 

So the solution is quite simple and you can download the

.Net code hereMarketEvents.zip

 

You’ll see in my WebFetch class, I am just passing a URL and it returns the HTML or XML as a string. That like the rest of the code is very straight forward…but I’m not going to go into much detail here.

 

In the MarketEvents.cs file you’ll see getNews() and getNewsDataSet()

I would recommend getNewsDataSet() simply because it parse the XML into an object in your Middle Tier, and thus is leaves doing much less work on the FLEX client side.

public DataSet getNewsDataSet()
       {
           //create a new DataSet that will hold our values
           DataSet rssDataSet = null;
           WebFetch.WebFetch wf = new WebFetch.WebFetch();
           string xmlString = wf.getWebPage("http://finance.yahoo.com/rss/topstories");
           //check if the xmlString is not blank
           if (String.IsNullOrEmpty(xmlString))
           {
               //stop the processing
               return rssDataSet;
           }
           try
           {
               using (StringReader stringReader = new StringReader(xmlString))
               {                    
                   rssDataSet = new DataSet();
                   rssDataSet.ReadXml(stringReader);
               }
           }
           catch
           {
               rssDataSet = null; 
           }
           return rssDataSet;
       }

 

Using getNewDataSet() the Flex side is easy just set your datagrid.dataprovidere.result.item

If you prefer to return a string and then work on the XML on the FLEX side…I’ll give you both the C# and the FLEX code….

C# Code

public string getNews()
       {
           WebFetch.WebFetch wf = new WebFetch.WebFetch();
           return wf.getWebPage("http://finance.yahoo.com/rss/topstories");
 
       }

 

FLEX Code (I’m assuming you know how to call a remote object from Flex so this is what happens when you get the result back)

private function gotNews (e:ResultEvent) : void {
            RSS = new ArrayCollection();
            var xml:XML = new XML(e.result);
            var obj:Object = xmlToObject(xml);
            entries.dataProvider=obj.rss.channel.item; //where entries is my datagrid           
        }
 
private function xmlToObject(value:XML):Object {
                var xmlStr:String = value.toXMLString();
                var xmlDoc:XMLDocument = new XMLDocument(xmlStr);
                var decoder:SimpleXMLDecoder = new SimpleXMLDecoder(true);
                var resultObj:Object = decoder.decodeXML(xmlDoc);
                return resultObj;
            }

 

Greg Uncategorized

Change Browser Title in FLEX using Javascript

March 27th, 2009

If you only need to statically set the Browser Title in FLEX, then just set the pageTitle property of your <mx:Application>

<mx:Application backgroundColor="#ffffff" pageTitle="My Application: By Greg Jessup"
    xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute"
    initialize="init()"
    width="100%"
    height="100%"
>

Howerver, sometimes you want to do it dynamically. The only way to do this is by making a call from Flex to the HTML template and invoking a JavaScript function.

We use the flash.external.ExternalInterface to accomplish this task.

Here is how its done…..

FLEX CODE

import flash.external.ExternalInterface;
 
private function SetBrowserTitle(newTitle:String) : void {
                if ( ExternalInterface.available ) {                     
                    ExternalInterface.call("changeTitle",newTitle);        
                }            
}

 

Javascript

Simply edit the html-template/index.template.html in you project. Your header will look something like this. The main thing you are concerned with here is adding the changeTitle function….see below

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${title}</title>
<script src="AC_OETags.js" language="javascript"></script>
<script language="JavaScript" type="text/javascript">
    function changeTitle(newTitle) {      
      document.title=newTitle;  // this works with IE only      
     }
</script>
<style>
body { margin: 0px; overflow:hidden }
</style>
</head>

Greg Uncategorized

Replace Non Printable Characters in PERL String

March 26th, 2009
#replace non printable characters in the description
my %good = map {$_=>1} (9,10,13,32..126);
$description =~ s/(.)/$good{ord($1)} ? $1 : ' '/eg;

Greg Uncategorized

ComboBox ItemRenderer in Flex AdvancedDatagrid

March 9th, 2009

image

 

If you are declaring your AdvancedDataGridColumn in MXML then simply add

headerRenderer="View.HeaderRenderer"

<mx:AdvancedDataGridColumn wordWrap="true"  headerRenderer="View.HeaderRenderer"  
    sortable="false" dataField="chkbox" width="200" textAlign="center">

 

Then Create your ComboBox in either MXML or ActionScript. I chose MXML in this case.

<?xml version="1.0"?>
 
<mx:HBox creationComplete="setStyles()" horizontalAlign="center" xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Style>
        HeaderComboBox {
           cornerRadius: 0;
           arrowButtonWidth: 0;
           openDuration: 10;
           closeDuration: 10;
           textAlign: left;
           fontSize: 10;
        }
    </mx:Style>
    
    <mx:Script>
        <![CDATA[
            import mx.events.ListEvent;         
            [Bindable]    public var headerRendererData: Array = [ {label:"Select Action", data:0, buttonName: ""}, 
                    {label:"Close Selected", data:"close",  buttonName: "Close these Tickets"},                
                    {label:"Update Selected", data:"update",  buttonName: "Update these Tickets"}];                   
 
 
 
               public function doWork(e:ListEvent) : void {                   
                   //Put code here to action a selection event
                   combo.selectedIndex = 0;  //reset combo to first value
                   trace (e);
               }
               private function setStyles() : void {
                   
                try {
                   combo.dataProvider = this.headerRendererData;;
                   combo.setStyle("cornerRadius",0);
                   combo.setStyle("openDuration",10);
                   combo.setStyle("closeDuration",10);
                }
                catch (e:Error) {}
               }
               
        ]]>
    </mx:Script>
 
    <mx:ComboBox id="combo" width="98%" dataProvider="{this.headerRendererData}" change="doWork(event)">
        
    </mx:ComboBox>
    
 
</mx:HBox>
 

Greg Uncategorized

SubSonic Multiple Databases ConnectionString or DataProviders

March 6th, 2009

So you have a SubSonic Project that you now need to connect to multiple Databases. In my case, I didn’t let SubSonic build the database infrastructure, but for my 2nd database, I just used and inline query. Why? Because I needed it done YESTERDAY…So it was just easier at the time.

To configure SubSonic to connect to the other database. I did the following.

Below in the XML…notice I have 2 connectionStrings and 2 providers

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" allowDefinition="MachineToApplication" restartOnExternalChanges="true" requirePermission="false"/>
  </configSections>
  <connectionStrings>
    <add name="SQLDashboard" connectionString="Data Source=MYQSTMGTDB01; Database=SQLPerfmonStats; Integrated Security=true;"/>
    <add name="MYDevicesDB" connectionString="Data Source=MYDevicesDB; Database=MYDevices; Integrated Security=true;"/>
  
  </connectionStrings>
  <SubSonicService defaultProvider="SQLDashboard" enableTrace="false" templateDirectory="">
    <providers>
      <clear/>
      <add name="MYDevicesDB" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="MYDevicesDB"/>
      <add name="SQLDashboard" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="SQLDashboard"/>
    </providers>
  </SubSonicService>
</configuration>

 

In my C# code I did the following using Subsonic.InlineQuery

String sql = @"select * from myTable";
 
IDataReader rdr = new SubSonic.InlineQuery("SACDevicesDB").ExecuteReader(sql);
             DataTable dt = new DataTable();
                 using (rdr)
                 {
                  dt.Load(rdr);
                 }
             return dt;

Greg Uncategorized

Taxed to excess

March 6th, 2009

Excellent letter to the editor Times Record News Witchita Falls Kansas

image

http://www.timesrecordnews.com/news/2009/feb/05/no-headline—2-6_oped_letters/

Dear IRS,

I am sorry to inform you that I will not be able to pay taxes owed April 15, but all is not lost.

I have paid these taxes: accounts receivable tax, building permit tax, CDL tax, cigarette tax, corporate income tax, dog licence tax, federal income tax, unemployment tax, gasoline tax, hunting licence tax, fishing licence tax, waterfowl stamp tax, inheritance tax, inventory tax, liquor tax, luxury tax, medicare tax, city, school and county property tax (up 33 percent last 4 years), real estate tax, social security tax, road usage tax, toll road tax, state and city sales tax, recreational vehicle tax, state franchise tax, state unemployment tax, telephone federal excise tax, telephone federal state and local surcharge tax, telephone minimum usage surcharge tax, telephone state and local tax, utility tax, vehicle licence registration tax, capitol gains tax, lease severance tax, oil and gas assessment tax, Colorado property tax, Texas, Colorado, Wyoming, Oklahoma and New Mexico sales tax, and many more that I can’t recall but I have run out of space and money.

When you do not receive my check April 15, just know that it is an honest mistake. Please treat me the same way you treated Congressmen Charles Rangle, Chris Dodd, Barney Frank and ex-Congressman Tom Dashelle and, of course, your boss Timothy Geithner. No penalties and no interest.

P.S. I will make at least a partial payment as soon as I get my stimulus check.

Ed Barnett

Wichita Falls

Greg Uncategorized

Create a Key Value Pair Object in Actionscript

March 5th, 2009

 

If this is essentially an ActionScript Dictionary, but if you don’t need some of the overhead a dictionary brings along, you can make a nice key value pair like this.

private var keyValuePair:Object = {"processor_TotalPercentTime_value" : "processor_color",
                                         "network_value" : "network_color",
                                         "network_value" : "network_color",
                                         "disk_DiskSecPerTransfer_value" : "disk_color",    
                                         "disk_KBytesPerTransfer_value" : "disk_color",
                                         "memory_PLE_value" : "memory_color",
                                         "memory_LazyWrites_value" : "memory_color",
                                         "memory_AvailableMBytes_value" : "memory_color",
                                         "MachineName":"sql_color"};

 

You would reference the keyValuePair as follows:

var myVal = keyValuePair["processor_TotalPercentTime"].toString();

Greg Uncategorized

Error #1034: Type Coercion failed: cannot convert mx.graphics::Stroke to mx.graphics.IStroke.

March 5th, 2009

This turned out to be a pretty haunting bug, and I still don’t quite understand what I did to fix it, but I did.

You’ve probably already seen the Adobe Bug SDK-9480 

And of couse you’ve seen an error that looks like so…..

TypeError: Error #1034: Type Coercion failed: cannot convert mx.graphics::Stroke@dfd3e21 to mx.graphics.IStroke.
    at mx.charts::AxisRenderer/measure()
    at mx.core::UIComponent/measureSizes()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:5956]
    at mx.core::UIComponent/validateSize()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:5902]
    at
mx.managers::LayoutManager/validateSize()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:579]
    at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:668]
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8628]
    at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8568]

 

The situation only appears to occur when I am running a Module across Application Domains.  For me it worked fine, as I was developing the module stand alone with a Main.mxml that I was using as my loader for the Module. When I ported the module to my global application….I was not so lucky and it broke things.

To fix the bug you will need to make a change in the code that is loading the module. In 1 of the following 2 ways. I used the 2nd because forcing all modules into the same “currentDomain” broke other modules that were using shared classes.

Here are the 2 ways I know of to fix it.

 

1) Set the Application Domain in your ModuleLoader as follows

var Mod:ModuleLoader = new ModuleLoader();
Mod.applicationDomain = ApplicationDomain.currentDomain;

2) In your Parent Application not in the module itself. (Every module needs and application)

import mx.graphics.IStroke;
private var uStroke:IStroke;

Greg Uncategorized

Use your Keyboard to turn your monitors off [ PushMonitOff v1.0 ]

March 5th, 2009

Found a handy piece of Software (Available Here) which allows you to quickly turn your monitors off using a keyboard shortcut. The default is Shift-F1. But can be changed using the task manager (seen below).

image

 

PushMonitOff v1.0

Greg Uncategorized