Exemplo n.º 1
0
        public override void InitByDataLink(DataLink link)
        {
            base.InitByDataLink(link);

            var hasher   = System.Security.Cryptography.MD5.Create();
            var hashdata = hasher.ComputeHash(System.Text.Encoding.Default.GetBytes($"procedure_unjoin_{TriggerKey}"));

            ProcedureName = string.Concat(hashdata.Select(b => b.ToString("x2")).ToArray());

            Chain = new Chain(RootType, BasePrefix);

            GenerateCreateObjectTrigger = link.CreateObject;

            foreach (var p in link.DataLinkParameter.Cast <DataLinkParameter>().Where(p => !p.LinkField))
            {
                if (!string.IsNullOrEmpty(p.ObjectField) && string.IsNullOrEmpty(p.Expression))
                {
                    Chain.Add(p.ObjectField);

                    if (!SimpleFields.ContainsKey(p.LayerField))
                    {
                        SimpleFields.Add(p.LayerField, p.ObjectField);
                    }
                }
                else
                {
                    var expressionField = new MapExpressionField(RootType, p.LayerField, p.Expression);
                    ExpressionFields.Add(expressionField);
                    foreach (var path in expressionField.Paths)
                    {
                        Chain.Add(path);
                    }
                }
            }
        }
        /// <summary>
        /// </summary>
        public MapExpressionField(Type type, string field, string sqlExpression, string prefix = "") : base(type, prefix)
        {
            LayerField = field;
            Expression = sqlExpression;
            Paths      = new List <string>();

            var fields = new List <string>();
            var match  = Regex.Match(Expression, @"@\b(\w+\.{0,1})+\b@");

            while (match.Success)
            {
                if (!fields.Contains(match.Value))
                {
                    fields.Add(match.Value);
                }

                match = match.NextMatch();
            }

            fields.Sort((a, b) => b.Length.CompareTo(a.Length));
            foreach (var path in fields)
            {
                Chain.Add(path.Trim('@'));
                Paths.Add(path.Trim('@'));
            }
        }
Exemplo n.º 3
0
        public void Add(string layerField, string objectPath)
        {
            Chain.Add(objectPath);

            if (!LayerObjectFields.ContainsKey(layerField))
            {
                LayerObjectFields.Add(layerField, objectPath);
            }
            else
            {
                throw new Exception();
            }
        }