Example #1
0
        private void ProcessStep(SqlConnection conn, SqlTransaction tran, TransactionStep step)
        {
            if (step.Collection == null && step.Entity == null)
            {
                //set notification
                return;
            }

            switch (step.Type)
            {
            case StepType.PropertyChange:
                if (step.Collection == null)
                {
                    ProcessPropertyChange(step.Entity, step);
                }
                else
                {
                    step.Collection.ToList().ForEach(e => ProcessPropertyChange(e, step));
                }
                break;

            case StepType.MethodCall:
                if (step.Collection == null)
                {
                    ProcessMethodCall(step.Entity, step, conn, tran);
                }
                else
                {
                    step.Collection.ToList().ForEach(e => ProcessMethodCall(e, step, conn, tran));
                }
                break;
            }

            return;
        }
Example #2
0
        private void ProcessPropertyChange(IEntity entity, TransactionStep step)
        {
            ElementBaseData ebd = entity.__Elements.Find(e => e.Name.Equals(step.MemberName));

            if (ebd != null)
            {
                if (step.PropertyValueEntity != null)
                {
                    ElementBaseData ebdpv = step.PropertyValueEntity.__Elements.Find(e => e.Name.Equals(step.PropertyValueElementName));
                    if (ebd != null)
                    {
                        memento.Add(new Tuple <IEntity, DataProxy, object>(entity, new DataProxy((int)ebd.ID, ebd.Data), ebdpv.Data));
                        ebd.Data = ebdpv.Data;
                    }
                    else
                    {
                        //set notification
                    }
                }
                else
                {
                    memento.Add(new Tuple <IEntity, DataProxy, object>(entity, new DataProxy((int)ebd.ID, ebd.Data), step.PropertyValue));
                    ebd.Data = step.PropertyValue;
                }
            }
            else
            {
                //set notification
            }
        }
Example #3
0
        private void ProcessMethodCall(IEntity entity, TransactionStep step, SqlConnection conn, SqlTransaction tran)
        {
            Type type = entity.GetType();
            //ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes);
            //object classObject = constructor.Invoke(new object[] { });
            PropertyInfo propConn = type.GetProperty("SqlConnection", BindingFlags.Public | BindingFlags.Instance);

            propConn.SetValue(entity, conn, null);
            PropertyInfo propTran = type.GetProperty("SqlTransaction", BindingFlags.Public | BindingFlags.Instance);

            propTran.SetValue(entity, tran, null);
            MethodInfo method = type.GetMethod(step.MemberName);

            if (method != null)
            {
                method.Invoke(entity, new object[] { });
            }
            else
            {
                //set notification
            }
            propConn.SetValue(entity, null, null);
            propTran.SetValue(entity, null, null);
            PropertyInfo exceptions = type.GetProperty("Exceptions", BindingFlags.Public | BindingFlags.Instance);

            _exceptions.AddRange(exceptions.GetValue(entity, null) as List <EntityException>);
            PropertyInfo notifications = type.GetProperty("Notifications", BindingFlags.Public | BindingFlags.Instance);

            _notifications.AddRange(notifications.GetValue(entity, null) as List <Notification>);
        }