Ejemplo n.º 1
0
        internal static Guid Save(Delivery delivery)
        {
            using (var client = DeliveryDBClient.Connect())
            {
                Guid guid = delivery.Guid;

                if (guid != Guid.Empty)
                {
                    // refer here for an explanation on what's going on:
                    // http://stackoverflow.com/questions/5848990/retrieve-an-object-in-one-db4o-session-store-in-another-disconnected-scenario

                    // Get an inactive reference, get its temp ID and bind the supplied object to it instead
                    Delivery inactiveReference = DeliveryDB.Get(delivery.Guid, false, client);
                    if (inactiveReference != null)
                    {
                        long tempDb4oID = client.Ext().GetID(inactiveReference);
                        client.Ext().Bind(delivery, tempDb4oID);
                    }
                }
                else
                {
                    guid = Guid.NewGuid();
                }

                // Try to store, and return new guid on success
                client.Store(delivery);
                return(guid);
            }
        }
 public static Delivery[] GetByTargetPeriod(DateTime start, DateTime end, Channel channel = null, Account account = null)
 {
     return(DeliveryDB.GetByTargetPeriod(
                channel == null ? -1 : channel.ID,
                account == null ? -1 : account.ID,
                start,
                end));
 }
        public Delivery[] GetConflicting()
        {
            if (this.Signature == null)
            {
                throw new InvalidOperationException("The delivery does not have a signature - cannot search for conflicts.");
            }

            return(DeliveryDB.GetBySignature(this.Signature, exclude: this.DeliveryID));
        }
        public void Save()
        {
            _guid = DeliveryDB.Save(this);

            if (Saved != null)
            {
                Saved(this);
            }
        }
        /// <summary>
        /// Gets outputs that conflict with the current output by signature.
        /// </summary>
        /// <returns></returns>
        public DeliveryOutput[] GetConflicting()
        {
            DeliveryOutput[] conflicting = null;
            if (this.Signature == null)
            {
                throw new InvalidOperationException("The output does not have a signature - cannot search for conflicts.");
            }

            conflicting = DeliveryDB.GetOutputsBySignature(this.Signature, exclude: this.OutputID);
            return(conflicting);
        }
        /// <summary>
        /// Gets outputs that conflict with the current output by signature.
        /// </summary>
        /// <returns></returns>
        public DeliveryOutput[] GetConflicting()
        {
            DeliveryOutput[] conflicting = null;
            if (this.Signature == null)
            {
                throw new InvalidOperationException("The output does not have a signature - cannot search for conflicts.");
            }

            conflicting = DeliveryDB.GetOutputsBySignature(this.Signature, exclude: this.OutputID);
            if (conflicting != null)
            {
                foreach (DeliveryOutput conflict in conflicting)
                {
                    if (conflict.PipelineInstanceID != null)
                    {
                        conflict.PipelineInstanceIsRunning = DeliveryDB.GetRuning(conflict.PipelineInstanceID.Value);
                    }
                }
            }
            return(conflicting);
        }
        // Statics
        // =============================

        public static Delivery Get(Guid deliveryID, bool deep = true)
        {
            return(DeliveryDB.Get(deliveryID, deep));
        }
 public void Delete()
 {
     DeliveryDB.Delete(this);
 }
 public void Save()
 {
     this.DeliveryID = DeliveryDB.Save(this);
 }
 public void Save()
 {
     this.OutputID = DeliveryDB.SaveOutput(this);
 }
 public static DeliveryOutput Get(Guid guid)
 {
     return(DeliveryDB.GetOutput(guid));
 }
 public static DeliveryOutput[] GetByTimePeriod(DateTime timePeriodStart, DateTime timePeriodEnd, Channel channel, Account account)
 {
     return(DeliveryDB.GetOutputsByTargetPeriod(channel.ID, account.ID, timePeriodStart, timePeriodEnd));
 }
 public static Delivery Get(Guid deliveryID)
 {
     return(DeliveryDB.Get(deliveryID));
 }