Esempio n. 1
0
        public static string ReadText(this IDataReader reader, int i, string columnName, string defaultValue)
        {
            return(ReadWrapper(reader, i, columnName, (column, r, index) => {
                if (column == System.DBNull.Value || column is string)
                {
                    return (column != System.DBNull.Value ? (string)column : defaultValue);
                }
                else
                {
                    if (column is DateTime)
                    {
                        return ((DateTime)column).ToString(FormatInfo.GetOutputDateTimeFormatString(), FormatInfo.defaultHeCultureInfo);
                    }
                    else
                    {
#if JAVA
                        if (column is Decimal)
                        {
                            return BuiltInFunction.DecimalToText((Decimal)column);
                        }
#endif
                        return Convert.ToString(column);
                    }
                }
            }));
        }
        private static int InnerActivityClose(HeContext heContext, int activityId, bool advanceProcess, bool skip, bool skipAll, Action </*id*/ int, /*name*/ string, ActivityKind, /*key*/ string> activityChecks, List <Pair <string, object> > inputs)
        {
            int    userId = heContext.Session.UserId;
            string SSKey;
            string url;
            int    tenantId;
            List <Pair <int, ActivityKind> > nextActIds;

            ActivityKind activityKind;
            string       activityName;
            int          processId;

            BPMRuntime.GetActivityDataForWS(activityId, out processId, out activityKind, out activityName, out SSKey, out url, out tenantId);

            activityChecks(activityId, activityName, activityKind, SSKey);

            using (ActivityHandler activityHandler = new ActivityHandler(url)) {
                string failureMessage;
                bool   success = activityHandler.ExecuteOnClose(SSKey, activityId, processId, tenantId, userId, BuiltInFunction.GetCurrentLocale(), advanceProcess, skip, skipAll, inputs, out failureMessage, out nextActIds);

                if (!success)
                {
                    ProcessBase.ThrowSpecificException(failureMessage);
                }
            }

            if (advanceProcess)
            {
                using (Transaction tran = DatabaseAccess.ForSystemDatabase.GetReadOnlyTransaction()) {
                    return(BPMRuntime.GetNextHumanActivity(heContext, tran, nextActIds, userId));
                }
            }

            return(BuiltInFunction.NullIdentifier());
        }
        public static int ProcessLaunch(HeContext heContext, ObjectKey SSKey, ObjectKey espaceSSKey, int parentActivityId, int parentProcessId, List <Pair <string, object> > inputs, out int nextHumanActivity)
        {
            List <Pair <int, ActivityKind> > nextActIds;

            int newProcessId = ProcessLaunch(heContext, SSKey, espaceSSKey, parentActivityId, parentProcessId, inputs, out nextActIds);

            nextHumanActivity = BuiltInFunction.NullIdentifier();

            return(newProcessId);
        }
Esempio n. 4
0
        private static void InnerActivityOpen(HeContext heContext, int activityId, bool onlyGetUrl, out bool success, out string failureMessage, out string handlingUrl, Func <ActivityKind, bool> activityKindCheck, string actionName)
        {
            string SSKey;
            string url;
            int    tenantId;

            int          processId;
            ActivityKind activityKind;
            string       activityName;
            string       espaceSSKey;

            BPMRuntime.GetActivityDataForWS(activityId, out processId, out activityKind, out activityName, out SSKey, out url, out tenantId, out espaceSSKey);

            int userId = tenantId == heContext.Session.TenantId ? heContext.Session.UserId : 0;

            if (!activityKindCheck(activityKind))
            {
                throw new InvalidOperationException("Activity '" + activityName + "' (#" + activityId + ") cannot be opened.");
            }

            if (!onlyGetUrl)
            {
                if (userId == 0)
                {
                    throw new SecurityException(actionName + " requires a logged user");
                }

                using (Transaction tran = DatabaseAccess.ForRuntimeDatabase.GetReadOnlyTransaction()) {
                    int allowedActivity = BPMRuntime.GetAllowedActivities(heContext, tran, new int[] { activityId }, userId).FirstIfSingleOrDefault();
                    if (allowedActivity != activityId)
                    {
                        throw new SecurityException("The user in session does not have the correct permissions to open the activity or the activity is already open by another user.");
                    }
                }
            }

            using (ActivityHandler activityHandler = new ActivityHandler(url, tenantId, userId, heContext.AppInfo.eSpaceUID, espaceSSKey)) {
                //ToDo: activityHandler.Timeout = (int)(1.2 * TimeoutInSec) * 1000;
                success     = activityHandler.ExecuteOnOpen(SSKey, activityId, processId, tenantId, userId, BuiltInFunction.GetCurrentLocale(), heContext.Session.SessionID, heContext.Context.Request.IsSecureConnection, heContext.Context.Request.Url.Host, onlyGetUrl, out failureMessage, out handlingUrl);
                handlingUrl = BuiltInFunction.AddPersonalAreaToURLPath(handlingUrl);
            }
            handlingUrl = RuntimePlatformUtils.CheckUriSecurity(HttpContext.Current.Request, handlingUrl);
        }
        internal virtual IDataReader GetActivities(Transaction trans, int userId, int tenantId, int startIndex, string locale, string additionalWhereClauses, int maxActivitiesReturned)
        {
            StringBuilder sql = new StringBuilder();

            sql.AppendFormat(@"
                WITH INBOXACTIVITIES AS (
                    SELECT 
                        ROW_NUMBER() OVER (
                            ORDER BY (CASE ACT.DUE_DATE WHEN @NULLDATE THEN @LONGFUTUREDATE ELSE ACT.DUE_DATE END) ASC,
                            ACT.OPENED DESC,
                            ACT.CREATED DESC) AS ROWNUMBER,
                        ACT.ID ID, 
                        AD.LABEL LABEL, 
                        ADL.LABEL LABEL_LANG, 
                        ACT.INBOX_DETAIL INBOX_DETAIL, 
                        ACT.DUE_DATE DUE_DATE, 
                        (CASE ACT.STATUS_ID WHEN 2 THEN 1 ELSE 0 END) AS OPENED, 
                        (CASE WHEN ACT.ID > {0} THEN 0 ELSE 1 END) AS SEEN ",
                             GetTaskboxLastSeenActivitySql(GetCachedTableName(trans, Constants.EpaTaskboxSeenActivityKey)));

            GetTaskboxFromClauseSql(sql, true);
            GetTaskboxWhereClauseSql(sql, trans, false, additionalWhereClauses);

            sql.Append(@"
                )

                SELECT ID, LABEL, LABEL_LANG, INBOX_DETAIL, DUE_DATE, OPENED, SEEN
                FROM INBOXACTIVITIES
                WHERE ROWNUMBER > @STARTINDEX AND ROWNUMBER <= @ENDINDEX ");

            Command cmd = trans.CreateCommand(sql.ToString());

            cmd.CreateParameter("@USERID", DbType.Int32, userId);
            cmd.CreateParameter("@TENANTID", DbType.Int32, tenantId);
            cmd.CreateParameter("@STARTINDEX", DbType.Int32, startIndex);
            cmd.CreateParameter("@ENDINDEX", DbType.Int32, startIndex + maxActivitiesReturned);
            cmd.CreateParameter("@NULLDATE", DbType.DateTime, BuiltInFunction.NullDate());
            cmd.CreateParameter("@LONGFUTUREDATE", DbType.DateTime, BuiltInFunction.NewDate(3000, 1, 1));
            cmd.CreateParameter("@LOCALE", DbType.String, locale);
            IDataReader reader = cmd.ExecuteReader();

            return(reader);
        }
        public static void ClientCertificateGetDetails(
            HeContext heContext,
            out string cookie,
            out int flags,
            out bool isPresent,
            out string issuer,
            out bool isValid,
            out string serialNumber,
            out string serverIssuer,
            out string serverSubject,
            out string subject,
            out DateTime validFrom,
            out DateTime validUntil)
        {
            cookie        = "";
            flags         = 0;
            isPresent     = false;
            issuer        = "";
            isValid       = false;
            serialNumber  = "";
            serverIssuer  = "";
            serverSubject = "";
            subject       = "";
            validFrom     = BuiltInFunction.NullDate();
            validUntil    = BuiltInFunction.NullDate();


            {
                System.Web.HttpClientCertificate cert = System.Web.HttpContext.Current.Request.ClientCertificate;
                cookie        = cert.Cookie;
                flags         = cert.Flags;
                isPresent     = cert.IsPresent;
                issuer        = cert.Issuer;
                isValid       = cert.IsValid;
                serialNumber  = cert.SerialNumber;
                serverIssuer  = cert.ServerIssuer;
                serverSubject = cert.ServerSubject;
                subject       = cert.Subject;
                validFrom     = cert.ValidFrom;
                validUntil    = cert.ValidUntil;
            }
        }
        public static void ActivityStart(HeContext heContext, int processId, string activityssKey, string actionName, List <Pair <string, object> > inputs, out int nextHumanActivityId)
        {
            int activityId;

            using (Transaction tran = DatabaseAccess.ForSystemDatabase.GetRequestTransaction()) {
                var retries = 0;
                do
                {
                    activityId = DBRuntimePlatform.Instance.GetActiveActivityInProcess(tran, processId, activityssKey, ActivityStatus.Listening);
                    if (activityId == BuiltInFunction.NullIdentifier())
                    {
                        if (Settings.GetBool(Settings.Configs.BPT_ConditionalStartListenersCreatedOnDemand))
                        {
                            using (Transaction priv = DatabaseAccess.ForSystemDatabase.GetCommitableTransaction()) {
                                DBRuntimePlatform.Instance.CreateMissingStartActivityInProcess(priv, processId, activityssKey);
                                activityId = DBRuntimePlatform.Instance.GetActiveActivityInProcess(tran, processId, activityssKey, ActivityStatus.Created);
                                priv.Commit();
                            }
                            // Needed to execute the onready as fast as possible (don't wait for the scheduler)
                            ActivityPushFromCreated(processId, activityssKey, activityId);
                            activityId = DBRuntimePlatform.Instance.GetActiveActivityInProcess(tran, processId, activityssKey, ActivityStatus.Listening);
                        }
                    }
                    retries++;
                    // Wait up to 30 seconds in case the scheduler captured the activity
                    if (activityId != BuiltInFunction.NullIdentifier() ||
                        retries >= Settings.GetInt(Settings.Configs.BPT_StartActivityReadyWaitTimeInSeconds))
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                } while (true);

                if (activityId == BuiltInFunction.NullIdentifier())
                {
                    throw new InvalidOperationException("There is no activity in process #" + processId + " that could be started using " + actionName + ".");
                }
            }

            ActivityStart(heContext, activityId, inputs, out nextHumanActivityId);
        }
        public static void ActivitySchedule(HeContext heContext, int activityId, DateTime startDate)
        {
            string SSKey;
            string url;
            int    tenantId;

            bool   success;
            string failureMessage;

            int          processId;
            ActivityKind activityKind;
            string       activityName;

            BPMRuntime.GetActivityDataForWS(activityId, out processId, out activityKind, out activityName, out SSKey, out url, out tenantId);

            using (ActivityHandler activityHandler = new ActivityHandler(url)) {
                //ToDo: activityHandler.Timeout = (int)(1.2 * TimeoutInSec) * 1000;
                success = activityHandler.ExecuteActivitySchedule(SSKey, activityId, processId, startDate, tenantId, heContext.Session.UserId, BuiltInFunction.GetCurrentLocale(), out failureMessage);
                if (!success)
                {
                    ProcessBase.ThrowSpecificException(failureMessage);
                }
            }
        }
 public static void NotifyGetMessage(HeContext heContext, out string message)
 {
     // Calls the built-in function
     message = BuiltInFunction.NotifyWidgetGetMessage();
 }
Esempio n. 10
0
        public static void ActivityReset(HeContext heContext, int activityId, bool resetActivityUser)
        {
            string SSKey;
            string url;
            int    tenantId;

            bool   success;
            string failureMessage;

            int          processId;
            ActivityKind activityKind;
            string       activityName;

            BPMRuntime.GetActivityDataForWS(activityId, out processId, out activityKind, out activityName, out SSKey, out url, out tenantId, out string espaceSSKey);

            int userId = tenantId == heContext.Session.TenantId ? heContext.Session.UserId : 0;

            using (ActivityHandler activityHandler = new ActivityHandler(url, tenantId, userId, heContext.AppInfo.eSpaceUID, espaceSSKey)) {
                //ToDo: activityHandler.Timeout = (int)(1.2 * TimeoutInSec) * 1000;
                success = activityHandler.ExecuteActivityReset(SSKey, activityId, processId, resetActivityUser, tenantId, userId, BuiltInFunction.GetCurrentLocale(), out failureMessage);
                if (!success)
                {
                    ProcessBase.ThrowSpecificException(failureMessage);
                }
            }
        }