Exemple #1
0
        ///// <summary>
        ///// 初始化
        ///// </summary>
        ///// <param name="factory">工厂</param>
        ///// <param name="employee"></param>
        ///// <param name="password"></param>
        //public CamstarCommon(string factory,string employee,string password)

        //{
        //    var model = GetConfigModel(factory);
        //    if (model is InsiteLoginModel loginModel)
        //    {
        //        loginModel.Password = password;
        //        loginModel.User = employee;
        //        _session = null;
        //        _client = null;
        //        _client = new CsiClient();
        //        _connection = null;
        //        _sessionId = Guid.NewGuid();
        //        _connection = _client.CreateConnection(loginModel.Host, loginModel.Port);
        //        _session = _connection.CreateSession(loginModel.User, loginModel.Password, _sessionId.ToString());
        //    }

        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="host"></param>
        /// <param name="port"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>

        public CamstarCommon(string host, int port, string userName, string password)
        {
            _session    = null;
            _client     = null;
            _client     = new CsiClient();
            _connection = null;
            _sessionId  = Guid.NewGuid();
            _connection = _client.CreateConnection(host, port);
            _session    = _connection.CreateSession(userName, password, _sessionId.ToString());
        }
Exemple #2
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="factory">工厂</param>
        public CamstarCommon(string factory, IConfiguration configuration)
        {
            if (string.IsNullOrEmpty(factory))
            {
                throw new Exception("工厂参数不能为空");
            }
            var model = GetConfigModel(factory, configuration);

            if (model is InsiteLoginModel loginModel)
            {
                _session    = null;
                _client     = null;
                _client     = new CsiClient();
                _connection = null;

                _sessionId  = Guid.NewGuid();
                _connection = _client.CreateConnection(loginModel.Host, loginModel.Port);
                _session    = _connection.CreateSession(loginModel.User, loginModel.Password, _sessionId.ToString());
            }
        }