コード例 #1
0
        internal MoodlightData(uint ItemId)
        {
            this.ItemId = ItemId;
            DataRow row;

            using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
            {
                queryreactor.setQuery("SELECT enabled,current_preset,preset_one,preset_two,preset_three FROM room_items_moodlight WHERE item_id = " + ItemId);
                row = queryreactor.getRow();
            }
            if (row == null)
            {
                throw new NullReferenceException("No moodlightdata found in the database");
            }
            this.Enabled       = CyberEnvironment.EnumToBool(row["enabled"].ToString());
            this.CurrentPreset = (int)row["current_preset"];
            this.Presets       = new List <MoodlightPreset>();
            this.Presets.Add(MoodlightData.GeneratePreset((string)row["preset_one"]));
            this.Presets.Add(MoodlightData.GeneratePreset((string)row["preset_two"]));
            this.Presets.Add(MoodlightData.GeneratePreset((string)row["preset_three"]));
        }
コード例 #2
0
        internal void UpdatePreset(int Preset, string Color, int Intensity, bool BgOnly, bool Hax = false)
        {
            if (!MoodlightData.IsValidColor(Color) || (!MoodlightData.IsValidIntensity(Intensity) && !Hax))
            {
                return;
            }
            string text;

            switch (Preset)
            {
            case 2:
                text = "two";
                goto IL_43;

            case 3:
                text = "three";
                goto IL_43;
            }
            text = "one";
IL_43:
            using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
            {
                queryreactor.setQuery(string.Concat(new object[]
                {
                    "UPDATE room_items_moodlight SET preset_",
                    text,
                    " = '@color,",
                    Intensity,
                    ",",
                    CyberEnvironment.BoolToEnum(BgOnly),
                    "' WHERE item_id = ",
                    this.ItemId
                }));
                queryreactor.addParameter("color", Color);
                queryreactor.runQuery();
            }
            this.GetPreset(Preset).ColorCode      = Color;
            this.GetPreset(Preset).ColorIntensity = Intensity;
            this.GetPreset(Preset).BackgroundOnly = BgOnly;
        }