Connected to Ax AOS by code

 1 public Axapta Logon()
 2 {
 3      // NameValueCollection settings = (NameValueCollection)System.Configuration.ConfigurationSettings.GetConfig("AXConnection ");
 4      string username = System.Configuration.ConfigurationSettings.AppSettings["UserName"].ToString();
 5      string password = System.Configuration.ConfigurationSettings.AppSettings["PassWord"].ToString();
 6      string domain = System.Configuration.ConfigurationSettings.AppSettings["Domain"].ToString();
 7      string defaultCompany = System.Configuration.ConfigurationSettings.AppSettings["DefaultCompany"].ToString();
 8      string defaultLanguage = System.Configuration.ConfigurationSettings.AppSettings["DefaultLanguage"].ToString();
 9      string instance = System.Configuration.ConfigurationSettings.AppSettings["Instance"].ToString();// 'DynamicsAxStd@AX4.0:2712'
10      Axapta Ax = new Axapta();
11      Ax.Refresh();
12      NetworkCredential netCredential = new NetworkCredential(username,password,domain);
13      Ax.LogonAs(username, domain, netCredential, defaultCompany, defaultLanguage, instance,null);
14             
15      return Ax;
16 }
posted @ 2012-11-13 09:54  Sprite.z  Views(255)  Comments(0Edit  收藏  举报