Exemple #1
0
        public void Set(string name, string value)
        {
            InitialiseCache();

            using var db = new ImageContext();

            if (_cache.TryGetValue(name, out ConfigSetting existing))
            {
                if (String.IsNullOrEmpty(value))
                {
                    // Setting set to null - delete from the DB and cache
                    db.ConfigSettings.Remove(existing);
                    _cache.Remove(name);
                }
                else
                {
                    // Setting set to non-null - save in the DB and cache
                    existing.Value = value;
                    db.ConfigSettings.Update(existing);
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(value))
                {
                    // Existing setting set to non-null - create in the DB and cache.
                    existing = new ConfigSetting {
                        Name = name, Value = value
                    };
                    _cache[name] = existing;
                    db.ConfigSettings.Add(existing);
                }
            }

            db.SaveChanges("SaveConfig");

            // Clear the cache and re-initialise it
            InitialiseCache(true);
        }
        protected ConfigBase Instantiate(ConfigBaseMetadata metadata, PluginRuntime pluginRuntime)
        {
            ServiceRegistration.Get <ILogger>().Debug("ConfigurationNode: Loading configuration item '{0}'", metadata.Location);
            ConfigBase result;

            if (metadata.GetType() == typeof(ConfigGroupMetadata))
            {
                result = new ConfigGroup();
            }
            else if (metadata.GetType() == typeof(ConfigSectionMetadata))
            {
                result = new ConfigSection();
            }
            else if (metadata.GetType() == typeof(ConfigSettingMetadata))
            {
                ConfigSettingMetadata csm = (ConfigSettingMetadata)metadata;
                try
                {
                    ConfigSetting cs = (ConfigSetting)pluginRuntime.InstantiatePluginObject(csm.ClassName);
                    if (cs == null)
                    {
                        throw new ArgumentException(string.Format("Configuration class '{0}' not found", csm.ClassName));
                    }
                    cs.Load();
                    result = cs;
                }
                catch (Exception ex)
                {
                    ServiceRegistration.Get <ILogger>().Error("Error loading configuration class '{0}'", ex, csm.ClassName);
                    return(null);
                }
            }
            else
            {
                throw new NotImplementedException(string.Format("Unknown child class '{0}' of '{1}'", metadata.GetType().FullName, typeof(ConfigBaseMetadata).FullName));
            }
            result.SetMetadata(metadata);
            return(result);
        }
Exemple #3
0
        public ConfigSetting GetSettingMember(ConfigSetting setting, string name)
        {
            if (setting == null)
            {
                throw new ArgumentNullException(nameof(setting));
            }
            else if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            IntPtr configSettingPointer = Imports.config_setting_get_member(setting.SettingPointer, name);

            if (configSettingPointer == IntPtr.Zero)
            {
                return(null);
            }
            else
            {
                return(new ConfigSetting(configSettingPointer));
            }
        }
Exemple #4
0
        static void SetProjectBasePath(string modulePath)
        {
            modulePath = PathTool.NormalizePath(modulePath);
            DirectoryInfo dirInfo = new DirectoryInfo(modulePath);

            while (dirInfo != null)
            {
                var files = dirInfo.GetFiles(PROJECT_ROOT_MARK_FILE);
                if (files != null && files.Length >= 1)
                {
                    break;
                }
                dirInfo = dirInfo.Parent;
            }

            if (dirInfo == null)
            {
                return;
            }

            ConfigSetting.SetValue("PROJECT_BASE", dirInfo.FullName);
        }
Exemple #5
0
        static partial void CheckConfigProvider(ConfigSetting setting, ref bool sourceDone)
        {
            var configProvider = setting.ConfigProvider;

            if (!string.IsNullOrEmpty(configProvider))
            {
                var providerType = TypeHelper.CreateType(configProvider, false);
                if (providerType != null)
                {
                    object returnValue;
                    if (TypeHelper.TryInvoke(providerType, "GetConfigSetting", out returnValue, false, setting.ConfigSource))
                    {
                        var configSetting = returnValue as ConfigSetting;
                        if (configSetting != null)
                        {
                            setting.Merge(configSetting);
                            sourceDone = true;
                        }
                    }
                }
            }
        }
        private void SkinPage_Loaded(object sender, EventArgs e)
        {
            var    files   = Directory.EnumerateFiles(Environment.CurrentDirectory + "\\Contents\\bg\\bg", "*.*", SearchOption.AllDirectories);
            string nowPath = ConfigSetting.GetXmlValue("skinBg", "path");

            foreach (string item in files)
            {
                if (Path.GetExtension(item) == ".png" || Path.GetExtension(item) == ".jpg" || System.IO.Path.GetExtension(item) == ".bmp")
                {
                    ImageRadioButton imageRadioButton = new ImageRadioButton()
                    {
                        Source = new BitmapImage(new Uri(item)), GroupName = "images"
                    };
                    imageRadioButton.Checked += ImageRadioButton_Checked;
                    defPanel.Children.Insert(defPanel.Children.Count - 1, imageRadioButton);
                    if (nowPath == item)
                    {
                        imageRadioButton.IsChecked = true;
                    }
                }
            }
        }
Exemple #7
0
        public ConfigSetting AddSetting(ConfigSetting parent, string name, int type)
        {
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            else if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            IntPtr configSettingPointer = Imports.config_setting_add(parent.SettingPointer, name, type);

            if (configSettingPointer == IntPtr.Zero)
            {
                return(null);
            }
            else
            {
                return(new ConfigSetting(configSettingPointer));
            }
        }
Exemple #8
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            mainWindow.Closed += (s, ee) =>
            {
                try
                {
                    Close();
                }
                catch { }
            };
            string bgPath = Environment.CurrentDirectory + ConfigSetting.GetXmlValue("skinBg", "path");

            SetBackgroundFromName(bgPath);
            //(backOpPanel.Background as ImageBrush).ImageSource = new BitmapImage(new Uri(bgPath, UriKind.Absolute));

            if (SystemHelper.IsWindow10)//判断是否为win10
            {
                //CompositionTarget.Rendering += WindowPositionChangeWithAero;
                AeroHelper.EnableAero(this, true);
                Width           = Width - ShadowMargin.Left - ShadowMargin.Right - 2;
                Height          = Height - ShadowMargin.Top - ShadowMargin.Bottom - 2;
                mainGrid.Margin = new Thickness(-1, -25, -1, -1);
                ShadowMargin    = new Thickness(0);

                backOpPanel.SetValue(Grid.RowSpanProperty, 1);
                backBlur.SetValue(Grid.RowSpanProperty, 1);
                backWhite.SetValue(Grid.RowSpanProperty, 1);
                WindowEntranceBackgroundMode = 5;
            }
            else
            {
                //CompositionTarget.Rendering += WindowPositionChange;
            }

            mainWindow.Show();
            OnLocationChanged(new EventArgs());
            mainGrid.Visibility = Visibility.Visible;
        }
Exemple #9
0
        private void Initialize()
        {
            //
            // DeamonServiceInstaller
            //
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.Load("DeamonService.exe.config");
            ConfigSetting serrings          = new ConfigSetting(xmldoc.DocumentElement);
            ConfigSetting installerSettings = serrings["Installer"];

            this.DeamonServiceInstaller.DisplayName = installerSettings["DisplayName"].Value;
            this.DeamonServiceInstaller.ServiceName = installerSettings["ServiceName"].Value;
            this.DeamonServiceInstaller.Description = installerSettings["Description"].Value;

            this.DeamonServiceInstaller.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
            //
            // DeamonServiceProcessInstaller
            //
            this.DeamonServiceProcessInstaller.Account  = System.ServiceProcess.ServiceAccount.LocalSystem;
            this.DeamonServiceProcessInstaller.Password = null;
            this.DeamonServiceProcessInstaller.Username = null;
        }
        /// <summary>
        /// 选择图片
        /// </summary>
        /// <param name="bgPath">被选择的图片路径</param>
        private void SelectImage(string bgPath)
        {
            string thumbPath = Path.Combine(AyuiConfig.AYUI_BackgroundImageThumbDirectoryPath, "z自定义", Path.GetFileName(bgPath));

            ConfigSetting.SetXmlValue("skinBg", "path", bgPath.Replace(Environment.CurrentDirectory, ""));
            if (!File.Exists(thumbPath))
            {
                Bitmap      bm          = new Bitmap(bgPath);
                BitmapImage bi          = bm.SetSize(128, 72).ToBitmapImage();
                byte[]      thumbBuffer = bi.ToBytes();
                if (!Directory.Exists(Path.GetDirectoryName(thumbPath)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(thumbPath));
                }
                FileStream fs = new FileStream(thumbPath, FileMode.Create);
                fs.Write(thumbBuffer, 0, thumbBuffer.Length);
                fs.Close();
            }
            ConfigSetting.SetXmlValue("skinBg", "thumb", thumbPath.Replace(Environment.CurrentDirectory, ""));
            //更新主题色,使出反编译大法才找到下面这个方法↓
            ThemeManager.AYUI(Application.Current);
            BackgroundImageChanged?.Invoke(this, new StringEventArgs(bgPath));
        }
Exemple #11
0
        public static void InitialConfig()
        {
            if (string.IsNullOrEmpty(UserDir))
            {
                throw new ArgumentException("UserDir 尚未初始化");
            }

            string filename = Path.Combine(UserDir, "settings.xml");

            _config = ConfigSetting.Open(filename, true);

#if NO
            try
            {
                _config = ConfigSetting.Open(filename, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"配置文件 {filename} 装载失败:{ex.Message}");
                _config = ConfigSetting.Create(filename);
            }
#endif
        }
Exemple #12
0
        public static Bitmap Run(Bitmap arg, ConfigSetting cfg)
        {
            ((beans.blob_tag)arg.Tag).minEncloseCircle = CvInvoke.MinEnclosingCircle(((beans.blob_tag)arg.Tag).contour);



            // or
            var m  = ((beans.blob_tag)arg.Tag).moments = ((beans.blob_tag)arg.Tag).moments ?? CvInvoke.Moments(((beans.blob_tag)arg.Tag).contour, false);
            int cx = (int )(m.M10 / m.M00);
            int cy = (int)(m.M01 / m.M00);

            Point p_Centroid = new Point(cx, cy);
            var   vp_Contour = ((beans.blob_tag)arg.Tag).contour;

            Point  p_Contour_first   = vp_Contour[0];
            double circumCirc_Radius = ComputeDistance((p_Centroid), p_Contour_first);
            double inscriCirc_Radius = ComputeDistance(p_Centroid, p_Contour_first);

            for (int p = 0; p < vp_Contour.Size; p++)
            {
                Point  p_Contour_current = vp_Contour[p];
                double r = ComputeDistance(p_Centroid, p_Contour_current);
                if (r < inscriCirc_Radius)
                {
                    inscriCirc_Radius = r;
                }
                if (r > circumCirc_Radius)
                {
                    circumCirc_Radius = r;
                }
            }

            ((beans.blob_tag)arg.Tag).Rmax = new distance(circumCirc_Radius);
            ((beans.blob_tag)arg.Tag).Rmin = new distance(inscriCirc_Radius);

            return(arg);
        }
Exemple #13
0
        public void Initial()
        {
            string filename = Path.Combine(this.BinDir, "settings.xml");

            // Console.WriteLine(filename);

            _config = ConfigSetting.Open(filename, true);

            this.DataDir = _config.Get("default", "data_dir", "c:\\capo_data");

            // 创建备份数据目录
            this.ShadowDataDir = this.DataDir + "_shadow";

            if (Directory.Exists(this.DataDir))
            {
#if NO
                string strError = "";
                int    nRet     = PathUtil.CopyDirectory(this.DataDir, this.ShadowDataDir, true, out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    return;
                }
#endif
                if (BackupDataDir(out string strError) == -1)
                {
                    MessageBox.Show(this, strError);
                    return;
                }
            }
            else
            {
                this.ShadowDataDir = "";
            }

            FillInstance(this.DataDir);
        }
Exemple #14
0
        private static IServiceLocator Setup()
        {
            var            config  = ConfigHelper.LoadConfigSettingFromAssemblies(typeof(ServiceLocator).Assembly, null, null, null);
            StartupSetting setting = null;

            if (config != null)
            {
                config = config["htb.devfx"];
                if (config != null)
                {
                    setting = ConfigSetting.ToSetting <StartupSetting>(config, "startup");
                }
            }
            ServiceLocatorSetting locatorSetting = null;

            if (setting != null && setting.CoreSetting != null)
            {
                locatorSetting = setting.CoreSetting.ServiceLocatorSetting;
            }
            IServiceLocator instance = null;

            if (locatorSetting != null && !string.IsNullOrEmpty(locatorSetting.TypeName))
            {
                var typeName = locatorSetting.TypeName;
                instance = (IServiceLocator)TypeHelper.CreateObject(typeName, typeof(IServiceLocator), false);
            }
            if (instance == null)
            {
                instance = new ServiceLocatorInternal();
            }
            if (instance is IServiceLocatorInternal)
            {
                ((IServiceLocatorInternal)instance).Init(locatorSetting);
            }
            return(instance);
        }
Exemple #15
0
        public IHttpActionResult PutConfigSetting(int id, CarSalesConfigSetting carSalesConfigSetting)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != carSalesConfigSetting.ID)
            {
                return(BadRequest());
            }
            ConfigSetting configSetting = new ConfigSetting();

            configSetting.ID = carSalesConfigSetting.ID;
            configSetting.VehicleAdvertisementNextRefNo = carSalesConfigSetting.VehicleAdvertisementNextRefNo;

            db.Entry(configSetting).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ConfigSettingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #16
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            using (var db = new ApplicationDbContext()) {
                string controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName.ToUpper();
                ViewBag.CurrentController = controller;

                var vendors = db.Vendors
                              //.Where(x => x.IsPublish.HasValue && x.IsPublish.Value)
                              .OrderBy(x => x.OrderNo)
                              .ToList();
                ViewBag.Vendors = vendors;

                var cofig = db.ConfigSettings.FirstOrDefault();
                if (cofig == null)
                {
                    cofig = new ConfigSetting();
                }
                ViewBag.ConfigSetting = cofig;

                var productCategories = db.ProductCategories.ToList();
                ViewBag.ProductCategories = productCategories;

                var visitorCounter = db.VisitorCounters.FirstOrDefault();
                if (visitorCounter == null)
                {
                    visitorCounter = new VisitorCounter();
                }
                ViewBag.VisitorCounter = visitorCounter;

                var plugins = db.Plugins
                              .Where(x => x.Show)
                              .OrderBy(x => x.OrderNo)
                              .ToList();
                ViewBag.Plugins = plugins;
            }
        }
Exemple #17
0
        //public IActionResult Index()
        //{
        //    return View();
        //}
        /// <summary>
        /// 登录 页面
        /// </summary>
        /// <returns></returns>
        public IActionResult Login()
        {
            var number = distributedCache.GetInt(errorCountKey);

            ViewBag.Title = "请登录";
            SetLocale();
            ConfigSetting configSetting = new ConfigSetting();

            ViewBag.quickLogin    = Request.Cookies["token"] != null;
            ViewBag.ConfigSetting = configSetting;
            //是否需要验证码服务
            if (this.config.SecurityConfig.NeedVerificationCode == NeedVerificationCode.OFF ||
                ((this.config.SecurityConfig.NeedVerificationCode == NeedVerificationCode.AUTO) && number < 10))
            {
                ViewBag.needCaptcha = "false";
            }
            else
            {
                ViewBag.needCaptcha = "true";
            }
            ViewBag.errorCount = number;

            return(View());
        }
Exemple #18
0
 /// <summary>
 /// Add services to the application and configure service provider
 /// </summary>
 /// <param name="services">Collection of service descriptors</param>
 public IServiceProvider ConfigureServices(IServiceCollection services)
 {
     ConfigSetting.LoadConfig(Configuration);
     return(services.ConfigureApplicationServices(Configuration));
 }
Exemple #19
0
 public override bool IsSettingSupported(ConfigSetting setting)
 {
     return(setting != null && setting is PathEntry);
 }
Exemple #20
0
 public ConfigSetting AddStringSetting(ConfigSetting parent, string name)
 {
     return(AddSetting(parent, name, Imports.CONFIG_TYPE_STRING));
 }
Exemple #21
0
        public void ConfigSetting()
        {
            ConfigSetting setting = new ConfigSetting("name", "value");
            Assert.AreEqual("name = value", setting.Content);

            setting.Value = "test";
            Assert.AreEqual("name = test", setting.Content);
        }
Exemple #22
0
partial         static void CheckConfigProvider(ConfigSetting setting, ref bool sourceDone);
 public DirectoryServer() : base(new Factory(), new DirectoryClient())
 {
     _config = ConfigSetting.Blank;
 }
Exemple #24
0
        public static Bitmap Run(Bitmap arg, ConfigSetting cfg)
        {
            ((beans.blob_tag)arg.Tag).moments = CvInvoke.Moments(((beans.blob_tag)arg.Tag).contour, false);

            return(arg);
        }
Exemple #25
0
        /// <summary>
        /// Performs loader-related initialization
        /// </summary>
        public virtual bool init()
        {
            Program.setD3Foreground();

            //Load Config
            _config = new Xmlconfig("config.xml", false).Settings;

            // Load scripts
            ///////////////////////////////////////////////
            Log.write("Loading scripts..");

            //Obtain the bot and operation types
            ConfigSetting scriptConfig = new Xmlconfig("scripts.xml", false).Settings;
            IList<ConfigSetting> scripts = scriptConfig["scripts"].GetNamedChildren("type");

            //Load the bot types
            List<Scripting.InvokerType> scriptingBotTypes = new List<Scripting.InvokerType>();

            foreach (ConfigSetting cs in scripts)
            {	//Convert the config entry to a bottype structure
                scriptingBotTypes.Add(
                    new Scripting.InvokerType(
                            cs.Value,
                            cs["inheritDefaultScripts"].boolValue,
                            cs["scriptDir"].Value)
                );
            }

            //Load them into the scripting engine
            Scripting.Scripts.loadBotTypes(scriptingBotTypes);

            try
            {	//Loads!
                bool bSuccess = Scripting.Scripts.compileScripts();
                if (!bSuccess)
                {	//Failed. Exit
                    Log.write(TLog.Error, "Unable to load scripts.");
                    return false;
                }
            }
            catch (Exception ex)
            {	//Error while compiling
                Log.write(TLog.Exception, "Exception while compiling scripts:\n" + ex.ToString());
                return false;
            }

            string invokerType = _config["General/botType"].Value;
            //Instance our botType
            if (!Scripting.Scripts.invokerTypeExists(invokerType))
            {
                Log.write(TLog.Error, "Unable to find botType '{0}'", invokerType);
                return false;
            }

            return true;
        }
 public override bool IsSettingSupported(ConfigSetting setting)
 {
     return(setting == null ? false : setting is SkinConfigSetting);
 }
Exemple #27
0
        public bool CheckTypeMatch(ConfigSetting setting)
        {
            if (setting.Default != null)
            {
                switch (setting.ConfigValueType)
                {
                case SettingType.NUMERIC:
                    if (setting.Default is int)
                    {
                        return(true);
                    }
                    break;

                case SettingType.FLOAT:
                    if (setting.Default is float)
                    {
                        return(true);
                    }
                    break;

                case SettingType.STRING:
                    if (setting.Default is string)
                    {
                        return(true);
                    }
                    break;

                case SettingType.BOOL:
                    if (setting.Default is bool)
                    {
                        return(true);
                    }
                    break;

                case SettingType.LIST:
                    if (setting.Default is string[])
                    {
                        return(true);
                    }
                    break;

                case SettingType.NUMERIC_LIST:
                    if (setting.Default is int[])
                    {
                        return(true);
                    }
                    break;

                case SettingType.DICTIONARY:
                    if (setting.Default is Dictionary <string, string> )
                    {
                        return(true);
                    }
                    break;

                case SettingType.NUMERIC_DICTIONARY:
                    if (setting.Default is Dictionary <int, int> )
                    {
                        return(true);
                    }
                    break;
                }
            }
            return(false);
        }
Exemple #28
0
 public ConfigParams(ConfigSetting config)
 {
     _config = config;
 }
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                ConfigSetting ds = new ConfigSetting();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "ConfigDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }
Exemple #30
0
        /// <summary>
        /// Returns the information if the specified <paramref name="setting"/> is supported by this
        /// configuration plugin.
        /// </summary>
        /// <param name="setting">The setting to check.</param>
        /// <returns><c>true</c>, if the setting is supported, i.e. it can be displayed in the GUI, else
        /// <c>false</c>.</returns>
        protected bool IsSettingSupported(ConfigSetting setting)
        {
            ConfigurationController controller = FindConfigurationController(setting);

            return(controller != null && controller.IsSettingSupported(setting));
        }
Exemple #31
0
        public void ProcessRequest(HttpContext context)
        {
            //ILog logs = LogManager.GetLogger("index");

            context.Response.ContentType = "text/plain";


            //签名验证
            if (context.Request["id"] != null && context.Request["sign"] != null && context.Request["nonce_str"] != null)
            {
                string request_sign = context.Request["sign"];

                string nonce_str = context.Request["nonce_str"];
                string timestamp = context.Request["timestamp"];

                int    id = int.Parse(context.Request["id"]);
                string sn = new GZH.CL.Config.AgentConfig().GetItem(id).sn;

                if (AgentSign.CheckRequestSign(request_sign, nonce_str, timestamp, id))
                {
                    if (context.Request["scope"] == null || context.Request["redirect"] == null)
                    {
                        context.Response.Write("abort request");
                        context.Response.End();
                    }

                    if (!CheckConfig(id))
                    {
                        context.Response.Write("abort config");
                        context.Response.End();
                    }

                    string scope        = context.Request["scope"];
                    string callback_url = context.Request["redirect"];

                    if (!string.IsNullOrWhiteSpace(scope) && callback_url.IndexOf("http://") != -1)
                    {
                        string state = scope == "snsapi_userinfo" ? "1" : "0";
                        state += "|" + id;
                        string redirect_uri = "http://" + HttpContext.Current.Request.Url.Host + "/api/authorize/redirect_uri.ashx";
                        string requestUri   = ConfigSetting.GetWeixinWeb().AuthorizeUrl;

                        callback_url  = context.Server.UrlEncode(callback_url);
                        redirect_uri += "?callback_url=" + callback_url;

                        requestUri += "?appid=" + ConfigSetting.GetWeixin().AppID;
                        requestUri += "&redirect_uri=" + context.Server.UrlEncode(redirect_uri);
                        requestUri += "&response_type=code&scope=" + scope + "&state=" + state + "#wechat_redirect";


                        context.Response.Redirect(requestUri);
                    }
                }
                else
                {
                    context.Response.Write("abort signature");
                }
            }
            else
            {
                context.Response.Write("abort signature request");
            }
        }
Exemple #32
0
        public static Bitmap Run(Bitmap arg, ConfigSetting cfg)
        {
            ((beans.blob_tag)arg.Tag).perimetr = new distance(CvInvoke.ArcLength(((beans.blob_tag)arg.Tag).contour, true));

            return(arg);
        }
Exemple #33
0
        public static void SetDbConfigVals()
        {
            ConfigSetting applicationMode = new ConfigSetting("ApplicationMode", ApplicationMode.ToString());

            Sort.Business.Config.setValue(applicationMode);
        }