• Partner Technical Services Blog

    Open XML SDK: Merging Documents

    • 3 Comments

    (This post courtesy Natalia Efimsteva)

    Office Open XML (OpenXML) is a zipped, XML-based file format developed by Microsoft for representing spreadsheets, charts, presentations and word processing documents. The Office Open XML specification has been standardized by ECMA (ECMA-376) [wiki]. Open XML is the native format for MS Office 2007/2010.

    Open XML allows you to manipulate MS Office files in your own and desired way. For example, you can create .docx files programmatically on the server side (which wasn’t recommended for binary MS Office formats like .doc).

    The Open XML SDK 2.0 for Microsoft Office is built on top of the System.IO.Packaging API and provides strongly typed part classes to manipulate Open XML documents. The SDK also uses the .NET Framework Language-Integrated Query (LINQ) technology to provide strongly typed object access to the XML content inside parts of Open XML documents.

    The Open XML SDK 2.0 simplifies the task of manipulating Open XML packages and the underlying Open XML schema elements within a package. The Open XML Application Programming Interface (API) encapsulates many common tasks that developers perform on Open XML packages, so you can perform complex operations with just a few lines of code.

    So now let’s discuss an often-asked question like programmatically merging Open XML documents. It’s not a very complicated task, but we need to think about some things.

    First of all, let’s look at the internal .docx structure. Below is an unzipped view:

    clip_image002

    The OpenXML SDK 2.0 contains a great tool – Document Explorer – which allows us to view XML markup as well as .Net representation of a code to construct this markup:

    clip_image004

    So when we’re merging documents we need not only merge content (text) but also styles of the document and other formatting settings.

    Open XML SDK operates on Open XML elements like paragraphs rather than logical (for user) objects like pages, content, and so on.

    But we have tool which can make our life easier – DocumentBuilder from PowerTools for Open XML. Another way is to use altChunk. This element specifies a location within a document for the insertion of the contents of a specified file containing external content to be imported into the main WordprocessingML document. Differences between these two approaches described in a post “Comparison of altChunk to the DocumentBuilder Class”. We will talk further about the DocumentBuilder approach.

    Use of the DocumentBuilder util is really very simple:

    using (WordprocessingDocument part1 = WordprocessingDocument.Open(@"Doc1.docx", false))

    using (WordprocessingDocument part2 = WordprocessingDocument.Open(@"Doc2.docx", false))

    {

    List<Source> sources = new List<Source>();

    sources.Add(new Source(part1, true));

    sources.Add(new Source(part2, true));

    DocumentBuilder.BuildDocument(sources, "MergedDoc.docx");

    }

    The most interesting is the second argument of the constructor of Source class. Using the keepSections argument appropriately allows you to precisely control which sets of section properties (visual formatting in other words) are moved from source documents into the destination document. For more information please see How to Control Sections when using OpenXml.PowerTools.DocumentBuilder post.

    We have two documents:

    Doc1.docx

    clip_image005

    Doc2.docx

    clip_image006

    DocumentBuilder will do all of the work for you for merging the two documents preserving:

    • formatting
    • page numbers (including Link Sections)
    • headers and footers
    • orientation
    • and so on.

    That’s magic!

    clip_image008

    Additional Resources

  • Partner Technical Services Blog

    Capture a Windows® Image from a Reference Computer Using Capture Media—for IT Pros

    • 2 Comments

    (This post courtesy of Simone Pace)

    In order to use System Center Configuration Manager 2007 to distribute the Windows 7 operating system to our managed clients, we need to provide to the OS bits somehow to the site server. One of the methods we can use is capturing a Windows 7 WIM image from a previously prepared reference computer.

    System Center Configuration Manager 2007 offers standard and easy ways to deploy software in our IT Infrastructure. One of the most relevant features we can take advantage of is the highly customizable Operating System Deployment capability built in the product.

    The Windows Vista® and Windows 7 new WIM image format further simplifies OS distribution by being independent from the destination client system’s hardware, so that we can use a single image to target different computers and keep our image repository less complex and more easily managed. This post shows an example of steps we can follow to successfully capture a WIM image of Windows 7 Ultimate Edition x64 from a reference computer.

    Note: Further posts will follow that illustrate the specific tasks required to upgrade a Windows XP computer.

    Testing lab description screenshots and computer names used in this article refers to a Virtual scenario running on a Hyper-V R2 host:

    • Domain: contoso.com (single site)
    • All Servers are Windows 2008 R2 Enterprise servers.
    • Server CON-001
    • SCCM with almost all roles installed
    • SQL Server 2008
    • Windows Automated Installation Kit 2.0
    • WDS Transport Server role installed
    • Server CON-002
    • Active Directory Domain Controller role installed
    • DNS Server role installed
    • DHCP Server role installed
    • SCCM Primary Site: C01
    • Reference client is a Windows 7 Ultimate edition x64 clean setup

    1. Create a Capture Media iso file.

    The iso image we are creating in this section will be used to boot the reference machine and start the OS wim image creation sequence.

    a. Log on CON-001 and open the Configuration Manager console.

    b. Go to Task Sequences node.

    c. Click on “Create Task Sequence Media” in the action panel.

    d. Select Capture Media and click next on the welcome page.

    clip_image002

    e. On the “Media file” click Browse, select the folder where you are going to save the media iso file, and give it a name (for example MediaCapture), click Next.clip_image004

    f. On “Boot Image” click Browse, and select the boot image suitable for your reference computer.

    Note: Two boot images (x86 and x64) are automatically added when you install WDS role in the system.

    g. On Distribution Point leave \\CON-001 (or select you preferred DP), click Next.clip_image006

    h. Review the summary and click Finish.

    i. The server starts building the iso image.

    clip_image008clip_image010clip_image012

    j. Click Close to close the wizard.

    2. Prepare the reference computer.

    a. Log on CON-Ref7Client with user Administrator account

    b. Check the following requirements

    i. The computer must be a workgroup member.

    ii. The local Administrator password must be blank.

    iii. The local system policy must not require password complexity.

    iv. Apply the latest Service Pack and updates.

    v. Install the required applications.

    3. Capture the image using the Capture Media.

    a. Capture the MediaCaputer.iso you created in Step 1 in the Virtual DVD of the reference PC (if is a VM), or

    b. Burn the MediaCapture.iso on a DVD and insert it in the computer.

    c. Boot the reference computer normally.

    d. Start the autoplay DVD and launch the Capture Image Wizard.

    clip_image013

    e. Click Next.

    f. Set the path where you want to save the wim file, give the image a name, and insert the appropriate credential to access the path and write on it.
    clip_image014

    g. Click Next.

    h. Fill in the required data in the Image Information window.

    clip_image015

    i. View the summary and launch the capture by clicking Finish.

    clip_image016

    j. The program will start executing the sysprep phase.

     clip_image017

    k. After sysprep, the computer will restart in WinPE to start the capture.

    clip_image018

    l. (Reboot).

    clip_image020

    m. Computer restarts in WinPE and starts the Capture.

    clip_image021

    n. Capturing first Partition (1-2)

    clip_image022

    o. And capturing second partition (2-2).

     clip_image023

    Note: The number of partitions captured depends on the reference PC’s disk partitions. In the case shown, the VM had a 100Mb partition for BitLocker® capability (Partition 1 of 2).

    p. When finished, press OK to quit and restart.

    clip_image024

    q. On the Server we can see the captured image file.

    clip_image025

    4. Add the file to the image repository in SCCM 2007.

    a. Share a folder and move the image file (example \\ServerName\Images).

    b. Open the SCCM console, navigate to Site Database > Computer Management > Operating System Deployment > Operating System Images.

    c. Import the image by clicking Add Operating System Image in the task panel.

    d. Type or browse the network path to the image you want to import, and click Next.

    clip_image027

    e. Fill in the required information, then click Next.

     clip_image029

    f. Review the summary and complete the wizard.

    clip_image031

    clip_image033

    5. Distribute the image to Distribution Point.

    a. In the SCCM console, navigate to the image you uploaded in step 4 (Site Database > Computer Management > Operating System Deployment > Operating System Images) and select it.

    b. Click Manage Distribution Points in the action panel.

    clip_image035

    c. Click Next on the wizard starting page.

    d. As DP doesn’t have the image deployed yet, leave the default selection (copy) and click Next.clip_image037

    e. Select the DPs where you want to deploy the image to and include their PXE DP’s hidden share.clip_image039

    f. Click Next and Next again in the Completion page.

    clip_image041

    clip_image043

    g. Check the copy progress in the Package Status folder until you see it is Installed.

    clip_image045

    h. You are now ready to distribute the Windows 7 Ultimate x64 Image to client computers, either by upgrading or installing new machines.

  • Partner Technical Services Blog

    Microsoft Dynamics® AX 2009: How to Call AX 2009 from an External Application and Open a Specific Form/Record

    • 0 Comments

    image

    (This post courtesy of Natalia Efimtseva)

    Recently I worked with my colleague, Max Belugin, who is an expert in Dynamics. We were solving one interesting question—how you can activate and open a specific AX 2009 form/record from an external application or code.

    You can use following approaches to open AX from an external environment:

    1. COM API

    Unfortunately, at the current moment .NET Business Connector doesn’t implement UI function, and thus it is not possible to open a specific AX form. But we can register AX32.EXE as a COM Object.

    static void Connect(string[] args)
    {
    AxClientLib.DynamicsAxApplication dynamicsClient;
    try
    {
    //find running Ax32.exe
    dynamicsClient = (AxClientLib.DynamicsAxApplication)System.Runtime.InteropServices.Marshal.GetActiveObject("Dynamics.Application");
    }
    catch      
    {
                   //Launch new Ax32.exe
    dynamicsClient = new AxClientLib.DynamicsAxApplicationClass();
    }
     
    if (dynamicsClient != null)
    {
    //Run form
    dynamicsClient.OpenMenuItem("DMO", "SalesTable", AxClientLib.AxMenuType.DisplayMenu);
    }
    }

    Note: API doesn’t really call “form open,” but rather calls a Menu Item associated with a form. So you can call a specific form in this way, but not a specific record.

    2. SysStartupCmd

    You can also run a command when an Application Object Server (AOS) instance starts (details).

    You need to:

    • Add your startup command to the switch in Classes\SysStartUpCmd\construct statement (given your startup statement is FormXX).
    case 'FormXX':
    return new SysStartupCmdFormXX(s,parm);
    • Create a new class SysStartupCmdFormXX.
    class SysStartupCmdFormXX extends SysStartupCmd
    {
    }
    • Override the method applInit in this class.
    void applInit()
    {
    Args args;
    FormRun formRun;
     
    args = new args(formstr(FormXX));
    formRun = classFactory.formRunClass(args);
    formRun.init();
    formRun.run();
    formRun.detach();
    }

    This guidance is taken from here—so you can implement your own desired behavior of AX.

    3. AxPath

    AxPath is a protocol for activating Axapta forms. It does the following:

    • It sits on a timer event and polls the queue.
    • When it finds that there are some commands for the queue, it executes them.

    There is an external part named "URL handler," which takes an URL and places it in the queue. The queue is implemented using shared memory.

    So, for example, when you click in the browser in URL like:

    AxPath://MenuItem/Display/EmplTable?Area=dat&RecID=1032355

    The following actions are performed:

    1. Browser executes an URL handler with the URL as a command-line parameter.
    2. URL handler puts that URL into the queue.
    3. When the Tabax plugin polls the queue and detects that the URL is present, it opens the EmplTable menu item and navigates to  the particular employee.

    With this method, you can open a specific form as well as a specific record.

    4. EventDrillDown

    This approach is based on alerts and notification capabilities of Axapta and named pipe protocols. External drill-down is the ability to initiate and use the AX drill-down feature from a program external to AX. This means you can open a specific form as well as a specific record.

    Please refer this link for more details and source code for this method.

  • Partner Technical Services Blog

    Microsoft Security Bulletin Webcasts for Partners

    • 0 Comments

    (This post courtesy of Riyaz Jaffer)

    Partner Technical Services (PTS) and Commercial Technical Support (CTS) teams are pleased to announce new live webcasts for Microsoft Partners. This new series highlights the latest security updates, including technical details on each update, recommendations for deployment, and security intelligence about potential and real-world threats caused by vulnerabilities—vulnerabilities which the latest security updates now address. These webcasts also include an in-depth question-and-answer session for partners to engage with a consultant who can properly respond to all of their concerns.

    Please find the registration links below:

    Event Title

    Date

    Time

    Duration

      PLC Registration URL

    PTS Webcast: Information About Microsoft February Security Bulletins (Level 200)

    2/10/2011

    11:00 AM PST

    90 min

    http://bit.ly/h0K7SG

    PTS Webcast: Information About Microsoft March Security Bulletins (Level 200)

    3/10/2011

    11:00 AM PST

    90 min

    http://bit.ly/gJeat5

    PTS Webcast: Information About Microsoft April Security Bulletins (Level 200)

    4/14/2011

    11:00 AM PDT

    90 min

    http://bit.ly/fgfzHC

  • Partner Technical Services Blog

    Hello World

    • 0 Comments

    Welcome to the New Partner Technical Services (PTS) Blog!

    PTS is composed a worldwide group of consultants who focus on helping Microsoft Partners succeed throughout the business cycle. We’re here to help you build a practice, answer your presales questions, help you position your business against the competition to win more deals, and consult on technical best practices during your deployment projects. We have both packaged and custom solutions that are designed to help increase revenue as well as expand your skill set to make your business win more throughout the business cycle.

    image

    As a Microsoft Partner, you are entitled to free, competitive presales assistance and Advisory Services each year. You have access to 10, 20, or 50 hours of advisory assistance based on your partner level or competencies. In addition, partners have access to no-charge, unlimited online technical support in Online Technical Communities.

    Partner Level, Competency, Network Membership, or Subscription
    Partner Advisory Hours per Membership Year
    Partners with a gold competency
    50 hours
    Partners with a silver competency
    20 hours
    Subscribers to Microsoft Action Pack Development and Design
    10 hours
    All Microsoft Partner Network members, including those who do not receive Partner Advisory Hours through their Partner Network or Microsoft competency benefits, may purchase Partner Advisory Hours.
    Additional advisory hours are available for purchase at any time. Contact your local Partner Technical Services team for details.

    You’ll meet some of our Partner Technical Consultants here, as they share some of their industry knowledge that they think will be useful to you as a partner. Because we have the opportunity to work with a huge range of implementations and deployments with our Partners, we come across some rather interesting problems and solutions, which we suspect might be useful to others in such a large community. We hope you enjoy learning about these issues as much as we do! image

    Our consultants are located around the globe and can deliver benefits to you in several languages. But you can also reach out directly to find your local Partner Technical Services team (https://partner.microsoft.com/global/40011365) to see specifically how we can help you and your business.

    Partners, if you have anything you’d like to read about, please let us know! We look forward to sharing our information, and to your input and interaction in the blog comments.

Page 1 of 2 (9 items) 12