Exemplo n.º 1
0
        private static BOSequenceNumber CreateSequenceForType(string numberType)
        {
            var sequenceBOSequenceNumber = new BOSequenceNumber {
                NumberType = numberType, SequenceNumber = 0
            };

            sequenceBOSequenceNumber.Save();
            return(sequenceBOSequenceNumber);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads from a stream. Uses the given <see cref="IBusinessObjectXmlReader"/> to
        /// create the objects from the xml.
        /// Any errors that occur when setting properties on objects will be added to the ReadResult property.
        /// Once this method returns, check the Successful flag of the ReadResult to see if there are errors, and
        /// check the Message flag to see what the errors were.
        /// </summary>
        /// <param name="xmlReader">The xml reader to use</param>
        /// <param name="boReader">The <see cref="IBusinessObjectXmlReader"/> to use. This object
        /// converts the xml data into business objects, so you can control how the objects are deserialised by
        /// creating your own.</param>
        /// <returns>A <see cref="DataStoreInMemory"/> containing all objects that were in the xml</returns>
        public IEnumerable <IBusinessObject> Read(XmlReader xmlReader, IBusinessObjectXmlReader boReader)
        {
            BOSequenceNumber.LoadNumberGenClassDef();
            var objects = new List <IBusinessObject>();
            var bos     = boReader.Read(xmlReader);

            bos.ForEach(bo => objects.Add(ConfigureObjectAfterLoad(bo)));

            ReadResult = boReader.PropertyReadExceptions.Count() == 0
                 ? new Result(true)
                 : new Result(false, BuildExceptionMessage(boReader.PropertyReadExceptions));
            return(objects);
        }
Exemplo n.º 3
0
        private BOSequenceNumber LoadSequenceNumber(string numberType)
        {
            BOSequenceNumber.LoadNumberGenClassDef(_tableName);
            var criteria = new Criteria("NumberType", Criteria.ComparisonOp.Equals, numberType);
            var sequenceBOSequenceNumber =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <BOSequenceNumber>(criteria);

            if (sequenceBOSequenceNumber != null)
            {
                return(sequenceBOSequenceNumber);
            }
            sequenceBOSequenceNumber = CreateSequenceForType(numberType);
            return(sequenceBOSequenceNumber);
        }
        /// <summary>
        /// Reads from a stream. Uses the given <see cref="IBusinessObjectXmlReader"/> to
        /// create the objects from the xml.
        /// Any errors that occur when setting properties on objects will be added to the ReadResult property.
        /// Once this method returns, check the Successful flag of the ReadResult to see if there are errors, and
        /// check the Message flag to see what the errors were.
        /// </summary>
        /// <param name="xmlReader">The xml reader to use</param>
        /// <param name="boReader">The <see cref="IBusinessObjectXmlReader"/> to use. This object
        /// converts the xml data into business objects, so you can control how the objects are deserialised by
        /// creating your own.</param>
        /// <returns>A <see cref="DataStoreInMemory"/> containing all objects that were in the xml</returns>
        public DataStoreInMemory Read(XmlReader xmlReader, IBusinessObjectXmlReader boReader)
        {
            BOSequenceNumber.LoadNumberGenClassDef();
            var objects = new ConcurrentDictionary <Guid, IBusinessObject>();
            var bos     = boReader.Read(xmlReader);

            bos.ForEach(
                bo =>
            {
                var objectToAdd = ConfigureObjectAfterLoad(bo);
                objects.TryAdd(objectToAdd.ID.GetAsGuid(), objectToAdd);
            });

            ReadResult = !boReader.PropertyReadExceptions.Any() ?
                         new Result(true) :
                         new Result(false, BuildExceptionMessage(boReader.PropertyReadExceptions));
            return(new DataStoreInMemory {
                AllObjects = objects
            });
        }
Exemplo n.º 5
0
 ///<summary>
 /// Creates a number generator of the specified type. If no record is currently in the database for that type.
 /// Then this will create an entry in the table with the seed number of zero.
 ///</summary>
 ///<param name="numberType">Type of number</param>
 ///<param name="tableName">the table that the sequence number is being stored in.</param>
 public NumberGenerator(string numberType, string tableName)
 {
     _tableName = tableName;
     _boSequenceNumber = LoadSequenceNumber(numberType);
 }
Exemplo n.º 6
0
 private static BOSequenceNumber CreateSequenceForType(string numberType)
 {
     var sequenceBOSequenceNumber = new BOSequenceNumber {NumberType = numberType, SequenceNumber = 0};
     sequenceBOSequenceNumber.Save();
     return sequenceBOSequenceNumber;
 }
Exemplo n.º 7
0
 ///<summary>
 /// Creates a number generator of the specified type. If no record is currently in the database for that type.
 /// Then this will create an entry in the table with the seed number of zero.
 ///</summary>
 ///<param name="numberType">Type of number</param>
 ///<param name="tableName">the table that the sequence number is being stored in.</param>
 public NumberGenerator(string numberType, string tableName)
 {
     _tableName        = tableName;
     _boSequenceNumber = LoadSequenceNumber(numberType);
 }