Exemplo n.º 1
0
        /// <summary>
        /// 根据读取的rule字符构建成一个Rule对象
        /// </summary>
        /// <param name="theRuleName">rule的名字</param>
        /// <param name="theRuleStrings">rule的字符串</param>
        private static TransferRule CalculateRules(string theRuleName, string theRuleStrings)
        {
            TransferRule tr = new TransferRule();

            tr.RuleName = theRuleName;

            Regex           rules           = new Regex(@"(?<DbName>\w+):(\[(?<TableName>\w+)\(?(?<FilterRule>\w*)\)?\])+");
            MatchCollection matchCollection = rules.Matches(theRuleStrings);

            foreach (Match aMatch in matchCollection)
            {
                //确定数据库
                Utility.AssertAreSame(1, aMatch.Groups["DbName"].Captures.Count, DbErrorString(theRuleName));
                DbTransfer dt = new DbTransfer();
                dt.DbName = aMatch.Groups["DbName"].Captures[0].Value;
                //确定表
                Utility.AssertAreSame(aMatch.Groups["TableName"].Captures.Count, aMatch.Groups["FilterRule"].Captures.Count, TableErrorString(theRuleName));
                for (int i = 0; i < aMatch.Groups["TableName"].Captures.Count; i++)
                {
                    TableTransfer tt = new TableTransfer();
                    tt.TableName       = aMatch.Groups["TableName"].Captures[i].Value;
                    tt.TableFilterName = aMatch.Groups["FilterRule"].Captures[i].Value;
                    dt.AddTransferTable(tt);
                }
                tr.DbsToTransfer.Add(dt);
            }
            return(tr);
        }
Exemplo n.º 2
0
        public object Clone()
        {
            DbTransfer aColoneObj = new DbTransfer();

            aColoneObj._DbName = _DbName;
            foreach (string protectTableName in _ProtectTableNames)
            {
                aColoneObj._ProtectTableNames.Add(protectTableName);
            }
            foreach (TableTransfer tt in _TablesToTransfer)
            {
                aColoneObj._TablesToTransfer.Add(tt.Clone() as TableTransfer);
            }
            return(aColoneObj);
        }
Exemplo n.º 3
0
        public void ConfigTheFilter(TransferRule theRule, string mainTableName, string orginDbName, string orginCopyDbName, string restoreDbName, string forRestoreCopyDbName)
        {
            _MainTable            = mainTableName;
            _TheRule              = theRule;
            _OrginDbName          = orginDbName;
            _OrginCopyDbName      = orginCopyDbName;
            _RestoreDbName        = restoreDbName;
            _ForRestoreCopyDbName = forRestoreCopyDbName;

            DbTransfer theDt = theRule.FindDbTransferByName(orginDbName);

            foreach (KeyValuePair <string, string> theColumnn in DefineProtectedTableFkColumnName())
            {
                theDt.AddProtectTable(theColumnn.Key);
            }

            AfterConfigTheFilter(theRule, orginDbName, orginCopyDbName, restoreDbName, forRestoreCopyDbName);
        }