Exemple #1
0
        /// <summary>
        /// 取得客户端
        /// </summary>
        /// <param name="strConnStr">连接字符串(10.15.43.32:6379,password=finchina)</param>
        /// <returns></returns>
        public ConnectionMultiplexer GetRedisClient(string strConnStr)
        {
            lock (diclock)
            {
                if (string.IsNullOrEmpty(strConnStr))
                {
                    return(null);
                }

                //提取连接字符串32位MD5码,作为KEY
                string strKey = EncryptUtil.MD5Encrypt(strConnStr);

                if (!dic_Client.ContainsKey(strKey))
                {
                    ConnectionMultiplexer redisClient = ConnectionMultiplexer.Connect(strConnStr);

                    if (redisClient != null)
                    {
                        dic_Client.Add(strKey, redisClient);
                        return(dic_Client[strKey]);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(dic_Client[strKey]);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 取得客户端
        /// </summary>
        /// <param name="strConnStr">连接字符串(mongodb://finchina:[email protected]:9981/WeixinMsg)</param>
        /// <returns></returns>
        public MongoClient GetMongoClient(string strConnStr)
        {
            lock (diclock)
            {
                if (string.IsNullOrEmpty(strConnStr))
                {
                    return(null);
                }

                //提取连接字符串32位MD5码,作为KEY
                string strKey = EncryptUtil.MD5Encrypt(strConnStr);

                if (!dic_Client.ContainsKey(strKey))
                {
                    MongoClient mongoClient = new MongoClient(strConnStr);

                    if (mongoClient != null)
                    {
                        dic_Client.Add(strKey, mongoClient);
                        return(dic_Client[strKey]);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(dic_Client[strKey]);
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="ftpConfig">FTP配置封装</param>
 public SftpUtil(FtpStru ftpConfig)
 {
     this.strFtpUri      = ftpConfig.ftpUri;
     this.intFtpPort     = ftpConfig.ftpPort;
     this.strFtpUserID   = ftpConfig.ftpUserID;
     this.strFtpPassword = ftpConfig.isPwdEncrypt? EncryptUtil.DesDecrypt_Default(ftpConfig.ftpPassword) : ftpConfig.ftpPassword;
     //创建Sftp客户端
     GetSftpClient();
 }
Exemple #4
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="ftpConfig">FTP配置封装</param>
 public FtpHelper(FtpStru ftpConfig)
 {
     this.strFtpUri      = ftpConfig.ftpUri;
     this.intFtpPort     = ftpConfig.ftpPort;
     this.strFtpUserID   = ftpConfig.ftpUserID;
     this.strFtpPassword = ftpConfig.isPwdEncrypt ? EncryptUtil.DesDecrypt_Default(ftpConfig.ftpPassword) : ftpConfig.ftpPassword;
     this.intRetryTimes  = 3;
     //创建ftp客户端
     GetFtpClient();
 }