private void SendSubstitution(Substitution s, string delimiter)
 {
     for (int i = 0; i < s.SubRule.Length; i++)
     {
         SubstitutionRule r = s.SubRule[i];
         if (Enum.TryParse(r.Type, true, out ccSR type))
         {
             SetSubValues(type, r, delimiter);
         }
         else
         {
             LogIt($"Unknown substitution rule type =>{r.Type}<=");
         }
     }
 }
        public Attributes(Browser parent, EIP EIP, TabPage tab, ClassCode cc, int Extras = 0)
        {
            this.parent      = parent;
            this.EIP         = EIP;
            this.tab         = tab;
            this.cc          = cc;
            this.ccAttribute = ((t1[])typeof(t1).GetEnumValues()).Select(x => Convert.ToByte(x)).ToArray();
            this.Extras      = Extras;

            extrasUsed = AddExtraControls();

            BuildControls();

            // Substitution has extra controls
            if (cc == ClassCode.Substitution_rules)
            {
                // Assumes only one extra control
                Substitution = new Substitution(parent, EIP, tab);
                Substitution.BuildControls();
            }

            // UserPattern has extra controls
            if (cc == ClassCode.User_pattern)
            {
                UserPattern = new UserPattern(parent, EIP, tab);
                UserPattern.BuildControls();
            }

            // IJP operation has extra controls
            if (cc == ClassCode.IJP_operation)
            {
                Errors = new Errors(parent, EIP, tab);
                Errors.BuildControls();
            }

            // Print data management has extra controls
            if (cc == ClassCode.Print_data_management)
            {
                PrintManagement = new PrintManagement(parent, EIP, tab);
                PrintManagement.BuildControls();
            }
        }
        private Substitution RetrieveSubstitutions(Msg m)
        {
            bool needYear      = false;
            bool needMonth     = false;
            bool needDay       = false;
            bool needHour      = false;
            bool needMinute    = false;
            bool needWeek      = false;
            bool needDayOfWeek = false;

            for (int c = 0; c < m.Column.Length; c++)
            {
                Column col = m.Column[c];
                for (int r = 0; r < col.Item.Length; r++)
                {
                    Item item = col.Item[r];
                    if (item.Date != null)
                    {
                        for (int i = 0; i < item.Date.Length; i++)
                        {
                            Substitute sub = item.Date[i].Substitute;
                            if (sub != null)
                            {
                                needYear      |= sub.Year != ED.Disable;
                                needMonth     |= sub.Month != ED.Disable;
                                needDay       |= sub.Day != ED.Disable;
                                needHour      |= sub.Hour != ED.Disable;
                                needMinute    |= sub.Minute != ED.Disable;
                                needDayOfWeek |= sub.DayOfWeek != ED.Disable;
                                needWeek      |= sub.Week != ED.Disable;
                            }
                        }
                    }
                }
            }

            List <SubstitutionRule> sr = new List <SubstitutionRule>();

            if (needYear)
            {
                RetrieveSubstitution(sr, ccSR.Year);
            }
            if (needMonth)
            {
                RetrieveSubstitution(sr, ccSR.Month);
            }
            if (needDay)
            {
                RetrieveSubstitution(sr, ccSR.Day);
            }
            if (needHour)
            {
                RetrieveSubstitution(sr, ccSR.Hour);
            }
            if (needMinute)
            {
                RetrieveSubstitution(sr, ccSR.Minute);
            }
            if (needWeek)
            {
                RetrieveSubstitution(sr, ccSR.Week);
            }
            if (needDayOfWeek)
            {
                RetrieveSubstitution(sr, ccSR.DayOfWeek);
            }
            Substitution substitution = new Substitution()
            {
                Delimiter  = "/",
                StartYear  = GetDecAttribute(ccSR.Start_Year),
                RuleNumber = 1,
                SubRule    = sr.ToArray()
            };

            return(substitution);
        }