示例#1
0
        public ActionResult deleteLine()
        {
            string templateId = Request.Form["templateId"];
            string LineID     = Request.Form["LineID"];

            if (Session[templateId] != null)
            {
                MyDB mydb = Session[templateId] as MyDB;

                /// 连接线可能有三种情况:来自于活动,表达式,或分支节点的缺省
                WFNodeAction action = mydb.WFNodeActions.Find(LineID);
                if (action != null)
                {
                    mydb.WFNodeActions.Remove(action);
                    return(Json(new { success = true }));
                }

                WFNodeExpression expression = mydb.WFNodeExpressions.Find(LineID);
                if (expression != null)
                {
                    mydb.WFNodeExpressions.Remove(expression);
                    return(Json(new { success = true }));
                }

                WFNodeStart start = mydb.WFNodeStarts.Find(LineID);
                if (start != null)
                {
                    start.Next = null;
                    return(Json(new { success = true }));
                }

                return(Json(new { success = false }));
            }
            return(Json(new { success = false }));
        }
示例#2
0
        /// <summary>
        /// URL: /workflow/Instance/create/id
        /// id: 模板ID
        /// 发起流程
        /// </summary>
        /// <returns></returns>
        public ActionResult create(string id)
        {
            using (MyDB mydb = new MyDB())
            {
                WFTemplate   template = mydb.WFTemplates.Find(id);
                WFNodeStart  start    = template.Nodes.OfType <WFNodeStart>().First();
                WFNodeHandle next     = start.Next as WFNodeHandle;
                if (next is WFNodeHandle)
                {
                    ((WFNodeHandle)next).Actions.Select(a => a);
                }

                Type t = getType(template);
                EntityObjectLib.WFInst inst = Activator.CreateInstance(t) as EntityObjectLib.WFInst;
                inst.WFTemplate  = template;
                inst.State       = "处理中";
                inst.WFInstNodes = new WFInstNode[] {
                    new WFInstNode
                    {
                        WFNode    = next,
                        State     = "处理中",
                        EntryTime = DateTime.Now,
                        WFInst    = inst
                    }
                };
                // 这里有一个设计约束:开始节点后一定是个处理节点
                return(View("toHandle", inst.CurrentNode));
            }
        }