连接服务器方法
在APP.confge中
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="RepositoryAccount" value="sa"/>
<add key="RepositoryPassword" value="sa"/>
<add key="RepositoryServer" value="127.0.0.1"/>
<add key="RepositoryPort" value=" 5060"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
代码页
一、//string UserAccount = ConfigurationManager.AppSettings["RepositoryAccount"];//获取位置文件里的用户登录账号
//string UserPassword = ConfigurationManager.AppSettings["RepositoryPassword"];//获取位置文件里的用户登录密码
//string Server = ConfigurationManager.AppSettings["RepositoryServer"];//获取位置文件里的服务器
//string Port = ConfigurationManager.AppSettings["RepositoryPort"];//获取位置文件里的端口号
//int port = Convert.ToInt32(Port);
二、
string UserAccount = UserName.Text;//获取输入的用户登录账号
string UserPassword = Password.Text;//获取输入的用户登录密码
string Server = TBServiceIp.Text;//获取输入的服务器IP
string Port = TBPort.Text;//获取输入的的端口号
int port = Convert.ToInt32(Port);
AMConnection connection = new Gisquest.AM.Interfaces.AMConnection(Server, port);
connection.Connect(UserAccount, UserPassword);
clientInterface = new AMClient(connection);
if(connection!=null)
{
MessageBox.Show("连接档案服务成功!!!");
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步