示例#1
0
        private static List <string> RetrievePostAndPreActions(XmlNode workflowNode)
        {
            List <string> list = new List <string>();

            if (workflowNode == null)
            {
                return(list);
            }
            for (int i = 0; i < workflowNode.ChildNodes.Count; i++)
            {
                list.AddRange(DDIVUtil.RetrievePostAndPreActions(workflowNode.ChildNodes[i]));
            }
            if (workflowNode.Attributes != null)
            {
                if (workflowNode.Attributes["PreAction"] != null)
                {
                    list.Add(workflowNode.Attributes["PreAction"].Value);
                }
                if (workflowNode.Attributes["PostAction"] != null)
                {
                    list.Add(workflowNode.Attributes["PostAction"].Value);
                }
            }
            return(list);
        }
示例#2
0
        internal static DataObjectStore GetStore(string xamlName, Service profile)
        {
            DataObjectStore dataObjectStore;

            if (!DDIVUtil.dataObjectStores.TryGetValue(xamlName, out dataObjectStore))
            {
                dataObjectStore = DDIVUtil.BuildDataObjectStore(profile);
                DDIVUtil.dataObjectStores[xamlName] = dataObjectStore;
            }
            return(dataObjectStore);
        }
示例#3
0
        internal static string RetrieveCodesInPostAndPreActions(string workflowName, string xaml, string codeBehind)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();

            xmlDocument.LoadXml(xaml);
            string result;

            using (XmlNodeList elementsByTagName = xmlDocument.GetElementsByTagName(workflowName))
            {
                List <string> functionNames = DDIVUtil.RetrievePostAndPreActions(elementsByTagName[0]);
                result = DDIVUtil.RetrieveCodeFunctions(codeBehind, functionNames);
            }
            return(result);
        }
示例#4
0
        public List <string> ValidateWithArg(object target, Service profile, Dictionary <string, string> arguments)
        {
            List <string> list     = new List <string>();
            Variable      variable = target as Variable;

            arguments.TryGetValue("CodeBehind", out this.codeBehind);
            arguments.TryGetValue("Xaml", out this.xaml);
            string xamlName = arguments["SchemaName"];

            using (new DDIVMockRbacPrincipal())
            {
                Dictionary <string, List <string> > rbacMetaData = DDIVUtil.GetRbacMetaData(xamlName, profile);
                DataObjectStore store      = DDIVUtil.GetStore(xamlName, profile);
                DataTable       table      = DDIVUtil.GetTable(xamlName, profile, rbacMetaData);
                DataRow         dataRow    = table.NewRow();
                DataColumn      dataColumn = table.Columns[variable.Name];
                bool?           flag       = null;
                foreach (Workflow workflow in from x in profile.Workflows
                         where x is GetObjectWorkflow || x is GetObjectForNewWorkflow
                         select x)
                {
                    List <string> list2 = new List <string>();
                    if (rbacMetaData != null && rbacMetaData.ContainsKey(variable.Name))
                    {
                        list2.AddRange(rbacMetaData[variable.Name]);
                    }
                    MethodInfo method = typeof(MetaDataIncludeWorkflow).GetMethod("IsVariableSettable", BindingFlags.Instance | BindingFlags.NonPublic);
                    if ((workflow is GetObjectWorkflow || workflow is GetObjectForNewWorkflow) && !(method.Invoke(workflow, new object[]
                    {
                        dataRow,
                        table,
                        store,
                        variable,
                        profile,
                        list2
                    }) is bool?))
                    {
                        string workflowName = (workflow is GetObjectWorkflow) ? "SetObjectWorkflow" : "NewObjectWorkflow";
                        string code         = DDIVUtil.RetrieveCodesInPostAndPreActions(workflowName, this.xaml, this.codeBehind);
                        if (DDIVUtil.IsVariableUsedInCode(code, variable.Name))
                        {
                            list.Add(string.Format("Variable '{0}', Workflow {1}. Please register dependency via RbacDependenciesForNew/RbacDependenciesForSet or set the SetRoles to NA", variable.Name + " " + variable.DataObjectName, workflow.Name));
                        }
                    }
                }
            }
            return(list);
        }
示例#5
0
        internal static DataTable GetTable(string xamlName, Service profile, Dictionary <string, List <string> > rbacMetaData)
        {
            DataTable dataTable;

            if (!DDIVUtil.dataTables.TryGetValue(xamlName, out dataTable))
            {
                dataTable = new DataTable();
                IList <Variable> variables = profile.Variables;
                foreach (Variable profile2 in variables)
                {
                    dataTable.Columns.Add(AutomatedDataHandlerBase.CreateColumn(profile2, rbacMetaData, DDIVUtil.GetStore(xamlName, profile)));
                }
                DDIVUtil.dataTables[xamlName] = dataTable;
            }
            return(dataTable);
        }