示例#1
0
        public static string GetResourceLink(Row row)
        {
            if (row == null)
                return string.Empty;

            File file = new File((IDictionary<string, object>)row.Values["File"]);
            return string.Format(CultureInfo.CurrentCulture, "https://www.rowshare.com/blob/{0}1/4/{1}", row.Id.ToString().Replace("-", ""), file.FileName);
        }
示例#2
0
        public static string PostData(string url, Row row, string login = null, string pwd = null)
        {
            SetCredentials(login, pwd);
            using (var client = new WebClient())
            {
                client.Encoding = Encoding.UTF8;
                if (!String.IsNullOrEmpty(Cookie))
                {
                    client.Headers.Add(HttpRequestHeader.Cookie, String.Format("{0}={1}", CookieName, Cookie));
                }
                client.Headers.Add(HttpRequestHeader.Accept, "*");
                client.Headers.Add(HttpRequestHeader.ContentType, "Application/json");

                var data = JsonUtilities.Serialize(row);
                return client.UploadString(String.Format(CultureInfo.CurrentCulture, "{0}api/{1}", RowShareUrl, url), data);
            }
        }
示例#3
0
        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));
        }
示例#4
0
        private OpeningTime ExtractOpeningTime(Row row, DayOfWeek dayOfWeek, string day, bool isToday)
        {
            string dayValue = string.Concat(row.Values[day]);
            var result = new OpeningTime()
            {
                DayOfWeek = dayOfWeek,
                DayOfWeekMessage = day,
                IsOpen = !string.IsNullOrWhiteSpace(dayValue),
                IsToday = isToday,
                Hours = ExtractHours(dayValue)
            };

            return result;
        }
示例#5
0
文件: Row.cs 项目: cubitouch/Barly
 public static void DeleteRow(Row data)
 {
     string url = string.Format(CultureInfo.CurrentCulture, "/row/delete/");
     RowShareCommunication.DeleteData(url, JsonUtilities.Serialize(data));
 }
示例#6
0
文件: Row.cs 项目: cubitouch/Barly
        public static Row UpdateRow(Row currentRow)
        {
            string url = string.Format(CultureInfo.CurrentCulture, "/row/save/");
            string json = RowShareCommunication.PostData(url, currentRow);

            return JsonUtilities.Deserialize<Row>(json, Utility.DefaultOptions);
        }