TechNinjutsu

A man didn’t understand how televisions work, and was convinced that there must be lots of little men inside the box, manipulating images at high speed.  An engineer explained to him about high frequency modulations of the electromagnetic spectrum, about transmitters and receivers, about amplifiers and cathode ray tubes, about scan lines moving across and down a phosphorescent screen. The man listened to the engineer with careful attention, nodding his head at every step of the argument. At the end he pronounced himself satisfied. He really did now understand how televisions work.
 "But I expect there are just a few little men in there, aren’t there?" -Douglas Adams

Find security duties related to menu item in Dynamics AX 7(365 for Operations)

posted Mar 1, 2017, 10:16 PM by d graham   [ updated Mar 3, 2017, 12:28 AM ]

using Microsoft.Dynamics.AX.Security.Management;
using Microsoft.Dynamics.AX.Metadata.Providers;

class jTest
{
    public static void main(Args _args)
    {
        jTest j = new jTest();
        
        SecurityRepository sr = new SecurityRepository(null, null);
        Querying.RelatedSecurityRolesFinder rsrf = new Microsoft.Dynamics.AX.Security.Management.Querying.RelatedSecurityRolesFinder(sr);

        j.getDisplayRelatedDuties("PurchTable", rsrf);
        j.getOutputRelatedDuties("PurchInvoice", rsrf);
        j.getActionRelatedDuties("PurchTableApprovalApprove", rsrf);
       
    }

    private void getActionRelatedDuties(str _actionMenuItem, Querying.RelatedSecurityRolesFinder _rsrf)
    {
        SecurityObjectsBag sob = _rsrf.FindRelatedSecurityObjectsForMenuItemAction(_actionMenuItem);
        this.displaySobDuties(sob);
    }

    private void getDisplayRelatedDuties(str _actionMenuItem, Querying.RelatedSecurityRolesFinder _rsrf)
    {
        SecurityObjectsBag sob = _rsrf.FindRelatedSecurityObjectsForMenuItemDisplay(_actionMenuItem);
        this.displaySobDuties(sob);
    }

    private void getOutputRelatedDuties(str _actionMenuItem, Querying.RelatedSecurityRolesFinder _rsrf)
    {
        SecurityObjectsBag sob = _rsrf.FindRelatedSecurityObjectsForMenuItemOutput(_actionMenuItem);
        this.displaySobDuties(sob);
    }

    private void displaySobDuties(SecurityObjectsBag _sob)
    {
        info(_sob.ToString());
        using(var dutiesEnumerator = _sob.Duties.getEnumerator())
        {
            while(dutiesEnumerator.MoveNext())
            {
                Interfaces.ISecurityObject d = dutiesEnumerator.Current;
                info(strFmt("%1, %2", d.Name, d.Identifier));
            }
        }
    }

}

Locating an AX7 entity field from the form control

posted Feb 3, 2017, 9:28 AM by d graham

1.   Find the form in the Application Explorer under UI elements and right click to view the design
2.       If the preview comes up find the control in the preview and Visual Studio will select it in the designer, or if the preview doesn’t come up then dig down into the many levels of tabs and groups to search for the form contro
3.       In the properties for the form control it will have a property for Data Source and for Data Field
4.       The Data Source property will tie back to the form data sources which will have a Table property   
5.       A Find references lookup from Application Explorer>Data Model>Tables on the PriceUnit field on InventTableModle will help to get back to the entity for data import, where it looks like AX is calling it PurchasePriceQty    

TLS version in Dynamics AX .net interop in X++

posted May 26, 2016, 10:23 AM by d graham   [ updated May 26, 2016, 10:29 AM ]

Recently in my office a discussion about which version of TLS is used by Dynamics AX in .net interop calls came up, as a vendor announced that in the next year TLS1.0 and TLS1.1 would be disabled for access to their API.

The setting that seems to control which protocols are available for web requests can be set with the following:
    
    System.Net.ServicePointManager::set_SecurityProtocol(System.Net.SecurityProtocolType::Tls12);

set_SecurityProtocol() will accept a bitmask value based on the System.Net.SecurityProtocolType enum: https://msdn.microsoft.com/en-us/library/system.net.securityprotocoltype(v=vs.110).aspx

It seems that the .net setting for System.Net.ServicePointManager.SecurityProtocol is set per AppDomain ( http://stackoverflow.com/questions/3028486/how-to-use-ssl3-instead-of-tls-in-a-particular-httpwebrequest ) which means that potentially setting that enum value for a specific vendor may have side effects on your other API integrations(if such exist). If you must select a specific protocol for a vendor it may be worth considering creating the call in it's own AppDomain.

To determine what the current value of System.Net.ServicePointManager.SecurityProtocol in your AX .net environment you can run a job like so:

    static void CheckEnviornmentSecurityProtocol(Args _args)
    {
        int i;
        boolean ssl3Enabled,tlsEnabled,tls11Enabled,tls12Enabled;
    
        ;
        i = System.Net.ServicePointManager::get_SecurityProtocol();
    
        ssl3Enabled = i & enum2int(System.Net.SecurityProtocolType::Ssl3);
        tlsEnabled = i & enum2int(System.Net.SecurityProtocolType::Tls);
        tls11Enabled = i & enum2int(System.Net.SecurityProtocolType::Tls11);
        tls12Enabled = i & enum2int(System.Net.SecurityProtocolType::Tls12);
    
        info(strFmt("'%1' enabled: '%2'",
                'ssl3',            
                ssl3Enabled));
        info(strFmt("'%1' enabled: '%2'",
                'tls1',            
                tlsEnabled));
        info(strFmt("'%1' enabled: '%2'",
                'tls11',            
                tls11Enabled));
        info(strFmt("'%1' enabled: '%2'",
                'tls12',            
                tls12Enabled));
    }


rootron5: how to root the retron 5

posted Aug 8, 2014, 1:13 AM by d graham

First, I would like to say that I am a big fan of the retron 5, I think it's a great device--anyone who likes retron video games should go buy one... 

I think this is the first public rooting of the Hyperkin Retron5, and I only soft-bricked my console once on the way, so I am pretty excited to share this with the world.

note: 
    -the controller will not be able to charge using the port on the retron while this is in use afaik 
    -this is only tested once on my device
    -usb settings are probably wonky so I wouldn't play too much with usb types other than adb unless that gets cleaned up

1. grab the factory restore from the hyperkin website: http://retron5.in/node/4  (maybe someone could mirror that incase hyperkin pulls the files)
2. follow the standard instructions until your sd card is formatted and has a file called update.zip on it (as a side note there is a neat magic number header on the sd card you can look at with a hex editor that causes the retron to mount data and cache on the sd card instead of the standard mount point)
3. delete the update.img from the sd card and replace it with the copy attached at the bottom
4. now continue to follow the standard instructions and flash the update with the retron recovery
5. connect with a mini usb and adb should be enabled and have root! enjoy!

this is kind-of a messy/hacky job on the update, but it's good enough for now.

Lots of interesting stuff in the stock rom:
 -check out retrondummy.apk or something like that for what looks like the lists of games supported (and probably with a small bit of reversing you could add your own games to the txt files) 
 -a cool chip tunes song (maybe they used for testing audio?)
 -the horse head picture that retron tech uses on facebook (and some other pics which maybe seem like easter eggs from the developers or something?)
 -retronUpdater seems like maybe it has the key for how the application files get decoded or something?
 -looks like the carts are probably having chr and prg dumped for nes, so I'm guessing the cart is just for show after the dump
 -it looks like it probably tries to run bootscript.sh if it exists on the data partition as part of init.rc

Download:


many thanks to my coworkers/friends and family who have been listening/helping me reach this goal! (glad I didn't have to buy that sdcard protocol analyzer I was looking at or desolder anything!)

Create return order in Dynamics AX 2012 using AIF with ReturnReturnOrderInService

posted Jul 17, 2014, 2:11 PM by d graham   [ updated Jul 17, 2014, 2:14 PM ]

I couldn't find any examples of this on the net, so here is an example of how to use AIF to create a return order in Dynamics AX 2012.

Note: this is sample code only and should probably not be used in production, is without any warranty, and may be missing fields etc

public static AifEntityKeyList createReturnOrder(SalesTable _salesTable)
{
    SalesLine                           salesLine;
    AifEntityKeyList                    AifEntityKeyList;
    AxdReturnOrderIn                    AxdReturnOrderIn;
    ReturnReturnOrderInService          rrois = ReturnReturnOrderInService::construct();
    ReturnReturnOrderIn                 ret = new ReturnReturnOrderIn();
    AfStronglyTypedDataContainerList    salesTableList, salesLineList, inventDimList;
    ReturnReturnOrderIn_SalesTable      rroiSalesTable;
    ReturnReturnOrderIn_SalesLine       ReturnReturnOrderIn_SalesLine;
    ReturnReturnOrderIn_InventDim       ReturnReturnOrderIn_InventDim;
   
    AxdReturnOrderIn = ret.getAxdInstance();
    salesTableList = ret.createSalesTable();
    rroiSalesTable = salesTableList.addNew();
    rroiSalesTable.parmCustAccount(_salesTable.CustAccount);
    salesLineList = rroiSalesTable.createSalesLine();
 
    while select salesLine
        where salesLine.SalesId == _salesTable.SalesId
    {
        ReturnReturnOrderIn_SalesLine = salesLineList.addNew();
        ReturnReturnOrderIn_SalesLine.parmItemId(salesLine.ItemId);
        ReturnReturnOrderIn_SalesLine.parmExpectedRetQty(-abs(salesLine.SalesQty));
        ReturnReturnOrderIn_SalesLine.parmInventDimId(salesLine.InventDimId);
        ReturnReturnOrderIn_SalesLine.parmCustAccount(salesLine.CustAccount);
        ReturnReturnOrderIn_SalesLine.parmSalesPrice(salesLine.SalesPrice);
       
        inventDimList = ReturnReturnOrderIn_SalesLine.createInventDim();
        ReturnReturnOrderIn_InventDim = inventDimList.addNew();
        ReturnReturnOrderIn_InventDim.populateFromTable(InventDim::find(salesLine.InventDimId));
    }
   
    AifEntityKeyList = rrois.create(ret);
    return AifEntityKeyList;
}

Scripting with IronPython in cdmaDevTerm

posted Jan 3, 2013, 10:06 PM by d graham   [ updated Feb 27, 2013, 6:02 PM ]

The new version of cdmaDevTerm(2.85 as of writing) features the ability to use iron python and script against cdmaDevLib directly.  Using IronPython finally provides the power and expressiveness required to script cdma flashes for carriers like PagePlus, MetroPCS and others(which I had received a few emails about with the previous xml based scripting system). I'm no IronPython guru, and you don't have to be either to achieve most basic tasks with cdmaDevLib--but the power of IronPython really does mean the only limit is that of your imagination.

There are two scripts included with .2.85: an attempt at a Cricket flashing script(untested), and a script to show a few examples of how to use the scripting system that comes up by default.

Here's the cricket script:

# sample carrier(cricket) flashing
# cdmaDevTerm ironPython script
# copyright 2012 dg, chromableedstudios.com
#
mdn = "0000000000"
min = "0000000000"
user = mdn + "@mycricket.com"
password = "cricket"

cdmaTerm.Connect(phone.ComPortName)#selected port in cdmaDevTerm
cdmaTerm.ModeSwitch(Qcdm.Mode.MODE_RADIO_OFFLINE)
q.Run()
cdmaTerm.SendSpc("000000")
#cdmaTerm.UnlockMotoEvdo() #uncomment for moto nvitem 8035
cdmaTerm.WriteMdn(mdn)
cdmaTerm.WriteMin(min)
cdmaTerm.WriteEvdo(user,password)
q.Run()
cdmaTerm.ModeSwitch(Qcdm.Mode.MODE_RADIO_RESET)
q.Run()
cdmaTerm.Disconnect()


The cricket script shows a few basic ideas too, like how to declare a variable(ex mdn = "0000000000") and that a comment starts with the # character. You may also realize if you read the cdmaDevTerm source that cdmaTerm.thePhone has been aliased to phone and cdmaTerm.Q has been aliased to q because of frequent use in scripts.


#
#cdmaDevTerm sample ironPython script #2
#copyright 2013 DG, chromableedstudios.com
#

#nv = CommandFactory.GetCommand(NvItems.NvItems.NV_SCM_I)
nv = CommandFactory.GetCommand(NvItems.NvItems.NV_MEID_I)
cdmaTerm.Q.Add(nv)
cdmaTerm.Q.Run()
#clear the default system log data
phone.LogData = ""

#this bit seems to show either a badly named method, bug or both
Logger.Add(nv.bytesRxdLessHdlc().ToHexString())
Logger.Add("\r\n")
Logger.Add(nv.bytesRxd.ToHexString())

This script shows how a command object is passed by ref and can be used to retrieve the result of the serial IO from the command(it is returned as a byte[] which has the extension method .ToHexString()).

It also seems to show a bug in the .2.85 release, though I need to track down just where that bytesRxdLessHdlc is actually being used.


These few examples came up in an issue discussion re: nv items on google code.
To write an nv item using the decimal value of the nv item, one can do something like this:

     cdmaTerm.WriteNv(906,"505050617373776F7264".ToHexBytes()) which is using cdmaTerm.WriteNv(ByVal nv As Integer, writeData() As Byte) also I think there is a helper method(GetNvWriteDataByteList) for the cdamDevTerm ui which allows the(slightly hacky) but equivalent:     cdmaTerm.WriteNv(906,"0x505050617373776F7264")

Adding Elysium for Windows 8/WP7 style in Win 7 using WPF with C#

posted Sep 26, 2012, 7:27 AM by d graham   [ updated Jul 1, 2013, 5:32 PM ]

Elysium is a 'Windows 8 style', open source, theme component released under the MIT license which is both free as in beer/soda and free as in speech.  I have decided to include Elysium in CdmaDevTerm(an open source project I develop).

Elysium provides two Windows 8 style themes which come in "Light" and "Dark"

Light:


 and Dark:


http://elysium.codeplex.com/ - is where the project hosting is, it is also available via nuGet now though.

In order to add Elysium to your project, grab the handful of .dll files which come with the example project which is provided by the authors and add them to your project:

Elysium.Theme.dll
Microsoft.Expression.Drawing.dll
Microsoft.Expression.Interactions.dll
Microsoft.Windows.Shell.dll
System.Windows.Interactivity.dll

Then on your xamal file add the name space bellow to the Window and preface the Window tag with the new namespace (metro:Window) :
xmlns:metro="http://schemas.codeplex.com/elysium/theme"

You will also have to change the class the main window inherits from in the code-behind file:
public partial class MainWindow : Elysium.Theme.Controls.Window

Then the last trick is in the main App.xamal you are going to want to add something like this:
<Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Elysium.Theme;component/Themes/Generic.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <!--Bug in .Net 4: http://connect.microsoft.com/VisualStudio/feedback/details/555322/global-wpf-styles-are-not-shown-when-using-2-levels-of-references-->
            <Style TargetType="{x:Type Window}"/>
        </ResourceDictionary>
    </Application.Resources>

The theme may be changed by calling for example:

Elysium.Theme.ThemeManager.Instance.Dark(Elysium.Theme.AccentColors.Lime);

which accepts as a parameter your choice of accent color.

techfail: shopping for home free <Vspan>, aqua teen hunger fail, and career openings: web developer...

posted Aug 10, 2012, 5:10 PM by d graham   [ updated Jul 4, 2013, 8:07 AM ]

Sometimes tech fails...and on with the fail* (a mini homage to thedailywtf.com):




*note: I document the fail not to blame, I just think it's interesting when software manifests itself in strange/funny ways

How to write MDN/MIN with cdmaDevTerm

posted Jul 29, 2012, 5:50 PM by d graham   [ updated Aug 4, 2012, 8:54 AM ]


How to write MDN/MIN with cdmaDevTerm:

CdmaDevTerm is a Free open source software project released under the GPL V3. It can be downloaded here: http://code.google.com/p/cdmaworkshoptool/

1. Connect to the QCDM port of the phone (note: some phones will present two ports a QC and an AT, some phones will share a single port for both and may require an AT command like AT$QCDM etc to change modes) (You can test if the port is the right port by the "read id 0x00" button, to which the phone should respond with some build information and date ie QC diag verno f)
2. Change to mode offline (you should see the # of bars for signal disappear because the radio subsystem is no longer in an online state and connected to the phone)
3. For a verizon phone send spc 000000 or for another carrier find your spc and sent that by typing the custom spc in the box by #4
4. Read the spc and the result should appear in box by 4 to verify 'locked' nv items are unlocked
5. Read the nam information (or skip this step if you are bold or don't care)
6. Type MDN with no spaces or symbols (ex: 1237773333) and press the "W" button to write
7. Type MIN with no spaces or symbols (ex: 1237773333) and press the "W" button to write
8. Change the "mode" combobox to "reset" then press the button "Mode Change" from step 2 again

1-10 of 25