public ActionResult Create() { int userId = (int)HttpContext.Session.GetInt32("userId"); List <Approval> approvals = db.Approval.Where(a => a.IdTutor == userId).ToList(); List <int> subjectsIds = new List <int>(); foreach (Approval app in approvals) { subjectsIds.Add(app.IdSubject); } if (!BoolParser.Parse(db.SscisParam.Single(p => p.ParamKey.Equals(SSCISParameters.STANDARTEVENTLENGTH)).ParamValue)) { ViewBag.LessonLength = db.SscisParam.Single(p => p.ParamKey.Equals(SSCISParameters.STANDARTEVENTLENGTH)).ParamValue; } else { ViewBag.LessonLength = "2"; } if (db.SscisUser.Find(userId).IdRoleNavigation == db.EnumRole.Single(r => r.Role.Equals(SSCISResources.Resources.ADMIN))) { ViewBag.SubjectID = new SelectList(db.EnumSubject.Where(s => s.IdParent == null && s.Lesson == false), "Id", "Code"); ViewBag.TutorID = new SelectList(db.SscisUser, "Id", "Login"); } else { ViewBag.SubjectID = new SelectList(db.EnumSubject.Where(s => subjectsIds.Contains(s.Id)), "Id", "Code"); ViewBag.TutorID = new SelectList(db.SscisUser.Where(t => t.Id == userId), "Id", "Login"); } return(View()); }
private void UpdateDataBaseZoo(List <string[]> rows) { ObservableCollection <Animal> collection = new ObservableCollection <Animal>(); foreach (var row in rows) { collection.Add(new Animal { AnimalName = row[0], Hair = BoolParser.Parse(row[1])?"+":"-", Feathers = BoolParser.Parse(row[2]) ? "+" : "-", Eggs = BoolParser.Parse(row[3]) ? "+" : "-", Milk = BoolParser.Parse(row[4]) ? "+" : "-", Airbourne = BoolParser.Parse(row[5]) ? "+" : "-", Aquatic = BoolParser.Parse(row[6]) ? "+" : "-", Predator = BoolParser.Parse(row[7]) ? "+" : "-", Toothed = BoolParser.Parse(row[8]) ? "+" : "-", Backbone = BoolParser.Parse(row[9]) ? "+" : "-", Breathes = BoolParser.Parse(row[10]) ? "+" : "-", Venomous = BoolParser.Parse(row[11]) ? "+" : "-", Fins = BoolParser.Parse(row[12]) ? "+" : "-", Legs = int.Parse(row[13]), Tail = BoolParser.Parse(row[14]) ? "+" : "-", Domestic = BoolParser.Parse(row[15]) ? "+" : "-", Catsize = BoolParser.Parse(row[16]) ? "+" : "-", Type = int.Parse(row[17]) }); } ObservableCollection <ClassifyAnimal> classify = new ObservableCollection <ClassifyAnimal>(); classify.Add(new ClassifyAnimal()); dataGridClassify.ItemsSource = classify; dataGrid.ItemsSource = collection; }
public ActionResult Login(string validationMessage = null, string redirectionUrl = null) { string redirectUrl = WebUtility.UrlDecode(redirectionUrl); bool webauth = BoolParser.Parse(Db.SscisParam.Where(p => p.ParamKey.Equals(SSCISParameters.WEBAUTHON, StringComparison.OrdinalIgnoreCase)).Single().ParamValue); string testAuthParametr; if (webauth) { string webAuth = Db.SscisParam.Where(p => p.ParamKey.Equals(SSCISParameters.WEBAUTHURL)).Single().ParamValue.ToString(); if (redirectionUrl != null) { testAuthParametr = webAuth + "?redirect=" + WebUtility.UrlEncode(redirectionUrl); } else { testAuthParametr = webAuth; } return(Redirect(testAuthParametr)); } ViewBag.Title = "Login"; MetaLogin model = new MetaLogin { ValidationMessage = validationMessage, RedirectionUrl = redirectionUrl }; return(View(model)); }
private void zoo_example() { string path = @"zoo.txt"; Headers = new string[] { "Hair", "Feathers", "Eggs", "Milk", "Airborne", "Aquatic", "Predator", "Toothed", "Backbone", "Breathes", "Venomous", "Fins", "Legs", "Tail", "Domestic", "Catsize" }; Result = "Animal type"; List <string[]> rows = new List <string[]>(); List <string[]> dummy = new List <string[]>(); foreach (var animalData in File.ReadAllLines(path)) { List <string> data = new List <string>(); string[] line = animalData.Split(','); for (int i = 0; i < line.Length; ++i) { if (i == 13 || i == 17 || i == 0) { data.Add(line[i]); } else { data.Add(BoolParser.Parse(line[i]).ToString()); } } dummy.Add(data.ToArray()); data.RemoveAt(0); rows.Add(data.ToArray()); } UpdateDataBaseZoo(dummy); tcMain.Clear(); tree = DecisionTreeTools.BuildTree(rows); DecisionTreeTools.Prune(tree.NextFalseNode.NextTrueNode.NextFalseNode.NextTrueNode, 1.01); DecisionTreeTools.Prune(tree.NextFalseNode.NextTrueNode.NextTrueNode.NextFalseNode, 1.01); PrintTree(tree); listBoxZoo.Items.Clear(); listBoxZoo.Items.Add( "1 -- (41) aardvark, antelope, bear, boar, buffalo, calf, cavy, cheetah, deer, dolphin, elephant, fruitbat, giraffe, girl, goat, gorilla, hamster, hare, leopard, lion, lynx, mink, mole, mongoose, opossum, oryx, platypus, polecat, pony, porpoise, puma, pussycat, raccoon, reindeer, seal, sealion, squirrel, vampire, vole, wallaby,wolf "); listBoxZoo.Items.Add( "2 -- (20) chicken, crow, dove, duck, flamingo, gull, hawk, kiwi, lark, ostrich, parakeet, penguin, pheasant, rhea, skimmer, skua, sparrow, swan, vulture, wren "); listBoxZoo.Items.Add("3 -- (5) pitviper, seasnake, slowworm, tortoise, tuatara"); listBoxZoo.Items.Add( "4 -- (13) bass, carp, catfish, chub, dogfish, haddock, herring, pike, piranha, seahorse, sole, stingray, tuna "); listBoxZoo.Items.Add("5 -- (4) frog, frog, newt, toad "); listBoxZoo.Items.Add("6 -- (8) flea, gnat, honeybee, housefly, ladybird, moth, termite, wasp "); listBoxZoo.Items.Add( "7 -- (10) clam, crab, crayfish, lobster, octopus, scorpion, seawasp, slug, starfish, worm"); listBoxZoo.Visibility = Visibility.Visible; }
/// <summary> /// Returns a bool value stored in this object. /// </summary> public bool AsBool(bool defaultValue = false) { if (rawObject is bool) { return((bool)rawObject); } if (rawObject is string) { return(BoolParser.Parse(((string)rawObject).ToLower())); } return(defaultValue); }
private void Debug_Click(object sender, EventArgs e) { BddSharp.AST.VarList.ResetDic(); BoolParser parser = new BoolParser(); Scanner sc = new Scanner(); TextReader tr = new StringReader(ExpressionBox.Text); CategorizeVariables(VarsBox.Text); Ast = parser.Parse(sc.Scan(tr)); DebugBox.Text = Ast.print(); }
public void ParseTest() { BoolParser target = new BoolParser(); System.Collections.Generic.IEnumerator <BddSharp.Parser.Token> ts = null; // TODO: Initialize to an appropriate value IBoolExpr expected = null; IBoolExpr actual; actual = target.Parse(ts); Assert.AreEqual(expected, actual, "BddSharp.Parser.BoolParser.parse did not return the expected value."); Assert.Inconclusive("Verify the correctness of this test method."); }
public ActionResult Create(MetaEvent model) { model.Event = new Event(); if (ModelState.IsValid && model.Date >= DateTime.Now) { for (int i = 0; i < model.Recurrence; i++) { Event newEvent = new Event(); newEvent.IdTutorNavigation = db.SscisUser.Find(model.TutorID); newEvent.IdTutor = model.TutorID; newEvent.IsCancelled = false; if (newEvent.IdTutorNavigation.IdRoleNavigation.Role.Equals(SSCISResources.Resources.ADMIN)) { newEvent.IsAccepted = true; } else { newEvent.IsAccepted = false; } newEvent.IsExtraLesson = false; newEvent.TimeFrom = new DateTime(model.Date.Year, model.Date.Month, model.Date.Day, model.TimeFrom.Hour, model.TimeFrom.Minute, 0); if (!BoolParser.Parse(db.SscisParam.Single(p => p.ParamKey.Equals(SSCISParameters.STANDARTEVENTLENGTH)).ParamValue)) { int hour = Convert.ToInt32(db.SscisParam.Where(p => p.ParamKey.Equals(SSCISParameters.STANDARTEVENTLENGTH)).Single().ParamValue); newEvent.TimeTo = new DateTime(model.Date.Year, model.Date.Month, model.Date.Day, model.TimeFrom.Hour + hour, model.TimeFrom.Minute, 0); } else { newEvent.TimeTo = model.Event.TimeFrom.AddHours(2); } newEvent.IdSubjectNavigation = db.EnumSubject.Find(model.SubjectID); newEvent.IdSubject = (int)model.SubjectID; newEvent.IdApplicantNavigation = null; newEvent.IdApplicant = null; int increase = i * 7; newEvent.TimeFrom = newEvent.TimeFrom.AddDays(increase); newEvent.TimeTo = newEvent.TimeTo.AddDays(increase); db.Event.Add(newEvent); db.SaveChanges(); } return(RedirectToAction("TutorEvents", new { created = 1 })); } return(RedirectToAction("Create")); }
public ActionResult HelpMe() { ViewBag.SubjectID = new SelectList(Db.EnumSubject.Where(s => s.IdParent == null), "Id", "Code"); int userId = 0; if (HttpContext.Session.GetInt32("userId").HasValue) { userId = (int)HttpContext.Session.GetInt32("userId");; } bool extraLessonEnable = true; extraLessonEnable = BoolParser.Parse(Db.SscisParam.Single(p => p.ParamKey.Equals(SSCISParameters.EXTRALESSONENABLE, StringComparison.OrdinalIgnoreCase)).ParamValue); string text = Db.SscisParam.Where(p => p.ParamKey.Equals(SSCISParameters.POTREBUJIPOMOCHTML, StringComparison.OrdinalIgnoreCase)).Single().ParamValue; ViewBag.TextHelpMe = WebUtility.HtmlDecode(text); ViewBag.Title = "Potřebuji pomoc"; ViewBag.PersonalTimeTable = personalTimetable.RenderEvents(Db, userId); ViewBag.PublicTimeTable = timeTableRenderer.RenderPublic(Db); ViewBag.ExtraLessonEnable = extraLessonEnable; return(View()); }
private void Execute_Click(object sender, EventArgs e) { BddSharp.AST.VarList.ResetDic(); BoolParser parser = new BoolParser(); Scanner sc = new Scanner(); TextReader tr = new StringReader(ExpressionBox.Text); CategorizeVariables(VarsBox.Text); Ast = parser.Parse(sc.Scan(tr)); BoolExpr.execute(Ast, "foo"); if (ExpressionBox.Text == string.Empty) { MessageBox.Show("Error: No expression provided."); } else { Thread.Sleep(4000); System.Diagnostics.Process.Start("results\\foo.jpg", null); } }
public static Maybe <bool> ParseToBool(this string source) { return(BoolParser.Parse(source)); }
public ActionResult HelpMe(MetaEvent model) { if (model != null) { model.Event = new Event(); if (ModelState.IsValid) { int userId = (int)HttpContext.Session.GetInt32("userId"); model.Event.TimeFrom = new DateTime(model.Date.Year, model.Date.Month, model.Date.Day, model.TimeFrom.Hour, model.TimeFrom.Minute, 0); if (!BoolParser.Parse(Db.SscisParam.Single(p => p.ParamKey.Equals(SSCISParameters.EXTRAEVENTLENGTH, StringComparison.OrdinalIgnoreCase)).ParamValue)) { int hour = Convert.ToInt32(Db.SscisParam.Where(p => p.ParamKey.Equals(SSCISParameters.EXTRAEVENTLENGTH, StringComparison.OrdinalIgnoreCase)).Single().ParamValue); model.Event.TimeTo = new DateTime(model.Date.Year, model.Date.Month, model.Date.Day, model.TimeFrom.Hour + hour, model.TimeFrom.Minute, 0); } else { model.Event.TimeTo = model.Event.TimeFrom.AddHours(1); } model.Event.IdSubjectNavigation = Db.EnumSubject.Find(model.SubjectID); model.Event.IdTutorNavigation = null; model.Event.IdTutor = null; model.Event.IsAccepted = false; model.Event.IsCancelled = false; model.Event.IsExtraLesson = true; model.Event.IdApplicantNavigation = Db.SscisUser.Find(userId); string comment = model.Comment.ToString(); model.Event.ExtraComment = model.Comment.ToString(); Db.Event.Add(model.Event); Db.SaveChanges(); int newId = model.Event.Id; EmailMessage emailMessage = new EmailMessage(); List <EmailAddress> listTo = new List <EmailAddress>(); foreach (var item in Db.Approval) { if (item.IdSubject == model.SubjectID) { if (item.IdTutorNavigation.Email != null && item.IdTutorNavigation.Email.Length > 2) { EmailAddress emailTo = new EmailAddress(); emailTo.Name = item.IdTutorNavigation.Login; emailTo.Address = item.IdTutorNavigation.Email; listTo.Add(emailTo); } } } string subjectCode = Db.EnumSubject.Where(s => s.Id == model.SubjectID).Single().Code; emailMessage.ToAddresses = listTo; emailMessage.Subject = string.Format(_configuration.GetValue <string>("EmailMessageConfigs:ExtraLectionEmail:Subject"), subjectCode); emailMessage.Content = string.Format(_configuration.GetValue <string>("EmailMessageConfigs:ExtraLectionEmail:Content"), comment, subjectCode, SSCHttpContext.AppBaseUrl, newId); _emailService.Send(emailMessage); return(RedirectToAction("HelpMe")); } } return(RedirectToAction("HelpMe")); }
public static Either <TLeft, bool> ParseToBool <TLeft>(this string source, TLeft left) { return(BoolParser.Parse(source, left)); }
public static Either <TLeft, bool> ParseToBool <TLeft>(this Either <TLeft, string> source, TLeft left) { return(source.FlatMap(x => BoolParser.Parse(x, left))); }
public static void CreateInstance() { BoolParser instance = new BoolParser(); instance.Parse(true); }