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());
        }
Exemplo n.º 2
0
        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, 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.ExecuteActivitySchedule(SSKey, activityId, processId, startDate, tenantId, userId, BuiltInFunction.GetCurrentLocale(), out failureMessage);
                if (!success)
                {
                    ProcessBase.ThrowSpecificException(failureMessage);
                }
            }
        }
        private static void ActivityPushFromCreated(int processId, string activityssKey, int activityId)
        {
            ActivityKind activityKind;
            string       activityName;
            string       ssKey;
            string       url;
            int          tenantId;

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

            using (ActivityHandler activityHandler = new ActivityHandler(url)) {
                activityHandler.ExecuteActivityAction(activityssKey, activityId, processId, tenantId, ActivityStatus.Created);
            }
        }
Exemplo n.º 4
0
        private static void SetProcessSuspension(HeContext heContext, int processId, bool suspend)
        {
            BPMRuntime.GetProcessDataForWS(processId, out string SSKey, out string url, out int tenantId, out string consumerKey);

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

            using (ActivityHandler activityHandler = new ActivityHandler(url, tenantId, userId, heContext.AppInfo.eSpaceUID, consumerKey)) {
                bool success = activityHandler.ExecuteSetProcessSuspension(SSKey, processId, suspend, tenantId, userId, out string failureMessage);
                if (!success)
                {
                    ProcessBase.ThrowSpecificException(failureMessage);
                }
            }
        }
Exemplo n.º 5
0
        private static void ActivityPushFromCreated(HeContext heContext, int processId, string activityssKey, int activityId)
        {
            ActivityKind activityKind;
            string       activityName;
            string       ssKey;
            string       url;
            int          tenantId;

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

            using (ActivityHandler activityHandler = new ActivityHandler(url, tenantId, heContext.Session.UserId, heContext.AppInfo.eSpaceUID, espaceSSKey)) {
                activityHandler.ExecuteActivityAction(activityssKey, activityId, processId, tenantId, ActivityStatus.Created);
            }
        }
Exemplo n.º 6
0
        public static int ProcessLaunch(HeContext heContext, ObjectKey SSKey, ObjectKey espaceSSKey, int parentActivityId, int parentProcessId, List <Pair <string, object> > inputs, out List <Pair <int, ActivityKind> > nextActIds)
        {
            string ssKey = ObjectKeyUtils.DatabaseValue(SSKey);

            BPMRuntime.GetProcessDataForWS(heContext, SSKey, espaceSSKey, out string url);

            using (ActivityHandler activityHandler = new ActivityHandler(url, heContext.Session.TenantId, heContext.Session.UserId, heContext.AppInfo.eSpaceUID, ObjectKeyUtils.DatabaseValue(espaceSSKey))) {
                int newProcessId = activityHandler.ExecuteProcessLaunch(ssKey, heContext.Session.TenantId, heContext.Session.UserId, parentActivityId, parentProcessId, inputs, out nextActIds, out string failureMessage);
                if (!failureMessage.IsEmpty() || newProcessId == 0)
                {
                    ProcessBase.ThrowSpecificException(failureMessage);
                }
                return(newProcessId);
            }
        }
        private static void SetProcessSuspension(HeContext heContext, int processId, bool suspend)
        {
            string SSKey;
            string url;
            int    tenantId;

            bool   success;
            string failureMessage;

            BPMRuntime.GetProcessDataForWS(processId, out SSKey, out url, out tenantId);

            using (ActivityHandler activityHandler = new ActivityHandler(url)) {
                success = activityHandler.ExecuteSetProcessSuspension(SSKey, processId, suspend, tenantId, heContext.Session.UserId, out failureMessage);
                if (!success)
                {
                    ProcessBase.ThrowSpecificException(failureMessage);
                }
            }
        }
Exemplo n.º 8
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);
        }
        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);

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