public TimeSignatureDialogViewModel(BarInfo info) { BarInfo = info; TimeSignatureControls = new TimeSignatureControlsViewModel() { TempoNumericBoxValue = info.Tempo, SelectedBeats = info.Beats, SelectedNoteLength = info.NoteLength }; this.ObservableForProperty(x => x.TimeSignatureControls.TempoNumericBoxValue) .Subscribe(x => BarInfo = new BarInfo( x.Value, TimeSignatureControls.SelectedBeats, TimeSignatureControls.SelectedNoteLength )); this.ObservableForProperty(x => x.TimeSignatureControls.SelectedBeats) .Subscribe(x => BarInfo = new BarInfo( TimeSignatureControls.TempoNumericBoxValue, x.Value, TimeSignatureControls.SelectedNoteLength )); this.ObservableForProperty(x => x.TimeSignatureControls.SelectedNoteLength) .Subscribe(x => BarInfo = new BarInfo( TimeSignatureControls.TempoNumericBoxValue, TimeSignatureControls.SelectedBeats, x.Value )); }
private void CreateBars() { var barInfoTypes = BarInfo.GetBarInfoTypesToShow(); foreach (BarInfoType barInfoType in barInfoTypes) { BarInfo barInfo = new BarInfo(barInfoType); Bar bar = CreateBar(barInfo); AddBar(bar); } }
/// <summary> /// This checks the users name and bar number against the Washington State Bar Association website. /// IF the name matches exactly, lisence type is lawyer, AND eligibility is yes return true. Else /// return false because the lawyer is not valid. /// </summary> /// <param name="name">Name of lawyer, must be full name as given to the bar association</param> /// <param name="barNumber"> bar number as a string</param> /// <param name="email">string that holds the provided email</param> /// <returns>true if lawyer is valid and information matches, false otherwise</returns> public async Task <bool> IsValidLawyerAsync(int barNumber, string email) { BarInfo lawyer = await FetchBarInfoAsync(BuildUrl(barNumber)); return(lawyer.Eligible.ToLower().Trim() == "yes" && lawyer.Type.ToLower().Trim() == "lawyer" && lawyer.Email == email); }
private Bar CreateBar(BarInfo barInfo) { BarType barType = barInfo.GetBarType(); Bar prefab = GetBarPrefab(barType); Bar bar = Instantiate(prefab); bar.ApplyBarInfo(barInfo); bar.transform.SetParent(barLayoutGroup.transform); bar.transform.localScale = new Vector3(1, 1, 1); bar.SetColor(WhitTools.GetColorWithRandomHue(0.6f, 1.0f)); return bar; }
public int Updata(BarInfo barInfo) { //定义参数集合,可以动态添加元素 List <SQLiteParameter> listPs = new List <SQLiteParameter>(); //构造update的sql语句 string sql = "update BarInfo set btime=@time where bnumber=@number"; listPs.Add(new SQLiteParameter("@time", barInfo.Btime)); listPs.Add(new SQLiteParameter("@number", barInfo.BNumber)); //执行语句并返回结果 return(SqliteHelper.ExecuteNonQuery(sql, listPs.ToArray())); }
/// <summary> /// 插入数据 /// </summary> /// <param name="info"></param> /// <returns></returns> public int Insert(BarInfo info) { //构造insert语句 string sql = "insert into BarInfo(bnumber,btype,bweight,btime) values(@number,@type,@weight,@time)"; //构造sql语句的参数 SQLiteParameter[] ps = { new SQLiteParameter("@number", info.BNumber), new SQLiteParameter("@type", info.BType), new SQLiteParameter("@weight", info.BWeight), new SQLiteParameter("@time", info.Btime) }; return(SqliteHelper.ExecuteNonQuery(sql, ps)); }
void SetNextText(bool isPositiveAnswer, bool isImmediatelly = false) { bool isLose; currentStorySettings = GameManager.Instance.StoryManager.GetNextStory(currentStorySettings, isPositiveAnswer, out isLose); if (currentStorySettings != null) { isAnswerButtonsEnabled = false; card.HideText(() => { card.ShowText(currentStorySettings, () => { isAnswerButtonsEnabled = true; }, isImmediatelly); }); } else { EndGamePopup endGamePopup = Instantiate(endGamePopupPrefab, transform); endGamePopup.transform.localPosition = Vector3.zero; endGamePopup.Show("ПРОДОЛЖЕНИЕ СЛЕДУЕТ :)"); PlayerPrefs.DeleteAll(); } StoryManager storyManager = GameManager.Instance.StoryManager; foreach (var parameter in storyManager.ValueByType) { BarInfo barInfo = barsInfo.Find((item) => item.parameterType == parameter.Key); if (barInfo != null) { Image image = barInfo.image; float current = image.fillAmount; float delta = current - (float)parameter.Value / storyManager.MaxValue; if (!Mathf.Approximately(delta, 0f)) { DOTween.To(() => 0f, (value) => { image.fillAmount = current - value * delta; }, 1, 0.1f) .SetId(this); } } } }
public void UpSqlite(BarInfo barInfo) { //根据编号查询结果 BarInfo barInfo2 = infoDal.GetByNumber(barInfo.BNumber); if (barInfo2 == null) { infoDal.Insert(barInfo); } else { long nowtick = TimeTransitionHelper.GetCurrentTimeUnix(); if (nowtick - barInfo.Btime > 1200)//20分钟后可再次扫码 { infoDal.Updata(barInfo); } } }
public static BarInfo ConvertToWeekly(BarInfo data) { DateTime dt = DateTime.MinValue; DateTime lastDate = DateTime.MinValue; data.Token.periodicity = Periodicity.Week; BarInfo ret = new BarInfo { Token = data.Token }; var srtData = data.OrderBy(x => x.TimeStamp); foreach (var itm in srtData) { if (dt.Date < itm.TimeStamp.Date) { dt = CloseWeekDate(itm.TimeStamp); ret.Add(new Bar { Close = itm.Close, High = itm.High, Low = itm.Low, Open = itm.Open, TimeStamp = dt, Volume = itm.Volume }); } else { var bar = ret[ret.Count - 1]; bar.Close = itm.Close; bar.High = bar.High > itm.High ? bar.High : itm.High; bar.Low = bar.Low < itm.High ? bar.Low : itm.Low; bar.Volume += itm.Volume; } lastDate = itm.TimeStamp; } if (ret.Count > 0) { ret[ret.Count - 1].TimeStamp = lastDate; } return(ret); }
IEnumerator MoveBar(BarInfo info) { if (grade != Grade.F) { float current = gradeBar.material.GetFloat("_Fill"); float init = current; float time = Time.time; while (true) { float t = (Time.time - time) / 0.25f; current = Mathf.Lerp(init, info.value, t); gradeBar.material.SetFloat("_Fill", current); if ((current >= info.value && info.value != 0) || (info.value == 0.0f && current == 0.0F)) { break; } else { yield return(null); } } if (info.value >= 1.0F && info.action == BarInfo.Action.Increase) { AddGrade(); } else if (info.value == 0.0F && info.action == BarInfo.Action.Decrease) { DecreaseGrade(); } } barActions.Dequeue(); if (barActions.Count > 0) { callNextAction = true; } }
static void Main(string[] args) { MemoryStream output = new MemoryStream(); BarInfo test = new BarInfo(1, false); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(BarInfo)); serializer.WriteObject(output, test); serializer = new DataContractJsonSerializer(typeof(Block[])); Console.WriteLine(output.ToArray()); for (int i = 0; i < 5; i++) { output = new MemoryStream(); Block[] blocks = new Block[2]; blocks[1] = timeBlock(); blocks[0] = dateBlock(); serializer.WriteObject(output, blocks); Console.Write(i == 0 ? '[' : ','); Console.WriteLine(ByteToCharArray(output.ToArray())); Thread.Sleep(2000); } output.Dispose(); }
public override void ApplyBarInfo(BarInfo barInfo) { base.ApplyBarInfo(barInfo); }
//private static List<BarInfo> Barinfo_list { get; set; } = new List<BarInfo>(); public static void Do(out List <BarInfo> barinfo_list_list) { barinfo_list_list = new List <BarInfo>(); //while (true) //{ bool EndOfPages = false; int CountOfPages = 1; while (EndOfPages == false) { HtmlDocument doc = new HtmlDocument(); //doc.LoadHtml(getRequest(@"http://gdebar.ru/bars?mainType[0]=3&withFilter=1&p=" + CountOfPages.ToString() + "&fromUrl=/bars")); doc.LoadHtml(Program.getRequest(@"http://gdebar.ru/bars?mainType[0]=3&withFilter=1&p=" + CountOfPages.ToString() + "&fromUrl=/bars")); //http://gdebar.ru/bars?mainType[0]=3&withFilter=1&p=' + str(i) + '&fromUrl=/bars //HtmlNodeCollection l = doc.DocumentNode.SelectNodes("//section[@class = 'catalog__list']"); //Console.WriteLine(doc.DocumentNode.SelectNodes("//div[@class = 'catalog__list']").Count); if (doc.DocumentNode.SelectNodes("//section[@class = 'catalog__list']")[0].InnerText.Contains("По данному запросу заведений не найдено :(")) { EndOfPages = true; Console.WriteLine("stop"); continue; } else { Console.WriteLine("continue"); } //Console.WriteLine(doc.Encoding.EncodingName); //Console.WriteLine(doc); HtmlNodeCollection BarCollection = doc.DocumentNode.SelectNodes("//div[@class = 'place-card__specif']/a"); for (int i = 0; i < BarCollection.Count; i++) { if (!BarCollection[i].InnerText.Contains("\r\n")) { BarCollection.Remove(BarCollection[i]); } } foreach (var item in BarCollection) //тестовый вывод { Console.WriteLine(item.InnerText); // Console.WriteLine(item.Attributes["href"].Value); } Console.WriteLine(BarCollection.Count); foreach (var item in BarCollection) { HtmlDocument doc_2 = new HtmlDocument(); doc_2.LoadHtml(Program.getRequest("http://gdebar.ru" + item.Attributes["href"].Value + "/menu")); HtmlNodeCollection Menu = doc_2.DocumentNode.SelectNodes("//div[@class = 'menu__dish d-flex align-items-center justify-content-between p-2']"); //if (Menu == null) continue; if (doc_2.DocumentNode.SelectNodes("//div[@class = 'text-center alert alert-danger h1']") != null) { continue; } if (Menu == null) { BarInfo info = new BarInfo(); HtmlNodeCollection ff = doc_2.DocumentNode.SelectNodes("//div[@id = 'bar-gallery-main']/div/a"); // отсюда берем ссылки на пикчи if (ff != null) { foreach (var item_3 in ff) { info.PictureLinks.Add(item_3.Attributes["href"].Value); } } else { info.PictureLinks.Add(null); } if (doc_2.DocumentNode.SelectNodes("//div[@class = 'dropdown-menu dropdown-menu--tooltip']/a") != null) { HtmlNodeCollection subwayy = doc_2.DocumentNode.SelectNodes("//div[@class = 'dropdown-menu dropdown-menu--tooltip']/a"); List <string> twmm = new List <string>(); foreach (var item_2 in subwayy) { twmm.Add(item_2.InnerText.Replace("\n", "").Trim().Split(" ")[0]); } info.NearSubway = twmm.ToArray(); } else if (doc_2.DocumentNode.SelectNodes("//div[@class = 'metro d-flex align-items-start pl-4 mt-2 flex-wrap']") != null) { List <string> twm = new List <string>(); HtmlNode temp = doc_2.DocumentNode.SelectNodes("//div[@class = 'metro d-flex align-items-start pl-4 mt-2 flex-wrap']")[0]; string sub = temp.InnerText.Replace("\r\n", "").Trim().Split(" ")[0]; twm.Add(sub); info.NearSubway = twm.ToArray(); } else { info.NearSubway = new string[] { "отсутствует" }; } if (doc_2.DocumentNode.SelectNodes("//a[@class = 'fancybox3']")[0].InnerText.ToLower().Contains("работает")) { info.WorkTime = doc_2.DocumentNode.SelectNodes("//a[@class = 'fancybox3']")[0].InnerText.Replace("\r\n", "").Split("работает ")[1].Replace(" ", ""); } else { info.WorkTime = "время работы неизвестно"; } if (doc_2.DocumentNode.SelectNodes("//a[@class = 'roistat-phone']") != null) { info.Phone = doc_2.DocumentNode.SelectNodes("//a[@class = 'roistat-phone']")[0].InnerText.Trim(); } else { info.Phone = doc_2.DocumentNode.SelectNodes("//div[@class = 'phone bar__main--info__line d-flex align-items-center justify-content-start mb-4 w-100 flex-nowrap']")[0].InnerText.Trim(); } string add = doc_2.DocumentNode.SelectNodes("//span[@class = 'font-weight-light mr-0']")[0].InnerText.Trim(); List <string> poss = Yandex.Yandex.GetPos(Apikey, add); Console.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------------"); Console.WriteLine(poss[0].Split(" ")[1]); Console.WriteLine("---------------------------------------------------"); info.Lat = Convert.ToDouble(poss[0].Split(" ")[1].Replace(".", ",")); //широта info.Lng = Convert.ToDouble(poss[0].Split(" ")[0].Replace(".", ",")); //долгота info.BarName = item.InnerText.Trim(); if (info.BarName.Contains('ё')) { info.BarName.Replace("ё", "е"); } info.HasMenu = false; barinfo_list_list.Add(info); continue; } BarInfo barinfo = new BarInfo(); MenuItems menuitems = new MenuItems(); //barinfo.NearSubway[0] = doc_2.DocumentNode.SelectNodes("//div[@class = 'metro d-flex align-items-start pl-4 mt-2 flex-wrap']/div"); //HtmlNodeCollection temp = doc_2.DocumentNode.SelectNodes("//div[@class = 'metro d-flex align-items-start pl-4 mt-2 flex-wrap']"); HtmlNodeCollection subway = doc_2.DocumentNode.SelectNodes("//div[@class = 'dropdown-menu dropdown-menu--tooltip']/a"); Console.WriteLine(item.InnerText.Trim()); if (doc_2.DocumentNode.SelectNodes("//div[@class = 'dropdown-menu dropdown-menu--tooltip']/a") != null) { subway = doc_2.DocumentNode.SelectNodes("//div[@class = 'dropdown-menu dropdown-menu--tooltip']/a"); List <string> twm = new List <string>(); foreach (var item_2 in subway) { twm.Add(item_2.InnerText.Replace("\n", "").Trim().Split(" ")[0]); } barinfo.NearSubway = twm.ToArray(); } else if (doc_2.DocumentNode.SelectNodes("//div[@class = 'metro d-flex align-items-start pl-4 mt-2 flex-wrap']") != null) { List <string> twm = new List <string>(); HtmlNode temp = doc_2.DocumentNode.SelectNodes("//div[@class = 'metro d-flex align-items-start pl-4 mt-2 flex-wrap']")[0]; string sub = temp.InnerText.Replace("\r\n", "").Trim().Split(" ")[0]; twm.Add(sub); barinfo.NearSubway = twm.ToArray(); } else { barinfo.NearSubway = new string[] { "отсутствует" }; } //HtmlNode tttt = doc_2.DocumentNode.SelectNodes("//div[@class = 'metro d-flex align-items-start pl-4 mt-2 flex-wrap']")[0]; foreach (var item_2 in Menu) { //barinfo = new BarInfo(); menuitems = new MenuItems(); HtmlNode subtitle_path_2 = item_2.ParentNode.ParentNode.ParentNode; //сладкая вода - не обязательная subtitle_2 HtmlNode subtitle_path = subtitle_path_2.ParentNode.ParentNode; //вода HtmlNode title_path = subtitle_path.ParentNode.ParentNode; //бар //Console.WriteLine(name_path.InnerText); //Console.WriteLine(subtitle_path.InnerText); menuitems.BarName = item.InnerText.Replace("\r", "").Replace("\n", "").Trim(); if (menuitems.BarName.Contains('ё')) { menuitems.BarName.Replace("ё", "е"); } //if (title_path.Name == "parent") Console.WriteLine("1"); if (title_path.GetAttributeValue("class", "") == "parent") { if (title_path.ChildNodes[0].InnerText.Contains(" (")) { menuitems.Title = title_path.ChildNodes[0].InnerText.Split(" (")[0]; //главная принадлежность } else { menuitems.Title = title_path.ChildNodes[0].InnerText; } Console.WriteLine(title_path.ChildNodes[0].InnerText); } if (subtitle_path.ChildNodes[0].InnerText.Contains(" (")) { menuitems.Subtitle = subtitle_path.ChildNodes[0].InnerText.Split(" (")[0]; //вторичная принадлежность } else { menuitems.Subtitle = subtitle_path.ChildNodes[0].InnerText; } if (subtitle_path_2.ChildNodes[0].ChildNodes[0].InnerText.Contains(" (")) { menuitems.Subtitle_2 = subtitle_path_2.ChildNodes[0].ChildNodes[0].InnerText.Split(" (")[0]; // если существует, то третичная } else { menuitems.Subtitle_2 = subtitle_path_2.ChildNodes[0].ChildNodes[0].InnerText; } Console.WriteLine(subtitle_path.ChildNodes[0].InnerText); Console.WriteLine(subtitle_path_2.ChildNodes[0].ChildNodes[0].InnerText); HtmlNodeCollection childrens = item_2.ChildNodes; //Console.WriteLine(childrens.Count); menuitems.Dish = childrens[0].ChildNodes[0].InnerText; menuitems.Price = Convert.ToInt32(childrens[1].InnerText.Split(" ")[0]); Console.WriteLine("блюдо - " + childrens[0].ChildNodes[0].InnerText); Console.WriteLine("цена - " + childrens[1].InnerText); Menuitems_list.Add(menuitems); //Console.WriteLine(subtitle_path.ChildNodes[0].InnerText); //Console.WriteLine(name_path.ChildNodes[0].ChildNodes[0].InnerText); //Console.WriteLine(title_path.ChildNodes[0].InnerText); //Console.WriteLine(name_path.Name); //Console.WriteLine(subtitle_path.Name); //Console.WriteLine(title_path.OriginalName); } Console.WriteLine("-"); //Console.WriteLine(item); //doc_2.LoadHtml(getRequest("http://gdebar.ru" + item.Attributes["href"].Value)); HtmlNodeCollection f = doc_2.DocumentNode.SelectNodes("//div[@id = 'bar-gallery-main']/div/a"); // отсюда берем ссылки на пикчи foreach (var item_3 in f) { barinfo.PictureLinks.Add(item_3.Attributes["href"].Value); } if (doc_2.DocumentNode.SelectNodes("//a[@class = 'fancybox3']")[0].InnerText.ToLower().Contains("работает")) { barinfo.WorkTime = doc_2.DocumentNode.SelectNodes("//a[@class = 'fancybox3']")[0].InnerText.Replace("\r\n", "").Split("работает ")[1].Replace(" ", ""); } else { barinfo.WorkTime = "отсутсвует"; } if (doc_2.DocumentNode.SelectNodes("//a[@class = 'roistat-phone']") != null) { barinfo.Phone = doc_2.DocumentNode.SelectNodes("//a[@class = 'roistat-phone']")[0].InnerText.Trim(); } else { barinfo.Phone = doc_2.DocumentNode.SelectNodes("//div[@class = 'phone bar__main--info__line d-flex align-items-center justify-content-start mb-4 w-100 flex-nowrap']")[0].InnerText.Trim(); } string address = doc_2.DocumentNode.SelectNodes("//span[@class = 'font-weight-light mr-0']")[0].InnerText.Trim(); List <string> pos = Yandex.Yandex.GetPos(Apikey, address); Console.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------------"); Console.WriteLine(pos[0].Split(" ")[1]); Console.WriteLine("---------------------------------------------------"); barinfo.Lat = Convert.ToDouble(pos[0].Split(" ")[1].Replace(".", ",")); //широта barinfo.Lng = Convert.ToDouble(pos[0].Split(" ")[0].Replace(".", ",")); //долгота Console.WriteLine("dddddddddddddddd - " + barinfo.Lat); barinfo.BarName = item.InnerText.Trim(); if (barinfo.BarName.Contains('ё')) { barinfo.BarName.Replace("ё", "е"); } barinfo.HasMenu = true; barinfo_list_list.Add(barinfo); } Console.WriteLine(CountOfPages); CountOfPages += 1; Thread.Sleep(2000); } //запись в бд // ClearBD("barinfo"); //ClearBD("menuitems"); //PastIntoBD(barinfo_list_list, Menuitems_list); Console.WriteLine("--------------------------------------------------------------------"); //Thread.Sleep(50000); //86400000 - это сутки //} }
/// <summary> /// Выполняет парсинг сайта KudaGo мск /// </summary> public static void Do(out List <BarInfo> barinfo_list_list) { barinfo_list_list = new List <BarInfo>(); HttpClient client = new HttpClient(); double PagesForKudaGo = 1; for (int j = 0; j < PagesForKudaGo; j++) { Console.WriteLine("J = " + j + " Pages = " + PagesForKudaGo); int page = j + 1; string url = "https://kudago.com/public-api/v1.4/places/?lang=&page=" + page + "&fields=&expand=&order_by=&text_format=&ids=&location=msk&has_showings=&showing_since=&showing_until&categories=bar&lon=&lat=&radius="; PagesForKudaGo += 1; string stuff = client.GetStringAsync(url).GetAwaiter().GetResult(); var rootobject = JsonConvert.DeserializeObject <MainJson.Rootobject>(stuff); PagesForKudaGo = Math.Ceiling((double)rootobject.count / 20); for (int i = 0; i < rootobject.results.Length; i++) { if (rootobject.results[i].is_closed == true) { continue; } BarInfo barinfo = new BarInfo(); // Console.WriteLine(rootobject.results[i].title + rootobject.results[i].id + " " + rootobject.results[i].is_closed + " " + rootobject.results[i].subway); barinfo.NearSubway = rootobject.results[i].subway.Split(", "); barinfo.BarName = rootobject.results[i].title; if (barinfo.BarName.Contains('ё')) { barinfo.BarName.Replace("ё", "е"); } barinfo.HasMenu = false; barinfo.Phone = rootobject.results[i].phone; url = "https://kudago.com/public-api/v1.4/places/" + rootobject.results[i].id + "/?expand=images"; stuff = client.GetStringAsync(url).GetAwaiter().GetResult(); var rootobject1 = JsonConvert.DeserializeObject <Details.Rootobject>(stuff); if (rootobject1.address.Contains("«Трёхгорная мануфактура»")) { rootobject1.address = rootobject1.address.Replace("«Трёхгорная мануфактура»,", ""); } else if (rootobject1.address.Contains("башня «Империя»")) { rootobject1.address = rootobject1.address.Replace("башня «Империя»", ""); } Console.WriteLine(rootobject1.address); List <string> pos = Yandex.Yandex.GetPos(Apikey, rootobject1.address); barinfo.Lat = Convert.ToDouble(pos[0].Split(" ")[1].Replace(".", ",")); //широта barinfo.Lng = Convert.ToDouble(pos[0].Split(" ")[0].Replace(".", ",")); //долгота //barinfo.Lat = rootobject1.coords.lat; //barinfo.Lng = rootobject1.coords.lon; if (rootobject1.timetable == "") { barinfo.WorkTime = "время работы неизвестно"; } else { barinfo.WorkTime = rootobject1.timetable; } for (int k = 0; k < rootobject1.images.Length; k++) { barinfo.PictureLinks.Add(rootobject1.images[k].image); } //Barinfo_list.Add(barinfo); barinfo_list_list.Add(barinfo); } Console.WriteLine(); Thread.Sleep(2000); } //PastIntoBD(barinfo_list_list); }
public bool Edit(BarInfo barInfo) { return(infoDal.Updata(barInfo) > 0); }
public bool Add(BarInfo barInfo) { return(infoDal.Insert(barInfo) > 0); }
/// <summary> /// Чтение данных из бд /// </summary> private static void ReadBD() { //выборка данных из бд Models.ModelOfBar bar = new Models.ModelOfBar(); Models.ModelOfMenuItems items = new Models.ModelOfMenuItems(); Models.ModelOfUserRate rate = new Models.ModelOfUserRate(); string connectionString = "Server=localhost;Port=5432;User ID=postgres;Password=3400430;Database=Menu;"; NpgsqlConnection npgSqlConnection = new NpgsqlConnection(connectionString); npgSqlConnection.Open(); Console.WriteLine("Соединение с БД открыто"); NpgsqlCommand npgSqlCommand = new NpgsqlCommand("SELECT * FROM barinfo", npgSqlConnection); NpgsqlDataReader npgSqlDataReader = npgSqlCommand.ExecuteReader(); if (npgSqlDataReader.HasRows) { Console.WriteLine("Таблица: BarInfo"); Console.WriteLine(""); foreach (DbDataRecord dbDataRecord in npgSqlDataReader) { bar = new Models.ModelOfBar(); //Console.WriteLine(dbDataRecord["BarName"] + " " + dbDataRecord["Latitude"] + " " + dbDataRecord["Longitude"] + " " + dbDataRecord["Phone"] + " " + dbDataRecord["WorkTime"] + " " + dbDataRecord["Pictures"]); bar.BarName = dbDataRecord["BarName"].ToString(); bar.Lat = Convert.ToDouble(dbDataRecord["Latitude"]); bar.Lng = Convert.ToDouble(dbDataRecord["Longitude"]); bar.Phone = dbDataRecord["Phone"].ToString(); bar.WorkTime = dbDataRecord["WorkTime"].ToString(); bar.HasMenu = Convert.ToBoolean(dbDataRecord["HasMenu"]); string[] temp = dbDataRecord["Pictures"].ToString().Split("|"); foreach (var item in temp) { if (item != "") { bar.PictureLinks.Add(item); } } BarInfo.Add(bar); } } else { Console.WriteLine("Запрос не вернул строк в BarInfo"); } npgSqlDataReader.Close(); npgSqlCommand = new NpgsqlCommand("SELECT * FROM menuitems", npgSqlConnection); npgSqlDataReader = npgSqlCommand.ExecuteReader(); if (npgSqlDataReader.HasRows) { Console.WriteLine("Таблица: MenuItems"); Console.WriteLine(""); foreach (DbDataRecord dbDataRecord in npgSqlDataReader) { items = new Models.ModelOfMenuItems(); // Console.WriteLine(dbDataRecord["Title"] + " " + dbDataRecord["Subtitle"] + " " + dbDataRecord["Subtitle_2"] + " " + dbDataRecord["Dish"] + " " + dbDataRecord["Price"] + " " + dbDataRecord["BarName"]); items.Title = dbDataRecord["Title"].ToString(); items.Subtitle = dbDataRecord["Subtitle"].ToString(); items.Subtitle_2 = dbDataRecord["Subtitle_2"].ToString(); items.Dish = dbDataRecord["Dish"].ToString(); items.Price = Convert.ToInt32(dbDataRecord["Price"]); items.BarName = dbDataRecord["BarName"].ToString(); MenuItems.Add(items); } } else { Console.WriteLine("Запрос не вернул строк в MenuItems"); } npgSqlDataReader.Close(); npgSqlCommand = new NpgsqlCommand("SELECT * FROM UserRate", npgSqlConnection); npgSqlDataReader = npgSqlCommand.ExecuteReader(); if (npgSqlDataReader.HasRows) { Console.WriteLine("Таблица: UserRate"); Console.WriteLine(""); foreach (DbDataRecord dbDataRecord in npgSqlDataReader) { rate = new Models.ModelOfUserRate(); // Console.WriteLine(dbDataRecord["Title"] + " " + dbDataRecord["Subtitle"] + " " + dbDataRecord["Subtitle_2"] + " " + dbDataRecord["Dish"] + " " + dbDataRecord["Price"] + " " + dbDataRecord["BarName"]); rate.BarName = dbDataRecord["BarName"].ToString(); string[] temp = dbDataRecord["Likes"].ToString().Split(","); foreach (var item in temp) { if (item != "") { rate.Likes.Add(Convert.ToInt64(item)); } } temp = dbDataRecord["Dislikes"].ToString().Split(","); foreach (var item in temp) { if (item != "") { rate.Dislikes.Add(Convert.ToInt64(item)); } } UserRate.Add(rate); } } else { Console.WriteLine("Запрос не вернул строк в MenuItems"); } Console.WriteLine("чтение завершено"); npgSqlDataReader.Close(); npgSqlConnection.Close(); }
public virtual void ApplyBarInfo(BarInfo barInfo) { this.barInfo = barInfo; barText.text = barInfo.text; }