public string getMyRidesSlim(int volunteerId) // returns future rides only { try { GzipMe(); RideSlimExt r = new RideSlimExt(); Object rl = r.GetFutureRides(volunteerId); return(j.Serialize(rl)); } catch (Exception ex) { throw new Exception(" שגיאה בשליפת נתוני הסעות עבר"); } }
public string GetRidePatViewSlim(int maxDays) { try { HttpResponse response = GzipMe(); RideSlimExt rp = new RideSlimExt(); Object r = rp.GetRidePatView(maxDays); j.MaxJsonLength = Int32.MaxValue; return(j.Serialize(r)); } catch (Exception ex) { CatchErrors catchErrors = new CatchErrors("WebService: Exception in GetRidePatView", ex + " " + ex.Message + " " + ex.InnerException + " " + ex.Source, ex.StackTrace); //Log.Error("Error in GetRidePatView", ex); throw new Exception("שגיאה בשליפת נתוני הסעות"); } }
public Object GetRidePatView(int daysAhead) { // get the basic ride data DbService db = new DbService(); Dictionary <int, RideSlimExt> dic = new Dictionary <int, RideSlimExt>(); //List<RideSlimExt> rides = new List<RideSlimExt>(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@daysAhead", daysAhead); cmd.CommandText = "spGetBasicRidePatData"; //if (db.con.State == ConnectionState.Closed) //{ // con.Open(); //} //command.Connection = con; SqlDataReader dr = db.GetDataReaderSP(cmd); while (dr.Read()) { Id = Convert.ToInt32(dr["ridepatnum"]); Destination = dr["destination"].ToString(); Origin = dr["origin"].ToString(); PickUpTime = Convert.ToDateTime(dr["PickUpTime"].ToString()); bool isAnonymous = true; if (dr["IsAnonymous"] == System.DBNull.Value) { isAnonymous = false; } else { isAnonymous = Convert.ToBoolean(dr["IsAnonymous"]); } PatientName = dr["patient"].ToString(); if (isAnonymous || PatientName.Contains("אנונימי") || PatientName.Contains("Anonymous")) { PatientName = "אנונימי"; } CellPhone = dr["CellPhone"].ToString(); RideSlimExt rse = new RideSlimExt(PatientName, "", 0, Origin, Destination, PickUpTime, Id, CellPhone); rse.Area = dr["area"].ToString(); rse.OnlyEscort = Convert.ToBoolean(dr["onlyEscort"]); dic.Add(Id, rse); } dr.Close(); // get the escorts cmd.CommandText = "spGetEscortsForRides"; dr = db.GetDataReaderSP(cmd); while (dr.Read()) { int ridepatnum = Convert.ToInt32(dr["ridepatnum"]); dic[ridepatnum].escorts = new List <EscoretSlim>(); string displayName = dr["DisplayName"].ToString(); bool isAnonymous = true; if (dr["IsAnonymous"] == System.DBNull.Value) { isAnonymous = false; } else { isAnonymous = Convert.ToBoolean(dr["IsAnonymous"]); } if (isAnonymous != true && !displayName.Contains("אנונימי") && !displayName.Contains("Anonymus")) { string cellphone = dr["CellPhone"].ToString(); dic[ridepatnum].escorts.Add(new EscoretSlim(displayName, cellphone, 0)); } else { dic[ridepatnum].escorts.Add(new EscoretSlim("אנונימי", "", 0)); } } dr.Close(); // get the equipment cmd.CommandText = "spGetEquipmentPerPatient"; dr = db.GetDataReaderSP(cmd); while (dr.Read()) { string patient = dr["patient"].ToString(); string equipment = dr["Name"].ToString(); foreach (KeyValuePair <int, RideSlimExt> kv in dic) { if (kv.Value.PatientName == patient) { if (kv.Value.equipment == null) { kv.Value.equipment = new List <string>(); } kv.Value.equipment.Add(equipment); } } } db.CloseConnection(); List <RideSlimExt> l = dic.Values.ToList <RideSlimExt>(); Object o = RideSlimExtToObject(l); return(o); }