Ejemplo n.º 1
0
 public long GetNextSequence(ITypeInfo typeInfo, string prefix)
 {
     if (typeInfo == null)
     {
         throw new ArgumentNullException("typeInfo");
     }
     return(GetNextSequence(XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary.GetClassInfo(typeInfo.Type), prefix));
 }
Ejemplo n.º 2
0
 public static void SetNextSequence(ITypeInfo typeInfo, string prefix, long nextId) {
     if (_sequenceGenerator == null)
         _sequenceGenerator = new SequenceGenerator();
     var objectByKey = _sequenceGenerator._explicitUnitOfWork.FindObject(_sequenceObjectType, GetCriteria(typeInfo.FullName,prefix), true);
     _sequenceGenerator._sequence = objectByKey != null ? (ISequenceObject)objectByKey : CreateSequenceObject(prefix + typeInfo.FullName, _sequenceGenerator._explicitUnitOfWork);
     _sequenceGenerator._sequence.NextSequence = nextId;
     _sequenceGenerator._explicitUnitOfWork.FlushChanges();
     _sequenceGenerator.Accept();
 }
Ejemplo n.º 3
0
        private static bool IsMySql(ITypeInfo typeInfo)
        {
            var sequenceObjectObjectSpaceProvider = GetSequenceObjectObjectSpaceProvider(typeInfo.Type);

            if (sequenceObjectObjectSpaceProvider != null)
            {
                var    helper       = new ConnectionStringParser(sequenceObjectObjectSpaceProvider.ConnectionString);
                string providerType = helper.GetPartByName(DataStoreBase.XpoProviderTypeParameterName);
                return(providerType == MySqlConnectionProvider.XpoProviderTypeString);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public static void SetNextSequence(ITypeInfo typeInfo, string prefix, long nextId)
        {
            if (_sequenceGenerator == null)
            {
                _sequenceGenerator = new SequenceGenerator();
            }
            var objectByKey = _sequenceGenerator._explicitUnitOfWork.FindObject(_sequenceObjectType, GetCriteria(typeInfo.FullName, prefix), true);

            _sequenceGenerator._sequence = objectByKey != null ? (ISequenceObject)objectByKey : CreateSequenceObject(prefix + typeInfo.FullName, _sequenceGenerator._explicitUnitOfWork);
            _sequenceGenerator._sequence.NextSequence = nextId;
            _sequenceGenerator._explicitUnitOfWork.FlushChanges();
            _sequenceGenerator.Accept();
        }
Ejemplo n.º 5
0
 public static void SetNextSequence(ITypeInfo typeInfo, long nextId)
 {
     SetNextSequence(typeInfo, null, nextId);
 }
Ejemplo n.º 6
0
        public static void GenerateSequence(ISupportSequenceObject supportSequenceObject, ITypeInfo typeInfo)
        {
            if (_defaultDataLayer == null)
            {
                return;
            }
            if (supportSequenceObject.Session is NestedUnitOfWork ||
                !supportSequenceObject.Session.IsNewObject(supportSequenceObject))
            {
                return;
            }
            if (_sequenceGenerator == null)
            {
                _sequenceGenerator = new SequenceGenerator();
            }
            long    nextSequence = _sequenceGenerator.GetNextSequence(typeInfo, supportSequenceObject.Prefix);
            Session session      = supportSequenceObject.Session;

            if (IsNotNestedUnitOfWork(session))
            {
                SessionManipulationEventHandler[] sessionOnAfterCommitTransaction = { null };
                sessionOnAfterCommitTransaction[0] = (sender, args) => {
                    if (_sequenceGenerator != null)
                    {
                        try {
                            _sequenceGenerator.Accept();
                        }
                        finally {
                            session.AfterCommitTransaction -= sessionOnAfterCommitTransaction[0];
                        }
                    }
                };
                session.AfterCommitTransaction += sessionOnAfterCommitTransaction[0];
            }
            supportSequenceObject.Sequence = nextSequence;
        }
Ejemplo n.º 7
0
        public static long GetNowSequence(ITypeInfo typeInfo)
        {
            var xpClassInfo = XpandModuleBase.Dictiorary.GetClassInfo(typeInfo.Type);

            return(GetNowSequence(xpClassInfo, null));
        }
Ejemplo n.º 8
0
 public long GetNextSequence(ITypeInfo typeInfo)
 {
     return(GetNextSequence(typeInfo, null));
 }
Ejemplo n.º 9
0
 public long GetNextSequence(ITypeInfo typeInfo) {
     return GetNextSequence(typeInfo, null);
 }
Ejemplo n.º 10
0
 public long GetNextSequence(ITypeInfo typeInfo, string prefix) {
     if (typeInfo == null)
         throw new ArgumentNullException("typeInfo");
     return GetNextSequence(XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary.GetClassInfo(typeInfo.Type), prefix);
 }
Ejemplo n.º 11
0
 public static void SetNextSequence(ITypeInfo typeInfo, long nextId) {
     SetNextSequence(typeInfo, null, nextId);
 }
Ejemplo n.º 12
0
 private static bool IsMySql(ITypeInfo typeInfo) {
     var sequenceObjectObjectSpaceProvider = GetSequenceObjectObjectSpaceProvider(typeInfo.Type);
     if (sequenceObjectObjectSpaceProvider != null) {
         var helper = new ConnectionStringParser(sequenceObjectObjectSpaceProvider.ConnectionString);
         string providerType = helper.GetPartByName(DataStoreBase.XpoProviderTypeParameterName);
         return providerType == MySqlConnectionProvider.XpoProviderTypeString;
     }
     return false;
 }
Ejemplo n.º 13
0
        public static void GenerateSequence(ISupportSequenceObject supportSequenceObject, ITypeInfo typeInfo) {
            if (_defaultDataLayer == null)
                return;
            if (supportSequenceObject.Session is NestedUnitOfWork ||
                !supportSequenceObject.Session.IsNewObject(supportSequenceObject))
                return;
            if (_sequenceGenerator == null)
                _sequenceGenerator = new SequenceGenerator();
            long nextSequence = _sequenceGenerator.GetNextSequence(typeInfo, supportSequenceObject.Prefix);
            Session session = supportSequenceObject.Session;
            if (IsNotNestedUnitOfWork(session)) {
                SessionManipulationEventHandler[] sessionOnAfterCommitTransaction = { null };
                sessionOnAfterCommitTransaction[0] = (sender, args) => {
                    if (_sequenceGenerator != null) {
                        try {
                            _sequenceGenerator.Accept();
                        }
                        finally {
                            session.AfterCommitTransaction -= sessionOnAfterCommitTransaction[0];
                        }
                    }

                };
                session.AfterCommitTransaction += sessionOnAfterCommitTransaction[0];
            }
            supportSequenceObject.Sequence = nextSequence;
        }
Ejemplo n.º 14
0
 public static long GetNowSequence(ITypeInfo typeInfo){
     var xpClassInfo = XpandModuleBase.Dictiorary.GetClassInfo(typeInfo.Type);
     return GetNowSequence(xpClassInfo,null);
 }