Sunday, March 24, 2013

FP: Script Not Found

Problem
Integrating with GP and a simple one line script is resulting in this error: "FP: Script Not Found"


Solution
 Deleting the script and then re-adding seemed to do nothing. There must have a been a reference to an orphaned function with the same name or something. The solution ended up being changing the name of the CHG script that was causing the "Script Not Found" error.

Note
I see a few search results showing that this error can be caused by Saving and not compiling a script. I didn't do this. I always compile the entire dictionary before chunking... so this must be an unknown problem.

Friday, March 22, 2013

Alexander the Great

http://en.wikipedia.org/wiki/Siege_of_Tyre

Summary: Built a bridge to an island. Tyre sent fire ships to burn it. When Alexander finally took the city he killed lots of civilians, the first time his character started to change from a benevolent conqueror to a destroyer.

http://www.livius.org/aj-al/alexander/alexander_t39.html

Summary: When Alexander seiged Gaza, Batis didn't want to surrender to him. This enraged Alexander. He was further enraged when he was hit by an enemy arrow. So, when Alexander breached and took the city he killed Batis brutally, by putting ropes through his heels and dragging him to death behind a chariot.

Note: This is what Achilles did to Hector in the Trojan war as well.

Note 2: A famous incident of this happened in modern times during a US Army Rangers operation in Mogadishu, Somalia. The operation was botched, and the Somalians overran the Americans. They drug the body of a killed soldier through the streets.

Session timing out in ASP.NET even though session timeout is not being met

I set the session timeout to a large number, because users were complaining that it would log them out in the middle of entering an article.

I was wondering how people were still getting logged out, and then I came across an article showing that the App Pool timeout can also cause this. Indeed, this value was set to 20 minutes, much less than the session timeout, and is a likely candidate for why people are still timing out. 

http://asp-net.vexedlogic.com/2012/05/23/aspasp-net-session-timeout-how-do-i-change-it/

Monday, March 18, 2013

Rapid Development metholodogy - unclassified

I have a deadline for code in a few weeks and haven't received the requirements spec. In order to get somewhat close to the deadline I've streamlined the dev process into this:  Designing, coding, and unit testing one piece of functionality at a time.
 
Have two documents: Design doc and Unit testing doc

Design doc is a tree based structure:
  1. Field Name
    1. Create
      1. Description of what should or shouldn't happen
    2. Read
      1. Dependent Field Name
        1. Create
          1. Description of what should or shouldn't happen
        2. Read
        3. Update
        4. Delete
    3. Update
    4. Delete

The "Dependent Field Name" is a field that's only purpose is to do something to the parent field. For example, I could have a field "Purchase Order Number", and then a Dependent Field would "Purchase Order Number Lookup" - that's sole purpose is to return a PO Number to the parent field.

Unit Test doc is
  1. Window
    1. Field Name
      1. Table with columns #, Bug, Fix. (self-explanatory)
I design a piece of functionality in the Design doc for a field. Code the functionality, and then unit test and write down any bugs in the Unit Test doc. In the Design doc once a piece of functionality is unit tested successfully I strike it out.

This has proven to be efficient and I have working code quickly. Not to mention the documentation is happening on the fly, instead of before or after the coding phase, which is very nice.

I don't know what the name of this development methodology is, but I like it, and I'd like to figure out what it would be classified as.

A quick Google search turns up:
1. Test-driven development and
2. Extreme programming - http://en.wikipedia.org/wiki/Extreme_programming

I'll have to do more research on this later.


Sunday, March 17, 2013

Capitalize textbox input as it's entered

Problem
I have a form with an input textbox and a button to process the results of that input. I need the input to be forced to uppercase in the textbox.

Note: If I didn't need the user to see it as capitalized then I would just do txtBox.Text.ToUpper() in the processing code, but I need the user to see it as capitalized.

Solution 

Monday, March 11, 2013

Modify an XML document in C#

This shows how to:
1. Open an XML file
2. Search for existing nodes and attributes
3. Modify and insert nodes
4. Save the results

Note: This code solves a specific problem, and makes no attempts to generalize.

How to run an exe with InstallScript

The script below will run an exe. 

prototype runEXE(STRING);  
function runEXE(exe) 
string fullPath;
begin     
    if(FeatureIsItemSelected(MEDIA, "Server") == TRUE) then
        fullPath = TARGETDIR^exe;
        LAAW_STARTUPINFO.dwFlags = LAAW_STARTUPINFO.dwFlags | STARTF_USESHOWWINDOW;
        LAAW_STARTUPINFO.wShowWindow = FALSE;
        if(LaunchAppAndWait(fullPath, "", LAAW_OPTION_WAIT) < 0)then
            MessageBox("Error launching " + exe + ". Check if it exists in " + TARGETDIR + " then manually launch it" , INFORMATION);
        endif;                 
    endif;   
end;


How to call it
The script below checks if the "Server" feature is being installed, and then calls runEXE on two files: test.bat and modifyConfig.exe.

 function OnEnd( )
begin  
    if(FeatureIsItemSelected(MEDIA, "Server") == TRUE) then
        runEXE("test.bat");
        runEXE("modifyConfig.exe");
   endif;    
end;

Sunday, March 10, 2013

POS for .NET with .NET 4 applications

Problem:
I have a .NET dll that uses POS for .NET to handle devices. I'm integrating with a program that's running in .NET 4.0. This results in PosExplorer not being able to return from the cstr. In some situations this may be causing execeptions, but in my case it's not reporting any errors at all.

Solution
In the ApplicationName.exe.config for the exe that is running the DLL put in

<configuration>
   <runtime>
      <NetFx40_LegacySecurityPolicy enabled="true"/>
   </runtime>
</configuration>


Note: The configuration section will probably already exist, so just stick the runtime section in there. If the application does not have a .config file, then create one. It needs to be named ApplicationName.exe.config
 
References

Support thread: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/4f205df3-2658-4531-87bd-77bda99d571c

Tool used to debug: http://www.yortsoft.com/Products/PosDotNetPlugNPlayConfigurationUtility.htm

MSDN doc: http://msdn.microsoft.com/en-us/library/dd409253%28v=vs.100%29.aspx
There was an error in this gadget