public static Collection<Column> GetColumnsByList(List list) { if (list == null) return null; Collection<Column> columns = GetColumnsByListId(list.Id.ToString().Replace("-", "")); foreach (Column column in columns) { column.Parent = list; } return columns; }
private void LoadLocations() { List locationTable = new List(); bool hasNewCache = false; try { locationTable = List.GetListById(_rowshareTableId); string cacheFilename = HostingEnvironment.MapPath(string.Format("~/App_Data/locations/{0}.json", locationTable.LastUpdateDateUtc.Ticks.ToString())); if (System.IO.File.Exists(cacheFilename)) { lock (cacheLock) { locationTable.LoadRows(System.IO.File.ReadAllText(cacheFilename)); } } else { locationTable.LoadRows(); hasNewCache = true; } if (hasNewCache) { locationTable.CacheRowsToFS(cacheFilename); locationTable.ClearCache(cacheFilename, locationTable.LastUpdateDateUtc); } } catch (System.Exception e) { string cacheDirectory = HostingEnvironment.MapPath(string.Format("~/App_Data/locations")); foreach (string cacheFile in System.IO.Directory.GetFiles(cacheDirectory)) { lock (cacheLock) { locationTable.LoadRows(System.IO.File.ReadAllText(cacheFile)); } } } _locations = new List<Location>(); foreach (Row row in locationTable.Rows) { _locations.Add(new Location(row)); } }
public Location(Row row) { Id = int.Parse(row.Values["Id"].ToString()); Name = row.Values["Nom"].ToString(); Description = row.Values["Description"].ToString(); Picture = GetResourceLink(row, "Photo"); Address = row.Values["Adresse"].ToString(); ZipCode = row.Values["Code postal"].ToString(); Latitude = double.Parse(row.Values["Latitude"].ToString()); Longitude = double.Parse(row.Values["Longitude"].ToString()); IsValid = bool.Parse(row.Values["Validé"].ToString()); if (row.Values["Foursquare"] != null) Foursquare = row.Values["Foursquare"].ToString(); OpeningTimes = new List<OpeningTime>(); OpeningTimes.Add(ExtractOpeningTime(row, DayOfWeek.Monday, "Lundi", DateTime.Today.DayOfWeek == DayOfWeek.Monday)); OpeningTimes.Add(ExtractOpeningTime(row, DayOfWeek.Tuesday, "Mardi", DateTime.Today.DayOfWeek == DayOfWeek.Tuesday)); OpeningTimes.Add(ExtractOpeningTime(row, DayOfWeek.Wednesday, "Mercredi", DateTime.Today.DayOfWeek == DayOfWeek.Wednesday)); OpeningTimes.Add(ExtractOpeningTime(row, DayOfWeek.Thursday, "Jeudi", DateTime.Today.DayOfWeek == DayOfWeek.Thursday)); OpeningTimes.Add(ExtractOpeningTime(row, DayOfWeek.Friday, "Vendredi", DateTime.Today.DayOfWeek == DayOfWeek.Friday)); OpeningTimes.Add(ExtractOpeningTime(row, DayOfWeek.Saturday, "Samedi", DateTime.Today.DayOfWeek == DayOfWeek.Saturday)); OpeningTimes.Add(ExtractOpeningTime(row, DayOfWeek.Sunday, "Dimanche", DateTime.Today.DayOfWeek == DayOfWeek.Sunday)); }
// 1 service => XX:XX - XX:XX // 2 services => XX:XX - XX:XX / XX:XX - XX:XX private List<TimeInterval> ExtractHours(string hours) { var intervals = new List<TimeInterval>(); string formatedHours = hours.Replace(" ", ""); string[] services = formatedHours.Split('/'); foreach (string service in services) { var times = service.Split('-'); if (times.Length == 2) intervals.Add(new TimeInterval(times[0], times[1])); } return intervals; }
public static Collection<Row> GetRowsByList(List list) { if (list == null) return null; Collection<Row> rows = GetRowsByListId(list.Id.ToString().Replace("-", "")); foreach (Row row in rows) { row.Parent = list; } return rows; }
public static void DeleteList(List data) { string url = string.Format(CultureInfo.CurrentCulture, "/row/delete/"); RowShareCommunication.DeleteData(url, JsonUtilities.Serialize(data)); }