public Efforts Sort() { ArrayList al = new ArrayList(); Efforts newEfforts = new Efforts(); foreach(Effort eff in this){ al.Add(eff.ConventionalId); } al.Sort(); foreach(string conventionalID in al){ foreach(Effort eff in this){ if (eff.ConventionalId == conventionalID){ newEfforts.Add(eff); } } } this.Clear(); foreach(Effort eff in newEfforts){ this.Add(eff); } return this; }
public static Efforts AllEfforts() { Efforts effs = new Efforts(); Effort eff; using(MySqlConnection conn = Connections.Inst.item("QED_DB").MySqlConnection){ conn.Open(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM efforts"; using(MySqlDataReader dr = cmd.ExecuteReader()){ while(dr.Read()) { eff = new Effort(dr, true); eff.BusinessCollection = effs; effs.Add(eff); } } } return effs; }
public static Efforts Unrolled() { Efforts effs = new Efforts(); Effort eff; bool beenHere = false; System.Text.StringBuilder inList = new System.Text.StringBuilder(); using(MySqlConnection conn = Connections.Inst.item("QED_DB").MySqlConnection){ conn.Open(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT effId FROM effortRollouts WHERE rolled = 1"; using(MySqlDataReader dr = cmd.ExecuteReader()){ while(dr.Read()){ if (beenHere) inList.Append(","); else beenHere = true; inList.Append(Convert.ToString(dr[0])); } } if (inList.Length > 0){ cmd.CommandText = "SELECT * FROM efforts WHERE id not in (" + inList.ToString() + ")"; }else{ cmd.CommandText = "SELECT * FROM efforts"; } using(MySqlDataReader dr = cmd.ExecuteReader()){ while(dr.Read()) { eff = new Effort(dr, true); eff.BusinessCollection = effs; effs.Add(eff); } } } return effs; }
public Efforts GetCachedEfforts(bool reload) { if (reload || _cachedEfforts == null) _cachedEfforts = this.Efforts; return _cachedEfforts; }