Ejemplo n.º 1
0
            public void BuildCombinations(Dictionary <int, Rule> allRules)
            {
                if (Combinations.Any())
                {
                    return;
                }

                if (SubRules.Contains("a") || SubRules.Contains("b"))
                {
                    IsBaseRule = true;
                    Combinations.Add(SubRules);
                    return;
                }

                if (SubRules.Contains('|'))
                {
                    string[] combos = SubRules.Split('|');
                    foreach (string combo in combos)
                    {
                        BuildCombo(combo, allRules);
                    }
                }
                else
                {
                    BuildCombo(SubRules, allRules);
                }
            }
Ejemplo n.º 2
0
            public void Populate(ref List <Node> nodes, Func <string, string> GetNodeName, Action <string> printFunc)
            {
                PrintFunc = printFunc;
                string[] ruleSplit = RawRules.Split('|', StringSplitOptions.RemoveEmptyEntries);
                foreach (String curSplit in ruleSplit)
                {
                    List <string> ids = curSplit.Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList();
                    int           intTest;
                    if (!int.TryParse(ids.ElementAt(0), out intTest))
                    {
                        Value = ids.ElementAt(0);
                        continue;
                    }

                    ids = ids.Select(i => GetNodeName(i)).ToList();

                    SubRules.Add(new List <string>());
                    SubRules.Last().AddRange(ids);

                    Sequences.Add(new List <Node>());
                    foreach (string id in ids)
                    {
                        Node curNode = nodes.Where(n => n.ID == id).First();
                        Sequences.Last().Add(curNode);
                    }
                }
            }
        public virtual void AddSubRule([NotNull] EntityRule rule)
        {
            Check.NotNull(rule, nameof(rule));

            if (IsInRule(rule.Id))
            {
                return;
            }
            SubRules.Add(new EntitySubRule(Id, rule.Id, TenantId));
        }
        public virtual void RemoveSubRule([NotNull] Guid ruleId)
        {
            Check.NotNull(ruleId, nameof(ruleId));

            if (!IsInRule(ruleId))
            {
                return;
            }

            SubRules.RemoveAll(r => r.SubId == ruleId);
        }
Ejemplo n.º 5
0
 // Open "Lab" or "SubRules" file
 private void CmdOpen_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog dlg = new OpenFileDialog()) {
         dlg.CheckFileExists = true;
         dlg.CheckPathExists = true;
         dlg.Multiselect     = false;
         dlg.ValidateNames   = true;
         Src src = (Src)cbSource.SelectedIndex;
         if (src == Src.Global)
         {
             dlg.Title  = "Select default substitution file";
             dlg.Filter = "Substitution File (HML)|*.hml|All (*.*)|*.*";
         }
         else
         {
             dlg.Title  = "Select Message file";
             dlg.Filter = "Substitution File (HML)|*.hml|All (*.*)|*.*";
         }
         if (!string.IsNullOrEmpty(parent.txtMessageFolder.Text))
         {
             dlg.InitialDirectory = Path.GetDirectoryName(parent.txtMessageFolder.Text);
         }
         if (dlg.ShowDialog(parent) == DialogResult.OK)
         {
             if (src == Src.Global)
             {
                 SubRules sr = Deserialize <SubRules>(dlg.FileName);
                 if (sr != null)
                 {
                     Subs[(int)Src.Global] = sr.Substitution;
                     clearSubstitutions();
                     loadSubstitutions(Subs[(int)src]);
                 }
             }
             else
             {
                 Lab lab = Deserialize <Lab>(dlg.FileName);
                 if (lab != null)
                 {
                     Subs[(int)Src.Message] = lab.Printer[0].Substitution;
                     clearSubstitutions();
                     loadSubstitutions(Subs[(int)Src.Message]);
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
        // Time to start things going.  cbSource must happen first to load substitutions
        internal void DoSubs_Load(object sender, EventArgs e)
        {
            // Get the global list of substitution rules
            string   fileName = Path.Combine(parent.txtMessageFolder.Text, txtGlobalFileName.Text);
            SubRules sr       = Deserialize <SubRules>(fileName);

            Subs[(int)Src.Global] = sr.Substitution;

            // Get the global loaded
            cbSource.SelectedIndex    = (int)Src.Global;
            cbAttribute.SelectedIndex = (int)ccSR.Month;

            // get a message that contains substitution rules.
            fileName = Path.Combine(parent.txtMessageFolder.Text, txtMsgFileName.Text);
            Lab lab = Deserialize <Lab>(fileName);

            Subs[(int)Src.Message] = lab.Printer[0].Substitution;
        }
Ejemplo n.º 7
0
        // Serialize the Substitution Class
        internal string Serialize()
        {
            string result = string.Empty;
            Src    src    = (Src)cbSource.SelectedIndex;

            if (Subs[(int)src] != null)
            {
                if (src == Src.Global)
                {
                    SubRules sr = new SubRules()
                    {
                        Substitution = Subs[(int)src]
                    };
                    result = Serializer <SubRules> .ClassToXml(sr);
                }
                else
                {
                    // TODO Have to save it
                }
            }
            return(result);
        }
        public virtual bool IsInRule([NotNull] Guid ruleId)
        {
            Check.NotNull(ruleId, nameof(ruleId));

            return(SubRules.Any(r => r.SubId == ruleId));
        }
Ejemplo n.º 9
0
 public override string ToString()
 {
     return(this.Number.ToString() + ": " + (string.IsNullOrEmpty(this.Value) ? string.Join(" | ", SubRules.Select(s => string.Join(", ", s))) : Value));
 }