Exemplo n.º 1
0
Arquivo: Form2.cs Projeto: xianrui69/-
 public static void loadSetting(Control.ControlCollection c)
 {
     for (int i = 0; i < ConfigurationManager.AppSettings.Count; i++)
     {
         var key   = ConfigurationManager.AppSettings.AllKeys[i];
         var val   = new CfgHelper(ConfigurationManager.AppSettings.AllKeys[i]).Value;
         var finds = c.Find(key, false);
         if (finds != null && finds.Length > 0)
         {
             var find = finds[0];
             if (find is TextBox)
             {
                 (find as TextBox).Text = val;
             }
             else if (find is CheckBox)
             {
                 (find as CheckBox).Checked = bool.Parse(val);
             }
             else if (find is ComboBox)
             {
                 try
                 {
                     (find as ComboBox).SelectedValue = (val);
                 }
                 catch (Exception e)
                 {
                     (find as ComboBox).SelectedText = (val);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        public void Configure_with_addparameters()
        {
            var nhConfig = ConfigurationExtensions.GetNhConfig();
            var mapper   = new MReadOnlyMappingManager();

            mapper.getRegisteredTypes += () => new[] { typeof(Entity) };
            var solr = new MSolrOperations <Entity>();

            var provider = new MServiceProvider();

            provider.getService += MServiceLocator.Table(new Dictionary <System.Type, object> {
                { typeof(IReadOnlyMappingManager), mapper },
                { typeof(ISolrOperations <Entity>), solr },
            });

            var addParameters = new AddParameters {
                CommitWithin = 4343
            };
            var helper = new CfgHelper(provider);

            helper.Configure(nhConfig, true, addParameters);
            var listener = nhConfig.EventListeners.PostInsertEventListeners[0];

            Assert.IsType <SolrNetListener <Entity> >(listener);
            Assert.Equal(addParameters, ((IListenerSettings)listener).AddParameters);
        }
Exemplo n.º 3
0
        public void Configure_from_serviceprovider()
        {
            var nhConfig = ConfigurationExtensions.GetNhConfig();

            var provider = new MServiceProvider();
            var mapper   = new MReadOnlyMappingManager();

            mapper.getRegisteredTypes += () => new[] { typeof(Entity) };

            var solr = new MSolrOperations <Entity>();

            provider.getService += MServiceLocator.Table(new Dictionary <System.Type, object> {
                { typeof(IReadOnlyMappingManager), mapper },
                { typeof(ISolrOperations <Entity>), solr },
            });
            var helper = new CfgHelper(provider);

            helper.Configure(nhConfig, true);
            Assert.True(nhConfig.EventListeners.PostInsertEventListeners.Length > 0);
            Assert.True(nhConfig.EventListeners.PostUpdateEventListeners.Length > 0);
            Assert.True(nhConfig.EventListeners.PostDeleteEventListeners.Length > 0);
            var listener = nhConfig.EventListeners.PostInsertEventListeners[0];

            Assert.IsType <SolrNetListener <Entity> >(listener);
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            var fn = openFileDialog1.FileName;

            if (!string.IsNullOrEmpty(fn))
            {
                if (File.Exists(fn))
                {
                    string extName = Path.GetExtension(fn);
                    //var fn1 = fn.Substring(0, fn.Length - extName.Length);
                    var fn1 = fn.Substring(fn.LastIndexOf("\\") + 1);
                    var aa  = new CfgHelper(fn1);
                    try
                    {
                        var old = aa.Value;
                        MessageBox.Show("已存在同名启动项,路径为:" + old);
                    }
                    catch (Exception exception)
                    {
                        aa.Value = fn;
                        MessageBox.Show("添加成功");
                    }
                }
            }
        }
Exemplo n.º 5
0
        public void Configure_from_servicelocator()
        {
            var mapper = new MReadOnlyMappingManager();

            mapper.getRegisteredTypes += () => new[] { typeof(Entity) };

            var serviceLocator = new MServiceLocator();

            serviceLocator.getInstance += MServiceLocator.One <IReadOnlyMappingManager>(mapper);

            var solr = new MSolrOperations <Entity>();

            serviceLocator.getService += MServiceLocator.One <ISolrOperations <Entity> >(solr);
            ServiceLocator.SetLocatorProvider(() => serviceLocator);
            var nhConfig = ConfigurationExtensions.GetNhConfig();
            var helper   = new CfgHelper();

            helper.Configure(nhConfig, true);
            Assert.True(nhConfig.EventListeners.PostInsertEventListeners.Length > 0);
            Assert.True(nhConfig.EventListeners.PostUpdateEventListeners.Length > 0);
            Assert.True(nhConfig.EventListeners.PostDeleteEventListeners.Length > 0);
            var listener = nhConfig.EventListeners.PostInsertEventListeners[0];

            Assert.IsType <SolrNetListener <Entity> >(listener);
        }
Exemplo n.º 6
0
        public void Does_not_override_existing_listeners()
        {
            var nhConfig = ConfigurationExtensions.GetNhConfig();

            var mockListener = new MPostInsertEventListener();

            nhConfig.SetListener(ListenerType.PostInsert, mockListener);

            var mapper = new MReadOnlyMappingManager();

            mapper.getRegisteredTypes += () => new[] { typeof(Entity) };

            var solr = new MSolrOperations <Entity>();

            var provider = new MServiceProvider();

            provider.getService += MServiceLocator.Table(new Dictionary <System.Type, object> {
                { typeof(IReadOnlyMappingManager), mapper },
                { typeof(ISolrOperations <Entity>), solr },
            });

            var helper = new CfgHelper(provider);

            helper.Configure(nhConfig, true);
            Assert.Equal(2, nhConfig.EventListeners.PostInsertEventListeners.Length);
        }
 static ServerHealthCheckConfigMgr()
 {
     if (ServerHealthCheckConfigMgr._config == null)
     {
         CfgHelper cfgHelper = new CfgHelper();
         ServerHealthCheckConfigMgr._config = cfgHelper.GetConfig("HealthCheck.xml");
         ServerHealthCheckConfigMgr._ns     = _config.Root.GetDefaultNamespace();
     }
 }
Exemplo n.º 8
0
 static DBConfig()
 {
     if (DBConfig._config == null)
     {
         CfgHelper cfgHelper = new CfgHelper();
         DBConfig._config = cfgHelper.GetConfig("Database.xml");
         DBConfig._ns     = _config.Root.GetDefaultNamespace();
     }
 }
Exemplo n.º 9
0
 static ServerConfigMgr()
 {
     if (ServerConfigMgr._config == null)
     {
         CfgHelper cfgHelper = new CfgHelper();
         ServerConfigMgr._config = cfgHelper.GetConfig("ServerLayout.xml");
         ServerConfigMgr._ns     = _config.Root.GetDefaultNamespace();
     }
 }
Exemplo n.º 10
0
        public void Setup() {
            BasicConfigurator.Configure();
            SetupSolr();

            cfg = SetupNHibernate();

            cfgHelper = new CfgHelper();
            cfgHelper.Configure(cfg, true);
            sessionFactory = cfg.BuildSessionFactory();
        }
Exemplo n.º 11
0
        public IntegrationTests2()
        {
            BasicConfigurator.Configure();
            SetupSolr();

            cfg = SetupNHibernate();

            cfgHelper = new CfgHelper();
            cfgHelper.Configure(cfg, true);
            sessionFactory = cfg.BuildSessionFactory();
        }
Exemplo n.º 12
0
        public void FixtureSetup()
        {
            BasicConfigurator.Configure();
            SetupSolr();

            cfg = SetupNHibernate();

            cfgHelper = new CfgHelper();
            cfgHelper.Configure(cfg, true);
            sessionFactory = cfg.BuildSessionFactory();
        }
Exemplo n.º 13
0
 public void Configure_from_serviceprovider()
 {
     var nhConfig = ConfigurationExtensions.GetNhConfig();
     var provider = MockRepository.GenerateMock<IServiceProvider>();
     var mapper = MockRepository.GenerateMock<IReadOnlyMappingManager>();
     mapper.Expect(x => x.GetRegisteredTypes()).Return(new[] {typeof (Entity)});
     var solr = MockRepository.GenerateMock<ISolrOperations<Entity>>();
     provider.Expect(x => x.GetService(typeof (IReadOnlyMappingManager))).Return(mapper);
     provider.Expect(x => x.GetService(typeof (ISolrOperations<Entity>))).Return(solr);
     var helper = new CfgHelper(provider);
     helper.Configure(nhConfig, true);
     Assert.That(nhConfig.EventListeners.PostInsertEventListeners.Length, Is.GreaterThan(0));
     Assert.That(nhConfig.EventListeners.PostUpdateEventListeners.Length, Is.GreaterThan(0));
     Assert.That(nhConfig.EventListeners.PostDeleteEventListeners.Length, Is.GreaterThan(0));
     var listener = nhConfig.EventListeners.PostInsertEventListeners[0];
     Assert.That(listener, Is.InstanceOf<SolrNetListener<Entity>>());
 }
        public static NGVodPosterConfig GetConfig()
        {
            var cfgHelper = new CfgHelper();

            //Load xml config
            var config = cfgHelper.GetConfig("NGVODPoster.xml");

            if (config == null)
            {
                Trace.TraceError("Failed to gete configuration");
                throw new Exception("Failed to load configuration xml file.");
            }

            //Get namespace
            var ns = config.Root.GetDefaultNamespace();

            var ngVodConfig = new NGVodPosterConfig();

            List <Task> tskList = new List <Task>()
            {
                ngVodConfig.setVHO(config, ns),
                ngVodConfig.setDirs(config, ns),
                ngVodConfig.setImage(config, ns),
                ngVodConfig.setLogDir(config, ns),
                ngVodConfig.setSMTP(config, ns),
                ngVodConfig.setMaxThreads(config, ns),
            };

            try
            {
                Task.WaitAll(tskList.ToArray());
                ngVodConfig.setVhoDirs();
            }
            catch (AggregateException aex)
            {
                foreach (var ex in aex.InnerExceptions)
                {
                    Trace.TraceError("Error setting config properties. {0}", ex.Message);
                }
                throw aex.Flatten();
            }

            return(ngVodConfig);
        }
Exemplo n.º 15
0
        private SearchFactoryImpl(Configuration cfg)
        {
            CfgHelper.Configure(cfg);

            mapping = SearchMappingFactory.CreateMapping(cfg);

            Analyzer analyzer = InitAnalyzer(cfg);

            InitDocumentBuilders(cfg, analyzer);

            Iesi.Collections.Generic.ISet <System.Type> classes = new HashedSet <System.Type>(documentBuilders.Keys);
            foreach (DocumentBuilder documentBuilder in documentBuilders.Values)
            {
                documentBuilder.PostInitialize(classes);
            }
            worker         = WorkerFactory.CreateWorker(cfg, this);
            readerProvider = ReaderProviderFactory.CreateReaderProvider(cfg, this);
            BuildFilterCachingStrategy(cfg.Properties);
        }
Exemplo n.º 16
0
        public void Configure_with_addparameters() {
            var nhConfig = ConfigurationExtensions.GetNhConfig();
            var mapper = new MReadOnlyMappingManager();
            mapper.getRegisteredTypes += () => new[] {typeof (Entity)};
            var solr = new MSolrOperations<Entity>();

            var provider = new MServiceProvider();
            provider.getService += MServiceLocator.Table(new Dictionary<System.Type, object> {
                {typeof(IReadOnlyMappingManager), mapper},
                {typeof(ISolrOperations<Entity>), solr},
            });

            var addParameters = new AddParameters {CommitWithin = 4343};
            var helper = new CfgHelper(provider);
            helper.Configure(nhConfig, true, addParameters);
            var listener = nhConfig.EventListeners.PostInsertEventListeners[0];
            Assert.IsInstanceOfType<SolrNetListener<Entity>>(listener);
            Assert.AreEqual(addParameters, ((IListenerSettings)listener).AddParameters);
        }
Exemplo n.º 17
0
        public void Configure_from_servicelocator() {
            var mapper = new MReadOnlyMappingManager();
            mapper.getRegisteredTypes += () => new[] {typeof (Entity)};

            var serviceLocator = new MServiceLocator();
            serviceLocator.getInstance += MServiceLocator.One<IReadOnlyMappingManager>(mapper);

            var solr = new MSolrOperations<Entity>();
            serviceLocator.getService += MServiceLocator.One<ISolrOperations<Entity>>(solr);
            ServiceLocator.SetLocatorProvider(() => serviceLocator);
            var nhConfig = ConfigurationExtensions.GetNhConfig();
            var helper = new CfgHelper();
            helper.Configure(nhConfig, true);
            Assert.GreaterThan(nhConfig.EventListeners.PostInsertEventListeners.Length, 0);
            Assert.GreaterThan(nhConfig.EventListeners.PostUpdateEventListeners.Length, 0);
            Assert.GreaterThan(nhConfig.EventListeners.PostDeleteEventListeners.Length, 0);
            var listener = nhConfig.EventListeners.PostInsertEventListeners[0];
            Assert.IsInstanceOfType<SolrNetListener<Entity>>(listener);
        }
Exemplo n.º 18
0
Arquivo: Form2.cs Projeto: xianrui69/-
 private void button1_Click(object sender, EventArgs e)
 {
     foreach (Control con in this.Controls)
     {
         var cofig = new CfgHelper(con.Name);
         if (con is TextBox)
         {
             cofig.Value = (con as TextBox).Text;
         }
         else if (con is CheckBox)
         {
             cofig.Value = (con as CheckBox).Checked + "";
         }
         else if (con is ComboBox)
         {
             cofig.Value = (con as ComboBox).SelectedValue + "";
         }
     }
     this.DialogResult = DialogResult.OK;
 }
Exemplo n.º 19
0
        public void Configure_from_serviceprovider() {
            var nhConfig = ConfigurationExtensions.GetNhConfig();

            var provider = new MServiceProvider();
            var mapper = new MReadOnlyMappingManager();
            mapper.getRegisteredTypes += () => new[] {typeof (Entity)};

            var solr = new MSolrOperations<Entity>();
            provider.getService += MServiceLocator.Table(new Dictionary<System.Type, object> {
                {typeof (IReadOnlyMappingManager), mapper},
                {typeof (ISolrOperations<Entity>), solr},
            });
            var helper = new CfgHelper(provider);
            helper.Configure(nhConfig, true);
            Assert.GreaterThan(nhConfig.EventListeners.PostInsertEventListeners.Length, 0);
            Assert.GreaterThan(nhConfig.EventListeners.PostUpdateEventListeners.Length, 0);
            Assert.GreaterThan(nhConfig.EventListeners.PostDeleteEventListeners.Length, 0);
            var listener = nhConfig.EventListeners.PostInsertEventListeners[0];
            Assert.IsInstanceOfType<SolrNetListener<Entity>>(listener);
        }
Exemplo n.º 20
0
        public void Does_not_override_existing_listeners()
        {
            var nhConfig     = ConfigurationExtensions.GetNhConfig();
            var mockListener = MockRepository.GenerateMock <IPostInsertEventListener>();

            nhConfig.SetListener(ListenerType.PostInsert, mockListener);

            var provider = MockRepository.GenerateMock <IServiceProvider>();
            var mapper   = MockRepository.GenerateMock <IReadOnlyMappingManager>();

            mapper.Expect(x => x.GetRegisteredTypes()).Return(new[] { typeof(Entity) });
            provider.Expect(x => x.GetService(typeof(IReadOnlyMappingManager))).Return(mapper);
            var solr = MockRepository.GenerateMock <ISolrOperations <Entity> >();

            provider.Expect(x => x.GetService(typeof(ISolrOperations <Entity>))).Return(solr);

            var helper = new CfgHelper(provider);

            helper.Configure(nhConfig, true);
            Assert.AreEqual(2, nhConfig.EventListeners.PostInsertEventListeners.Length);
        }
Exemplo n.º 21
0
        public void Configure_from_serviceprovider()
        {
            var nhConfig = ConfigurationExtensions.GetNhConfig();
            var provider = MockRepository.GenerateMock <IServiceProvider>();
            var mapper   = MockRepository.GenerateMock <IReadOnlyMappingManager>();

            mapper.Expect(x => x.GetRegisteredTypes()).Return(new[] { typeof(Entity) });
            var solr = MockRepository.GenerateMock <ISolrOperations <Entity> >();

            provider.Expect(x => x.GetService(typeof(IReadOnlyMappingManager))).Return(mapper);
            provider.Expect(x => x.GetService(typeof(ISolrOperations <Entity>))).Return(solr);
            var helper = new CfgHelper(provider);

            helper.Configure(nhConfig, true);
            Assert.GreaterThan(nhConfig.EventListeners.PostInsertEventListeners.Length, 0);
            Assert.GreaterThan(nhConfig.EventListeners.PostUpdateEventListeners.Length, 0);
            Assert.GreaterThan(nhConfig.EventListeners.PostDeleteEventListeners.Length, 0);
            var listener = nhConfig.EventListeners.PostInsertEventListeners[0];

            Assert.IsInstanceOfType <SolrNetListener <Entity> >(listener);
        }
Exemplo n.º 22
0
        private void timer1_Tick1(object sender, EventArgs e)
        {
            if (!isOpen)
            {
                return;
            }
            var s = sCount - (DateTime.Now - time1).Seconds;

            if ((DateTime.Now - time1).Seconds < sCount)
            {
                label1.Text = s + "秒内点击确定则终止启动项!";
                return;
            }
            timer1.Stop();
            label1.Text = "已执行!再次点击则关闭";
            isOpen      = false;
            for (int i = 0; i < ConfigurationManager.AppSettings.Count; i++)
            {
                var val = new CfgHelper(ConfigurationManager.AppSettings.AllKeys[i]).Value;
                if (val.IndexOf(".") == -1)
                {
                    continue;
                }
                Process.Start(val);
                //File.Open(new CfgHelper(ConfigurationManager.AppSettings.AllKeys[i]).Value, FileMode.Open);
            }
            Mute();
            if (voice)
            {
                SetVolunme(voiceNum);
            }
            if (Close)
            {
                checkBox1.Enabled = false;
                timer1.Interval   = 100;
                timer1.Tick      -= timer1_Tick1;
                timer1.Tick      += timer1_Tick2;
                timer1.Start();
            }
        }
Exemplo n.º 23
0
        public void Configure_with_addparameters()
        {
            var nhConfig = ConfigurationExtensions.GetNhConfig();
            var provider = MockRepository.GenerateMock <IServiceProvider>();
            var mapper   = MockRepository.GenerateMock <IReadOnlyMappingManager>();

            mapper.Expect(x => x.GetRegisteredTypes()).Return(new[] { typeof(Entity) });
            var solr = MockRepository.GenerateMock <ISolrOperations <Entity> >();

            provider.Expect(x => x.GetService(typeof(IReadOnlyMappingManager))).Return(mapper);
            provider.Expect(x => x.GetService(typeof(ISolrOperations <Entity>))).Return(solr);
            var addParameters = new AddParameters {
                CommitWithin = 4343
            };
            var helper = new CfgHelper(provider);

            helper.Configure(nhConfig, true, addParameters);
            var listener = nhConfig.EventListeners.PostInsertEventListeners[0];

            Assert.IsInstanceOfType <SolrNetListener <Entity> >(listener);
            Assert.AreEqual(addParameters, ((IListenerSettings)listener).AddParameters);
        }
Exemplo n.º 24
0
        public void Does_not_override_existing_listeners()
        {
            var nhConfig = ConfigurationExtensions.GetNhConfig();
            var mockListener = MockRepository.GenerateMock<IPostInsertEventListener>();
            nhConfig.SetListener(ListenerType.PostInsert, mockListener);

            var provider = MockRepository.GenerateMock<IServiceProvider>();
            var mapper = MockRepository.GenerateMock<IReadOnlyMappingManager>();
            mapper.Expect(x => x.GetRegisteredTypes()).Return(new[] { typeof(Entity) });
            provider.Expect(x => x.GetService(typeof(IReadOnlyMappingManager))).Return(mapper);
            var solr = MockRepository.GenerateMock<ISolrOperations<Entity>>();
            provider.Expect(x => x.GetService(typeof(ISolrOperations<Entity>))).Return(solr);

            var helper = new CfgHelper(provider);
            helper.Configure(nhConfig, true);
            Assert.AreEqual(2, nhConfig.EventListeners.PostInsertEventListeners.Length);
        }
Exemplo n.º 25
0
 public void Configure_with_addparameters()
 {
     var nhConfig = ConfigurationExtensions.GetNhConfig();
     var provider = MockRepository.GenerateMock<IServiceProvider>();
     var mapper = MockRepository.GenerateMock<IReadOnlyMappingManager>();
     mapper.Expect(x => x.GetRegisteredTypes()).Return(new[] {typeof (Entity)});
     var solr = MockRepository.GenerateMock<ISolrOperations<Entity>>();
     provider.Expect(x => x.GetService(typeof (IReadOnlyMappingManager))).Return(mapper);
     provider.Expect(x => x.GetService(typeof (ISolrOperations<Entity>))).Return(solr);
     var addParameters = new AddParameters {CommitWithin = 4343};
     var helper = new CfgHelper(provider);
     helper.Configure(nhConfig, true, addParameters);
     var listener = nhConfig.EventListeners.PostInsertEventListeners[0];
     Assert.That(listener, Is.InstanceOf<SolrNetListener<Entity>>());
     Assert.AreEqual(addParameters, ((IListenerSettings)listener).AddParameters);
 }
Exemplo n.º 26
0
        private void loadSetting()
        {
            var aa = new CfgHelper("sCount");

            try
            {
                sCount = int.Parse(aa.Value); //定时
            }
            catch (Exception exception)
            {
            }
            try
            {
                wifiOpen = new CfgHelper("wifiOpen").Value; //白名单 wifi
            }
            catch (Exception e)
            {
            }
            try
            {
                wifiStop = new CfgHelper("wifiStop").Value; //黑名单 wifi
            }
            catch (Exception e)
            {
            } // voice = false, contain = true;
            try
            {
                contain = bool.Parse(new CfgHelper("contain").Value); // wifi包含名称时起作用还是连接时
            }
            catch (Exception e)
            {
            }
            if (!string.IsNullOrEmpty(wifiOpen) || !string.IsNullOrEmpty(wifiStop))
            {
                string curWifiName = "";
                var    wifis       = Form2.getWifis(out curWifiName);
                if (contain)
                {
                    if (wifis.Contains(wifiOpen))
                    {
                        checkBox1.Enabled = false;
                        sCount            = 0;
                        label1.Text       = "wifi有白名单!立即启动";
                    }
                    else if (wifis.Contains(wifiStop))
                    {
                        timer1.Stop();
                        label1.Text = "wifi在黑名单!暂停启动";
                        if (Close)
                        {
                            this.Close();
                        }
                        黑名单时进行的操作事件("黑名单启动项1");
                    }
                }
                else if (curWifiName == wifiOpen)
                {
                    checkBox1.Enabled = false;
                    sCount            = 0;
                    label1.Text       = "wifi有白名单!立即启动";
                }
                else if (curWifiName == wifiStop)
                {
                    timer1.Stop();
                    label1.Text = "wifi在黑名单!暂停启动";
                    if (Close)
                    {
                        this.Close();
                    }
                    黑名单时进行的操作事件("黑名单启动项1");
                }
            }
            try
            {
                voice = bool.Parse(new CfgHelper("voice").Value); //音量
            }
            catch (Exception e)
            {
            }
            try
            {
                voiceNum = int.Parse(new CfgHelper("voiceNum").Value); //白名单 wifi
            }
            catch (Exception e)
            {
            }
            try
            {
                Close = bool.Parse(new CfgHelper("Close").Value); //音量
            }
            catch (Exception e)
            {
            }
        }
Exemplo n.º 27
0
        public void Does_not_override_existing_listeners() {
            var nhConfig = ConfigurationExtensions.GetNhConfig();

            var mockListener = new MPostInsertEventListener();
            nhConfig.SetListener(ListenerType.PostInsert, mockListener);

            var mapper = new MReadOnlyMappingManager();
            mapper.getRegisteredTypes += () => new[] {typeof (Entity)};

            var solr = new MSolrOperations<Entity>();

            var provider = new MServiceProvider();
            provider.getService += MServiceLocator.Table(new Dictionary<System.Type, object> {
                {typeof(IReadOnlyMappingManager), mapper},
                {typeof(ISolrOperations<Entity>), solr},
            });

            var helper = new CfgHelper(provider);
            helper.Configure(nhConfig, true);
            Assert.AreEqual(2, nhConfig.EventListeners.PostInsertEventListeners.Length);
        }