Exemplo n.º 1
0
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="action">Instancia da ação.</param>
 /// <param name="result">Resultado.</param>
 /// <param name="beforeActions">Ações executadas anteriormente.</param>
 /// <param name="afterActions">Ações executadas posteriomente.</param>
 /// <param name="alternativeActions">Ações alternativas executadas.</param>
 public ExecuteAction(PersistenceAction action, PersistenceActionResult result, ExecuteAction[] beforeActions, ExecuteAction[] afterActions, ExecuteAction[] alternativeActions)
 {
     action.Require("action").NotNull();
     _action             = action;
     _result             = result;
     _beforeActions      = beforeActions;
     _afterActions       = afterActions;
     _alternativeActions = alternativeActions;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Desserializa o objeto.
        /// </summary>
        /// <param name="reader"></param>
        public void Deserialize(Serialization.IO.CompactReader reader)
        {
            ActionId       = reader.ReadInt32();
            Type           = (PersistenceActionType)reader.ReadInt32();
            EntityFullName = reader.ReadString();
            ProviderName   = reader.ReadString();
            var RowVersionString = reader.ReadString();

            if (!string.IsNullOrEmpty(RowVersionString))
            {
                RowVersion = long.Parse(RowVersionString);
            }
            else
            {
                RowVersion = null;
            }
            var parameters = new List <PersistenceParameter>();
            var count      = reader.ReadInt32();

            for (var i = 0; i < count; i++)
            {
                var parameter = new PersistenceParameter();
                ((ICompactSerializable)parameter).Deserialize(reader);
                parameters.Add(parameter);
            }
            Parameters = new PersistenceParameterCollection(parameters);
            if (reader.ReadBoolean())
            {
                var conditional = new Colosoft.Query.ConditionalContainer();
                ((ICompactSerializable)conditional).Deserialize(reader);
                this.Conditional = conditional;
            }
            var actions = new List <PersistenceAction>();

            count = reader.ReadInt32();
            for (var i = 0; i < count; i++)
            {
                var persistenceAction = new PersistenceAction();
                ((ICompactSerializable)persistenceAction).Deserialize(reader);
                actions.Add(persistenceAction);
            }
            AlternativeActions.AddRange(actions);
            var beforeActions = new List <PersistenceAction>();

            count = reader.ReadInt32();
            for (var i = 0; i < count; i++)
            {
                var persistenceAction = new PersistenceAction();
                ((ICompactSerializable)persistenceAction).Deserialize(reader);
                beforeActions.Add(persistenceAction);
            }
            BeforeActions.AddRange(beforeActions);
            var afterActions = new List <PersistenceAction>();

            count = reader.ReadInt32();
            for (var i = 0; i < count; i++)
            {
                var persistenceAction = new PersistenceAction();
                ((ICompactSerializable)persistenceAction).Deserialize(reader);
                afterActions.Add(persistenceAction);
            }
            AfterActions.AddRange(afterActions);
            if (reader.ReadBoolean())
            {
                _storedProcedureName = new Colosoft.Query.StoredProcedureName();
                ((ICompactSerializable)_storedProcedureName).Deserialize(reader);
            }
            if (reader.ReadBoolean())
            {
                var query = new Colosoft.Query.QueryInfo();
                ((ICompactSerializable)query).Deserialize(reader);
                this.Query = query;
            }
        }
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="action">Instancia da ação associada.</param>
 /// <param name="message">Mensagem do ocorrido.</param>
 public ActionValidateDetails(PersistenceAction action, IMessageFormattable message)
 {
     _action  = action;
     _message = message;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Lê os dados do XML.
        /// </summary>
        /// <param name="reader"></param>
        void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToAttribute("ActionId");
            ActionId = reader.ReadContentAsInt();
            reader.MoveToAttribute("Type");
            var typeString = reader.ReadContentAsString();

            Type = (PersistenceActionType)Enum.Parse(typeof(PersistenceActionType), typeString);
            reader.MoveToAttribute("EntityFullName");
            EntityFullName = reader.ReadContentAsString();
            reader.MoveToAttribute("ProviderName");
            ProviderName = reader.ReadContentAsString();
            reader.MoveToAttribute("RowVersion");
            var RowVersionString = reader.ReadContentAsString();

            if (!string.IsNullOrEmpty(RowVersionString))
            {
                RowVersion = long.Parse(RowVersionString);
            }
            else
            {
                RowVersion = null;
            }
            if (reader.MoveToAttribute("CommandTimeout"))
            {
                var timeout = 0;
                if (int.TryParse(reader.ReadContentAsString(), out timeout))
                {
                    CommandTimeout = timeout;
                }
            }
            reader.MoveToElement();
            reader.ReadStartElement();
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("Parameters", Namespaces.Data);
                var parameters = new List <PersistenceParameter>();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.LocalName == "Parameter")
                    {
                        var parameter = new PersistenceParameter();
                        ((System.Xml.Serialization.IXmlSerializable)parameter).ReadXml(reader);
                        parameters.Add(parameter);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                Parameters = new PersistenceParameterCollection(parameters);
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            if (!reader.IsEmptyElement)
            {
                var conditional = new Colosoft.Query.ConditionalContainer();
                ((System.Xml.Serialization.IXmlSerializable)conditional).ReadXml(reader);
                this.Conditional = conditional;
            }
            else
            {
                reader.Skip();
            }
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("AlternativeActions");
                var actions = new List <PersistenceAction>();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.LocalName == "PersistenceAction")
                    {
                        var persistenceAction = new PersistenceAction();
                        ((System.Xml.Serialization.IXmlSerializable)persistenceAction).ReadXml(reader);
                        actions.Add(persistenceAction);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                AlternativeActions.AddRange(actions);
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("BeforeActions");
                var actions = new List <PersistenceAction>();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.LocalName == "PersistenceAction")
                    {
                        var persistenceAction = new PersistenceAction();
                        ((System.Xml.Serialization.IXmlSerializable)persistenceAction).ReadXml(reader);
                        actions.Add(persistenceAction);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                BeforeActions.AddRange(actions);
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("AfterActions");
                var actions = new List <PersistenceAction>();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.LocalName == "PersistenceAction")
                    {
                        var persistenceAction = new PersistenceAction();
                        ((System.Xml.Serialization.IXmlSerializable)persistenceAction).ReadXml(reader);
                        actions.Add(persistenceAction);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                AfterActions.AddRange(actions);
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            _storedProcedureName = ReadItem <Colosoft.Query.StoredProcedureName>(reader, "StoredProcedureName");
            if (!reader.IsEmptyElement)
            {
                var query = new Colosoft.Query.QueryInfo();
                ((System.Xml.Serialization.IXmlSerializable)query).ReadXml(reader);
                this.Query = query;
            }
            else
            {
                reader.Skip();
            }
            reader.ReadEndElement();
        }
 /// <summary>
 /// Adiciona um erro para o resultado.
 /// </summary>
 /// <param name="action">Instancia da ação associada.</param>
 /// <param name="message">Mensagem do ocorrido.</param>
 public void AddError(PersistenceAction action, IMessageFormattable message)
 {
     this.Errors.Add(new ActionValidateDetails(action, message));
 }