3

レポートと .net を初めて使用します。SSRSを使用してレポートを完成させましたが、バーコードをレポートに追加したいと考えています。バーコード画像を生成する Web サービスが既に 1 つありますが、現在はデータ マトリックス形式のみです。検索して見つけたバーコード化された画像または文字列を取得するメソッドをそのWebサービスに書きたい

Microsoft.Dynamics.AX

クラスですが、それらの使用方法がわかりません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 ?

サードパーティのツールがたくさんあることは知っていますが、セルフコーディングでそれを行うことができるかどうか疑問に思っていますか?事前に助けてくれてありがとう.

4

1 に答える 1

2

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;

最後に、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;
}

次に、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;
    }

最後に、何かを更新したい場合:

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;
            }
        }

Somethingただし、更新する予定がある場合は、 .ForUpdate() で選択していることを確認してください。

また、使用する予定のオブジェクトをアプリケーション プロキシ (EPApplicationProxies など) に追加し、それをプロジェクトから参照する必要があります。

于 2013-08-08T19:42:23.233 に答える