public void updateProjectNextFindingIdValue()
 {
     XMLSPYPLUGINLib.XMLData xdXmlData = axAuthentic_Project.AuthenticView.WholeDocument.FirstXMLData;
     while (xdXmlData.Name != "Metadata")
     {
         xdXmlData = xdXmlData.Parent;
     }
     if (xdXmlData.HasChildren)
     {
         XMLSPYPLUGINLib.XMLData xdXmlDataAttr;
         try
         {
             xdXmlDataAttr = xdXmlData.GetFirstChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataAttr);
             Console.WriteLine(xdXmlDataAttr.Name.ToString());
             while (xdXmlDataAttr.Name != "next_ID_Number")
             {
                 xdXmlDataAttr = xdXmlData.GetNextChild();
             }
             xdXmlDataAttr.TextValue = currentProject.FindingId.ToString();
         }
         catch (Exception ex)
         {
             MessageBox.Show("in updateProjectNextFindingIdValue : " + ex.Message);
         }
         btSaveProjectMetadata_Click(null, null);
     }
 }
 private int returnLoadedProjectNextFindingIdValue()
 {
     try
     {
         XMLSPYPLUGINLib.XMLData xdXmlData = axAuthentic_Project.AuthenticView.WholeDocument.FirstXMLData;
         while (xdXmlData.Name != "Metadata")
         {
             if (xdXmlData.Name == "Project")
             {
                 xdXmlData = xdXmlData.GetFirstChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataElement);
                 break;
             }
             xdXmlData = xdXmlData.Parent;
         }
         if (xdXmlData.HasChildren)
         {
             XMLSPYPLUGINLib.XMLData xdXmlDataAttr;
             xdXmlDataAttr = xdXmlData.GetFirstChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataAttr);
             while (xdXmlDataAttr.Name != "next_ID_Number")
             {
                 xdXmlDataAttr = xdXmlData.GetNextChild();
             }
             return(Int32.Parse(xdXmlDataAttr.TextValue));
         }
     }
     // Swallow these errors.  This is from having stuff like an invalid range.
     // Since there is no way to validate the range in the authentic control
     // we have to do this for right now, YUCK!
     catch (System.Runtime.InteropServices.COMException) { }
     catch (System.FormatException) {}
     return(-1);
 }
Example #3
0
 private void btAssignIssueID_Click(object sender, System.EventArgs e)
 {
     try
     {
         XMLSPYPLUGINLib.XMLData xdXmlData = axAuthentic1.AuthenticView.Selection.FirstXMLData;
         while (xdXmlData.Name != "Finding")
         {
             xdXmlData = xdXmlData.Parent;
         }
         if (xdXmlData.HasChildren)
         {
             XMLSPYPLUGINLib.XMLData xdXmlDataAttr = xdXmlData.GetFirstChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataAttr);
             try
             {
                 while (xdXmlDataAttr.Name != Project.FindingIDAttributeName)
                 {
                     xdXmlDataAttr = xdXmlData.GetNextChild();
                 }
                 xdXmlDataAttr.TextValue = "XXXX";
                 return;
             }
             catch
             {}
             xdXmlDataAttr           = axAuthentic1.CreateChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataAttr);
             xdXmlDataAttr.Name      = Project.FindingIDAttributeName;
             xdXmlDataAttr.TextValue = "YYYYY";
             xdXmlData.AppendChild(xdXmlDataAttr);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #4
0
 static XMLSPYPLUGINLib.XMLData findXmlDataRecursively(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject, string strElementToFind)
 {
     XMLSPYPLUGINLib.XMLData xdXmlData = axTargetAuthenticObject.AuthenticView.WholeDocument.FirstXMLData;
     while (xdXmlData.Name != strElementToFind)
     {
         xdXmlData = xdXmlData.Parent;
     }
     return(xdXmlData);
 }
Example #5
0
 static string getAttributeFromElement(XMLSPYPLUGINLib.XMLData xnDataToSearch, string strAttributeName)
 {
     if (true == xnDataToSearch.HasChildren)
     {
         for (int iChildId = 0; iChildId < xnDataToSearch.CountChildren(); iChildId++)
         {
             XMLSPYPLUGINLib.XMLData xdAttribute = xnDataToSearch.GetChild(iChildId);
             if (XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataAttr == xdAttribute.kind)
             {
                 if (strAttributeName == xdAttribute.Name)
                 {
                     return(xdAttribute.TextValue);
                 }
             }
         }
     }
     return("");
 }
Example #6
0
        private void processAuthenticKeyboardEvent(AxXMLSPYPLUGINLib.AxAuthentic axActiveAuthenticControl, char cKeyPressed, utils.LocalWindowsHook lwhSender)
        {
            try
            {
                // find out which control is currently selected
                string strCurrentSelectedControl = "";
                if (axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.kind != XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataText)
                {
                    strCurrentSelectedControl = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Name;
                }
                else
                if (axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Parent.kind != XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataText)
                {
                    strCurrentSelectedControl = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Parent.Name;
                }
                else
                {
                    strCurrentSelectedControl = "Error in recognizing SPYXMLDataKind";
                }
                // apply Gui Funcionality
                switch (strCurrentSelectedControl)
                {
                case "value":                       // this could be the Target DNS or IP
                    string strParentControl = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Parent.Name;
                    if (cKeyPressed == 0x0d)
                    {
                        // 05-Feb-07: [Dinis], This is a hack to make the Enter work with the DnsName and IP elements (which use an attribute for its value and don't work in the new version of the Authentic component)

                        // get the value of the current element which should be either DnsValue or IP
                        string strValueOfCurrentElement = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.TextValue;
                        // get the parent.parent object which should be a 'Target' Element
                        XMLSPYPLUGINLib.XMLData xdData = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Parent.Parent;
                        if (xdData.Name == "Target")
                        {
                            // Now we are going to create manually either the 'DnsValue' or the 'IP' Element (the name we need is conveiniently in strParentControl)
                            XMLSPYPLUGINLib.XMLData xdXmlDataElement = axActiveAuthenticControl.CreateChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataElement);
                            xdXmlDataElement.Name = strParentControl;
                            // create the atribute 'value'
                            XMLSPYPLUGINLib.XMLData xdXmlDataAttribute = axActiveAuthenticControl.CreateChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataAttr);
                            xdXmlDataAttribute.Name = "value";
                            // add addit it to the xdXmlDataElement
                            xdXmlDataElement.AppendChild(xdXmlDataAttribute);
                            // now that we have an 'DnsValue' or 'IP' element ready we need to find the correct location to insert it (note that due to the current xsd you cannot append it at the end)
                            // Get first Child
                            XMLSPYPLUGINLib.XMLData xdChild = xdData.GetFirstChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataElement);
                            // and go though all childs until we find the current one
                            for (int iChildId = 0; iChildId < xdData.CountChildren(); iChildId++)
                            {
                                // at lack of better choise we will use the 'value' attribute to try to fing the location to insert (the only problem will happen if there is a duplicate 'value' (which would be a mistake in this case))
                                if (xdChild.Name == strParentControl && getAttributeFromElement(xdChild, "value") == strValueOfCurrentElement)
                                {
                                    // This will place the new Element before the current one
                                    xdData.InsertChild(xdXmlDataElement);
                                    // xdData.AppendChild(xdXmlDataElement);   /// this one doesn't work since it all puts it at the end
                                    break;
                                }
                                // move to the next child (we need to do this so that the InsertChild works as expected
                                if (iChildId < xdData.CountChildren() - 1)                // don't go to the next child if we are on the last one
                                {
                                    xdChild = xdData.GetNextChild();
                                }
                            }
                        }
                    }
                    break;

                    switch (strParentControl)
                    {
                    case "DnsName":
                        authentic.authentic_GotoNextTag(axActiveAuthenticControl);
                        authentic.authentic_GotoNextTag(axActiveAuthenticControl);
                        authentic.authentic_GotoNextTag(axActiveAuthenticControl);
                        authentic.authentic_GotoNextTag(axActiveAuthenticControl);

                        ///string strText =

                        string strParentContol2 = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Name;

                        // bool bResulta = authentic.authentic_InsertElementInCurrentSelectionPos_spyAuthenticInsertBefore(axActiveAuthenticControl, "DnsName");
                        break;

                    case "IP":
                        break;
                    }
                    break;

                case "level2":
                case "level3":
                    checkForCtrlVandInsertDataFromClipboard(axActiveAuthenticControl, cKeyPressed, false);
                    checkForEnterAndInsertNewLine(axActiveAuthenticControl, cKeyPressed);

                    //if (0x0d == cKeyPressed)			// 0x0d (13) Enter
                    //	utils.authentic.authentic_InsertNewLine(axActiveAuthenticControl);
                    break;

                case "AdittionalDetails":
                    checkForCtrlVandInsertDataFromClipboard(axActiveAuthenticControl, cKeyPressed, true);
                    if (0x08 == cKeyPressed)                                                    // 0x08 (08) Del
                    {
                        break;
                    }
                    checkForEnterAndInsertNewLine(axActiveAuthenticControl, cKeyPressed);
                    //if (0x0d == cKeyPressed)			// 0x0d (13) Enter
                    //	utils.authentic.authentic_InsertNewLine(axActiveAuthenticControl);
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);      // this was being thrown during normal ORG usage
            }
        }