Example #1
0
    private void Stream(XmlLinkedNode linkedNode)
    {
        Data.Add(new ClassSeparatorData(typeof(XmlLinkedNode)));

        switch (linkedNode)
        {
        case XmlElement element:
            Stream(element);
            return;

        case XmlCharacterData characterData:
            Stream(characterData);
            return;

        case XmlDeclaration declaration:
            Stream(declaration);
            return;

        case XmlDocumentType documentType:
            Stream(documentType);
            return;

        case XmlEntityReference entityReference:
            Stream(entityReference);
            return;

        case XmlProcessingInstruction processingInstruction:
            Stream(processingInstruction);
            return;
        }
    }
Example #2
0
        /// <summary>
        /// 准备执行
        /// </summary>
        /// <returns>是否可以进行</returns>
        public bool readyRun()
        {
            //检查网络状态 可能有强制执行点需求 不放在此处检查
            //if (!comm_1.IsOpen)
            //{
            //    MessageBox.Show("未连接到终端", "can not run");
            //    stopRun();
            //    return false;
            //}
            if (isRunCase || isRunTest)
            {
                MessageBox.Show("发现未结束的任务", "can not run");
                stopRun();
                return(false);
            }
            if (tvw_Case.SelectedNode == null)
            {
                MessageBox.Show("未选择任何项目", "can not run");
                stopRun();
                return(false);
            }
            startTreeNode = tvw_Case.SelectedNode;

            repeatTime       = 0;
            repeatStartIndex = 0;
            isCatchEnd       = false;

            if (startTreeNode.Parent == null)
            {
                //do something
                startTreeNode.Toggle();
                parentsTree   = startTreeNode;
                startTreeNode = parentsTree.Nodes[0];
                startXmlNode  = (System.Xml.XmlLinkedNode)(startTreeNode.Tag);
                parentsXml    = startXmlNode.ParentNode;
                nowIndex      = 0;
                nowCount      = startXmlNode.ParentNode.ChildNodes.Count;
                endIndex      = nowCount - 1;
                //startTreeNode.ImageIndex = 8;
                //startTreeNode.SelectedImageIndex = 8;
                //timerCount = 0;
                //timerFlag = 0;
                //myCasetimer.Enabled = true;
                return(true);
            }
            startXmlNode = (System.Xml.XmlLinkedNode)(tvw_Case.SelectedNode.Tag);
            parentsTree  = startTreeNode.Parent;
            parentsXml   = startXmlNode.ParentNode;
            nowIndex     = startTreeNode.Index;
            nowCount     = startXmlNode.ParentNode.ChildNodes.Count;
            endIndex     = nowCount - 1;
            //startTreeNode.ImageIndex = 8;
            //startTreeNode.SelectedImageIndex = 8;
            //timerCount = 0;
            //timerFlag = 0;
            //myCasetimer.Enabled = true;
            //isRead90 = true;
            //isRead93 = false;
            return(true);
        }
Example #3
0
        private void SelectCurrentItemInTreeRec(ItemsControl parent, object item)
        {
            var currentItem = graphControl.CurrentItem;

            if (currentItem == null)
            {
                return;
            }
            XmlLinkedNode employee = currentItem.Tag as XmlLinkedNode;

            if (item == null || parent == null || employee == null)
            {
                return;
            }

            var treeViewItem = parent.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem;

            if (treeViewItem != null)
            {
                if (item == employee)
                {
                    treeViewItem.IsSelected = true;
                    return;
                }
                foreach (var child in treeViewItem.Items)
                {
                    SelectCurrentItemInTreeRec(treeViewItem, child);
                }
            }
        }
Example #4
0
        private void Stream(XmlLinkedNode lnkNode)
        {
            MDataObjs.Add(new ClassSeparator(typeof(XmlLinkedNode)));

            // No data to show at this level, but we want to explicitly
            // show that there is an intermediate class.

            switch (lnkNode)
            {
            case XmlElement elem:
                Stream(elem);
                return;

            case XmlCharacterData charData:
                Stream(charData);
                return;

            case XmlDeclaration decl:
                Stream(decl);
                return;

            case XmlDocumentType dType:
                Stream(dType);
                return;

            case XmlEntityReference entRef:
                Stream(entRef);
                return;

            case XmlProcessingInstruction pi:
                Stream(pi);
                return;
            }
        }
 string GetPermissionValue(XmlLinkedNode x)
 {
     return(x.Attributes["Permission"] != null ?
            x.Attributes["Permission"].Value :
            x.Attributes["Class"] != null ? x.Attributes["Class"].Value :
            null);
 }
Example #6
0
        private async void TreeMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            XmlLinkedNode clickedItem  = ((TreeView)e.Source).SelectedItem as XmlLinkedNode;
            INode         selectedNode = filteredGraphWrapper.WrappedGraph.Nodes.FirstOrDefault(node => node.Tag == clickedItem);

            graphControl.CurrentItem = selectedNode;
            await ZoomToCurrentItem();
        }
Example #7
0
        private void ZoomToTreeItem()
        {
            XmlLinkedNode clickedItem = treeView.SelectedItem as XmlLinkedNode;
            // get the correspondent node in the graph
            INode selectedNode = filteredGraphWrapper.WrappedGraph.Nodes.FirstOrDefault(node => node.Tag == clickedItem);

            if (selectedNode != null && graphControl.Graph.Contains(selectedNode))
            {
                // select the node in the GraphControl
                GraphControl.CurrentItem = selectedNode;
                graphControl.EnsureVisible(selectedNode.Layout.ToRectD());
            }
        }
Example #8
0
        FrameworkElement FillSimpleValue(XmlLinkedNode linkedNode)
        {
            StackPanel nsp = new StackPanel();

            nsp.Orientation = Orientation.Horizontal;
            nsp.Children.Add(new Label()
            {
                MinWidth = 100, Content = linkedNode.ParentNode.Name
            });
            //TextBlock tb = new TextBlock();
            //tb.MinWidth = 50;
            //tb.CreateBinding(TextBlock.TextProperty, linkedNode, x => x.Value, (m, v) => { m.Value = v; });
            nsp.Children.Add(new TextBox()
            {
                MinWidth = 50, Text = linkedNode.Value
            });

            return(nsp);
        }
Example #9
0
        private void LoadNames(XmlLinkedNode linkedNode, T episode, DatabaseVersion dbVersion, DataStructure dataStructure)
        {
            switch (linkedNode.Name)
            {
            case "title":
            case "title_de":
                if (dataStructure == DataStructure.FakeData)
                {
                    episode.FakeTitleDE = linkedNode.GetElementValue();
                }
                else
                {
                    episode.TitleDE = linkedNode.GetElementValue();
                }
                break;

            case "title_en":
                if (dataStructure == DataStructure.FakeData)
                {
                    episode.FakeTitleEN = linkedNode.GetElementValue();
                }
                else
                {
                    episode.TitleEN = linkedNode.GetElementValue();
                }
                break;

            case "description":
            case "description_de":
                episode.DescriptionDE = linkedNode.GetElementValue();
                break;

            case "description_en":
                episode.DescriptionEN = linkedNode.GetElementValue();
                break;
            }
        }
Example #10
0
 public drizzleXMLReader(string str)
 {
     if (str == string.Empty)
     {
         success = false;
         return;
     }
     try
     {
         xd = new XmlDocument();
         xd.LoadXml(str);
         xe           = xd.DocumentElement;
         tablecontent = xe["TableContent"];
         if (tablecontent != null)
         {
             lines = tablecontent.FirstChild;
             if (lines == null)
             {
                 success = false;
             }
             else
             {
                 success = true;
             }
         }
         else
         {
             success = false;
         }
     }
     catch (Exception ee)
     {
         success = false;
     }
     //var tmp = xd.GetElementsByTagName
 }
Example #11
0
        FrameworkElement FillLinkedNode(XmlLinkedNode linkedNode)
        {
            StackPanel commonPanel = new StackPanel();

            commonPanel.Orientation = Orientation.Vertical;

            if (linkedNode.Value != null)
            {
                commonPanel.Children.Add(FillSimpleValue(linkedNode));
            }
            else
            {
                Expander childExpander = new Expander();
                childExpander.ExpandDirection = ExpandDirection.Down;
                childExpander.Header          = linkedNode.Name;

                StackPanel childPanel = new StackPanel();
                childPanel.Orientation = Orientation.Vertical;

                linkedNode.ForEach(lnode => {
                    var res = lnode as System.Xml.XmlLinkedNode;
                    childPanel.Children.Add(FillLinkedNode(res));
                });
                if (childPanel.Children.Count == 1)
                {
                    commonPanel.Children.Add(childPanel);
                }
                else
                {
                    childPanel.Margin     = new Thickness(20, 0, 0, 0);
                    childExpander.Content = childPanel;
                    commonPanel.Children.Add(childExpander);
                }
            }
            return(commonPanel);
        }
Example #12
0
 internal XmlLinkedNode(XmlDocument doc) : base(doc)
 {
     next = null;
 }
Example #13
0
 internal XmlLinkedNode() : base()
 {
     next = null;
 }
        private void radio_Checked(object sender, RoutedEventArgs e)
        {
            if (_openingDialog)
            {
                return;
            }

            // Check which radio button was pressed
            bool?state = (sender as RadioButton).Name == "radioAllow" ?
                         (bool?)true :
                         (sender as RadioButton).Name == "radioDeny" ?
                         (bool?)false :
                         (bool?)null;


            // Retrieve the data of the permission being set
            ListBoxItem   lbItem          = Visual.GetRoot <ListBoxItem>(sender as RadioButton);
            XmlLinkedNode x               = (XmlLinkedNode)lbItem.Content;
            string        permissionValue = GetPermissionValue(x);

            if (permissionValue == null)
            {
                return;
            }

            // Retrieve relevant parameters
            object[]          parameters = PermissionTarget_dialog.Content as object[];
            Oltp.UserRow      user       = parameters[0] as Oltp.UserRow;
            Oltp.UserGroupRow group      = parameters[0] as Oltp.UserGroupRow;
            Oltp.AccountPermissionDataTable permissionsTable = parameters[1] as Oltp.AccountPermissionDataTable;

            // Get the row with the last value for this permissions
            Oltp.AccountPermissionRow perm = permissionsTable.FindByAccountIDTargetIDTargetIsGroupPermissionType(
                Window.CurrentAccount.ID,
                user == null ? group.ID : user.ID,
                user == null,
                permissionValue);

            if (state == null && perm != null)
            {
                // Moving to unset, so if a permission exists, delete it
                perm.Delete();
            }
            else if (state != null)
            {
                if (perm == null)
                {
                    // Create a new permission target if none exists
                    perm                = permissionsTable.NewAccountPermissionRow();
                    perm.AccountID      = Window.CurrentAccount.ID;
                    perm.TargetID       = user != null ? user.ID : group.ID;
                    perm.TargetIsGroup  = user == null;
                    perm.PermissionType = permissionValue;
                    perm.Value          = true;
                    permissionsTable.Rows.Add(perm);
                }
                else if (perm.RowState == DataRowState.Deleted)
                {
                    // If the target was deleted, restore it
                    perm.RejectChanges();
                }

                // Apply the correct value
                if (state == true)
                {
                    perm.Value = true;
                }
                else
                {
                    perm.Value = false;
                }
            }
        }
 internal XmlLinkedNode( XmlDocument doc ): base( doc ) {
     next = null;
 }
 internal XmlLinkedNode(): base() {
     next = null;
 }
        /// <summary>
        /// Open the dialog
        /// </summary>
        private void PermissionTarget_dialog_Open(object sender, RoutedEventArgs e)
        {
            // Set dataItem as current item
            ListViewItem currentItem = _listTable.GetParentListViewItem(e.OriginalSource as FrameworkElement);

            Oltp.UserRow      user  = currentItem.Content as Oltp.UserRow;
            Oltp.UserGroupRow group = currentItem.Content as Oltp.UserGroupRow;

            // Retrieve applied permissions from the server
            Oltp.AccountPermissionDataTable permissionsTable = null;
            Window.AsyncOperation(delegate()
            {
                using (OltpProxy proxy = new OltpProxy())
                {
                    permissionsTable = proxy.Service.AccountPermission_Get(Window.CurrentAccount.ID,
                                                                           user == null ? group.ID : user.ID,
                                                                           user == null
                                                                           );
                }
            },
                                  delegate(Exception ex)
            {
                MessageBoxError("Failed to open permissions.", ex);
                return(false);
            },
                                  delegate()
            {
                _openingDialog = true;

                // Apply retrieved permissions to the GUI radio buttons
                ListBox permissionsList = Visual.GetDescendant <ListBox>(PermissionTarget_dialog);
                for (int i = 0; i < permissionsList.Items.Count; i++)
                {
                    XmlLinkedNode x        = (XmlLinkedNode)permissionsList.Items[i];
                    string permissionValue = GetPermissionValue(x);

                    if (permissionValue == null)
                    {
                        continue;
                    }

                    Oltp.AccountPermissionRow perm = permissionsTable.FindByAccountIDTargetIDTargetIsGroupPermissionType(
                        Window.CurrentAccount.ID,
                        user == null ? group.ID : user.ID,
                        user == null,
                        permissionValue);

                    ListBoxItem lbItem = (ListBoxItem)permissionsList.ItemContainerGenerator.ContainerFromIndex(i);

                    if (perm == null)
                    {
                        Visual.GetDescendant <RadioButton>(lbItem, "radioNotSet").IsChecked = true;
                    }
                    else if (perm.Value)
                    {
                        Visual.GetDescendant <RadioButton>(lbItem, "radioAllow").IsChecked = true;
                    }
                    else
                    {
                        Visual.GetDescendant <RadioButton>(lbItem, "radioDeny").IsChecked = true;
                    }
                }

                currentItem.IsSelected = true;

                // Show the dialog
                PermissionTarget_dialog.Title = String.Format("Editing permissions for {0}", user == null ? group.Name : user.Name);
                PermissionTarget_dialog.BeginEdit(new object[] { user == null ? group as DataRow : user as DataRow, permissionsTable });

                _openingDialog = false;
            });
        }