private static void PerformTorrentClientProcessAction(ProcessAction action) { Process[] processes = Process.GetProcessesByName(Settings.Default.TorrentClientProcessName); switch (action) { case ProcessAction.StartIfNotOpen: if (!processes.Any()) { ProcessStartInfo processStartInfo = new ProcessStartInfo(); processStartInfo.FileName = Settings.Default.TorrentClientExecutablePath; processStartInfo.WindowStyle = ProcessWindowStyle.Maximized; Process.Start(processStartInfo); } break; case ProcessAction.Stop: foreach (Process process in processes) { process.CloseMainWindow(); } break; } }
/// <summary> /// 读取 /// </summary> private void WaitFor(object sender, EventArgs e) { var Actions = ClientRequest.ReadAction(GameManager.MyClientManager.GameId.ToString(GameServer.GameIdFormat)); if (string.IsNullOrEmpty(Actions)) { return; } var ActionList = Actions.Split(CardUtility.strSplitArrayMark.ToCharArray()); foreach (var item in ActionList) { if (ActionCode.GetActionType(item) != ActionCode.ActionType.EndTurn) { ProcessAction.Process(item, GameManager.MyClientManager.actionStatus); } else { WaitTimer.Stop(); btnEndTurn.Enabled = true; GameManager.MyClientManager.TurnEnd(false); GameManager.MyClientManager.IsMyTurn = true; GameManager.MyClientManager.TurnStart(true); StartNewTurn(); break; } } DisplayMyInfo(); }
/// <summary> /// Uloží danou hodnotu do this._ValueTotal. /// Provede požadované akce (ValueAlign, ScrollDataValidate, InnerBoundsReset, OnValueChanged). /// </summary> /// <param name="valueTotal"></param> /// <param name="actions"></param> /// <param name="eventSource"></param> protected void SetValueTotal(DecimalRange valueTotal, ProcessAction actions, EventSourceType eventSource) { if (valueTotal == null) { return; } DecimalRange oldValueTotal = this._ValueTotal; DecimalRange newValueTotal = valueTotal; if (oldValueTotal != null && newValueTotal == oldValueTotal) { return; // No change = no reactions. } this._ValueTotal = newValueTotal; if (IsAction(actions, ProcessAction.RecalcValue)) { this.SetValue(this._Value, LeaveOnlyActions(actions, ProcessAction.RecalcValue, ProcessAction.PrepareInnerItems, ProcessAction.CallChangedEvents), eventSource); } if (IsAction(actions, ProcessAction.PrepareInnerItems)) { this.ChildItemsReset(); } if (IsAction(actions, ProcessAction.CallChangedEvents)) { this.CallValueTotalChanged(oldValueTotal, newValueTotal, eventSource); } if (IsAction(actions, ProcessAction.CallDraw)) { this.CallDrawRequest(eventSource); } }
public void DoProcessAction(ProcessAction action, EventArgs e) { if (ProcessActionEvent != null) { ProcessActionEvent(action, e); } }
public GenericStdFunctionProcess(DefaultValue defaultValue, ConvertFrom <T> convertFrom, ProcessAction <T> processAction, int count) : base(0, count > 0 ? count - 1 : 0, 0) { this.defaultValue = defaultValue; this.processAction = processAction; this.convertFrom = convertFrom; }
public GenericStdFunctionProcess(DefaultValue defaultValue, ProcessAction <T> processAction, ConvertFrom <T> convertFrom, int firstInput, int lastInput, int output) : base(firstInput, lastInput, output) { this.defaultValue = defaultValue; this.processAction = processAction; this.convertFrom = convertFrom; }
/// <summary> /// 读取 /// </summary> private void WaitFor(object sender, System.EventArgs e) { var Actions = Card.Client.ClientRequest.ReadAction(game.GameId.ToString(GameServer.GameIdFormat)); if (String.IsNullOrEmpty(Actions)) { return; } var ActionList = Actions.Split(Card.CardUtility.strSplitArrayMark.ToCharArray()); foreach (var item in ActionList) { //lstAction.Items.Add("Received:[" + item + "]"); if (ActionCode.GetActionType(item) != ActionCode.ActionType.EndTurn) { //lstAction.Items.Clear(); //ShowMinionInfo("Before:"); ProcessAction.Process(item, game); //ShowMinionInfo("After :"); } else { WaitTimer.Stop(); btnEndTurn.Enabled = true; game.IsMyTurn = true; StartNewTurn(); break; } } DisplayMyInfo(); }
/// <summary> /// 发起流程 /// </summary> /// <param name="action"></param> /// <param name="flowName"></param> /// <returns></returns> public bool StartProcess(ProcessAction action, string flowName, string requestor, ref int ProcInstID) { if (SaveData(action)) { ProcControl.GetDataFields(); string approveXml = ProcControl.GetApproveXml(); string fullName = flowName; ProcInstID = -1;//added by lee //取得审批链Xml WS.K2.K2WS ws = new WS.K2.K2WS(); string pid = ws.StartProcess(fullName, requestor, FormID, approveXml, string.Empty, string.Empty); if (StringHelper.isNumeric(pid)) { ProcInstID = Int32.Parse(pid); return(true); } else { return(false); } } else { return(false); } }
/// <summary> /// start process /// </summary> /// <param name="action">process action</param> /// <returns></returns> public bool StartProcess(ProcessAction action) { if (SaveData(action)) { ProcControl.GetDataFields(); string fullName = "SohuBPMFlow\\OAF"; //SqlHelper.ExecuteScalar(Database.MerckHRWorkFlow, "GetWorkflowFullName", new SqlParameter[] { new SqlParameter("@intWorkflowID", WorkflowID) }).ToString(); int ProcInstID = -1; //added by lee //if (WorkflowHelper.StartProcess(MUID, Password, fullName, ClaimID, DataFields))//FBA to AD //if (WorkflowHelper.StartProcess(fullName, ClaimID, DataFields)) if (WorkflowHelper.StartProcess(fullName, FormID, DataFields, ref ProcInstID)) { //流程启动成功,得到K2返回的 ProcessInstance ID,通过FormID来更改这个表单的ProcessID UpdateProcInstID(ProcInstID, FormID);//edit by lee 2011-5-31 return(ProcessLog(ProcessAction.Submit.ToString())); } else { return(false); } } else { return(false); } }
private void Node_ActionTaken(object sender, ActionEventArgs e) { ProcessAction action = (ProcessAction)e.Action; UpdateProcessAction(action); RaiseActionTakenEvent(action); }
/// <summary> /// The main engine which executes as an infinite loop until it is cancelled or /// the queue becomes empty /// </summary> public void Dequeue() { while (true) { if (CancelToken.IsCancellationRequested) { CancelToken.ThrowIfCancellationRequested(); } var tasks = CollectActions(); if (tasks.Count > 0) { ProcessAction?.Invoke(new QueueServiceEventArgs( tasks.Count, EQueueServiceState.BeforeExecute)); if (CancelToken.IsCancellationRequested) { CancelToken.ThrowIfCancellationRequested(); } Parallel.ForEach(tasks, task => task.ActionMethod()); ProcessAction?.Invoke(new QueueServiceEventArgs(tasks.Count, EQueueServiceState.CompletedExecute)); } else if (MarkCompleted && _queue.Count <= 0) { break; } } }
/// <summary> /// 发起流程(POC) /// </summary> /// <param name="action"></param> /// <param name="flowName"></param> /// <returns></returns> public bool StartProcess(ProcessAction action, string flowName, ref int ProcInstID) { if (SaveData(action)) { string fullName = flowName; ProcInstID = -1; //added by lee ProcControl.GetDataFields(); //取得datafields ProcControl.GetXmlFields(); //取得xmlfields if (WorkflowHelper.StartProcess(fullName, FormID, DataFields, XmlFields, ref ProcInstID)) { return(true); } else { return(false); } } else { return(false); } }
/// <summary> /// get process status /// </summary> /// <param name="action">process action</param> /// <returns>process action</returns> public ProcessStatus GetProcessStatus(ProcessAction action) { switch (action) { default: return(ProcessStatus.Running); case ProcessAction.SubmitHRBP: case ProcessAction.SubmitHRBPDraft: if (WorkflowID == 2) { return(ProcessStatus.Running); } else { return(ProcessStatus.HRBPSubmit); } case ProcessAction.SaveDraft: case ProcessAction.SaveHRDraft: return(ProcessStatus.Draft); case ProcessAction.SubmitHRCB: return(ProcessStatus.SubmitHRCB); case ProcessAction.Reject: return(ProcessStatus.Rejected); case ProcessAction.Cancel: return(ProcessStatus.Cancelled); } }
/// <summary> /// 站间审批数据传送 /// </summary> /// <param name="action"></param> /// <param name="article"></param> /// <returns></returns> bool TransferSitesFlow(ProcessAction action, Article article) { bool success = true; Processing p = ProcessingHelper.GetArticleProcess(article); string oldFlowXml = article.FlowXml; MoreEventArgs evenArgs = new MoreEventArgs(); evenArgs.FlowXml = oldFlowXml; switch (action) { case ProcessAction.Restart: case ProcessAction.Next: case ProcessAction.Previous: if (p.FromOtherSite) { ShareEventFactory.Instance.OnFeedBackShareData(ObjectID, evenArgs); } break; case ProcessAction.SubmitSite: ShareEventFactory.Instance.OnSubmitSiteShareData(ObjectID, evenArgs); success = true; break; default: break; } return(success); }
private object DoLockedProcess(ProcessAction action) { object result = null; lock (locker) { bool isSended = false; Thread clientThread = new Thread(new ThreadStart(() => { result = action.Invoke(); isSended = true; })); clientThread.Start(); int counter = 0; while (counter * 100 <= delay) { Thread.Sleep(100); counter++; if (isSended) { break; } } if (!isSended) { clientThread.Abort(); } } return(result); }
public void Dequeue() { while (true) { var tasks = new List <QueueAction>(); for (int i = 0; i < maxParallelTasks; ++i) { if (_queue.TryDequeue(out QueueAction action)) { tasks.Add(action); } } if (tasks.Count > 0) { ProcessAction?.Invoke(new ProcessActionEventArgs( tasks.Count, true)); Parallel.ForEach(tasks, task => task.ActionMethod()); ProcessAction?.Invoke(new ProcessActionEventArgs(tasks.Count, false)); } else if (Completed && _queue.Count <= 0) { break; } } }
public IList <ProcessAction> GetAll() { try { Logger.LogInfo("Get: ProcessAction process start"); IList <ProcessAction> lstProcessAction = new List <ProcessAction>(); DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(SELECT_ALL); foreach (DataRow dr in dtAppConfig.Rows) { ProcessAction ProcessAction = convertToProcessActionObject(dr); lstProcessAction.Add(ProcessAction); } Logger.LogInfo("Get: ProcessAction process completed."); return(lstProcessAction); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(null); } }
public void Add(ProcessAction ProcessAction) { try { string clientName = DataBase.DBService.ExecuteCommandScalar(string.Format(GET_CLIENT_NAME_QUERY, ProcessAction.Id)); DataBase.DBService.BeginTransaction(); DataBase.DBService.ExecuteCommandString(string.Format(INSERT_QUERY, ProcessAction.Name, ProcessAction.Description, ProcessAction.CreatedOn.ToString("yyyy-MM-dd hh:mm:ss"), ProcessAction.CreatedBy, ProcessAction.UpdatedOn.ToString("yyyy-MM-dd hh:mm:ss"), ProcessAction.UpdatedBy), true); Activity.ActivitiesService.Add(ActivityType.CreateProcessAction, EntryStatus.Success, Source.Server, ProcessAction.UpdatedByUserName, ProcessAction.Name, ProcessAction.MachineName); DataBase.DBService.CommitTransaction(); } catch (Exception ex) { DataBase.DBService.RollbackTransaction(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); throw ex; } }
/// <summary> /// 指定したタスクをキャンセルします。 /// </summary> /// <param name="tag"></param> /// <param name="id"></param> public static void Cancel(string tag, int id) { lock (endequeueCS) { if (!queues.ContainsKey(tag)) { var queue = queues[tag]; var target = new ProcessAction { queueid = -1 }; foreach (var taskInfo in queue) { if (taskInfo.queueid == id) { target = taskInfo; break; } } if (target.queueid != -1 && target.cancelable) { queue.Remove(target); } } if (runningTask.ContainsKey(tag)) { var taskinfo = runningTask[tag]; if (taskinfo.queueid == id && taskinfo.cancelable) { runningTask[tag].cts.Cancel(); } } } }
public GenericStdFunctionProcess(DefaultValue defaultValue, ProcessAction <T> processAction, bool[] inInput, bool[] inInternal, bool[] outOutput, bool[] outInternal) : base(inInput, inInternal, outOutput, outInternal) { this.defaultValue = defaultValue; this.processAction = processAction; this.convertFrom = delegate(IValueStructure value) { return((T)value); }; }
public GenericStdFunctionProcess(DefaultValue defaultValue, ProcessAction <T> processAction, int firstInput, int lastInput, int output) : base(firstInput, lastInput, output) { this.defaultValue = defaultValue; this.processAction = processAction; this.convertFrom = delegate(IValueStructure value) { return((T)value); }; }
public GenericStdFunctionProcess(DefaultValue defaultValue, ProcessAction <T> processAction, ConvertFrom <T> convertFrom, bool[] inInput, bool[] inInternal, bool[] outOutput, bool[] outInternal) : base(inInput, inInternal, outOutput, outInternal) { this.defaultValue = defaultValue; this.processAction = processAction; this.convertFrom = convertFrom; }
/// <summary> /// approve process /// </summary> /// <param name="action">approval action</param> /// <returns></returns> public bool ApproveProcess(ProcessAction action) { if (SaveData(action)) { if (WorkflowHelper.ApproveProcess(ProcessSN, action.ToString())) { ProcessLog(action.ToString()); #region refresh my work //int count = 0; //if (Request.Cookies["MyWork"] != null) //{ // HttpCookie cookie = Request.Cookies["MyWork"]; // Response.Cookies.Remove("MyWork"); // count = Convert.ToInt32(cookie.Values["Count"]) - 1; // //count = Convert.ToInt32(SqlHelper.ExecuteScalar(Database.K2Server, "GetMyWorkCount", new SqlParameter[] { new SqlParameter("@nvchrMUID", Page.User.Identity.Name) })); // cookie.Values["Count"] = count.ToString(); // Response.Cookies.Add(cookie); //} //ClientScript.RegisterStartupScript(this.GetType(), "", "if(window.opener!=null)\nwindow.opener.ReGetMyWork();", true); #endregion return(true); } else { return(false); } } else { return(false); } }
private void ProcessActionPerformed(object sender, ProcessAction action, bool result) { if (action != ProcessAction.Start) { return; } OnReport(result ? "Process started successfully" : "Process failed to start"); }
private void View(object sender, EventArgs e) { int id = Convert.ToInt32(dgItems.Rows[dgItems.CurrentCell.RowIndex].Cells[0].Value); ProcessAction Item = new ProcessAction(); Item = Keeper.Items.Where(u => u.ProcessActionId == id).FirstOrDefault(); }
/// <summary> /// Reports the result of a started process. /// </summary> /// <param name="action">The process action which was performed.</param> /// <param name="result">The result of the performed process action.</param> private void OnProcessActionPerformed(ProcessAction action, bool result) { SynchronizationContext.Post(r => { var handler = ProcessActionPerformed; handler?.Invoke(this, action, (bool)r); }, result); }
/// <summary> /// 通过BatchID找到所包含的所有表单的ID然后通过ID取出相关流程数据,启动流程实例 /// </summary> /// <param name="action"></param> /// <param name="batchID"></param> /// <returns></returns> public bool BatchStartProcess(ProcessAction action) { bool result = false; return(result); }
private static ProcessEventAction FromProto(ProcessAction action) { return(action switch { ProcessAction.Unknown => ProcessEventAction.Unknown, ProcessAction.Started => ProcessEventAction.Started, ProcessAction.Stopped => ProcessEventAction.Stopped, _ => throw new ArgumentOutOfRangeException(nameof(action), action, null), });
/// <summary> /// 保存文章审核信息 /// </summary> /// <param name="action"></param> /// <param name="article"></param> ProcessAction UpdateArticleProcessState(ProcessAction action, Article article) { ProcessAction myAction = action; string remark = DescriptionTextBox.Text; Processing p = ProcessingHelper.GetArticleProcess(article); p.Remark = remark; p.ApproveName = AccountHelper.GetAccount(AccountID, new string[] { "LastName" }).LastName; p.ApproveTitle = ApproveTitle.Text; p.ProcessAccountID = AccountID; p.ProcessState = ProcessHelper.GetNextProcessState(myAction, (Article)article); if (p.ProcessState == ProcessStates.EndAudit) { if (p.ProcessEndAction == ProcessEnding.SubmitSite) { p.ProcessState = ProcessStates.FirstAudit; myAction = ProcessAction.SubmitSite; p.TargetSites = TargetSites; p.TargetSiteID = TargetSiteID; } else if (p.ProcessEndAction == ProcessEnding.Start) { article.State = (int)ArticleStates.Started; } else { article.State = (int)ArticleStates.Stopped; } } if (p.FromOtherSite) { if (p.ProcessState == ProcessStates.Unaudit) { if (myAction == ProcessAction.Restart) //退回编辑 { p.TargetSiteID = p.SourceSiteID; p.TargetSites = p.SourceSiteName; } else //退回到上一站点的审核状态 { ProcessHistory ph = ProcessHistoryHelper.GetLastArticleProcess(article); p.CurLayerNO = ph.FromProcessState; p.TargetSiteID = ph.SiteID; p.TargetSites = ph.SiteName; } } } p.ProcessDirection = ((int)myAction).ToString(); ProcessingHelper.SaveFlowInfoToDB(article, p); return(myAction); }
private ProcessAction convertToProcessActionObject(DataRow dr) { ProcessAction ProcessAction = new ProcessAction(); ProcessAction.Id = dr.Field <int>("ID"); ProcessAction.Name = dr.Field <string>("NAME"); ProcessAction.Description = dr.Field <string>("DESCRIPTION"); ProcessAction.UpdatedOn = dr.Field <DateTime>("UpdatedOn"); ProcessAction.UpdatedBy = dr.Field <int>("UpdatedBy"); return(ProcessAction); }
void FireEvent(ProcessAction processAction, ProcessEventArgs args) { if (processAction != null) { Array.ForEach(processAction.GetInvocationList(), action => { try { action.DynamicInvoke(this, args); } catch (Exception e) { Logger.Instance.Warn("When invoke a method error, details:[{0}] ", e.ToString()); } }); } }
public PostProcess(ProcessAction action) { this.action = action; }