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());
        }
        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;

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

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

            if (!onlyGetUrl)
            {
                int userId = heContext.Session.UserId;

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

                using (Transaction tran = DatabaseAccess.ForSystemDatabase.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)) {
                //ToDo: activityHandler.Timeout = (int)(1.2 * TimeoutInSec) * 1000;
                success     = activityHandler.ExecuteOnOpen(SSKey, activityId, processId, tenantId, heContext.Session.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 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);
                }
            }
        }
Esempio n. 4
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);
                }
            }
        }