GetObject() private method

private GetObject ( bool isMine ) : GameObject
isMine bool
return GameObject
コード例 #1
0
        public override void Enter(IWorkflowContext context)
        {
            //增加一条工作项,系统自动完成,LevelCode取CurrentTask的
            string levelCode = context.CurrentTask.LevelCode;
            var    workitem  = ObjectHelper.GetObject <IWorkflowItem>();

            string instanceId = context.FlowInstance.Id;
            var    instance   = context.FlowInstance.WorkItems.OrderByDescending(o => o.ItemId).First();

            workitem.AutoFinish      = true;
            workitem.Status          = WorkItemStatus.AutoFinished;
            workitem.ItemId          = instance.ItemId + 1;
            workitem.ItemSeq         = instance.ItemSeq + 1;
            workitem.AppCode         = context.CurrentTask.AppCode;
            workitem.PartUserName    = "******";
            workitem.InstanceId      = context.FlowInstance.Id;
            workitem.ReceiveTime     = DateTime.Now;
            workitem.FinishTime      = DateTime.Now;
            workitem.LevelCode       = levelCode;
            workitem.Alias           = Alias;
            workitem.CurrentActivity = Name;
            workitem.PreItemId       = context.CurrentTask.ItemId;
            workitem.PasserUserId    = context.CurrentUser.Id;
            workitem.PasserUserName  = context.CurrentUser.Name;
            context.FlowInstance.InsertWorkItem(workitem);
            context.LevelCode = string.Format("{0}-{1}:", levelCode, workitem.ItemId);
            Log(string.Format("{0}:改写了levelCode为:{1}", context.FlowInstance.Id, context.LevelCode));
        }
コード例 #2
0
        public override void Enter(IWorkflowContext context)
        {
            //增加一条工作项,系统自动完成
            //如果当前工作项levelCode为00-4:01 则结果为00
            //如果当前工作项levelCode为00-4:01-10:01 则结果为00-4:01
            string levelCode      = context.CurrentTask.LevelCode.Substring(0, context.CurrentTask.LevelCode.LastIndexOf('-'));
            var    workitem       = ObjectHelper.GetObject <IWorkflowItem>();
            var    instanceHelper = ObjectHelper.GetObject <IWorkflowInstanceService>();

            string instanceId = context.FlowInstance.Id;
            var    newestItem = context.FlowInstance.WorkItems.OrderByDescending(o => o.ItemId).First();

            workitem.AutoFinish      = true;
            workitem.Status          = WorkItemStatus.AutoFinished;
            workitem.AppCode         = context.CurrentTask.AppCode;
            workitem.ItemId          = newestItem.ItemId + 1;
            workitem.ItemSeq         = newestItem.ItemSeq + 1;
            workitem.PartUserName    = "******";
            workitem.InstanceId      = context.FlowInstance.Id;
            workitem.ReceiveTime     = DateTime.Now;
            workitem.FinishTime      = DateTime.Now;
            workitem.LevelCode       = levelCode;
            workitem.Alias           = Alias;
            workitem.CurrentActivity = Name;
            workitem.PreItemId       = context.CurrentTask.ItemId;
            workitem.PasserUserId    = context.CurrentUser.Id;
            workitem.PasserUserName  = context.CurrentUser.Name;
            context.FlowInstance.InsertWorkItem(workitem);
            context.LevelCode = levelCode;
        }
コード例 #3
0
        public JsonResult GetPage()
        {
            var result = DBContext <PageEntity> .Instance.Where(o => true);

            var  permissions = new List <TreeNode>();
            var  param       = new Dictionary <string, object>();
            bool isOpen      = false;

            foreach (var r in result)
            {
                param[NamingCenter.PARAM_PAGE_ID]   = r.Id;
                param[NamingCenter.PARAM_TYPE_NAME] = r.Type;
                isOpen = r.Type.Equals(PermissionType.Module.ToString());
                permissions.Add(new TreeNode()
                {
                    Value    = r.Id,
                    ParentId = r.ParentId.IsNullOrEmpty() ? "Root" : r.ParentId,
                    Text     = r.Title,
                    Open     = isOpen,
                    Url      = HttpHelper.BuildUrl(pageDesignerUrl, param),
                    Icon     = isOpen ? folderIconUrl : appIconUrl
                });
            }
            permissions.Add(new TreeNode()
            {
                Value    = "Root",
                ParentId = "null",
                Text     = ObjectHelper.GetObject <ILangProvider>().GetString("AllPage"),
                Open     = true,
                Icon     = rootIconUrl,
                Url      = pageDesignerUrl
            });
            return(Json(permissions, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
ファイル: EndActivity.cs プロジェクト: yunqian44/FoxOne
        public override void Enter(IWorkflowContext context)
        {
            //增加一条工作项,系统自动完成,LevelCode取CurrentTask的
            string levelCode = context.CurrentTask.LevelCode;
            var    workitem  = ObjectHelper.GetObject <IWorkflowItem>();

            string instanceId = context.FlowInstance.Id;
            var    newestItem = context.FlowInstance.WorkItems.OrderByDescending(o => o.ItemId).First();

            workitem.AutoFinish      = true;
            workitem.Status          = WorkItemStatus.AutoFinished;
            workitem.AppCode         = context.CurrentTask.AppCode;
            workitem.ItemId          = newestItem.ItemId + 1;
            workitem.ItemSeq         = newestItem.ItemSeq + 1;
            workitem.PartUserName    = "******";
            workitem.InstanceId      = context.FlowInstance.Id;
            workitem.ReceiveTime     = DateTime.Now;
            workitem.FinishTime      = DateTime.Now;
            workitem.LevelCode       = levelCode;
            workitem.Alias           = Alias;
            workitem.CurrentActivity = Name;
            workitem.PreItemId       = context.CurrentTask.ItemId;
            workitem.PasserUserId    = context.CurrentUser.Id;
            workitem.PasserUserName  = context.CurrentUser.Name;
            context.FlowInstance.InsertWorkItem(workitem);
            context.FlowInstance.FlowTag         = FlowStatus.Finished;
            context.FlowInstance.EndTime         = DateTime.Now;
            context.FlowInstance.WorkItemNewSeq  = workitem.ItemSeq;
            context.FlowInstance.WorkItemNewTask = workitem.ItemId;
            Owner.UpdateInstance(context.FlowInstance);
            context.FlowInstance.DeleteParameter();
            SendOtherToRead(context);
        }
コード例 #5
0
ファイル: BreakdownActivity.cs プロジェクト: yunqian44/FoxOne
        public override void Exit(IWorkflowContext context)
        {
            var preItem      = context.FlowInstance.WorkItems.FirstOrDefault(o => o.ItemId == context.CurrentTask.PreItemId);
            var lastItem     = context.FlowInstance.WorkItems.OrderByDescending(o => o.ItemId).First();
            var workflowItem = ObjectHelper.GetObject <IWorkflowItem>();

            workflowItem.PartUserId           = preItem.PartUserId;
            workflowItem.PartUserName         = preItem.PartUserName;
            workflowItem.InstanceId           = preItem.InstanceId;
            workflowItem.ItemId               = lastItem.ItemId + 1;
            workflowItem.ItemSeq              = lastItem.ItemSeq + 1;
            workflowItem.PartDepepartmentName = preItem.PartDepepartmentName;
            workflowItem.PartDepartmentId     = preItem.PartDepartmentId;
            workflowItem.ParallelInfo         = preItem.ParallelInfo;
            workflowItem.Status               = WorkItemStatus.Sent;
            workflowItem.ReceiveTime          = DateTime.Now;
            workflowItem.ExpiredTime          = GetExpiredTime();
            workflowItem.PreItemId            = context.CurrentTask.ItemId;
            workflowItem.AppCode              = preItem.AppCode;
            workflowItem.CurrentActivity      = preItem.CurrentActivity;
            workflowItem.Alias          = preItem.Alias;
            workflowItem.LevelCode      = preItem.LevelCode;
            workflowItem.PasserUserId   = context.CurrentUser.Id;
            workflowItem.PasserUserName = context.CurrentUser.Name;
            context.FlowInstance.InsertWorkItem(workflowItem);
        }
コード例 #6
0
ファイル: WorkflowHelper.cs プロジェクト: yunqian44/FoxOne
        /// <summary>
        /// 传阅
        /// </summary>
        /// <param name="userIds">用户ID,多个用逗号隔开</param>
        public void SendToOtherToRead(string userIds)
        {
            Validate();
            var userIdSplit = userIds.Split(new char[] { ',', '|', ';' }, StringSplitOptions.RemoveEmptyEntries);
            var users       = DBContext <IUser> .Instance.Where(o => userIdSplit.Contains(o.Id, StringComparer.OrdinalIgnoreCase)).ToList();

            int taskId = FlowInstance.GetMaxReadTaskID();

            using (var tran = new TransactionScope())
            {
                foreach (var user in users)
                {
                    var newItem = ObjectHelper.GetObject <IWorkflowItem>("Read");
                    newItem.InstanceId           = CurrentItem.InstanceId;
                    newItem.ReceiveTime          = DateTime.Now;
                    newItem.PartUserId           = user.Id;
                    newItem.PartUserName         = user.Name;
                    newItem.PartDepartmentId     = user.Department.Id;
                    newItem.PartDepepartmentName = user.Department.Name;
                    newItem.Status          = WorkItemStatus.Sent;
                    newItem.ItemId          = ++taskId;
                    newItem.Alias           = "传阅";
                    newItem.CurrentActivity = "传阅";
                    newItem.AppCode         = CurrentItem.AppCode;
                    newItem.PreItemId       = CurrentItem.ItemId;
                    newItem.PasserUserId    = CurrentUser.Id;
                    newItem.PasserUserName  = CurrentUser.Name;
                    FlowInstance.InsertWorkItem(newItem);
                }
                tran.Complete();
            }
        }
コード例 #7
0
ファイル: EndActivity.cs プロジェクト: yunqian44/FoxOne
 public void SendOtherToRead(IWorkflowContext context)
 {
     if (Actor != null)
     {
         var users = Actor.Resolve(context);
         if (users.Count > 0)
         {
             var currentTask = context.CurrentTask;
             int taskId      = context.FlowInstance.GetMaxReadTaskID();
             foreach (var user in users)
             {
                 var newItem = ObjectHelper.GetObject <IWorkflowItem>("Read");
                 newItem.InstanceId           = currentTask.InstanceId;
                 newItem.ReceiveTime          = DateTime.Now;
                 newItem.PartUserId           = user.Id;
                 newItem.PartUserName         = user.Name;
                 newItem.PartDepartmentId     = user.Department.Id;
                 newItem.PartDepepartmentName = user.Department.Name;
                 newItem.Status          = WorkItemStatus.Sent;
                 newItem.ItemId          = ++taskId;
                 newItem.Alias           = "传阅";
                 newItem.CurrentActivity = "传阅";
                 newItem.AppCode         = currentTask.AppCode;
                 newItem.PreItemId       = currentTask.ItemId;
                 newItem.PasserUserId    = context.CurrentUser.Id;
                 newItem.PasserUserName  = context.CurrentUser.Name;
                 context.FlowInstance.InsertWorkItem(newItem);
             }
         }
     }
 }
コード例 #8
0
ファイル: WorkflowHelper.cs プロジェクト: yunqian44/FoxOne
        public IWorkflow Build(string appCode)
        {
            var app = DBContext <IWorkflowApplication> .Instance.Get(appCode);

            string workflowId  = app == null ? "1" : app.WorkflowId;//测试时,未定义应用。
            var    returnValue = ObjectHelper.GetObject <IWorkflowBuilder>().Build(workflowId);

            ValidateWorkflow(returnValue);
            return(returnValue);
        }
コード例 #9
0
ファイル: WorkflowHelper.cs プロジェクト: yunqian44/FoxOne
        private IWorkflowContext GetWorkflowContext()
        {
            var context = ObjectHelper.GetObject <IWorkflowContext>();

            context.LevelCode    = CurrentItem.LevelCode;
            context.CurrentUser  = CurrentUser;
            context.FlowInstance = FlowInstance;
            context.CurrentTask  = CurrentItem;
            context.Parameter    = FlowInstance.Parameters;
            return(context);
        }
コード例 #10
0
ファイル: HomeController.cs プロジェクト: yunqian44/FoxOne
 public ActionResult LogOn(string userName, string password)
 {
     if (Sec.Provider.Authenticate(userName, password))
     {
         FormsAuthentication.SetAuthCookie(userName, false);
         return(RedirectToAction("Index", "Home"));
     }
     else
     {
         ViewData["ErrorMessage"] = ObjectHelper.GetObject <ILangProvider>().GetString("InValid_User_Or_Password");
         return(View());
     }
 }
コード例 #11
0
        public JsonResult RoleTypePermission()
        {
            string roleId       = Request["RoleId"];
            string permissionId = Request["Id"];
            string action       = Request["action"];

            switch (action)
            {
            case "Get":
                var roleType = DBContext <IRoleType> .Instance.FirstOrDefault(o => o.Id.Equals(roleId, StringComparison.OrdinalIgnoreCase));

                if (roleType != null)
                {
                    return(Json(roleType.Permissions));
                }
                else
                {
                    var role = DBContext <IRole> .Instance.FirstOrDefault(o => o.Id.Equals(roleId, StringComparison.OrdinalIgnoreCase));

                    if (role != null)
                    {
                        return(Json(role.RoleType.Permissions));
                    }
                }
                break;

            case "Add":
                var item = ObjectHelper.GetObject <IRoleTypePermission>();
                item.Id           = Guid.NewGuid().ToString();
                item.PermissionId = permissionId;
                item.RoleTypeId   = roleId;
                var result = DBContext <IRoleTypePermission> .Insert(item);

                return(Json(result));

            case "Remove":
                var items = DBContext <IRoleTypePermission> .Instance.Where(o => o.RoleTypeId.Equals(roleId, StringComparison.OrdinalIgnoreCase) && permissionId.Split(',').Contains(o.PermissionId, StringComparer.OrdinalIgnoreCase));

                int count = 0;
                foreach (var i in items)
                {
                    if (DBContext <IRoleTypePermission> .Delete(i))
                    {
                        count++;
                    }
                }
                return(Json(count == items.Count()));
            }
            return(Json(false));
        }
コード例 #12
0
ファイル: WorkflowHelper.cs プロジェクト: yunqian44/FoxOne
        public IList <IWorkflowChoice> GetUserChoice(string stepName, NextStepUser user)
        {
            var returnValue = new List <IWorkflowChoice>();
            var choice      = ObjectHelper.GetObject <IWorkflowChoice>();

            choice.Choice      = stepName;
            choice.Participant = new List <IUser>();
            var tempUser = DBContext <IUser> .Instance.Get(user.ID);

            tempUser.DepartmentId = user.OrgId;
            choice.Participant.Add(tempUser);
            returnValue.Add(choice);
            return(returnValue);
        }
コード例 #13
0
ファイル: WorkflowHelper.cs プロジェクト: yunqian44/FoxOne
        private IWorkflowInstance GetNewInstance(string appCode, string procName, string dataLocator, int impoLevel, int secret)
        {
            var instance = ObjectHelper.GetObject <IWorkflowInstance>();

            instance.ApplicationId   = appCode;
            instance.CreatorId       = CurrentUser.Id;
            instance.WorkItemNewSeq  = 1;
            instance.WorkItemNewTask = 1;
            instance.StartTime       = DateTime.Now;
            instance.FlowTag         = FlowStatus.Begin;
            instance.SecretLevel     = secret;
            instance.InstanceName    = string.IsNullOrEmpty(procName) ? instance.Application.Name : procName;
            instance.ImportantLevel  = impoLevel;
            instance.DataLocator     = dataLocator;
            return(instance);
        }
コード例 #14
0
 public void SetProperty()
 {
     foreach (var key in Properties.Keys)
     {
         var item = ObjectHelper.GetObject <IDURPProperty>();
         item.Id     = this.GetType().FullName + key;
         item.Name   = key;
         item.Value  = Properties[key].ToString();
         item.RentId = this.RentId;
         item.Type   = this.Id;
         if (!DBContext <IDURPProperty> .Update(item))
         {
             DBContext <IDURPProperty> .Insert(item);
         }
     }
 }
コード例 #15
0
ファイル: WorkflowHelper.cs プロジェクト: yunqian44/FoxOne
        /// <summary>
        /// 将特定字符串转换成用于运行流程的参数
        /// </summary>
        /// <param name="userChoice">格式:userId1_orgId1_stepName1,userId2_orgId2_stepName2...</param>
        /// <returns></returns>
        public IList <IWorkflowChoice> GetUserChoice(string userChoice)
        {
            IList <IWorkflowChoice> choices = new List <IWorkflowChoice>();

            string[] tempChoice = userChoice.Split(',');
            foreach (var c in tempChoice)
            {
                var tempUser = c.Split('_');
                var choice   = choices.FirstOrDefault(o => o.Choice == tempUser[2]);
                if (tempUser[0].Equals("NULL", StringComparison.CurrentCultureIgnoreCase))
                {
                    var workflowChoice = ObjectHelper.GetObject <IWorkflowChoice>();
                    workflowChoice.Choice      = tempUser[2];
                    workflowChoice.Participant = new List <IUser>();

                    choices.Add(workflowChoice);
                }
                else
                {
                    var user = DBContext <IUser> .Instance.Get(tempUser[0]);

                    user.DepartmentId = tempUser[1];
                    int rank = 0;
                    if (int.TryParse(tempUser[3], out rank))
                    {
                        user.Rank = rank;
                    }
                    if (choice == null)
                    {
                        var workflowChoice = ObjectHelper.GetObject <IWorkflowChoice>();
                        workflowChoice.Choice      = tempUser[2];
                        workflowChoice.Participant = new List <IUser>()
                        {
                            user
                        };
                        choices.Add(workflowChoice);
                    }
                    else
                    {
                        choice.Participant.Add(user);
                    }
                }
            }
            return(choices);
        }
コード例 #16
0
        public virtual DateTime GetExpiredTime()
        {
            if (this.Interval <= 0)
            {
                this.Interval = 3;
            }
            var      workDayService = ObjectHelper.GetObject <IWorkDayService>();
            DateTime returnValue    = DateTime.Now;

            if (ExpireRule == ExpireRule.ByNaturalDay)
            {
                returnValue = DateTime.Now.AddDays(Interval);
            }
            else
            {
                returnValue = workDayService.GetTimeAfterSpan(DateTime.Now, new TimeSpan(Interval, 0, 0, 0));
            }
            return(returnValue);
        }
コード例 #17
0
ファイル: DURPBase.cs プロジェクト: loloopop/FoxOne
 public void SetProperty()
 {
     foreach (var key in Properties.Keys)
     {
         if (Properties[key] == null || Properties[key].ToString().IsNullOrEmpty())
         {
             continue;
         }
         var item = ObjectHelper.GetObject <IDURPProperty>();
         item.Id     = Guid.NewGuid().ToString();
         item.Name   = key;
         item.Value  = Properties[key].ToString();
         item.RentId = this.RentId;
         item.Type   = this.Id;
         if (!DBContext <IDURPProperty> .Update(item))
         {
             DBContext <IDURPProperty> .Insert(item);
         }
     }
 }
コード例 #18
0
ファイル: HomeController.cs プロジェクト: xym000/FoxOne
 public ActionResult LogOn(string userName, string password)
 {
     if (Sec.Provider.Authenticate(userName, password))
     {
         FormsAuthentication.SetAuthCookie(userName, false);
         string returnUrl = Request.QueryString["ReturnUrl"];
         if (!returnUrl.IsNullOrEmpty())
         {
             return(Redirect(returnUrl));
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     else
     {
         ViewData["ErrorMessage"] = ObjectHelper.GetObject <ILangProvider>().GetString("InValid_User_Or_Password");
         return(View());
     }
 }
コード例 #19
0
ファイル: WorkflowHelper.cs プロジェクト: yunqian44/FoxOne
        private IWorkflowItem GetNewWorkItem(IActivity activity, IUser user, string appCode, string instanceId)
        {
            var newItem = ObjectHelper.GetObject <IWorkflowItem>();

            newItem.AppCode         = appCode;
            newItem.Alias           = activity.Alias;
            newItem.CurrentActivity = activity.Name;
            newItem.ItemSeq         = 1;
            newItem.ItemId          = 1;
            newItem.Status          = WorkItemStatus.Sent;
            newItem.InstanceId      = instanceId;
            newItem.ReceiveTime     = DateTime.Now;
            if (activity is ResponseActivity)
            {
                newItem.ExpiredTime = (activity as ResponseActivity).GetExpiredTime();
            }
            newItem.PartUserId           = user.Id;
            newItem.PartUserName         = user.Name;
            newItem.LevelCode            = "00";
            newItem.PartDepartmentId     = user.Department.Id;
            newItem.PartDepepartmentName = user.Department.Name;
            return(newItem);
        }
コード例 #20
0
ファイル: WorkflowHelper.cs プロジェクト: yunqian44/FoxOne
 public static void ClearCache(string definitionId)
 {
     ObjectHelper.GetObject <IWorkflowBuilder>().ClearCache(definitionId);
 }
コード例 #21
0
 public override void Enter(IWorkflowContext context)
 {
     if (context.LevelCode == "00")
     {
         throw new Exception("分发部门步骤只能用于并行流程开始步骤后");
     }
     if (context.LevelCode.Equals(context.CurrentTask.LevelCode, StringComparison.CurrentCultureIgnoreCase) ||
         context.CurrentTask.LevelCode.StartsWith(context.LevelCode, StringComparison.CurrentCultureIgnoreCase))
     {
         //当前上下文中的LevelCode与当前工作项的LevelCode一致,说明是从会签内的某一步退回到分发部门步骤
         //这时只需当成普通的审核步骤来处理工作项即可
         base.Enter(context);
     }
     else
     {
         var      users = Actor.Resolve(context);
         var      usersGroupBy = users.GroupBy(o => o.DepartmentId);
         int      taskSeqCount = usersGroupBy.Count();
         string   instanceId = context.FlowInstance.Id;
         var      newestItem = context.FlowInstance.WorkItems.OrderByDescending(o => o.ItemId).First();
         DateTime dt = DateTime.Now;
         int      i = 1, j = 1;
         bool     isFirst    = true;
         var      levelCodes = context.FlowInstance.GetLevelCode(context.LevelCode, taskSeqCount);
         foreach (var user in usersGroupBy)
         {
             isFirst = true;
             foreach (var u in user)
             {
                 var workflowItem = ObjectHelper.GetObject <IWorkflowItem>();
                 workflowItem.PartUserId           = u.Id;
                 workflowItem.PartUserName         = u.Name;
                 workflowItem.InstanceId           = instanceId;
                 workflowItem.ItemId               = newestItem.ItemId + j;
                 workflowItem.ItemSeq              = newestItem.ItemSeq + i;
                 workflowItem.PartDepepartmentName = u.Department.Name;
                 workflowItem.PartDepartmentId     = u.Department.Id;
                 workflowItem.ParallelInfo         = u.Department.Id;
                 if (ResponseRuleType == ResponseRuleType.SerialResponse && !isFirst)
                 {
                     workflowItem.Status = WorkItemStatus.Pause;
                 }
                 else
                 {
                     workflowItem.Status = WorkItemStatus.Sent; //如果是 串行审批  工作项的状态在这里是不一样的。
                     isFirst             = false;
                 }
                 workflowItem.ReceiveTime     = dt;
                 workflowItem.ExpiredTime     = GetExpiredTime();
                 workflowItem.PreItemId       = context.CurrentTask.ItemId;
                 workflowItem.AppCode         = context.FlowInstance.ApplicationId;
                 workflowItem.CurrentActivity = this.Name;
                 workflowItem.Alias           = Alias;
                 workflowItem.PasserUserId    = context.CurrentUser.Id;
                 workflowItem.PasserUserName  = context.CurrentUser.Name;
                 workflowItem.LevelCode       = levelCodes[i - 1];
                 context.FlowInstance.InsertWorkItem(workflowItem);
                 j++;
             }
             i++;
         }
     }
 }
コード例 #22
0
        public override void Enter(IWorkflowContext context)
        {
            var      users      = Actor.Resolve(context).OrderBy(o => o.Rank);
            string   instanceId = context.FlowInstance.Id;
            var      lastItem   = context.FlowInstance.WorkItems.OrderByDescending(o => o.ItemId).First();
            DateTime dt         = DateTime.Now;
            int      i          = 1;
            string   levelCode  = context.CurrentTask.LevelCode;
            string   keyInfo    = context.CurrentTask.ParallelInfo;

            if (!context.LevelCode.Equals(context.CurrentTask.LevelCode, StringComparison.CurrentCultureIgnoreCase))
            {
                //从普通审批步骤,进入到会签入的审批步骤,或者从会签入的审批步骤,退出到普通的审批步骤,都会进入这里。
                //主要体现是上下文中的levelCode不等于当前工作项的levelCode,因为经过“并行开始”或“并行结束”步骤,都会把上下文的levelCode改掉。
                levelCode = context.LevelCode;

                if (levelCode.EndsWith(":"))
                {
                    //并行开始步骤 直接 连接 审批步骤 时,会进入这里。levelCode不能单纯取上下文中的levelCode,要去自动生成
                    //上下文的可能是00-4:,自动生成后,就会变成00-4:01,00-4:02....
                    levelCode = context.FlowInstance.GetLevelCode(context.LevelCode, 1)[0];
                }
                else
                {
                    if (levelCode != "00")
                    {
                        //从嵌套会签中退出外层会签时,需要为当前工作项找回外层会签的并行keyInfo
                        var firstWorkItem = context.FlowInstance.WorkItems.OrderBy(o => o.ItemId).FirstOrDefault(o => o.LevelCode == levelCode);
                        if (firstWorkItem != null)
                        {
                            keyInfo = firstWorkItem.ParallelInfo;
                        }
                    }
                }
            }
            foreach (var user in users)
            {
                var workflowItem = ObjectHelper.GetObject <IWorkflowItem>();
                workflowItem.PartUserId           = user.Id;
                workflowItem.PartUserName         = user.Name;
                workflowItem.InstanceId           = instanceId;
                workflowItem.ItemId               = lastItem.ItemId + i;
                workflowItem.ItemSeq              = lastItem.ItemSeq + 1;
                workflowItem.PartDepepartmentName = user.Department.Name;
                workflowItem.PartDepartmentId     = user.Department.Id;
                workflowItem.ParallelInfo         = keyInfo;
                if (ResponseRuleType == ResponseRuleType.SerialResponse && i != 1)
                {
                    workflowItem.Status = WorkItemStatus.Pause;
                }
                else
                {
                    workflowItem.Status = WorkItemStatus.Sent; //如果是 串行审批  工作项的状态在这里是不一样的。
                }
                workflowItem.ReceiveTime     = dt;
                workflowItem.ExpiredTime     = GetExpiredTime();
                workflowItem.PreItemId       = context.CurrentTask.ItemId;
                workflowItem.AppCode         = context.FlowInstance.ApplicationId;
                workflowItem.CurrentActivity = this.Name;
                workflowItem.Alias           = Alias;
                workflowItem.LevelCode       = levelCode;
                workflowItem.PasserUserId    = context.CurrentUser.Id;
                workflowItem.PasserUserName  = context.CurrentUser.Name;
                context.FlowInstance.InsertWorkItem(workflowItem);
                i++;
            }
            SendOtherToRead(context);
        }
コード例 #23
0
ファイル: WorkflowBuilder.cs プロジェクト: yunqian44/FoxOne
 public IWorkflow Build(string workflowId)
 {
     return(CacheHelper.GetFromCache <IWorkflow>(WORKFLOW_CACHE_KEY_FORMAT.FormatTo(workflowId), () =>
     {
         var components = DBContext <ComponentEntity> .Instance.Where(o => o.PageId.Equals(workflowId, StringComparison.OrdinalIgnoreCase));
         var workflow = ObjectHelper.GetObject <IWorkflow>();
         workflow.Activities = new List <IActivity>();
         workflow.Transitions = new List <ITransition>();
         Controls = new List <IControl>();
         JavaScriptSerializer serializer = new JavaScriptSerializer();
         serializer.RegisterConverters(new[] { new ComponentConverter() });
         foreach (var component in components)
         {
             var type = TypeHelper.GetType(component.Type);
             if (!component.JsonContent.IsNullOrEmpty())
             {
                 var instance = serializer.Deserialize(component.JsonContent, type);
                 var control = instance as IControl;
                 control.Id = component.Id;
                 control.ParentId = component.ParentId;
                 control.PageId = component.PageId;
                 control.TargetId = component.TargetId;
                 Controls.Add(control);
             }
         }
         foreach (var e in Controls)
         {
             if (e.ParentId.Equals(workflowId))
             {
                 if (e is IActivity)
                 {
                     var acti = e as IActivity;
                     acti.Name = e.Id;
                     workflow.Activities.Add(acti);
                     if (e is ResponseActivity)
                     {
                         var acti1 = e as ResponseActivity;
                         if (acti1.IsRoot)
                         {
                             workflow.Root = acti1;
                         }
                         if (acti1.IsFreeApproval)
                         {
                             var vActi = new BreakdownActivity()
                             {
                                 ResponseRuleType = ResponseRuleType.AllResponse, NeedChoice = false, Id = acti1.Name + "_BreakDown", Name = acti1.Name + "_BreakDown", Alias = acti1.Alias + "-分发", Actor = new UserSelectActor()
                                 {
                                     InnerActor = new ChildDepartmentActor()
                                     {
                                         DeptName = "IT研发中心", IfGetAllChildren = true, IfReturnSelf = true, RoleName = SysConfig.DefaultUserRole
                                     }
                                 }
                             };
                             var vTran = new BusinessTransition()
                             {
                                 Id = acti1.Name + "_To_" + vActi.Name, Label = "自由分发", Condition = new ChoiceCondition()
                                 {
                                     Choice = vActi.Name
                                 }
                             };
                             vTran.To = vActi;
                             vTran.From = acti1;
                             workflow.Transitions.Add(vTran);
                             workflow.Activities.Add(vActi);
                         }
                     }
                 }
                 else if (e is ITransition)
                 {
                     var tran = e as BusinessTransition;
                     tran.To = Controls.FirstOrDefault(o => o.Id.Equals(tran.ToId)) as IActivity;
                     tran.From = Controls.FirstOrDefault(o => o.Id.Equals(tran.FromId)) as IActivity;
                     workflow.Transitions.Add(tran);
                 }
                 GetChildren(e);
             }
         }
         foreach (var activity in workflow.Activities)
         {
             activity.Owner = workflow;
             if (activity.Actor != null)
             {
                 activity.Actor.Owner = activity;
                 if (activity.Actor is UserSelectActor)
                 {
                     (activity.Actor as UserSelectActor).InnerActor.Owner = activity;
                 }
             }
         }
         foreach (var tran in workflow.Transitions)
         {
             tran.Owner = workflow;
             if (tran.Condition != null)
             {
                 tran.Condition.Owner = tran;
             }
             if (tran.From.Transitions == null)
             {
                 tran.From.Transitions = new List <ITransition>();
             }
             tran.From.Transitions.Add(tran);
         }
         return workflow;
     }));
 }
コード例 #24
0
        public ActionResult Pagemanagement()
        {
            string pageId  = Request.QueryString[NamingCenter.PARAM_PAGE_ID];
            string type    = Request.QueryString[NamingCenter.PARAM_TYPE_NAME];
            var    param   = new Dictionary <string, object>();
            var    tabList = new List <InnerTabModel>();
            var    tab     = new Tab()
            {
                Id = "PageTab", PageId = "PageManagement", InitIndex = 0
            };

            if (type.IsNotNullOrEmpty())
            {
                param.Add(NamingCenter.PARAM_KEY_NAME, pageId);
                tabList.Add(new InnerTabModel()
                {
                    Id = "PageInfo", Url = HttpHelper.BuildUrl(pageEdit, param)
                });
                param.Clear();
            }
            if (pageId.IsNullOrEmpty())
            {
                pageId = "Root";
            }
            param.Add(NamingCenter.PARAM_PARENT_ID, pageId);
            param.Add(NamingCenter.PARAM_PAGE_ID, pageId);
            if (type == PermissionType.Page.ToString())
            {
                tabList.Add(new InnerTabModel()
                {
                    Id = "ComponentInfo", Url = HttpHelper.BuildUrl(ctrlList, param)
                });
                tabList.Add(new InnerTabModel()
                {
                    Id = "ExtFileInfo", Url = HttpHelper.BuildUrl("/Page/PageLayoutFileEntityList", param)
                });
                tabList.Add(new InnerTabModel()
                {
                    Id = "Design", Url = "/Page/PreView?" + NamingCenter.PARAM_PAGE_ID + "=" + pageId
                });
                tabList.Add(new InnerTabModel()
                {
                    Id = "PreView", Url = "/Page/" + pageId
                });
                tabList.Add(new InnerTabModel()
                {
                    Id = "Other", Url = "/PageDesigner/Other/" + pageId
                });
            }
            else
            {
                tabList.Add(new InnerTabModel()
                {
                    Id = "ChildrenInfo", Url = HttpHelper.BuildUrl(pageList, param)
                });
            }
            tabList.ForEach(o =>
            {
                var tabItem = new TabItem()
                {
                    Id       = o.Id,
                    Visiable = true,
                    TabName  = ObjectHelper.GetObject <ILangProvider>().GetString(o.Id)
                };
                tabItem.Content.Add(new IFrame()
                {
                    Src = o.Url, Id = "{0}-Iframe".FormatTo(o.Id)
                });
                tab.TabItems.Add(tabItem);
            });
            return(View(tab));
        }
コード例 #25
0
        public JsonResult RoleTypePermission()
        {
            string roleId       = Request["RoleId"];
            string permissionId = Request["Id"];
            string action       = Request["action"];
            string ruleId       = Request["RuleId"];

            switch (action)
            {
            case "Get":
                var roleType = DBContext <IRoleType> .Instance.FirstOrDefault(o => o.Id.Equals(roleId, StringComparison.OrdinalIgnoreCase));

                if (roleType != null)
                {
                    return(Json(roleType.Permissions));
                }
                else
                {
                    var role = DBContext <IRole> .Instance.FirstOrDefault(o => o.Id.Equals(roleId, StringComparison.OrdinalIgnoreCase));

                    if (role != null)
                    {
                        return(Json(role.RoleType.Permissions));
                    }
                }
                break;

            case "Add":

                string[] ids         = permissionId.Split(',');
                int      effectCount = 0;
                foreach (var id in ids)
                {
                    var item = ObjectHelper.GetObject <IRoleTypePermission>();
                    item.Id           = Guid.NewGuid().ToString();
                    item.PermissionId = id;
                    item.RoleTypeId   = roleId;
                    effectCount      += (DBContext <IRoleTypePermission> .Insert(item) ? 1 : 0);
                }
                Sec.Provider.Abandon();
                return(Json(ids.Length == effectCount));

            case "Remove":
                var items = DBContext <IRoleTypePermission> .Instance.Where(o => o.RoleTypeId.Equals(roleId, StringComparison.OrdinalIgnoreCase) && permissionId.Split(',').Contains(o.PermissionId, StringComparer.OrdinalIgnoreCase));

                int count = 0;
                foreach (var i in items)
                {
                    if (DBContext <IRoleTypePermission> .Delete(i))
                    {
                        count++;
                    }
                }
                Sec.Provider.Abandon();
                return(Json(count == items.Count()));

            case "Update":
                var permission = DBContext <IPermission> .Instance.FirstOrDefault(o => o.Id.Equals(permissionId, StringComparison.OrdinalIgnoreCase)).Childrens;

                if (!permission.IsNullOrEmpty())
                {
                    string[] permissionIds = permission.Select(o => o.Id).ToArray();
                    var      items1        = DBContext <IRoleTypePermission> .Instance.Where(o => o.RoleTypeId.Equals(roleId, StringComparison.OrdinalIgnoreCase) && permissionIds.Contains(o.PermissionId, StringComparer.OrdinalIgnoreCase));

                    foreach (var i in items1)
                    {
                        DBContext <IRoleTypePermission> .Delete(i);
                    }
                }
                var item2 = ObjectHelper.GetObject <IRoleTypePermission>();
                item2.Id           = Guid.NewGuid().ToString();
                item2.PermissionId = ruleId;
                item2.RoleTypeId   = roleId;
                DBContext <IRoleTypePermission> .Insert(item2);

                Sec.Provider.Abandon();
                break;
            }
            return(Json(false));
        }