示例#1
0
        public void Update(PluginConfigInfo configInfo)
        {
            const string sqlString = "UPDATE siteserver_PluginConfig SET ConfigValue = @ConfigValue WHERE PluginId = @PluginId AND SiteId = @SiteId AND ConfigName = @ConfigName";

            var parms = new IDataParameter[]
            {
                GetParameter(ParmConfigValue, DataType.Text, configInfo.ConfigValue),
                GetParameter(ParmPluginId, DataType.VarChar, 50, configInfo.PluginId),
                GetParameter(ParmSiteId, DataType.Integer, configInfo.SiteId),
                GetParameter(ParmConfigName, DataType.VarChar, 200, configInfo.ConfigName)
            };

            ExecuteNonQuery(sqlString, parms);
        }
示例#2
0
        public void Insert(PluginConfigInfo configInfo)
        {
            const string sqlString = "INSERT INTO siteserver_PluginConfig(PluginId, SiteId, ConfigName, ConfigValue) VALUES (@PluginId, @SiteId, @ConfigName, @ConfigValue)";

            var parms = new IDataParameter[]
            {
                GetParameter(ParmPluginId, DataType.VarChar, 50, configInfo.PluginId),
                GetParameter(ParmSiteId, DataType.Integer, configInfo.SiteId),
                GetParameter(ParmConfigName, DataType.VarChar, 200, configInfo.ConfigName),
                GetParameter(ParmConfigValue, DataType.Text, configInfo.ConfigValue)
            };

            ExecuteNonQuery(sqlString, parms);
        }
示例#3
0
        public Configuration(string configPath, PluginConfigInfo cfg)
        {
            doc = new Document();

            //配置文件全路径
            ConfigPath = Path.GetFullPath(configPath);

            //如果存在配置文件,则直接打开
            if (File.Exists(ConfigPath))
            {
                doc.Load(ConfigPath);
            }
            else
            {
                //如果不存在配置文件,则打开模板配置文件
                doc.Load(configPath);
            }

            //加载配置文件信息
            LoadConfigInfo(doc.RootNode, "MDS.Plugin.SZQuotV5");
        }
        /// <summary>
        /// 初始化插件
        /// </summary>
        /// <param name="cfg">插件配置文件实例</param>
        /// <param name="logHelper"></param>
        /// <returns>成功则返回true,否则返回false</returns>
        public bool Initialize(PluginConfigInfo cfg, ILog4cbHelper logHelper)
        {
            try
            {
                Context.PluginInfo = cfg;
                Context.LogHelper = logHelper;
                PluginContext.Configuration = new Configuration(cfg.ConfigPath, cfg);
                //创建一个主备冗余服务对象
                MSService = DirectoryService.GetMasterSlaveService(ServiceName,false);
                MSService.ModeChanged += new EventHandler(MSService_ModeChanged);
                MSService.CheckStatus += new Func<MasterSlaveService, bool>(MSService_CheckStatus);

                quotCenter = new MDS.Plugin.SZQuotV5.QuotationCenter (Context.LogHelper);
                return true;
            }
            catch (Exception ex)
            {
                Context.LogHelper.LogErrMsg(ex, "初始化失败");
                return false;
            }
        }
示例#5
0
        public bool SetConfig(int siteId, string name, object config)
        {
            if (name == null)
            {
                name = string.Empty;
            }

            try
            {
                if (config == null)
                {
                    DataProvider.PluginConfigDao.Delete(_metadata.Id, siteId, name);
                }
                else
                {
                    var settings = new JsonSerializerSettings
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    };
                    var json = JsonConvert.SerializeObject(config, Formatting.Indented, settings);
                    if (DataProvider.PluginConfigDao.IsExists(_metadata.Id, siteId, name))
                    {
                        var configInfo = new PluginConfigInfo(0, _metadata.Id, siteId, name, json);
                        DataProvider.PluginConfigDao.Update(configInfo);
                    }
                    else
                    {
                        var configInfo = new PluginConfigInfo(0, _metadata.Id, siteId, name, json);
                        DataProvider.PluginConfigDao.Insert(configInfo);
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtils.AddPluginErrorLog(_metadata.Id, ex);
                return(false);
            }
            return(true);
        }
示例#6
0
        /// <summary>
        /// 初始化插件
        /// </summary>
        /// <param name="cfg">插件配置文件实例</param>
        /// <param name="logHelper"></param>
        /// <returns>成功则返回true,否则返回false</returns>
        public bool Initialize(PluginConfigInfo cfg, ILog4cbHelper logHelper)
        {
            try
            {
                Context.PluginInfo          = cfg;
                Context.LogHelper           = logHelper;
                PluginContext.Configuration = new Configuration(cfg.ConfigPath, cfg);
                //创建一个主备冗余服务对象
                MSService              = DirectoryService.GetMasterSlaveService(ServiceName, false);
                MSService.ModeChanged += new EventHandler(MSService_ModeChanged);
                MSService.CheckStatus += new Func <MasterSlaveService, bool>(MSService_CheckStatus);


                quotCenter = new MDS.Plugin.SZQuotV5.QuotationCenter(Context.LogHelper);
                return(true);
            }
            catch (Exception ex)
            {
                Context.LogHelper.LogErrMsg(ex, "初始化失败");
                return(false);
            }
        }
        public Configuration(string configPath, PluginConfigInfo cfg)
        {
            doc = new Document();

            //配置文件全路径
            ConfigPath = Path.GetFullPath(configPath);

            //如果存在配置文件,则直接打开
            if (File.Exists(ConfigPath))
            {
                doc.Load(ConfigPath);
            }
            else
            {
                //如果不存在配置文件,则打开模板配置文件
                doc.Load(configPath);
            }

            //加载配置文件信息
            LoadConfigInfo(doc.RootNode, "MDS.Plugin.SZQuotV5");
        }