예제 #1
0
        public string RegisterStationaryAirConditioner(string manufacturer, string model, string energyEfficiencyRating, int powerUsage)
        {
            Conditioner conditioner = new Conditioner(manufacturer, model, energyEfficiencyRating, powerUsage);

            AirConditioner.AirConditioners.Add(conditioner);
            throw new InvalidOperationException(string.Format(Constants.Register, conditioner.Model, conditioner.Manufacturer));
        }
        private void BlokWnioskowaniaKlimatyzacji(ref Conditioner Out, ChartItem5Value in1, ChartItem1Value in2)
        {
            double min, low, mid, mor, max, join;

            for (int i = 0; i < Out.Count; i++)
            {
                if (in1.Max + in1.Mor + in1.Mid < 1 && in1.Min + in1.Low > 0)
                {
                    min = Min(in2.Y, 1, Out[i].Min);
                }
                else
                {
                    min = Min(in2.Y, in1.Mid, Out[i].Min);
                }

                mid = Min(in2.Y, in1.Mor, Out[i].Mid);
                if (in1.Max + in1.Mor + in1.Mid < 1 && in1.Min + in1.Low == 0)
                {
                    max = Min(in2.Y, 1, Out[i].Max);
                }
                else
                {
                    max = Min(in2.Y, in1.Max, Out[i].Max);
                }

                low = 0;
                mor = 0;

                join = Max(min, low, mid, mor, max);

                Out[i].ZbiorWnioskowania = join;
                Out[i].Text = Out.AddTextJoin(Out[i].Text, join);
            }
            BlokWyostrzania(ref Out);
        }
예제 #3
0
        public string RegisterPlaneAirConditioner(string manufacturer, string model, int volumeCoverage, string electricityUsed)
        {
            Conditioner conditioner = new Conditioner(manufacturer, model, volumeCoverage, electricityUsed);

            AirConditioner.AirConditioners.Add(conditioner);
            throw new InvalidOperationException(
                      string.Format(Constants.Register, conditioner.Model, conditioner.Manufacturer));
        }
예제 #4
0
        public string TestAirConditioner(string manufacturer, string model)
        {
            Conditioner conditioner = AirConditioner.GetAirConditioner(manufacturer, model);

            conditioner.EnergyRating += 5;
            var mark = conditioner.Test();

            AirConditioner.Reports.Add(new Report(conditioner.Manufacturer, conditioner.Model, mark));
            throw new InvalidOperationException(string.Format(Constants.Test, model, manufacturer));
        }
예제 #5
0
        public PartialViewResult Add(string catchhall)
        {
            var    catchs = catchhall.Split('/');
            Device newDevice;

            if (!String.IsNullOrEmpty(catchs[0]))
            {
                using (DeviceContext db = new DeviceContext())
                {
                    switch (catchs[0])
                    {
                    case "light":
                        newDevice = new Light("Лампа", new Modeslvl(new string[] { "низкий", "средний", "высокий", "макс." }));
                        db.Devices.Add(newDevice);
                        db.SaveChanges();
                        return(PartialView("PartLight", newDevice));

                    case "tv":
                        newDevice = new TV("TV", new Modeslvl(new string[] { "низкий", "средний", "высокий", "макс." }), new Volume100(), new Channel100());
                        db.Devices.Add(newDevice);
                        db.SaveChanges();
                        return(PartialView("PartTV", newDevice));

                    case "cond":
                        newDevice = new Conditioner("Cond", new Termostat());
                        db.Devices.Add(newDevice);
                        db.SaveChanges();
                        return(PartialView("PartCond", newDevice));

                    case "ref":
                        newDevice = new Refrigerator("Ref", new Modeslvl(new string[] { "эконом.", "авто", "интенс." }), new RefTemp(), new RefrigeratorSpace(50));
                        db.Devices.Add(newDevice);
                        db.SaveChanges();
                        return(PartialView("PartRef", newDevice));

                    case "ref_add":
                        return(PartialView("PartRefItem", new int[] { Convert.ToInt32(catchs[1]), Convert.ToInt32(catchs[2]) }));

                    case "micr":
                        newDevice = new Microwave("Micr", new Modeslvl((new string[] { "разморозка", "низкий", "средний", "макс" })), new NetTimer());
                        db.Devices.Add(newDevice);
                        db.SaveChanges();
                        return(PartialView("PartMicrowave", newDevice));

                    default:
                        throw new Exception("Bad Request");
                    }
                }
            }
            else
            {
                throw new Exception("Bad Request");
            }
        }
예제 #6
0
            public static void F()
            {
                Pult        pult = new Pult();
                Conditioner tv   = new Conditioner();

                pult.SetCommand(new ConditionerOnCommand(tv));
                pult.PressButton();
                pult.PressUndo();

                Console.ReadLine();
            }
        private void BlokWyostrzania(ref Conditioner Out)
        {
            double up    = 0;
            double above = 0;

            for (int i = 1; i < Out.Count; i++)
            {
                up    += Out[i].X * Out[i].ZbiorWnioskowania;
                above += Out[i].ZbiorWnioskowania;
            }
            CenterOfGravityConditioner = (above == 0) ? 0 : Math.Round(up / above);
        }
예제 #8
0
        public void Evaluate(int SpreadMax)
        {
            COLLADAUtil.Logger = new LoggerWrapper(FLogger);

            //if any of the inputs has changed
            //recompute the outputs
            if (FFileNameInput.IsChanged)
            {
                FColladaDocument = null;
                FColladaModel    = null;
                FColladaModelOutput.SliceCount = 0;
                FInfoOutput.SliceCount         = 0;

                string filename = FFileNameInput[0];
                if (string.IsNullOrEmpty(filename) || !File.Exists(filename))
                {
                    return;
                }

                FLogger.Log(LogType.Message, "Loading " + filename);
                try
                {
                    FColladaDocument = new Document(filename);
                    Conditioner.ConvexTriangulator(FColladaDocument);
                    // not necessary anymore
                    //Conditioner.Reindexor(colladaDocument);
                    FColladaModel = new Model(FColladaDocument);

                    FColladaModelOutput.SliceCount = 1;
                    FColladaModelOutput[0]         = FColladaModel;
                    ConfigurateModel();

                    FLogger.Log(LogType.Message, filename + " loaded.");
                }
                catch (Exception e)
                {
                    FLogger.Log(e);
                }
            }

            if (FInfoNeedsUpdate)
            {
                FInfoNeedsUpdate       = false;
                FInfoOutput.SliceCount = FInfo.Count;
                for (int i = 0; i < FInfo.Count; i++)
                {
                    FInfoOutput[i] = FInfo[i];
                }
            }
        }
예제 #9
0
        public void Switch(int id)
        {
            Conditioner Conditioner = this.GetConditionerById(id);

            if (Conditioner.IsOn)
            {
                Conditioner.Off();
            }
            else
            {
                Conditioner.On();
            }
            this.Unit.SaveChanges();
        }
        //przyjmujemy wszystkie wartosci (pracujemy na referencjach wykresow ktore beda modyfikowane) potem wyciągamy indexy wrazie potrzeby(godzina,temp) i lecimy
        public void Rozmywanie(Heat Out1, Conditioner Out2, Temp InChart1, int value1, WorkHour InChart2, int index2)
        {
            int index1 = 0;

            for (int i = 0; i < InChart1.Count; i++)
            {
                if (InChart1[i].X == value1)
                {
                    index1 = i;
                }
            }
            temp = InChart1[index1].X;//dla Labela
            BlokWnioskowaniaOgrzewania(ref Out1, InChart1[index1], InChart2[index2]);
            BlokWnioskowaniaKlimatyzacji(ref Out2, InChart1[index1], InChart2[index2]);
        }
예제 #11
0
        protected void ConditionerOnOffButton_Click(object sender, EventArgs e)
        {
            Conditioner tempDevice = (Conditioner)deviceDictionary[i];

            deviceDictionary.Remove(i);
            if (tempDevice.Power)
            {
                tempDevice.Power = false;
            }
            else
            {
                tempDevice.Power = true;
            }
            deviceDictionary.Add(i, tempDevice);
            Page.Session["Devices"] = deviceDictionary;
            Display();
        }
예제 #12
0
        static void Main()
        {
            var auto1 = new BMW();
            var auto2 = new AUDI();

            PrintAuto(auto1);
            PrintAuto(auto2);
            Console.WriteLine("----------------------------------");

            var auto3 = new Insurance(new BMW());
            var auto4 = new Conditioner(new Tires(new AUDI()));
            var auto5 = new Tires(new Conditioner(new Insurance(new BMW())));

            PrintAuto(auto3);
            PrintAuto(auto4);
            PrintAuto(auto5);
        }
예제 #13
0
        public Device CreateDevice(string TypeOfDevice)
        {
            switch (TypeOfDevice)
            {
                case ("refrigerator"):
                    NewDevice = new Refrigerator();
                    NewDevice.deviceNotificator +=  ServiceMessages.Message;
                    return NewDevice;
                case ("conditioner"):
                    NewDevice = new Conditioner();
                    return NewDevice;
                case ("radio"):
                default:
                    NewDevice = new Radio();
                    return NewDevice;

            }
        }
예제 #14
0
        protected void ConditionrApplyButton_Click(object sender, EventArgs e)
        {
            Conditioner tempDevice = (Conditioner)deviceDictionary[i];

            if (tempDevice.Power)
            {
                deviceDictionary.Remove(i);
                int  value;
                bool result = Int32.TryParse(conditionerTemperatureBound.Text, out value);
                tempDevice.Temperature.CurrentValue = value;
                deviceDictionary.Add(i, tempDevice);
                Page.Session["Devices"] = deviceDictionary;
                Display();
            }
            else
            {
                Display();
                conditionerErrPlaceHolder.Controls.Add(Span("УСТРОЙСТВО НЕ ВКЛЮЧЕНО!"));
            }
        }
예제 #15
0
        public void Mock_TestAirConditionerShouldThrow()
        {
            //Arrange

            var mock = new Mock <Controller>();

            mock.Setup(c => c.TestAirConditioner(null, null))
            .Returns(new AirConditioner().ToString);

            //Act

            var conditioner = new Conditioner(null, null, 0, null);

            conditioner.EnergyRating = 10;

            var result = conditioner;

            //Assert

            Assert.AreEqual(10, result.EnergyRating);
        }
예제 #16
0
 protected void AddConditionerButton_Click(object sender, EventArgs e)
 {
     if (Page != null)
     {
         if ((Conditioner)Page.Session["EmptyConditioner"] != null)
         {
             conditioner                        = (Conditioner)Page.Session["EmptyConditioner"];
             conditioner.Name                   = nameTextBox.Text.ToString();
             conditioner.Temperature            = graphicFactory.CreateEmptySlider();
             conditioner.Temperature.SliderName = "Температура";
             int  minTempValue;
             bool result1 = Int32.TryParse(minTemperatureValueTextBox.Text, out minTempValue);
             int  maxTempValue;
             bool result2 = Int32.TryParse(maxTemperatureValueTextBox.Text, out maxTempValue);
             conditioner.Temperature.MinValue     = minTempValue;
             conditioner.Temperature.CurrentValue = minTempValue;
             conditioner.Temperature.MaxValue     = maxTempValue;
             if (result1 && result2)
             {
                 Dictionary <int, Device> devicesDictionary = (Dictionary <int, Device>)Page.Session["Devices"];
                 devicesDictionary.Add((int)Page.Session["NextDeviceId"], conditioner);
                 Page.Session["Devices"]      = devicesDictionary;
                 Page.Session["NextDeviceId"] = (int)Page.Session["NextDeviceId"] + 1;
                 DisplayDeviceControl.Initializer();
                 displayPlaceHolder.Controls.Add(DisplayDeviceControl);
                 Page.Session["EmptyConitioner"] = null;
                 Initializer();
             }
             else
             {
                 Page.Session["EmptyConditioner"] = null;
                 Initializer();
                 Controls.Add(Span("НЕКОРРЕКТНЫЙ ВВОД ДАННЫХ"));
             }
         }
     }
 }
예제 #17
0
        protected void SelectButton_Click(object sender, EventArgs e)
        {
            Page.Session["EmptyUserDevice"]  = null;
            Page.Session["EmptyTV"]          = null;
            Page.Session["EmptyHeater"]      = null;
            Page.Session["EmptyConditioner"] = null;
            secondPlaceHolder.Controls.Clear();
            if (dropDownList.SelectedIndex == 0)
            {
            }

            if (dropDownList.SelectedIndex == 1)
            {
                userDevice         = graphicFactory.CreateEmptyUserDevice();
                userDevice.Sliders = new Dictionary <int, Slider>();
                Page.Session["EmptyUserDevice"] = userDevice;
            }

            if (dropDownList.SelectedIndex == 2)
            {
                tV = graphicFactory.CreateEmptyTV();
                Page.Session["EmptyTV"] = tV;
            }

            if (dropDownList.SelectedIndex == 3)
            {
                heater = graphicFactory.CreateEmptyHeater();
                Page.Session["EmptyHeater"] = heater;
            }

            if (dropDownList.SelectedIndex == 4)
            {
                conditioner = graphicFactory.CreateEmptyConditioner();
                Page.Session["EmptyConditioner"] = conditioner;
            }
            DrawDevice();
        }
예제 #18
0
        static void Backed()
        {
            Console.WriteLine("Hello World!");
            BaseQueryer.Ender l;
            Conditioner       c = new Conditioner();

            var empty = Conditioner.Default;



            Database db = "";

            l = db.Select("username").From("Users");
            Console.WriteLine(l.FullQuery);
            l = db.Select("username").From("Users").Where("abc=$1 AND c LIKE %@0", 5, true);
            Console.WriteLine(l.FullQuery);
            l = db.From("USERS")
                .Where("abc=$1 AND c LIKE %@0 AND IsActive = $2", 5, "gg", true)
                .Order("batman");
            Console.WriteLine(l.FullQuery);
            l = db.Insert("tblUsers")
                .Pair("username", "Neville")
                .Pair("ref", false)
                .Pair("cherar", 'y');
            Console.WriteLine(l.FullQuery);
            l = db.Insert("tblUsers")
                .Keys("username", "isActive")
                .Values(433555, true);
            Console.WriteLine(l.FullQuery);
            l = db.Insert("tblUsers")
                .Keys("username", "isActive")
                .Select("username, id").From("tblUsers").Where("abc=$1 AND c LIKE %@0 AND IsActive = $2", 5, null, true);
            Console.WriteLine(l.FullQuery);
            l = db.Insert("tblUsers", new
            {
                ID       = 66,
                IsActive = false,
                username = "******"
            });
            Console.WriteLine(l.FullQuery);


            l = db.Update("tblFriendRequests")
                .Pair("IsActive", false)
                .Where("ID = $0", 4);
            Console.WriteLine(l.FullQuery);


            l = db.Update("tblUsers")
                .Pair("ID", 66)
                .Pair("IsActive", false);
            Console.WriteLine(l.FullQuery);
            l = db.Update("tblUsers")
                .Pair("ID", 66)
                .Pair("IsActive", false)
                .Where("abc=$1 AND c LIKE %@0 AND IsActive = $2", 5, "gg", true);
            Console.WriteLine(l.FullQuery);
            l = db.Update("tblUsers", new
            {
                ID       = 66,
                IsActive = true,
                username = "******"
            })
                .Where("abc=$1 AND c LIKE %@0 AND IsActive = $2", 5, "gg", true);
            Console.WriteLine(l.FullQuery);
            l = db.Update("tblUsers")
                .Pair("ID", 66)
                .Pair("IsActive", false);
            Console.WriteLine(l.FullQuery);
            var r = Console.ReadLine();


            //

            var a = c["name LIKE $0", "neville"];
            var b = c["id", 9];
            var d = c["username = $0", "nn2gcc"];
            var e = c["username = '******' @0", "batman"];


            //   string str = a.And(b.And(d)).FullQuery;
            //   string str = a.And(b).Queryfy;

            l = db.Select("fname").From("Users u").Join("comments c", "c.UserID = u.ID");
            Console.WriteLine(l.FullQuery);
            l = db.Select("fname").From("Users u").Join("comments c", "c.UserID = u.ID")
                .WhereCondition(empty.And(a.Or(b)).Or(d.Or(e)));
            Console.WriteLine(l.FullQuery);
            l = db.Update("tblUsers")
                .Pair("ID", 66)
                .Pair("IsActive", false);
            Console.WriteLine(l.FullQuery);
            l = db.Select("username").From("Users");
            Console.WriteLine(l.FullQuery);
        }
예제 #19
0
        public Conditioner GetConditionerById(int id)
        {
            Conditioner Conditioner = this.Unit.GetRepository <Conditioner>().Get(filter: x => x.Id == id).FirstOrDefault();

            return(Conditioner);
        }
예제 #20
0
        public Conditioner CreateEmptyConditioner()
        {
            Conditioner EmptyConditioner = new Conditioner();

            return(EmptyConditioner);
        }
예제 #21
0
        protected override void Seed(DevicesContext context)
        {
            Device d1 = new Device {
                Type = "tv", img = "~/Content/Images/MainScreen/tv.jpg"
            };
            Device d2 = new Device {
                Type = "lamp", img = "~/Content/Images/MainScreen/lamp.jpg"
            };
            Device d3 = new Device {
                Type = "tr", img = "~/Content/Images/MainScreen/TR.jpg"
            };
            Device d4 = new Device {
                Type = "kettle", img = "~/Content/Images/MainScreen/kettle.jpg"
            };
            Device d5 = new Device {
                Type = "fridge", img = "~/Content/Images/MainScreen/fridge.jpg"
            };
            Device d6 = new Device {
                Type = "cond", img = "~/Content/Images/MainScreen/cond.jpg"
            };

            context.Device.Add(d1);
            context.Device.Add(d2);
            context.Device.Add(d3);
            context.Device.Add(d4);
            context.Device.Add(d5);
            context.Device.Add(d6);


            TeleVision tv = new TeleVision {
                Name = "Телевизор", State = false, CurrentChanel = "ICTV", Volume = 20, Brightness = 30, Mode = false, Device = d1
            };

            context.TeleVision.Add(tv);

            Conditioner c = new Conditioner {
                Name = "Кондиционер", State = false, Programm = 2, Device = d6
            };
            DVD d = new DVD {
                State = false, IsDiskboxOpen = false, IsPlay = false, TeleVision = tv
            };
            Fridge f = new Fridge {
                Name = "Холодильник", State = false, StateFrize = false, Programm = 1, Device = d5
            };
            Kettle k = new Kettle {
                Name = "Чайник", State = false, Device = d4
            };
            TapRecoder tr = new TapRecoder {
                Name = "Музыкальный центр", State = false, Mode = false, Volume = 20, Device = d3
            };
            Lamp l = new Lamp {
                Name = "Лампа", State = false, Brightness = 20, CurrentColor = 1, Device = d2
            };

            context.Conditioner.Add(c);
            context.DVD.Add(d);
            context.Fridge.Add(f);
            context.Kettle.Add(k);
            context.TapeReoder.Add(tr);
            context.Lamp.Add(l);

            context.SaveChanges();
        }
예제 #22
0
        private void SaveChange(int id, string type, IDictionary <int, Models.Devices.Device> device)
        {
            switch (type)
            {
            case "cond":

                Conditioner cond = dbconnect.Conditioner.Find(id);

                cond.Programm = ((Models.Devices.Conditioner)device[0]).Programm;
                cond.State    = ((Models.Devices.Conditioner)device[0]).State;

                dbconnect.SaveChanges();

                break;

            case "tr":



                TapRecoder tr = dbconnect.TapeReoder.Find(id);

                tr.State  = ((Models.Devices.TapRecoder)device[0]).State;
                tr.Mode   = ((Models.Devices.TapRecoder)device[0]).Mode;
                tr.Volume = ((Models.Devices.TapRecoder)device[0]).Volume;

                dbconnect.SaveChanges();
                break;

            case "lamp":

                Lamp lamp = dbconnect.Lamp.Find(id);

                lamp.State        = ((Models.Devices.Lamp)device[0]).State;
                lamp.CurrentColor = ((Models.Devices.Lamp)device[0]).currentcolor;
                lamp.Brightness   = ((Models.Devices.Lamp)device[0]).Brightness;

                dbconnect.SaveChanges();

                break;

            case "fridge":

                Fridge fridge = dbconnect.Fridge.Find(id);

                fridge.Programm   = ((Models.Devices.Fridge)device[0]).Programm;
                fridge.State      = ((Models.Devices.Fridge)device[0]).State;
                fridge.StateFrize = ((Models.Devices.Fridge)device[0]).StateFrize;

                dbconnect.SaveChanges();

                break;

            case "kettle":

                Kettle kettle = dbconnect.Kettle.Find(id);

                kettle.State = ((Models.Devices.Kettle)device[0]).State;
                dbconnect.SaveChanges();

                break;

            case "tv":

                TeleVision tv = dbconnect.TeleVision.Find(id);

                tv.State         = ((Models.Devices.TeleVision)device[0]).State;
                tv.Mode          = ((Models.Devices.TeleVision)device[0]).Mode;
                tv.Volume        = ((Models.Devices.TeleVision)device[0]).Volume;
                tv.CurrentChanel = ((Models.Devices.TeleVision)device[0]).Chanel.ToString();
                tv.Brightness    = ((Models.Devices.TeleVision)device[0]).Brightness;


                dbconnect.SaveChanges();

                break;
            }
        }
예제 #23
0
        public void Display()
        {
            Controls.Clear();
            if (Page != null)
            {
                deviceDictionary = (IDictionary <int, Device>)Page.Session["Devices"];
            }
            string tempPower;

            conditionerPlaceHolder       = new PlaceHolder();
            conditionerPlaceHolder.ID    = "conditionerPlaceHolder" + i;
            conditionerErrPlaceHolder    = new PlaceHolder();
            conditionerErrPlaceHolder.ID = "conditionerErrPlaceHolder" + i;
            Controls.Add(conditionerPlaceHolder);

            if (deviceDictionary[i].Power)
            {
                tempPower = "включен";
            }
            else
            {
                tempPower = "выключен";
            }

            conditionerDelButton          = MyButton("");
            conditionerDelButton.ID       = "heaterDelButton" + i;
            conditionerDelButton.CssClass = "delButton";
            conditionerDelButton.Click   += ConditionerDelButton_Click;
            conditionerPlaceHolder.Controls.Add(conditionerDelButton);

            conditionerPlaceHolder.Controls.Add(Span("Устройство: " + deviceDictionary[i].Name + "<br />"));
            conditionerPlaceHolder.Controls.Add(Span("Состояние: " + tempPower + "<br />"));

            Conditioner tempDevice = (Conditioner)deviceDictionary[i];

            SliderExtender temperatureSliderExtender = SliderExtender(tempDevice.Temperature.MinValue, tempDevice.Temperature.MaxValue);

            temperatureSliderExtender.ID      = "temperatureSliderExtender" + i;
            conditionerTemperatureTarget      = TextBox();
            conditionerTemperatureBound       = TextBox();
            conditionerTemperatureTarget.Text = tempDevice.Temperature.CurrentValue.ToString();
            conditionerTemperatureBound.Text  = tempDevice.Temperature.CurrentValue.ToString();
            Table temperatureTable = MyTable(tempDevice.Temperature.SliderName + ": ", conditionerTemperatureBound, conditionerTemperatureTarget);

            temperatureTable.ID                       = "temperatureTable" + i;
            conditionerTemperatureTarget.ID           = "ConditionerTarget" + i;
            conditionerTemperatureBound.ID            = "ConditionerBound" + i;
            temperatureSliderExtender.TargetControlID = conditionerTemperatureTarget.ID;
            temperatureSliderExtender.BoundControlID  = conditionerTemperatureBound.ID;
            conditionerPlaceHolder.Controls.Add(temperatureTable);
            conditionerPlaceHolder.Controls.Add(temperatureSliderExtender);
            conditionerPlaceHolder.Controls.Add(Span("<br />"));
            conditionerApplyButton          = MyButton("Применить");
            conditionerApplyButton.ID       = "conditionerApplyButton" + i;
            conditionerApplyButton.Click   += ConditionrApplyButton_Click;
            conditionerApplyButton.CssClass = "applyButton";
            conditionerPlaceHolder.Controls.Add(conditionerApplyButton);
            conditionerOnOffButton          = MyButton("Вкл/Выкл");
            conditionerOnOffButton.ID       = "conditionerOnOffButton" + i;
            conditionerOnOffButton.Click   += ConditionerOnOffButton_Click;
            conditionerOnOffButton.CssClass = "onOffButton";
            conditionerPlaceHolder.Controls.Add(conditionerOnOffButton);
            conditionerPlaceHolder.Controls.Add(Span("<br />"));
            conditionerPlaceHolder.Controls.Add(conditionerErrPlaceHolder);
        }
예제 #24
0
        private void CreateNewDevice(string type, string lampType, string name)
        {
            using (SmartHouseContext context = new SmartHouseContext())
            {
                int id = (int)Session["CurrentRoom"];
                switch (type)
                {
                case "Alarm":
                    Alarm newAlarm = new Alarm(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Alarm.Add(newAlarm);
                    break;

                case "Conditioner":
                    Conditioner newConditioner = new Conditioner(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Conditioner.Add(newConditioner);
                    break;

                case "Exhauster":
                    Exhauster newExhauster = new Exhauster(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Exhauster.Add(newExhauster);
                    break;

                case "Fridge":
                    Fridge newFridge = new Fridge(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Fridge.Add(newFridge);
                    break;

                case "Jalousie":
                    Jalousie newJalousie = new Jalousie(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Jalousie.Add(newJalousie);
                    break;

                case "Lamp":
                    Lamp newLamp = new Lamp(name, lampType);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Lamp.Add(newLamp);
                    break;

                case "Radiator":
                    Radiator newRadiator = new Radiator(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Radiator.Add(newRadiator);
                    break;

                case "Router":
                    Router newRouter = new Router(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Router.Add(newRouter);
                    break;

                case "StereoSystem":
                    StereoSystem newStereoSystem = new StereoSystem(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).StereoSystem.Add(newStereoSystem);
                    break;

                case "TV":
                    TV newTV = new TV(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).TV.Add(newTV);
                    break;

                default:
                    Alarm newAlarma = new Alarm(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Alarm.Add(newAlarma);
                    break;
                }
                context.SaveChanges();
            }
        }
예제 #25
0
 private void RenameDevice(int id, string type, string name)
 {
     using (SmartHouseContext context = new SmartHouseContext())
     {
         if (context.Alarms.Any())
         {
             if (type == context.Alarms.FirstOrDefault().GetType().ToString())
             {
                 Alarm device = context.Alarms.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(Session["CurrentRoom"]);
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Conditioners.Any())
         {
             if (type == context.Conditioners.FirstOrDefault().GetType().ToString())
             {
                 Conditioner device = context.Conditioners.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(Session["CurrentRoom"]);
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Exhausters.Any())
         {
             if (type == context.Exhausters.FirstOrDefault().GetType().ToString())
             {
                 Exhauster device = context.Exhausters.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(Session["CurrentRoom"]);
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Fridges.Any())
         {
             if (type == context.Fridges.FirstOrDefault().GetType().ToString())
             {
                 Fridge device = context.Fridges.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(Session["CurrentRoom"]);
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Jalousies.Any())
         {
             if (type == context.Jalousies.FirstOrDefault().GetType().ToString())
             {
                 Jalousie device = context.Jalousies.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(Session["CurrentRoom"]);
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Lamps.Any())
         {
             if (type == context.Lamps.FirstOrDefault().GetType().ToString())
             {
                 Lamp device = context.Lamps.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(Session["CurrentRoom"]);
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Radiators.Any())
         {
             if (type == context.Radiators.FirstOrDefault().GetType().ToString())
             {
                 Radiator device = context.Radiators.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(Session["CurrentRoom"]);
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Routers.Any())
         {
             if (type == context.Routers.FirstOrDefault().GetType().ToString())
             {
                 Router device = context.Routers.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(Session["CurrentRoom"]);
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.StereoSystems.Any())
         {
             if (type == context.StereoSystems.FirstOrDefault().GetType().ToString())
             {
                 StereoSystem device = context.StereoSystems.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(Session["CurrentRoom"]);
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.TVs.Any())
         {
             if (type == context.TVs.FirstOrDefault().GetType().ToString())
             {
                 TV device = context.TVs.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(Session["CurrentRoom"]);
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
     }
     return;
 }
예제 #26
0
        public Conditioner CreateConditioner(string deviceName, bool power, Slider slider)
        {
            Conditioner tempConditioner = new Conditioner(deviceName, power, slider);

            return(tempConditioner);
        }
        public ActionResult Add(string type, string Namedevice)
        {
            switch (type)
            {
            case "cond":

                Device d = new Device {
                    Type = "cond", img = "~/Content/Images/MainScreen/cond.jpg"
                };
                Conditioner c = new Conditioner {
                    Name = Namedevice, State = false, Programm = 2, Device = d
                };


                Session["Filtr"] = type;
                dbconnect.Conditioner.Add(c);
                dbconnect.SaveChanges();


                break;

            case "tr":

                Device d1 = new Device {
                    Type = "tr", img = "~/Content/Images/MainScreen/TR.jpg"
                };
                TapRecoder tr = new TapRecoder {
                    Name = Namedevice, State = false, Mode = false, Volume = 20, Device = d1
                };

                Session["Filtr"] = type;
                dbconnect.TapeReoder.Add(tr);
                dbconnect.SaveChanges();
                break;

            case "lamp":

                Device d2 = new Device {
                    Type = "lamp", img = "~/Content/Images/MainScreen/lamp.jpg"
                };
                Lamp l = new Lamp {
                    Name = Namedevice, State = false, Brightness = 20, CurrentColor = 1, Device = d2
                };

                Session["Filtr"] = type;
                dbconnect.Lamp.Add(l);
                dbconnect.SaveChanges();

                break;

            case "fridge":

                Device d3 = new Device {
                    Type = "fridge", img = "~/Content/Images/MainScreen/fridge.jpg"
                };
                Fridge f = new Fridge {
                    Name = Namedevice, State = false, StateFrize = false, Programm = 1, Device = d3
                };

                Session["Filtr"] = type;
                dbconnect.Fridge.Add(f);
                dbconnect.SaveChanges();

                break;

            case "kettle":

                Device d4 = new Device {
                    Type = "kettle", img = "~/Content/Images/MainScreen/kettle.jpg"
                };
                Kettle k = new Kettle {
                    Name = Namedevice, State = false, Device = d4
                };

                Session["Filtr"] = type;
                dbconnect.Kettle.Add(k);
                dbconnect.SaveChanges();

                break;

            case "tv":

                Device d5 = new Device {
                    Type = "tv", img = "~/Content/Images/MainScreen/tv.jpg"
                };
                TeleVision tv = new TeleVision {
                    Name   = Namedevice, State = false, CurrentChanel = "ICTV",
                    Volume = 20, Brightness = 30, Mode = false, Device = d5
                };
                DVD dvd = new DVD {
                    State = false, IsDiskboxOpen = false, IsPlay = false, TeleVision = tv
                };

                Session["Filtr"] = type;
                dbconnect.TeleVision.Add(tv);
                dbconnect.DVD.Add(dvd);
                dbconnect.SaveChanges();

                break;
            }



            IDictionary <int, Models.Devices.Device> filtrDevice = new SortedDictionary <int, Models.Devices.Device>();

            return(View("Index", filtrDevice));
        }
예제 #28
0
 public ConditionerOnCommand(Conditioner cSet)
 {
     c = cSet;
 }
        public ActionResult Del(int id, string chanel)
        {
            try
            {
                switch (chanel)
                {
                case "cond":

                    Conditioner c = dbconnect.Conditioner.Find(id);

                    dbconnect.Conditioner.Remove(c);
                    dbconnect.SaveChanges();

                    break;

                case "tr":

                    TapRecoder tr = dbconnect.TapeReoder.Find(id);
                    dbconnect.TapeReoder.Remove(tr);
                    dbconnect.SaveChanges();
                    break;

                case "lamp":

                    Lamp l = dbconnect.Lamp.Find(id);
                    dbconnect.Lamp.Remove(l);
                    dbconnect.SaveChanges();

                    break;

                case "fridge":

                    Fridge f = dbconnect.Fridge.Find(id);
                    dbconnect.Fridge.Remove(f);
                    dbconnect.SaveChanges();

                    break;

                case "kettle":

                    Kettle k = dbconnect.Kettle.Find(id);
                    dbconnect.Kettle.Remove(k);
                    dbconnect.SaveChanges();

                    break;

                case "tv":


                    TeleVision tv = dbconnect.TeleVision.Include(p => p.DVDs).Where(p => p.Id == id).FirstOrDefault();
                    dbconnect.TeleVision.Remove(tv);
                    dbconnect.SaveChanges();

                    break;
                }

                IDictionary <int, Models.Devices.Device> filtrDevice = new SortedDictionary <int, Models.Devices.Device>();
                return(View("Index", filtrDevice));
            }
            catch
            {
                IDictionary <int, Models.Devices.Device> filtrDevice = new SortedDictionary <int, Models.Devices.Device>();
                return(View("Index", filtrDevice));
            }
        }
예제 #30
0
        protected override void Seed(HouseContext context)
        {
            Router router1 = new Router()
            {
                Id   = 3,
                Name = "EtherNet 1324_v",
            };

            TV tv1 = new TV(new ChannelSystem(1), new VolumeSystem(), new BrightSystem())
            {
                Id   = 1,
                Name = "Berezka",
            };

            TV tv2 = new TV(new ChannelSystem(2), new VolumeSystem(), new BrightSystem())
            {
                Id   = 2,
                Name = "Samsung",
            };

            TV tv3 = new TV(new ChannelSystem(3), new VolumeSystem(), new BrightSystem())
            {
                Id   = 3,
                Name = "Phillips",
            };

            Conditioner cond1 = new Conditioner(15, new FanSystem())
            {
                Id   = 1,
                Name = "Fan 1",
            };

            Conditioner cond2 = new Conditioner(15, new FanSystem())
            {
                Id   = 2,
                Name = "Fan 2",
            };

            Oven oven1 = new Oven(20, 100, 50)
            {
                Id       = 1,
                Name     = "Oven 1",
                OvenMode = OvenModes.Grill,
            };

            Oven oven2 = new Oven(25, 100, 40)
            {
                Id       = 2,
                Name     = "Oven 2",
                OvenMode = OvenModes.Microwave,
            };

            AudioSystem audio1 = new AudioSystem(new MusicalSystem(), new VolumeSystem())
            {
                Id   = 1,
                Name = "Sony X54",
            };

            AudioSystem audio2 = new AudioSystem(new MusicalSystem(), new VolumeSystem())
            {
                Id   = 2,
                Name = "AudioSystem 8.1",
            };

            context.TVs.Add(tv1);
            context.TVs.Add(tv2);
            context.TVs.Add(tv3);

            context.Ovens.Add(oven1);
            context.Ovens.Add(oven2);

            context.Routers.Add(router1);

            context.AudioSystems.Add(audio1);
            context.AudioSystems.Add(audio2);

            context.Conditioners.Add(cond1);
            context.Conditioners.Add(cond2);

            context.SaveChanges();
            base.Seed(context);
        }
예제 #31
0
        static void Main(string[] args)
        {
            var logger = new DatabaseLogger {
            };

            //for (char ch = 'a'; ch <= 'z'; ch++)
            //    new Mad { Name = "Hello" + ch, Gone = ch%2 == 0 }.Add();

            //new Mad { Dated = DateTime.Now }.Add();
            //var mads = new Mad().GetAll();

            //var persons = new Person().GetAll();


            //string str = null;
            //str.IfEmpty("");

            Database db = "";

            BaseQueryer.Ender l;


            var emps = new Employee().GetAll();

            //var control = new EmpDB(new Employee());
            //var emps2 = control.GetAll();

            var control = new Employee2 {
                Fname = "Hell", Lname = "Bent"
            };
            //control.Add();
            var emps2 = control.ShowAll();

            Console.ReadLine();

            //var emp = new Employee { Fname = "Neville", Lname = "Nazerane_9", Age = 25, Initials = 'L', Salary = 4582.14 };

            //int eID = emp.Add();
            //emp.Lname = "Nazerane";
            //emp.Update();
            //var emp2 = new Employee { ID = eID };
            //emp2.Get();
            //emp2.Delete();
            //var all = emp2.GetAll();


            //var p1 = new Person { FullName = "Neville Nazerane", Address = "144 Sample St", Job = "Batman"};

            //p1.Add();
            //p1.Address = "Another address 2";
            //p1.FullName = "Neville 2 Fernando";
            //p1.Update();


            //new Person { FullName = "My name" }.Add(); // adds all except ID (primary key)
            //Person p = new Person { ID = 2 };
            //p.Get(); // gets by primary key
            //p.Address = "New address"; p.Update(); // updates by primary key
            //new Person { ID = 3 }.Delete(); // RIP



            //p1.Address = "Another address 2"; p1.Update();

            //p1.ID = 4; p1.Get();
            //p1.ID = 5; p1.Delete();

            //var p2 = new Person { ID = 20 };
            //p2.Get();
            ////p2.Delete();

            //var pAll = p1.GetAll();

            //var testEmployee = new BusEmployee { Fname = "Neville4", Lname = "Fernando", Age = 45, Initials = 'N', Salary = 8832.1 };

            Console.WriteLine(
                new Employee {
                ID = 9, Age = 23, Lname = "Nazerane"
            }.Condition()
                );


            Console.ReadLine();
            //Console.WriteLine(testEmployee.Add());


            //Console.WriteLine(new Employee().Delete());

            //l = db.Delete("MyName");
            //Console.WriteLine(l.FullQuery);

            //l = db.Delete("YourName").Where("ID = @0", 44);
            //Console.WriteLine(l.FullQuery);

            var aa = new Auth {
                id = 84, name = 544, title = "My %man_"
            };
            var c = Conditioner.GetUniversalConditioner(aa);

            //var ec = Conditioner.GetEquateConditioner(aa);
            //var lc = Conditioner.GetLikeConditioner(aa);
            var empty = Conditioner.Default;

            var cond = Conditioner.Default;

            var auths = new List <Auth> {
                new Auth {
                    id = 9, name = 54
                },
                new Auth {
                    id = 8, name = 14
                },
                new Auth {
                    id = 3, name = 65
                }
            };

            auths.ForEach(a => cond = cond.Or(c["AuthID", a.id].And(c["AuthTypeID", a.name])));
            var condPerm = c["TargetID", 5].And(c["TargetTypeID", 8]);

            l = db.From("batman").WhereCondition(empty.And(cond).And(condPerm));

            Console.WriteLine(l.FullQuery);

            Console.WriteLine("Repeating:");
            empty = Conditioner.Default;

            var cond2 = Conditioner.Default;

            auths.ForEach(a => cond2 = cond2 | !(c["AuthID", a.id] & c["AuthTypeID", a.name]));
            var condPerm2 = c["TargetID", 5] & c["TargetTypeID", 8];
            var condEq    = c[o => o.name];
            var condLk    = c[o => o.title, "%@0%"];

            l = db.Delete("batman").WhereCondition(empty & cond2 & condPerm2 | (condEq & condLk));

            Console.WriteLine(l.FullQuery);
            Console.WriteLine("\n");

            l = db.Insert("tblUsers")
                .Keys("username", "isActive")
                .SelectQuery("username, id, @0", 993).From("tblUsers").Where("abc = $1 AND c LIKE %@0 AND IsActive = $2", 5, null, true);
            Console.WriteLine(l.FullQuery);

            var re = Console.ReadLine();

            Console.Read();
        }