示例#1
0
        private void SafeEndTransaction(TransactionInfo transInfo, bool commit, bool toFreeResources, out CloseConnectionTransactionException closeConnectionException)
        {
            closeConnectionException = null;
            try {
#if DEBUG_DBCONNECTIONPOOLING
                OSTrace.Error("DBConnectionPooling[TID=" + transInfo.Transaction.GetHashCode() + "] - returned to pool");
                OSTrace.Error(new StackTrace().ToString());
#endif
                EndTransaction(transInfo, commit, toFreeResources);
            } catch (InvalidOperationException e) {
                //Do not collect exception in case of invalid operation exception.
                // End transaction throws this exception if connection is already commited and we don't want to throw that to client
#if DEBUG_DBCONNECTIONPOOLING
                OSTrace.Error("DBConnectionPooling[TID=" + transInfo.Transaction.GetHashCode() + "]");
                OSTrace.Error(new StackTrace().ToString());
#endif
                EventLogger.WriteError(String.Format("Error closing the transaction to the database: {0}\n{1}\n{2}", e.Message, e.StackTrace,
                                                     new StackTrace(true)));
            } catch (Exception e) {
#if DEBUG_DBCONNECTIONPOOLING
                OSTrace.Error("DBConnectionPooling[TID=" + transInfo.Transaction.GetHashCode() + "]");
                OSTrace.Error(new StackTrace().ToString());
#endif
                //collect here exception, so it can be bubbled up and thrown if needed
                closeConnectionException = new CloseConnectionTransactionException("Error closing the transaction to the database", e);
                EventLogger.WriteError(String.Format("Error closing the transaction to the database: {0}\n{1}\n{2}", e.Message, e.StackTrace,
                                                     new StackTrace(true)));
            }
        }
示例#2
0
        protected TransactionInfo AddToPoolAndReserve()
        {
            lock (this) {
                TransactionInfo transInfo = null;
                while (transInfo == null)
                {
                    transInfo = BuildTransactionInfo();
                    transInfo.Reserve();

                    //drivers doesn't ensure connection is good so make sure
                    if (transInfo.Transaction.Connection == null || transInfo.Transaction.Connection.State == ConnectionState.Closed)
                    {
                        if (transInfo.Transaction.Connection != null)
                        {
                            transInfo.ReturnConnectionToPool();
                        }
                        LogException(new InvalidTransactionException("Connection in transaction is null."), new StackTrace(), "Releasing connection pools and retrying");
                        transInfo = null; // retry;
                        TransactionService.ReleasePooledConnections("Connection in transaction is null.");
                        Thread.Sleep(TransactionServiceConstants.RETRY_CONNECTION_TIME);
                    }
                }

#if DEBUG_DBCONNECTIONPOOLING
                OSTrace.Info("DBConnectionPooling[TID=" + transInfo.Transaction.GetHashCode() + "] - reserved from pool");
                OSTrace.Error(new StackTrace().ToString());
#endif
                TransactionPool.Add(transInfo.Transaction, transInfo);
                return(transInfo);
            }
        }
        protected StaticRecordMetadata GetRecordMetadataByKey(ObjectKey key)
        {
            StaticRecordMetadata record;

            if (!RecordsMetaByKey.TryGetValue(key, out record) || record == null || !record.Valid)
            {
                record = newStaticRecord();

                using (Transaction systemTransaction = DatabaseAccess.ForSystemDatabase.GetReadOnlyTransaction()) {
                    using (IDataReader reader = DBRuntimePlatform.Instance.GetStaticRecordBykey(systemTransaction, key, EntityKey, EspaceId)) {
                        if (reader.Read())
                        {
                            record.Read(reader);
                            AddToMetadataCache(record);
                        }
                        else
                        {
                            //Not found on db so we can return a empty record
                            OSTrace.Error("GetRecordMetadataByKey(Key=" + ObjectKeyUtils.DatabaseValue(key) +
                                          ", EntityKey=" + ObjectKeyUtils.DatabaseValue(EntityKey) +
                                          ", EspaceId=" + EspaceId + ") found no metadata!");
                        }
                    }
                }
            }
            return(record);
        }
        public static List <IPAddress> DnsLookup(string address)
        {
            IPAddress[] ip_list = null;

            try {
                ip_list = Dns.GetHostEntry(address).AddressList;
            } catch (Exception e) {
                OSTrace.Error("Dns Lookup", e);
            }

            if (ip_list != null && ip_list.Length > 0)
            {
                return(ip_list.ToList());
            }

            // Dns.GetHostEntry performs a more thorough lookup (reverse dns lookup in addition to the forward dns lookup)
            // which will fail to retrieve the ip address in some scenarios where the GetHostAddresses will succeed.

            try {
                ip_list = Dns.GetHostAddresses(address);
            } catch (Exception e) {
                OSTrace.Error("Dns Lookup Extended", e);
            }

            if (ip_list != null && ip_list.Length > 0)
            {
                return(ip_list.ToList());
            }

            throw new Exception("Unable to resolve address:" + address);
        }
示例#5
0
        /// <summary>
        /// Aborts a transaction and releases it.
        /// </summary>
        /// <param name="trans">Transaction to be aborted.</param>
        public void AbortTransaction(IDbTransaction trans)
        {
            if (trans == null)
            {
                return;
            }

            bool            isRequestTransaction;
            TransactionInfo transInfo = GetTransactionInfo(trans, out isRequestTransaction);

            if (transInfo != null)
            {
#if DEBUG_DBCONNECTIONPOOLING
                OSTrace.Info("DBConnectionPooling[TID=" + transInfo.Transaction.GetHashCode() + "] - returned to pool");
                OSTrace.Error(new StackTrace().ToString());
#endif

                transInfo.Release();

                if (isRequestTransaction)
                {
                    RequestTransactionInfo = null;
                }
                else
                {
                    TransactionPool.Remove(transInfo.Transaction);
                }

                transInfo.ReturnConnectionToPool();
            }
        }
        public static bool IsLoopbackAddress(string hostnameOrIp)
        {
            hostnameOrIp = RemoveScopeIdFromIp(hostnameOrIp).Trim().ToLower();

            string internalAddress;

            if (HttpContext.Current == null)
            {
                // Can't cache this in services because settings change as diferent sandboxes are served
                internalAddress = RuntimePlatformSettings.Misc.InternalAddress.GetValue();
            }
            else
            {
                if (cachedInternalAddress == null)
                {
                    internalAddress = cachedInternalAddress = RuntimePlatformSettings.Misc.InternalAddress.GetValue();
                }
                else
                {
                    internalAddress = cachedInternalAddress;
                }
            }
            var toRetrun = hostnameOrIp.IsOneOf("127.0.0.1", "::1", "localhost", internalAddress);

            OSTrace.Debug("IsLoopbackAddress - hostnameOrIp: " + hostnameOrIp + " - internalAddress: " + internalAddress + " result: " + toRetrun);
            return(toRetrun);
        }
示例#7
0
    internal static string MD5HashWithPrivateSalt(string str)
    {
        var toReturn = MD5PasswordHelper.HexDeriveUsingUTF16(str, SharedKeys.PrivateSalt());

        OSTrace.Debug("MD5HashWithPrivateSalt returned:" + toReturn);
        return(toReturn);
    }
        static IEnumerable <IPlatformTableSourceColumnInfo> TryGetColumnsFromExpression(string indexName, string columnExpression, IEnumerable <IPlatformTableSourceColumnInfo> columns)
        {
            var setOfColumns = new HashSet <IPlatformTableSourceColumnInfo>();

            try {
                var matches = ColumnNameRegex.Matches(columnExpression);
                foreach (Match match in matches)
                {
                    // Second group matches the capturing group in the regex above (first group matches the whole regex).
                    var column = columns.SingleOrDefault(c => c.Name.EqualsIgnoreCase(match.Groups[1].Value));
                    if (column != null)
                    {
                        // Workaround for yield return inside try-catch block.
                        setOfColumns.Add(column);
                    }
                    else
                    {
                        OSTrace.Info("Unable to find a column in index {0} with expression {1}".F(indexName, columnExpression));
                    }
                }
            } catch (Exception e) {
                // No need to propagete the exception. Just tolerate the error and proceed.
                // The result is a possible inconsistency warning while publishing.
                OSTrace.Error("Error while parsing index {0} with expression {1}".F(indexName, columnExpression), e);
            }
            return(setOfColumns.AsEnumerable());
        }
示例#9
0
        protected void SetContextInfo(HeContext heContext, SecurityTokenAPI.RequestSecurityTokenPayload authorizationPayload)
        {
            try {
                if (authorizationPayload.TenantId != 0)
                {
                    heContext.Session.TenantId = authorizationPayload.TenantId;
                }
                if (authorizationPayload.UserId != 0)
                {
                    heContext.Session.UserId = authorizationPayload.UserId;
                }
            } catch (Exception e) {
                OSTrace.Warning("Invalid authentication information.", e);
            }

            if (Request.Content.Headers.TryGetValues("Content-Language", out var headerValues))
            {
                string locale = headerValues.First();
                if (!string.IsNullOrWhiteSpace(locale))
                {
                    GenericExtendedActions.SetCurrentLocale(heContext, locale);
                }
            }
            else
            {
                OSTrace.Warning("Locale information missing from the request.");
            }
        }
示例#10
0
        public static void InitializeRunningInfo()
        {
            if (initialized)
            {
                return;
            }

            lock (typeof(RunningInfo)) {
                if (initialized)
                {
                    return;
                }

                AppInfo appInfo = AppInfo.GetAppInfo();
                if (appInfo == null)
                {
                    InitializingErrorMessage = "AppInfo is null";
                    return;
                }

                try {
                    using (Transaction tran = DatabaseAccess.ForSystemDatabase.GetCommitableTransaction()) {
                        EspaceName = appInfo.eSpaceName;
                        PAName     = appInfo.PtaName;
                        PAUserName = appInfo.PtaUserName;
                        tenantId   = appInfo.Tenant.Id;

                        espaceId = DBRuntimePlatform.Instance.GetEspaceId(tran, EspaceName);
                        if (espaceId == 0)
                        {
                            initialized = false;
                        }

                        if (PAName == "")
                        {
                            PAName = null;
                        }

                        if (PAUserName == "")
                        {
                            PAUserName = null;
                        }
                        else if (PAUserName != null)
                        {
                            int scTenantId = DBRuntimePlatform.Instance.GetTenantIdByName(tran, Constants.ServiceCenterName, Constants.ServiceCenterName);
                            userId = DBRuntimePlatform.Instance.GetUserId(tran, scTenantId, PAUserName);
                        }
                    }
                } catch (Exception e) {
                    initialized = false;
                    InitializingErrorMessage = "An exception ocurred during RunningInfo initialization: " + e.Message;
                    Log.ErrorLog.LogApplicationError(InitializingErrorMessage, e.StackTrace, null, "InitializeRunningInfo");
                    OSTrace.Error(InitializingErrorMessage, e);
                    throw;
                }

                initialized = true;
            }
        }
        public DatabasePluginProvider(IEnumerable <DirectoryInfo> plugins)
        {
            pluginDirectories = plugins;

            LoadPlugins((e, s) => {
                OSTrace.Info(s, e);
            });
        }
示例#12
0
 protected void LogException(Exception e, string additionalMessage)
 {
     try {
         OSTrace.Error((e != null ? e.Message : "") + Environment.NewLine + additionalMessage +
                       (e != null && e.StackTrace != null ? e.StackTrace : ""));
     } catch {
     }
 }
 /// <summary>
 /// Executes a command and returns the value of the first column of the first row in the resultset returned by the query.
 /// This implementation logs exceptions.
 /// </summary>
 /// <param name="cmd">The command to execute.</param>
 /// <returns>An object with the resulting first row and first column of the query defined in the query command.</returns>
 public virtual object ExecuteScalar(IDbCommand cmd)
 {
     try {
         return(cmd.ExecuteScalar());
     } catch (DbException e) {
         OSTrace.Error("Error executing ExecuteScalar (" + e.Message + ") with statement:" + Environment.NewLine + cmd.CommandText);
         throw;
     }
 }
示例#14
0
 public override IDataReader ExecuteReader(IDbCommand cmd)
 {
     try {
         return(new SQLServerDataReaderWrapper((SqlDataReader)cmd.ExecuteReader(), this));
     } catch (DbException e) {
         OSTrace.Error("Error executing ExecuteReader (" + e.Message + ") with statement:" + Environment.NewLine + cmd.CommandText);
         throw;
     }
 }
示例#15
0
 /// <summary>
 /// Logs an error with information about the exception, the stack trace and a message.
 /// </summary>
 /// <param name="e">Exception to log.</param>
 /// <param name="additionalStack">Stack trace to add to the log.</param>
 /// <param name="additionalMessage">Message to add to the log.</param>
 protected void LogException(Exception e, StackTrace additionalStack, string additionalMessage)
 {
     try {
         String additionalStackString = (additionalStack != null ? additionalStack.ToString() : "");
         OSTrace.Error((e != null ? e.Message : "") + Environment.NewLine + additionalMessage +
                       (e != null && e.StackTrace != null ? e.StackTrace.ToString() + (String.IsNullOrEmpty(additionalStackString) ? "" : "\n" + additionalStackString) : additionalStackString));
     } catch {
     }
 }
示例#16
0
        protected IEnumerable <ITableSourceForeignKeyInfo> GetForeignKeys_Old(IEnumerable <CacheTableSourceInfo> tableSources)
        {
            string paramPrefix = DatabaseServices.ExecutionService.ParameterPrefix;
            string tableNames  = "";

            try {
                tableNames = "'" + tableSources.Select(t => t.Name).StrCat("','") + "'";
                IList <ITableSourceForeignKeyInfo> foreignKeys = new List <ITableSourceForeignKeyInfo>();
                //on mysql table_schema always equal to constraint_schema so we can shortcut to optimize
                string query = string.Format(@"SELECT t.TABLE_NAME, 
                                                      c.CONSTRAINT_NAME, c.COLUMN_NAME, c.REFERENCED_TABLE_NAME, c.REFERENCED_COLUMN_NAME, 
                                                      r.DELETE_RULE
                                               FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE c
                                                 INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS t ON c.CONSTRAINT_NAME = t.CONSTRAINT_NAME 
                                                 INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS r ON r.CONSTRAINT_NAME = t.CONSTRAINT_NAME
                                               WHERE t.CONSTRAINT_TYPE = 'FOREIGN KEY' 
                                                 AND t.TABLE_SCHEMA = {0} 
                                                 AND c.CONSTRAINT_SCHEMA = {0} 
                                                 AND r.CONSTRAINT_SCHEMA = {0} 
                                                 AND t.TABLE_NAME  IN (" + tableNames + @")", paramPrefix + "schema");

                using (IDbConnection conn = DatabaseServices.TransactionService.CreateConnection()) {
                    IDbCommand cmd = DatabaseServices.ExecutionService.CreateCommand(conn, query);
                    //----------------- Caché --------------------
                    // Caché does not look at the parameter name, it assigns parameters in the order they appear, one per question mark "?"
                    // So the above query expects 3 parameters, although it is the same Caché expects 3, so add 3 parameters.
                    DatabaseServices.ExecutionService.CreateParameter(cmd, paramPrefix + "schema", DbType.String, tableSources.First().Database.Name);
                    cmd.CommandTimeout = QueryTimeout;
                    using (IDataReader reader = cmd.ExecuteReader()) {
                        while (reader.Read())
                        {
                            string tableName            = (string)reader["TABLE_NAME"];
                            string foreignKeyName       = (string)reader["CONSTRAINT_NAME"];
                            string columnName           = (string)reader["COLUMN_NAME"];
                            string referencedColumnName = (string)reader["REFERENCED_COLUMN_NAME"];
                            string referencedTableName  = (string)reader["REFERENCED_TABLE_NAME"];
                            bool   isCascadeDelete      = "CASCADE".EqualsIgnoreCase((string)reader["DELETE_RULE"]);

                            CacheTableSourceInfo tableSource = tableSources.First(t => t.Name.EqualsIgnoreCase(tableName));

                            string                     qualifiedReferencedTableName = GetQualifiedIdentifier(tableSource.Database.Name, referencedTableName);
                            ITableSourceInfo           referencedTableSource        = new CacheTableSourceInfo(DatabaseServices, tableSource.Database, referencedTableName, qualifiedReferencedTableName);
                            ITableSourceForeignKeyInfo foreignKeyInfo = new CacheTableSourceForeignKeyInfo(tableSource, foreignKeyName, columnName, referencedTableSource, referencedColumnName, isCascadeDelete);
                            foreignKeys.Add(foreignKeyInfo);
                        }
                    }


                    return(foreignKeys);
                }
            }
            catch (Exception e) {
                OSTrace.Error(string.Format("Failed to retrieve foreign key information from database. Tables: {0}", tableNames), e);
                return(new List <ITableSourceForeignKeyInfo>());
            }
        }
        private static bool IsResponsePayloadValid(string responseString, ResponseSecurityTokenPayload authorizationPayload)
        {
            bool isResponseValid = SecurityTokenAPI.ValidatePayloadHash(RuntimeSettingsProvider.Instance, responseString, authorizationPayload.ResponseHash);

            if (!isResponseValid)
            {
                OSTrace.Error("Response hash doesn't match the response. Response may have been tampered with.");
            }
            return(isResponseValid);
        }
 /// <summary>
 /// Executes a command and returns the number of affected rows.
 /// This implementation does not use the <code>isApplication</code> flag, and logs exceptions.
 /// </summary>
 /// <param name="cmd">The command to execute.</param>
 /// <returns>The number of rows affected.</returns>
 public override int ExecuteNonQuery(IDbCommand cmd)
 {
     try {
         return(cmd.ExecuteNonQuery());
     }
     catch (DbException e) {
         OSTrace.Error("Error executing ExecuteNonQuery (" + e.Message + ") with statement:" + Environment.NewLine + cmd.CommandText);
         throw;
     }
 }
示例#19
0
        private bool ValidateProducerKey(string requestProducerKey, string eSpaceProducerKey)
        {
            bool isProducerKeyValid = requestProducerKey == eSpaceProducerKey;

            if (!isProducerKeyValid)
            {
                OSTrace.Error($"Producer Module keys don't match. Expected '{eSpaceProducerKey}' but was '{requestProducerKey}'");
            }
            return(isProducerKeyValid);
        }
 public void ClearCache()
 {
     OSTrace.Debug("StaticEntityRuntime.ClearCache: Clearing cache for " + ObjectKeyUtils.DatabaseValue(EntityKey) + ".");
     _recordsMetaByName.Clear();
     _recordsMetaByKey.Clear();
     foreach (Hashtable recordsById in _recordsByIdByLocale.Values)
     {
         recordsById.Clear();
     }
 }
        public static string Invoke(string sharePath, string eSpaceName, string ptaName, string action, string[] parameters, out string result, out string exception)
        {
            AppDomain domain = null;

            try {
                string partialPath    = sharePath + FileSystemUtils.PathSeparator + "partial" + FileSystemUtils.PathSeparator + ptaName;
                string partialBinPath = partialPath + FileSystemUtils.PathSeparator + "bin";
                string fullBinPath    = sharePath + FileSystemUtils.PathSeparator + "full" + FileSystemUtils.PathSeparator + "bin";
                if (!Directory.Exists(partialBinPath))   // no run has been done yet
                {
                    Directory.CreateDirectory(partialBinPath);
                    var dllsToCopy = new string[] {
                        Path.GetFileName(Settings.Get(Settings.Configs.CompilerService_RuntimeCommon)),
                        Path.GetFileName(Settings.Get(Settings.Configs.CompilerService_RuntimePlatform)),
                        Path.GetFileName(Settings.Get(Settings.Configs.CompilerService_Auditing)),
                        Path.GetFileName(Settings.Get(Settings.Configs.CompilerService_DatabaseAbstractionLayer)),
                        Path.GetFileName(Settings.Get(Settings.Configs.DotNetCompilerService_SMS)),
                        Path.GetFileName(Settings.Get(Settings.Configs.CompilerService_WebWidgets)),
                        Path.GetFileName(Settings.Get(Settings.Configs.CompilerService_WidgetsRuntimeAPI)),
                        Path.GetFileName(Settings.Get(Settings.Configs.DotNetCompilerService_SharpZipLib)),
                        Path.GetFileName(Settings.Get(Settings.Configs.DotNetCompilerService_GemboxSpreadSheet)),
                        eSpaceName + ".dll",
                        eSpaceName + "CodeBehind.dll",
                    };
                    foreach (var dll in dllsToCopy)
                    {
                        File.Copy(fullBinPath + FileSystemUtils.PathSeparator + dll,
                                  partialBinPath + FileSystemUtils.PathSeparator + dll);
                    }
                }

                string runtimePlatformFile = partialBinPath + FileSystemUtils.PathSeparator + Path.GetFileName(Settings.Get(Settings.Configs.CompilerService_RuntimePlatform));

                var info = new AppDomainSetup();
                info.ApplicationBase = partialPath;
                domain = AppDomain.CreateDomain("Test", null, info);

                var testActionCaller = (TestActionCaller)domain.CreateInstanceFromAndUnwrap(runtimePlatformFile, typeof(TestActionCaller).FullName);
                return(testActionCaller.InnerInvoke(fullBinPath, eSpaceName, ptaName, action, parameters, out result, out exception));
            } catch (Exception e) {
                exception = e.Message;
                result    = string.Empty;
                return("Internal Error");
            } finally {
                if (domain != null)
                {
                    try {
                        AppDomain.Unload(domain);
                    } catch (CannotUnloadAppDomainException ex) {
                        OSTrace.Error("Unloading Domain", ex);
                    }
                    ForceCleanup();
                }
            }
        }
 private static void Execute(Action <T> invocation)
 {
     try {
         GetImplementations().Apply(invocation);
     } catch (ExtensibilityException e) {
         throw e;
     } catch (Exception e) {
         OSTrace.Error("Executing Extension Point action", e);
         throw new ExtensibilityException(e);
     }
 }
 public static IScreenControllerProxy TryGetControllerProxy(Type controllerType)
 {
     if (controllerType != null && (typeof(ScreenServicesApiController)).IsAssignableFrom(controllerType))
     {
         try {
             return((IScreenControllerProxy)controllerType.GetField("ProxyInstance", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).GetValue(null));
         } catch (Exception ex) {
             OSTrace.Error("Unable to load controller proxy for " + controllerType.FullName, ex);
         }
     }
     return(null);
 }
示例#24
0
        /// <summary>
        /// Releases a transaction to the pool.
        /// If the transaction is poolable, it is released and put back into the pool, otherwise it is removed.
        /// Throws an <see cref="InvalidTransactionReleaseException"/> if the transaction is not releasable.
        /// </summary>
        /// <exception cref="InvalidTransactionReleaseException">Occurs if the transaction is not releasable.</exception>
        /// <param name="trans">Transaction to be released.</param>
        public virtual void ReleaseTransaction(IDbTransaction trans)
        {
            if (trans == null)
            {
                return;
            }
            TransactionInfo transInfo = (TransactionInfo)TransactionPool[trans];

            if (transInfo != null)
            {
                if (!transInfo.IsReleasable)
                {
                    throw (new InvalidTransactionReleaseException("Cannot release a transaction that was created with \"GetCommitableTransaction\". Use commit or rollback"));
                }
#if DEBUG_DBCONNECTIONPOOLING
                OSTrace.Info("DBConnectionPooling[TID=" + transInfo.Transaction.GetHashCode() + "] - returned to pool");
                OSTrace.Error(new StackTrace().ToString());
#endif
                if (transInfo.IsPoolable)
                {
                    transInfo.Release();
                }
                else
                {
                    TransactionPool.Remove(trans);
                }
            }
            else
            {
                try {
                    if (RequestTransactionInfo != null && trans == RequestTransactionInfo.Transaction)
                    {
                        //when releasing the request transaction make sure the connection is ok
                        if (trans.Connection != null && trans.Connection.State != ConnectionState.Open)
                        {
                            LogException(new InvalidTransactionException("Request transaction not open on release."), new StackTrace(), "Request Transaction discarded due to connection not being in a correct state.");
                            //clear and try to dispose connection
                            lock (this) {
                                RequestTransactionInfo = null;
                            }
                            trans.Connection.Dispose();
                        }
                        else
                        {
                            RequestTransactionInfo.MarkChange();
                        }
                    }
                } catch {
                    //this is a best effort
                }
            }
        }
 public static string DecryptStringForUpgrade(string text)
 {
     if (text != null)
     {
         try {
             return(SecureConfidentialInformationEncryption.DecryptForUpgrade(text));
         } catch (Exception e) {
             //probably not encrypted
             OSTrace.Error("Decrypting for upgrade", e);
         }
     }
     return(text);
 }
示例#26
0
 public override IDataReader ExecuteReader(IDbCommand cmd)
 {
     try {
         var reader = (OracleDataReader)cmd.ExecuteReader();
         if (reader.HasRows)
         {
             SetDataReaderFetchSize(reader);
         }
         return(new OracleDataReaderWrapper(reader, this));
     } catch (DbException e) {
         OSTrace.Error("Error executing ExecuteReader (" + e.Message + ") with statement:" + Environment.NewLine + cmd.CommandText);
         throw;
     }
 }
示例#27
0
 private void InnerOnChange(PubSubMessage message)
 {
     lock (this) {
         if (!monitorDisposed)
         {
             this.filter.UnregisterForTopics(this.InnerOnChange, topics);
             try {
                 base.OnChanged(message);
             } catch (Exception ex) {
                 OSTrace.Error($"Error notifing PubSubMonitor change for topic: {UniqueId}. Possible due to Application Unload.", ex);
             }
         }
     }
 }
示例#28
0
 private static bool changeVdirPath(DirectoryEntry espaceDir, string espaceName, string path, string rootPath)
 {
     try {
         if (IsEspacePath(espaceName, espaceDir.Properties["Path"][0].ToString(), rootPath) && espaceDir.Properties["Path"][0].ToString() != path)
         {
             espaceDir.Properties["Path"][0] = path;
             OSDirectoryEntry.CommitChanges(espaceDir);
             return(true);
         }
     } catch (Exception e) {
         OSTrace.Error("Changing vdir", e);
     }
     return(false);
 }
示例#29
0
        private string GetTextResource(string espaceName, string resourceName, bool enableWarnings)
        {
            var resourceBinary = RuntimePlatformUtils.TryGetResourceBinary(resourceName, espaceName);

            if (resourceBinary != null && resourceBinary.Length > 0)
            {
                return(Encoding.UTF8.GetStringWithoutBOM(resourceBinary));
            }

            if (enableWarnings)
            {
                OSTrace.Warning("Could not get " + resourceName + " file for '{0}'.", espaceName);
            }

            return(null);
        }
        private bool ValidateConsumerAndProducerKeys(string consumerKey, string producerKey)
        {
            bool consumerKeysAreValid = ObjectKey.Parse(consumerKey) == ConsumerModuleKey;
            bool producerKeysAreValid = ObjectKey.Parse(producerKey) == ProducerModuleKey;

            if (!consumerKeysAreValid)
            {
                OSTrace.Error($"Consumer Module keys don't match. Expected '{ObjectKeyUtils.DatabaseValue(ConsumerModuleKey)}' but was '{consumerKey}'");
            }
            if (!producerKeysAreValid)
            {
                OSTrace.Error($"Producer Module keys don't match. Expected '{ObjectKeyUtils.DatabaseValue(ProducerModuleKey)}' but was '{producerKey}'");
            }

            return(producerKeysAreValid && consumerKeysAreValid);
        }