简体   繁体   English

如何使用microsoft的Dynamics AX类?

[英]How to use microsoft's Dynamics AX classes?

I am new to the reporting and .net I have completed report using the SSRS but now i want to add the Barcode into the report.I already have one web service which is generating the Barcode image for me but for only data-matrix format now i want to write the method in that web service which will get me the Barcoded image or string I have searched and came across the 我是报道和.net的新手。我已经使用SSRS完成了报告,但现在我想将条形码添加到报告中。我已经有一个Web服务,它为我生成条形码图像,但现在只为数据矩阵格式我想在该Web服务中编写该方法,这将获得我搜索过的条形码图像或字符串

Microsoft.Dynamics.AX

Classes but i have no idea how to use them msdn also not provided any help with it so my questions are 类,但我不知道如何使用它们msdn也没有提供任何帮助,所以我的问题是

1) Is it possible to use the Microsoft.Dynamics.AX classes in to the web service? 
2) If possible how to add references any links will be helpful ?
3) If not then any other way for it ? any links will be helpful ?

I know there is lot's of third party tools but i am wondering whether is it possible to do it by self coding ?Thanks for the help in advance . 我知道有很多第三方工具,但我想知道是否有可能通过自编码来做到这一点?感谢您的帮助提前。

1) Yes 2) You'll need these to access information from within AX. 1)是2)您需要这些来访问AX内的信息。

using Microsoft.Dynamics.AX.Framework.Linq.Data;
using U23 = Microsoft.Dynamics.AX.ManagedInterop;
using U22 = Microsoft.Dynamics.AX.Framework.Linq.Data;
using Microsoft.Dynamics.Portal.Application.Proxy;

Finally, here is my basic layout of my access layer in C#. 最后,这是我在C#中访问层的基本布局。

private U23.Session _axSession = new U23.Session();
public U23.Session Connection
{
    get
    {
        return this._axSession;
    }
}
/// <summary>
/// Checks to see if the AX session is connected. If it's null we return false. 
/// Then we check to see if it's logged in, then return true. Otherwise it's not logged in.
/// </summary>
public bool Connected
{
    get
    {
        if (this._axSession == null)
        {
            return false;
        }
        else if (this._axSession.isLoggedOn())
        {
            return true;
        }
        return false;
    }
}

/// <summary>
/// This connects to the AX session. If it's already connected then we don't need to connect
/// again, so we return true. Otherwise we'll try to initiate the session. 
/// </summary>
/// <returns>
/// True: Connection openned successfully, or was already open.
/// False: Connection failed.
/// </returns>
public bool OpenConnection()
{
    if (this.Connected)
    {
        return true;
    }
    else
    {
        try
        {
            _axSession.Logon(null, null, null, null);
            return true;
        }
        catch
        {
            return false;
        }
    }
}

/// <summary>
/// If the session is logged on we will try to close it.
/// </summary>
/// <returns>
/// True: Connection closed successfully
/// False: Problem closing the connection
/// </returns>
public bool CloseConnection()
{
    bool retVal = false;
    if (this.Connection.isLoggedOn())
    {
        try
        {
            _axSession.Logoff();
            retVal = true;
        }
        catch
        {
            retVal = false;
        }
    }
    else
    {
        retVal = true;
    }
    this.Connection.Dispose();
    return retVal;
}

Then to access certain functions in AX you'll just need to: 然后,要访问AX中的某些功能,您只需:

public Somethings GetSomethingsById(int id)
    {
        Somethings retVal = new Somethings();
        U22.QueryProvider provider = new U22.AXQueryProvider(null);
        U22.QueryCollection<Somethings> somethings = new U22.QueryCollection<Somethings>(provider);
        var somethings2 = somethings.Where(x => x.SomethingId == id);
        retVal = somethings2.FirstOrDefault();
        return retVal;
    }

Finally, if you want to update something: 最后,如果你想更新一些东西:

public bool UpdateSomething(Something something)
        {
            U23.RuntimeContext.Current.TTSBegin();
            try
            {
                if (something.Count == 0)
                {
                    something.Delete();
                }
                something.Update();
                U23.RuntimeContext.Current.TTSCommit();
                return true;
            }
            catch
            {
                U23.RuntimeContext.Current.TTSAbort();
                return false;
            }
        }

but make sure you're selecting your Something with .ForUpdate() when you plan on updating it. 但要确保你选择的Something有.ForUpdate()当您计划更新它。

You'll also have to add any of objects you plan on using to an Application Proxy (such as EPApplicationProxies) and reference that from your project. 您还必须将计划使用的任何对象添加到应用程序代理(例如EPApplicationProxies)并从项目中引用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft Dynamics AX Windows 8应用程序连接到AOT - Microsoft Dynamics AX Windows 8 App connect to AOT 我可以在.NET / C#中为Microsoft Dynamics AX进行编码吗? - Can I code in .NET/C# for Microsoft Dynamics AX? Dynamics AX的移动应用程序 - Mobile application for Dynamics AX 如何将Dynamics AX时区转换为C#TimeZoneInfo? - How to convert Dynamics AX Timezone to C# TimeZoneInfo? 从暂停的交易中提取项目行,Microsoft Dynamics 2012 ax for POS零售 - Retrieve item lines from suspended transactions, Microsoft Dynamics 2012 ax for POS RETAIL Microsoft Dynamics的Discovery.svc - microsoft Dynamics's discovery.svc 将adfs登录名转发到Dynamics AX - Forwarding adfs login to Dynamics AX 在验证我的 wcf 服务中的 AX 服务器域、用户名和密码等凭据后,下载 Microsoft Dynamics AX 2012 服务 wsdl 元数据 - Download Microsoft Dynamics AX 2012 service wsdl metadata after validating credentials like AX server domain, user name and password in my wcf service 如何在不使用VS的情况下从Dynamics AX中的c#项目刷新wcf服务引用 - How to refresh a wcf service reference from c# project in Dynamics AX without VS 如何通过c#从Dynamics AX 2009导出阵列? - How can I export an array from Dynamics AX 2009 via c#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM