public static void AddAccount(BankImportRule rule, GLCategoryEnum categoryType)
        {
            var os = rule.ObjectSpace;

            var code    = rule.RuleName;
            var op      = CriteriaOperator.Parse("[Code]=?", code);
            var account = os.FindObject <Account>(op) ?? CreateAccount(code, categoryType, os);

            rule.ToAccount = account;
            rule.ObjectSpace.ReloadObject(rule);
        }
        public static void SaveAndApplyRule(BankImport bankImport, BankImportRule rule)
        {
            try
            {
                var os = rule.ObjectSpace;
                os.CommitChanges();

                ApplyBankRule(bankImport, rule);
            }
            catch (Exception e)
            {
                throw;
            }

            bankImport.ObjectSpace.Refresh();
        }
        public static void ApplyBankRule(BankImport bankImport, BankImportRule rule)
        {
            foreach (var line in bankImport.Lines)
            {
                if (!MatchOK(line.Ref1, rule.Ref1))
                {
                    continue;
                }

                if (!MatchOK(line.Ref2, rule.Ref2))
                {
                    continue;
                }

                if (!MatchOK(line.Ref3, rule.Ref3))
                {
                    continue;
                }

                if (!MatchOK(line.Ref4, rule.Ref4))
                {
                    continue;
                }

                if (!MatchOK(line.Ref5, rule.Ref5))
                {
                    continue;
                }

                line.Account = line.ObjectSpace.GetObject(rule.ToAccount);

                if (line.Account != null)
                {
                    line.ObjectSpace.ModifiedObjects.Add(line);

                    Console.WriteLine(line.ObjectSpace.ModifiedObjects.Count);
                    line.ObjectSpace.CommitChanges();
                }
            }
        }
 public static void CopyRef5(BankImportRule rule)
 {
     rule.RuleName = rule.Ref5;
 }