private static bool IsValidKey(string key, ActivityType nodeType, Diagram diagram)
        {
            if (string.IsNullOrEmpty(key))
            {
                return(false);
            }

            if (nodeType == ActivityType.Initial || nodeType == ActivityType.Completed)
            {
                return(true);
            }

            if (!DiagramUtils.GetTemplateKeys(diagram).Contains(key))
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        private void btnActivityTempalte_Click(object sender, RoutedEventArgs e)
        {
            var element = sender as UIElement;

            if (!DiagramUtils.IsMainDiagram(element))
            {
                return;
            }

            var diagram = Part.FindAncestor <Diagram>(element);

            if (diagram == null)
            {
                return;
            }


            var nodeData = diagram.SelectedNode.Data as ActivityNode;

            if (nodeData == null)
            {
                return;
            }
            if (nodeData.Category != ActivityType.Normal.ToString())
            {
                MessageBox.Show("只能为Normal节点设置模板");
                return;
            }

            string templateID = Guid.NewGuid().ToString();

            //保存到数据库
            DiagramUtils.WebInterAct.SaveActivityTemplate(templateID);
            //保存到palette中
            DiagramUtils.AddActivityTemplate(diagram, nodeData.WfClone(templateID));
            DiagramUtils.GetTemplateKeys(diagram).Add(templateID);
        }