예제 #1
0
        /// <inheritdoc/>
        public ServiceState GetInitialServiceState(string applicationOwnerId, string applicationId)
        {
            // Read the workflow template
            string workflowData = File.ReadAllText(_generalSettings.WorkflowTemplate, Encoding.UTF8);

            return(WorkflowHelper.GetInitialWorkflowState(workflowData));
        }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //string currentUser = new IdentityUser().GetEmployee().LoginId;
            //UploadAttachments1._BPMContext.LoginId = currentUser;
            ViewState["IsSubmit"] = false;
            if (!string.IsNullOrEmpty(Request.QueryString["sn"]))
            {
                sn.Value = Request.QueryString["sn"];

                WorklistItem listItem = WorkflowHelper.GetWorklistItemWithSN(sn.Value, "founder\\" + _BPMContext.CurrentUser.LoginId);
                taskID.Value   = listItem.ID.ToString();
                nodeID.Value   = listItem.ActivityInstanceDestination.ActID.ToString();
                nodeName.Value = listItem.ActivityInstanceDestination.Name;
                InitApproveOpinion(nodeName.Value);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                FormId = _BPMContext.ProcInst.FormId;
                InitFormData();
            }
            else
            {
                ExceptionHander.GoToErrorPage();
            }
        }

        //Countersign1.SimulateUser = ViewState["loginName"].ToString();
        //FlowRelated1.SimulateUser = ViewState["loginName"].ToString();

        ShowButton();

        SetMenu();
    }
        private void step2CodeActivity_Validate_ExecuteCode(object sender, EventArgs e)
        {
            PackageElementProviderInstalledPackageItemEntityToken castedEntityToken = (PackageElementProviderInstalledPackageItemEntityToken)this.EntityToken;

            PackageManagerUninstallProcess packageManagerUninstallProcess = PackageManager.Uninstall(castedEntityToken.PackageId);

            this.Bindings.Add("PackageManagerUninstallProcess", packageManagerUninstallProcess);

            this.Bindings.Add("FlushOnCompletion", packageManagerUninstallProcess.FlushOnCompletion);
            this.Bindings.Add("ReloadConsoleOnCompletion", packageManagerUninstallProcess.ReloadConsoleOnCompletion);

            if (packageManagerUninstallProcess.PreUninstallValidationResult.Count > 0)
            {
                this.UpdateBinding("Errors", WorkflowHelper.ValidationResultToBinding(packageManagerUninstallProcess.PreUninstallValidationResult));
            }
            else
            {
                List <PackageFragmentValidationResult> validationResult = packageManagerUninstallProcess.Validate();

                if (validationResult.Count > 0)
                {
                    this.UpdateBinding("Errors", WorkflowHelper.ValidationResultToBinding(validationResult));
                }
            }
        }
예제 #4
0
        /// <inheritdoc/>
        public ServiceState MoveServiceForwardInWorkflow(Guid instanceId, string applicationOwnerId, string applicationId, int instanceOwnerId)
        {
            ServiceState currentState = GetCurrentState(instanceId, applicationOwnerId, applicationId, instanceOwnerId);
            string       workflowData = File.ReadAllText(_generalSettings.WorkflowTemplate, Encoding.UTF8);

            return(WorkflowHelper.UpdateCurrentState(workflowData, currentState));
        }
예제 #5
0
    protected bool CommonApproval(string sn, string option, string action)
    {
        if (string.IsNullOrWhiteSpace(option))
        {
            option = action;
        }
        activityName = GetCurrentActiveName(sn);
        bool isAddSign    = new Workflow_Common().IsAddSign(sn, _BPMContext.CurrentUser.LoginId);
        bool isChangeSign = new Workflow_Common().IsChangeSign(sn, _BPMContext.CurrentUser.LoginId);
        bool isSuccess    = false;

        if (!isAddSign)
        {
            isSuccess = WorkflowHelper.ApproveProcess(sn, action, _BPMContext.CurrentUser.ApprovalUser);
        }
        else if (isChangeSign)
        {
            isSuccess = WorkflowHelper.ApproveProcess(sn, action, _BPMContext.CurrentUser.ApprovalUser);
        }
        else
        {
            isSuccess = WorkflowHelper.BackToPreApprover(sn, _BPMContext.CurrentUser.ApprovalUser);
        }
        if (isSuccess)
        {
            AddApprovalOption(sn, action, option, isAddSign ? "1" : "0", activityName);
            return(true);
        }
        return(false);
    }
예제 #6
0
        public ActionResult DisplayByName(string projectname)
        {
            try
            {
                Session["ReturnURL"] = System.Web.HttpContext.Current.Request.Url.PathAndQuery;

                if (!ScreenViewer.SignInHelper.ValidateSignIn())
                {
                    return(RedirectToAction("Login", "Account", new { ReturnUrl = Session["ReturnURL"].ToString() }));
                }

                ScreenViewer.API.ProjectController PC = new API.ProjectController();
                int projectId = PC.GetProjectId(projectname);
                SessionManager.ClearSessionData(HttpContext.Session);
                AddProgramParameter();
                TempData["addparams"] = true;
                return(RedirectToAction("Display", "Project", new { id = projectId }));
            }
            catch (Exception ex)
            {
                Data.Log log = ex.Save(HttpContext.Session, WorkflowHelper.BuildCallData(HttpContext.Session), ImpactLevel.High);
                ViewBag.URL = System.Web.HttpContext.Current.Request.Url;
                return(View("Error", new HandleErrorInfo(ex, "ProjectController", "DisplayByName")));
            }
        }
예제 #7
0
        public JsonResult Start(WorkflowStartParameter startParameter)
        {
            WorkflowHelper helper = new WorkflowHelper(Sec.User);

            helper.StartWorkflow(startParameter.AppCode, startParameter.InstanceName, startParameter.DataLocator, startParameter.ImportLevel, startParameter.SecurityLevel);
            return(Json(helper.FlowInstance.Id));
        }
예제 #8
0
        public IEnumerable <TreeNode> SelectItems()
        {
            WorkflowHelper         helper = new WorkflowHelper(Sec.User);
            IEnumerable <TreeNode> result = null;

            switch (SourceType)
            {
            case WorkflowDataSourceType.Definition:
                result = helper.GetAllDefinition().Select(o => new TreeNode()
                {
                    Text = o.Name, Value = o.Id
                });
                break;

            case WorkflowDataSourceType.Application:
                result = helper.GetAllApplication().Select(o => new TreeNode()
                {
                    Text = o.Name, Value = o.Id
                });
                break;

            default:
                throw new FoxOneException("Not Support!");
            }
            return(result);
        }
예제 #9
0
        public ActionResult Detail()
        {
            var            relatePages = new List <PageRelateEntity>();
            var            dataLocator = Request.QueryString[DATA_LOCATOR];
            WorkflowHelper helper      = new WorkflowHelper(Sec.User);

            if (dataLocator.IsNotNullOrEmpty())
            {
                helper.OpenWorkflow(dataLocator);
            }
            else
            {
                var instanceId = Request.QueryString[INST_ID];
                int itemId     = Request.QueryString[TASK_ID].ConvertTo <int>();
                helper.OpenWorkflow(instanceId, itemId);
            }
            helper.SetReadTime();
            var formType = helper.FlowInstance.Application.FormType;
            var app      = helper.FlowInstance.Application;
            var page     = PageBuilder.BuildPage(formType);
            var form     = page.Controls.FirstOrDefault(o => o is Form) as Form;

            form.Key      = helper.FlowInstance.DataLocator;
            form.FormMode = FormMode.View;
            InsertTable(helper);
            ViewData["Title"] = string.Format("{0} - {1}", helper.FlowInstance.InstanceName, helper.CurrentItem.Alias);
            var tempRelate = DBContext <PageRelateEntity> .Instance.Where(o => o.PageId.Equals(formType, StringComparison.OrdinalIgnoreCase));

            if (!tempRelate.IsNullOrEmpty())
            {
                foreach (var item in tempRelate)
                {
                    relatePages.Add(new PageRelateEntity()
                    {
                        Id        = item.Id,
                        PageId    = item.PageId,
                        RelateUrl = Env.Parse(item.RelateUrl).Replace("KEY", form.Key),
                        RentId    = item.RentId,
                        TabName   = item.TabName,
                        TabRank   = item.TabRank
                    });
                }
            }
            if (app.NeedAttachement)
            {
                relatePages.Add(new PageRelateEntity()
                {
                    Id        = "AttachmentInfo",
                    RelateUrl = "/Attachment/Index/" + form.Key,
                    TabName   = "附件信息",
                    TabRank   = 1000
                });
            }
            form.AppendQueryString   = true;
            form.PostUrl             = "/Workflow/Save";
            ViewData["Tab"]          = relatePages;
            ViewData["Form"]         = page.Children.OrderBy(o => o.Rank).ToList();
            ViewData["DefinitionId"] = app.WorkflowId;
            return(View());
        }
예제 #10
0
    public static bool ModifyDataField(string sn, NameValueCollection dataFields)
    {
        Connection k2Conn = new Connection();

        try
        {
            k2Conn.Open(K2ServerName, WorkflowHelper.GetConnString());

            SourceCode.Workflow.Client.ProcessInstance inst = k2Conn.OpenProcessInstance(Convert.ToInt32(sn.Split('_')[0]));
            if (inst != null)
            {
                foreach (string s in dataFields)
                {
                    inst.DataFields[s].Value = dataFields[s];
                }

                inst.Update();
            }
            return(true);
        }
        catch (Exception ex)
        {
            return(false);
        }
        finally
        {
            k2Conn.Close();
        }
    }
        public void Process(WorkflowPipelineArgs args)
        {
            string workflowComment = (!string.IsNullOrEmpty(args.CommentFields[Constants.Comments])) ? args.CommentFields[Constants.Comments] : Constants.NoComment;

            try
            {
                using (new SecurityDisabler())
                {
                    Item currentDataItem = args.DataItem;
                    if (currentDataItem.Fields[Multisite.Templates.MainSite.Fields.IsDisplayOnMainSite].IsChecked())
                    {
                        Item copiedItem     = _mallSiteWorkflowRepository.GetCopiedItemInMainSite(currentDataItem);
                        Item notifyStepItem = args.ProcessorItem.InnerItem;

                        var from = notifyStepItem.Fields[Templates.NotifyNextStepUser.Fields.From].Value;
                        var emailTemplateItem = notifyStepItem.TargetItem(Templates.NotifyNextStepUser.Fields.EmailTemplate);
                        var receivers         = WorkflowHelper.GetMainAdminsOf(copiedItem.GetSiteItem());

                        _workflowNotifyService.SendEmailNotifications(receivers, from, copiedItem, workflowComment, emailTemplateItem);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error($"NotifyNextStepUser: {ex}", this);
            }
        }
예제 #12
0
    //提交
    protected void Submit_Click(object sender, EventArgs e)
    {
        string           id = ViewState["FormID"].ToString();
        WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id);

        if (workFlowInstance != null)
        {
            UploadAttachments1.SaveAttachment(id);
            bool isSuccess = WorkflowHelper.BackToPreApprover(sn.Value, "founder\\" + _BPMContext.CurrentUser.LoginId);

            string Opinion = GetApproveOpinion(nodeName.Value);
            if (string.IsNullOrEmpty(Opinion))
            {
                Opinion = "同意";
            }
            string ApproveResult    = "同意";
            string OpinionType      = "";
            string IsSign           = "2";//会签步骤
            string DelegateUserName = "";
            string DelegateUserCode = "";
            if (isSuccess && !(bool)ViewState["IsSubmit"])
            {
                var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record()
                {
                    ApprovalID        = Guid.NewGuid().ToString(),
                    WFTaskID          = int.Parse(taskID.Value),
                    FormID            = id,
                    InstanceID        = workFlowInstance.InstanceId,
                    Opinion           = Opinion,
                    ApproveAtTime     = DateTime.Now,
                    ApproveByUserCode = CurrentEmployee.EmployeeCode,
                    ApproveByUserName = CurrentEmployee.EmployeeName,
                    ApproveResult     = ApproveResult,
                    OpinionType       = OpinionType,
                    CurrentActiveName = nodeName.Value,
                    ISSign            = IsSign,
                    CurrentActiveID   = nodeID.Value,
                    DelegateUserName  = DelegateUserName,
                    DelegateUserCode  = DelegateUserCode,
                    CreateAtTime      = DateTime.Now,
                    CreateByUserCode  = CurrentEmployee.EmployeeCode,
                    CreateByUserName  = CurrentEmployee.EmployeeName,
                    UpdateAtTime      = DateTime.Now,
                    UpdateByUserCode  = CurrentEmployee.EmployeeCode,
                    UpdateByUserName  = CurrentEmployee.EmployeeName,
                    FinishedTime      = DateTime.Now
                };

                if (bfApproval.AddApprovalRecord(appRecord))
                {
                    wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee);

                    //if (jc.UpdateStatus(id, "03"))
                    //{}
                    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批成功'); window.opener.location.href=window.opener.location.href; ", true);
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true);
                }
            }
        }
    }
예제 #13
0
        public static IContextualResourceModel CreateContextualResourceModel(Flowchart chart)
        {
            var workflowHelper = new WorkflowHelper();
            var tempResource   = new Mock <IContextualResourceModel>();

            var builder = workflowHelper.CreateWorkflow("bob");

            builder.Implementation = chart;
            var tempResourceWorkflowXaml = workflowHelper.GetXamlDefinition(builder);
            var mock = new Mock <IServer>();

            mock.Setup(server => server.ResourceRepository.FetchResourceDefinition(It.IsAny <IServer>(),
                                                                                   It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <bool>()))
            .Returns(new ExecuteMessage
            {
                HasError = false,
                Message  = tempResourceWorkflowXaml
            });
            tempResource.Setup(model => model.Environment).Returns(mock.Object);
            tempResource.Setup(model => model.Category).Returns(@"Unassigned\" + "bob");
            tempResource.Setup(model => model.ResourceName).Returns("bob");
            tempResource.Setup(model => model.DisplayName).Returns("bob");
            tempResource.Setup(model => model.IsNewWorkflow).Returns(true);
            tempResource.Setup(model => model.WorkflowXaml).Returns(tempResourceWorkflowXaml);

            return(tempResource.Object);
        }
예제 #14
0
        private IEnumerable <User> GetReceivers(Item contentItem, ID currentState, ID nextState)
        {
            if (currentState.Equals(Constants.States.Draft) && nextState.Equals(Constants.States.WaitingForMallSiteApproval))
            {
                return(WorkflowHelper.GetMallAdminsOf(contentItem.GetSiteItem()));
            }
            else if (currentState.Equals(Constants.States.Draft) && nextState.Equals(Constants.States.WaitingForMainSiteApproval))
            {
                return(WorkflowHelper.GetMainAdminsOf(contentItem.GetSiteItem()));
            }
            else if ((currentState.Equals(Constants.States.WaitingForMallSiteApproval) && nextState.Equals(Constants.States.Draft)) ||
                     (currentState.Equals(Constants.States.WaitingForMainSiteApproval) && nextState.Equals(Constants.States.Draft)) ||
                     (currentState.Equals(Constants.States.WaitingForMallSiteApproval) && nextState.Equals(Constants.States.Approved)) ||
                     (currentState.Equals(Constants.States.WaitingForMainSiteApproval) && nextState.Equals(Constants.States.Approved)))
            {
                var result = new List <User>
                {
                    WorkflowHelper.GetAuthorOf(contentItem)
                };

                var sourceItem = _mallSiteWorkflowRepository.TryGetSourceItemBy(contentItem);
                if (sourceItem != null) // Get related user if existed.
                {
                    result.Add(User.FromName(sourceItem.Statistics.UpdatedBy, true));
                }
                return(result.Distinct());
            }
            return(Enumerable.Empty <User>());
        }
예제 #15
0
    public void UpdateDataFields(int procInstID, Dictionary <string, string> dict)
    {
        Connection k2Conn = new Connection();

        try
        {
            k2Conn.Open(K2ServerName, WorkflowHelper.GetConnString());

            SourceCode.Workflow.Client.ProcessInstance inst = k2Conn.OpenProcessInstance(procInstID);
            if (inst != null)
            {
                foreach (string s in dict.Keys)
                {
                    inst.DataFields[s].Value = dict[s];
                }
            }
            else
            {
                Response.Redirect("ProcessesManage_List.aspx", false);
            }
            inst.Update();

            k2Conn.Close();
        }
        catch
        {
            k2Conn.Close();
        }
    }
예제 #16
0
        private void SetupWorkflow()
        {
            divStates.Visible = false;
            grid.MasterTableView.GetColumn("WorkflowCreatedBy").Visible = false;
            grid.MasterTableView.GetColumn("WorkflowState").Visible     = false;
            grid.MasterTableView.GetColumn("WorkflowAction").Visible    = false;

            if (WebConfigSettings.EnableContentWorkflow && siteSettings.EnableContentWorkflow)
            {
                workflowId          = WorkflowHelper.GetWorkflowId(News.FeatureGuid);
                workflowIsAvailable = WorkflowHelper.WorkflowIsAvailable(workflowId);
                if (workflowIsAvailable)
                {
                    firstWorkflowStateId = WorkflowHelper.GetFirstWorkflowStateId(workflowId);
                    lastWorkflowStateId  = WorkflowHelper.GetLastWorkflowStateId(workflowId);

                    divStates.Visible = true;
                    grid.MasterTableView.GetColumn("WorkflowCreatedBy").Visible = true;
                    grid.MasterTableView.GetColumn("WorkflowState").Visible     = true;
                    grid.MasterTableView.GetColumn("WorkflowAction").Visible    = true;

                    if (!Page.IsPostBack)
                    {
                        ddStates.DataSource = WorkflowHelper.GetWorkflowStates(workflowId);
                        ddStates.DataBind();
                        ddStates.Items.Insert(0, new ListItem(ResourceHelper.GetResourceString("Resource", "All"), ""));
                    }
                }
            }
        }
예제 #17
0
    /// <summary>
    /// 是否DataField
    /// </summary>
    /// <param name="procInstID"></param>
    /// <returns></returns>
    bool ExistDataField(int procInstID)
    {
        bool       flag   = false;
        Connection k2Conn = new Connection();

        try
        {
            k2Conn.Open(K2ServerName, WorkflowHelper.GetConnString());
            SourceCode.Workflow.Client.ProcessInstance inst = k2Conn.OpenProcessInstance(procInstID);
            if (inst != null)
            {
                foreach (DataField item in inst.DataFields)
                {
                    if (item.Name == "IsPass")
                    {
                        flag = true;
                        break;
                    }
                }
            }
            k2Conn.Close();
        }
        catch
        {
            k2Conn.Close();
        }
        return(flag);
    }
예제 #18
0
    /// <summary>
    /// 绑定默认DataFields
    /// </summary>
    /// <param name="procInstID"></param>
    private void LoadDataFields(int procInstID)
    {
        List <BPMListItem> items  = new List <BPMListItem>();
        Connection         k2Conn = new Connection();

        try
        {
            k2Conn.Open(K2ServerName, WorkflowHelper.GetConnString());
            SourceCode.Workflow.Client.ProcessInstance inst = k2Conn.OpenProcessInstance(procInstID);
            if (inst != null)
            {
                foreach (DataField df in inst.DataFields)
                {
                    items.Add(new BPMListItem {
                        Name = df.Name, Value = df.Value.ToString()
                    });
                }
                rptList.DataSource = items;
                rptList.DataBind();

                k2Conn.Close();
            }
            else
            {
                k2Conn.Close();
            }
        }
        catch (Exception ex)
        {
            k2Conn.Close();
            lblException.Text    = "异常信息:" + ex.Message;
            lblException.Visible = true;
        }
    }
예제 #19
0
    //WF_WorkFlowInstance wf_WorkFlowInstance = new WF_WorkFlowInstance();
    //BFApprovalRecord bfApproval = new BFApprovalRecord();

    #region 执行过程中更新参数

    /// <summary>
    /// 执行过程中更新参数
    /// </summary>
    private void UpdateWFParams()
    {
        string CompanyCode             = BPMHelp.GetCompanyCodeByDeptID(StartDeptId);
        NameValueCollection dataFields = new NameValueCollection();

        if (K2_TaskItem.ActivityInstanceDestination.Name == "部门负责人意见")
        {
            if (cbVP.Checked)
            {
                dataFields.Add("VicePresident", Workflow_Common.GetRoleUsers(StartDeptId + "," + Countersign1.Result, "主管副总经理"));
            }
            else
            {
                dataFields.Add("VicePresident", "noapprovers");
            }
            if (cbPresident.Checked)
            {
                dataFields.Add("VicePresident", Workflow_Common.GetRoleUsers(CompanyCode, "总经理"));
            }
            else
            {
                dataFields.Add("President", "noapprovers");
            }
        }

        if (dataFields.Count != 0 && !string.IsNullOrEmpty(_BPMContext.Sn))
        {
            WorkflowHelper.UpdateDataFields(_BPMContext.Sn, dataFields, _BPMContext.CurrentUser.ApprovalUser);
        }
    }
예제 #20
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (workInProgress == null)
            {
                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                return;
            }

            SiteUser currentUser = SiteUtils.GetCurrentSiteUser();

            if (currentUser == null)
            {
                WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                return;
            }


            if (workInProgress.Status == ContentWorkflowStatus.AwaitingApproval)
            {
                workInProgress.RejectContentChanges(
                    currentUser.UserGuid,
                    txtRejectionComments.Text);

                WorkflowHelper.SendRejectionNotification(
                    SiteUtils.GetSmtpSettings(),
                    siteSettings,
                    currentUser,
                    workInProgress,
                    txtRejectionComments.Text);
            }

            WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
        }
예제 #21
0
    //拒绝
    protected void Reject_Click(object sender, EventArgs e)
    {
        string id = ViewState["FormID"].ToString();

        WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id);

        if (workFlowInstance != null)
        {
            UploadAttachments1.SaveAttachment(id);

            string action           = "不同意";
            bool   isSuccess        = WorkflowHelper.ApproveProcess(sn.Value, action);
            string Opinion          = GetApproveOpinion(nodeName.Value);
            string ApproveResult    = "不同意";
            string OpinionType      = "";
            string IsSign           = "0";
            string DelegateUserName = "";
            string DelegateUserCode = "";
            if (isSuccess && !(bool)ViewState["IsSubmit"])
            {
                var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record()
                {
                    ApprovalID        = Guid.NewGuid().ToString(),
                    WFTaskID          = int.Parse(taskID.Value),
                    FormID            = id,
                    InstanceID        = workFlowInstance.InstanceId,
                    Opinion           = Opinion,
                    ApproveAtTime     = DateTime.Now,
                    ApproveByUserCode = CurrentEmployee.EmployeeCode,
                    ApproveByUserName = CurrentEmployee.EmployeeName,
                    ApproveResult     = ApproveResult,
                    OpinionType       = OpinionType,
                    CurrentActiveName = nodeName.Value,
                    ISSign            = IsSign,
                    CurrentActiveID   = nodeID.Value,
                    DelegateUserName  = DelegateUserName,
                    DelegateUserCode  = DelegateUserCode,
                    CreateAtTime      = DateTime.Now,
                    CreateByUserCode  = CurrentEmployee.EmployeeCode,
                    CreateByUserName  = CurrentEmployee.EmployeeName,
                    UpdateAtTime      = DateTime.Now,
                    UpdateByUserCode  = CurrentEmployee.EmployeeCode,
                    UpdateByUserName  = CurrentEmployee.EmployeeName,
                    FinishedTime      = DateTime.Now
                };
                ViewState["IsSubmit"] = true;
                bfApproval.AddApprovalRecord(appRecord);
                wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee);

                if (wf_Instruction.UpdateStatus(id, "01", workFlowInstance.WfInstanceId))
                {
                    WebCommon.Show(this, Resources.Message.ApplicationReviewSucess);
                    Response.Redirect("~/Workflow/ToDoWorkList.aspx", false);
                }
            }
        }

        //WorkflowHelper.ApproveProcess
        //insert data to business object
    }
예제 #22
0
        private static XmlPropertyChangeAction ToXmlModel(IePropertyChangeAction ieAction, WorkflowDataMaps dataMaps)
        {
            if (ieAction == null)
            {
                return(null);
            }

            var xmlAction = new XmlPropertyChangeAction
            {
                Name          = ieAction.Name,
                PropertyValue = ieAction.PropertyValue,
                UsersGroups   = ToXmlModel(ieAction.UsersGroups, dataMaps)
            };

            int propertyTypeId;

            if (!dataMaps.PropertyTypeMap.TryGetValue(ieAction.PropertyName, out propertyTypeId) &&
                !WorkflowHelper.TryGetNameOrDescriptionPropertyTypeId(ieAction.PropertyName, out propertyTypeId))
            {
                throw new ExceptionWithErrorCode(I18NHelper.FormatInvariant("Id of Standard Property Type '{0}' is not found.", ieAction.PropertyName),
                                                 ErrorCodes.UnexpectedError);
            }
            xmlAction.PropertyTypeId = propertyTypeId;

            ToXmlModel(ieAction.ValidValues, propertyTypeId, ieAction.PropertyName, dataMaps, xmlAction);

            return(xmlAction);
        }
예제 #23
0
    /// <summary>
    /// 提交
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Submit_Click(object sender, EventArgs e)
    {
        if (!VertifyOverTime())
        {
            return;
        }

        if (!BeforeSubmit())
        {
            return;
        }
        string id = ViewState["FormID"].ToString();

        var dataInfo = SaveFormData();

        Countersign1.SaveData(true);//会签数据保存
        Countersign_Group1.SaveData(true);
        if (dataInfo != null)
        {
            uploadAttachments.SaveAttachment(FormId);
            // Countersign1.SaveAndSubmit();//会签数据保存

            #region 工作流参数
            NameValueCollection dataFields = SetWFParams();
            if (dataFields == null)
            {
                return;
            }
            #endregion


            WorkflowHelper.CurrentUser = "******" + _BPMContext.CurrentUser.LoginId;
            AppDict appInfo = new Pkurg.BPM.Services.AppDictService().GetByAppId("10109");
            if (appInfo == null)
            {
                Alert("提交失败");
                return;
            }
            int wfInstanceId = 0; //process instance id
            WorkflowHelper.StartProcess(appInfo.WorkFlowName, FormId, dataFields, ref wfInstanceId);
            if (wfInstanceId > 0)
            {
                string instId = SaveWorkFlowInstance("1", DateTime.Now, wfInstanceId.ToString());
                if (!string.IsNullOrEmpty(instId))
                {
                    SaveWorkItem();
                    if (!AfterWorkflowStart(wfInstanceId))
                    {
                        return;
                    }
                    IFrameHelper.DownloadLocalFileUrl(instId);
                    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('提交成功');window.opener.location.href=window.opener.location.href;", true);
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null;window.open('', '_self', '');window.close();", true);
                    return;
                }
            }
        }

        Alert("提交失败");
    }
예제 #24
0
        private static string GeneratePreviewUrl(Item contentItem)
        {
            bool   hasPresentation = WorkflowHelper.DoesItemHasPresentationDetails(contentItem.ID.Guid.ToString());
            string previewUrl;

            // Generate preview link
            if (hasPresentation)
            {
                previewUrl = string.Format(Constants.PreviewUrlHasPresentation,
                                           HttpContext.Current.Request.Url.Scheme,
                                           HttpContext.Current.Request.Url.Host,
                                           contentItem.ID.Guid.ToString().ToUpper(),
                                           contentItem.Language.Name);
            }
            else
            {
                previewUrl = string.Format(Constants.PreviewUrlNoPresentation,
                                           HttpContext.Current.Request.Url.Scheme,
                                           HttpContext.Current.Request.Url.Host,
                                           contentItem.ID.Guid.ToString().ToUpper(),
                                           contentItem.Language.Name);
            }

            return(previewUrl);
        }
예제 #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Guid   sourcePointGuid = QueryHelper.GetGuid("sourcepointguid", Guid.Empty);
        string graphName       = QueryHelper.GetString("graph", String.Empty);

        if (CurrentStepInfo != null)
        {
            editElem.SourcePointGuid   = sourcePointGuid;
            editElem.RuleCategoryNames = CurrentWorkflow.IsAutomation ? ModuleName.ONLINEMARKETING : WorkflowInfo.OBJECT_TYPE;
            if (sourcePointGuid == Guid.Empty)
            {
                editElem.AfterCreateRedirectURL = UIContextHelper.GetElementUrl("CMS", "Workflows.EditCase", false);
                editElem.AfterCreateRedirectURL = URLHelper.AddParameterToUrl(editElem.AfterCreateRedirectURL, "graph", graphName);
            }
            else if (!RequestHelper.IsPostBack() && QueryHelper.GetBoolean("saved", false))
            {
                ShowChangesSaved();
                WorkflowHelper.RefreshDesignerFromDialog(Page, CurrentStepInfo.StepID, graphName);
            }
        }
        else
        {
            editElem.StopProcessing = true;
        }
    }
예제 #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            // Do nothing!
        }
        else
        {
            plcLabel.Visible = !SimpleMode;
            RequiredFieldValidatorLabel.ErrorMessage = GetString("workflowstep.sourcepoint.requireslabel");

            if (CurrentSourcePoint != null)
            {
                // Switch default doesn't have condition
                if ((CurrentSourcePoint.Type == SourcePointTypeEnum.SwitchDefault) || (CurrentSourcePoint.Type == SourcePointTypeEnum.Timeout))
                {
                    lblCondition.Visible = cbCondition.Visible = false;
                }

                if (!RequestHelper.IsPostBack())
                {
                    txtLabel.Text    = CurrentSourcePoint.Label;
                    txtText.Text     = CurrentSourcePoint.Text;
                    txtTooltip.Text  = CurrentSourcePoint.Tooltip;
                    cbCondition.Text = CurrentSourcePoint.Condition;
                }
            }

            if (cbCondition.Visible)
            {
                WorkflowInfo wi = WorkflowInfoProvider.GetWorkflowInfo(CurrentStepInfo.StepWorkflowID);
                cbCondition.ResolverName = WorkflowHelper.GetResolverName(wi);
            }
        }
    }
예제 #27
0
    protected override bool BeforeWorkflowApproval(ref string action, ref string option)
    {
        uploadAttachments.SaveAttachment(FormId);
        switch (action)
        {
        case "领取":
            option = string.IsNullOrEmpty(option) ? "已领取" : option;
            break;

        case "处理":
            option = string.IsNullOrEmpty(option) ? "处理完成" : option;
            break;

        case "驳回":
            option = string.IsNullOrEmpty(option) ? "处理完成" : option;
            // action = "处理";
            return(ChangeResultToUnAgree());

        case "提交":
            NextUser = WorkflowHelper.GetBackToPreApproverUser(_BPMContext.Sn, _BPMContext.CurrentUser.LoginId);
            NextUser = NextUser.Replace("founder\\", "");
            option   = string.IsNullOrEmpty(option) ? "处理完成" : option;
            break;

        default:
            break;
        }
        return(true);
    }
예제 #28
0
        public void Process(WorkflowPipelineArgs args)
        {
            Item   contentItem     = args.DataItem;
            string workflowComment = (!string.IsNullOrEmpty(args.CommentFields[Constants.Comments])) ? args.CommentFields[Constants.Comments] : Constants.NoComment;

            try
            {
                using (new SecurityDisabler())
                {
                    Item notifyStepItem      = args.ProcessorItem.InnerItem;
                    Item currentWorkflowStep = WorkflowHelper.GetCurrentState(args); // Current workflow state
                    Item nextWorkflowStep    = WorkflowHelper.GetNextState(args);    // Next workflow state

                    var from = notifyStepItem.Fields[Templates.NotifyNextStepUser.Fields.From].Value;
                    var emailTemplateItem = notifyStepItem.TargetItem(Templates.NotifyNextStepUser.Fields.EmailTemplate);
                    var receivers         = GetReceivers(contentItem, currentWorkflowStep.ID, nextWorkflowStep.ID);

                    _workflowNotifyService.SendEmailNotifications(receivers, from, contentItem, workflowComment, emailTemplateItem);
                }
            }
            catch (Exception ex)
            {
                Log.Error($"NotifyNextStepUser: {ex}", this);
            }
        }
예제 #29
0
    /// <summary>
    /// 将结果变为不同意
    /// </summary>
    public void ChangeResultToUnAgree()
    {
        NameValueCollection dataFields = new NameValueCollection();

        dataFields.Add("IsPass", "0");
        WorkflowHelper.UpdateDataFields(_BPMContext.Sn, dataFields, DefaultApprover);
    }
예제 #30
0
 /// <summary>
 /// 页面加载
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     //防止二次提交
     ScriptManager.RegisterOnSubmitStatement(Page, typeof(Page), "Go_disabled", "disabledButton('lbAgree');disabledButton('lbReject');disabledButton('lbSubmit');");
     ScriptManager.RegisterStartupScript(Page, typeof(Page), "Clear_disabled", "enableButton('lbAgree');enableButton('lbReject');enableButton('lbSubmit');", true);
     if (!IsPostBack)
     {
         ViewState["IsSubmit"] = false;
         if (!string.IsNullOrEmpty(Request.QueryString["sn"]))
         {
             WorkflowHelper.CurrentUser = "******" + _BPMContext.CurrentUser.LoginId;
             sn.Value = Request.QueryString["sn"];
             WorklistItem listItem = WorkflowHelper.GetWorklistItemWithSN(sn.Value, "founder\\" + _BPMContext.CurrentUser.LoginId);
             taskID.Value   = listItem.ID.ToString();
             nodeID.Value   = listItem.ActivityInstanceDestination.ActID.ToString();
             nodeName.Value = listItem.ActivityInstanceDestination.Name;
             InitApproveOpinion(nodeName.Value);
         }
         if (!string.IsNullOrEmpty(Request.QueryString["id"]))
         {
             ViewState["FormID"] = _BPMContext.ProcInst.FormId;
             BindFormData();
         }
         else
         {
             ExceptionHander.GoToErrorPage();
         }
         ShowButton();
         InitCheckBoxList();
         InitCheckButton();
         InitLeader();
     }
 }
        public void WorkflowHelperCreateWorkflowWithDisplayNameExpectedReturnsActivityBuilderWithFlowChartImplementation()
        {
            const string DisplayName = "TestResource";

            var result = new WorkflowHelper().CreateWorkflow(DisplayName);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Implementation, typeof(Flowchart));

            var flowChart = (Flowchart)result.Implementation;
            Assert.AreEqual(flowChart.DisplayName, DisplayName);
        }
예제 #32
0
        static void Main()
        {
            WorkflowHelper wfh = new WorkflowHelper();
            RuleSet rules = wfh.GetRules("GuestPassRuleSet");

            GuestPass gp1 = new GuestPass(1, 20, "2013-05-04");
            GuestPass gp2 = new GuestPass(2, 30, "2013-05-05");
            GuestPass gp3 = new GuestPass(3, 40, "2013-05-06");
            GuestPass gp4 = new GuestPass(4, 1, "");

            wfh.RunRules<GuestPass>(gp1, "GuestPassRuleSet");
            wfh.RunRules<GuestPass>(gp2, "GuestPassRuleSet");
            wfh.RunRules<GuestPass>(gp3, "GuestPassRuleSet");

            Console.WriteLine(gp1.ToString());
            Console.WriteLine(gp2.ToString());
            Console.WriteLine(gp3.ToString());

            Application.EnableVisualStyles();
            Application.Run(new RuleSetToolkitEditor());
        }
        public void WorkflowHelperSerializeWorkflowWithModelServiceExpectedReturnsActivityXaml()
        {
            var modelService = CreateModelService();

            var result = new WorkflowHelper().SerializeWorkflow(modelService.Object).ToString();

            Assert.IsFalse(result.Contains("<?xml version=\"1.0\" encoding=\"utf-16\"?>"));

            var root = XElement.Parse(result);

            XNamespace sads = "http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger";
            var debugSymbol = root.Element(sads + "DebugSymbol.Symbol");
            if(debugSymbol != null)
            {
                Assert.IsTrue(string.IsNullOrEmpty(debugSymbol.Value));
            }

            XNamespace mva = "clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities";
            var vbSettings = root.Element(mva + "VisualBasic.Settings");
            Assert.IsNotNull(vbSettings);

            XNamespace a = "http://schemas.microsoft.com/netfx/2009/xaml/activities";
            XNamespace x = "http://schemas.microsoft.com/winfx/2006/xaml";

            var namespacesForImplementation = root.Element(a + "TextExpression.NamespacesForImplementation");
            Assert.IsNotNull(namespacesForImplementation);

            XNamespace scg = "clr-namespace:System.Collections.Generic;assembly=mscorlib";
            var nsList = namespacesForImplementation.Element(scg + "List");
            Assert.IsNotNull(nsList);

            var actualNamespaces = nsList.Elements(x + "String").Select(e => e.Value).ToList();
            Assert.IsTrue(ExpectedNamespaces.SequenceEqual(actualNamespaces));

            var referencesForImplementation = root.Element(a + "TextExpression.ReferencesForImplementation");
            Assert.IsNotNull(referencesForImplementation);

            XNamespace sco = "clr-namespace:System.Collections.ObjectModel;assembly=mscorlib";
            var asmList = referencesForImplementation.Element(sco + "Collection");
            Assert.IsNotNull(asmList);

            var actualAssemblies = asmList.Elements(a + "AssemblyReference").Select(e => e.Value).ToList();
            Assert.IsTrue(ExpectedAssemblies.SequenceEqual(actualAssemblies));
        }
 public void WorkflowHelperSerializeWorkflowWithNullModelServiceExpectedReturnsEmptyString()
 {
     var result = new WorkflowHelper().SerializeWorkflow(null);
     Assert.AreEqual(string.Empty, result.ToString());
 }