// Кодирование public BitArray Encode(string source) { List<bool> encodedSource = new List<bool>(); for (int i = 0; i < source.Length; i++) { //str += "'"+source[i]+"':["; List<bool> encodedSymbol = this.Root.Traverse(source[i], new List<bool>()); foreach (bool ee in encodedSymbol) { str+=ee?"1":"0"; } //str += "] "; if(i!=source.Length-1) str += " "; encodedSource.AddRange(encodedSymbol); } BitArray bits = new BitArray(encodedSource.ToArray()); return bits; }
public string[] GetCities(string prefixText, int count, Dictionary<string, string> contextValues) { List<string> cities = new List<string>(_lookupService.GetCities(prefixText, contextValues["State"], count)); return cities.ToArray(); }
public ActionResult Edit(Entry entry, int[] selectedCategories, string huKeywords, string enKeywords, string toDeleteFiles) { var toEditEntry = db.Entries.Where(e => e.Id == entry.Id).First(); KeywordsProcedure(toEditEntry, huKeywords, enKeywords); var attachments = TempData["Attachments"] as List<string>; var featuredImage = TempData["FeaturedImage"] as List<string>; if (ModelState.IsValid) { toEditEntry.enContent = entry.enContent; toEditEntry.enIntroduction = entry.enIntroduction; toEditEntry.enTitle = entry.enTitle; toEditEntry.huContent = entry.huContent; toEditEntry.huIntroduction = entry.huIntroduction; toEditEntry.huTitle = entry.huTitle; toEditEntry.IsFeatured = entry.IsFeatured; toEditEntry.Published = entry.Published; toEditEntry.PublishedDate = entry.PublishedDate; toEditEntry.UserId = int.Parse((string)Session["UserId"]); toEditEntry.Categories.Clear(); foreach (var id in selectedCategories.ToList()) { Category category = db.Categories.Single(e => e.Id == id); toEditEntry.Categories.Add(category); } //Delete to delete List<string> fileNames = new List<string>(); foreach (var idString in toDeleteFiles.Split(',').Where(e => e != "")) { int id = int.Parse(idString); var file = db.Files.Where(e => e.Id == id).First(); fileNames.Add(file.Name); toEditEntry.Files.Remove(file); db.Files.Remove(file); } var ctrl = new UploadController(); ctrl.PathValue = "/Public/Files/"; ctrl.Remove(fileNames.ToArray()); //Add new ones if (attachments != null) { foreach (var att in attachments) { WebApplication.File newAtt = new WebApplication.File { Entry = toEditEntry, Location = Guid.NewGuid().ToString(), Name = Path.GetFileName(att) }; db.Files.Add(newAtt); } } if (featuredImage != null && featuredImage.Count > 0) { string[] fileName = { Path.GetFileName(entry.FeaturedImage) }; ctrl.PathValue = "/Public/Images/"; ctrl.Remove(fileName); toEditEntry.FeaturedImage = featuredImage[0]; } else if (string.IsNullOrEmpty(entry.FeaturedImage)) { toEditEntry.FeaturedImage = ""; } try { db.SaveChanges(); } catch (DbEntityValidationException e) { } TempData["Attachments"] = null; TempData["FeaturedImage"] = null; return RedirectToAction("Index"); } ViewBag.Categories = db.Categories.Select(e => e); ViewBag.SelectedCategories = selectedCategories.ToList(); ViewBag.enKeywords = db.Keywords.Where(e => e.Type == true); ViewBag.huKeywords = db.Keywords.Where(e => e.Type == false); return View(entry); }