Infor LN (BaaN ERP)论坛

 找回密码
 加入Baan会员

QQ登录

只需一步,快速开始

QQ群一:61560730(已满)QQ群二:34342363
查看: 4602|回复: 2

ASP.NET连接到BaaN与BOBS

[复制链接]
发表于 2009-5-7 17:33:00 | 显示全部楼层 |阅读模式
用.net去开发BaaN的应用,现在大概有这么几种方法:

1)直接连接BaaN的数据库。(风险很大,只有小公司会使用这种方法)
2)把BaaN的数据通过Exchange导出,然后导入到SQL server,这些动作都做成Job,再从SQL server抓取有用的数据进行开发。(数据不及时,不准确)
3)通过BaaN的客户端直接调用BaaN的函数、过程或方法。获取自己想要的数据。(只能做成桌面版,一个application,在同一时间,只能使用一次调用,如果做成web版的,有两个以上用户同时浏览数据,就会出错。)

可能还有更好的方法,我暂时还没有想到。

前几天,在baanboard上看到一篇文章,有人开发了一个Baan OLE Broker Server (BOBS),解决了同一个application在同时只能调用BaaN的函数一次的问题,可以同时重复调用BaaN的函数或方法。

如果你有BaaN的开发权限,可以考虑去用这个方法去调用BaaN的资料去web上秀出来。

BOBS的资料和介绍,可以去http://www.baanboard.com/node/1736下载。

BOBS的使用经验,供大家参考:

1)下载BOBS后,首先修改BaaNOleBrokerServer.config文件里面的配置,目前BOSS只支持两个版本的BaaN系统,IV和V。对LN还不支持。把BaaNVersion的值改为自己所使用的版本。

<projectSettings>
....
<add key="BaaNVersion" value="V" />
</projectSettings>

其他的设置要根据自己的IIS的设置去配置。

运行程序,当出现下面的界面,恭喜你,可以使用了。



2)然后可以建一个web应用在你所配置的IIS上。
把web.config里面的appsettings加上
  <appSettings>
    <add key="ServerIP" value="实际服务器IP" />
    <add key="ServerPort" value="32001" />
</appSettings>

3)当然,最主要还是要有BaaN的开发权限。
通过session ttadv2539m000新建DLL,在里面写你要调用的函数。然后编译。
我找了一个已经存在的DLL,是BaaN的标准DLL,whwmddll0007,里面可以查看某一颗料在某个仓库是否有库存,如果有,则返回TRUE,否则返回FALSE。
下面的程序仅供参考。

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Collections;

public partial class inventory : System.Web.UI.Page
{
    public enum STATE { CONNECT, PROCESS_SESSION, DISCONNECT };
    private STATE m_processState = STATE.CONNECT;

    public String ReceivedData = "", BaaNParameters = "", BaaNCommand = "";

    private int size = 0;
    private byte[] data = new byte[128];
    public Socket clientSocet;

    public static String ServerIP = ConfigurationManager.AppSettings["ServerIP"].ToString();
    public static int ServerPort = Convert.ToInt32(ConfigurationManager.AppSettings["ServerPort"].ToString());
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button_submit_Click(object sender, EventArgs e)
    {
        open_connection();

        if (m_processState == STATE.PROCESS_SESSION)
        {
            BaaNParameters = '"' + TextBox_wh.Text.ToString().Trim() + "\",\"" + TextBox_item.Text + "\"";;

            BaaNCommand = "owhwmddll0007|whwmd.dll0007.item.present.in.warehouse(" + BaaNParameters + " )\r\n";
            clientSocet.Send(Encoding.Default.GetBytes(BaaNCommand));
            size = clientSocet.Receive(data);
            Label_size.Text = Encoding.Default.GetString(data, 0, size);
        }

    }

    private void open_connection()
    {
        String ClientID = "owhwmddll0007|dll0007.end()|" + DateTime.Now + "\r\n";
        // The firs part(before the first pipe) is the dll name, in the midle is the end function when running
        // an API session, and at the end, just the time

        clientSocet = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        try
        {
            clientSocet.Connect(new IPEndPoint(IPAddress.Parse(ServerIP), ServerPort));
            m_processState = STATE.CONNECT;
        }
        catch
        {
            m_processState = STATE.DISCONNECT;
            //news
        }

        if (m_processState != STATE.DISCONNECT)
        {
            // Send the Client ID.
            clientSocet.Send(Encoding.Default.GetBytes(ClientID));
            m_processState = STATE.PROCESS_SESSION;
            try
            {
                clientSocet.ReceiveTimeout = 60000;
                size = clientSocet.Receive(data);
                Label_size.Text = Encoding.Default.GetString(data, 0, size);
            }
            catch (Exception re)
            {
                m_processState = STATE.DISCONNECT;
                Label_size.Text = "Error receiving data from server " + re.Message;

            }
            ReceivedData = Encoding.Default.GetString(data, 0, size);
            if (ReceivedData != "OK")
            {
                m_processState = STATE.DISCONNECT;
            }
        }

    }
}
发表于 2010-6-14 22:11:47 | 显示全部楼层
BOBS 实验成功
您需要登录后才可以回帖 登录 | 加入Baan会员

本版积分规则

QQ|Archiver|手机版|小黑屋|Infor LN Baan论坛 沪ICP备20006045号-3

GMT+8, 2024-3-28 20:21 , Processed in 0.141836 second(s), 17 queries .

Powered by Discuz! X3.5

Copyright © 2001-2023 Tencent Cloud.

快速回复 返回顶部 返回列表