private void btnSave_Click(object sender, EventArgs e) { rule r = new rule(); if (txtPositionID.Text.Trim().Length > 0 && txtPositionName.Text.Trim().Length > 0 && r.CheckNumber(txtSalary.Text.Trim()) == true) { try { positionBLL.Save(txtPositionID.Text, txtPositionName.Text, txtSalary.Text, txtPositionID.Text); //update control // btnSave.Enabled = false; DisplayNotify("Lưu dữ liệu thành công", 1); } catch (Exception ex) { DisplayNotify("Lỗi Lưu dữ liệu không thành công", -1); } } else { DisplayNotify("Lỗi nhập sai các ô nhập liệu hoặc nhập thiếu", -1); } }
private static IEnumerable<ReportEntry> ProcessRuleRoot(rule rule, XElement ruleRoot, XmlNamespaceManager namespaceManager, string context, string phase) { if (ruleRoot != null) { if (rule.assert != null) { foreach (assert assrt in rule.assert) { dynamic evaluationResult = ruleRoot.XPathEvaluate(context.Equals("/") ? (context + assrt.test) : assrt.test, namespaceManager); if (evaluationResult.GetType().Equals(typeof (bool))) { if (!(bool) evaluationResult) yield return ReportIssue(rule, context, phase, assrt, ValidationSource.Schematron); } else { var found = (IEnumerable) evaluationResult; IEnumerable<XElement> attList = found.Cast<XElement>(); XElement elem = attList.FirstOrDefault(); if (elem == null) yield return ReportIssue(rule, context, phase, assrt, ValidationSource.Schematron); } } } } }
/*Rules form changed to computable way (AB->C to ABC) */ private float getRuleSupport(rule input) { string[] wantedRule = input.text.Split(new string[] { "->" }, StringSplitOptions.None); string compositeRule = wantedRule[0] + "@" + wantedRule[1]; return(getSupport(compositeRule)); }
private float getConfidence(rule input) { string[] wantedRule = input.text.Split(new string[] { "->" }, StringSplitOptions.None); float denominator = getSupport(wantedRule[0]); float numerator = input.support; return(numerator / denominator); }
// Use this for initialization void Awake() { rules = this; r1.gameObject.SetActive(false); r2.gameObject.SetActive(false); r3.gameObject.SetActive(false); r4.gameObject.SetActive(false); }
private float getLift(rule input) { string[] wantedRule = input.text.Split(new string[] { "->" }, StringSplitOptions.None); float A = input.support; float B = getSupport(wantedRule[0]); float C = getSupport(wantedRule[1]); return(A / (B * C)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { rule rules = new rule(); DataTable dt = rules.SelectAllRules(); DataRow[] row = dt.Select(); foreach (DataRow rs in row) //将检索到的数据逐一,循环添加到Listbox1中 { TextBox1.Text = rs["content"].ToString(); } } }
public bool CheckFieldNumber(Control control) { bool check = true; // field number if (control.Name == "txtPhone" || control.Name == "txtNumberID" || control.Name == "txtSalary") { rule r = new rule(); if (control.Name == "txtPhone") { if (r.CheckPhone(control.Text) == false) { check = false; this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Red; } else { this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Green; } } else { if (control.Name == "txtNumberID") { if (r.CheckNumberID(control.Text) == false) { check = false; this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Red; } else { this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Green; } } else { if (r.CheckNumber(control.Text) == false) { check = false; this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Red; } else { this.Controls.Find(control.Tag.ToString(), true)[0].ForeColor = Color.Green; } } } } return(check); }
public bool DeleteOne(int id) { bool num; try { rule wk = db.rules.Find(id); db.rules.Remove(wk); db.SaveChanges(); num = true; } catch (Exception e) { throw e; } return(num); }
public int CompareTo(object obj) { rule r = (rule)obj; if (this.num > r.num) { return(1); } else if (this.num < r.num) { return(-1); } else { return(this.name.CompareTo(r.name)); } }
public string[] sortByOdds(string[] rules) { int len = rules.Length; rule[] rs = new rule[len]; int i; for (i = 0; i < len; i++) { rs[i] = new rule(rules[i]); } Array.Sort(rs); string[] res = new string[len]; for (i = 0; i < len; i++) { res[i] = rs[i].name; } return res; }
public string[] sortByOdds(string[] rules) { int len = rules.Length; rule[] rs = new rule[len]; int i; for (i = 0; i < len; i++) { rs[i] = new rule(rules[i]); } Array.Sort(rs); string[] res = new string[len]; for (i = 0; i < len; i++) { res[i] = rs[i].name; } return(res); }
public bool ChangeContext(int id, string context) { bool num; try { rule cr = db.rules.Find(id); if (cr != null) { cr.context = context; db.SaveChanges(); num = true; } else { return(false); } } catch (Exception e) { throw e; } return(num); }
private static IEnumerable<ReportEntry> ProcessRule(XDocument docToValidate, rule rule, XmlNamespaceManager namespaceManager, pattern pattern, string phase) { var result = new List<ReportEntry>(); XElement ruleRoot = null; if (!string.IsNullOrEmpty(rule.context)) { if (rule.context == "/" && docToValidate.Document != null) ruleRoot = docToValidate.Document.Root; else ruleRoot = docToValidate.XPathSelectElement(rule.context, namespaceManager); } result.AddRange(ProcessRuleRoot(rule, ruleRoot, namespaceManager, rule.context, phase)); if (rule.extends != null && !string.IsNullOrEmpty(rule.extends.rule)) { foreach (rule subRule in pattern.rule.Where(r => r.@abstract && r.id == rule.extends.rule)) { result.AddRange(ProcessRuleRoot(subRule, ruleRoot, namespaceManager, rule.context, phase)); } } return result; }
c.ReportDiagnosticWhenActive(Diagnostic.Create(rule, identifier.GetLocation()));
{ typeof(INotNullValidator), (context, rule, component) => new RequiredClientValidator(rule, component) },
c.ReportDiagnosticWhenActive(Diagnostic.Create(rule, lockExpression.GetLocation(), lockExpressionType.Name));
c.ReportDiagnosticWhenActive(Diagnostic.Create(rule, zeroMember.GetLocation(), identifier.ValueText));
c.ReportDiagnosticWhenActive(Diagnostic.Create(rule, c.Node.GetLocation()));
public ActionResult <string> Rule(int id) { rule rl = new rule(); return(rl.createEngine()); }
static void ParseRules(string infile, string outfile) { Console.WriteLine("-=-=- Parsing nics: " + infile + " -> " + outfile + " -=-=-"); string[] rows = File.ReadAllLines(infile); List<rule> rules = new List<rule>(); string currentserver = null; rule currentrule = null; string currentname = null; foreach (string row in rows) { if (row.StartsWith("Server: ")) { currentserver = row.Substring(8); continue; } if (currentserver == null || row == string.Empty || row.StartsWith("----------")) { continue; } if (!row.Contains(' ')) { continue; } string name = row.Contains(':') ? row.Split(':').First() : string.Empty; string value = row.Contains(':') ? row.Split(new char[] { ':' }, 2).Last().Trim() : row.Trim(); if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("Verbose"))) { Console.WriteLine("name: '" + name + "'"); Console.WriteLine("value: '" + value + "'"); } if (name == "Rule Name") { currentrule = new rule { _server = currentserver }; currentrule._rulename = value; } else if (name == "Enabled") { currentrule._enabled = value; } else if (name == "Direction") { currentrule._direction = value; } else if (name == "Profiles") { currentrule._profiles = value; } else if (name == "Grouping") { currentrule._grouping = value; } else if (name == "LocalIP") { currentrule._localip = value; } else if (name == "RemoteIP") { currentrule._remoteip = value; } else if (name == "Protocol") { currentrule._protocol = value; } else if (name == string.Empty && currentname == "Protocol") { if (value.Split(' ').First() == "Type" && value.Split(new char[] { ' ' }, 2).Last().Trim() == "Code") { } else if (value.Contains(' ')) { currentrule._protocol += ": Type: " + value.Split(' ').First() + ", Code: " + value.Split(new char[] { ' ' }, 2).Last().Trim(); } else { Console.WriteLine("Unknown protocol row: Server: " + currentrule._server + ", value: '" + value + "'"); } } else if (name == "LocalPort") { currentrule._localport = value; } else if (name == "RemotePort") { currentrule._remoteport = value; } else if (name == "Edge traversal") { currentrule._edgetraversal = value; } else if (name == "Action") { currentrule._action = value; rules.Add(currentrule); currentrule = null; } else { Console.WriteLine("Unknown row: Server: " + currentrule._server + ", name: '" + name + "'"); } if (name != string.Empty) { currentname = name; } } List<string> output = new List<string>(); output.Add( "Server\tRuleName\tEnabled\tDirection\t" + "Profiles\tGrouping\tLocalIP\tRemoteIP\t" + "Protocol\tLocalPort\tRemotePort\tEdgeTraversal\t" + "Action"); output.AddRange(rules .Select(s => s._server + '\t' + s._rulename + '\t' + s._enabled + '\t' + s._direction + '\t' + s._profiles + '\t' + s._grouping + '\t' + s._localip + '\t' + s._remoteip + '\t' + s._protocol + '\t' + s._localport + '\t' + s._remoteport + '\t' + s._edgetraversal + '\t' + s._action) .OrderBy(s => s)); File.WriteAllLines(outfile, output); return; }
/* This function first splits the input ABCD to A,B,C,D * and then creates of its multiples up to one less from input length * so in that case function creates singles,doubles,triples but not quadruples * (A,B,C,D,AB,AC,AD,BC,BD,CD,ABC,ACD,ADB,BCD) -> list of multiples (rule particles) * and then matches these rules particles and create every possible distinct rules * A->B,A->C,...,AC->B,AC->D,...,ABC->D,...,BCD->A */ private void createRules(List <string> ruleCandidates, int columnCount) { List <rule> Rules = new List <rule>(); foreach (string candidate in ruleCandidates) { List <string> ruleParticles = new List <string>(); string[] elements = candidate.Split('@');//Splits to singles List <string> sets = new List <string>(); foreach (string element in elements) { sets.Add(element); ruleParticles.Add(element); } //singles added as ruleParticle for becoming input of the next iteration List <string> nextSets = new List <string>(); for (int i = 0; i < elements.Length - 2; i++) { foreach (string item in sets)//Split to singles and looks for anything can be add { string[] contents = item.Split('@'); foreach (string element in elements) { bool found = true;//flag for anything found to be add foreach (string content in contents) { if (element == content) { found = false; break; } } if (found) { string toBeAdded = element + "@" + item; foreach (string particle in ruleParticles) { if (SortString(particle) == SortString(toBeAdded)) { found = false; } } if (found) { ruleParticles.Add(toBeAdded); //When creates multiples(singles,doubles,triples and so on) add them as rule praticle nextSets.Add(toBeAdded); //its stored her for becoming next iterations input } } } } sets.Clear(); foreach (string item in nextSets) { sets.Add(item); } nextSets.Clear(); } for (int i = 0; i < ruleParticles.Count; i++)//Creates all possible rules with rule particles { for (int j = i; j < ruleParticles.Count; j++) { bool distinct = true; string[] a = ruleParticles[i].Split('@'); string[] b = ruleParticles[j].Split('@'); for (int k = 0; k < a.Length; k++)//checks for AB->B situation { for (int l = 0; l < b.Length; l++) { if (a[k] == b[l]) { distinct = false; break; } } if (!distinct) { break; } } if (distinct)//yoksa i -> j ve tersi olan j->i diye iki kural oluşturulur ve kurallara eklenir { rule newRule = new rule(); newRule.text = ruleParticles[i] + "->" + ruleParticles[j]; if (!Rules.Contains(newRule)) { Rules.Add(newRule); } rule reverseNewRule = new rule(); reverseNewRule.text = ruleParticles[j] + "->" + ruleParticles[i]; if (!Rules.Contains(reverseNewRule)) { Rules.Add(reverseNewRule); } } } } ruleParticles.Clear(); nextSets.Clear(); sets.Clear(); } for (int i = 0; i < Rules.Count; i++) { rule k = Rules[i]; k.support = getRuleSupport(Rules[i]);//her bir kuralın support u hesaplanır Rules[i] = k; } createOutput(Rules); }
public static void Main() { string line; char currentState; int requiredSteps; Dictionary <condition, rule> turingMachine = new Dictionary <condition, rule>(); System.IO.StreamReader file = new System.IO.StreamReader("input.txt"); line = file.ReadLine(); currentState = line[15]; //read starting state line = file.ReadLine(); requiredSteps = Int32.Parse(line.Split()[5]); //read itrartion number //read instruction set while (true) { char readState = ' '; int readValue; condition readCondition = new condition(); rule readRule = new rule(); for (int i = 0; i < 10; i++) { line = file.ReadLine(); if (line == null) { break; } if (i == 1) { readState = line.Split()[2][0]; } else if (i == 2 || i == 6) { readValue = Int32.Parse(line.Split()[7][0].ToString()); readCondition = new condition(); readCondition.state = readState; readCondition.value = readValue; } else if (i == 3 || i == 7) { readRule = new rule(); readRule.value = Int32.Parse(line.Split()[8][0].ToString()); } else if (i == 4 || i == 8) { readRule.direction = line.Split()[10].TrimEnd('.'); } else if (i == 5 || i == 9) { readRule.newState = line.Split()[8][0]; turingMachine.Add(readCondition, readRule); } } if (line == null) { break; } } int currentPosition = 0; condition currentCondition = new condition(); rule currentRule = new rule(); Dictionary <int, int> tape = new Dictionary <int, int>(); //execute turing machine instructions for (int i = 0; i < requiredSteps; i++) { //check if tape needs to be resized, probably should optimize if (!tape.ContainsKey(currentPosition)) { tape.Add(currentPosition, 0); } //find instruction to execute currentCondition.state = currentState; currentCondition.value = tape[currentPosition]; currentRule = turingMachine[currentCondition]; //execute instructions tape[currentPosition] = currentRule.value; currentState = currentRule.newState; if (currentRule.direction == "right") { currentPosition++; } else if (currentRule.direction == "left") { currentPosition--; } else { Console.WriteLine("Unexpected rule found! {0}", currentRule.direction); } } int checksum = 0; foreach (KeyValuePair <int, int> field in tape) { checksum += field.Value; } Console.WriteLine("Done! Result: {0}", checksum); }
c.ReportDiagnosticWhenActive(Diagnostic.Create(rule, Language.Syntax.InvocationIdentifier(invocation).Value.GetLocation()));
return(new EnhancedAdjustmentRule(rule, baseUtcOffset, baseUtcOffsetDelta.ToTimeSpan(), forceDaylight));
public void Run() { int __ruleIndex = 0; __res = new __MetaCnvResult <GameState>(); __res.HasValue = false; __res.Value = default(GameState); switch (__ruleIndex) { case 0: { float dt = default(float); dt = __arg0; __opDollarVector2 p = new __opDollarVector2(); p.__arg0 = 1.0f; p.__arg1 = 1.0f; __opDollarVector2 vx = new __opDollarVector2(); vx.__arg0 = 1.0f; vx.__arg1 = 0.0f; __opDollarVector2 vx1 = new __opDollarVector2(); vx1.__arg0 = -1.0f; vx1.__arg1 = 0.0f; __opDollarVector2 vy = new __opDollarVector2(); vy.__arg0 = 0.0f; vy.__arg1 = 1.0f; when s1 = new when(); __opDollar __tmp0 = new __opDollar(); __tmp0.__arg0 = "Position"; vectorx __tmp1 = new vectorx(); __tmp1.__arg0 = __tmp0; lt __tmp2 = new lt(); __tmp2.__arg0 = __tmp1; __opDollarf __tmp3 = new __opDollarf(); __tmp3.__arg0 = 30.0f; __tmp2.__arg1 = __tmp3; s1.__arg0 = __tmp2; yield s2 = new yield(); __opColon__opColon <Expr> __tmp4 = new __opColon__opColon <Expr>(); __tmp4.__arg0 = vx; __tmp4.__arg1 = new nil <Expr>(); s2.__arg0 = __tmp4; when s3 = new when(); __opDollar __tmp5 = new __opDollar(); __tmp5.__arg0 = "Position"; vectorx __tmp6 = new vectorx(); __tmp6.__arg0 = __tmp0; gt __tmp7 = new gt(); __tmp7.__arg0 = __tmp1; __opDollarf __tmp8 = new __opDollarf(); __tmp8.__arg0 = 0.0f; __tmp7.__arg1 = __tmp8; s3.__arg0 = __tmp7; yield s4 = new yield(); __opColon__opColon <Expr> __tmp9 = new __opColon__opColon <Expr>(); __tmp9.__arg0 = vx1; __tmp9.__arg1 = new nil <Expr>(); s4.__arg0 = __tmp9; yield s5 = new yield(); __opColon__opColon <Expr> __tmp10 = new __opColon__opColon <Expr>(); __opPlus __tmp11 = new __opPlus(); __opDollar __tmp12 = new __opDollar(); __opDollar __tmp13 = new __opDollar(); __tmp12.__arg0 = "Position"; __tmp13.__arg0 = "Velocity"; __tmp11.__arg0 = __tmp12; __tmp11.__arg1 = __tmp13; __tmp10.__arg0 = __tmp11; __tmp10.__arg1 = new nil <Expr>(); s5.__arg0 = __tmp10; ImmutableDictionary <string, Value> dict1 = ImmutableDictionary <string, Value> .Empty.Add("Position", p); ImmutableDictionary <string, Value> dict = dict1.Add("Velocity", vx); //r1 __opColon__opColon <string> __r1tmp0 = new __opColon__opColon <string>(); __r1tmp0.__arg0 = "Velocity"; __r1tmp0.__arg1 = new nil <string>(); __opSemicolon __r1tmp1 = new __opSemicolon(); __r1tmp1.__arg0 = s1; __r1tmp1.__arg1 = s2; rule r1 = new rule(); r1.__arg0 = __r1tmp0; r1.__arg1 = __r1tmp1; r1.__arg2 = new nop(); r1.__arg3 = ImmutableDictionary <string, Value> .Empty; r1.__arg4 = dt; //r2 __opColon__opColon <string> __r2tmp0 = new __opColon__opColon <string>(); __r2tmp0.__arg0 = "Velocity"; __r2tmp0.__arg1 = new nil <string>(); __opSemicolon __r2tmp1 = new __opSemicolon(); __r2tmp1.__arg0 = s3; __r2tmp1.__arg1 = s4; rule r2 = new rule(); r2.__arg0 = __r2tmp0; r2.__arg1 = __r2tmp1; r2.__arg2 = new nop(); r2.__arg3 = ImmutableDictionary <string, Value> .Empty; r2.__arg4 = dt; //r3 __opColon__opColon <string> __r3tmp0 = new __opColon__opColon <string>(); __r3tmp0.__arg0 = "Position"; __r3tmp0.__arg1 = new nil <string>(); rule r3 = new rule(); r3.__arg0 = __r3tmp0; r3.__arg1 = s5; r3.__arg2 = new nop(); r3.__arg3 = ImmutableDictionary <string, Value> .Empty; r3.__arg4 = dt; tick __tick = new tick(); __opColon__opColon <Rule> __ticktmp0 = new __opColon__opColon <Rule>(); __opColon__opColon <Rule> __ticktmp1 = new __opColon__opColon <Rule>(); __opColon__opColon <Rule> __ticktmp2 = new __opColon__opColon <Rule>(); __ticktmp2.__arg0 = r3; __ticktmp2.__arg1 = new nil <Rule>(); __ticktmp1.__arg0 = r2; __ticktmp1.__arg1 = __ticktmp2; __ticktmp0.__arg0 = r3; //r1; __ticktmp0.__arg1 = new nil <Rule>(); //__ticktmp1; __opColon__opColon <Rule> __ticktmp3 = new __opColon__opColon <Rule>(); __opColon__opColon <Rule> __ticktmp4 = new __opColon__opColon <Rule>(); __opColon__opColon <Rule> __ticktmp5 = new __opColon__opColon <Rule>(); __ticktmp5.__arg0 = r3; __ticktmp5.__arg1 = new nil <Rule>(); __ticktmp4.__arg0 = r2; __ticktmp4.__arg1 = __ticktmp5; __ticktmp3.__arg0 = r3; //r1; __ticktmp3.__arg1 = new nil <Rule>(); //__ticktmp4; __tick.__arg0 = __ticktmp0; __tick.__arg1 = __ticktmp3; __tick.__arg2 = dict; __tick.__arg3 = ImmutableDictionary <string, Value> .Empty; __tick.__arg4 = dt; __tick.Run(); if (!(__tick.__res.HasValue)) { goto default; } __MetaCnvResult <GameState> __restmp0 = __tick.__res; GameState __restmp1 = __restmp0.Value; __res.HasValue = true; __res.Value = __restmp1; break; } default: break; } }
c.ReportDiagnosticWhenActive(Diagnostic.Create(rule, identifier.GetLocation(), identifier.ValueText.Substring(identifier.ValueText.Length - nameEnding.Length)));
private static ReportEntry ReportIssue(rule rule, string context, string phase, assert assrt, ValidationSource validationSource) { return new ReportEntry { AssertId = assrt.id, Context = context, Phase = phase, Query = assrt.test, RuleId = rule.id, Detail = assrt.Text.Aggregate((t1, t2) => string.Format("{0} {1}", t1, t2)), ValidationSource = validationSource }; }