Exemplo n.º 1
0
        public void SaveDesign(string keyValue, string codes)
        {
            FlowEntity        flowEntity        = GetForm(keyValue);
            FlowVersionEntity flowVersionEntity = new FlowVersionEntity();
            Random            rand = new Random();

            flowVersionEntity.EnCode = "V" + DateTime.Now.ToString("yyyyMMddHHmmss") + rand.Next(0000, 9999);
            flowVersionEntity.Codes  = codes;
            if (flowEntity != null && !string.IsNullOrEmpty(flowEntity.Id))
            {
                flowVersionEntity.FlowId = flowEntity.Id;
                JObject obj = JObject.Parse(codes);
                if (obj != null)
                {
                    foreach (KeyValuePair <string, JToken> item in obj)
                    {
                        string key = item.Key;
                        switch (key)
                        {
                        case "title":
                            break;

                        case "nodes":
                            GenFlowNodes(flowVersionEntity, item);
                            break;

                        case "lines":
                            GenFlowLines(flowVersionEntity, item);
                            break;

                        case "areas":
                            GenFlowAreas(flowVersionEntity, item);
                            break;

                        case "initNum":
                            flowVersionEntity.InitNum = (int)item.Value;
                            break;
                        }
                    }
                }
                service.SaveDesign(flowVersionEntity);
            }
            else
            {
                throw new Exception("获取数据异常!");
            }
        }