예제 #1
0
파일: Simulation.cs 프로젝트: Ricium/Wetu
        private Animal AddDevice(int CompanyIndex)
        {
            this.SelectRandomUser();

            if (this.SelectedUser != 0)
            {
                var values = new NameValueCollection();
                values["Address"] = GenerateRandomString(8);
                values["CompanyId"] = this.WetuSystem[CompanyIndex].CompanyId.ToString();
                values["UserKey"] = this.SelectedUser.ToString();
                values["ModifiedDate"] = this.SelectRandomModifiedDate().ToString();

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

                Animal ins = new Animal();
                ins.AnimalId = result;
                ins.DeviceAddress = values["Address"];
                return ins;
            }
            else
            {
                this.AddUser(this.SelectedCompanyIndex);
                this.SelectRandomUser();

                var values = new NameValueCollection();
                values["Address"] = GenerateRandomString(8);
                values["CompanyId"] = this.WetuSystem[CompanyIndex].CompanyId.ToString();
                values["UserKey"] = this.SelectedUser.ToString();
                values["ModifiedDate"] = this.SelectRandomModifiedDate().ToString();

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

                Animal ins = new Animal();
                ins.AnimalId = result;
                ins.DeviceAddress = values["Address"];
                return ins;
            }
        }
예제 #2
0
파일: Simulation.cs 프로젝트: Ricium/Wetu
        public void AddAnimal()
        {
            Animal ins = new Animal();
            ins = this.AddDevice();

            if(ins.AnimalId != 0)
            {
                Console.WriteLine("Company " + this.SelectedCompanyIndex.ToString() + " Added Device: " + ins.DeviceAddress);

                int SexId = this.rand.Next(1, 3);
                var values = new NameValueCollection();
                string Name = GenerateRandomString(8);
                values["Name"] = Name;
                values["Tag"] = GenerateRandomString(8);
                values["DeviceId"] = ins.AnimalId.ToString();
                values["SexId"] = SexId.ToString();
                values["Species"] = this.SelectRandomSpecies().ToString();
                values["CompanyId"] = this.SelectedCompany.ToString();
                values["UserKey"] = this.SelectedUser.ToString();
                values["ModifiedDate"] = this.SelectRandomModifiedDate().ToString();

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

                if (result != 0)
                {
                    ins.AnimalId = result;
                    this.WetuSystem[this.SelectedCompanyIndex].Animals.Add(ins);
                    Console.WriteLine("Company " + this.SelectedCompanyIndex.ToString() + " Added Animal: " + Name + " with Device - " + ins.DeviceAddress);

                    if(SexId == 1)
                    {
                        this.WetuSystem[this.SelectedCompanyIndex].MaleAnimals.Add(ins);
                    }
                    else
                    {
                        this.WetuSystem[this.SelectedCompanyIndex].FemaleAnimals.Add(ins);
                    }

                }
                else
                {
                    Console.WriteLine("Failed to insert Animal");
                }
            }
            else
            {
                Console.WriteLine("Failed to insert Device");
            }
        }
예제 #3
0
파일: Simulation.cs 프로젝트: Ricium/Wetu
        private Animal AddChildDevice()
        {
            var values = new NameValueCollection();
            values["Address"] = GenerateRandomString(8);
            values["CompanyId"] = this.SelectedCompany.ToString();
            values["UserKey"] = this.SelectedUser.ToString();
            values["ModifiedDate"] = this.SelectRandomModifiedDate().ToString();

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

            Animal ins = new Animal();
            ins.AnimalId = result;
            ins.DeviceAddress = values["Address"];
            return ins;
        }