示例#1
0
        static void getPlants()
        {
            using (var context = new Context())
            {
                Admin ad = new Admin();
                Console.WriteLine("Enter UserName");
                ad.UserName = Console.ReadLine();
                Console.WriteLine("Enter Password");
                ad.Password = Console.ReadLine();
                var check = context.Admins.SingleOrDefault(t => t.UserName == ad.UserName && t.Password == ad.Password);
                if (check != null)
                {
                    try
                    {
                        Plants hp = new Plants();

                        foreach (var item in context.Plants.ToList())
                        {
                            Console.WriteLine($"ID {item.PlantId} - Name {item.PlantName}");
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
                else
                {
                    Console.WriteLine("Incorrect UserName or Password");
                }
            }
        }
示例#2
0
 public override void PopulateExamineList(List <WIExamineInfo> examine)
 {
     Props.Revealed = true;
     Props.NumTimesEncountered++;
     Props.EncounteredTimesOfYear |= WorldClock.SeasonCurrent;
     Plants.Examine(Props, examine);
 }
示例#3
0
 public void OnPlayerDetect()
 {
     Props.Revealed = true;
     Props.CurrentSeason.Revealed  = true;
     Props.EncounteredTimesOfYear |= WorldClock.SeasonCurrent;
     Plants.SaveProps(Props);
 }
示例#4
0
        static void removePlants()
        {
            using (var context = new Context())
            {
                Admin ad = new Admin();
                Console.WriteLine("Enter UserName");
                ad.UserName = Console.ReadLine();
                Console.WriteLine("Enter Password");
                ad.Password = Console.ReadLine();
                var check = context.Admins.SingleOrDefault(t => t.UserName == ad.UserName && t.Password == ad.Password);
                if (check != null)
                {
                    try
                    {
                        Plants hp = new Plants();
                        Console.WriteLine("Enter Plant Id");
                        hp.PlantId = Convert.ToInt32(Console.ReadLine());

                        context.Plants.Remove(hp);
                        context.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
                else
                {
                    Console.WriteLine("Incorrect UserName or Password");
                }
            }
        }
示例#5
0
        public double GetHeatPenalty()
        {
            if (m_SeedType == null)
            {
                return(0);
            }

            Plants.SeedDetail seedDetail = Plants.GetSeedDetail(m_SeedType);

            double targetHeat     = seedDetail.HeatTarget;
            double heatDifference = 0.0;

            double insufficientHeatScalar = 0.01;
            double excessHeatScalar       = 0.01;

            heatDifference = Math.Abs(HeatValue - targetHeat);

            if (HeatValue < targetHeat)
            {
                return(heatDifference * insufficientHeatScalar);
            }

            else
            {
                return(heatDifference * excessHeatScalar);
            }
        }
示例#6
0
        public async Task <IActionResult> PutPlants(int id, Plants plants)
        {   //Update a plant
            if (id != plants.PlantID)
            {
                return(BadRequest());
            }

            _context.Entry(plants).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlantsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#7
0
        public List <Plants> GetPlants()
        {
            List <Plants> allPlants = new List <Plants>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    SqlCommand    cmd     = new SqlCommand(AllPlants, conn);
                    SqlDataReader results = cmd.ExecuteReader();

                    while (results.Read())
                    {
                        Plants p = new Plants();
                        p.Name        = Convert.ToString(results["name"]);
                        p.Maturity    = Convert.ToString(results["maturity"]);
                        p.Height      = Convert.ToString(results["height"]);
                        p.Spread      = Convert.ToString(results["spread"]);
                        p.Size        = Convert.ToString(results["size"]);
                        p.Sun         = Convert.ToString(results["sun"]);
                        p.Description = Convert.ToString(results["description"]);
                        allPlants.Add(p);
                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }
            return(allPlants);
        }
示例#8
0
        public double GetWaterPenalty()
        {
            if (m_SeedType == null)
            {
                return(0);
            }

            Plants.SeedDetail seedDetail = Plants.GetSeedDetail(m_SeedType);

            double targetWater     = seedDetail.WaterTarget;
            double waterDifference = 0.0;

            double insufficientWaterScalar = 0.01;
            double excessWaterScalar       = 0.01;

            waterDifference = Math.Abs(WaterValue - targetWater);

            if (WaterValue < targetWater)
            {
                return(waterDifference * insufficientWaterScalar);
            }

            else
            {
                return(waterDifference * excessWaterScalar);
            }
        }
        async Task ExecuteLoadPlantsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Plants.Clear();
                var items = await DataStore.GetPlantsAsync(true);

                Plants.ReplaceRange(items);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                // MessageDialog.SendMessage("Unable to load items.", "Error");
            }
            finally
            {
                IsBusy = false;
            }
        }
示例#10
0
 public void RecognizeLeaf()
 {
     Task.Run(() =>
     {
         ImageProcessor imageProcessor = new ImageProcessor(LeafImage);
         imageProcessor.EdgeDetect(Threshold);
         imageProcessor.Thinning();
         imageProcessor.CheckLines(MinLine);
         imageProcessor.MarkPoints(Distance);
         imageProcessor.CalcAngels();
         List <LeafToken> leafTokens = imageProcessor.GetTokens();
         double[] input = new double[NumberOfInputNodes];
         for (int i = 0; i < NumberOfInputNodes; i++)
         {
             input[i] = i < leafTokens.Count - 1 ? leafTokens[i].Sin : 0;
         }
         bpn.Run(ref input, out output);
         for (int i = 0; i < Plants.Count; i++)
         {
             Plants[i].Probability = output[i];
         }
         Results = Plants.OrderByDescending(x => x.Probability).ToList();
         NotifyOfPropertyChange(() => Results);
     });
 }
示例#11
0
        public async Task <ActionResult <Plants> > PostPersonPlants(Plants plant)
        {
            _context.Plants.Add(plant);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetPlant), new { plantId = plant.PlantId }, plant));
        }
示例#12
0
    public void CallInPlantingTip(int index)
    {
        plantingTip.gameObject.SetActive(true);
        if (plantingTip.transform.localPosition.y > 1 || plantingTip.transform.localPosition.y < -1)
        {
            plantingTip.localPosition = new Vector3(150, 0, 0);
        }
        int plantType = GameData._playerData.Farms [index].plantType;

        plantingTip.gameObject.name = index.ToString();
        Text[] t = plantingTip.gameObject.GetComponentsInChildren <Text> ();

        switch (plantType)
        {
        case 0:
            t [0].text = "Crops";
            break;

        case 1:
            t [0].text = "Wine";
            break;

        case 2:
            t [0].text = "Beer";
            break;

        case 3:
            t [0].text = "Whiskey";
            break;

        default:
            break;
        }

        int  i          = 2;
        bool canPrepare = true;

        Plants p = LoadTxt.GetPlant(plantType);
        Dictionary <int, int> d = p.plantReq;

        foreach (int key in d.Keys)
        {
            t[i].text = LoadTxt.MatDic [key].name + " ×" + d [key];
            if (_gameData.CountInHome(key) < d[key])
            {
                t[i].color = Color.red;
                canPrepare = false;
            }
            else
            {
                t[i].color = Color.green;
            }
            i++;
        }
        plantingTip.GetComponentInChildren <Button>().interactable = canPrepare;

        t[5].text = p.plantTime + " h";
        t[7].text = p.plantGrowCycle + " day";
        t[8].text = "Prepare";
    }
        public void AddPlant()
        {
repeate:
            Console.WriteLine("--->> ADD PLANTS <<---");
            Console.WriteLine("Enter Plant Name: ");
            plant.PlantName = Console.ReadLine();
            Console.WriteLine("Enter Plant Address: ");
            plant.PlantAddress = Console.ReadLine();
            if (plant.PlantName != null && plant.PlantAddress != null)
            {
                try
                {
                    Plants.Add(plant);
                    SaveChanges();
                    Console.WriteLine("Manufecturing plants are added");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
            else
            {
                Console.WriteLine(" !!Enter all required fields!! ");
                goto repeate;
            }
        }
示例#14
0
 public static void AddPlantsDetails()
 {
     using (var db = new MasterContext())
     {
         var plant = new Plants();
         {
             Console.WriteLine("Enter PlantName!!");
             plant.PlantName = Console.ReadLine();
             Console.WriteLine("Enter PlantLocation!!");
             plant.PlantLocation = Console.ReadLine();
             Console.WriteLine("Enter CompanyId!!");
             plant.CompanyId = Convert.ToInt32(Console.ReadLine());
             var check = db.Plants.Where(t => t.PlantName == plant.PlantName);
             if (check != null)
             {
                 Console.WriteLine("Plant Name is Existing");
             }
             else
             {
                 db.Plants.Add(plant);
                 db.SaveChanges();
                 Console.WriteLine("Plants Information is added Successfully!!");
             }
         }
     }
 }
示例#15
0
        public Plants GetPlantByName(string name)
        {
            Plants p = new Plants();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    SqlCommand cmd = new SqlCommand(PlantByName, conn);
                    cmd.Parameters.AddWithValue("@name", name);
                    SqlDataReader results = cmd.ExecuteReader();

                    while (results.Read())
                    {
                        p.Name        = Convert.ToString(results["name"]);
                        p.Maturity    = Convert.ToString(results["maturity"]);
                        p.Height      = Convert.ToString(results["height"]);
                        p.Spread      = Convert.ToString(results["spread"]);
                        p.Size        = Convert.ToString(results["size"]);
                        p.Sun         = Convert.ToString(results["sun"]);
                        p.Description = Convert.ToString(results["description"]);
                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }
            return(p);
        }
示例#16
0
        public ActionResult Detail(string id)
        {
            Plants p = new Plants();

            //p = plantDal
            return(View());
        }
        public async Task <IActionResult> Edit(int id, [Bind("id,Name,Adress")] Plants plants)
        {
            if (id != plants.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(plants);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlantsExists(plants.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(plants));
        }
示例#18
0
        public double GetSoilPenalty()
        {
            if (m_SeedType == null)
            {
                return(0);
            }

            Plants.SeedDetail seedDetail = Plants.GetSeedDetail(m_SeedType);

            double targetSoilQuality     = seedDetail.SoilTarget;
            double soilQualityDifference = 0.0;

            double insufficientSoilQualityScalar = 0.01;
            double excessSoilQualityScalar       = 0.01;

            soilQualityDifference = Math.Abs(SoilValue - targetSoilQuality);

            if (SoilValue < targetSoilQuality)
            {
                return(soilQualityDifference * insufficientSoilQualityScalar);
            }

            else
            {
                return(soilQualityDifference * excessSoilQualityScalar);
            }
        }
示例#19
0
        public AdministrationViewModel()
        {
            Task.Run(() => {
                if (File.Exists(@"vrste.txt"))
                {
                    List <string> plants = new List <string>(File.ReadLines(@"vrste.txt").ToList());
                    int id = 0;
                    foreach (var plant in plants)
                    {
                        Plants.Add(new PlantModel(plant, id++));
                    }
                    NotifyOfPropertyChange(() => Plants);
                }
                _dataSet = new DataSet();
                if (File.Exists(@"podaci.xml"))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(@"podaci.xml");

                    _dataSet.Load((XmlElement)doc.DocumentElement.ChildNodes[0]);

                    NumberOfInputNodes = _dataSet.Data[0].InputSize;
                    NotifyOfPropertyChange(() => NumberOfInputNodes);
                }
            });
        }
示例#20
0
    //Write to the Sun Info UI the info collected from the DB related to the Luminosity
    private void WriteSunInfo(Plants p)
    {
        Text descricao = Sun_Description.GetComponent <Text>();

        descricao.text = "\n<b>Luminosidade: </b>" + p.Luminosidade + "\n\n" +
                         "<b>Clima: </b>" + p.Clima + "\n";
    }
示例#21
0
        static void addPlants()
        {
            using (var context = new Context())
            {
                Admin ad = new Admin();
                Console.WriteLine("Enter UserName");
                ad.UserName = Console.ReadLine();
                Console.WriteLine("Enter Password");
                ad.Password = Console.ReadLine();
                var check = context.Admins.SingleOrDefault(t => t.UserName == ad.UserName && t.Password == ad.Password);
                if (check != null)
                {
                    try
                    {
                        Plants dp = new Plants();
                        Console.WriteLine("Enter plant Name");
                        dp.PlantName = Console.ReadLine();

                        context.Plants.Add(dp);
                        context.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
                else
                {
                    Console.WriteLine("Incorrect UserName or Password");
                }
            }
        }
示例#22
0
        public void OnDie()
        {
            Damageable damageable = worlditem.Get <Damageable> ();

            damageable.ResetDamage();
            Plants.Dispose(this);
        }
示例#23
0
    public override void _Ready()
    {
        player = GetNode(Game.PLAYER_PATH) as Player;

        worldGenerator = new WorldGenerator();
        worldGenerator.terrainModifiers.Add(new HillLandscapeTM(AVERAGE_HEIGHT, HEIGHT_SPREAD));
        worldGenerator.generators.Add(new IceGenerator(SEA_LEVEL));
        worldGenerator.generators.Add(new RockGenerator(RED_ROCK_LAYER_NUM));

        foreach (UniformRandomBlockGenerator g in fossilGenerators)
        {
            worldGenerator.generators.Add(g);
        }

        Base    b = GetNode(Game.PLANET_BASE_PATH) as Base;
        Vector2 horizontalBasePos = new Vector2(b.position.x, b.position.z);

        b.position = new IntVector3(b.position.x, worldGenerator.GetHeightAt(horizontalBasePos) - 1, b.position.z);
        b.InitGeneration();
        worldGenerator.terrainModifiers.Add(b.Smoothing);
        worldGenerator.generators.Add(b.Generator);

        Vector2 playerPos = new Vector2(player.Translation.x, player.Translation.z) / Block.SIZE;
        float   terrainGraphicalHeight = worldGenerator.GetHeightAt(playerPos) * Block.SIZE;

        player.Translation = new Vector3(playerPos.x, terrainGraphicalHeight + Player.INIT_REL_POS.y, playerPos.y);

        Plants p = GetNode(Game.PLANTS_PATH) as Plants;

        blockChageCallback = (oldBlock, newBlock, blockPos) => p.HandleBlockChange(oldBlock, newBlock, blockPos);
    }
示例#24
0
        public Plants GetModel()
        {
            if (_model == null)
            {
                _model = new Plants();

                _model.Add(new Plant
                {
                    Name        = "율마",
                    MarkerColor = MarkerColor.Green,
                    WaterPeriod = new TimeSpan(10, 0, 0),
                    WaterTime   = new TimeSpan(0, 0, 2),
                    LastWatered = DateTime.MinValue
                });
                _model.Add(new Plant
                {
                    Name        = "아이비",
                    MarkerColor = MarkerColor.Red,
                    WaterPeriod = new TimeSpan(10, 0, 0),
                    WaterTime   = new TimeSpan(0, 0, 7),
                    LastWatered = DateTime.MinValue
                });
                _model.Add(new Plant
                {
                    Name        = "스파티필름",
                    MarkerColor = MarkerColor.Blue,
                    WaterPeriod = new TimeSpan(10, 0, 0),
                    WaterTime   = new TimeSpan(0, 0, 5),
                    LastWatered = DateTime.MinValue
                });
            }

            return(_model);
        }
示例#25
0
        public override string ToString()
        {
            StringBuilder output  = new StringBuilder();
            string        shortId = $"{this._id.ToString().Substring(this._id.ToString().Length - 6)}";

            // Print out the counts of each type of animal
            var counts = Plants.GroupBy(plant => plant.Type)
                         .Select(group => new PrintReport
            {
                Name  = group.Key,
                Count = group.Count()
            });



            output.Append($"Plowed field {shortId} has {this._plants.Count} plants\n");
            // this._plants.ForEach(a => output.Append($"   {a}\n"));

            foreach (PrintReport report in counts)
            {
                output.Append($"  {report.Name}: {report.Count}\n");
            }

            return(output.ToString());
        }
示例#26
0
        public static void ReadCards()
        {
            string queryString = "select card_id, card_title, st_title, cult_id, optimal, tolerance, limit_dev from cards natural join stages";

            using (NpgsqlConnection connection = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString))
            {
                NpgsqlCommand command = new NpgsqlCommand(queryString, connection);
                connection.Open();
                NpgsqlDataReader reader = command.ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        Card new_Card = new Card
                        {
                            Card_id         = (int)reader[0],
                            Title           = reader[1].ToString(),
                            Stage           = reader[2].ToString(),
                            Cult_id         = (int)reader[3],
                            Optimal         = (float)reader[4],
                            Tolerance       = (float)reader[5],
                            Limit_deviation = (float)reader[6]
                        };
                        Plants.Where(p => (p.Cult_id == new_Card.Cult_id) && (p.Stage == new_Card.Stage)).First().Cards_of_plant.Add(new_Card);
                        new_Card = null;
                    }
                }
                finally { reader.Close(); }
            }
        }
示例#27
0
        public static void ReadPlants()
        {
            string queryString = "select p_id, s_title, t_title, st_title, count,cult_id, house_id from plants natural join stages natural join cultures natural join sorts natural join types order by p_id";

            using (NpgsqlConnection connection = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString))
            {
                NpgsqlCommand command = new NpgsqlCommand(queryString, connection);
                connection.Open();
                NpgsqlDataReader reader = command.ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        Plant new_plant = new Plant
                        {
                            Plant_id       = (int)reader[0],
                            Sort           = reader[1].ToString(),
                            Type           = reader[2].ToString(),
                            Stage          = reader[3].ToString(),
                            Count          = (int)reader[4],
                            Cult_id        = (int)reader[5],
                            House_id       = (int)reader[6],
                            Cards_of_plant = new List <Card>()
                        };
                        Plants.Add(new_plant);
                        new_plant = null;
                    }
                }
                finally { reader.Close(); }
            }
        }
示例#28
0
        public async void GetMethod()
        {
            Plants.Clear();

            //var plants = await DataStore.GetItemsAsync(true);
            var clientget = new HttpClient();
            var uri2      = "http://192.168.87.171:3000/measurements";

            try
            {
                var response2 = await clientget.GetAsync(uri2);

                if (response2.IsSuccessStatusCode)
                {
                    string content = await response2.Content.ReadAsStringAsync();

                    Console.WriteLine(content);
                    List <Plant> plantie = JsonConvert.DeserializeObject <List <Plant> >(content);

                    foreach (var item in plantie)
                    {
                        Plant planget = new Plant {
                            PlantID = item.plantID, Temperature = item.temperature, AirHumidity = item.airHumidity, TempWarning = item.tempWarning, DrySoil = item.drySoil, DateTime = item.dateTime, ImageSource = item.imageSource, ColorBackground = item.colorBackground
                        };


                        Plants.Add(planget);
                    }
                }
            }
            catch (Exception)
            {
                Debug.WriteLine("Error");
            }
        }
示例#29
0
        public async Task <IActionResult> PutPlants([FromRoute] int id, [FromBody] Plants plants)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != plants.PlantId)
            {
                return(BadRequest());
            }

            _context.Entry(plants).State = EntityState.Modified;

            try
            {
                plants.LastWateredOn = DateTime.Now;
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlantsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Plants plantViewModel = db.Plants.Find(id);

            db.Plants.Remove(plantViewModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }