private void PopulateList(Object obj, OracleDataReader reader, PopulateData populateData) { Type type = obj.GetType().GetGenericArguments()[0]; var instance = Activator.CreateInstance(type); populateData(instance, reader); ((IList)obj).Add(instance); }
public override void Init(object initData) { base.Init(initData); Equipment = (EquipmentViewModel)initData; if (Equipment != null) { Types = PopulateData.GetTypes(); SelectedType = Equipment.Type; Name = Equipment.Name; Quantity = Equipment.Quantity; Id = Equipment.Id; } else { Types = PopulateData.GetTypes(); } }
private void PopulateFormObjects(int salesDateID) { // Use PopulateData class to retreive a bulk of the data. // then use the properties to get access to the data. PopulateData LoadDefaultData = new PopulateData(salesDateID); // Assign 3 fueldata objects // Load Gas SalesData // get list of Gas Sales AssignGasSales(LoadDefaultData.FuelDataAllList); RebateData = LoadDefaultData.RebatesData; NetworkTotalData = LoadDefaultData.NetworkTotalsData; RegisterTotalData = LoadDefaultData.RegisterData; VendorsDict = LoadDefaultData.VendorList; }
/// <summary> /// /// </summary> /// <param name="sqlQuery"></param> /// <param name="data">A single object of T or a List<T> where T is the datatype in PopulateData</param> /// <param name="populateData"></param> protected void ExecuteReader(string sqlQuery, Object data, PopulateData populateData) { var cmd = GetCommand(sqlQuery); var reader = cmd.ExecuteReader(); while (reader.Read()) { if (data.GetType().IsGenericType&& data is IEnumerable) { PopulateList(data, reader, populateData); } else { populateData(data, reader); } } CloseConnection(cmd); }
private void Form1_Load(object sender, EventArgs e) { string path = ConfigurationSettings.AppSettings["ProjectPath"]; string assemblyName = ConfigurationSettings.AppSettings["AssemblyName"]; try { projectData = XDocument.Load("XML/VsProject3Grader.xml"); string directory = Directory.GetCurrentDirectory(); string assemblyFile = string.Format("{0}\\{1}.DLL", directory, assemblyName); p4Assembly = Assembly.LoadFile(assemblyFile); //path + assemblyName + @".dll"); setup = new Setup(p4Assembly, projectData); grader = new Grader(setup.Name()); List <string> topicNames = setup.TopicNames(); foreach (string topicName in topicNames) { grader.Topics.Add(setup.SetupTopic(topicName)); } ProjectName.Text = grader.Name; PopulateData data = new PopulateData(); setup.GradeTheProject(grader, data); ResultsView.DataSource = grader.Topics; StudentName.Text = grader.Programmer; GradeSummary.Text = String.Format("Grade {0} / {1}", grader.TotalGrade, grader.TotalValue); Percentage.Text = String.Format("{0:0.0%}", grader.GradePercentage); ProgressIndicator.Maximum = grader.TotalValue; ProgressIndicator.Value = grader.TotalGrade; Color color = GetProgressColor(grader.GradePercentage); ProgressIndicator.BackColor = color; ProgressIndicator.ForeColor = color; } catch (System.IO.FileNotFoundException ex) { MessageBox.Show(String.Format("Could not load {0} from {1}. Check the properties in your App.Config file", assemblyName, path), "Could not find file", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public VehicleController(PopulateData dataManager) { CRUDDataInstance = dataManager; }
private void PopulateData() { populateData = new PublicClasses.PopulateData(); dgvHallDetails.DataSource = populateData.PopulateDetails("sp_Select_HallData", obj.sqlConnection, rs); }
static void Main(string[] args) { try { ConfigureAutoMapper.Configure(); var cmd = 0; var rand = new Random(); PopulateData.Populate(); while (true) { Console.WriteLine("Escolha a estratrégia: "); Console.WriteLine("Linq"); Console.WriteLine("1 - Batch"); Console.WriteLine("2 - Eager Load (Funciona apenas com Collection do tipo ISet)"); Console.WriteLine("3 - Lazy Load\n"); Console.WriteLine("QueryOver"); Console.WriteLine("4 - Batch"); Console.WriteLine("5 - Eager Load (Funciona apenas com Collection do tipo ISet)"); Console.WriteLine("6 - Lazy Load\n"); Console.WriteLine("Hql"); Console.WriteLine("7 - Batch"); Console.WriteLine("8 - Eager Load (Funciona apenas com Collection do tipo ISet)"); Console.WriteLine("9 - Lazy Load\n"); Console.WriteLine("Criteria (Estratégias Fetch no mapeamento funcionam nesse caso)"); Console.WriteLine("10 - Batch"); Console.WriteLine("11 - Eager Load (Funciona apenas com Collection do tipo ISet)"); Console.WriteLine("12 - Lazy Load\n"); Console.WriteLine("AutoMapper"); Console.WriteLine("13 - Mapper para Nome, Rua, Numero, Tipo"); Console.WriteLine("14 - Mapper para Nome"); Console.WriteLine("15 - Mapper para 2 listas"); Console.WriteLine("16 - Mapper para 1 listas Many to Many\n"); Console.WriteLine("Extra"); Console.WriteLine("17 - Get in Session"); Console.WriteLine("18 - Paginação com relacionamento one to many usando query over"); Console.WriteLine("19 - Paginação com relacionamento one to many usando linq\n"); var result = Console.ReadLine(); if (int.TryParse(result, out cmd)) { if (cmd < 1) { break; } var id = rand.Next(1, 10); switch (cmd) { case 1: LinqStrategy.Batch(id); break; case 2: LinqStrategy.EagerLoad(id); break; case 3: LinqStrategy.LazyLoad(id); break; case 4: QueryOverStrategy.Batch(id); break; case 5: QueryOverStrategy.EagerLoad(id); break; case 6: QueryOverStrategy.LazyLoad(id); break; case 7: HqlStrategy.Batch(id); break; case 8: HqlStrategy.EagerLoad(id); break; case 9: HqlStrategy.LazyLoad(id); break; case 10: CriteriaStrategy.Batch(id); break; case 11: CriteriaStrategy.EagerLoad(id); break; case 12: CriteriaStrategy.LazyLoad(id); break; case 13: AutoMapperStrategy.PessoaEnderecoTelefoneTipo(id); break; case 14: AutoMapperStrategy.Pessoa(id); break; case 15: AutoMapperStrategy.PessoaWithCollectionsSet(id); break; case 16: AutoMapperStrategy.PessoaWithManyToManySet(id); break; case 17: ExtraStrategy.SessionGet(id); break; case 18: ExtraStrategy.PaginationWithQueryOverWithCollectionEagerFetch(); break; case 19: ExtraStrategy.PaginationWithLinqWithCollectionEagerFetch(); break; default: Console.WriteLine("Nenhuma opção selecionada"); break; } } else { break; } Console.WriteLine("Tecle qualquer tecla para continuar..."); Console.ReadLine(); Console.Clear(); } } catch (Exception e) { Console.WriteLine(e.Message); } }
static void Main(string[] args) { #region Database Connection and Instantiation Variables // Redis Connetion params via App.config string host = ConfigurationManager.AppSettings["RedisHost"]; int port = Convert.ToInt32(ConfigurationManager.AppSettings["RedisPort"]); string password = ConfigurationManager.AppSettings["RedisPassword"]; // General Purpose AppConfig Values int serverSleepInterval = Convert.ToInt32(ConfigurationManager.AppSettings["ServerSleepInterval"]); int serverUpdateLoopCount = Convert.ToInt32(ConfigurationManager.AppSettings["ServerUpdateLoopCount"]); #endregion // Start Main Loop char choice; for (; ; ) { do { Common.ClearScreen(); Common.MainMenuHeader("Leaderboard Main Menu"); Console.WriteLine("\nServer Utilities"); Console.WriteLine(" 1. Populate Sorted Set"); Console.WriteLine(" 2. Increment Sorted Set"); Console.WriteLine(" 3. Infinite Loop Update"); Console.WriteLine(" 4. Flush Database"); Common.DashLine(); Console.Write("Choose one (q to quit): "); do { choice = (char)Console.Read(); } while (choice == '\n' | choice == '\r'); } while (choice < '1' | choice > '6' & choice != 'q'); if (choice == 'q') break; Console.WriteLine("\n"); switch (choice) { case '1': // Add inital Sorted Set Data Common.ClearScreen(); PopulateData.AddInitalData(host, port, password); Common.PausePrompt(); break; case '2': // Increment Sorted Set Data One Time Common.ClearScreen(); PopulateData.IncrementData(host, port, password, serverUpdateLoopCount, serverSleepInterval); Common.PausePrompt(); break; case '3': // Infinite Loop Sorted Set Data Update Common.ClearScreen(); PopulateData.IncrementData(host, port, password, 0, serverSleepInterval); break; case '4': // FlushDB Common.ClearScreen(); PopulateData.FlushDatabase(host, port, password); Common.PausePrompt(); break; default: Common.ClearScreen(); Common.PausePrompt(); break; } // end Switch } // end ForLoop } // end Main Method