Calendar

July 2009
SunMonTueWedThuFriSat
 << < > >>
   1234
567891011
12131415161718
19202122232425
262728293031 

Announce

Who's Online?

Member: 0
Visitor: 1

Microsoft Dynamics Snap for Dynamics AX 2009
Microsoft Dynamics Snap for Dynamics AX 2009
 

 Downloads & Files



Source Code Offline Expense
source code, 565K, uploaded Oct 16 2008 at 7:21 AM - 702 downloads
Source Code Business Data Lookup
source code, 883K, uploaded Oct 16 2008 at 7:21 AM - 839 downloads
Source Code Employee Table Patch for Demo VPC
source code, 124K, uploaded Nov 27 2008 at 7:11 AM - 191 downloads

Release Notes

This release contains the following snap-in applications for use with Microsoft Dynamics AX 2009 and Microsoft Office 2007.

Offline Expense - This snap-in enables expenses to be entered in Excel while disconnected from the corporate network, and then posted to Dynamics AX at a later time. This snap-in uses WCF-based services and LINQ to retrieve data from Dynamics AX, and uses the Application Integration Framework, or AIF to send business documents to Dynamics AX.

Business Data Lookup (BDL) - This snap-in enables information workers to access data from Dynamics AX from within Excel, Word and Outlook. This snap-in is an upgrade of the BDL snap-in that was distributed with Microsoft Dynamics AX 4.0.

These applications require .Net 3.5, Microsoft Office 2007, Microsoft Visual Studio 2008 and Microsoft Dynamics AX 2009. Each snap-in contains a document describing the basic architecture, functional footprint, and deployment steps for exploring the sample code.

We are planning to provide some further documentation on the techniques used to build the new Expense Entry snap-in which employes a WCF-based query service and the LINQ provider. We welcome your feedback and questions on this forum.
14 Feb 2009
Admin · 43 views · 1 comment
Webservice Example

Web Service Basic

Introduction
We all talk about webservices, webservices can do this and webservices can do that. But when we are asked to make one, we hesitate. Maybe it's because we never made a webservice before, and all the time playing with Webforms and Windows Forms or even Console Applications. By the way, I love Console applications. In this article, I will show you how to create a simple webservice that is consumed by a Console application client.
Making the WebService:
First, start your Visual Studio .NET, and in the project type, select ASP.NET WebService. In the left pane, choose the language of your choice. In this example, I will be using Visual C#.NET. Once you select the project, a page will appear which will be more like a design page, switch to its code view. In the code view, you can see lot of comments and C# code already written for you. You will also see that at the bottom, there is a method HelloWorld which is written for you by default, so you can test your service and of course say hello to the world. After removing the unwanted code and comments, your code will look like this:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
namespace WebServiceExample
{
public class Service1 : System.Web.Services.WebService
{
public Service1()
{

InitializeComponent();
}

// Add the Description Attribute so you
// will know the purpose of your WebService
[WebMethod(Description="This Method prints HelloWorld")]
public string HelloWorld()
{
return "Hello World";
}
}
}


Let's dig into this small code. [WebMethod] Attribute denotes that this method will be used by the clients, also this method has to be public in order for a client to use it. Description inside the WebMethod Attribute just gives the method more meaning. Don't worry about the InitializeComponent() method since it's written by default.
Running the WebService:
OK, now you have made your first kick ass WebService (without even writing a single line of code). Let's run it and check whether it gives the correct result or not. In the Solution Explorer, right click on the .asmx file, and select View in Browser


Once you click on "View in Browser", the next screen you will see will be something like this:

I have erased most of the stuff, so you can only see the method that you need in this example. Below, you can see the method HelloWorld and the description you wrote for the method.
Now, click on the HelloWorld method. I don't want to scare you with all the SOAP and HTTP code produced, so I am only going to paste the screen shot which will be relevant to this example.

Alright, so far so good. Now, just press the Invoke button to see the result of your method named HelloWorld().

This is cool. You have just tested your first webservice and it ran since you didn't coded it. I know what you are thinking right now. Is the client going to see the result like this strange format (this is XML format). Well, of course not. That's why you need to make a Proxy class which consumes this service.
Making a Proxy Client:
Let's make a Console application which consumes this service. You can use any language and platform to consume this service, that's the purpose of XML WebService. Now, this procedure requires some mouse clicking :). So I will write down the steps instead of pasting the screen shots.

  • Start a new project which will be a Console Application in Visual C#.NET.
  • Once you see the code view in the Console application, right click on the project name from the Solution Explorer. Remember that project name will be written in bold.
  • Click on "Add Web Reference".
  • Paste the URL of your WebService. You can get the URL of your WebService when you view your webservice in IE or any other browser.
  • Click GO.
  • Your webservice will be loaded. In the Web Reference Name textbox, write "MyService" and click Add Reference.
  • You will see that the web reference has been added in your Solution Explorer, meaning that webservice is ready to kick some butt.

Now, all you have to do is to make the instance of the WebService class using the reference name that you provided, which is "MyService".

using System;
namespace MyClient
{
class Class1
{

[STAThread]
static void Main(string[] args)
{
// Make an instance of the WebService Class
// using the Web Reference you provided
MyService.Service1 service = new MyService.Service1();
// Assign message what ever is returned
// from HelloWorld in this case "HelloWorld"
string message = service.HelloWorld();
// Prints out the message on the screen
Console.WriteLine(message);
}
}
}

And that's it. You use the webservice class just like any other class. Something you need to keep in mind is that if you decide to make a new method in your webservice and want to make it available to the client, then always remember to build your webservice solution so that the assembly can be updated. If you don't build your webservice, you won't be able to see the methods on the client side.

14 Feb 2009
Admin · 33 views · Leave a comment
Invent Movement Journal Creation and Posting
static void MovementJournalImportExcel(Args _args)
{
     InventJournalTrans         inventJournalTrans;
     InventDim                  inventDim;
     InventJournalTable         inventJournalTable;
     InventJournalCheckPost     journalCheckPost;
     InventJournalId            journalId;
     journalTableData           journalTabledata;
     InventBatch                inventBatch;
     InventBatch                localInventBatch;
     NumberSeq                  numberSeq;
     NumberSequenceReference    numberSequenceReference;
     InventSerial               inventSerial;
     InventSerial               localinventSerial;
     int j,countno=0,i,k;
     real Scarp;
     FilenameOpen    filename;

     Sysexcelapplication excelapp=sysexcelapplication::construct();
     sysexcelworksheet excelworksheet;
     sysexcelrange excelrange;
     sysexcelcells excelcells;
    // comvariant cellvalue=new comvariant();
    ;

    // Creating Journal Header
    inventJournaltable.initValue();
    inventJournalTable.JournalNameId = 'ERecover';
    numberSeq = new NumberSeq();
    numberSequenceReference = InventParameters::numRefInventJournalId();
    numberseq = NumberSeq::newGetNum(numberSequenceReference);

    inventJournalTable.JournalId = numberseq.num();
    inventJournalTable.Description = InventJournalName::find(
inventJournalTable.JournalNameId).Description;
    inventJournalTable.insert();


    excelapp.workbooks().open('C:\\Documents and
Settings\\asrivastava\\Desktop\\ElectronicData_OnlyWstatus_10032007.xls');
    excelworksheet=excelapp.worksheets().itemFromNum(1);
    excelcells=excelworksheet.cells();

    // Creating Unit Numbers
     for(i=301;i<=5600;i++)
     {
        inventBatch.clear();
        inventBatch.initValue();
        inventBatch.itemId = excelcells.item(i,11).value().bStr();
        inventBatch.inventBatchId = excelcells.item(i,1).value().bStr();
        localinventBatch = InventBatch::find(inventBatch.inventBatchId,
inventBatch.itemId);

        if(!localinventBatch)
        {
            inventBatch.OakSerialUnit = excelcells.item(i,2).value().bStr();
            inventBatch.insert();
        }
     }

    //Creating Appartment Numbers
     for(k=1;k<=648;k++)
     {
        inventSerial.clear();
        inventSerial.initValue();
        inventSerial.InventSerialId = excelcells.item(k,8).value().bStr();
        inventSerial.ItemId = excelcells.item(k,11).value().bStr();
        localinventSerial = InventSerial::find(inventSerial.InventSerialId,
inventSerial.ItemId);

        if(!localInventSerial)
        {
            inventSerial.ProdDate = systemDateGet();
            inventSerial.insert();
        }
     }

     // Creating Journal Lines
     for(j=301;j<=5600;j++)
     {
        inventJournalTrans.clear();
        inventJournalTrans.initValue();
        inventJournalTrans.TransDate = systemDateGet();
        inventJournalTrans.LedgerAccountIdOffset = "99999";
        inventJournalTrans.JournalType = InventJournalType::Movement;
        inventJournalTrans.JournalId = inventJournalTable.JournalId;
        numberSeq = new NumberSeq();
        numberSequenceReference =
InventParameters::numRefInventJournalVoucherId();
        numberseq = NumberSeq::newGetNum(numberSequenceReference);

        inventJournalTrans.Voucher     = numberseq.num();
        inventJournalTrans.ItemId      = excelcells.item
(j,11).value().bStr();
        // defaulting branch and item name
        inventJournalTrans.CostAmount  = InventTable::find(
inventJournalTrans.ItemId).inventTableModuleInvent().Price;
        inventJournalTable             = InventJournalTable::find(
inventJournalTrans.JournalId);
        inventDim.InventLocationId     =  excelcells.item
(j,10).value().bStr();
        inventDim.inventBatchId        = excelcells.item
(j,1).value().bStr();
        inventDim.inventSerialId       = excelcells.item
(j,8).value().bStr();
        inventJournalTrans.InventDimId =
inventDim::findOrCreate(inventDim).inventDimId;
        inventJournalTrans.Qty         = 1;
        inventJournalTrans.AdjustmentNotes = "Initial Data Load";
        inventJournalTrans.LineNum = j;


        inventJournalTrans.insert();
     }


    excelapp.workbooks().item(1).saved(true);
    excelapp.workbooks().close();

    // Posting Journal
    journalTableData = JournalTableData::newTable(inventJournalTable);
    journalTableData.updateBlock
(JournalBlockLevel::InUse,JournalBlockLevel::None);
    if (!infolog.num(Exception::Error))
    {
        infolog.clear(0);
        journalCheckPost =
InventjournalCheckPost::newJournalCheckPost(JournalCheckPostType::Post,InventJournalTable);
        journalCheckPost.parmAutoBlock(true);
        journalCheckPost.run();
    }
}
16 Jan 2009
Admin · 57 views · Leave a comment
Using ADO for interfacing AX with an external database
f we need to interface any external database with Dynamics AX, we can achieve this task by using ADO and its AX available classes:CCADOConnection, CCADORecordSet, CCADOFields, CCADOField andCCADOCommand. Here an example:

static void ADOTestJob(Args _args)
{CCADOConnection     ccConnection;
CCADOCommand        ccCommand;
CCADORecordSet      ccRecordset;
CCADOFields         ccFields;
str                 st;
str                 data1;
int                 data2;
;
ccConnection = new CCADOConnection();// Setting the connection string
ccConnection.connectionString(StrFmt('Provider=SQLOLEDB.1;Persist Security Info=False;User ID=%3;Password=%4;Initial Catalog=%2;Data Source=%1'
'servername'  // Server's IP or name,
 'database'    // Database or catalog
'user'        // Username
'pwd'         // Password));// Open the connection
ccConnection.open();// Preparing the query
st = "SELECT * FROM mytable";// Recordset object creation
ccRecordset = new CCADORecordSet();// Executing the querycc
Recordset.open( st, ccConnection );// Reading data
while (!ccRecordset.EOF())
{
ccFields = ccRecordset.fields();// We can access fields either by name or by Index
data1 = ccFields.itemName("FIELD1").value();
data2 = ccFields.itemIdx(1).value();
info(strfmt("Data %1, %2", data1, data2));// Read next record
ccRecordset.moveNext();
}// Closing the connection
ccRecordset.close();
ccConnection.close();}


If we need to execute something (an UPDATEDELETE, etc.), we can use the CCADOCommand:

void ExecuteSQLExt(str sql){// Creating the ADO Command objectccCommand = new CCADOCommand();// Associate it with an existing opened connectionccCommand.activeConnection(ccConnection);// Executing the commandccCommand.commandText(SQL);ccCommand.execute();}


NOTE: For working with ADO constants like cursor types (adOpenForwardOnly, adOpenKeyset, adOpenDynamic, adOpenStatic), we only need to include the macro CCADO (#CCADO) where they are defined.
03 Jan 2009
Admin · 48 views · Leave a comment
Sendning Report as an attachment

void SendingReportasMail(UserId userid,EmplTable empltable)
{
    #SysMailer
    SysMailer mailer;
    SysMailerAddressField tos;
    SysMailerAttachments attachments;
    InteropPermission interopPermission;

    SysReportRun            reportRun;
    printJobSettings p1,printJobSettings;
    Args _args;

    SysINetMail m = new SysINetMail();
    str fileName = 'C:\PurchaseOrders.pdf';
    str relayServer;
    int portNumber;
    str userName;
    str password;
    boolean NTLM;
    SysEmailParameters parameters      = SysEmailParameters::find();
    if (parameters.SMTPRelayServerName)
        relayServer =   parameters.SMTPRelayServerName;
    else
        relayServer = parameters.SMTPServerIPAddress;
    portNumber =  parameters.SMTPPortNumber;
    userName =  parameters.SMTPUserName;
    password = SysEmailParameters::password();
    NTLM = parameters.NTLM;
    CodeAccessPermission::revertAssert();
    WinAPI::deleteFile(fileName); //For Deleting the saved file
    try
    {

        _args = new Args();
        _args.parm(userid);
        _args.name(reportstr(WI_EmailPurchDetailsNew));
        reportRun = classFactory.reportRunClass(_args);
        reportRun.query().interactive(false);
        reportRun.report().interactive(false);

        printJobSettings =reportrun.printJobSettings();
        printJobSettings.format(PrintFormat::PDF);
        reportRun.setTarget(PrintMedium::File);
        printJobSettings.fileName(fileName);  //For Saving the file in C Drive
        reportRun.run();

        interopPermission = new InteropPermission(InteropKind::ComInterop);
        interopPermission.assert();
        mailer = new SysMailer();
        CodeAccessPermission::revertAssert();
        mailer.SMTPRelayServer(relayServer,portNumber,userName,password,NTLM);
        mailer.subject("Purchase Order Details");
        mailer.fromAddress("test@gamil.com","Naresh");
        tos = mailer.tos();
        attachments=mailer.attachments();
        attachments.add(fileName);      //Attaching the Saved File
        tos.appendAddress(empltable.Email);
        mailer.htmlBody("Purchase Orders Details");
        mailer.sendMail();

        WinAPI::deleteFile(fileName); //For Deleting the saved file
   }
   catch (Exception::Error)
   {
         infolog.clear(0);
         info("Sending Mail Failed");
   }

}

29 Oct 2008
Admin · 111 views · Leave a comment

1, 2, 3, 4, 5, 6, 7  Next page