Ejemplo n.º 1
0
        /// <summary>
        /// Performs a database update after the database schema is updated.
        /// </summary>
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            var holder = CurrentNodeHolder.GetInstance(ObjectSpace) ?? ObjectSpace.CreateObject <CurrentNodeHolder>();

            if (holder.CurrentNode == null)
            {
                // create new replication node
                holder.CurrentNode = ObjectSpace.CreateObject <ReplicationNode>();

                var settingsNodeId = Settings.Default.CurrentReplicationNodeId;
                if (!string.IsNullOrEmpty(settingsNodeId))
                {
                    holder.CurrentNode.NodeId = settingsNodeId;
                }

                // try to get the name for a new replication node using OnInitCurrentNodeId event
                var args = new InitCurrentNodeIdArgs(holder.CurrentNode.NodeId);
                XafDeltaModule.OnInitCurrentNodeId(args);
                if (!string.IsNullOrEmpty(args.NodeId))
                {
                    holder.CurrentNode.NodeId = args.NodeId;
                }

                holder.CurrentNode.Name = args.NodeId;
            }

            ObjectSpace.CommitChanges();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Called when deleting.
 /// </summary>
 protected override void OnDeleting()
 {
     if (Equals(CurrentNodeHolder.GetInstance(Session).CurrentNode))
     {
         throw new CurrentNodeDeletionException();
     }
     base.OnDeleting();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the current node.
 /// </summary>
 /// <param name="objectSpace">The object space.</param>
 /// <returns>Current replication node</returns>
 public static ReplicationNode GetCurrentNode(IObjectSpace objectSpace)
 {
     return(CurrentNodeHolder.GetCurrentNode(objectSpace));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the current node.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <returns>Current replication node</returns>
 public static ReplicationNode GetCurrentNode(Session session)
 {
     return(CurrentNodeHolder.GetCurrentNode(session));
 }