Beispiel #1
0
        public DateTime SDate()
        {
            var sdate = int.Parse(ConfigurationOperator.GetValue("syear"));
            var sql   = @"select isnull(max(日期),'1900-01-01')日期  from " + tableName + " where 年=" + sdate;
            var riqi  = FITTHelper.GetSingleVal(sql).ToString();

            if (DateTime.Parse(riqi) == DateTime.Parse("1900-01-01"))
            {
                return(new DateTime(sdate, 1, 1));
            }
            else
            {
                return(DateTime.Parse((riqi)));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 取webconfig中的配置
        /// </summary>
        /// <param name="SourceName"></param>
        /// <returns></returns>
        private static FileConfigurationSource GetFileConfigurationSource()
        {
            FileConfigurationSource fileSource;
            string configPath = new ConfigurationOperator().getRedirectConfigPath();

            //获取重定向配置文件资源
            if (string.IsNullOrEmpty(configPath))
            {
                fileSource = null;
            }
            else
            {
                fileSource = new FileConfigurationSource(HttpContext.Current.Server.MapPath(configPath));
            }

            return(fileSource);
        }
Beispiel #3
0
        /// <summary>
        ///  获得SqlSugarClient
        /// </summary>
        public static SqlSugarClient GetIntance()
        {
            var listConn = new List <string>();
            var list     = new ConfigurationOperator().ALLConnectionStrings();

            foreach (var item in list)
            {
                if (!string.IsNullOrWhiteSpace(item))
                {
                    listConn.Add(item);
                }
            }
            if (listConn.Count < 1)
            {
                throw new Exception("数据库配置错误");
            }
            return(InitDataBase(listConn));
        }
        /// <summary>
        /// 添加数据库连接字符串
        /// </summary>
        /// <param name="connName"></param>
        /// <param name="connStr"></param>
        /// <param name="xType"></param>
        /// <param name="configName"></param>
        /// <returns></returns>
        public static bool addConnection(string connName, string connStr, string prividerName)
        {
            bool bRet = false;

            try
            {
                ConfigurationOperator cfgOper = new ConfigurationOperator(configFilePath);
                cfgOper.setConnectionString(connName, connStr, prividerName);
                cfgOper.Dispose();
                bRet = true;
            }
            catch (System.Exception ex)
            {
                throw ex;
            }

            return(bRet);
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        static ConnectionAdmin()
        {
            ConfigurationOperator cfgOper = new ConfigurationOperator(configFilePath);
            string filePath = cfgOper.getRedirectConfigPath();

            try
            {
                if (string.IsNullOrEmpty(filePath))
                {
                    configFilePath = "~";
                }
                else
                {
                    configFilePath = @"~/" + filePath.Substring(0, filePath.LastIndexOf(@"/"));
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 删除数据库连接字符串
        /// </summary>
        /// <param name="connName"></param>
        /// <returns></returns>
        public static bool deleteConnection(string connName)
        {
            ConfigurationOperator cfgOper = new ConfigurationOperator(configFilePath);

            return(cfgOper.deleteConnectionNode(connName));
        }
        public static ConnDef getConnDef(string connName)
        {
            ConfigurationOperator cfgOper = new ConfigurationOperator(configFilePath);

            return(cfgOper.getConnDef(connName));
        }
        /// <summary>
        /// 取默认连接串
        /// </summary>
        /// <returns></returns>
        public static string getDefaultConnName()
        {
            ConfigurationOperator cfgOper = new ConfigurationOperator(configFilePath);

            return(cfgOper.getDefaultConnName());
        }
        /// <summary>
        /// 设置默认数据库连接
        /// </summary>
        /// <returns></returns>
        public static bool setDefaultConn(string connName)
        {
            ConfigurationOperator cfgOper = new ConfigurationOperator(configFilePath);

            return(cfgOper.setDefaultConnStr(connName));
        }
        /// <summary>
        /// 返回数据库连接名列表
        /// </summary>
        /// <returns>ListData<string></returns>
        public static List <string> getConnNameList()
        {
            ConfigurationOperator cfgOper = new ConfigurationOperator(configFilePath);

            return(cfgOper.getConnNameList());
        }
        /// <summary>
        /// 获取所有数据库连接内容
        /// </summary>
        /// <param name="connName"></param>
        /// <returns>DataTable 列包括:name、val、xtype、xdefault</returns>
        public static DataTable getAllConnInfoTable()
        {
            ConfigurationOperator cfgOper = new ConfigurationOperator(configFilePath);

            return(cfgOper.allConnectionStrings());
        }