예제 #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));
 }
예제 #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();
 }
예제 #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);
        }
예제 #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();
        }
예제 #5
0
 public static void SetNextSequence(ITypeInfo typeInfo, long nextId)
 {
     SetNextSequence(typeInfo, null, nextId);
 }
예제 #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;
        }
예제 #7
0
        public static long GetNowSequence(ITypeInfo typeInfo)
        {
            var xpClassInfo = XpandModuleBase.Dictiorary.GetClassInfo(typeInfo.Type);

            return(GetNowSequence(xpClassInfo, null));
        }
예제 #8
0
 public long GetNextSequence(ITypeInfo typeInfo)
 {
     return(GetNextSequence(typeInfo, null));
 }
예제 #9
0
 public long GetNextSequence(ITypeInfo typeInfo) {
     return GetNextSequence(typeInfo, null);
 }
예제 #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);
 }
예제 #11
0
 public static void SetNextSequence(ITypeInfo typeInfo, long nextId) {
     SetNextSequence(typeInfo, null, nextId);
 }
예제 #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;
 }
예제 #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;
        }
예제 #14
0
 public static long GetNowSequence(ITypeInfo typeInfo){
     var xpClassInfo = XpandModuleBase.Dictiorary.GetClassInfo(typeInfo.Type);
     return GetNowSequence(xpClassInfo,null);
 }