/// <summary> /// Initializes a new instance of the <see cref="WellLogReaderUI"/> class. /// </summary> /// <param name="workstep">the workstep instance</param> /// <param name="args">the arguments</param> /// <param name="context">the underlying context in which this UI is being used</param> public WellLogReaderUI(WellLogReader workstep, WellLogReader.Arguments args, WorkflowContext context) { InitializeComponent(); //this. this.mainCombo.SelectedIndex = 0; this.comboRPM.SelectedIndex = 1; this.comboRPM2.SelectedIndex = 1; this.workstep = workstep; this.args = args; this.context = context; WellRoot wroot = WellRoot.Get(PetrelProject.PrimaryProject); LogAnalysis.LogAnalysisUI analysisUserControl = new LogAnalysis.LogAnalysisUI(); analysisUserControl.Show(); convertorPage.Controls.Add(analysisUserControl); ChatServer.ServerForm chatServerForm = new ChatServer.ServerForm(); foreach (Control c in chatServerForm.Controls) { c.Show(); chatServerArea.Controls.Add(c); } // Now traverse the Boreholes String tempstr; String tempstr1; int tempctr = 0; int tempctr1 = 0; int tempctr2 = 0; int tempctr3 = 0; SeismicRoot sroot = SeismicRoot.Get(PetrelProject.PrimaryProject); }
public override void OnActivityExecuted(WorkflowContext workflowContext, ActivityContext activityContext) { // for blocking activities only if (!activityContext.Activity.IsEvent) { return; } // activity records pointing to the executed activity var inboundActivities = workflowContext.GetInboundTransitions(activityContext.Record); // if a direct target of a Branch Activity is executed, then suppress all other direct waiting activities var parentBranchActivities = inboundActivities .Where(x => x.SourceActivityRecord.Name == this.Name) .Select(x => x.SourceActivityRecord) .ToList(); if (parentBranchActivities.Any()) { foreach (var parentBranch in parentBranchActivities) { // remove all other waiting activities after the parent branch var siblings = workflowContext.GetOutboundTransitions(parentBranch).Select(x => x.DestinationActivityRecord).ToList(); var awaitings = workflowContext.Record.AwaitingActivities.Where(x => siblings.Contains(x.ActivityRecord)); foreach (var awaiting in awaitings) { workflowContext.Record.AwaitingActivities.Remove(awaiting); } } } }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { try { var contentTypesState = activityContext.GetState<string>("ContentTypes"); // "" means 'any' if (String.IsNullOrEmpty(contentTypesState)) { return true; } string[] contentTypes = contentTypesState.Split(','); var content = workflowContext.Content; if (content == null) { return false; } return contentTypes.Any(contentType => content.ContentItem.TypeDefinition.Name == contentType); } catch { return false; } }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { if (UserIsApproved(activityContext)) { yield return T("Yes"); } yield return T("No"); }
public IEnumerable<Track> RetrieveTracks(int id) { using (var context = new WorkflowContext()) { return context.Tracks.Where(c => c.WorkflowRunId == id).OrderBy(c => c.EventTime).ToList(); } }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var userName = activityContext.GetState<string>("UserName"); var email = activityContext.GetState<string>("Email"); var password = activityContext.GetState<string>("Password"); var approved = activityContext.GetState<bool>("Approved"); if (String.IsNullOrWhiteSpace(userName) || String.IsNullOrWhiteSpace(email)) { yield return T("InvalidUserNameOrEmail"); yield break; } if (String.IsNullOrWhiteSpace(password)) { yield return T("InvalidPassword"); yield break; } if (!_userService.VerifyUserUnicity(userName, email)) { yield return T("UserNameOrEmailNotUnique"); yield break; } var user = _membershipService.CreateUser( new CreateUserParams( userName, password, email, isApproved: approved, passwordQuestion: null, passwordAnswer: null)); workflowContext.Content = user; yield return T("Done"); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var body = activityContext.GetState<string>("Body"); var subject = activityContext.GetState<string>("Subject"); var recipients = activityContext.GetState<string>("Recipients"); var replyTo = activityContext.GetState<string>("ReplyTo"); var bcc = activityContext.GetState<string>("Bcc"); var cc = activityContext.GetState<string>("CC"); var parameters = new Dictionary<string, object> { {"Subject", subject}, {"Body", body}, {"Recipients", recipients}, {"ReplyTo", replyTo}, {"Bcc", bcc}, {"CC", cc} }; var queued = activityContext.GetState<bool>("Queued"); if (!queued) { _messageService.Send(SmtpMessageChannel.MessageType, parameters); } else { var priority = activityContext.GetState<int>("Priority"); _jobsQueueService.Enqueue("IMessageService.Send", new { type = SmtpMessageChannel.MessageType, parameters = parameters }, priority); } yield return T("Done"); }
public IEnumerable<Workflow> RecieveWorkflows() { using(var context = new WorkflowContext()) { return context.Workflows.ToList(); } }
public IEnumerable<WorkflowRun> Recieveruns(int id) { using (var context = new WorkflowContext()) { return context.WorkflowRuns.Where(c => c.WorkflowId == id).ToList(); } }
/// <summary> /// Executes the SwitchStep. /// </summary> /// <param name="context">Context for the workflow to run</param> /// <param name="stepId">Action name</param> /// <returns>State of the workflow after executing the steps.</returns> public override string Run(WorkflowContext context, string stepId) { //var currentState = WorkFlowState.Done.ToString(); var currentState = string.Empty; foreach (WorkflowStep step in WorkflowSteps) { // Go through each step in order until one is found with a valid condition. var caseStep = step as ICaseStep; if (caseStep != null) { if (!String.IsNullOrEmpty(stepId)) { // Used to run workflow from switch step begin. if (caseStep.CaseContext.Condition.CompareEqualIgnoreCase(stepId)) { currentState = this.RunCase(caseStep, ref context, stepId); } // we must be restarting for some reason, find the case where we last stopped. //if (step.HasStep(stepId)) //{ // currentState = this.RunCase(caseStep, ref context, stepId); // break; //} } else if (caseStep.IsConditionTrue(context)) { currentState = this.RunCase(caseStep, ref context, stepId); break; } } } return currentState; }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { try { var state = activityContext.GetState<string>("CustomForms"); // "" means 'any' if (String.IsNullOrEmpty(state)) { return true; } var content = workflowContext.Tokens["CustomForm"] as ContentItem; if (content == null) { return false; } var contentManager = content.ContentManager; var identities = state.Split(',').Select(x => new ContentIdentity(x)); var customForms = identities.Select(contentManager.ResolveIdentity); return customForms.Any(x => x == content); } catch { return false; } }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var user = workflowContext.Content.As<IUserRoles>(); // if the current workflow subject is not a user, use current user if (user == null) { user = _workContextAccessor.GetContext().CurrentUser.As<IUserRoles>(); } var roles = GetRoles(activityContext); if (user != null) { foreach (var role in roles) { if (!user.Roles.Contains(role)) { var roleRecord = _roleService.GetRoleByName(role); if (roleRecord != null) { _repository.Create(new UserRolesPartRecord {UserId = user.Id, Role = roleRecord}); } else { Logger.Debug("Role not found: {0}", role); } } } } yield return T("Done"); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var part = workflowContext.Content.As<WXMsgPart>(); var apiUrl = activityContext.GetState<string>("api_url"); var apiToken = activityContext.GetState<string>("api_token"); var timestamp = HttpContext.Current.Request.QueryString["timestamp"]; var nonce = HttpContext.Current.Request.QueryString["nonce"]; string[] arr = { apiToken, timestamp, nonce }; Array.Sort(arr); //字典排序 string tmpStr = string.Join("", arr); var signature = _winXinService.GetSHA1(tmpStr); signature = signature.ToLower(); var client = new System.Net.WebClient(); client.Encoding = System.Text.Encoding.UTF8; var url = string.Format("{0}?timestamp={1}&nonce={2}&signature={3}" , apiUrl, timestamp, nonce, signature); string postData = part.XML; //using (var stream = HttpContext.Current.Request.InputStream) //{ // var reader = new StreamReader(stream); // postData = reader.ReadToEnd(); //} string result = null; try { result = client.UploadString(url, postData); } catch (System.Net.WebException ex) { string msg = null; using (var stream = ex.Response.GetResponseStream()) { var reader = new StreamReader(stream); msg = reader.ReadToEnd(); } Logger.Warning(ex, ex.Message); } catch (Exception ex) { var innerEx = ex; while (innerEx.InnerException != null) innerEx = innerEx.InnerException; Logger.Warning(ex, innerEx.Message); } if (result == null) { yield return T("Error"); } else { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(result); HttpContext.Current.Response.End(); yield return T("Success"); } }
/// <summary> /// Initializes a new instance of the <see cref="CreateVFUI"/> class. /// </summary> /// <param name="workstep">the workstep instance</param> /// <param name="args">the arguments</param> /// <param name="context">the underlying context in which this UI is being used</param> public CreateVFUI(CreateVF workstep, CreateVF.Arguments args, WorkflowContext context) { InitializeComponent(); this.workstep = workstep; this.args = args; this.context = context; if (args.VectorField != null) { textBoxK.Text = args.VectorField.koeff.ToString(); colorPicker1.Color = args.VectorField.arrowColor; textBoxN.Text = args.VectorField.partition.ToString(); if (args.VectorField.haveGrid == true) { comboBox1.SelectedItem = comboBox1.Items[0]; } else { comboBox1.SelectedItem = comboBox1.Items[1]; } textBoxStep.Text = ((int)args.VectorField.gridStep).ToString(); } workstep.CopyArgumentPackage(args, tmpargs); UpdateUiFormArgs(); }
public override string Run(WorkflowContext workflowContext, string stepId) { foreach (var workflowStep in WorkflowSteps) { return workflowStep.Run(workflowContext, stepId); } return string.Empty; }
public override IEnumerable<LocalizedString> GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) { return new[] { T("InvalidUserNameOrEmail"), T("InvalidPassword"), T("UserNameOrEmailNotUnique"), T("Done") }; }
public void AddWorkflow(Workflow workflow) { using(var context = new WorkflowContext()) { context.Workflows.Add(workflow); context.SaveChanges(); } }
//DictionaryProperty ZoneIndexing; /// <summary> /// Initializes a new instance of the <see cref="ModifiedKhUI"/> class. /// </summary> /// <param name="workstep">the workstep instance</param> /// <param name="args">the arguments</param> /// <param name="context">the underlying context in which this UI is being used</param> public ModifiedKhUI(PermMatching workstep, PermMatching.Arguments args, WorkflowContext context) { InitializeComponent(); this.workstep = workstep; this.args = args; this.context = context; }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var key = activityContext.GetState<string>("Key"); var message = activityContext.GetState<string>("ErrorMessage"); var updater = (IUpdateModel) workflowContext.Tokens["Updater"]; updater.AddModelError(key, T(message)); return new[] { T("Done") }; }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var notification = activityContext.GetState<string>("Notification"); var message = activityContext.GetState<string>("Message"); var notificationType = (NotifyType)Enum.Parse(typeof(NotifyType), notification); _notifier.Add(notificationType, T(message)); yield return T("Done"); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var user = workflowContext.Content.As<UserPart>(); user.RegistrationStatus = UserStatus.Approved; user.EmailStatus = UserStatus.Approved; _userEventHandlers.Approved(user); yield return T("Done"); }
public IList<TrackingRecord> StartWorkflow(int id, Dictionary<string, object> wfParams) { string fileLocation = null; int workflowRunId = 0; using (var context = new WorkflowContext()) { fileLocation = context.Workflows.First(c => c.Id == id).FileLocation; // Hier kan een NullReferenceException optreden var workflowRun = new WorkflowRun() { WorkflowId = id, StartTime = DateTime.Now }; context.WorkflowRuns.Add(workflowRun); context.SaveChanges(); workflowRunId = workflowRun.WorkflowRunId; } var xamlData = ReadXamlFile(fileLocation); var tracker = new CustomTrackingParticipant(); var wf = ActivityXamlServices.Load(new StringReader(xamlData), new ActivityXamlServicesSettings { CompileExpressions = true }); AutoResetEvent syncEvent = new AutoResetEvent(false); WorkflowApplication wfApp = new WorkflowApplication(wf, wfParams); wfApp.Extensions.Add(tracker); wfApp.Extensions.Add<TextWriter>(() => new StreamWriter(@"C:/XAML/log.txt")); // Handle the desired lifecycle events. Exception exception = null; wfApp.Completed = (e) => syncEvent.Set(); wfApp.OnUnhandledException += (WorkflowApplicationUnhandledExceptionEventArgs e) => { using (WorkflowContext context = new WorkflowContext()) { context.Tracks.Add(new Track() { ActivityName = e.UnhandledException.ToString(), EventTime = DateTime.Now.AddHours(-1), State = "Faulted", WorkflowRunId = workflowRunId, }); context.SaveChanges(); } LogTracks(workflowRunId, tracker); return UnhandledExceptionAction.Terminate; }; // Start the workflow. wfApp.Run(); syncEvent.WaitOne(); LogTracks(workflowRunId, tracker); return tracker.Records; }
public override bool StartWorkflow(WorkflowContext context) { //Do anything here...start a third-party workflow, call a web service, modify SharePoint content, etc. //This just does something for demonstration purposes... context.ListItem[SPBuiltInFieldId.Title] = "Provider Updated"; context.ListItem.Update(); return true; }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var levelString = activityContext.GetState<string>("Level"); var message = activityContext.GetState<string>("Message"); LogLevel level; Enum.TryParse(levelString, true, out level); Logger.Log(level, null, message); yield return T("Done"); }
public IEnumerable<ActivityRecord> ExecuteWorkflow(WorkflowContext workflowContext, ActivityRecord activityRecord, IDictionary<string, object> tokens) { var firstPass = true; var scheduled = new Stack<ActivityRecord>(); scheduled.Push(activityRecord); var blocking = new List<ActivityRecord>(); while (scheduled.Any()) { activityRecord = scheduled.Pop(); var activityContext = CreateActivityContext(activityRecord, tokens); // while there is an activity to process if (!firstPass){ if (activityContext.Activity.IsEvent) { blocking.Add(activityRecord); continue; } } else { firstPass = false; } // signal every activity that the activity is about to be executed var cancellationToken = new CancellationToken(); InvokeActivities(activity => activity.OnActivityExecuting(workflowContext, activityContext, cancellationToken)); if (cancellationToken.IsCancelled) { // activity is aborted continue; } var outcomes = activityContext.Activity.Execute(workflowContext, activityContext).ToList(); // signal every activity that the activity is executed InvokeActivities(activity => activity.OnActivityExecuted(workflowContext, activityContext)); foreach (var outcome in outcomes) { // look for next activity in the graph var transition = workflowContext.Record.WorkflowDefinitionRecord.TransitionRecords.FirstOrDefault(x => x.SourceActivityRecord == activityRecord && x.SourceEndpoint == outcome.TextHint); if (transition != null) { scheduled.Push(transition.DestinationActivityRecord); } } } // apply Distinct() as two paths could block on the same activity return blocking.Distinct(); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var userName = activityContext.GetState<string>("UserName"); var email = activityContext.GetState<string>("Email"); if (_userService.VerifyUserUnicity(userName, email)) { yield return T("Unique"); } else { yield return T("NotUnique"); } }
/// <summary> /// Initializes a new instance of the <see cref="ShaleWorkstepUI"/> class. /// </summary> /// <param name="workstep">the workstep instance</param> /// <param name="args">the arguments</param> /// <param name="context">the underlying context in which this UI is being used</param> public ShaleWorkstepUI(ShaleWorkstep workstep, ShaleWorkstep.Arguments args, WorkflowContext context) { InitializeComponent(); btn_Apply.Image = Shale.Properties.Resources.IDB_BUTTON_APPLY; btn_DelBoreHole.Image = PetrelImages.RowDelete; this.workstep = workstep; this.args = args; this.context = context; workstep.CopyArgumentPackage(args, tmpargs); }
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var content = workflowContext.Content; if (content != null) { var comments = content.As<CommentsPart>(); if (comments != null) { comments.CommentsActive = false; } } yield return T("Done"); }
private bool ActionIsValid(WorkflowContext workflowContext, ActivityContext activityContext) { // checking if user has triggered an accepted action // triggered action var userAction = workflowContext.Tokens["UserTask.Action"]; var actions = GetActions(activityContext); bool isValidAction = actions.Contains(userAction); return isValidAction; }
/// <summary> /// evaluate the condition and return true/false /// e.g. getVariableData('isLastUamReplica') = 'True' /// </summary> /// <param name="context">The context for a workflow containing the /// workflow parameters which are likely used in determining /// whether the case condition is met.</param> /// <returns>True if condition is met, false otherwise</returns> public bool IsConditionTrue(WorkflowContext context) { // The condition statements is used to determine when a step // should be run. If this is the default step, the step should // always be run, regardless of the state of the condition statement. if (this.defaultCase) { return true; } return true; //return CompareXPath.IsConditionTrue(this.condition, context); }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { return(true); }
private IStateListener GetStateListener(WorkflowContext workflowContext) { return(_workflowEngine.WorkflowEngineBuilder.ListenerFactory?.CreateStateListener( workflowContext.WorkflowConfiguration.Class, workflowContext.WorkflowConfiguration.Id)); }
/// <summary> /// 记录工作流状态,针对退回特殊处理 /// </summary> /// <param name="rpt"></param> /// <param name="IsProType">是否是批次</param> protected void WorkFlowStatus(B_MonthlyReport rpt, bool IsProBatch) { //有效流程状态:Progress, Approved //4-return, 9 -withdraw if (OperatorType == 6 || OperatorType == 7) { rpt.WFStatus = "Draft"; if (OperatorType == 6) //退回操作 { if (IsProBatch) { WorkflowContext wfc = WFClientSDK.GetProcess(null, rpt.ID.ToString(), new UserInfo() { UserCode = "$VirtualUserCode$" + VirtualUser }); BizContext bizContext = new BizContext(); bizContext.NodeInstanceList = wfc.NodeInstanceList; bizContext.ProcessRunningNodeID = wfc.ProcessInstance.RunningNodeID; bizContext.BusinessID = rpt.ID.ToString(); bizContext.ApprovalContent = "项目汇总退回服务发起"; bizContext.CurrentUser = new UserInfo() { UserCode = "$VirtualUserCode$" + VirtualUser }; bizContext.ExtensionCommond = new Dictionary <string, string>(); bizContext.ExtensionCommond.Add("RejectNode", Guid.Empty.ToString()); WorkflowContext wf = WFClientSDK.ExecuteMethod("RejectProcess", bizContext); if (wf.StatusCode != 0) { throw new Exception("子流程退回到发起人没有成功,请联系管理员。"); } //ClientProcess.Return(rpt.ID.ToString(), "项目汇总退回服务发起", -1, null, "", false); //ClientProcess.Return(rpt.ID.ToString(), "这个是自动的服务意见", -1); } new MonthlyReportLog().AddMonthlyReportAction((int)MonthlyReportLogActionType.Return, rpt.SystemID, rpt.FinYear, rpt.FinMonth, BusinessID.ToGuid()); } else if (OperatorType == 7) { new MonthlyReportLog().AddMonthlyReportAction((int)MonthlyReportLogActionType.Withdraw, rpt.SystemID, rpt.FinYear, rpt.FinMonth, BusinessID.ToGuid()); rpt.WFStatus = "Draft"; } } else if (OperatorType == 9)//9, cancel { rpt.WFStatus = "Cancel"; new MonthlyReportLog().AddMonthlyReportAction((int)MonthlyReportLogActionType.Cancel, rpt.SystemID, rpt.FinYear, rpt.FinMonth, BusinessID.ToGuid()); } else { if (rpt.WFStatus != "Approved") //这里为了避免通知节点的提交覆盖了审批完成状态,而添加的 { rpt.WFStatus = "Progress"; //CreatTime取流程提交时间,该时间为流程开始时间 rpt.ModifyTime = DateTime.Now; rpt.Status = 5; } new MonthlyReportLog().AddMonthlyReportAction((int)MonthlyReportLogActionType.Submit, rpt.SystemID, rpt.FinYear, rpt.FinMonth, BusinessID.ToGuid()); } B_MonthlyreportOperator.Instance.UpdateMonthlyreport(rpt); }
public override IEnumerable <LocalizedString> GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) { return(Enumerable.Empty <LocalizedString>()); }
/// <summary> /// 获得当前工作流程的上下文0 /// </summary> public void GetWorkflowContext() { WorkflowContext context = WFContext; if (context != null) { if (context.FormAction == FormAction.Todo) { if (context.TaskInstance.TaskState == TaskState.Complete || !context.TaskInstance.IsValid) { jsonResult = JsonHelper.OutResult(false, "任务已结束!"); return; } if (context.Instance.InstanceState == InstanceState.Complete || context.Instance.InstanceState == InstanceState.Invalid) { jsonResult = JsonHelper.OutResult(false, "流程已结束!"); return; } } JsonHelper js = new JsonHelper(false, false); js.Add("name", context.DefinitionInfo.WorkflowName); js.Add("title", context.Instance.InstanceTitle); js.Add("instanceID", context.InstanceID.ToString()); js.Add("formID", context.Instance.FormID); js.Add("startTime", context.Instance.StartTime.ToString("yyyy-MM-dd HH:mm:ss")); if (context.Instance.FinishTime.HasValue) { js.Add("finishTime", context.Instance.FinishTime.Value.ToString("yyyy-MM-dd HH:mm:ss")); } if (!string.IsNullOrEmpty(context.DefinitionInfo.App.FormPath)) { js.Add("formPath", context.DefinitionInfo.App.FormPath); } js.Add("sheetID", context.Instance.SheetID); js.Add("workflowID", context.WorkflowID); js.Add("taskID", context.TaskID); if (WFContext.TaskInstance != null) { js.Add("taskState", context.TaskInstance.TaskState); } js.Add("instanceState", context.Instance.InstanceState); js.Add("formAction", (int)context.FormAction); js.Add("urgency", context.Instance.Urgency); js.Add("importance", context.Instance.Importance); js.Add("appID", context.AppID); if (context.Activity != null) { js.Add("activityID", context.Activity.ActivityID); js.Add("activityName", context.Activity.ActivityName); js.Add("activityType", context.Activity.ActivityType.ToString()); js.Add("splitType", context.Activity.SplitType.ToString()); js.Add("joinType", context.Activity.JoinType.ToString()); js.Add("respondType", context.Activity.RespondType.ToString()); js.Add("isEditForm", context.Activity.IsEditForm); js.Add("isShowOpinion", context.DefinitionInfo.IsShowOpinion && context.Activity.IsShowOpinion); js.Add("isOpinionRequire", context.Activity.IsOpinionRequire); //按钮权限 js.Add("enableCirculate", context.DefinitionInfo.IsEnableCirculate && (context.Activity.CirculateType == CirculateType.Manual || context.Activity.CirculateType == CirculateType.Both)); js.Add("enableTransmit", context.DefinitionInfo.IsEnableTransmit && context.Activity.IsEnableTransmit); js.Add("enableReject", context.DefinitionInfo.IsEnableReject && context.Activity.RejectType != RejectType.None); if (context.FormAction == FormAction.View && context.Instance.InstanceState == InstanceState.Running && context.Instance.CreatorID == context.User.UserID) { js.Add("enableWithdraw", context.DefinitionInfo.IsEnableWithdraw && WF.Run.IsCanWithdraw(context.ActivityInstance)); } js.Add("enableInvalid", context.DefinitionInfo.IsEnableInvalid && context.Instance.CreatorID == context.User.UserID && context.Instance.InstanceState == InstanceState.Running); } js.Add("orgID", context.User.OrgID); js.Add("orgName", context.User.OrgName); js.Add("orgFullName", context.User.OrgFullName); js.Add("userID", context.User.UserID); js.Add("userName", context.User.UserName); js.Add("fullName", context.User.FullName); jsonResult = JsonHelper.OutResult(true, js.ToString()); } }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { yield return(T("Done")); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { var url = activityContext.GetState <string>("Url"); var verb = (activityContext.GetState <string>("Verb") ?? "GET").ToUpper(); var headers = activityContext.GetState <string>("Headers"); var formValues = activityContext.GetState <string>("FormValues") ?? ""; using (var httpClient = new HttpClient { BaseAddress = new Uri(url) }) { HttpResponseMessage response; httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); if (!String.IsNullOrWhiteSpace(headers)) { foreach (var header in ParseKeyValueString(headers)) { httpClient.DefaultRequestHeaders.Add(header.Key, header.Value); } } switch (verb) { default: case "GET": response = httpClient.GetAsync("").Result; break; case "POST": var format = activityContext.GetState <string>("FormFormat"); switch (format) { default: case "KeyValue": var form = ParseKeyValueString(formValues); response = httpClient.PostAsync("", new FormUrlEncodedContent(form)).Result; break; case "Json": var json = formValues.Replace("((", "{").Replace("))", "}"); response = httpClient.PostAsync("", new StringContent(json, Encoding.UTF8, "application/json")).Result; break; } break; } workflowContext.SetState("WebRequestResponse", response.Content.ReadAsStringAsync().Result); if (response.IsSuccessStatusCode) { yield return(T("Success")); } else { yield return(T("Error")); } } }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { return(IsExpired(workflowContext, activityContext)); }
public Handler(WorkflowContext db, BpmnService bpmnService) { this.db = db; this.bpmnService = bpmnService; }
public override IEnumerable <LocalizedString> GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) { yield return(T("Done")); }
/// <summary> /// This method creates the dialog UI for the given workstep, arguments /// and context. /// </summary> /// <param name="workstep">the workstep instance</param> /// <param name="argumentPackage">the arguments to pass to the UI</param> /// <param name="context">the underlying context in which the UI is being used</param> /// <returns>a Windows.Forms.Control to edit the argument package with</returns> protected override System.Windows.Forms.Control CreateDialogUICore(Workstep workstep, object argumentPackage, WorkflowContext context) { return(new DisplayWellHeadInformationWithCustomUIWorkstepUI((DisplayWellHeadInformationWithCustomUIWorkstep)workstep, (Arguments)argumentPackage, context)); }
public void Jump(string to, WorkflowContext context) { this.Jump(context); }
public static void NextP(WorkflowContext context) { var p = context.Variables.Get <double>("p"); p.Value *= -3; }
/// <summary> /// 添加更新批次数据 /// </summary> /// <param name="rpt"></param> private void AddBatchData(B_SystemBatch _BatchModel) { //获取批次 List <V_SubReport> BatchRptList = JsonConvert.DeserializeObject <List <V_SubReport> >(_BatchModel.SubReport); //批次更新 BatchRptList.ForEach(p => { B_MonthlyReport tempModel = B_MonthlyreportOperator.Instance.GetMonthlyreport(p.ReportID); List <B_MonthlyReportDetail> rptDetailList = B_MonthlyreportdetailOperator.Instance.GetMonthlyreportdetailList(p.ReportID).ToList(); tempModel.WFStatus = "Approved"; #region 子流程虚拟审批人提交,是流程走完。 try { WorkflowContext workflow = WFClientSDK.GetProcess(null, tempModel.ID.ToString(), new UserInfo() { UserCode = "$VirtualUserCode$" + VirtualUser }); if (workflow.ProcessInstance.Status != 3) { Dictionary <string, object> formParams = new Dictionary <string, object>(); formParams.Add("ReportName", workflow.ProcessInstance.ProcessTitle); formParams.Add("ProcessKey", workflow.ProcessInstance.FlowCode); BizContext bizContext = new BizContext(); bizContext.NodeInstanceList = workflow.NodeInstanceList; bizContext.ProcessRunningNodeID = workflow.ProcessInstance.RunningNodeID; bizContext.BusinessID = tempModel.ID.ToString(); bizContext.FlowCode = workflow.ProcessInstance.FlowCode; bizContext.ApprovalContent = "同意"; bizContext.CurrentUser = new UserInfo() { UserCode = "$VirtualUserCode$" + VirtualUser }; bizContext.ProcessURL = "/BusinessReport/TargetApprove.aspx"; bizContext.FormParams = formParams; bizContext.ExtensionCommond = new Dictionary <string, string>(); bizContext.ExtensionCommond.Add("RejectNode", Guid.Empty.ToString()); WorkflowContext wfc = WFClientSDK.ExecuteMethod("SubmitProcess", bizContext); } } catch (Exception ex) { ExceptionHelper.TrueThrow(true, string.Format("{0}", ex)); } #endregion B_MonthlyreportOperator.Instance.UpdateMonthlyreport(tempModel); //?? BtoAData(tempModel, rptDetailList); }); _BatchModel.WFBatchStatus = "Approved"; //修改B批次表的审批状态 B_SystemBatchOperator.Instance.UpdateSystemBatch(_BatchModel); var amodel = new A_SystemBatch() { ID = _BatchModel.ID, FinYear = _BatchModel.FinYear, FinMonth = _BatchModel.FinMonth, BatchType = _BatchModel.BatchType, WFBatchStatus = _BatchModel.WFBatchStatus, SubReport = _BatchModel.SubReport, CreateTime = DateTime.Now, CreatorName = this.CurrentUser, Opinions = _BatchModel.Opinions, Batch_Opinions = _BatchModel.Batch_Opinions, TargetPlanID = _BatchModel.TargetPlanID }; A_SystemBatchOperator.Instance.DeleteSystemBatch(amodel); //将B批次表信息,添加到A表 A_SystemBatchOperator.Instance.AddSystemBatch(amodel); }
public override IEnumerable <LocalizedString> GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) { return(GetOutcomes(activityContext).Select(outcome => T.Encode(outcome))); }
private async Task <bool> TryGetDomainEntity(WorkflowContext workflowContext, CancellationToken cancellationToken) { return(await TryGetDomainEntity(workflowContext.WorkflowConfiguration, workflowContext.WorkflowInstance, cancellationToken) .ConfigureAwait(false)); }
/// <summary> /// 手机页面上的数据展示 /// </summary> /// <param name="BusinessID"> 这个可能是多个参数,用“,”连接 </param> /// <param name="processCode"></param> /// <param name="wfc"></param> /// <returns></returns> public override FlowPageShowData getMobileCommonData(string BusinessID, string processCode, WorkflowContext wfc) { string _BusinessID = BusinessID.Split(',')[0]; // 参数1 string ProType = BusinessID.Split(',')[1]; // 参数2 FlowPageShowData flowdata = new FlowPageShowData(); flowdata.groups = new List <Groups>(); if (wfc != null) { #region 页面数据展示 if (!string.IsNullOrEmpty(ProType)) // 合并审批 { var Batch = B_SystemBatchOperator.Instance.GetSystemBatch(_BusinessID.ToGuid()); // 去拿批次数据 List <V_SubReport> BatchRptList = JsonConvert.DeserializeObject <List <V_SubReport> >(Batch.SubReport); // for 循环多个 项目公司加载出来 if (BatchRptList.Count > 0) { BatchRptList.ForEach(BR => { var approval = B_BusinessBaseOperator.Instance.GetBusinessBase(BR.ReportID); //基本信息 var baseInfo = InitBaseInfo(approval); flowdata.groups.Add(baseInfo); //附件信息(直接添加的) var attachmenInfo = InitAttachment(approval); flowdata.groups.Add(attachmenInfo); }); } } else // 分支审批 { var approval = B_BusinessBaseOperator.Instance.GetBusinessBase(_BusinessID.ToGuid()); var monthRpt = B_MonthlyreportOperator.Instance.GetMonthlyreport(_BusinessID.ToGuid()); //这里判断系统的类型 int SysType = StaticResource.Instance[monthRpt.SystemID, approval.CreateTime].Category; if (SysType == 1 || SysType == 4) // 直管 经营 { //基本信息 var baseInfo = InitBaseInfo(approval); flowdata.groups.Add(baseInfo); //月度报表 var monthRptInfo = InitMonthRpt(approval); flowdata.groups.Add(monthRptInfo); //年度报表 var yearRptInfo = InitYearRpt(approval); flowdata.groups.Add(yearRptInfo); //附件信息(直接添加的) var attachmenInfo = InitAttachment(approval); flowdata.groups.Add(attachmenInfo); } else if (SysType == 2) //项目公司 { //基本信息 var baseInfo = InitBaseInfo(approval); flowdata.groups.Add(baseInfo); //附件信息(直接添加的) var attachmenInfo = InitAttachment(approval); flowdata.groups.Add(attachmenInfo); } else if (SysType == 3) // 总部系统 { //基本信息 var baseInfo = InitBaseInfo(approval); flowdata.groups.Add(baseInfo); //年度报表 var yearRptInfo = InitYearRpt(approval); flowdata.groups.Add(yearRptInfo); //附件信息(直接添加的) var attachmenInfo = InitAttachment(approval); flowdata.groups.Add(attachmenInfo); } } #endregion #region 工作流信息 flowdata.mainTitle = wfc.ProcessInstance.ProcessTitle; flowdata.requestId = BusinessID; flowdata.processCode = processCode; flowdata.status = ConstantWS.success; flowdata.message = ConstantWS.successText; flowdata.remarkisshow = "0"; Groups workflowApprove = new Groups() { type = ConstantWS.flowData_group_workFlow , approvesubTitle = "审批流程" , logsubTitle = "审批历史" , AppCode = wfc.AppCode , AppID = wfc.AppID , BusinessID = wfc.BusinessID , CurrentUser = wfc.CurrentUser , WFToken = wfc.WFToken , ProcessInstance = wfc.ProcessInstance , NodeInstanceList = wfc.NodeInstanceList , CcNodeInstanceList = wfc.CcNodeInstanceList , CurrentUserNodeID = wfc.CurrentUserNodeID , ProcessLogList = wfc.ProcessLogList , CurrentUserSceneSetting = wfc.CurrentUserSceneSetting , CurrentUserHasTodoTask = wfc.CurrentUserHasTodoTask , CurrentUserTodoTaskIsRead = wfc.CurrentUserTodoTaskIsRead , CurrentUserActivityPropertiesList = wfc.CurrentUserActivityPropertiesList , ExtensionInfos = wfc.ExtensionInfos , StatusCode = wfc.StatusCode.ToString() , StatusMessage = wfc.StatusMessage , LastException = wfc.LastException == null ? "" : wfc.LastException.Message }; foreach (var log in workflowApprove.ProcessLogList) { log.LogContent = log.LogContent.Replace("\"", """); // 替换双引号,导致的Json数据截断问题。 } flowdata.groups.Add(workflowApprove); #endregion } return(flowdata); }
public UserRepository(WorkflowContext _context) { context = _context; }
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) { var url = activityContext.GetState <string>("Url"); return(!string.IsNullOrWhiteSpace(url)); }
public Transition(WorkflowContext context) { this.context = context; }
/// <summary> /// Run the invoke workflow step. This step will invoke execution /// of either a Workflow Code Block or a new workflow, depending /// on the value of the type field set during initialization /// from the BPEL attributes. /// </summary> /// <param name="context">Context for the workflow to run</param> /// <param name="stepId">Step at which to start execution. This /// parameter is ignored for the Invoke step.</param> /// <returns>State of the workflow after executing the invoke step.</returns> public override string Run(WorkflowContext context, string stepId) { return(InvokeContext.Name); }
public override IEnumerable <LocalizedString> GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) { return(new[] { T("Unpublished") }); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { ContentItem contentItem = workflowContext.Content.ContentItem; if (contentItem == null) { return(new[] { T("NotGITCommitItem") }); } GITCommitPart gitLogPart = contentItem.As <GITCommitPart>(); if (gitLogPart == null) { return(new[] { T("NotGITCommitItem") }); } if (string.IsNullOrEmpty(gitLogPart.LogMessage)) { return(new[] { T("LogHasNoTicketNumber") }); } var message = gitLogPart.LogMessage; var matches = Regex.Matches(message, @"([#]\d+)"); List <int> ticketNumbers = new List <int>(); foreach (Match match in matches) { string number = message.Substring(match.Index + 1, match.Length - 1); int ticketNumber; if (int.TryParse(number, out ticketNumber)) { ticketNumbers.Add(ticketNumber); } } if (ticketNumbers.Count == 0) { return(new[] { T("LogHasNoTicketNumber") }); } ticketNumbers = ticketNumbers.Distinct().ToList(); List <TicketPart> tickets = new List <TicketPart>(); foreach (var id in ticketNumbers) { var ticket = ticketSearchService.GetByTicketNumber(id); if (ticket != null) { tickets.Add(ticket); } } if (tickets.Count == 0) { return(new[] { T("LogHasNoTicketNumber") }); } foreach (var ticket in tickets) { GITCommitsTicketPart gitLogsTicketPart = ticket.As <GITCommitsTicketPart>(); if (gitLogsTicketPart != null) { if (string.IsNullOrEmpty(gitLogsTicketPart.GITCommits)) { gitLogsTicketPart.GITCommits = gitLogPart.Id.ToString(CultureInfo.InvariantCulture); } else { gitLogsTicketPart.GITCommits += "," + gitLogPart.Id.ToString(CultureInfo.InvariantCulture); } } workflowManager.TriggerEvent( GITCommitConnectedToTicketActivity.ActivityName, ticket.ContentItem, () => new Dictionary <string, object> { { "Content", ticket.ContentItem }, { "GITCommit", gitLogPart } }); } return(new[] { T("Done") }); }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { TicketPart ticketPart = workflowContext.Content.As <TicketPart>(); CRMCommentPart commentPart = workflowContext.Content.As <CRMCommentPart>(); ContentItemPermissionPart permissionsPart = workflowContext.Content.As <ContentItemPermissionPart>(); if (ticketPart == null) { if (commentPart == null) { this.Logger.Debug("ContentItem mismatch: Expexting TicketPart"); return(new[] { T("Failed") }); } else { var contentPart = this.contentManager.Get(commentPart.Record.CRMCommentsPartRecord.ContentItemRecord.Id); ticketPart = contentPart.As <TicketPart>(); permissionsPart = contentPart.As <ContentItemPermissionPart>(); } } if (permissionsPart == null) { this.Logger.Debug("ContentItem mismatch: Expexting ContentItemPermissionPart "); return(new[] { T("Failed") }); } // setup tokenizer Dictionary <string, object> temp = new Dictionary <string, object>(); temp.Add("Content", workflowContext.Content); var titlePart = ticketPart.As <TitlePart>(); // read email template Id string emailTemplateIdString = activityContext.GetState <string>(EmailTemplateActivityForm.EmailTemplateIdFieldName); int emailTemplateId; if (!int.TryParse(emailTemplateIdString, out emailTemplateId)) { this.Logger.Debug("There is no email Template for new Tickets"); return(new[] { T("Failed") }); } bool sendToRequestingUser = this.GetBooleanValue(activityContext, EmailTemplateActivityForm.SentToRequestingUserFieldName); bool sendToOwner = this.GetBooleanValue(activityContext, EmailTemplateActivityForm.SentToOwnerFieldName); bool sendToSharedWithUsers = this.GetBooleanValue(activityContext, EmailTemplateActivityForm.SentToSharedUsersFieldName); var ticketEmailTemplate = this.emailTemplateRepository.Table.First(c => c.Id == emailTemplateId); if (ticketEmailTemplate == null) { this.Logger.Debug("There is no email Template for new Tickets"); return(new[] { T("Failed") }); } var queued = activityContext.GetState <bool>("Queued"); var priority = activityContext.GetState <int>("Priority"); List <UserPartRecord> recipients = new List <UserPartRecord>(); if (permissionsPart.Record.Items != null) { foreach (var permission in permissionsPart.Record.Items) { if (permission.AccessType == ContentItemPermissionAccessTypes.Assignee && sendToOwner) { recipients.AddRange(this.GetRecipients(permission)); } else if (sendToSharedWithUsers) { recipients.AddRange(this.GetRecipients(permission)); } } } if (sendToRequestingUser) { var record = ticketPart.Record; if (record.RequestingUser != null) { recipients.Add(record.RequestingUser); } else if (record.SourceId == TicketSourceTypes.Email && !string.IsNullOrEmpty(record.SourceData)) { dynamic sender = JObject.Parse(record.SourceData); string email = sender.Email; string name = sender.Name; recipients.Add(new UserPartRecord { Email = email, UserName = name }); } } // filter the redundent items recipients = recipients.GroupBy(c => c.Id).Select(c => c.First()).ToList(); foreach (var recipient in recipients.Where(c => !string.IsNullOrEmpty(c.Email))) { temp[ActivityTokenProvider.UserKey] = recipient; string body = this.tokenizer.Replace(ticketEmailTemplate.Body, temp); string subject = this.tokenizer.Replace(ticketEmailTemplate.Subject, temp); this.SendEmail(subject, body, recipient.Email, queued, priority); } return(new[] { T("Done") }); }
public override Task Next(WorkflowContext context) { throw new System.NotImplementedException(); }
/// <summary> /// Initializes a new instance of the <see cref="TimeUnitConversionWithCustomUIWorkstepUI"/> class. /// </summary> /// <param name="workstep">the workstep instance</param> /// <param name="args">the arguments</param> /// <param name="context">the underlying context in which this UI is being used</param> public TimeUnitConversionWithCustomUIWorkstepUI(TimeUnitConversionWithCustomUIWorkstep workstep, TimeUnitConversionWithCustomUIWorkstep.Arguments args, WorkflowContext context) { InitializeComponent(); this.workstep = workstep; this.args = args; this.context = context; // context.ArgumentPackageChanged += ContextOnArgumentPackageChanged; // ApplyButton.Click += ApplyButtonOnClick; OkButton.Click += OkButtonOnClick; CancelButton.Click += CancelButtonOnClick; // ApplyButton.Image = PetrelImages.Apply; OkButton.Image = PetrelImages.OK; CancelButton.Image = PetrelImages.Cancel; }
public override IEnumerable <LocalizedString> GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) { return(new[] { T("Done"), T("NotGITCommitItem"), T("LogHasNoTicketNumber"), T("TicketNotFound") }); }
public JobContext(Job job, WorkflowContext context) { Job = job; WorkflowContext = context; }
public override IEnumerable <LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) { _contentManager.Unpublish(workflowContext.Content.ContentItem); yield return(T("Unpublished")); }
public Handler(WorkflowContext db) { this.db = db; }