March 14, 2013

Exporting data to Excel from axapta x++

Exporting data to Excel from axapta x++





Hi All!
Sometimes we need to export data from Microsoft Dynamics AX to Excel using axapta x++ code and we don't know how to do this...
Exists some differents ways to do this, but I think the best way is using the SysExcel class of Dynamics AX and its related.
The only problem I found using this class... is that it can not be used in a batch process.
Sample code:


static void TheaxaptaCreateExcel(Args _args)
{
   SysExcelApplication  xlsApplication;
   SysExcelWorkBooks    xlsWorkBookCollection;
   SysExcelWorkBook     xlsWorkBook;
   SysExcelWorkSheets   xlsWorkSheetCollection;
   SysExcelWorkSheet    xlsWorkSheet;
   SysExcelRange        xlsRange;
   CustTable            custTable;
   int                  row = 1;
   str                  fileName;
   ;
   //Filename
   fileName = "C:\\Test.xlsx";
   //Initialize Excel instance
   xlsApplication           = SysExcelApplication::construct();
   //Open Excel document
   //xlsApplication.visible(true);
   //Create Excel WorkBook and WorkSheet
   xlsWorkBookCollection    = xlsApplication.workbooks();
   xlsWorkBook              = xlsWorkBookCollection.add();
   xlsWorkSheetCollection   = xlsWorkBook.worksheets();
   xlsWorkSheet             = xlsWorkSheetCollection.itemFromNum(1);
   //Excel columns captions
   xlsWorkSheet.cells().item(row,1).value("Account Num");
   xlsWorkSheet.cells().item(row,2).value("Name");
   row++;
   //Fill Excel with CustTable AccountNum and Name fields (only 20 records)
   while select custTable
   {
      if(row == 20)
        break;
      xlsWorkSheet.cells().item(row,1).value(custTable.AccountNum);
      xlsWorkSheet.cells().item(row,2).value(custTable.Name);
      row++;
   }
   //Check whether the document already exists
   if(WinApi::fileExists(fileName))
      WinApi::deleteFile(fileName);
   //Save Excel document
   xlsWorkbook.saveAs(fileName);
   //Open Excel document
   xlsApplication.visible(true);
   //Close Excel
   //xlsApplication.quit();
   //xlsApplication.finalize();
}

-Harry

March 12, 2013

How to Connect the Host Hard Drive to a VirtualBox OS

How to Connect the Host Hard Drive to a VirtualBox Guest OS

VirtualBox from Oracle is an amazing and free application if you like testing different operating systems without messing up your original operating system or Master Boot Record (MBR). VirtualBox is also useful if you like to test operating systems before their final release. 
However, most people want to connect their host hard disk drives to the guest operating system. For your information, the host OS is the operating system you’re actually using, while the Guest OS refers to the OS virtually installed inside VirtualBox. 

We’ve used Windows 7 as the host operating system and Windows XP as the guest OS. Let’s begin.

Step 1 : Install Guest Additions

1start How to Connect the Host Hard Drive to a VirtualBox Guest OS

First off, you need to start up the operating system you want to connect your hard disk drives to. Choose your OS and click the start button. When the OS is ready, click Devices  

> Install Guest Additions.

2installguest How to Connect the Host Hard Drive to a VirtualBox Guest OS.

Clicking this will prompt the Guest Addition setup menu on Windows XP (Guest OS). Install the guest addition and reboot your guest OS as required.

3guestadditionsetup How to Connect the Host Hard Drive to a VirtualBox Guest OS

Step 2 : Share Folder

When installed and rebooted, click Devices again and choose Shared Folders.

4 How to Connect the Host Hard Drive to a VirtualBox Guest OS

A box will open. Simply click the add icon (+ sign) on the right. From the Folder Path pull down menu, click Other.

5addshare How to Connect the Host Hard Drive to a VirtualBox Guest OS

A folder browser (similar to Windows Explorer) will open up. From here, you can select any hard drive or any folder inside a hard drive. Upon selecting click OK.

6select How to Connect the Host Hard Drive to a VirtualBox Guest OS

Step 3 : Connect to Shared Folder

Now, VirtualBox has shared the selected hard drive/folder (in our case, E drive) with the guest OS. You now need to access it. To do so, go to My Computer and in Other Places, right click on My Network Places and choose Map Network Drive.

7map network drive How to Connect the Host Hard Drive to a VirtualBox Guest OS

Here in the Drive box, you have to select a Drive letter for the folder/hard disk drive you’re connecting to. You can choose randomly or select as your choice from the pull down menu. From the Folder box, click the browse button and click the plus sign on the left of ‘VirtualBox Shared Folders’ and then ‘\\vboxsvr’.
This will show you a list of folders or hard drives shared with the guest OS. Click the one you want to connect to and click OK. On the Map Network Drive, make sure the Reconnect at logon checkbox is checked if you want to automatically connect to this drive each time your guest OS starts up.

8add How to Connect the Host Hard Drive to a VirtualBox Guest OS

Step 4 : Access Shared Folder

You’re done! Now, go to My Computer and you’ll be able to access the hard disk drive of your computer right from the guest operating system installed inside VirtualBox.
9network drives How to Connect the Host Hard Drive to a VirtualBox Guest OS

I hope it was easy for you to follow this tutorial and now you are able to access your hard disk and install any software from your local hard disk drive.

-Harry

March 09, 2013

Installing Microsoft SharePoint Foundation

Installing Microsoft SharePoint Foundation

Note: Microsoft SharePoint Foundation (MSF) can be only installed on a 64-bit hardware

Recently i installed MSF on my local system , I just sharing my exp about how to install MSF. Installation and configuration of Microsoft SharePoint Server 2010. We will complete this tutorial in four main steps as:
      1.     Hardware and Software requirements
      2.     Pre-requisites
      3.     Installation
      4.     Post Setup Configuration



1.     Hardware and Software requirements

Microsoft SharePoint Foundation (MSF) can be only installed on a 64-bit hardware and Microsoft provides the detailed hardware and software requirements in the following TechNet article.This is the new name for Windows SharePoint Services V4.
http://technet.microsoft.com/en-us/library/cc262485(office.14).aspx#section2

2.     Pre-requisites

In this release Microsoft has included a Prerequisite Installer (Preparation Tool) which will take care of all the pre-requisites which are required to setup a SharePoint Server.The tool would connect to Internet to download and install any prerequisites as well as enabling and configuring any Windows features and roles required by setup. Also the administrator can override this if the necessary software is already present in the hard disk or in a network location.
The Preparation Tool executable, Prerequisiteinstaller.exe, is located at the root of the setup folder. It can also be launched from the setup splash screen.When you run the Prerequisiteinstaller.exe /? , the following screen is shown which will list the command-line parameters that can be used with this executable.



You can also install the pre-requisite from a folder if it is already downloaded from the internet and the SharePoint server doesn’t have internet access.

C:\setup\prerequinstaller.exe /IDFX:c:\GenevaFramework.amd64.msi

It is possible to include multiple file location parameters for the different components. In the following example, we've also added local file location parameter for both the IDFX and Sync framework:

C:\setup\prerequinstaller.exe /IDFX:c:\GenevaFramework.amd64.msi /SYNC c:\sync.msi

To install the Pre-requisites, run the prerequisiteinstaller.exe in the installation media of SharePoint or run the Splash which will provide you the following screen.



Click on the “Install Software prerequisites” option which will start the installation of the necessary pre-requisites.



You can get the download link for each of the required product when you click Learn more about these prerequisites in the above screen.

Click Next will start the download and installation of pre-requisites from the internet.



Accept the EULA and click Next and this will start the installation of the required product.



Some of them may require a Restart and the pre-requisite installer will continue once the system is restarted.



There is a link called “Review the log file” in the above screen which will help to find out any issue with the installation of the Pre-requisites.Once the installation is complete, you will see the following screen and it means that all the required Pre-requisites are installed and configured on the server and you can start the installation of SharePoint.

Installation of SharePoint Server 2010

When installing SharePoint Foundation, there are primarily three setup options.Following is a short description of each type of installation:

Standalone Installation:

  SQL Server 2008 Express Edition is the database type automatically installed (instead of Windows Internal Database/SQL Server 2005 Embedded Edition used in Windows SharePoint Services 3.0).   This is almost a “one-click” installation, no questions are asked during setup or during Post Setup Configuration Wizard (PSConfig)
A Web application and team site collection are automatically created in the newly created farm. The search service is started automatically.
Cannot add servers to join a farm.
When the installation is complete, the browser opens taking you to a newly created site collection. Installer is not prompted for farm passphrase, it is automatically generated.
Standalone Same as Basic installation, except it allows changing installation directory location. Complete SQL Server 2005 SP2/SQL Server 2008 is the database type, not installed by setup.
Administrator can pick whether or not to create a site and the site template to use.
Prompted for farm passphrase during PSConfig phase of installation. The farm passphrase will be discussed later in this document.
To run setup you must at minimum be a local administrator on the computer where SharePoint Server 2010 is installed.



Run the Splash from the setup media which will show the above screen and click on “Install SharePoint Foundation” which will start the installation process.



-Harry

March 08, 2013

Installing Oracle Database 11g Release 2

Step-by-step instructions for installing Oracle Database 11g Release 2

Here are step-by-step instructions for installing Oracle Database 11g Release 2 on Windows 7. It’s provided in response to questions posted on my step-by-step instructions for installing Oracle 11gR1 on Windows 7. For reference, I posted the former because it didn't work without intervention. I hadn't updated step-by-step instructions because Oracle Database 11g Release 2 has always worked for me when installing on Windows 7.
A number of students and blog readers have mentioned that it didn't work for them. My guess is that they had configuration issues within the Windows 7 environment. There are some Windows 7 configuration caveats before you perform this installation, and they are:
Windows 7 Configuration Steps
  1. Make sure you have at least 3 GB of memory on your Windows PC, or that you can allocate 4 GB of memory to your virtual machine (the latter typically requires 8 GB of real memory to avoid extensive disk caching of memory).
  2. Install Oracle’s SJDK and run time for Java 6 or 7 on Windows 7 (I installed Java 7). Although either work with the database, you need the Java 6 SDK 32-bit version (at least SJDK 1.6.0_4) for Oracle SQL Developer. This means you need to download the 32-bit version even when you’re installing the 64-bit Oracle Database 11g version.
  3. Disable Microsoft’s User Access Controls (UAC). I blogged about a set of Windows 7 gripes, and the second point shows you the screen shots that let you disable UAC on Windows 7.
  4. Configure your C:\Windows\System32\drivers\etc\hosts file. Use lines 1 through 3 when you’re using a DHCP IP address, and lines 1 through 4 when you’re using a static IP address.  Please note that the hostnameneeds to be lowercase.
1 127.0.0.1 localhost 
2 ::1 localhost
3 127.0.0.1 agarwalax theaxapta.blogspot.com
4 172.26.126.131 agarwalax theaxapta.blogspot.com 



  1. Create a user account name that doesn’t have a white space, like McLaughlinM in the screen shots, and assign it Administrator privileges.
  2. The Oracle Enterprise Manager (OEM) uses port ranges above 5,000, which according to Microsoft requires that you set MaxUserPort key in the Windows Registry. You can find more details at this Microsoft Support page. Personally, I haven’t found this necessary and after adding it to please somebody without setting it everything ran fine in Windows 7.

Registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Value Name
MaxUserPort

Value Type
DWORD

Value Data
65534

Value Range
5000-65534 (decimal)

Value Default
0×1388 (5000 decimal)

Description
This parameter controls the maximum port number that is used when a program requests any available user port from the system. Typically, ephemeral (short-lived) ports are allocated between the values of 1024 and 5000 inclusive. After the release of security bulletin MS08-037, the behavior of Windows Server 2003 was changed to more closely match that of Windows Server 2008 and Windows Vista. For more information about Microsoft security bulletin MS08-037

Oracle 11g Release 2 Installation Steps

  1. The Oracle Database 11g Release 2 files are broken down into two zip files on the Oracle site. That means you need to download both files, and then expand them into an installation directory. I called my installation directory C:\OracleInstall, but you can call it whatever works for you. Here’s a screen shot of the directory after expanding both compressed files (done with WinZip 15).

You should notice that the two expanded compressed files put everything into a database directory (or folder). Within the installation folder (C:\OracleInstall\database), you double click on the oui icon to launch (start) the Oracle Universal Installer. It’ll open a command prompt that may dwell on the screen for a few seconds up to maybe fifteen seconds.


  1. It’s a good idea to provide an email address for security updates no matter what. You can unchecked the box if you don’t want updates via Oracle Support Services. Click the Next button to continue.



  1. Most developers want to Create and configure a database. If that’s your desire, leave the default radio button checked. Click the Next button to continue.



  1. Most developers install their test instance on a desktop or laptop. If that’s your desire, leave the defaultDesktop Class radio button checked. Click the Next button to continue.



  1. These are default settings and generally the easiest to use. I’d suggest you change the Character Set drop down to Unicode. Then, enter a password twice. Oracle requires that you use at least one capital letter and one number in a 6 character or more long password. Click the Next button to continue.



  1. The next screen is a progress bar that checks for prerequisites. You shouldn't have to do anything here because it automatically advances you to the next dialog screen. This generally takes less than a minute to run but can take two or so. If you’re much beyond 3 minutes there may be a resource problem with your Windows PC or virtual machine.



  1. This shows you all the selected values for the installation. Unless you want to abort the installation, click the Finish button to proceed.



  1. This screen is the main progress bar, and you’ll be here somewhere between 5 and 10 minutes. The downside is that there are some dialog that will popup during this phase and you need to authorize them, so it’s a bad time to take a break.



  1. The first popup screen requires you to authorize the Java run time to call home. You should click the Allow Access button to proceed.



  1. When the progress bar starts configuring the instance, failures can occur. The first may occur during the network configuration, which typically happens if you didn't preconfigure the hosts file. You don’t need to do anything but watch here unless the installer triggers an error.



  1. The following progress bar is launched by the Oracle Database Configuration Assistant. It typically runs without a problem. You don’t need to do anything but watch here unless the installer triggers an error. This takes a few minutes, and unfortunately requires you to stick aroung to again authorize Java.



  1. The second popup screen requires you to authorize the Java runtime to call home. You should click theAllow Access button to proceed.



  1. The third and last popup screen asks you to whether you want to open other scheme. Generally, you should click the OK button to proceed.



  1. The next dialog shows you that the network and database instances are configured. It’s also running the OEM (Oracle Enterprise Manager) installation. You can wait here but it won’t be a long wait.



  1. This is the last dialog and says you’ve installed Oracle Database 11g Release 2 successfully. You can theClose button to complete the installation.

-Harry