Exemplo n.º 1
0
        public void AddTube()
        {
            this.SelectRandomCompany();
            this.SelectRandomUser();

            if (this.SelectedUser != 0)
            {
                int AnimalId = this.SelectRandomMaleAnimal();
                if (AnimalId != 0)
                {
                    var values = new NameValueCollection();
                    values["AnimalId"]     = AnimalId.ToString();
                    values["CompanyId"]    = this.SelectedCompany.ToString();
                    values["UserKey"]      = this.SelectedUser.ToString();
                    values["ModifiedDate"] = this.SelectRandomModifiedDate().ToString();

                    int result = post.GetDataInstance <int>(this.PostUrl + URLs.AddTube, values);

                    if (result != 0)
                    {
                        Tube ins = new Tube();
                        ins.TubeId   = result;
                        ins.AnimalId = AnimalId;
                        this.WetuSystem[this.SelectedCompanyIndex].InseminationTubes.Add(ins);
                        Console.WriteLine("Company " + this.SelectedCompanyIndex.ToString() + " Added Tube: " + result.ToString() + " from - " + ins.AnimalId);
                    }
                    else
                    {
                        Console.WriteLine("Failed to insert Insemination Tube");
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void CreateBirth()
        {
            this.SelectRandomCompany();
            this.SelectRandomUser();

            if (this.SelectedUser != 0)
            {
                //...Make sure there is at least 1 male and female
                if (this.WetuSystem[this.SelectedCompanyIndex].FemaleAnimals.Count == 0)
                {
                    Console.WriteLine("Failed to add Birth Scenario: No Female Animals");
                }
                else
                {
                    //...Select Female Parent
                    int Female = this.SelectRandomFemaleAnimal();

                    if (Female != 0)
                    {
                        int Male    = 0;
                        int Child   = 0;
                        int Success = 0;
                        int Tube    = 0;

                        //...Select Birth Type
                        //...1 = Natural, 2 = AI
                        int BirthType = this.rand.Next(1, 3);

                        //...Make sure Company Has Insemination Tubes
                        if (BirthType == 2)
                        {
                            if (this.WetuSystem[this.SelectedCompanyIndex].InseminationTubes.Count == 0)
                            {
                                BirthType = 1;
                            }
                        }
                        else
                        {
                            if (this.WetuSystem[this.SelectedCompanyIndex].MaleAnimals.Count == 0)
                            {
                                if (this.WetuSystem[this.SelectedCompanyIndex].InseminationTubes.Count == 0)
                                {
                                    Console.WriteLine("Failed to add Birth Scenario: No Male Animals");
                                }
                                else
                                {
                                    BirthType = 2;
                                }
                            }
                        }

                        if (BirthType == 1)
                        {
                            //...Natural Insemination
                            Male = this.SelectRandomMaleAnimal();

                            //...Determine Success
                            int SuccessSelect = this.rand.Next(1, 101);

                            if ((SuccessSelect >= 25) && (SuccessSelect <= 75))
                            {
                                //...Successful birth
                                //...Create New Child
                                Child   = this.AddChild();
                                Success = 1;
                            }
                            else
                            {
                                Child   = 0;
                                Success = 0;
                            }
                        }
                        else
                        {
                            //...Select Insemination Tube
                            Tube = this.SelectRandomTube();
                            Male = this.WetuSystem[this.SelectedCompanyIndex].InseminationTubes[this.SelectedTube].AnimalId;

                            //...Determine Success
                            int SuccessSelect = this.rand.Next(1, 101);

                            if ((SuccessSelect >= 25) && (SuccessSelect <= 75))
                            {
                                //...Successful birth
                                //...Create New Child
                                Child   = this.AddChild();
                                Success = 1;
                            }
                            else
                            {
                                Child   = 0;
                                Success = 0;
                            }
                        }

                        //...Insert
                        var values = new NameValueCollection();
                        values["FemaleId"]     = Female.ToString();
                        values["MaleId"]       = Male.ToString();
                        values["ChildId"]      = Child.ToString();
                        values["TubeId"]       = Tube.ToString();
                        values["BirthTypeId"]  = BirthType.ToString();
                        values["Success"]      = Success.ToString();
                        values["CompanyId"]    = this.SelectedCompany.ToString();
                        values["UserKey"]      = this.SelectedUser.ToString();
                        values["ModifiedDate"] = this.SelectRandomModifiedDate().ToString();

                        int result = post.GetDataInstance <int>(this.PostUrl + URLs.AddBirth, values);

                        if (result != 0)
                        {
                            if (Tube != 0)
                            {
                                Tube toRemove = new Tube();
                                toRemove.AnimalId = Male;
                                toRemove.TubeId   = Tube;
                                this.WetuSystem[this.SelectedCompanyIndex].InseminationTubes.Remove(toRemove);
                            }

                            Console.WriteLine("Birth was added");
                        }
                        else
                        {
                            Console.WriteLine("Failed to add Birth Scenario");
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void CreateBirth()
        {
            this.SelectRandomCompany();
            this.SelectRandomUser();

            if (this.SelectedUser != 0)
            {
                //...Make sure there is at least 1 male and female
                if (this.WetuSystem[this.SelectedCompanyIndex].FemaleAnimals.Count == 0)
                {
                    Console.WriteLine("Failed to add Birth Scenario: No Female Animals");
                }
                else
                {
                    //...Select Female Parent
                    int Female = this.SelectRandomFemaleAnimal();

                    if (Female != 0)
                    {
                        int Male = 0;
                        int Child = 0;
                        int Success = 0;
                        int Tube = 0;

                        //...Select Birth Type
                        //...1 = Natural, 2 = AI
                        int BirthType = this.rand.Next(1, 3);

                        //...Make sure Company Has Insemination Tubes
                        if (BirthType == 2)
                        {
                            if (this.WetuSystem[this.SelectedCompanyIndex].InseminationTubes.Count == 0)
                            {
                                BirthType = 1;
                            }
                        }
                        else
                        {
                            if (this.WetuSystem[this.SelectedCompanyIndex].MaleAnimals.Count == 0)
                            {
                                if (this.WetuSystem[this.SelectedCompanyIndex].InseminationTubes.Count == 0)
                                {
                                    Console.WriteLine("Failed to add Birth Scenario: No Male Animals");
                                }
                                else
                                {
                                    BirthType = 2;
                                }
                            }
                        }

                        if (BirthType == 1)
                        {
                            //...Natural Insemination
                            Male = this.SelectRandomMaleAnimal();

                            //...Determine Success
                            int SuccessSelect = this.rand.Next(1, 101);

                            if ((SuccessSelect >= 25) && (SuccessSelect <= 75))
                            {
                                //...Successful birth
                                //...Create New Child
                                Child = this.AddChild();
                                Success = 1;
                            }
                            else
                            {
                                Child = 0;
                                Success = 0;
                            }
                        }
                        else
                        {
                            //...Select Insemination Tube
                            Tube = this.SelectRandomTube();
                            Male = this.WetuSystem[this.SelectedCompanyIndex].InseminationTubes[this.SelectedTube].AnimalId;

                            //...Determine Success
                            int SuccessSelect = this.rand.Next(1, 101);

                            if ((SuccessSelect >= 25) && (SuccessSelect <= 75))
                            {
                                //...Successful birth
                                //...Create New Child
                                Child = this.AddChild();
                                Success = 1;
                            }
                            else
                            {
                                Child = 0;
                                Success = 0;
                            }
                        }

                        //...Insert
                        var values = new NameValueCollection();
                        values["FemaleId"] = Female.ToString();
                        values["MaleId"] = Male.ToString();
                        values["ChildId"] = Child.ToString();
                        values["TubeId"] = Tube.ToString();
                        values["BirthTypeId"] = BirthType.ToString();
                        values["Success"] = Success.ToString();
                        values["CompanyId"] = this.SelectedCompany.ToString();
                        values["UserKey"] = this.SelectedUser.ToString();
                        values["ModifiedDate"] = this.SelectRandomModifiedDate().ToString();

                        int result = post.GetDataInstance<int>(this.PostUrl + URLs.AddBirth, values);

                        if (result != 0)
                        {
                            if (Tube != 0)
                            {
                                Tube toRemove = new Tube();
                                toRemove.AnimalId = Male;
                                toRemove.TubeId = Tube;
                                this.WetuSystem[this.SelectedCompanyIndex].InseminationTubes.Remove(toRemove);
                            }

                            Console.WriteLine("Birth was added");
                        }
                        else
                        {
                            Console.WriteLine("Failed to add Birth Scenario");
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void AddTube()
        {
            this.SelectRandomCompany();
            this.SelectRandomUser();

            if (this.SelectedUser != 0)
            {
                int AnimalId = this.SelectRandomMaleAnimal();
                if (AnimalId != 0)
                {

                    var values = new NameValueCollection();
                    values["AnimalId"] = AnimalId.ToString();
                    values["CompanyId"] = this.SelectedCompany.ToString();
                    values["UserKey"] = this.SelectedUser.ToString();
                    values["ModifiedDate"] = this.SelectRandomModifiedDate().ToString();

                    int result = post.GetDataInstance<int>(this.PostUrl + URLs.AddTube, values);

                    if (result != 0)
                    {
                        Tube ins = new Tube();
                        ins.TubeId = result;
                        ins.AnimalId = AnimalId;
                        this.WetuSystem[this.SelectedCompanyIndex].InseminationTubes.Add(ins);
                        Console.WriteLine("Company " + this.SelectedCompanyIndex.ToString() + " Added Tube: " + result.ToString() + " from - " + ins.AnimalId);
                    }
                    else
                    {
                        Console.WriteLine("Failed to insert Insemination Tube");
                    }
                }
            }
        }