Esempio n. 1
0
        /// <summary>
        /// 查询接口
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public ApiResult <List <SpecialSchemeViewModel> > PostQuery(QueryCondition condition)
        {
            ApiResult <List <SpecialSchemeViewModel> > apiResult = new ApiResult <List <SpecialSchemeViewModel> >();

            apiResult.Result = new List <SpecialSchemeViewModel>();
            try
            {
                string querySql = XmlCommandManager.GetCommand("SpecialService:QueryList").CommandText;
                var    result   = Pagination.QueryBase <SpecialScheme>(querySql, condition);
                SpecialSchemeViewModel viewModel;
                foreach (var item in result.Data)
                {
                    viewModel = new SpecialSchemeViewModel();
                    viewModel.SpecialScheme = item;
                    apiResult.Result.Add(viewModel);
                }
                apiResult.TotalCount = result.Total;
                apiResult.TotalPage  = result.TotalPage;
                apiResult.Code       = ResultCode.Success;
            }
            catch (Exception e)
            {
                apiResult.Code    = ResultCode.SystemError;
                apiResult.Message = e.ToString();
            }
            return(apiResult);
        }
        /// <summary>
        /// 获取数据库表列相关信息
        /// </summary>
        /// <param name="tableNameList">表名集合</param>
        /// <returns>每张表列信息</returns>
        public static IEnumerable <dynamic> GetTableInfo(string[] tableNameList)
        {
            string strSQL = XmlCommandManager.GetCommand("Table:GetAllTableInfo").CommandText;

            strSQL = string.Format(strSQL, string.Join("','", tableNameList));
            return(DapperHelper.Query(strSQL));
        }
Esempio n. 3
0
        private void SetCommand(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            XmlCommandItem item = XmlCommandManager.GetCommand(name);

            if (item == null)
            {
                throw new ArgumentOutOfRangeException("name",
                                                      string.Format("指定的XmlCommand名称 {0} 不存在。", name));
            }

            // 填充命令对象
            _command.CommandText = item.CommandText;
            _command.CommandType = item.CommandType;

            if (item.Timeout > 0)
            {
                _command.CommandTimeout = item.Timeout;
            }

            FillParameters(item);
        }
Esempio n. 4
0
        /// <summary>
        /// 创建新的XmlCommand对象。
        /// </summary>
        /// <param name="name">命令名字</param>
        /// <param name="argsObject">匿名对象表示的参数</param>
        /// <param name="replaces">替换的关键字字典</param>
        public XmlCommand(string name, object argsObject, Dictionary <string, string> replaces)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            XmlCommandItem command = XmlCommandManager.GetCommand(name);

            if (command == null)
            {
                throw new ArgumentOutOfRangeException("name", string.Format("指定的XmlCommand名称 {0} 不存在。", name));
            }

            // 根据XML的定义以及传入参数,生成SqlParameter数组
            SqlParameter[] parameters = GetParameters(command, argsObject);

            // 创建CPQuery实例
            StringBuilder commandText = new StringBuilder(command.CommandText);

            if (replaces != null)
            {
                foreach (KeyValuePair <string, string> kvp in replaces)
                {
                    commandText.Replace(kvp.Key, kvp.Value);
                }
            }


            _query = CPQuery.From(commandText.ToString(), parameters);
            _query.Command.CommandTimeout = command.Timeout;
            _query.Command.CommandType    = command.CommandType;
        }
Esempio n. 5
0
        public string GetSql(string xmlcommandName)
        {
            // 这个测试类为了简单,就直接借用XmlCommand中定义的SQL语句

            XmlCommandItem x1 = XmlCommandManager.GetCommand(xmlcommandName);

            return(x1.CommandText);
        }
Esempio n. 6
0
        public void AppStart()
        {
            Profiler.ApplicationName    = "ClownFish.Web DEMO - XmlCommand";
            DbHelper.DefaultCommandKind = CommandKind.XmlCommand;

            SqlServerDb.ConfigClownFish();

            string path = System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, @"App_Data\XmlCommand");

            XmlCommandManager.LoadCommnads(path);
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            AdminRun.Run();

            if (!SetConsoleCtrlHandler(cancelHandler, true))
            {
                Console.WriteLine("程序监听系统按键异常");
            }
            try
            {
                //1.MEF初始化
                MefConfig.Init();

                //2.数据库初始化连接
                ConfigInit.InitConfig();

                //3.系统参数配置初始化
                ConfigManager configManager = MefConfig.TryResolve <ConfigManager>();
                configManager.Init();

                Console.Title         = SystemConfig.ProgramName;
                Console.CursorVisible = false; //隐藏光标

                //4.任务启动
                QuartzHelper.InitScheduler();
                QuartzHelper.StartScheduler();

                //5.加载SQL信息到缓存中
                XmlCommandManager.LoadCommnads(SysConfig.XmlCommandFolder);

                //测试dapper orm框架
                //DapperDemoService.Test();

                //启动站点
                using (NancyHost host = Startup.Start(SystemConfig.WebPort))
                {
                    //调用系统默认的浏览器
                    string url = string.Format("http://127.0.0.1:{0}", SystemConfig.WebPort);
                    Process.Start(url);
                    Console.WriteLine("系统已启动,当前监听站点地址:{0}", url);

                    //4.消息队列启动
                    RabbitMQClient.InitClient();

                    //5.系统命令初始化
                    CommandHelp.Init();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            Console.Read();
        }
Esempio n. 8
0
        private XmlCommandItem GetXmlCommand(string name)
        {
            Init();

            XmlCommandItem command = XmlCommandManager.GetCommand(name);

            if (command == null)
            {
                throw new ArgumentOutOfRangeException("name", "不能根据指定的名称找到匹配的XmlCommand,name: " + name);
            }

            return(command);
        }
Esempio n. 9
0
        protected override void OnStart(string[] args)
        {
            try
            {
                //1.MEF初始化
                MefConfig.Init();

                //2.数据库初始化连接
                ConfigInit.InitConfig();

                //3.系统参数配置初始化
                ConfigManager configManager = MefConfig.TryResolve <ConfigManager>();
                configManager.Init();

                //4.任务启动
                QuartzHelper.InitScheduler();
                QuartzHelper.StartScheduler();

                //5.加载SQL信息到缓存中
                XmlCommandManager.LoadCommnads(SysConfig.XmlCommandFolder);
                //开发时监听资源文件变化,用于实时更新
                DevelperHelper.WatcherResourceChange();

                // 保持web服务运行
                ThreadPool.QueueUserWorkItem((o) =>
                {
                    //7.启动站点
                    using (NancyHost host = Startup.Start(SystemConfig.WebPort))
                    {
                        //调用系统默认的浏览器
                        string url = string.Format("http://127.0.0.1:{0}", SystemConfig.WebPort);
                        LogHelper.WriteLog(string.Format("系统已启动,当前监听站点地址:{0}", url));
                        try
                        {
                            //4.消息队列启动
                            RabbitMQClient.InitClient();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                        //8.系统命令初始化
                        CommandHelp.Init();
                    }
                });
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("服务启动异常", ex);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="env"></param>
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          //.SetBasePath(AppContext.BaseDirectory)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();
            ConfigInit.InitConfig(Configuration);
            EFInitializer.UnSafeInit();
            XmlCommandManager.UnSafeInit();
        }
Esempio n. 11
0
 /// <summary>
 /// 从指定的目录中加载所有 XmlCommand 配置
 /// </summary>
 /// <param name="directoryPath">包含XmlCommand配置文件的目录,如果不指定就表示接受XmlCommand规范的默认目录</param>
 /// <returns></returns>
 public Initializer LoadXmlCommandFromDirectory(string directoryPath = null)
 {
     // 如果不指定目录,就采用XmlCommand规范的默认目录(建议不指定!)
     if (string.IsNullOrEmpty(directoryPath))
     {
         if (ClownFish.Base.Framework.RunTimeEnvironment.IsAspnetApp)
         {
             // 如果是ASP.NET程序,默认的XmlCommand存放目录就是 App_Data\\XmlCommand
             directoryPath = System.IO.Path.Combine(System.Web.HttpRuntime.AppDomainAppPath, "App_Data\\XmlCommand");
         }
         else
         {
             // 非ASP.NET程序,就是当前执行程序下的 XmlCommand 目录
             directoryPath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "XmlCommand");
         }
     }
     XmlCommandManager.LoadFromDirectory(directoryPath);
     return(this);
 }
Esempio n. 12
0
        protected override void OnStart(string[] args)
        {
            AppDomain.MonitoringIsEnabled = true;

            AdminRun.Run();

            DebuggableAttribute att = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttribute <DebuggableAttribute>();

            if (att.IsJITTrackingEnabled)
            {
                //Debug模式才让线程停止10s,方便附加到进程调试
                Thread.Sleep(10000);
            }
            if (!SetConsoleCtrlHandler(cancelHandler, true))
            {
                LogHelper.WriteLog("程序监听系统按键异常");
            }
            try
            {
                //1.MEF初始化
                MefConfig.Init();
                LogHelper.WriteLog("MEF初始化");

                //2.数据库初始化连接
                ConfigInit.InitConfig();
                LogHelper.WriteLog("数据库初始化连接");

                //3.系统参数配置初始化
                ConfigManager configManager = MefConfig.TryResolve <ConfigManager>();
                configManager.Init();
                LogHelper.WriteLog("系统参数配置初始化");

                //4.任务启动
                QuartzHelper.InitScheduler();
                QuartzHelper.StartScheduler();
                LogHelper.WriteLog("任务启动");

                //5.加载SQL信息到缓存中
                XmlCommandManager.LoadCommnads(SysConfig.XmlCommandFolder);
                LogHelper.WriteLog("加载SQL信息到缓存中");

                //测试dapper orm框架
                //DapperDemoService.Test();

                #region 控制台用死循环监听

                ////启动站点
                //using (NancyHost host = Startup.Start(SystemConfig.WebPort))
                //{
                //    //调用系统默认的浏览器
                //    string url = string.Format("http://127.0.0.1:{0}", 9059);
                //    Process.Start(url);
                //    LogHelper.WriteLog( string.Format("系统已启动,当前监听站点地址:{0}", url));

                //    //4.消息队列启动
                //    RabbitMQClient.InitClient();

                //    LogHelper.WriteLog("消息队列启动");

                //    ////5.系统命令初始化

                //    CommandHelp.Init();
                //    LogHelper.WriteLog("系统命令初始化");
                //}

                #endregion

                ///Window服务用线程池
                ThreadPool.QueueUserWorkItem((o) =>
                {
                    //启动站点
                    string url = string.Format("http://127.0.0.1:{0}", SysConfig.WebPort);
                    Startup.Start(SysConfig.WebPort);
                    LogHelper.WriteLog(string.Format("系统已启动,当前监听站点地址:{0}", url));

                    //4.消息队列启动
                    //RabbitMQClient.InitClient();
                    LogHelper.WriteLog("消息队列启动");
                });
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.Message);
            }
        }
Esempio n. 13
0
 /// <summary>
 /// 获取数据库所有表
 /// </summary>
 /// <returns>所有表</returns>
 public static IEnumerable <dynamic> GetAllTable()
 {
     return(DapperHelper.Query(XmlCommandManager.GetCommand("Table:GetAllTable").CommandText));
 }
Esempio n. 14
0
 /// <summary>
 /// 加载XML字符串中包含的 XmlCommand
 /// </summary>
 /// <param name="xml"></param>
 /// <returns></returns>
 public Initializer LoadXmlCommandFromText(string xml)
 {
     XmlCommandManager.LoadFromText(xml);
     return(this);
 }