Example #1
0
 /// <summary>
 /// 从数据库构造
 /// </summary>
 /// <param name="row"></param>
 public WorkFlowDefLine(Db_WorkFlowDefLine row)
 {
     this.Id   = row.Id;
     this.from = row.From;
     this.to   = row.To;
     this.M    = row.M;
     this.name = row.Name;
     this.type = row.Type;
 }
Example #2
0
 /// <summary>
 /// 构造方法 从步骤获取数据后进行构造
 /// </summary>
 /// <param name="row">数据库中的线信息</param>
 /// <param name="from">来自(出发节点)</param>
 /// <param name="to">目标(数据库)</param>
 public WorkFlowDefLineDetail(Db_WorkFlowDefLine row, WorkFlowDefStep from, Db_WorkFlowDefStep to) : base(row)
 {
     this.FromStep = from;
     this.ToStep   = new WorkFlowDefStep(to);
 }
Example #3
0
        /// <summary>
        /// 编辑流程图结构
        /// </summary>
        /// <param name="condtion"></param>
        /// <returns></returns>
        public WorkFlowDefinition EditDefUnit(WorkFlowDefEditRequest condtion)
        {
            if (condtion.lines == null)
            {
                condtion.lines = new List <WorkFlowDefLine>();
            }
            if (condtion.areas == null)
            {
                condtion.areas = new List <WorkFlowDefArea>();
            }
            if (condtion.nodes == null)
            {
                condtion.nodes = new List <WorkFlowDefStep>();
            }

            using (var db = new DefaultContainer()) {
                //三从表 创建新增/编辑已有/删除多余

                //节点
                Dictionary <string, string> nodesComb = new Dictionary <string, string>();//ID转换
                #region -- 节点
                foreach (var item in condtion.nodes)
                {
                    var row = db.Db_WorkFlowDefBaseUnitSet.OfType <Db_WorkFlowDefStep>().SingleOrDefault(p => p.Id == item.Id);
                    if (row == null)
                    {
                        var newId = SysHelps.GetNewId();
                        nodesComb.Add(item.Id, newId);
                        var newRow = new Db_WorkFlowDefStep()
                        {
                            Id = newId,
                            Db_WorkFlowDefinitionId = this.Id,
                            Name   = item.name,
                            Type   = (int)item.type,
                            Height = item.height,
                            Width  = item.width,
                            Left   = item.left,
                            Top    = item.top
                        };
                        db.Db_WorkFlowDefBaseUnitSet.Add(newRow);
                    }
                    else
                    {
                        nodesComb.Add(item.Id, item.Id);
                        row.Name   = item.name;
                        row.Type   = (int)item.type;
                        row.Height = item.height;
                        row.Width  = item.width;
                        row.Left   = item.left;
                        row.Top    = item.top;
                    }
                }
                var delSetpRows = (from c in db.Db_WorkFlowDefBaseUnitSet.OfType <Db_WorkFlowDefStep>().AsEnumerable() where !condtion.nodes.Select(p => p.Id).Contains(c.Id) && c.Db_WorkFlowDefinitionId == this.Id select c);
                if (delSetpRows.Count() > 0)
                {
                    db.Db_WorkFlowDefBaseUnitSet.RemoveRange(delSetpRows);
                }
                #endregion

                //连线

                #region -- 连线
                foreach (var item in condtion.lines)
                {
                    var row = db.Db_WorkFlowDefLineSet.SingleOrDefault(p => p.Id == item.Id);
                    if (row == null)
                    {
                        var newRow = new Db_WorkFlowDefLine()
                        {
                            Id   = SysHelps.GetNewId(),
                            From = nodesComb[item.from],
                            To   = nodesComb[item.to],
                            M    = item.M,
                            Name = item.name,
                            Type = item.type,
                            Db_WorkFlowDefinitionId = this.Id
                        };
                        db.Db_WorkFlowDefLineSet.Add(newRow);
                    }
                    else
                    {
                        row.From = nodesComb[item.from];
                        row.To   = nodesComb[item.to];
                        row.M    = item.M;
                        row.Name = item.name;
                        row.Type = item.type;
                    }
                }
                var delLineRows = (from c in db.Db_WorkFlowDefLineSet.AsEnumerable() where !condtion.lines.Select(p => p.Id).Contains(c.Id) && c.Db_WorkFlowDefinitionId == this.Id select c);
                if (delLineRows.Count() > 0)
                {
                    db.Db_WorkFlowDefLineSet.RemoveRange(delLineRows);
                }
                #endregion

                //区域

                #region -- 区域
                foreach (var item in condtion.areas)
                {
                    var row = db.Db_WorkFlowDefBaseUnitSet.OfType <Db_WorkFlowDefArea>().SingleOrDefault(p => p.Id == item.Id);
                    if (row == null)
                    {
                        var newRow = new Db_WorkFlowDefArea()
                        {
                            Id = SysHelps.GetNewId(),
                            Db_WorkFlowDefinitionId = this.Id,
                            Name   = item.name,
                            Color  = item.color,
                            Height = item.height,
                            Width  = item.width,
                            Left   = item.left,
                            Top    = item.top
                        };
                        db.Db_WorkFlowDefBaseUnitSet.Add(newRow);
                    }
                    else
                    {
                        row.Name   = item.name;
                        row.Color  = item.color;
                        row.Height = item.height;
                        row.Width  = item.width;
                        row.Left   = item.left;
                        row.Top    = item.top;
                    }
                }
                var delAreaRows = (from c in db.Db_WorkFlowDefBaseUnitSet.OfType <Db_WorkFlowDefArea>().AsEnumerable() where !condtion.areas.Select(p => p.Id).Contains(c.Id) && c.Db_WorkFlowDefinitionId == this.Id select c);
                if (delAreaRows.Count() > 0)
                {
                    db.Db_WorkFlowDefBaseUnitSet.RemoveRange(delAreaRows);
                }

                #endregion

                db.SaveChanges();
            }

            var info = WorkFlowDefinition.GetInstance(this.Id);
            info.SetUnits();
            return(info);
        }