コード例 #1
0
        public InjectionCache ReadInjectionElements(IDataReader reader, ObjectKey _eSpaceUID, bool hideInProvider)
        {
            List <ICodeInjectionElement>          callbacks = new List <ICodeInjectionElement>();
            List <AbstractCallback.EventListener> listeners = new List <AbstractCallback.EventListener>();

            while (reader.Read())
            {
                if (DataReaderUtils.SafeGet <string>(reader, "CallbackType").EqualsIgnoreCase("Dynamic") && !hideInProvider)
                {
                    listeners.Add(NewCallbackListener(reader, callbacks));
                }
                else
                {
                    callbacks.Add(CreateInjectedJavascript(reader));
                }
            }
            HashSet <AbstractCallback>      onlyCallbacks    = new HashSet <AbstractCallback>();
            HashSet <ICodeInjectionElement> calbacksToRemove = new HashSet <ICodeInjectionElement>();

            callbacks.OfType <AbstractCallback>().Apply(c => onlyCallbacks.Add(c));
            listeners.Apply(l => l.NormalizeCallback(onlyCallbacks));
            listeners = listeners.Distinct().ToList(); // clean repeated listeners
            callbacks = callbacks.Distinct().ToList(); //#886594 - We should have only one callback per listener.
            foreach (var callback in callbacks.OfType <AbstractCallback>())
            {
                if (!listeners.Select(listener => listener.Callback).Contains(callback))
                {
                    calbacksToRemove.Add(callback);
                }
            }
            callbacks.Except(calbacksToRemove);
            return(new InjectionCache(callbacks, listeners));
        }
コード例 #2
0
 public override void GetDbSpecificCatalogConfigurationParameters(Dictionary <string, object> parameters, IDataReader reader,
                                                                  string databaseName)
 {
     parameters.Add("Schema", databaseName.IsNullOrEmpty() ? DataReaderUtils.SafeGet <string>(reader["NAME"], string.Empty).Trim() : databaseName);
     parameters.Add("Tablespace", DataReaderUtils.SafeGet <string>(reader["DATATABLESPACE"], string.Empty).Trim());
     parameters.Add("TablespaceIndex", DataReaderUtils.SafeGet <string>(reader["INDEXTABLESPACE"], string.Empty).Trim());
 }
コード例 #3
0
        public byte[] GetEmailContent(Transaction tran, int emailId)
        {
            Command cmd = tran.CreateCommand(tran.DatabaseServices.DMLService.Queries.GetMaxRecordsSQL(1, tran.DatabaseServices.DMLService.Identifiers.EscapeIdentifier("CONTENT"), "OSSYS_EMAIL_CONTENT", "ID = @EMAILID"));

            cmd.CreateParameter("@EMAILID", DbType.String, emailId);
            return(DataReaderUtils.SafeGet <byte[]>(cmd.ExecuteScalar(true), new byte[0]));
        }
コード例 #4
0
        public override long ExecuteNonQueryGetLongIdentity(Command cmd, string idColumnName)
        {
            cmd.CommandText = cmd.CommandText + " RETURNING " + idColumnName.ToUpper() + " INTO @id";

            DataParameter IdParamenter = cmd.CreateOutputParameter("@id", DbType.Int64);

            cmd.ExecuteNonQuery();
            return(DataReaderUtils.SafeGet <long>(IdParamenter.Value));
        }
        public static int Script_GetId(Transaction trans, string scriptName)
        {
            Command cmd = trans.CreateCommand(
                @"SELECT OSSYS_CALLBACK.ID FROM OSSYS_CALLBACK 
                    LEFT JOIN OSSYS_CALLBACKTYPE ON OSSYS_CALLBACK.CALLBACKTYPEID = OSSYS_CALLBACKTYPE.ID
                  WHERE CALLBACKNAME = @SCRIPTNAME AND NOT(OSSYS_CALLBACKTYPE.LABEL IS NULL) AND NOT(OSSYS_CALLBACKTYPE.LABEL='Dynamic')");

            cmd.CreateParameter("@SCRIPTNAME", DbType.String, scriptName);
            return(DataReaderUtils.SafeGet <int>(cmd.ExecuteScalar()));
        }
コード例 #6
0
        public override int ExecuteNonQueryGetIdentity(Command cmd, string idColumnName)
        {
            bool plSqlNeeded = RuntimePlatformUtils.IsJava();

            cmd.CommandText = ((plSqlNeeded ? "begin " : String.Empty) + cmd.CommandText + " RETURNING " + idColumnName.ToUpper() + " INTO @id"
                               + (plSqlNeeded ? " ;end;" : String.Empty));

            DataParameter IdParamenter = cmd.CreateOutputParameter("@id", DbType.Int32);

            cmd.ExecuteNonQuery();
            return(DataReaderUtils.SafeGet <int>(IdParamenter.Value));
        }
コード例 #7
0
 private ICodeInjectionElement CreateInjectedJavascript(IDataReader reader)
 {
     if (!Enum.IsDefined(typeof(Locations), DataReaderUtils.SafeGet <string>(reader, "CallbackLocation")))
     {
         throw new ArgumentException("Invalid enum type.");
     }
     return(new InjectedJavascript(
                DataReaderUtils.SafeGet <string>(reader, "CALLBACKNAME"),
                DataReaderUtils.SafeGet <string>(reader, "URL"),
                DataReaderUtils.SafeGet <string>(reader, "SCRIPT"),
                (CodeInjectionFactory.Locations)Enum.Parse(typeof(CodeInjectionFactory.Locations), DataReaderUtils.SafeGet <string>(reader, "CallbackLocation")),
                DataReaderUtils.SafeGet <int>(reader, "ORDER"),
                DataReaderUtils.SafeGet <string>(reader, "DESCRIPTION"),
                DataReaderUtils.SafeGet <bool>(reader, "IsActive")));
 }
コード例 #8
0
        private ICodeInjectionElement CreateEctCallback(IDataReader reader, CodeInjectionFactory.Locations locationId, WebServiceCallbackInvoke invoke)
        {
            int id = DataReaderUtils.SafeGet <int>(reader["ID"]);

            switch (Convert.ToString(reader["METHODNAME"]))
            {
            case "GetHtml":
                return(new Callbacks.ECT.ECTGetHtmlCallback(id, locationId, invoke));

            case "ShowFeedback":
                return(new Callbacks.ECT.ECTShowFeedbackCallback(id, locationId, invoke));

            default:
                return(null);
            }
        }
コード例 #9
0
        public override int SaveEmail(Transaction tran, string @from, string to, string cc, string bcc, string subject, byte[] content, int contentlen,
                                      int activityId, int tenantId, int eSpaceId, string emailDefSSKey, bool storeContent, string messageId, bool enableEmails,
                                      string testEmails)
        {
            Command cmd = tran.CreateCommand(
                "DECLARE EMAILDEFINITIONID NUMBER(10,0);" +
                "BEGIN " +
                "SELECT ID INTO EMAILDEFINITIONID " +
                "FROM OSSYS_EMAIL_DEFINITION ED " +
                "WHERE ED.SS_KEY = @EMAILDEFSSKEY AND ED.IS_ACTIVE = 1 " + (eSpaceId != 0 ? "AND ED.ESPACE_ID = @ESPACEID " : "") + "AND ROWNUM <= 1;" +
                "INSERT INTO OSSYS_EMAIL (\"FROM\", \"TO\", \"CC\", \"BCC\", SUBJECT, CREATED, ACTIVITY_ID, TENANT_ID, EMAIL_DEFINITION_ID, STORE_CONTENT, IS_TEST_EMAIL, \"SIZE\", MESSAGE_ID) " +
                "VALUES(@EMAILFROM, @EMAILTO, @EMAILCC, @EMAILBCC, @SUBJECT, GETDATE(), @ACTIVITYID, @TENANTID, EMAILDEFINITIONID, @STORECONTENT, @ISTESTEMAIL ,@EMAILSIZE, @MESSAGEID) " +
                "RETURNING ID INTO @EMAILID;" +
                "END;");

            cmd.CreateParameter("@EMAILFROM", DbType.String, from);
            cmd.CreateParameter("@EMAILTO", DbType.String, enableEmails ? to : testEmails);
            cmd.CreateParameter("@EMAILCC", DbType.String, enableEmails ? cc : "");
            cmd.CreateParameter("@EMAILBCC", DbType.String, enableEmails ? bcc : "");
            cmd.CreateParameter("@ISTESTEMAIL", DbType.Boolean, !enableEmails);
            cmd.CreateParameter("@SUBJECT", DbType.String, subject);
            cmd.CreateParameter("@MESSAGEID", DbType.String, messageId);
            cmd.CreateParameter("@ACTIVITYID", DbType.Int32, activityId != 0 ? (object)activityId : null);
            cmd.CreateParameter("@TENANTID", DbType.Int32, tenantId != 0 ? (object)tenantId : null);
            cmd.CreateParameter("@EMAILDEFSSKEY", DbType.String, emailDefSSKey);
            if (eSpaceId != 0)
            {
                cmd.CreateParameter("@ESPACEID", DbType.Int32, eSpaceId);
            }
            cmd.CreateParameter("@STORECONTENT", DbType.Boolean, storeContent);
            cmd.CreateParameter("@EMAILSIZE", DbType.Int32, contentlen);

            DataParameter IdParamenter = cmd.CreateOutputParameter("@EMAILID", DbType.Int32);

            cmd.ExecuteNonQuery();
            int emailId = DataReaderUtils.SafeGet <int>(IdParamenter.Value);

            cmd = tran.CreateCommand(
                "INSERT INTO OSSYS_EMAIL_CONTENT (\"ID\", \"CONTENT\", \"TENANT_ID\") VALUES (@EMAILID, @CONTENT, @TENANTID)");

            cmd.CreateParameter("@EMAILID", DbType.Int32, emailId);
            cmd.CreateParameter("@CONTENT", DbType.Binary, content);
            cmd.CreateParameter("@TENANTID", DbType.Int32, tenantId != 0 ? (object)tenantId : null);
            cmd.ExecuteNonQuery();

            return(emailId);
        }
コード例 #10
0
        public static JavaScript CreateFromReader(IDataReader reader)
        {
            string scriptOrUrl = DataReaderUtils.SafeGet <string>(reader, "URL");

            if (scriptOrUrl.Trim().IsNullOrEmpty())
            {
                scriptOrUrl = DataReaderUtils.SafeGet <string>(reader, "SCRIPT");
            }
            return(new JavaScript(
                       DataReaderUtils.SafeGet <int>(reader, "ID"),
                       DataReaderUtils.SafeGet <string>(reader, "CALLBACKNAME"),
                       scriptOrUrl,
                       DataReaderUtils.SafeGet <string>(reader, "LOCATION"),
                       DataReaderUtils.SafeGet <int>(reader, "ORDER"),
                       DataReaderUtils.SafeGet <string>(reader, "DESCRIPTION"),
                       DataReaderUtils.SafeGet <bool>(reader, "ISACTIVE")));
        }
コード例 #11
0
        private AbstractCallbackInvoke CreateCallbackInvoke(IDataReader reader)
        {
            int    id           = DataReaderUtils.SafeGet <int>(reader["ID"]);
            string url          = Convert.ToString(reader["URL"]);
            string serviceName  = Convert.ToString(reader["SERVICENAME"]);
            string providerName = Convert.ToString(reader["PROVIDERNAME"]);
            string methodName   = Convert.ToString(reader["METHODNAME"]);
            string toLowerUrl   = url.ToLowerInvariant();

            if (toLowerUrl.TrimStart().StartsWith("http://") || toLowerUrl.TrimStart().StartsWith("https://"))
            {
                return(new WebServiceCallbackInvoke(url, serviceName, providerName, methodName));
            }
            else
            {
                return(new LibraryCallbackInvoke(url, serviceName, providerName, methodName));
            }
        }
コード例 #12
0
        private ICodeInjectionElement CreateCallback(IDataReader reader, CodeInjectionFactory.Locations locationId, AbstractCallbackInvoke invoke)
        {
            int id = DataReaderUtils.SafeGet <int>(reader["ID"]);

            if (Convert.ToString(reader["PROVIDERNAME"]) == "ECT_Provider")
            {
                return(CreateEctCallback(reader, locationId, (WebServiceCallbackInvoke)invoke));
            }
            else if (Convert.ToBoolean(reader["IS_VOLATILE"]) == true)
            {
                return(new VolatileContentCallback(id, locationId, (AbstractStringCallbackInvoke)invoke));
            }
            else if (Convert.ToBoolean(reader["IS_STATIC"]) == true)
            {
                return(new StaticContentCallback(id, locationId, (AbstractStringCallbackInvoke)invoke));
            }
            else
            {
                return(new DummyCallback(id, locationId, invoke));
            }
        }
 public override int ExecuteNonQueryGetIdentity(Command cmd, string idColumnName)
 {
     cmd.CommandText = cmd.CommandText + "; SELECT LAST_INSERT_ID()";
     return(DataReaderUtils.SafeGet <int>(cmd.ExecuteScalar()));
 }
コード例 #14
0
        private AbstractCallback.EventListener NewCallbackListener(IDataReader reader, List <ICodeInjectionElement> injectionElements)
        {
            AbstractCallbackInvoke invoke = CreateCallbackInvoke(reader);

            CodeInjectionFactory.Locations location = (CodeInjectionFactory.Locations)Enum.Parse(typeof(CodeInjectionFactory.Locations), DataReaderUtils.SafeGet <string>(reader, "CallbackLocation"));
            AbstractCallback callback = CreateCallback(reader, location, invoke) as AbstractCallback;

            callback.HideInProvider = (reader["HIDE_IN_PROVIDER"] != DBNull.Value ? Convert.ToBoolean(reader["HIDE_IN_PROVIDER"]) : false);
            callback.IsLocalizable  = (reader["IS_LOCALIZED"] != DBNull.Value ? Convert.ToBoolean(reader["IS_LOCALIZED"]) : false);
            injectionElements.Add(callback);

            return(CreateCallbackEventListener(reader, callback));
        }
コード例 #15
0
 public override long ExecuteNonQueryGetLongIdentity(Command cmd, string idColumnName)
 {
     cmd.CommandText = cmd.CommandText + "; SELECT SCOPE_IDENTITY()";
     return(DataReaderUtils.SafeGet <long>(cmd.ExecuteScalar()));
 }
コード例 #16
0
 public override void GetDbSpecificCatalogConfigurationParameters(Dictionary <string, object> parameters, IDataReader reader,
                                                                  string databaseName)
 {
     parameters.Add("Catalog", databaseName.IsNullOrEmpty() ? DataReaderUtils.SafeGet <string>(reader["NAME"], string.Empty).Trim() : databaseName);
 }
コード例 #17
0
        internal bool DeleteProcesses(Transaction trans)
        {
            if (!IsBulkDeletion)
            {
                string sql = @"select PARENT_PROCESS_ID, IS_TERMINAL
                    from OSSYS_BPM_PROCESS p inner join OSSYS_BPM_PROCESS_STATUS ps on p.STATUS_ID = ps.ID
                    where p.ID = @processId";

                using (Command cmd = CreateSQLCommand(trans, sql)) {
                    using (IDataReader reader = cmd.ExecuteReader()) {
                        if (reader.Read())
                        {
                            if (DataReaderUtils.SafeGet <int>(reader, "PARENT_PROCESS_ID") != 0)
                            {
                                throw new OutSystems.RuntimePublic.Processes.ProcessDeletion.ProcessNotTopLevelException();
                            }

                            if (!DataReaderUtils.SafeGet <bool>(reader, "IS_TERMINAL"))
                            {
                                throw new OutSystems.RuntimePublic.Processes.ProcessDeletion.InvalidProcessStatusException();
                            }
                        }
                        else
                        {
                            throw new OutSystems.RuntimePublic.Processes.ProcessDeletion.ProcessNotFoundException();
                        }
                    }
                }
            }

            string processesToDeleteSQL = ProcessesToDeleteQuery(trans.DatabaseServices, /*isDeletingTopProcesses*/ false);

            // remove circular reference in top process id
            using (Command cmd = CreateSQLCommand(trans, "UPDATE OSSYS_BPM_PROCESS SET PARENT_ACTIVITY_ID = NULL WHERE TOP_PROCESS_ID IN ({0})", processesToDeleteSQL)) {
                cmd.ExecuteNonQuery();
            }

            // Remove sub processes
            string subProcessesSQL =
                string.Format(@"FROM OSSYS_BPM_PROCESS 
                                WHERE ID <> TOP_PROCESS_ID 
                                  AND ID NOT IN (
                                    SELECT PARENTID 
                                    FROM (
                                        SELECT DISTINCT PARENT_PROCESS_ID AS PARENTID 
                                        FROM OSSYS_BPM_PROCESS 
                                        WHERE PARENT_PROCESS_ID IS NOT NULL
                                    ) PARENTPROCS
                                  ) AND TOP_PROCESS_ID IN ({0})", processesToDeleteSQL);
            bool moreSubProcessesToDelete = true;

            while (moreSubProcessesToDelete)
            {
                using (Command cmd = CreateSQLCommand(trans, "SELECT COUNT(*) " + subProcessesSQL)) {
                    moreSubProcessesToDelete = DataReaderUtils.SafeGet <bool>(cmd.ExecuteScalar());
                }
                if (moreSubProcessesToDelete)
                {
                    using (Command cmd = CreateSQLCommand(trans, "DELETE " + subProcessesSQL)) {
                        cmd.ExecuteNonQuery();
                    }
                }
            }

            // Remove circular references in TOP_PROCESS_ID
            using (Command cmd = CreateSQLCommand(trans, "UPDATE OSSYS_BPM_PROCESS SET TOP_PROCESS_ID = NULL WHERE ID IN ({0})", processesToDeleteSQL)) {
                cmd.ExecuteNonQuery();
            }

            // Delete top processes
            processesToDeleteSQL = ProcessesToDeleteQuery(trans.DatabaseServices, /*isDeletingTopProcesses*/ true);
            using (Command cmd = CreateSQLCommand(trans, "DELETE FROM OSSYS_BPM_PROCESS WHERE ID IN ({0})", processesToDeleteSQL)) {
                int     deleted = cmd.ExecuteNonQuery();
                AppInfo info    = AppInfo.GetAppInfo();
                if (info != null)
                {
                    GenericExtendedActions.LogMessage(info.OsContext,
                                                      IsBulkDeletion ?
                                                      string.Format("Bulk deleted {0} top processes older than {1} (ProcessDefinitionId = {2})", deleted, olderThan.Value.ToString(FormatInfo.GetOutputDateFormatString()), processDefinitionId.HasValue ? processDefinitionId.ToString() : "NULL") :
                                                      string.Format("Deleted top-process #{0}", processId),
                                                      "BPT_API");
                }
            }

            if (IsBulkDeletion)
            {
                return(HasProcessesToDelete(trans));
            }
            return(false);
        }