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 }