public void PopulateHighCharts() { UserProgram greProgram = new UserProgram() { ID = "1", Name = "GRE", Score = 25 }; greProgram.userSubPrograms.Add(new UserProgram() { ID = "11", Name = "GRE1", Score = 25 }); greProgram.userSubPrograms.Add(new UserProgram() { ID = "12", Name = "GRE2", Score = 25 }); greProgram.userSubPrograms.Add(new UserProgram() { ID = "13", Name = "GRE3", Score = 25 }); UserPrograms.Add(greProgram); UserProgram gmatProgram = new UserProgram() { ID = "2", Name = "GMAT", Score = 25 }; gmatProgram.userSubPrograms.Add(new UserProgram() { ID = "21", Name = "GMAT1", Score = 25 }); gmatProgram.userSubPrograms.Add(new UserProgram() { ID = "22", Name = "GMAT2", Score = 25 }); gmatProgram.userSubPrograms.Add(new UserProgram() { ID = "23", Name = "GMAT3", Score = 25 }); UserPrograms.Add(gmatProgram); UserProgram kbrProgram = new UserProgram() { ID = "3", Name = "KBR", Score = 25 }; kbrProgram.userSubPrograms.Add(new UserProgram() { ID = "31", Name = "KBR1", Score = 25 }); kbrProgram.userSubPrograms.Add(new UserProgram() { ID = "32", Name = "KBR2", Score = 25 }); kbrProgram.userSubPrograms.Add(new UserProgram() { ID = "33", Name = "KBR3", Score = 25 }); UserPrograms.Add(kbrProgram); }
public bool CanDeleteProgram(PluginProgram program) { return(UserPrograms.Any(x => x.Library == program.Library && x.Name == program.Name && x.Path == program.Path && File.Exists(program.Path))); }
public PluginProgram?SaveProgram(string name, string data, bool overwrite) { var programPath = Path.Combine(UserDir, name + ".json"); if (!Directory.Exists(Path.GetDirectoryName(programPath))) { Directory.CreateDirectory(Path.GetDirectoryName(programPath)); } if (File.Exists(programPath) && !overwrite) { return(null); } File.WriteAllText(programPath, data); // Reload programs UserPrograms = GetProgramFiles(UserDir); return(UserPrograms.Single(x => x.Path == programPath)); }
/** * this method returns a list of UserPrograms objects of every program in the system. * */ public static List <UserPrograms> getAllPrograms() { List <UserPrograms> programs = new List <UserPrograms>(); String database = System.Configuration.ConfigurationManager.ConnectionStrings["programaholics_anonymous_databaseConnectionString"].ConnectionString; using (OleDbConnection sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + database)) { try { String query = "SELECT * FROM [programs] ORDER BY [username]"; OleDbDataAdapter adapter = new OleDbDataAdapter(query, sqlConn); ProgramsDataSet ds = new ProgramsDataSet(); adapter.Fill(ds, "programs"); DataTable table = new DataTable(); table = ds.Tables["programs"]; int i = 0; do { DataRow dr = table.Rows[i]; //set current data row List <Program> userPrograms = new List <Program>(); //new list for each user String username = dr["username"].ToString(); //get current user while (username == dr["username"].ToString()) //for each user create new Program and add to list of programs { Program program = new Program(); program.username = dr["username"].ToString(); program.ID = Convert.ToInt32(dr["ID"].ToString()); program.language = dr["language"].ToString(); program.programName = dr["programName"].ToString(); program.createdOnDate = dr["createdOnDate"].ToString(); userPrograms.Add(program); i++; if (i < table.Rows.Count) //make sure we don't out of bounds error { dr = table.Rows[i]; //move to next data row } else { break; //break loop if gone over total data rows in table } } UserPrograms thisUser = new UserPrograms(); //complets list of all programs for user thisUser.username = username; //set username thisUser.programs = userPrograms; //add all programs programs.Add(thisUser); //add to all programs in system. } while (i < table.Rows.Count); } catch (OleDbException ex) { } finally { sqlConn.Close(); } return(programs); } }
/** * this method returns a list of UserPrograms objects of every program in the system. * */ public static List<UserPrograms> getAllPrograms() { List<UserPrograms> programs = new List<UserPrograms>(); String database = System.Configuration.ConfigurationManager.ConnectionStrings["programaholics_anonymous_databaseConnectionString"].ConnectionString; using (OleDbConnection sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + database)) { try { String query = "SELECT * FROM [programs] ORDER BY [username]"; OleDbDataAdapter adapter = new OleDbDataAdapter(query, sqlConn); ProgramsDataSet ds = new ProgramsDataSet(); adapter.Fill(ds, "programs"); DataTable table = new DataTable(); table = ds.Tables["programs"]; int i = 0; do { DataRow dr = table.Rows[i]; //set current data row List<Program> userPrograms = new List<Program>(); //new list for each user String username = dr["username"].ToString(); //get current user while (username == dr["username"].ToString()) //for each user create new Program and add to list of programs { Program program = new Program(); program.username = dr["username"].ToString(); program.ID = Convert.ToInt32(dr["ID"].ToString()); program.language = dr["language"].ToString(); program.programName = dr["programName"].ToString(); program.createdOnDate = dr["createdOnDate"].ToString(); userPrograms.Add(program); i++; if (i < table.Rows.Count) //make sure we don't out of bounds error { dr = table.Rows[i]; //move to next data row } else { break; //break loop if gone over total data rows in table } } UserPrograms thisUser = new UserPrograms(); //complets list of all programs for user thisUser.username = username; //set username thisUser.programs = userPrograms; //add all programs programs.Add(thisUser); //add to all programs in system. } while (i < table.Rows.Count); } catch (OleDbException ex) { } finally { sqlConn.Close(); } return programs; } }
public ProgramsXmlWriter(UserPrograms programs) { this.programs = programs; }