Пример #1
0
        public void SaveFlowViewInfo(int flowid, string jsonstr)
        {
            using (var dal = BaseInfo._container.Resolve <UnitOfWork>())
            {
                var fa = dal.GetRepository <FlowActive>();

                var fs = dal.GetRepository <FlowStep>();

                dal.Set <FlowActive>().Where(a => a.FlowId == flowid).Delete();

                dal.Set <FlowStep>().Where(a => a.FlowId == flowid).Delete();

                dal.Set <ActiveCondition>().Where(a => a.FlowId == flowid).Delete();

                #region 分析json字符串
                var siSerializer = new JavaScriptSerializer();
                var objects      = siSerializer.Deserialize <FlowView>(jsonstr);

                var nodes = objects.nodes;
                var steps = new List <FlowStep>();
                foreach (var ss in nodes.Keys)
                {
                    var nodekey = ss;
                    var step    = ExpandHelper.DicToObject <FlowStep>(nodes[nodekey]);
                    step.flowNodeName = nodekey;
                    step.stepName     = step.name;
                    step.FlowId       = flowid;
                    steps.Add(step);
                }

                var lines   = objects.lines;
                var actives = new List <FlowActive>();
                foreach (var item in lines.Keys)
                {
                    var linekey   = item;
                    var linekalue = lines[linekey];
                    var active    = ExpandHelper.DicToObject <FlowActive>(linekalue);

                    var condis = new List <ActiveCondition>();
                    if (linekalue.ContainsKey("ConditionInfo"))
                    {
                        foreach (var cc in linekalue["ConditionInfo"])
                        {
                            var condition = ExpandHelper.DicToObject <ActiveCondition>(cc);
                            condition.FlowId = flowid;
                            condis.Add(condition);
                        }
                    }
                    active.ConditionInfo = condis;
                    active.FlowId        = flowid;
                    active.FlowLineName  = linekey;
                    actives.Add(active);
                }
                #endregion

                fa.Insert(actives);

                fs.Insert(steps);

                dal.Save();
            }
        }