Example #1
0
        public virtual void StartQualificationProcess()
        {
            Guid leadManagementProcessUId = (Guid)Terrasoft.Core.Configuration.SysSettings.GetValue(
                UserConnection, "LeadManagementProcess");
            ProcessSchema schema;

            if (leadManagementProcessUId.IsEmpty())
            {
                schema = UserConnection.ProcessSchemaManager.GetInstanceByName("LeadManagement");
            }
            else
            {
                schema = UserConnection.ProcessSchemaManager.GetInstanceByUId(leadManagementProcessUId);
            }
            bool canUseFlowEngine = ProcessSchemaManager.GetCanUseFlowEngine(UserConnection, schema);

            if (canUseFlowEngine)
            {
                var flowEngine = new FlowEngine(UserConnection);
                var param      = new Dictionary <string, string>();
                param["LeadId"] = Entity.Id.ToString();
                flowEngine.RunProcess(schema, param);
            }
            else
            {
                Process process = schema.CreateProcess(UserConnection);
                process.SetPropertyValue("LeadId", Entity.Id);
                process.Execute(UserConnection);
            }
        }
        private void PublishNotification(string processUId)
        {
            IProcessEngine processEngine = _userConnection.IProcessEngine;
            Process        process       = processEngine.FindProcessByUId(processUId, true);

            if (process == null || process.Status != ProcessStatus.Running)
            {
                return;
            }
            var  schema           = (BaseProcessSchema)process.Schema;
            bool canUseFlowEngine = ProcessSchemaManager.GetCanUseFlowEngine(_userConnection, schema);

            foreach (Collection <ProcessFlowElement> processElements in process.FlowElements.Values)
            {
                foreach (ProcessFlowElement processElement in processElements)
                {
                    if (processElement.Status != ProcessStatus.Running)
                    {
                        continue;
                    }
                    if (processElement.IsProcess)
                    {
                        PublishNotification(processElement.UId.ToString());
                        continue;
                    }
                    object showExecutionPage;
                    if (!processElement.TryGetPropertyValue("ShowExecutionPage", out showExecutionPage))
                    {
                        continue;
                    }
                    if (canUseFlowEngine)
                    {
                        try {
                            InitializeProcessElement(processElement);
                        }
                        catch (Exception e) {
                            AddErrorInfo(process, processElement, e);
                            continue;
                        }
                    }
                    try {
                        PublishNotificationMethod.Invoke(processElement, null);
                        UpdateProcessElementData(processElement);
                    }
                    catch (Exception e) {
                        AddErrorInfo(process, processElement, e);
                    }
                }
            }
        }
 public virtual bool CanUseFlowEngine(ProcessSchema processSchema)
 {
     return(ProcessSchemaManager.GetCanUseFlowEngine(UserConnection, processSchema));
 }
 protected virtual bool GetIsUseFlowEngine(EmailTemplateUserTask userTask)
 {
     return(!userTask.Owner.IsEmbedded &&
            ProcessSchemaManager.GetCanUseFlowEngine(userTask.UserConnection, userTask.Owner.ProcessSchema));
 }