//流程实例化
    //根据类名进行实例化
    protected virtual void IniProcess(string processName)
    {
        //如果流程已经启动了 就跳出
        if (CheckProcessIsInied(processName))
        {
            return;
        }
        try
        {
            //根据名称 实例化对应的流程
            Type        type = Type.GetType(processName);
            ProcessBase pb   = type.Assembly.CreateInstance(type.Name) as ProcessBase;

            if (pb != null)
            {
                _nowRunProcess = pb;
                GameObject obj = new GameObject(processName);
                _nowRunProcess.Initialization(this, obj);
            }
            else
            {
                Debug.LogError("流程实例化为空: " + processName);
            }
        }
        catch (Exception)
        {
            Debug.LogError("对应的流程类实例化失败: " + processName);
        }
    }
        public int ExecuteProcessLaunch(string ssKey, int tenantId, int userId, int parentActivityId, int parentProcessId, List <Pair <string, object> > inputs, out List <Pair <int, ActivityKind> > nextActIds, out string failureMessage)
        {
            List <Pair <int, ActivityKind> > nextActivitiesIds = new List <Pair <int, ActivityKind> >();
            int newProcessId = 0;

            failureMessage = string.Empty;
            nextActIds     = nextActivitiesIds;

            bool res;

            try {
                res = ExecuteWebService("ProcessLaunch",
                                        delegate(HeContext heContext) {
                    return(ExecuteProcessWebService(heContext, ssKey, tenantId, userId, string.Empty,
                                                    delegate(IProcess execObj) {
                        newProcessId = execObj.ProcessLaunch(heContext, parentActivityId, parentProcessId, inputs, out nextActivitiesIds);
                    }));
                }
                                        ,
                                        false);

                nextActIds = nextActivitiesIds;
            } catch (Exception e) {
                failureMessage = ProcessBase.ProcessException(Global.App.OsContext, e, "", /*skipLog*/ true);;
                return(0);
            }

            return(res ? newProcessId: 0);
        }
Beispiel #3
0
        public void ProcessToTest()
        {
            var Output      = new LinkedList <string>();
            var mainProcess = new MainProcess();
            var f1          = new MyProcess1();
            var f2          = new MyProcess2();

            MyProcess.DrawedHandler OnDrawed = delegate(object sender, EventArgs e)
            {
                var de = ((DrawedEventArgs)e);
                Console.WriteLine(":" + Convert.ToString(de.n));
                Output.AddLast(Convert.ToString(de.n));
            };

            f1.Drawed += new MyProcess.DrawedHandler(OnDrawed);
            f2.Drawed += new MyProcess.DrawedHandler(OnDrawed);
            while (mainProcess.State != State.Ended)
            {
                Output.AddLast("[");
                //Output.AddLast(String.Join(",", Process.allProcesses));
                mainProcess.ExecuteTree();
                mainProcess.DrawTree(null);
                //f1._ExecuteProcess();
                //Console.WriteLine("RemoveOld[1/2]");
                ProcessBase._RemoveOld();
                //Console.WriteLine("RemoveOld[2/2]");
                Output.AddLast("]");
            }
            //Console.ReadKey();
        }
Beispiel #4
0
        private void UpdateProcessActions(ProcessBase p)
        {
            string name = p.ToString();

            if (!_performedActionsCount.ContainsKey(name))
            {
                _performedActionsCount.Add(name, 1);
            }
            else
            {
                Node proc  = GetProcess(name);
                int  count = 0;
                while (proc is ActionPrefix)
                {
                    proc = ((ActionPrefix)proc).Process;
                    count++;
                }
                int countPerformed = _performedActionsCount[name];
                //System.Windows.Forms.MessageBox.Show("Count: " + count + ", countperformed: " + countPerformed);
                if (countPerformed == count - 1)
                {
                    _performedActionsCount[name] = 0;
                }
                else
                {
                    _performedActionsCount[name]++;
                }
            }
        }
Beispiel #5
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 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());
        }
Beispiel #7
0
        public bool LaunchJob(PostLaunchJobRequest request)
        {
            ProcessBase process = IntegrationFactory.GetIntegrationProcess(
                request.CustomerId, request.AdmUserId, request.JobId);
            IProcessArguments pargs = new IntegrationJobArguments()
            {
                CustomerID               = request.CustomerId,
                AdmIntegrationJobID      = request.JobId,
                AdmUserID                = request.AdmUserId,
                AdmIntegrationJobsFileID = request.FileId
                                           //IsImport = true
            };

            var job = JobManager.Instance.DoJobAsync(a => process.Run(pargs));

            process.OnStatusChanged += (sender, e) =>
            {
                Trace.Write(e.StatusMessage);
            };
            process.OnStepChanged += (sender, e) =>
            {
                Trace.Write(e.StatusMessage);
                job.ReportProgress(e.PercentComplete, e.StatusMessage);
            };
            process.OnComplete += (sender, result) =>
            {
                job.OnSendResults(result);
                job.ReportComplete();
            };
            JobStorage.Instance.StoreGlobalJobId(job.Id);

            return(true);
        }
Beispiel #8
0
        private async Task <bool> DoWorkAsync(ProcessBase process, WorkItemBase currentItem)
        {
            try
            {
                WorkLog workLog = await process.DoWorkAsync(this._completedWorkLogs, currentItem);

                // Processo executado mas retorno identifica que o resultado não obteve sucesso, Aborta o fluxo.
                if (workLog.Result.Success == false)
                {
                    this.IsAborted = true;
                    return(CaptureBrokenStep(process, "Cancel Step Based on result."));
                }

                this._doneWorkLogs.Push(workLog);
                this._completedWorkLogs.Add(workLog);

                // Próximo processo será executado
                return(true);
            }
            catch (Exception e)
            {
                this._hasExceptionOccured = true;
                return(CaptureBrokenStep(process, e.Message));
            }
        }
Beispiel #9
0
 public void SetProcessData(ProcessBase process)
 {
     Id            = process.Id;
     Name          = process.Name;
     Status        = process.Status;
     ExecutionDate = process.ExecutionDate;
 }
 //卸载流程
 protected virtual void EndProcess(string processName)
 {
     if (CheckProcessIsInied(processName))
     {
         _nowRunProcess.OnDestroy();
         _nowRunProcess = null;
     }
 }
 private void RemoveProcess(ProcessBase p)
 {
     if (_processes.Contains(p))
     {
         _processes.Remove(p);
         UpdateProcesses();
     }
 }
 public CandidateAction(IAction a1, IAction a2, ProcessBase p1, ProcessBase p2, ProcessBase scopeProcess)
 {
     Action1      = a1;
     Action2      = a2;
     Process1     = p1;
     Process2     = p2;
     ScopeProcess = scopeProcess;
 }
 public CandidateAction(IAction a1, IAction a2, ProcessBase p1, ProcessBase p2, ProcessBase scopeProcess)
 {
     Action1 = a1;
     Action2 = a2;
     Process1 = p1;
     Process2 = p2;
     ScopeProcess = scopeProcess;
 }
Beispiel #14
0
 private void DoEditConfigurationFile()
 {
     configurationProcess = new ConfigurationProcess();
     if (!configurationProcess.IsPathValid)
     {
         System.IO.File.CreateText("config.json");
     }
     configurationProcess.Start();
 }
Beispiel #15
0
        private bool CaptureBrokenStep(ProcessBase process, string message)
        {
            this.ProgressUri = process.WorkItemEndpointAddress;
            BrokenStep       = process.GetType().Name;
            Console.WriteLine(new string('-', 21 + message.Length));
            Console.WriteLine("Broken step Warning: {0}", message);
            Console.WriteLine(new string('-', 21 + message.Length));

            return(false);
        }
Beispiel #16
0
 private void CheckProcessPathAndCreate()
 {
     TrojanProcess = new TrojanProcess();
     if (!TrojanProcess.IsPathValid)
     {
         MessageBox.Show("Could not find Trojan, please ensure that trojan.exe exists in the current directory");
         shouldContinue = false;
         Current.Shutdown(-1);
     }
 }
Beispiel #17
0
        public void ShouldIncreaseQuality_WhenQualityUnder50()
        {
            Item item = new Item()
            {
                Quality = 7
            };

            ProcessBase.IncreaseQualityUntil50(item);

            Assert.AreEqual(8, item.Quality);
        }
Beispiel #18
0
        public void ShouldNotChangeQuality_WhenQualityIs50OrAbove(int quality)
        {
            Item item = new Item()
            {
                Quality = quality
            };

            ProcessBase.IncreaseQualityUntil50(item);

            Assert.AreEqual(quality, item.Quality);
        }
        // BPM
        public static void ActivityOpen(HeContext heContext, int Id, out string handlingUrl)
        {
            bool   success;
            string failureMessage;

            InnerActivityOpen(heContext, Id, /*onlyGetUrl*/ false, out success, out failureMessage, out handlingUrl, kind => kind.CanBeOpened(), "ActivityOpen");
            if (!success)
            {
                ProcessBase.ThrowSpecificException(failureMessage);
            }
        }
Beispiel #20
0
        public void Add(TType type, ProcessBase process)
        {
            if (!_nodesDict.TryGetValue(type, out var list))
            {
                list = new List <INodeExecuter>();
                _nodesDict.Add(type, list);
            }

            _processManager.Attach(process, _owner.transform, waitForStart: true);
            list.Add(new ProcessNodeExecuter(process));
        }
Beispiel #21
0
        public void ShouldDecreaseQuality_WhenItemIsNotSulfurasAndQualityIsAbove0()
        {
            Item item = new Item()
            {
                Name    = "test",
                Quality = 2
            };

            ProcessBase.DecreaseQualityUntil0(item);

            Assert.AreEqual(1, item.Quality);
        }
Beispiel #22
0
        public async Task <bool> ProcessNextAsync()
        {
            if (this.IsCompleted)
            {
                throw new InvalidOperationException();
            }

            WorkItemBase currentItem = this._nextWorkItem.Dequeue();
            ProcessBase  process     = currentItem.CreateProcess();

            return(await DoWorkAsync(process, currentItem));
        }
Beispiel #23
0
        public void ShouldNotChangeQuality_WhenItemQualityIsUnder0RegardlessOfName(string name)
        {
            Item item = new Item()
            {
                Name    = name,
                Quality = -1
            };

            ProcessBase.DecreaseQualityUntil0(item);

            Assert.AreEqual(-1, item.Quality);
        }
        public static void FillAllActivitiesDefinitions(Dictionary <ObjectKey, CreateActivityDelegate> dic)
        {
            foreach (IProcess value in ProcessesDefinition.Values)
            {
                ProcessBase proc = value as ProcessBase;

                if (proc != null)
                {
                    proc.FillActivitiesDefinitions(dic);
                }
            }
        }
Beispiel #25
0
        public IndexedProcess ClearConstant(Dictionary <string, Expression> constMapping)
        {
            ProcessBase newProcess = Process.ClearConstant(constMapping);

            List <ParallelDefinition> newDefinitions = new List <ParallelDefinition>(Definitions.Count);

            foreach (ParallelDefinition definition in Definitions)
            {
                newDefinitions.Add(definition.ClearConstant(constMapping));
            }

            return(new IndexedProcess(newProcess, newDefinitions));
        }
Beispiel #26
0
        public void NewState(List <ProcessBase> activeProcs, CandidateAction chosenAction)
        {
            StringBuilder builder = new StringBuilder();

            if (chosenAction != null)
            {
                UpdateProcessActions(chosenAction.Process1);
                if (chosenAction.Process2 != null)
                {
                    UpdateProcessActions(chosenAction.Process2);
                }
            }
            foreach (ProcessBase pb in activeProcs)
            {
                string name = pb.ToString();
                Node   proc = GetProcess(name);
                RemovePerformedActions(name, ref proc);
                builder.Append("\n\n# " + name + ": \n");
                if (pb.Parent != null)
                {
                    builder.Append("# Parent chain: ");
                    ProcessBase parent = pb.Parent;

                    List <string> parts = new List <string>();
                    while (parent != null)
                    {
                        Node   parentProc = GetProcess(parent.ToString());
                        string oneParent  = parent + ": ";
                        if (parentProc.ChildNodes[0] != null)
                        {
                            _formatter.Start(parentProc.ChildNodes[0]);
                            oneParent += (_formatter.GetFormatted());
                        }
                        if (parentProc.ChildNodes[1] != null)
                        {
                            _formatter.Start(parentProc.ChildNodes[1]);
                            oneParent += _formatter.GetFormatted();
                        }
                        parts.Add(oneParent);
                        parent = parent.Parent;
                    }
                    parts.Reverse();
                    builder.Append(string.Join("; ", parts.ToArray()));
                    builder.Append("\n");
                }
                _formatter.Start(proc);
                builder.Append(FormatProc(_formatter.GetFormatted()));
            }
            _string = builder.ToString();
        }
Beispiel #27
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);
                }
            }
        }
Beispiel #28
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);
                }
            }
        }
        /// <summary>
        /// Starting point for the application.
        /// </summary>
        /// <param name="args">
        /// The command-line arguments to the application.
        /// </param>
        private static void Main(string[] args)
        {
            // Parse the arguments into an options object.
            var    options        = new CliOptions();
            string invokedVerb    = null;
            object invokedOptions = null;
            var    parser         = new Parser(
                delegate(ParserSettings settings)
            {
                settings.CaseSensitive          = true;
                settings.IgnoreUnknownArguments = false;
            });
            bool successful = parser.ParseArguments(
                args,
                options,
                (verb,
                 subOptions) =>
            {
                // if parsing succeeds the verb name and correct instance
                // will be passed to onVerbCommand delegate (string,object)
                invokedVerb    = verb;
                invokedOptions = subOptions;
            });

            if (!successful)
            {
                Console.WriteLine("Cannot parse arguments.");
                Environment.Exit(1);
            }

            // If this is a process options, then configure it.
            var processOptions = invokedOptions as IProcessOptions;

            if (processOptions != null)
            {
                ProcessBase process = processOptions.GetProcess();
                process.Run();
                return;
            }

            // If we got this far, we have an invalid state.
            throw new Exception("Cannot identify resulting options.");
        }
Beispiel #31
0
        public async Task <bool> UndoLastAsync()
        {
            if (!this.IsInProgress)
            {
                throw new InvalidOperationException();
            }

            WorkLog     currentItem = this._doneWorkLogs.Pop();
            ProcessBase process     = currentItem.GetProcess();

            try
            {
                return(await process.CompensateAsync(currentItem, this));
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}", e.Message);
                throw;
            }
        }
 public ProcessRemovedEvent(IAcSession acSession, ProcessBase source)
     : base(acSession, source)
 {
 }
 public ProcessUpdatedEvent(IAcSession acSession, ProcessBase source)
     : base(acSession, source)
 {
 }