コード例 #1
0
ファイル: MySqlDialect.cs プロジェクト: hnjm/trancesql
        /// <inheritdoc/>
        public void Render(RenderContext context, BeginTransaction beginTransaction)
        {
            switch (beginTransaction.Isolation)
            {
            case null:
                context.Write("START TRANSACTION");
                break;

            case Isolation.Snapshot:
                context.Write("START TRANSACTION WITH CONSISTENT SNAPSHOT");
                break;

            default:
                throw new InvalidCommandException($"Unsupported isolation level '{beginTransaction.Isolation}'");
            }

            if (beginTransaction.ReadOnly.HasValue)
            {
                if (beginTransaction.Isolation != null)
                {
                    context.Write(',');
                }
                context.Write(beginTransaction.ReadOnly.Value ? " READ ONLY" : " READ WRITE");
            }
            context.Write(';');
        }
        public BeginTransaction GetBeginTransactionMethod()
        {
            BeginTransaction beginTransactionMethod = this.BeginTransactionMethod;

            if (beginTransactionMethod == null)
            {
                throw new InvalidOperationException("The configuration has not yet been used to create a CacheHandle, did you call .Build() yet?");
            }

            return(beginTransactionMethod);
        }
コード例 #3
0
ファイル: SqliteDialect.cs プロジェクト: PaulHatch/trancesql
        /// <inheritdoc/>
        public void Render(RenderContext context, BeginTransaction beginTransaction)
        {
            if (beginTransaction.Isolation != null)
            {
                throw new InvalidCommandException($"BeginTransaction.Isolation is not supported by this SQL dialect");
            }

            if (beginTransaction.ReadOnly.HasValue)
            {
                throw new InvalidCommandException($"BeginTransaction.ReadOnly is not supported by this SQL dialect");
            }

            context.Write("BEGIN TRANSACTION;");
        }
コード例 #4
0
ファイル: OracleDialect.cs プロジェクト: PaulHatch/trancesql
        /// <inheritdoc/>
        public void Render(RenderContext context, BeginTransaction beginTransaction)
        {
            if (beginTransaction.ReadOnly.HasValue)
            {
                throw new InvalidCommandException($"BeginTransaction.ReadOnly is not supported by this SQL dialect");
            }

            switch (beginTransaction.Isolation)
            {
            case null:
                context.Write("BEGIN TRANSACTION");
                break;

            case Isolation.ReadUncommitted:
                context.WriteLine("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;");
                context.Write("BEGIN TRANSACTION");
                break;

            case Isolation.ReadCommitted:
                context.WriteLine("SET TRANSACTION ISOLATION LEVEL READ COMMITTED;");
                context.Write("BEGIN TRANSACTION");
                break;

            case Isolation.RepeatableRead:
                context.WriteLine("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;");
                context.Write("BEGIN TRANSACTION");
                break;

            case Isolation.Snapshot:
                context.Write("BEGIN TRANSACTION WITH CONSISTENT SNAPSHOT;");
                break;

            case Isolation.Serializable:
                context.WriteLine("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;");
                context.Write("BEGIN TRANSACTION");
                break;

            default:
                throw new InvalidCommandException($"Unsupported isolation level '{beginTransaction.Isolation}'");
            }

            context.Write(';');
        }
コード例 #5
0
ファイル: PostgresDialect.cs プロジェクト: hnjm/trancesql
        /// <inheritdoc/>
        public void Render(RenderContext context, BeginTransaction beginTransaction)
        {
            switch (beginTransaction.Isolation)
            {
            case null:
                context.Write("BEGIN TRANSACTION");
                break;

            case Isolation.ReadUncommitted:
                context.Write("BEGIN TRANSACTION ISOLATION LEVEL READ UNCOMMITTED");
                break;

            case Isolation.ReadCommitted:
                context.Write("BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED");
                break;

            case Isolation.RepeatableRead:
                context.Write("BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ");
                break;

            case Isolation.Serializable:
                context.Write("BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE");
                break;

            default:
                throw new InvalidCommandException($"Unsupported isolation level '{beginTransaction.Isolation}'");
            }

            if (beginTransaction.ReadOnly.HasValue)
            {
                if (beginTransaction.Isolation != null)
                {
                    context.Write(',');
                }
                context.Write(beginTransaction.ReadOnly.Value ? " READ ONLY" : " READ WRITE");
            }
            context.Write(';');
        }
コード例 #6
0
        public void Dispose()
        {
            // Clearing all of these ensures that the transient APIs
            // can't be called outside of the appropriate scope.

            #region dispose-dispatcher service-apis
            _GetNuGetExePath             = null;
            _GetNuGetDllPath             = null;
            _DownloadFile                = null;
            _AddPinnedItemToTaskbar      = null;
            _RemovePinnedItemFromTaskbar = null;
            _CreateShortcutLink          = null;
            _UnzipFileIncremental        = null;
            _UnzipFile                 = null;
            _AddFileAssociation        = null;
            _RemoveFileAssociation     = null;
            _AddExplorerMenuItem       = null;
            _RemoveExplorerMenuItem    = null;
            _SetEnvironmentVariable    = null;
            _RemoveEnvironmentVariable = null;
            _AddFolderToPath           = null;
            _RemoveFolderFromPath      = null;
            _InstallMSI                = null;
            _RemoveMSI                 = null;
            _StartProcess              = null;
            _InstallVSIX               = null;
            _UninstallVSIX             = null;
            _InstallPowershellScript   = null;
            _UninstallPowershellScript = null;
            _SearchForExecutable       = null;
            _GetUserBinFolder          = null;
            _GetSystemBinFolder        = null;
            _CopyFile                = null;
            _CopyFolder              = null;
            _Delete                  = null;
            _DeleteFolder            = null;
            _CreateFolder            = null;
            _DeleteFile              = null;
            _BeginTransaction        = null;
            _AbortTransaction        = null;
            _EndTransaction          = null;
            _GenerateUninstallScript = null;
            _GetKnownFolder          = null;
            _IsElevated              = null;
            #endregion

            #region dispose-dispatcher core-apis
            _Warning          = null;
            _Message          = null;
            _Error            = null;
            _Debug            = null;
            _Verbose          = null;
            _ExceptionThrown  = null;
            _Progress         = null;
            _ProgressComplete = null;
            _GetHostDelegate  = null;
            _IsCancelled      = null;
            #endregion

            #region dispose-dispatcher request-apis
            _OkToContinue                       = null;
            _YieldPackage                       = null;
            _YieldPackageDetails                = null;
            _YieldPackageSwidtag                = null;
            _YieldSource                        = null;
            _YieldMetadataDefinition            = null;
            _YieldInstallationOptionsDefinition = null;
            #endregion

            #region dispose-dispatcher host-apis
            _GetMetadataKeys             = null;
            _GetMetadataValues           = null;
            _GetInstallationOptionKeys   = null;
            _GetInstallationOptionValues = null;
            _PackageSources   = null;
            _GetConfiguration = null;
            _ShouldContinueWithUntrustedPackageSource = null;
            _ShouldProcessPackageInstall                = null;
            _ShouldProcessPackageUninstall              = null;
            _ShouldContinueAfterPackageInstallFailure   = null;
            _ShouldContinueAfterPackageUninstallFailure = null;
            _ShouldContinueRunningInstallScript         = null;
            _ShouldContinueRunningUninstallScript       = null;
            _AskPermission = null;
            _WhatIf        = null;
            #endregion

            #region dispose-dispatcher protocol-apis
            _ProtocolGetNames        = null;
            _ProtocolIsValidSource   = null;
            _ProtocolGetItemMetadata = null;
            _ProtocolDownloadItem    = null;
            _ProtocolUnpackItem      = null;
            _InstallItem             = null;
            #endregion

            _callback = null;
        }
コード例 #7
0
 public void BeginTransaction( )
 {
     CheckDisposed();
     (_BeginTransaction ?? (_BeginTransaction = (_callback.Resolve <BeginTransaction>() ?? (() => { }))))();
 }
コード例 #8
0
        /// <summary>
        /// Initializes the Rublon 2-factor authentication transaction
        /// and returns the URL address to redirect user's browser
        /// or NULL if user's account is not protected.
        ///
        /// First, method checks the account's protection status in the Rublon server for current user.
        /// If user has protected this account, method returns the URL address.
        /// Redirect user's browser to this URL to start the Rublon authentication process.
        ///
        /// If Rublon user has deleted his Rublon account or Rublon API is not available at this time,
        /// method returns null. If so, just bypass Rublon and sign in the user.
        ///
        /// Notice: to use this method the configurations values (system token and secret key)
        /// must be provided to the constructor. If not, function will throw an exception.
        /// </summary>
        /// <param name="callbackUrl">Callback URL address.</param>
        /// <param name="userId">User's ID in local system.</param>
        /// <param name="userEmail">User's email address.</param>
        /// <param name="consumerParams">Additional transaction parameters.</param>
        /// <returns></returns>
        public string Authorize(string callbackUrl, string userId, string userEmail, JObject consumerParams)
        {
            TestConfiguration();

            if (!string.IsNullOrEmpty(this.languge))
            {
                consumerParams.Add(RublonAuthParams.FIELD_LANG, languge);
            }

            try
            {
                var beginTransaction = new BeginTransaction(this, callbackUrl, userEmail, userId, consumerParams);
                beginTransaction.Perform();
                return beginTransaction.GetWebURI();
            }
            catch (APIException.UserNotFoundException)
            {
                return null;
            }
            catch (RublonException)
            {
                throw;
            }
        }
コード例 #9
0
 internal static void OnBeginTransaction(object sender, EventArgs e)
 {
     BeginTransaction?.Invoke(sender, e);
 }