public static void GenerateProject(int count) { List<Team> teams = Team.Get_All(); List<Company> companies = Company.Get_All(); Random rand=new Random(); for (int i = 0; i < count; i++) { Project p = new Project(); p.ProjectName = RandomString(15); p.Team = teams[rand.Next(teams.Count)]; p.Company = companies[rand.Next(companies.Count)]; p.StartOn = new DateTime(rand.Next(2000, 2013), rand.Next(1, 13), rand.Next(1, 29)); p.EndOn_Plan = p.StartOn.AddDays(rand.Next(100, 1000)); p.Location_East = (double)rand.Next(1183667, 1192333) / 10000; p.Location_North = (double)rand.Next(312333, 326167) / 10000; p.Save(); } }
private static List<Project> toList(DataTable dt) { List<Project> result = new List<Project>(); foreach (DataRow row in dt.Rows) { Project project = new Project(); project.ID = Int32.Parse(row["id"].ToString()); project.ProjectName = row["projectname"].ToString(); project.Team = Team.Get_ByID(Int32.Parse(row["teamid"].ToString())); project.Company = Company.Get_ByID(Int32.Parse(row["companyid"].ToString())); project.StartOn = DateTime.Parse(row["starton"].ToString()); project.EndOn_Plan = DateTime.Parse(row["endon_plan"].ToString()); if (row["endon_fact"] == DBNull.Value) project.EndOn_Fact = DateTime.MinValue; else project.EndOn_Fact = DateTime.Parse(row["endon_fact"].ToString()); project.Location_East = Double.Parse(row["location_east"].ToString()); project.Location_North = Double.Parse(row["location_north"].ToString()); result.Add(project); } return result; }