public RedisCacheProvider(IConfiguration configuration, ILog ilog)
        {
            this.configuration = configuration;
            this.log           = new Log4netHelper(ilog, this.GetType());


            if (!int.TryParse(configuration["Vcredit:Cache:Redis:ExpriesDays"], out redisExpries))
            {
                redisExpries = 3;
            }

            string enableConfig = configuration["Vcredit:Cache:Redis:Enable"];
            bool   enable       = !string.IsNullOrEmpty(enableConfig) && enableConfig.Equals("true", StringComparison.InvariantCultureIgnoreCase);

            if (enable)
            {
                Close();
                try
                {
                    string[] RedisReadWriteHosts    = new string[] { configuration["Vcredit:Cache:Redis:ReadWriteHosts"] };
                    string[] RedisReadOnlyHosts     = new string[] { configuration["Vcredit:Cache:Redis:ReadOnlyHosts"] };
                    RedisClientManagerConfig config = new RedisClientManagerConfig()
                    {
                        AutoStart        = false,
                        MaxReadPoolSize  = 200,
                        MaxWritePoolSize = 50
                    };
                    redisManager = new PooledRedisClientManager(RedisReadWriteHosts, RedisReadOnlyHosts, config); //readWriteHosts
                    redisManager.Start();
                }
                catch (Exception ex)
                {
                    log.Log("实例化PooledRedisClientManager异常。", LogType.Error, ex);
                }
            }
            else
            {
                Close();
            }

            redisEnable = enable;
        }
Exemple #2
0
        public static void Info(
            string account,
            String OperationName,
            String ParamInfo,
            String DetailInfo,
            bool Result,
            Guid TransactionID)
        {
            LogDBHelper.AddSysLog(account, OperationName, ParamInfo, DetailInfo, Result.ToString(), TransactionID);
            String msg = "UserAccount:" + account + "||OperationName:" + OperationName + "||DetailInfo:" + DetailInfo + "||Result:" + Result + "||TransactionID:" + TransactionID;

            if (Result)
            {
                Log4netHelper.Info(msg);
            }
            else
            {
                Log4netHelper.Error(msg);
            }
        }
Exemple #3
0
        public static void Info(
            Guid OrgID,
            Guid OperatorID,
            String OperationName,
            String ParamInfo,
            String DetailInfo,
            bool Result,
            Guid TransactionID)
        {
            String msg = "OrgID:" + OrgID + "||OperatorID:" + OperatorID + "||OperationName:" + OperationName + "||DetailInfo:" + DetailInfo + "||Result:" + Result + "||TransactionID:" + TransactionID;

            if (Result)
            {
                Log4netHelper.Info(msg);
            }
            else
            {
                Log4netHelper.Error(msg);
            }
        }
Exemple #4
0
        private bool GetAvailabilityDC(string dcName)
        {
            DirectoryEntry domain = new DirectoryEntry();

            try
            {
                domain.Path               = string.Format("LDAP://{0}", dcName);
                domain.Username           = ConfigInstance["AD_Admin"];
                domain.Password           = ConfigInstance["AD_Password"];;
                domain.AuthenticationType = AuthenticationTypes.Secure;

                domain.RefreshCache();

                return(true);
            }
            catch (Exception ex)
            {
                Log4netHelper.Error("[IsConnected方法]错误信息:" + ex.Message);
                return(false);
            }
        }
Exemple #5
0
 public BaseDao(IConfiguration configuration, ILog ilog)
 {
     this.configuration = configuration;
     this.log           = new Log4netHelper(ilog, this.GetType());
 }
Exemple #6
0
        public static bool AddSysLog(
            string UserAccount,
            String OperationName,
            String ParamInfo,
            String DetailInfo,
            String Result,
            Guid TransactionID
            )
        {
            bool   bResult  = true;
            string strError = string.Empty;

            try
            {
                CParameters  paras             = new CParameters();
                SqlParameter paraUserAccount   = new SqlParameter("@UserAccount", UserAccount);
                SqlParameter paraOperationName = new SqlParameter("@OperationName", OperationName);
                SqlParameter paraParamInfo     = new SqlParameter("@ParamInfo", ParamInfo);
                SqlParameter paraDetailInfo    = new SqlParameter("@DetailInfo", DetailInfo);
                SqlParameter paraResult        = new SqlParameter("@Result", Result);
                SqlParameter paraTransactionID = new SqlParameter("@TransactionID", TransactionID);

                paras.Add(paraUserAccount);
                paras.Add(paraOperationName);
                paras.Add(paraParamInfo);
                paras.Add(paraDetailInfo);
                paras.Add(paraResult);
                paras.Add(paraTransactionID);

                CBaseDB _db = new CBaseDB(Conntection.strConnection);
                do
                {
                    int     iResult = 0;
                    DataSet ds      = new DataSet();
                    if (!_db.ExcuteByTransaction(paras, "dbo.[prc_AddSysLog]", out iResult, out strError))
                    {
                        strError = "prc_AddSysLog数据库执行失败,Error:" + strError;
                        Log4netHelper.Error(strError);
                        bResult = false;
                        break;
                    }
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            switch (iResult)
                            {
                            case 0:
                                bResult = true;
                                break;

                            case -9999:
                                bResult = false;
                                break;

                            default:
                                bResult = false;
                                break;
                            }
                        }
                        else
                        {
                            bResult = false;
                            break;
                        }
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                Log4netHelper.Error(ex.ToString());
                bResult = false;
            }
            return(bResult);
        }