Ejemplo n.º 1
0
        /// <summary>
        /// 初始化流程FLActivity
        /// </summary>
        /// <param name="activity"></param>
        /// <param name="wfActivity"></param>
        private void InitFLActivities(IFLActivity activity, object wfActivity)
        {
            //if (wfActivity is IEventWaiting)
            //{
            //    IEventWaiting m = (IEventWaiting)activity;
            //    IEventWaiting n = (IEventWaiting)wfActivity;
            //    m.AllowSendBack = n.AllowSendBack;
            //}

            if (wfActivity is IFLRootActivity)
            {
                IFLRootActivity m = (IFLRootActivity)activity;
                IFLRootActivity n = (IFLRootActivity)wfActivity;

                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;

                m.EEPAlias = n.EEPAlias;
                m.TableName = n.TableName;
                m.Keys = n.Keys;
                m.PresentFields = n.PresentFields;
                m.OrgKind = (_orgKind == null || _orgKind == string.Empty) ? n.OrgKind : _orgKind;
                m.FormName = n.FormName;
                m.WebFormName = n.WebFormName;
                m.ExpTime = n.ExpTime;
                m.ExpTimeField = n.ExpTimeField;
                m.UrgentTime = n.UrgentTime;
                m.TimeUnit = n.TimeUnit;
                m.NotifySendMail = n.NotifySendMail;
                m.SkipForSameUser = n.SkipForSameUser;
                m.RejectProcedure = n.RejectProcedure;
                m.BodyField = n.BodyField;
            }
            else if (wfActivity is IFLDetailsActivity)
            {
                IFLDetailsActivity m = (IFLDetailsActivity)activity;
                IFLDetailsActivity n = (IFLDetailsActivity)wfActivity;

                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;

                m.DetailsTableName = n.DetailsTableName;
                m.ParallelField = n.ParallelField;
                m.SendToMasterField = n.SendToMasterField;
                m.ParallelMode = n.ParallelMode;
                m.ParallelRate = n.ParallelRate;
                m.RelationKeys = n.RelationKeys;
                m.SendToField = n.SendToField;

                m.ExpTime = n.ExpTime;
                m.FLNavigatorMode = n.FLNavigatorMode;
                m.FLNavigatorField = n.FLNavigatorField;
                m.FormName = n.FormName;
                m.WebFormName = n.WebFormName;
                m.NavigatorMode = n.NavigatorMode;
                m.Parameters = n.Parameters;

                m.ExtApproveID = n.ExtApproveID;
                m.ExtGroupField = n.ExtGroupField;
                m.ExtValueField = n.ExtValueField;

                m.SendToKind = n.SendToKind;
                m.SendToRole = n.SendToRole;
                m.SendToUser = n.SendToUser;
                m.TimeUnit = n.TimeUnit;
                m.UrgentTime = n.UrgentTime;
                m.SendEmail = n.SendEmail;

                m.AllowSendBack = n.AllowSendBack;

                m.PlusApprove = n.PlusApprove;
                m.PlusApproveReturn = n.PlusApproveReturn;

                #region  --- 修改为动态---

                //if (_hostDataSet == null)
                //{
                //    _hostDataSet = HostTable.GetHostDataSet(this, _keyValues, _clientInfo);
                //}

                //Activity temp = FLInstance.GetActivityByXoml(_flDefinitionFile, string.Empty);
                //IFLRootActivity rootActivity = (IFLRootActivity)temp;

                //DataSet detailsDataSet = HostTable.GetDetailsDataSet(_hostDataSet, rootActivity.Keys, n.DetailsTableName, n.RelationKeys, _clientInfo);
                //string parallelField = n.ParallelField;
                //string sendToField = n.SendToField;

                //if (detailsDataSet != null && detailsDataSet.Tables.Count != 0 && detailsDataSet.Tables[0].Rows.Count != 0)
                //{
                //    int i0 = 1;
                //    int i1 = 1;
                //    int i2 = 1;

                //    FLParallelActivity parallelActivity = null;
                //    foreach (DataRow row in detailsDataSet.Tables[0].Rows)
                //    {
                //        FLStandActivity stand = new FLStandActivity();

                //        //stand.Name = n.Name + "_s" + i0.ToString();
                //        stand.Name = n.Name + "_" + i0.ToString();
                //        i0++;

                //        stand.Description = ((FLDetails)n).Description;
                //        stand.Enabled = ((FLDetails)n).Enabled;

                //        stand.ExpTime = ((FLDetails)n).ExpTime;
                //        stand.FLNavigatorMode = ((FLDetails)n).FLNavigatorMode;
                //        stand.FormName = ((FLDetails)n).FormName;
                //        stand.WebFormName = ((FLDetails)n).WebFormName;
                //        stand.NavigatorMode = ((FLDetails)n).NavigatorMode;
                //        stand.Parameters = ((FLDetails)n).Parameters;
                //        stand.SendToField = ((FLDetails)n).SendToField;
                //        stand.SendToKind = ((FLDetails)n).SendToKind;
                //        stand.SendToRole = ((FLDetails)n).SendToRole;
                //        stand.TimeUnit = ((FLDetails)n).TimeUnit;
                //        stand.UrgentTime = ((FLDetails)n).UrgentTime;
                //        stand.SendEmail = ((FLDetails)n).SendEmail;
                //        stand.PlusApprove = false;

                //        object sendToId2 = row[sendToField];
                //        if (sendToId2 == null || sendToId2 == DBNull.Value || sendToId2.ToString() == string.Empty)
                //        {
                //            continue;
                //            //String message = string.Format(SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(_clientInfo[0]))[0]), "FLRuntime", "FLInstance", "SendToFieldValueIsNull"), n.DetailsTableName);
                //            //throw new FLException(message);
                //        }
                //        ((ISupportFLDetailsActivity)stand).SendToId2 = sendToId2.ToString();

                //        if (!string.IsNullOrEmpty(parallelField))
                //        {
                //            object isParallel = row[parallelField];
                //            if ((isParallel != null && isParallel != DBNull.Value) &&
                //                (isParallel.ToString().Trim().ToLower() == "y" || isParallel.ToString().Trim().ToLower() == "and"))
                //            {
                //                if (parallelActivity == null)
                //                {
                //                    parallelActivity = new FLParallelActivity();
                //                    parallelActivity.Description = n.ParallelRate > 0 ? string.Format("rate:{0}", n.ParallelRate) : "and";
                //                    parallelActivity.Name = n.Name + "_p" + i2.ToString();
                //                    i2++;

                //                    ((FLActivity)m).ChildFLActivities.Add(parallelActivity);
                //                }

                //                FLSequenceActivity sequenceActivity = new FLSequenceActivity();
                //                sequenceActivity.Name = n.Name + "_se" + i1.ToString();
                //                i1++;
                //                ((FLActivity)parallelActivity).ChildFLActivities.Add(sequenceActivity);

                //                ((FLActivity)sequenceActivity).ChildFLActivities.Add(stand);
                //            }
                //            else
                //            {
                //                parallelActivity = null;
                //                ((FLActivity)m).ChildFLActivities.Add(stand);
                //            }
                //        }
                //        else
                //        {
                //            parallelActivity = null;
                //            ((FLActivity)m).ChildFLActivities.Add(stand);
                //        }
                //    }
                //}

                #endregion
            }
            else if (wfActivity is IFLSubFlowActivity)
            {
                IFLSubFlowActivity m = (IFLSubFlowActivity)activity;
                IFLSubFlowActivity n = (IFLSubFlowActivity)wfActivity;

                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;

                m.IncludeFirstActivity = n.IncludeFirstActivity;
                m.XomlName = n.XomlName;
                m.XomlField = n.XomlField;
                //    m.Name = n.Name;
                //    m.Description = n.Description;
                //    m.Enabled = n.Enabled;

                //    string xomlName = n.XomlName;

                //    IFLActivity temp1 = new FLRootActivity();

                //    FileInfo fileInfo = new FileInfo(_flDefinitionFile);
                //    string file = fileInfo.Directory + @"\" + xomlName;
                //    Activity temp2 = GetActivityByXoml(file, string.Empty);

                //    InitFLActivities(temp1, temp2);

                //    List<string> temp3 = new List<string>();
                //    foreach (FLActivity a in ((FLActivity)temp1).ChildFLActivities)
                //    {
                //        temp3.Add(a.Name);
                //    }

                //    bool isFirst = true;
                //    foreach (string k in temp3)
                //    {
                //        if (isFirst && !n.IncludeFirstActivity)
                //        {
                //            isFirst = false; continue;
                //        }

                //        FLActivity temp4 = ((FLActivity)temp1).GetFLActivityByName(k);
                //        temp4.Enabled = n.Enabled;

                //        ((FLActivity)temp1).ChildFLActivities.Remove(temp4);
                //        ((FLActivity)m).ChildFLActivities.Add(temp4);
                //    }
            }
            else if (wfActivity is IEventWaiting)
            {
                IEventWaiting m = (IEventWaiting)activity;
                IEventWaiting n = (IEventWaiting)wfActivity;

                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;

                m.ExpTime = n.ExpTime;
                m.FLNavigatorMode = n.FLNavigatorMode;
                m.FormName = n.FormName;
                m.WebFormName = n.WebFormName;
                m.NavigatorMode = n.NavigatorMode;
                m.Parameters = n.Parameters;
                m.SendToField = n.SendToField;
                m.SendToKind = n.SendToKind;
                m.SendToRole = n.SendToRole;
                m.SendToUser = n.SendToUser;
                m.TimeUnit = n.TimeUnit;
                m.UrgentTime = n.UrgentTime;
                m.SendEmail = n.SendEmail;

                m.AllowSendBack = n.AllowSendBack;

                if (wfActivity is IFLStandActivity)
                {
                    ((IFLStandActivity)m).PlusApprove = ((IFLStandActivity)n).PlusApprove;
                    ((IFLStandActivity)m).PlusApproveReturn = ((IFLStandActivity)n).PlusApproveReturn;
                    ((IFLStandActivity)m).DelayAutoApprove = ((IFLStandActivity)n).DelayAutoApprove;
                }
                else if (wfActivity is IFLApproveActivity)
                {
                    IFLApproveActivity q = (IFLApproveActivity)activity;
                    IFLApproveActivity p = (IFLApproveActivity)wfActivity;

                    ((IFLApproveActivity)q).PlusApprove = ((IFLApproveActivity)p).PlusApprove;
                    ((IFLApproveActivity)q).PlusApproveReturn = ((IFLApproveActivity)p).PlusApproveReturn;
                    ((IFLApproveActivity)q).DelayAutoApprove = ((IFLApproveActivity)p).DelayAutoApprove;

                    List<IFLApproveBranchActivity> list = p.GetApproveRights();
                    foreach (IFLApproveBranchActivity a in list)
                    {
                        FLApproveBranchActivity approveBranch = new FLApproveBranchActivity();
                        approveBranch.Grade = a.Grade;
                        approveBranch.Expression = a.Expression;
                        approveBranch.Name = activity.Name + "-" + a.Name;

                        approveBranch.Description = m.Description;
                        approveBranch.ExpTime = m.ExpTime;
                        approveBranch.FLNavigatorMode = m.FLNavigatorMode;
                        approveBranch.FormName = m.FormName;
                        approveBranch.WebFormName = m.WebFormName;
                        approveBranch.NavigatorMode = m.NavigatorMode;
                        approveBranch.Parameters = m.Parameters;
                        approveBranch.SendToField = m.SendToField;
                        approveBranch.SendToKind = m.SendToKind;
                        approveBranch.SendToRole = m.SendToRole;
                        approveBranch.SendToUser = m.SendToUser;
                        approveBranch.TimeUnit = m.TimeUnit;
                        approveBranch.UrgentTime = m.UrgentTime;
                        approveBranch.SendEmail = m.SendEmail;
                        approveBranch.AllowSendBack = m.AllowSendBack;

                        approveBranch.ParentActivity = activity.Name;
                        activity.AddFLActivity(approveBranch);
                    }
                }
            }
            else if (wfActivity is IfElseActivity)
            {
                IFLIfElseActivity m = (IFLIfElseActivity)activity;
                IfElseActivity n = (IfElseActivity)wfActivity;

                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;
            }
            else if (wfActivity is IfElseBranchActivity)
            {
                IFLIfElseBranchActivity m = (IFLIfElseBranchActivity)activity;
                IfElseBranchActivity n = (IfElseBranchActivity)wfActivity;

                m.Name = n.Name;
                m.Condition = n.Description == null ? string.Empty : n.Description.ToString();
                m.Description = n.Description;
                m.Enabled = n.Enabled;
                //m.Condition = n.Condition == null ? string.Empty : n.Condition.ToString();
            }
            else if (wfActivity is ParallelActivity)
            {
                IFLParallelActivity m = (IFLParallelActivity)activity;
                ParallelActivity n = (ParallelActivity)wfActivity;

                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;
            }
            else if (wfActivity is SequenceActivity)
            {
                IFLSequenceActivity m = (IFLSequenceActivity)activity;
                SequenceActivity n = (SequenceActivity)wfActivity;

                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;
            }
            else if (wfActivity is IFLNotifyActivity)
            {
                IFLNotifyActivity m = (IFLNotifyActivity)activity;
                IFLNotifyActivity n = (IFLNotifyActivity)wfActivity;

                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;

                m.ExpTime = n.ExpTime;
                m.FLNavigatorMode = n.FLNavigatorMode;
                m.FormName = n.FormName;
                m.WebFormName = n.WebFormName;
                m.NavigatorMode = n.NavigatorMode;
                m.Parameters = n.Parameters;
                m.SendToField = n.SendToField;
                m.SendToKind = n.SendToKind;
                m.SendToRole = n.SendToRole;
                m.SendToUser = n.SendToUser;
                m.TimeUnit = n.TimeUnit;
                m.UrgentTime = n.UrgentTime;
                m.SendEmail = n.SendEmail;
            }
            else if (wfActivity is IFLProcedureActivity)
            {
                IFLProcedureActivity m = (IFLProcedureActivity)activity;
                IFLProcedureActivity n = (IFLProcedureActivity)wfActivity;

                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;

                m.ErrorLog = n.ErrorLog;
                m.ErrorToRole = n.ErrorToRole;
                m.MethodName = n.MethodName;
                m.ModuleName = n.ModuleName;
            }
            else if (wfActivity is IFLValidateActivity)
            {
                IFLValidateActivity m = (IFLValidateActivity)activity;
                IFLValidateActivity n = (IFLValidateActivity)wfActivity;

                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;

                m.Expression = n.Expression;
                m.Message = n.Message;
            }
            else if (wfActivity is IFLHyperLinkActivity)
            {
                IFLHyperLinkActivity m = (IFLHyperLinkActivity)activity;
                IFLHyperLinkActivity n = (IFLHyperLinkActivity)wfActivity;

                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;

                m.Parameters = n.Parameters;
            }
            else if (wfActivity is IFLQueryActivity)
            {
                IFLQueryActivity m = (IFLQueryActivity)activity;
                IFLQueryActivity n = (IFLQueryActivity)wfActivity;

                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;

                m.Parameters = n.Parameters;
            }
            else if (wfActivity is IFLRejectActivity)
            {
                IFLRejectActivity m = (IFLRejectActivity)activity;
                IFLRejectActivity n = (IFLRejectActivity)wfActivity;

                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;

                m.ExpTime = n.ExpTime;
                m.FLNavigatorMode = n.FLNavigatorMode;
                m.FormName = n.FormName;
                m.WebFormName = n.WebFormName;
                m.NavigatorMode = n.NavigatorMode;
                m.Parameters = n.Parameters;
                m.SendToField = n.SendToField;
                m.SendToKind = n.SendToKind;
                m.SendToRole = n.SendToRole;
                m.SendToUser = n.SendToUser;
                m.TimeUnit = n.TimeUnit;
                m.UrgentTime = n.UrgentTime;
                m.SendEmail = n.SendEmail;
            }
            else if (wfActivity is IFLGotoActivity)
            {
                IFLGotoActivity m = (IFLGotoActivity)activity;
                IFLGotoActivity n = (IFLGotoActivity)wfActivity;
                m.Name = n.Name;
                m.Description = n.Description;
                m.Enabled = n.Enabled;
                m.ActivityName = n.ActivityName;
            }
            else
            {
                String message = string.Format(SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(_clientInfo[0]))[0]), "FLRuntime", "FLInstance", "NotSupportActivityType"), wfActivity.GetType().Name);
                throw new FLException(message);
            }

            if (wfActivity is CompositeActivity)
            {
                CompositeActivity compositeActivity = (CompositeActivity)wfActivity;
                foreach (Activity child in compositeActivity.Activities)
                {
                    IFLActivity a = null;
                    if (child is IFLSubFlowActivity)
                    {
                        //a = new FLSequenceActivity();
                        a = new FLSubFlowActivity();
                    }
                    else if (child is IFLDetailsActivity)
                    {
                        //a = new FLSequenceActivity();
                        a = new FLDetailsActivity();
                    }
                    else if (child is IFLStandActivity)
                    {
                        a = new FLStandActivity();
                    }
                    else if (child is IFLApproveActivity)
                    {
                        a = new FLApproveActivity();
                    }
                    else if (child is IfElseActivity)
                    {
                        a = new FLIfElseActivity();
                    }
                    else if (child is IfElseBranchActivity)
                    {
                        a = new FLIfElseBranchActivity();
                    }
                    else if (child is ParallelActivity)
                    {
                        a = new FLParallelActivity();
                    }
                    else if (child is SequenceActivity)
                    {
                        a = new FLSequenceActivity();
                    }
                    else if (child is IFLNotifyActivity)
                    {
                        a = new FLNotifyActivity();
                    }
                    else if (child is IFLProcedureActivity)
                    {
                        a = new FLProcedureActivity();
                    }
                    else if (child is IFLValidateActivity)
                    {
                        a = new FLValidateActivity();
                    }
                    else if (child is IFLHyperLinkActivity)
                    {
                        a = new FLHyperLinkActivity();
                    }
                    else if (child is IFLQueryActivity)
                    {
                        a = new FLQueryActivity();
                    }
                    else if (child is IFLRejectActivity)
                    {
                        a = new FLRejectActivity();
                    }
                    else if (child is IFLGotoActivity)
                    {
                        a = new FLGotoActivity();
                    }
                    else
                    {
                        String message = string.Format(SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(_clientInfo[0]))[0]), "FLRuntime", "FLInstance", "NotSupportActivityType"), wfActivity.GetType().Name);
                        throw new FLException(message);
                    }

                    activity.AddFLActivity(a);
                    InitFLActivities(a, child);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 取得下一Activity的集合
        /// </summary>
        /// <param name="currentFLActivity">当前Activity</param>
        /// <param name="nextFLActivities">下一Activity的集合</param>
        private void GetNextFLActivities(FLActivity currentFLActivity, List<FLActivity> nextFLActivities)
        {
            SetUpperParallel(currentFLActivity);
            SetLocation(currentFLActivity);

            if (_isFirstInParallel && ((_tempParallel != currentFLActivity.UpperParallel) || (_tempParallelBranch != currentFLActivity.UpperParallelBranch)))
            {
                return;
            }

            if (currentFLActivity is IFLNotifyActivity || currentFLActivity is IFLProcedureActivity)
            {
                if (!nextFLActivities.Exists(
                    delegate(FLActivity flActivity)
                    {
                        if (currentFLActivity.Name == flActivity.Name)
                            return true;
                        else
                            return false;
                    }
                ) && currentFLActivity.Enabled)
                {

                    if (currentFLActivity is IFLProcedureActivity && !preview)
                    {
                        Logic.CallServerMethod(this, FLInstanceParms, this._keyValues, this._clientInfo, currentFLActivity as IFLProcedureActivity);
                    }

                    nextFLActivities.Add(currentFLActivity);
                }
            }

            if (currentFLActivity is IFLRejectActivity && currentFLActivity.Enabled)
            {
                nextFLActivities.Clear();
                nextFLActivities.Add(currentFLActivity);

                return;
            }

            if (currentFLActivity is IFLGotoActivity && currentFLActivity.Enabled)
            {
                nextFLActivities.Clear();
                nextFLActivities.Add(currentFLActivity);

                return;
            }

            if (currentFLActivity is IFLValidateActivity)
            {
                if (!nextFLActivities.Exists(
                    delegate(FLActivity flActivity)
                    {
                        if (currentFLActivity.Name == flActivity.Name)
                            return true;
                        else
                            return false;
                    }
                ) && currentFLActivity.Enabled && !preview)
                {
                    nextFLActivities.Add(currentFLActivity);

                    if (!JudgeCondition(((IFLValidateActivity)currentFLActivity).Expression))
                    {
                        _v = false;
                        _vN = currentFLActivity.Name;
                        VM = ((IFLValidateActivity)currentFLActivity).Message;
                        return;

                        //String message = string.Format(SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(_clientInfo[0]))[0]), "FLRuntime", "FLInstance", "ValidateFail"), currentFLActivity.Name);
                        //throw new FLException(2, message);
                    }
                }
            }

            FLActivity activity = null;
            if ((currentFLActivity is IFLApproveActivity && currentFLActivity.ExecutionStatus != FLActivityExecutionStatus.Executed) || currentFLActivity is IFLApproveBranchActivity)
            {
                #region

                List<FLActivity> approveRights;
                FLActivity approveActivity = null;
                if (currentFLActivity is IFLApproveActivity)
                {
                    approveRights = currentFLActivity.ChildFLActivities;
                    approveActivity = currentFLActivity;
                }
                else
                {
                    approveActivity = _rootFLActivity.GetFLActivityByName(((IFLApproveBranchActivity)currentFLActivity).ParentActivity);
                    approveRights = approveActivity.ChildFLActivities;
                }

                string roleId = string.Empty;
                string orgKind = ((IFLRootActivity)_rootFLActivity).OrgKind;
                if (((IEventWaiting)approveActivity).SendToKind == SendToKind.Manager || ((FLApproveActivity)approveActivity).I > 0)           // Manager或者RefManager第一次进
                {
                    roleId = ((IEventWaitingExecute)_sendFromFLActivity).RoleId;
                }
                else if (((IEventWaiting)approveActivity).SendToKind == SendToKind.RefManager)      // RefManager第二次进
                {
                    string sendToField = ((IEventWaiting)approveActivity).SendToField;
                    string values = _keyValues[1].ToString();

                    string tableName = _rootFLActivity.TableName;
                    string qq = Global.GetRoleIdByRefRole(this, sendToField, tableName, values, _clientInfo);
                    roleId = qq;//Global.GetManagerRoleId(qq.ToString(), orgKind, _clientInfo);
                }
                else if (((IEventWaiting)approveActivity).SendToKind == SendToKind.ApplicateManager)
                {
                    if (!string.IsNullOrEmpty(this.CreateRole))
                    {
                        roleId = this.CreateRole;
                    }
                    else
                    {
                        string user = this.Creator;
                        List<string> roles = Global.GetRoleIdsByUserId(user, _clientInfo);
                        if (roles.Count > 0)
                        {
                            roleId = roles[0];
                        }
                    }
                }

                if (((IEventWaiting)approveActivity).SendToKind == SendToKind.Manager && string.IsNullOrEmpty(roleId))
                {
                    if (preview)
                    {
                        return;
                    }
                    else
                    {
                        String message = string.Format(SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(_clientInfo[0]))[0]), "FLRuntime", "InstanceManager", "UserNotHaveRole"), ((IEventWaitingExecute)_sendFromFLActivity).UserId);
                        throw new FLException(2, message);
                    }
                }

                bool b = false;
                string levelNo = Global.GetLevelNo(roleId, orgKind, _clientInfo);

                if (!string.IsNullOrEmpty(levelNo))
                {
                    List<string> gRoleIds = new List<string>();
                    foreach (FLActivity a in approveRights)
                    {
                        gRoleIds.Clear();

                        if (JudgeCondition(((IFLApproveBranchActivity)a).Expression))
                        {
                            string grade = string.Empty;
                            string name = string.Empty;
                            string roleId2 = roleId;
                            string roleId3 = string.Empty;
                            bool bb = true;
                            do
                            {
                                roleId3 = roleId2;
                                grade = Global.GetManagerLevelNo(roleId3, orgKind, _clientInfo);
                                if (string.IsNullOrEmpty(grade)) { bb = false; break; }
                                name = approveActivity.Name + "-" + grade;
                                roleId2 = Global.GetManagerRoleId(roleId3, orgKind, _clientInfo);
                                if (gRoleIds.Contains(roleId2))
                                {
                                    String message = string.Format(SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(_clientInfo[0]))[0]), "FLRuntime", "InstanceManager", "UserManagerIsCircle"), roleId2);
                                    throw new FLException(2, message);
                                }
                                if (roleId2 == roleId3)
                                {
                                    String message = string.Format(SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(_clientInfo[0]))[0]), "FLRuntime", "InstanceManager", "UserManagerCanNotBeYouself"), roleId2);
                                    throw new FLException(2, message);
                                }
                                gRoleIds.Add(roleId2);
                            }
                            while (!(name == a.Name || (((FLApproveActivity)approveActivity).I == 0 && a.Name == approveActivity.Name + "-0")));

                            if (!bb)
                            {
                                continue;
                            }

                            _r = roleId3;

                            if (approveRights.IndexOf(a) == approveRights.Count - 1 && currentFLActivity.Name == name)  // add by andy
                            {
                                break;
                            }

                            SetUpperParallel(a);
                            SetLocation(a);
                            nextFLActivities.Add(a);
                            b = true;
                            approveActivity.Execute();
                            ((FLApproveActivity)approveActivity).I++;
                            break;
                        }
                    }
                }

                if (!b)
                {
                    approveActivity.Execute();

                    GetNextFLActivities(approveActivity, nextFLActivities);
                }

                #endregion
            }
            else if (currentFLActivity is IFLDetailsActivity && currentFLActivity.ExecutionStatus != FLActivityExecutionStatus.Executed)
            {
                #region

                IFLDetailsActivity detailsActivity = (IFLDetailsActivity)currentFLActivity;
                if (_hostDataSet == null)
                {
                    _hostDataSet = HostTable.GetHostDataSet(this, _keyValues, _clientInfo);
                }

                currentFLActivity.ClearActivities();
                FLActivity childActivity = null;
                if (!string.IsNullOrEmpty(detailsActivity.ExtApproveID))
                {
                    childActivity = new FLSequenceActivity();
                    DataRow hostRow = _hostDataSet.Tables[0].Rows[0];
                    string groupID = hostRow[detailsActivity.ExtGroupField].ToString();
                    object value = hostRow[detailsActivity.ExtValueField];
                    List<string> roles = Global.GetExtApproveRoles(detailsActivity.ExtApproveID, groupID, value, _clientInfo);
                    for (int i = 0; i < roles.Count; i++)
                    {
                        FLStandActivity stand = new FLStandActivity();
                        stand.Name = detailsActivity.Name + "_" + i.ToString();
                        childActivity.AddFLActivity(stand);
                        stand.Description = ((IFLDetailsActivity)detailsActivity).Description;
                        stand.Enabled = ((IFLDetailsActivity)detailsActivity).Enabled;
                        stand.ExpTime = ((IFLDetailsActivity)detailsActivity).ExpTime;
                        stand.FLNavigatorMode = ((IFLDetailsActivity)detailsActivity).FLNavigatorMode;
                        stand.FormName = ((IFLDetailsActivity)detailsActivity).FormName;
                        stand.WebFormName = ((IFLDetailsActivity)detailsActivity).WebFormName;
                        stand.NavigatorMode = ((IFLDetailsActivity)detailsActivity).NavigatorMode;
                        stand.Parameters = ((IFLDetailsActivity)detailsActivity).Parameters;
                        stand.SendToField = ((IFLDetailsActivity)detailsActivity).SendToField;
                        stand.SendToKind = ((IFLDetailsActivity)detailsActivity).SendToKind;
                        stand.SendToRole = ((IFLDetailsActivity)detailsActivity).SendToRole;
                        stand.SendToUser = ((IFLDetailsActivity)detailsActivity).SendToUser;
                        stand.TimeUnit = ((IFLDetailsActivity)detailsActivity).TimeUnit;
                        stand.UrgentTime = ((IFLDetailsActivity)detailsActivity).UrgentTime;
                        stand.SendEmail = ((IFLDetailsActivity)detailsActivity).SendEmail;
                        stand.PlusApprove = ((IFLDetailsActivity)detailsActivity).PlusApprove;
                        stand.PlusApproveReturn = ((IFLDetailsActivity)detailsActivity).PlusApproveReturn;
                        stand.AllowSendBack = ((IFLDetailsActivity)detailsActivity).AllowSendBack;

                        ((ISupportFLDetailsActivity)stand).SendToId2 = roles[i];
                    }

                    if (childActivity.ChildFLActivities.Count > 0) //当有子activity时才加入
                    {
                        ((FLActivity)detailsActivity).AddFLActivity(childActivity);
                    }
                }
                else if (!string.IsNullOrEmpty(detailsActivity.SendToMasterField))
                {
                    #region

                    DataRow hostRow = _hostDataSet.Tables[0].Rows[0];
                    string ids = string.Empty;

                    if (hostRow.Table.Columns.Contains(detailsActivity.SendToMasterField))
                    {
                        //String message = string.Format(SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(_clientInfo[0]))[0]), "FLRuntime", "FLInstance", "TableNotExistColumn"), _rootFLActivity.TableName, detailsActivity.SendToMasterField);
                        //throw new FLException(2, message);

                        object obj = hostRow[detailsActivity.SendToMasterField];
                        if (obj != null && obj != DBNull.Value && !string.IsNullOrEmpty(obj.ToString()))
                        {
                            //String message = string.Format(SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(_clientInfo[0]))[0]), "FLRuntime", "FLInstance", "SendToFieldValueIsNull"), _rootFLActivity.TableName, detailsActivity.SendToMasterField);
                            //throw new FLException(2, message);
                            ids = obj.ToString();
                        }
                    }

                    if (detailsActivity.ParallelMode == ParallelMode.And || detailsActivity.ParallelMode == ParallelMode.Or)
                    {
                        childActivity = new FLParallelActivity();
                        childActivity.Description = (detailsActivity.ParallelMode == ParallelMode.And && detailsActivity.ParallelRate > 0) ?
                            string.Format("rate:{0}", detailsActivity.ParallelRate) : detailsActivity.ParallelMode.ToString();
                        childActivity.Name = detailsActivity.Name + "_p1";
                    }
                    else
                    {
                        childActivity = new FLSequenceActivity();
                        childActivity.Name = detailsActivity.Name + "_se1";
                    }

                    int i0 = 0;
                    string[] sendToIds = ids.ToString().Split(",".ToCharArray());
                    foreach (string sendToId in sendToIds)
                    {
                        if (string.IsNullOrEmpty(sendToId))
                        {
                            continue;
                        }

                        FLStandActivity stand = new FLStandActivity();
                        stand.Name = detailsActivity.Name + "_" + i0.ToString();
                        i0++;
                        if (detailsActivity.ParallelMode == ParallelMode.And || detailsActivity.ParallelMode == ParallelMode.Or)
                        {
                            FLSequenceActivity sequenceActivity = new FLSequenceActivity();
                            sequenceActivity.Name = detailsActivity.Name + "_se" + i0.ToString();
                            sequenceActivity.AddFLActivity(stand);
                            childActivity.AddFLActivity(sequenceActivity);
                        }
                        else
                        {
                            childActivity.AddFLActivity(stand);
                        }

                        stand.Description = ((IFLDetailsActivity)detailsActivity).Description;
                        stand.Enabled = ((IFLDetailsActivity)detailsActivity).Enabled;

                        stand.ExpTime = ((IFLDetailsActivity)detailsActivity).ExpTime;
                        stand.FLNavigatorMode = ((IFLDetailsActivity)detailsActivity).FLNavigatorMode;
                        stand.FormName = ((IFLDetailsActivity)detailsActivity).FormName;
                        stand.WebFormName = ((IFLDetailsActivity)detailsActivity).WebFormName;
                        stand.NavigatorMode = ((IFLDetailsActivity)detailsActivity).NavigatorMode;
                        stand.Parameters = ((IFLDetailsActivity)detailsActivity).Parameters;
                        stand.SendToField = ((IFLDetailsActivity)detailsActivity).SendToField;
                        stand.SendToKind = ((IFLDetailsActivity)detailsActivity).SendToKind;
                        stand.SendToRole = ((IFLDetailsActivity)detailsActivity).SendToRole;
                        stand.SendToUser = ((IFLDetailsActivity)detailsActivity).SendToUser;
                        stand.TimeUnit = ((IFLDetailsActivity)detailsActivity).TimeUnit;
                        stand.UrgentTime = ((IFLDetailsActivity)detailsActivity).UrgentTime;
                        stand.SendEmail = ((IFLDetailsActivity)detailsActivity).SendEmail;
                        stand.PlusApprove = ((IFLDetailsActivity)detailsActivity).PlusApprove;
                        stand.PlusApproveReturn = ((IFLDetailsActivity)detailsActivity).PlusApproveReturn;
                        stand.AllowSendBack = ((IFLDetailsActivity)detailsActivity).AllowSendBack;

                       // ((ISupportFLDetailsActivity)stand).SendToId2 = sendToId;
                        if (((IFLDetailsActivity)detailsActivity).SendToKind == SendToKind.RefRole)
                        {
                            stand.SendToKind = SendToKind.Role;
                            stand.SendToRole = sendToId;
                        }
                        else if (((IFLDetailsActivity)detailsActivity).SendToKind == SendToKind.RefUser)
                        {
                            stand.SendToKind = SendToKind.User;
                            stand.SendToUser = sendToId;
                        }
                    }
                    if (childActivity.ChildFLActivities.Count > 0) //当有子activity时才加入
                    {
                        ((FLActivity)detailsActivity).AddFLActivity(childActivity);
                    }

                    #endregion
                }
                else
                {
                    #region

                    Activity temp = FLInstance.GetActivityByXoml(this.FLDefinitionFile, string.Empty);
                    IFLRootActivity rootActivity = (IFLRootActivity)temp;

                    DataSet detailsDataSet = HostTable.GetDetailsDataSet(this, _hostDataSet, rootActivity.Keys, detailsActivity.DetailsTableName, detailsActivity.RelationKeys, _clientInfo);
                    string parallelField = detailsActivity.ParallelField;
                    string sendToField = detailsActivity.SendToField;

                    Dictionary<string, FLSequenceActivity> sequenceActivities = new Dictionary<string, FLSequenceActivity>(); // for y1,y2,y3
                    if (detailsDataSet != null && detailsDataSet.Tables.Count != 0 && detailsDataSet.Tables[0].Rows.Count != 0)
                    {
                        int i0 = 1;
                        int i1 = 1;
                        int i2 = 1;

                        foreach (DataRow row in detailsDataSet.Tables[0].Rows)
                        {
                            FLStandActivity stand = new FLStandActivity();

                            //stand.Name = n.Name + "_s" + i0.ToString();
                            stand.Name = detailsActivity.Name + "_" + i0.ToString();
                            i0++;

                            stand.Description = ((IFLDetailsActivity)detailsActivity).Description;
                            stand.Enabled = ((IFLDetailsActivity)detailsActivity).Enabled;

                            stand.ExpTime = ((IFLDetailsActivity)detailsActivity).ExpTime;
                            stand.FLNavigatorMode = ((IFLDetailsActivity)detailsActivity).FLNavigatorMode;
                            stand.FormName = ((IFLDetailsActivity)detailsActivity).FormName;
                            stand.WebFormName = ((IFLDetailsActivity)detailsActivity).WebFormName;
                            stand.NavigatorMode = ((IFLDetailsActivity)detailsActivity).NavigatorMode;
                            stand.Parameters = ((IFLDetailsActivity)detailsActivity).Parameters;
                            stand.SendToField = ((IFLDetailsActivity)detailsActivity).SendToField;
                            stand.SendToKind = ((IFLDetailsActivity)detailsActivity).SendToKind;
                            stand.SendToRole = ((IFLDetailsActivity)detailsActivity).SendToRole;
                            stand.SendToUser = ((IFLDetailsActivity)detailsActivity).SendToUser;
                            stand.TimeUnit = ((IFLDetailsActivity)detailsActivity).TimeUnit;
                            stand.UrgentTime = ((IFLDetailsActivity)detailsActivity).UrgentTime;
                            stand.SendEmail = ((IFLDetailsActivity)detailsActivity).SendEmail;
                            stand.PlusApprove = ((IFLDetailsActivity)detailsActivity).PlusApprove;
                            stand.PlusApproveReturn = ((IFLDetailsActivity)detailsActivity).PlusApproveReturn;
                            stand.AllowSendBack = ((IFLDetailsActivity)detailsActivity).AllowSendBack;

                            if (!string.IsNullOrEmpty(detailsActivity.FLNavigatorField))
                            {
                                object flNavigatorMode = row[detailsActivity.FLNavigatorField];
                                if (flNavigatorMode != null)
                                {
                                    if (string.Compare(flNavigatorMode.ToString(), "Continue", true) == 0)
                                    {
                                        stand.FLNavigatorMode = FLNavigatorMode.Continue;
                                    }
                                }
                            }

                            object sendToId2 = row[sendToField];
                            if (sendToId2 == null || sendToId2 == DBNull.Value || sendToId2.ToString() == string.Empty)
                            {
                                continue;
                                //String message = string.Format(SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(_clientInfo[0]))[0]), "FLRuntime", "FLInstance", "SendToFieldValueIsNull"), n.DetailsTableName);
                                //throw new FLException(message);
                            }
                            //((ISupportFLDetailsActivity)stand).SendToId2 = sendToId2.ToString();
                            if (((IFLDetailsActivity)detailsActivity).SendToKind == SendToKind.RefRole)
                            {
                                stand.SendToKind = SendToKind.Role;
                                stand.SendToRole = sendToId2.ToString();
                            }
                            else if (((IFLDetailsActivity)detailsActivity).SendToKind == SendToKind.RefUser)
                            {
                                stand.SendToKind = SendToKind.User;
                                stand.SendToUser = sendToId2.ToString();
                            }

                            if (!string.IsNullOrEmpty(parallelField))
                            {
                                object isParallel = row[parallelField];
                                if ((isParallel != null && isParallel != DBNull.Value) &&
                                    (isParallel.ToString().Trim().ToLower() == "y" || isParallel.ToString().Trim().ToLower() == "and"))
                                {
                                    if (childActivity == null)
                                    {
                                        childActivity = new FLParallelActivity();
                                        childActivity.Description = detailsActivity.ParallelRate > 0 ? string.Format("rate:{0}", detailsActivity.ParallelRate) : "and";
                                        childActivity.Name = detailsActivity.Name + "_p" + i2.ToString();
                                        i2++;

                                        ((FLActivity)detailsActivity).AddFLActivity(childActivity);
                                    }

                                    FLSequenceActivity sequenceActivity = new FLSequenceActivity();
                                    sequenceActivity.Name = detailsActivity.Name + "_se" + i1.ToString();
                                    i1++;
                                    ((FLActivity)childActivity).AddFLActivity(sequenceActivity);

                                    ((FLActivity)sequenceActivity).AddFLActivity(stand);
                                }
                                else if ((isParallel != null && isParallel != DBNull.Value) && (isParallel.ToString().Trim().ToLower().StartsWith("y")))
                                {
                                    if (childActivity == null)
                                    {
                                        childActivity = new FLParallelActivity();
                                        childActivity.Description = "and";
                                        childActivity.Name = detailsActivity.Name + "_p" + i2.ToString();
                                        i2++;

                                        ((FLActivity)detailsActivity).AddFLActivity(childActivity);
                                    }
                                    FLSequenceActivity sequenceActivity = null;
                                    if(sequenceActivities.ContainsKey(isParallel.ToString()))
                                    {
                                        sequenceActivity = sequenceActivities[isParallel.ToString()];
                                    }
                                    if (sequenceActivity == null)
                                    {
                                        sequenceActivity = new FLSequenceActivity();
                                        sequenceActivity.Name = detailsActivity.Name + "_se" + i1.ToString();
                                        i1++;
                                        ((FLActivity)childActivity).AddFLActivity(sequenceActivity);
                                        sequenceActivities[isParallel.ToString()] = sequenceActivity;
                                    }
                                    sequenceActivity.AddFLActivity(stand);
                                }
                                //修改n值时会串签
                                //else if ((isParallel != null && isParallel != DBNull.Value) &&
                                //    (isParallel.ToString().Trim().ToLower() == "n" || isParallel.ToString().Trim().ToLower() == "or"))
                                //{
                                //    if (childActivity == null)
                                //    {
                                //        childActivity = new FLParallelActivity();
                                //        childActivity.Description = "Or";
                                //        childActivity.Name = detailsActivity.Name + "_p" + i2.ToString();
                                //        i2++;

                            //        ((FLActivity)detailsActivity).AddFLActivity(childActivity);
                                //    }
                                //    FLSequenceActivity sequenceActivity = new FLSequenceActivity();
                                //    sequenceActivity.Name = detailsActivity.Name + "_se" + i1.ToString();
                                //    i1++;
                                //    ((FLActivity)childActivity).AddFLActivity(sequenceActivity);

                            //    ((FLActivity)sequenceActivity).AddFLActivity(stand);
                                //}
                                else
                                {
                                    childActivity = null;
                                    ((FLActivity)detailsActivity).AddFLActivity(stand);
                                }
                            }
                            else
                            {
                                childActivity = null;
                                ((FLActivity)detailsActivity).AddFLActivity(stand);
                            }
                        }
                    }

                    #endregion
                }

                XmlSerializer serializer = CreateXmlSerializer(typeof(FLDetailsActivity));

                StringBuilder builder = new StringBuilder();
                XmlWriter writer = XmlWriter.Create(builder);
                serializer.Serialize(writer, detailsActivity);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(builder.ToString());
                XmlNode nodeDetails = doc.SelectSingleNode(string.Format("FLDetailsActivity[@Name='{0}']", detailsActivity.Name));

                XmlNode nodeOldDetails = (XmlNode)_flDefinitionXmlNodes[detailsActivity.Name];
                nodeOldDetails.InnerXml = nodeDetails.InnerXml;

                InitFLDefinitionXmlNodes(nodeOldDetails);
                _flDefinitionXmlString = nodeOldDetails.OwnerDocument.InnerXml;

                ((FLActivity)detailsActivity).Execute();

                Hashtable childAll = ((FLActivity)detailsActivity).GetAllChildFLActivities();
                foreach (string key in childAll.Keys)
                {
                    _setUpperParallels.Remove(key);
                }
                foreach (string key in childAll.Keys)
                {
                    _setLocations.Remove(key);
                }
                SetUpperParallel((FLActivity)detailsActivity);
                SetLocation((FLActivity)detailsActivity);

                if (((FLActivity)detailsActivity).ChildFLActivities.Count == 0)
                {
                    GetNextFLActivities((FLActivity)detailsActivity, nextFLActivities);
                    //当detailsActivity没有任何人需要签核时, 撤消detailsActivity状态,不然退回后再也无法进入detailsActivity
                    ((FLActivity)detailsActivity).InitExecStatus();
                }
                else
                {
                    if (((FLActivity)detailsActivity).ChildFLActivities[0] is FLStandActivity)
                    {

                        SetUpperParallel(((FLActivity)detailsActivity).ChildFLActivities[0]);
                        SetLocation(((FLActivity)detailsActivity).ChildFLActivities[0]);

                        nextFLActivities.Add(((FLActivity)detailsActivity).ChildFLActivities[0]);
                    }
                    else
                    {
                        GetNextFLActivities(((FLActivity)detailsActivity).ChildFLActivities[0], nextFLActivities);
                    }
                }

                #endregion
            }
            else if (currentFLActivity is IFLSubFlowActivity && currentFLActivity.ExecutionStatus != FLActivityExecutionStatus.Executed)
            {

                IFLSubFlowActivity subflow = currentFLActivity as IFLSubFlowActivity;
                ((FLActivity)subflow).ChildFLActivities.Clear();
                string xomlName = subflow.XomlName;
                if (_hostDataSet == null)
                {
                    _hostDataSet = HostTable.GetHostDataSet(this, _keyValues, _clientInfo);
                }
                DataRow hostRow = _hostDataSet.Tables[0].Rows[0];
                if (!string.IsNullOrEmpty(subflow.XomlField) && hostRow.Table.Columns.Contains(subflow.XomlField))
                {
                    object obj = hostRow[subflow.XomlField];
                    if (obj != null && obj != DBNull.Value && !string.IsNullOrEmpty(obj.ToString()))
                    {
                        xomlName = obj.ToString();
                    }
                }

                if (!string.IsNullOrEmpty(xomlName))
                {
                    FLRootActivity subflowRoot = new FLRootActivity();
                    FileInfo fileInfo = new FileInfo(this.FLDefinitionFile);
                    string file = fileInfo.Directory + @"\" + xomlName;

                    if (!File.Exists(file))
                    {
                        file = fileInfo.Directory + @"\SubFlows\" + xomlName;
                    }
                    Activity subflowDefniation = GetActivityByXoml(file, string.Empty);

                    InitFLActivities(subflowRoot, subflowDefniation);

                    for (int i = 0; i < subflowRoot.ChildFLActivities.Count; i++)
                    {
                        if (i == 0 && !subflow.IncludeFirstActivity)
                        {
                            continue;
                        }

                        FLActivity child = subflowRoot.ChildFLActivities[i];

                        //((FLActivity)subflowRoot).ChildFLActivities.Remove(child);

                        if (this.RootFLActivity.GetFLActivityByName(child.Name) != null)
                        {
                            if (this.RootFLActivity.GetFLActivityByName(currentFLActivity.Name).GetFLActivityByName(child.Name) == null)
                            {
                                throw new FLException(string.Format("Activity:'{0}' exists in main flow and sub flow.", child.Name));
                            }
                        }

                        ((FLActivity)subflow).AddFLActivity(child);
                    }
                }

                XmlSerializer serializer = CreateXmlSerializer(typeof(FLSubFlowActivity));

                StringBuilder builder = new StringBuilder();
                XmlWriter writer = XmlWriter.Create(builder);
                serializer.Serialize(writer, subflow);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(builder.ToString());
                XmlNode nodeSubs = doc.SelectSingleNode(string.Format("FLSubFlowActivity[@Name='{0}']", subflow.Name));

                XmlNode nodeOldSubs = (XmlNode)_flDefinitionXmlNodes[subflow.Name];
                nodeOldSubs.InnerXml = nodeSubs.InnerXml;

                InitFLDefinitionXmlNodes(nodeOldSubs);
                _flDefinitionXmlString = nodeOldSubs.OwnerDocument.InnerXml;
                ((FLActivity)subflow).Execute();

                Hashtable childAll = ((FLActivity)subflow).GetAllChildFLActivities();
                foreach (string key in childAll.Keys)
                {
                    _setUpperParallels.Remove(key);
                    _setLocations.Remove(key);
                }

                SetUpperParallel((FLActivity)subflow);
                SetLocation((FLActivity)subflow);

                if (((FLActivity)subflow).ChildFLActivities.Count == 0)
                {
                    GetNextFLActivities((FLActivity)subflow, nextFLActivities);
                    //当subflow没有任何人需要签核时, 撤消subflow状态,不然退回后再也无法进入subflow
                    ((FLActivity)subflow).InitExecStatus();
                }
                else
                {
                    if (((FLActivity)subflow).ChildFLActivities[0] is FLStandActivity)
                    {
                        SetUpperParallel(((FLActivity)subflow).ChildFLActivities[0]);
                        SetLocation(((FLActivity)subflow).ChildFLActivities[0]);
                        nextFLActivities.Add(((FLActivity)subflow).ChildFLActivities[0]);
                    }
                    else
                    {
                        GetNextFLActivities(((FLActivity)subflow).ChildFLActivities[0], nextFLActivities);
                    }
                }
            }
            else
            {
                #region

                if ((currentFLActivity is IEventWaiting) || (currentFLActivity is IFLValidateActivity) || ((currentFLActivity is IControlFL) && (currentFLActivity.ExecutionStatus == FLActivityExecutionStatus.Executed)))
                {
                    if (currentFLActivity is IFLParallelActivity && (string.IsNullOrEmpty(((IFLParallelActivity)currentFLActivity).Description) || string.IsNullOrEmpty(((IFLParallelActivity)currentFLActivity).Description.Trim()) || ((IFLParallelActivity)currentFLActivity).Description.ToLower() == "and"))
                    {
                        bool b = true;
                        foreach (FLActivity a in currentFLActivity.ChildFLActivities)
                        {
                            if (!((IFLParallelActivity)currentFLActivity).ExecutedBranches.Exists(
                                delegate(string s)
                                {
                                    if (a.Name == s)
                                        return true;
                                    else
                                        return false;
                                }
                                ))
                            {
                                b = false;
                                break;
                            }
                        }

                        if (!b)
                        {
                            return;
                        }
                    }
                    else if (currentFLActivity is IFLParallelActivity && (!string.IsNullOrEmpty(((IFLParallelActivity)currentFLActivity).Description) && !string.IsNullOrEmpty(((IFLParallelActivity)currentFLActivity).Description.Trim()) && ((IFLParallelActivity)currentFLActivity).Description.ToLower().Contains("rate")))
                    {
                        decimal rate = 0;
                        decimal x = currentFLActivity.ChildFLActivities.Count;
                        if (x != 0)
                        {
                            decimal y = ((IFLParallelActivity)currentFLActivity).ExecutedBranches.Count;
                            decimal j = y / x;

                            string q = ((IFLParallelActivity)currentFLActivity).Description.Trim();
                            string[] qq = q.Split(":".ToCharArray());
                            string p = qq[1].Trim();
                            rate = decimal.Parse(p);

                            rate = rate / 100;
                            if (j < rate)
                            {
                                return;
                            }
                        }
                    }

                    activity = GetRealNextFLActivity(currentFLActivity);
                    if (activity == null)
                    {
                        activity = GetRealParentFLActivity(currentFLActivity);
                        if (activity == null || activity is IFLRootActivity)
                        {
                            _flflag = 'Z';
                            return;
                        }

                        FLActivity parentActivity = GetRealParentFLActivity(activity);
                        if (parentActivity is IFLParallelActivity && ((string.IsNullOrEmpty(((IFLParallelActivity)parentActivity).Description) || string.IsNullOrEmpty(((IFLParallelActivity)parentActivity).Description.Trim()) || ((IFLParallelActivity)parentActivity).Description.Trim().ToLower() == "and")
                            || (!string.IsNullOrEmpty(((IFLParallelActivity)parentActivity).Description) && !string.IsNullOrEmpty(((IFLParallelActivity)parentActivity).Description.Trim()) && ((IFLParallelActivity)parentActivity).Description.Trim().ToLower().Contains("rate"))))
                        {
                            if (!((IFLParallelActivity)parentActivity).ExecutedBranches.Exists(
                                 delegate(string s)
                                 {
                                     if (currentFLActivity.Name == s)
                                         return true;
                                     else
                                         return false;
                                 }
                                 ))
                            {
                                ((IFLParallelActivity)parentActivity).ExecutedBranches.Add(activity.Name);
                                foreach (FLActivity a in parentActivity.ChildFLActivities)
                                {
                                    FLDirection direction = ((IFLSequenceActivity)a).FLDirection;
                                    if (a.Name != activity.Name && direction != FLDirection.Waiting)
                                    {
                                        //if (direction != _flDirection)
                                        //{
                                        //    String message = string.Format(SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(_clientInfo[0]))[0]), "FLRuntime", "FLInstance", "DirectionError"), _flDirection.ToString(), a.Name, direction.ToString());
                                        //    throw new FLException(2, message);
                                        //}
                                    }
                                }
                                ((IFLSequenceActivity)activity).SetFLDirection(_flDirection);
                            }
                        }
                    }

                    if (activity is IEventWaiting && !(activity is IFLApproveActivity || activity is IFLApproveBranchActivity) && activity.Enabled)
                    {
                        SetUpperParallel(activity);
                        SetLocation(activity);
                        nextFLActivities.Add(activity);
                    }
                    else
                    {
                        GetNextFLActivities(activity, nextFLActivities);
                    }
                }
                else
                {
                    if (currentFLActivity is IControlFL && !(currentFLActivity is IFLRootActivity))
                    {
                        currentFLActivity.Execute();
                    }

                    FLActivity parentFLActivity = GetRealParentFLActivity(currentFLActivity);
                    if (parentFLActivity != null && parentFLActivity is IFLIfElseActivity)
                    {
                        foreach (FLActivity flActivity in parentFLActivity.ChildFLActivities)
                        {
                            flActivity.Execute();
                        }
                    }

                    if (currentFLActivity is IFLIfElseActivity)
                    {
                        List<FLActivity> branchActivities = currentFLActivity.ChildFLActivities;
                        List<FLActivity> runBranchActivities = new List<FLActivity>();
                        FLActivity elseBranchActivity = null;

                        foreach (FLActivity branchActivity in branchActivities)
                        {
                            IFLIfElseBranchActivity a = (IFLIfElseBranchActivity)branchActivity;
                            string condition = a.Condition;
                            if (condition != string.Empty)
                            {
                                if (JudgeCondition(condition))
                                {
                                    runBranchActivities.Add(branchActivity);
                                    break;
                                }
                            }
                            else
                            {
                                elseBranchActivity = branchActivity;
                            }
                        }

                        foreach (FLActivity branchActivity in runBranchActivities)
                        {
                            GetNextFLActivities(branchActivity, nextFLActivities);
                        }

                        if (runBranchActivities.Count == 0)
                        {
                            GetNextFLActivities(elseBranchActivity, nextFLActivities);
                        }
                    }
                    else if (currentFLActivity is IFLParallelActivity)
                    {
                        _isFirstInParallel = true;
                        _tempParallel = currentFLActivity.Name;
                        foreach (FLActivity a in currentFLActivity.ChildFLActivities)
                        {
                            _tempParallelBranch = a.Name;
                            List<FLActivity> tempNextFLActivities = new List<FLActivity>();

                            ((IFLSequenceActivity)a).SetFLDirection(FLDirection.Waiting);
                            GetNextFLActivities(a, tempNextFLActivities);

                            int j = 0;
                            foreach (FLActivity tempFLActivity in tempNextFLActivities)
                            {
                                if (tempFLActivity is IEventWaiting)
                                {
                                    j++;
                                }
                            }

                            if (j == 0)
                            {
                                ((IFLParallelActivity)currentFLActivity).ExecutedBranches.Add(a.Name);
                            }

                            nextFLActivities.AddRange(tempNextFLActivities);
                        }
                        _isFirstInParallel = false;
                        _tempParallel = string.Empty;
                        _tempParallelBranch = string.Empty;

                        if (nextFLActivities.Count == 0)
                        {
                            GetNextFLActivities(currentFLActivity, nextFLActivities);
                        }
                    }
                    else
                    {
                        List<FLActivity> activities = currentFLActivity.ChildFLActivities;
                        if (activities.Count == 0)
                        {
                            activity = GetRealNextFLActivity(currentFLActivity);
                            if (activity == null)
                            {
                                activity = GetRealParentFLActivity(currentFLActivity);
                                if (activity == null || activity is IFLRootActivity)
                                {
                                    _flflag = 'Z';
                                    return;
                                }
                            }

                            if (activity is IEventWaiting && !(activity is IFLApproveActivity || activity is IFLApproveBranchActivity) && activity.Enabled)
                            {
                                SetUpperParallel(activity);
                                SetLocation(activity);
                                nextFLActivities.Add(activity);
                            }
                            else
                            {
                                GetNextFLActivities(activity, nextFLActivities);
                            }
                        }
                        else
                        {
                            activity = activities[0];
                            if (activity is IEventWaiting && !(activity is IFLApproveActivity || activity is IFLApproveBranchActivity) && activity.Enabled)
                            {
                                SetUpperParallel(activity);
                                SetLocation(activity);
                                nextFLActivities.Add(activity);
                            }
                            else
                            {
                                GetNextFLActivities(activity, nextFLActivities);
                            }
                        }
                    }
                }

                #endregion
            }
        }