public int StatusUpdate(String IPAddress, ref System.Xml.XmlDocument RequestXML, ref System.Xml.XmlDocument data)
        {
            string strXML = RequestXML.InnerXml;

            MSXML2.IXMLDOMDocument statusUpdateXML = new MSXML2.DOMDocument();

            statusUpdateXML.loadXML(strXML.ToString());

            string iPAddresslocal = IPAddress;

            try
            {
                int StatusUpdateID = Get(statusUpdateXML, iPAddresslocal);
            }
            catch (Exception ex)
            {
            }
            data.LoadXml(statusUpdateXML.xml);

            //string destination="";
            //string codeBase = Assembly.GetExecutingAssembly().CodeBase;
            //UriBuilder uri = new UriBuilder(codeBase);
            //string path = Uri.UnescapeDataString(uri.Path);
            //destination = Path.Combine(Path.GetDirectoryName(path), "ResponseXML.xml");
            //statusUpdateXML.save(destination);

            return(1);
        }
Пример #2
0
        /// <summary>
        /// If Libronix is running, save its workspace in the specified file.
        /// <param name="path"></param>
        /// </summary>
        public static void SaveWorkspace(string path)
        {
            try
            {
                // If Libronix isn't running, we'll get an exception here
                object libApp = Marshal.GetActiveObject("LibronixDLS.LbxApplication");
                if (libApp == null)
                {
                    return;
                }

                LbxApplication libronixApp = libApp as LbxApplication;
                object         document    = libronixApp.MSXML.CreateDocument(0);
                //MSXML2.DOMDocument40 doc = new MSXML2.DOMDocument40();
                //doc.
                libronixApp.SaveWorkspace(document, "");
                MSXML2.DOMDocument doc = document as MSXML2.DOMDocument;
                doc.save(path);
                //Type docType = document.GetType();
                //MethodInfo info = docType.GetMethod("save");
                //if (info != null)
                //    info.Invoke(document, new object[] {path});
            }
            catch (COMException)
            {
                return;
            }
        }
Пример #3
0
        /// <summary>
        /// 根据SQL语句生成DOMDocumentClass对象
        /// </summary>
        /// <param name="Strsql">SQL语句</param>
        /// <param name="U8Login">U8Login对象</param>
        /// <returns></returns>
        public static MSXML2.DOMDocument getDom(string Strsql, string strConn)
        {
            MSXML2.DOMDocument dom  = new MSXML2.DOMDocument();
            ADODB.Connection   conn = new ADODB.Connection();
            ADODB.Recordset    rs   = new ADODB.Recordset();

            conn.Open(strConn);

            rs.Open(Strsql, conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic, -1);
            rs.Save(dom, ADODB.PersistFormatEnum.adPersistXML);

            return(dom);
        }
Пример #4
0
        static void DoTheRestore(string path)
        {
            LbxApplication libronixApp = null;

            try
            {
                // If Libronix isn't running, we'll get an exception here
                object libApp = Marshal.GetActiveObject("LibronixDLS.LbxApplication");
                return;                 // It IS running; don't disturb it.
            }
            catch (COMException e)
            {
                if ((uint)e.ErrorCode == 0x800401E3)                 // MK_E_UNAVAILABLE
                {
                    // try to start
                    libronixApp = new LbxApplicationClass();
                }
            }
            if (libronixApp == null)             // can't start, or not installed.
            {
                return;
            }
            try
            {
                // Try to load workspace.
                if (!File.Exists(path))
                {
                    libronixApp.Visible = true;                     //let them see it, anyway.
                    return;
                }
                object             document = libronixApp.MSXML.CreateDocument(0);
                MSXML2.DOMDocument doc      = document as MSXML2.DOMDocument;
                doc.load(path);

                //Type docType = document.GetType();
                //MethodInfo info = docType.GetMethod("Save");
                //if (info == null)
                //{
                //    ReportLoadProblem();
                //    return;
                //}
                //info.Invoke(document, new object[] { path });
                libronixApp.LoadWorkspace(document, "", DlsSaveChanges.dlsPromptToSaveChanges);
                libronixApp.Visible = true;                 //only after we reload the workspace, to save flashing.
            }
            catch (Exception)
            {
                libronixApp.Visible = true;                 //let them see it, anyway.
                ReportLoadProblem();
            }
        }
        /// <summary>
        /// Determine the type of request/response recived in XML
        /// This is done by extracting the attribute value from the
        /// first node value of first child element of the document
        /// </summary>
        /// <param name="XMLFilename"> </param>
        public string TypeOfXMLRecieved(string XMLFilename)
        {
            // Declares and initializes a local variable document
            // of type IXMLDOMDocument present in MSXML2 class. This
            // variable is used to point to the XML filename or document
            MSXML2.IXMLDOMDocument document = new MSXML2.DOMDocument();

            // Declares a local variable element of type IXMLDOMElement
            // This is used to point to the elements present in the XML
            // document
            MSXML2.IXMLDOMElement element;

            // Declares a local variable node of type IXMLDOMElement
            // This is used to point to the nodes present in the XML
            // Document
            MSXML2.IXMLDOMNode node;

            // A local variable NodeValue is declared of type string
            // it is used to store the retrieved value from the XML and
            // returns it from the function
            string NodeValue;

            // Read the XML document syncronously
            document.async = false;

            // Initializes NodeValue to null
            NodeValue = null;

            // Loads the XML document for reading
            if (document.load(XMLFilename))
            {
                // Extract the first element of the XML
                element = document.documentElement;

                // Extract the first child node from the element
                // and stores it to the node
                node = element.firstChild;

                // now extract the first node value from the attributes
                // present in the XML and saves it to NodeValue
                NodeValue = node.attributes.nextNode().nodeValue.ToString();
            }

            // Simply returns the NodeValue variable
            return(NodeValue);
        }
        // The following CreateBasicXMLItmesForSchematicElt private procedure is used to create the first expected XML items for a XML NodeFeature or LinkFeature
        private void CreateBasicXMLItemsForSchematicElt(ESRI.ArcGIS.Geodatabase.IFeature inFeature,
                                                        ref MSXML2.DOMDocument outDOMDoc,
                                                        ref MSXML2.IXMLDOMElement outXMLElement,
                                                        string inEltTypeName)
        {
            MSXML2.IXMLDOMElement xmlElt_EltTypeName;
            MSXML2.IXMLDOMElement xmlElt_ExternalUID;
            MSXML2.IXMLDOMElement xmlElt_DatasourceName;
            MSXML2.IXMLDOMElement xmlElt_UCID;
            MSXML2.IXMLDOMElement xmlElt_UOID;

            // Specifying its FeatureClassName
            xmlElt_EltTypeName = outDOMDoc.createElement("FeatureClassName");
            outXMLElement.appendChild(xmlElt_EltTypeName);
            if (inFeature.Fields.FindField("Feeder") != -1)
            {
                xmlElt_EltTypeName.nodeTypedValue = inEltTypeName + "sFeeder" + inFeature.get_Value(inFeature.Fields.FindField("Feeder")).ToString();
            }
            else
            {
                xmlElt_EltTypeName.nodeTypedValue = inEltTypeName + "s";
            }

            // Specifying its ExternalUniqueID
            xmlElt_ExternalUID = outDOMDoc.createElement("ExternalUniqueID");
            outXMLElement.appendChild(xmlElt_ExternalUID);
            xmlElt_ExternalUID.nodeTypedValue = inEltTypeName + "-" + inFeature.OID.ToString();

            // Specifying its DatasourceName
            xmlElt_DatasourceName = outDOMDoc.createElement("DatasourceName");
            outXMLElement.appendChild(xmlElt_DatasourceName);
            xmlElt_DatasourceName.nodeTypedValue = "XMLDataSource";

            // Specifying its UCID
            xmlElt_UCID = outDOMDoc.createElement("UCID");
            outXMLElement.appendChild(xmlElt_UCID);
            xmlElt_UCID.nodeTypedValue = inFeature.Class.ObjectClassID;

            // Add UOID to NodeElement
            xmlElt_UOID = outDOMDoc.createElement("UOID");
            outXMLElement.appendChild(xmlElt_UOID);
            xmlElt_UOID.nodeTypedValue = inFeature.OID;
        }
        // The following CompleteXMLEltByProperties private procedure is used to create all the expected propertyset properties listed in the input PropertiesArray array
        private void CompleteXMLEltByProperties(ESRI.ArcGIS.Geodatabase.IFeature inFeature,
                                                ref MSXML2.DOMDocument outDOMDoc,
                                                ref MSXML2.IXMLDOMElement outXMLElement,
                                                string[] propertiesArray)
        {
            int i = 0;

            MSXML2.IXMLDOMElement xmlPropertySet;
            MSXML2.IXMLDOMElement xmlPropertyArray;
            MSXML2.IXMLDOMElement xmlPropertySetProperty;
            MSXML2.IXMLDOMElement xmlProperty_Key;
            MSXML2.IXMLDOMElement xmlProperty_Value;

            if (propertiesArray.Length > 0)
            {
                //-------- PropertySet Section START --------
                // Creating the PropertySet element for the input outXMLElement
                xmlPropertySet = outDOMDoc.createElement("PropertySet");
                outXMLElement.appendChild(xmlPropertySet);
                // Creating the PropertyArray element
                xmlPropertyArray = outDOMDoc.createElement("PropertyArray");
                xmlPropertySet.appendChild(xmlPropertyArray);

                while (i < propertiesArray.Length)
                {
                    // Creating the i PropertySetProperty
                    xmlPropertySetProperty = outDOMDoc.createElement("PropertySetProperty");
                    xmlPropertyArray.appendChild(xmlPropertySetProperty);
                    // Specifying the key && value field related to that i PropertySetProperty
                    xmlProperty_Key = outDOMDoc.createElement("Key");
                    xmlPropertySetProperty.appendChild(xmlProperty_Key);
                    xmlProperty_Key.nodeTypedValue = propertiesArray[i].ToString();
                    xmlProperty_Value = outDOMDoc.createElement("Value");
                    xmlPropertySetProperty.appendChild(xmlProperty_Value);
                    xmlProperty_Value.nodeTypedValue = inFeature.get_Value(inFeature.Fields.FindField(propertiesArray[i].ToString()));
                    i += 1;
                }
            }
            //-------- PropertySet Section END --------
        }
        public void GenerateXmlData(string diagramName, string diagramClassName, ref object xmlSource, ref bool cancel)
        {
            MSXML2.DOMDocument      xmlDOMDocument = new MSXML2.DOMDocument();
            ESRI.ArcGIS.Carto.IMaps maps;
            ESRI.ArcGIS.Carto.IMap  currentMap;
            ESRI.ArcGIS.Geodatabase.IEnumFeature enumFeature;
            ESRI.ArcGIS.Geodatabase.IFeature     feature;
            MSXML2.IXMLDOMProcessingInstruction  xmlProcInstr;
            MSXML2.IXMLDOMElement   xmlDiagrams;
            MSXML2.IXMLDOMElement   xmlDiagram;
            MSXML2.IXMLDOMElement   xmlFeatures;
            MSXML2.IXMLDOMElement   xmlDataSources;
            MSXML2.IXMLDOMElement   xmlDataSource;
            MSXML2.IXMLDOMElement   xmlDataSource_Namestring;
            MSXML2.IXMLDOMElement   xmlDataSource_WorkspaceInfo;
            MSXML2.IXMLDOMElement   xmlWorkspaceInfo_PathName;
            MSXML2.IXMLDOMElement   xmlWorkspaceInfo_WorkspaceFactoryProgID;
            MSXML2.IXMLDOMAttribute rootAtt1;
            MSXML2.IXMLDOMAttribute rootAtt2;
            ESRI.ArcGIS.Geodatabase.IEnumFeatureSetup enumFeatureSetup;
            string xmlDatabase;

            // Retrieving the selected set of features
            enumFeature = null;
            feature     = null;

            m_mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)m_application.Document;
            maps         = m_mxDocument.Maps;
            int i = 0;

            while (i < maps.Count)
            {
                currentMap                 = maps.get_Item(i);
                enumFeature                = (ESRI.ArcGIS.Geodatabase.IEnumFeature)currentMap.FeatureSelection;
                enumFeatureSetup           = (ESRI.ArcGIS.Geodatabase.IEnumFeatureSetup)enumFeature;
                enumFeatureSetup.AllFields = true;
                feature = enumFeature.Next();
                if (feature != null)
                {
                    break;
                }

                i += 1;
            }

            // if (there is no selected feature in the MxDocument, the procedure is interrupted
            if (feature == null)
            {
                MessageBox.Show("There is no feature selected. Select a set of features.", "Generate/Update XML diagrams", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cancel = true;
                return;
            }

            //Checking the feature dataset related to the selected features
            ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass;
            string featureDatasetName;

            featureClass       = (ESRI.ArcGIS.Geodatabase.IFeatureClass)feature.Class;
            featureDatasetName = featureClass.FeatureDataset.BrowseName;
            xmlDatabase        = featureClass.FeatureDataset.Workspace.PathName;

            // if the selected features come from another feature dataset than the expected one, the procedure is interrupted
            if (featureDatasetName != DatasetName)
            {
                //More restrictive condition: if (xmlDatabase != "c:\Mybase.gdb" )
                MessageBox.Show("This component doesn't work from the selected set of features.");
                cancel = true;
                return;
            }

            // Writing the XML heading items in the DOMDocument
            xmlProcInstr = xmlDOMDocument.createProcessingInstruction("xml", "version='1.0'");
            xmlDOMDocument.appendChild(xmlProcInstr);
            xmlProcInstr = null;

            //-------- Diagrams Section START --------
            // Creating the root Diagrams element
            xmlDiagrams = xmlDOMDocument.createElement("Diagrams");
            xmlDOMDocument.documentElement = xmlDiagrams;
            rootAtt1      = xmlDOMDocument.createAttribute("xmlns:xsi");
            rootAtt1.text = "http://www.w3.org/2001/XMLSchema-instance";
            xmlDiagrams.attributes.setNamedItem(rootAtt1);

            // Creating the Diagram element for the diagram which is going to be generated
            xmlDiagram = xmlDOMDocument.createElement("Diagram");
            xmlDiagrams.appendChild(xmlDiagram);
            rootAtt1      = xmlDOMDocument.createAttribute("EnforceDiagramTemplateName");
            rootAtt1.text = "false";
            xmlDiagram.attributes.setNamedItem(rootAtt1);
            rootAtt2      = xmlDOMDocument.createAttribute("EnforceDiagramName");
            rootAtt2.text = "false";
            xmlDiagram.attributes.setNamedItem(rootAtt2);

            //-------- DataSources Section START --------
            // Creating the DataSources element
            xmlDataSources = xmlDOMDocument.createElement("Datasources");
            xmlDiagram.appendChild(xmlDataSources);
            xmlDataSource = xmlDOMDocument.createElement("Datasource");
            xmlDataSources.appendChild(xmlDataSource);

            // Specifying the Namestring for the related Datasource element
            xmlDataSource_Namestring = xmlDOMDocument.createElement("NameString");
            xmlDataSource.appendChild(xmlDataSource_Namestring);
            xmlDataSource_Namestring.nodeTypedValue = "XMLDataSource";

            // Specifying the WorkspaceInfo for the related Datasource element
            xmlDataSource_WorkspaceInfo = xmlDOMDocument.createElement("WorkSpaceInfo");
            xmlDataSource.appendChild(xmlDataSource_WorkspaceInfo);
            xmlWorkspaceInfo_PathName = xmlDOMDocument.createElement("PathName");
            xmlDataSource_WorkspaceInfo.appendChild(xmlWorkspaceInfo_PathName);
            xmlWorkspaceInfo_PathName.nodeTypedValue = xmlDatabase;
            xmlWorkspaceInfo_WorkspaceFactoryProgID  = xmlDOMDocument.createElement("WorkspaceFactoryProgID");
            xmlDataSource_WorkspaceInfo.appendChild(xmlWorkspaceInfo_WorkspaceFactoryProgID);
            xmlWorkspaceInfo_WorkspaceFactoryProgID.nodeTypedValue = "esriDataSourcesGDB.FileGDBWorkspaceFactory";
            //-------- DataSources Section END --------

            //-------- Features Section START --------
            xmlFeatures = xmlDOMDocument.createElement("Features");
            xmlDiagram.appendChild(xmlFeatures);
            while (feature != null)
            {
                switch (feature.FeatureType)
                {
                case ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimpleJunction:
                    CreateXMLNodeElt(feature, ref xmlDOMDocument, ref xmlFeatures, feature.Class.AliasName);
                    break;

                case ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimpleEdge:
                    CreateXMLLinkElt(feature, ref xmlDOMDocument, ref xmlFeatures, feature.Class.AliasName);
                    break;
                }
                feature = enumFeature.Next();
            }

            // output the XML we created
            xmlSource = xmlDOMDocument;
            cancel    = false;
            //-------- Features Section END --------
            //-------- Diagrams Section END --------
        }
        // The following CreateXMLLinkElt private procedure is used to create all the expected XML items for a XML LinkFeature related to a HV_Line or LV_Line simple edge feature
        private void CreateXMLLinkElt(ESRI.ArcGIS.Geodatabase.IFeature inFeature, ref MSXML2.DOMDocument outDOMDoc, ref MSXML2.IXMLDOMElement outXMLElements, string inLinkTypeName)
        {
            if (!inFeature.HasOID)
            {
                MessageBox.Show("No OID");
                return;
            }

            MSXML2.IXMLDOMElement xmlLink;
            MSXML2.IXMLDOMElement xmlLink_FromNode;
            MSXML2.IXMLDOMElement xmlLink_ToNode;
            int    indexListPoints;
            string listPoints;
            int    nbVertices;
            string vertices;

            MSXML2.IXMLDOMElement xmlLink_Vertices;
            MSXML2.IXMLDOMElement xmlLink_Vertex;
            MSXML2.IXMLDOMElement xmlLink_XVertex;
            MSXML2.IXMLDOMElement xmlLink_YVertex;
            string xValue;
            string yValue;

            //-------- Feature Section START related to the "infeature" --------
            // Creating the LinkFeature Feature
            xmlLink = outDOMDoc.createElement("LinkFeature");
            outXMLElements.appendChild(xmlLink);

            // Specifying basic XML items for this LinkFeature
            CreateBasicXMLItemsForSchematicElt(inFeature, ref outDOMDoc, ref xmlLink, inLinkTypeName);
            // Specifying its FromNode
            xmlLink_FromNode = outDOMDoc.createElement("FromNode");
            xmlLink.appendChild(xmlLink_FromNode);
            xmlLink_FromNode.nodeTypedValue = inFeature.get_Value(inFeature.Fields.FindField("FromJunctionType")) + "-" + inFeature.get_Value(inFeature.Fields.FindField("FromJunctionOID"));
            // Specifying its ToNode
            xmlLink_ToNode = outDOMDoc.createElement("ToNode");
            xmlLink.appendChild(xmlLink_ToNode);
            xmlLink_ToNode.nodeTypedValue = inFeature.get_Value(inFeature.Fields.FindField("ToJunctionType")) + "-" + inFeature.get_Value(inFeature.Fields.FindField("ToJunctionOID"));

            //Add Vertices to LinkFeature ---- NEED TO BE COMPLETED
            indexListPoints = inFeature.Fields.FindField("ListPoints");
            if (indexListPoints > 0)
            {
                listPoints = "";
                listPoints = inFeature.get_Value(indexListPoints).ToString();
                if (listPoints != "")
                {
                    int foundChar = listPoints.IndexOf(";", 1);
                    nbVertices = System.Convert.ToInt32(listPoints.Substring(0, foundChar));
                    vertices   = listPoints.Substring(foundChar + 1);
                    if (nbVertices > 0)
                    {
                        // Specifying its Vertices
                        xmlLink_Vertices = outDOMDoc.createElement("Vertices");
                        xmlLink.appendChild(xmlLink_Vertices);

                        int iLoc;
                        for (int i = 1; i <= nbVertices; i++)
                        {
                            xValue = "";
                            yValue = "";
                            iLoc   = vertices.IndexOf(";", 1);
                            if (vertices != "" && (iLoc) > 0)
                            {
                                xValue = vertices.Substring(0, iLoc);
                            }
                            vertices = vertices.Substring(iLoc + 1);
                            iLoc     = vertices.IndexOf(";", 1);
                            if (vertices != ";" && (iLoc) > 0)
                            {
                                yValue = vertices.Substring(0, iLoc);
                            }

                            if (xValue != "" && yValue != "")
                            {
                                xmlLink_Vertex = outDOMDoc.createElement("Vertex");
                                xmlLink_Vertices.appendChild(xmlLink_Vertex);
                                xmlLink_XVertex = outDOMDoc.createElement("X");
                                xmlLink_Vertex.appendChild(xmlLink_XVertex);
                                xmlLink_XVertex.nodeTypedValue = xValue;
                                xmlLink_YVertex = outDOMDoc.createElement("Y");
                                xmlLink_Vertex.appendChild(xmlLink_YVertex);
                                xmlLink_YVertex.nodeTypedValue = yValue;
                                if (vertices.Length - iLoc > 0)
                                {
                                    vertices = vertices.Substring(iLoc + 1);                                     //sVertices.Length - iLoc)
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }
            else
            {            // Retrieving ListPoint from geometry
                ESRI.ArcGIS.Geometry.IPolyline        oPoly   = (ESRI.ArcGIS.Geometry.IPolyline)inFeature.ShapeCopy;
                ESRI.ArcGIS.Geometry.IPointCollection colLink = (ESRI.ArcGIS.Geometry.IPointCollection)oPoly;
                if (colLink != null && colLink.PointCount > 2)
                {
                    ESRI.ArcGIS.Geometry.IPoint oPoint;

                    xmlLink_Vertices = outDOMDoc.createElement("Vertices");
                    xmlLink.appendChild(xmlLink_Vertices);
                    for (int i = 1; i < colLink.PointCount - 1; i++)
                    {
                        oPoint = colLink.get_Point(i);

                        xmlLink_Vertex = outDOMDoc.createElement("Vertex");
                        xmlLink_Vertices.appendChild(xmlLink_Vertex);
                        xmlLink_XVertex = outDOMDoc.createElement("X");
                        xmlLink_Vertex.appendChild(xmlLink_XVertex);
                        xmlLink_XVertex.nodeTypedValue = oPoint.X;
                        xmlLink_YVertex = outDOMDoc.createElement("Y");
                        xmlLink_Vertex.appendChild(xmlLink_YVertex);
                        xmlLink_YVertex.nodeTypedValue = oPoint.Y;
                    }
                }
            }

            //Specifying its properties
            switch (inFeature.Class.AliasName)
            {
            case "LV_Line":
            {
                CompleteXMLEltByProperties(inFeature, ref outDOMDoc, ref xmlLink, m_LVLinesPropertiesArray);
                break;
            }
            }
            //-------- Feature Section END related to the "infeature" --------
        }
        // The following CreateXMLLNodeElt private procedure is used to create all the expected
        // XML items for a XML NodeFeature related to a Station or Feeder simple junction feature
        private void CreateXMLNodeElt(ESRI.ArcGIS.Geodatabase.IFeature inFeature, ref MSXML2.DOMDocument outDOMDoc, ref MSXML2.IXMLDOMElement outXMLElements, string inNodeTypeName)
        {
            if (!inFeature.HasOID)
            {
                MessageBox.Show("No OID");
                return;
            }

            MSXML2.IXMLDOMElement xmlNode;
            MSXML2.IXMLDOMElement xmlNode_XCoord;
            MSXML2.IXMLDOMElement xmlNode_YCoord;
            MSXML2.IXMLDOMElement xmlNode_RelatedContainerID;
            bool relatedContainer;

            MSXML2.IXMLDOMNodeList xmlNodeList;
            MSXML2.IXMLDOMElement  xmlDrawing;
            MSXML2.IXMLDOMElement  xmlDrawing_EltTypeName;
            MSXML2.IXMLDOMElement  xmlDrawing_ExternalUID;

            //-------- Feature Section START related to the "infeature" --------
            // Creating the NodeFeature element
            xmlNode = outDOMDoc.createElement("NodeFeature");
            outXMLElements.appendChild(xmlNode);
            // Specifying basic XML items for this NodeFeature
            CreateBasicXMLItemsForSchematicElt(inFeature, ref outDOMDoc, ref xmlNode, inNodeTypeName);

            // Specifying its X && Y when they exist
            if ((inFeature.Fields.FindField("X") > 0) && (inFeature.Fields.FindField("Y") > 0))
            {
                // Specifying InitialX
                xmlNode_XCoord = outDOMDoc.createElement("InitialX");
                xmlNode.appendChild(xmlNode_XCoord);
                xmlNode_XCoord.nodeTypedValue = inFeature.get_Value(inFeature.Fields.FindField("X"));
                // Specifying InitialY
                xmlNode_YCoord = outDOMDoc.createElement("InitialY");
                xmlNode.appendChild(xmlNode_YCoord);
                xmlNode_YCoord.nodeTypedValue = inFeature.get_Value(inFeature.Fields.FindField("Y"));
            }
            else
            {
                // Retrieving initial position from Geometry
                ESRI.ArcGIS.Geometry.IPoint oPoint = (ESRI.ArcGIS.Geometry.IPoint)inFeature.ShapeCopy;

                if (oPoint != null)
                {
                    // Specifying InitialX
                    xmlNode_XCoord = outDOMDoc.createElement("InitialX");
                    xmlNode.appendChild(xmlNode_XCoord);
                    xmlNode_XCoord.nodeTypedValue = oPoint.X;
                    // Specifying InitialY
                    xmlNode_YCoord = outDOMDoc.createElement("InitialY");
                    xmlNode.appendChild(xmlNode_YCoord);
                    xmlNode_YCoord.nodeTypedValue = oPoint.Y;
                }
            }

            xmlNode_RelatedContainerID = outDOMDoc.createElement("RelatedContainerID");
            xmlNode.appendChild(xmlNode_RelatedContainerID);

            // Specifying its properties
            switch (inFeature.Class.AliasName)
            {
            case "Station":
            {
                xmlNode_RelatedContainerID.nodeTypedValue = "Container-" + System.Convert.ToString(inFeature.get_Value(inFeature.Fields.FindField("Feeder")));
                // For Station feature, the field contained in the StationsPropertiesArray will be exported
                CompleteXMLEltByProperties(inFeature, ref outDOMDoc, ref xmlNode, m_stationsPropertiesArray);
                break;
            }

            case "Feeder":
            {
                xmlNode_RelatedContainerID.nodeTypedValue = "Container-" + inFeature.OID.ToString();
                // For Feeder feature, the field contained in the StationsPropertiesArray will be exported
                CompleteXMLEltByProperties(inFeature, ref outDOMDoc, ref xmlNode, m_feedersPropertiesArray);
                break;
            }
            }
            //-------- Feature Section END related to the "infeature" --------

            // Checking the existence of the related container
            xmlNodeList      = outXMLElements.selectNodes("NodeFeature/ExternalUniqueID");
            relatedContainer = false;

            foreach (MSXML2.IXMLDOMNode node in xmlNodeList)
            {
                if (node.text == xmlNode_RelatedContainerID.nodeTypedValue.ToString())
                {
                    relatedContainer = true;
                    break;
                }
            }             // pNode

            // Creating the related container when it doesn//t already exist
            if (!relatedContainer)
            {
                xmlDrawing = outDOMDoc.createElement("NodeFeature");
                outXMLElements.appendChild(xmlDrawing);
                // Specifying its FeatureClassName
                xmlDrawing_EltTypeName = outDOMDoc.createElement("FeatureClassName");
                xmlDrawing.appendChild(xmlDrawing_EltTypeName);
                xmlDrawing_EltTypeName.nodeTypedValue = "Containers";
                // Specifying its ExternalUniqueID
                xmlDrawing_ExternalUID = outDOMDoc.createElement("ExternalUniqueID");
                xmlDrawing.appendChild(xmlDrawing_ExternalUID);
                xmlDrawing_ExternalUID.nodeTypedValue = xmlNode_RelatedContainerID.nodeTypedValue;
            }
        }
        // determins the request type passed in the given XML document
        public string DetermineRequestType(string path, out int UploadDownloadPrint, out string[] chatInfo)
        {
            int    b        = 0;
            string scopeVal = "";
            bool   flag     = false;

            string[] st = new string[3];

            try
            {
                // load the XML document
                MSXML2.IXMLDOMDocument document = new MSXML2.DOMDocument();
                if (!document.load(path))
                {
                    throw new Exception("XML request found corrupted.");
                }

                // retrieve the request element
                MSXML2.IXMLDOMElement      element = document.documentElement;
                MSXML2.IXMLDOMNode         node    = element.firstChild;
                MSXML2.IXMLDOMNamedNodeMap nodemap = node.attributes;
                // retrieve it's attributes
                MSXML2.IXMLDOMNode childNode = nodemap.nextNode();

                if (0 == node.nodeName.CompareTo("request"))
                {
                    // see what value does the element tequest holds
                    // and react apprpriately
                    switch (childNode.nodeValue.ToString())
                    {
                    case "CHAT":
                    {
                        b = 4;
                        MSXML2.IXMLDOMNode         scope      = node.firstChild;
                        MSXML2.IXMLDOMNamedNodeMap nodemap2   = scope.attributes;
                        MSXML2.IXMLDOMNode         childNode2 = nodemap2.nextNode();
                        MSXML2.IXMLDOMNode         childNode3 = nodemap2.nextNode();
                        MSXML2.IXMLDOMNode         childNode4 = nodemap2.nextNode();
                        // set file name to upload to "path" parameter
                        st.Initialize();
                        st.SetValue(childNode2.nodeValue.ToString(), 0);
                        st.SetValue(childNode3.nodeValue.ToString(), 1);
                        st.SetValue(childNode4.nodeValue.ToString(), 2);
                        break;
                    }

                    case "SEARCH":
                    {
                        WriteSearchResponse(node);
                        break;
                    }

                    case "SHOWFILES":
                    {
                        WriteShowfileResponse("SHOWFILES");
                        break;
                    }

                    case "DOWNLOAD":
                    {
                        // set flag that its download request
                        b    = 2;
                        flag = true;
                        break;
                    }

                    case "UPLOAD":
                    {
                        // set flag that its upload request
                        b    = 1;
                        flag = true;
                        break;
                    }

                    case "PRINT":
                    {
                        // set flag that its print request
                        b    = 3;
                        flag = true;
                        break;
                    }

                    case "STREAMING":
                    {
                        // set flag that its Streaming request
                        b    = 5;
                        flag = true;
                        break;
                    }

                    default:
                        throw new Exception("Request type could not be resolved.");
                    }

                    if (flag)
                    {
                        MSXML2.IXMLDOMNode         scope      = node.firstChild;
                        MSXML2.IXMLDOMNamedNodeMap nodemap2   = scope.attributes;
                        MSXML2.IXMLDOMNode         childNode2 = nodemap2.nextNode();
                        // set file name to upload to "path" parameter
                        scopeVal = childNode2.nodeValue.ToString();
                    }
                }
            }
            catch (Exception e)
            {
                WriteErrorResponse(e.Message);
            }

            chatInfo            = st;
            UploadDownloadPrint = b;
            return(scopeVal);
        }
 // creates an XML document
 private MSXML2.IXMLDOMDocument CreateDocument()
 {
     // crate a document object and retrun that
     MSXML2.IXMLDOMDocument document = new MSXML2.DOMDocument();
     return(document);
 }
		public void GenerateXmlData(string diagramName, string diagramClassName, ref object xmlSource, ref bool cancel)
		{
			MSXML2.DOMDocument xmlDOMDocument = new MSXML2.DOMDocument();
			ESRI.ArcGIS.Carto.IMaps maps;
			ESRI.ArcGIS.Carto.IMap currentMap;
			ESRI.ArcGIS.Geodatabase.IEnumFeature enumFeature;
			ESRI.ArcGIS.Geodatabase.IFeature feature;
			MSXML2.IXMLDOMProcessingInstruction xmlProcInstr;
			MSXML2.IXMLDOMElement xmlDiagrams;
			MSXML2.IXMLDOMElement xmlDiagram;
			MSXML2.IXMLDOMElement xmlFeatures;
			MSXML2.IXMLDOMElement xmlDataSources;
			MSXML2.IXMLDOMElement xmlDataSource;
			MSXML2.IXMLDOMElement xmlDataSource_Namestring;
			MSXML2.IXMLDOMElement xmlDataSource_WorkspaceInfo;
			MSXML2.IXMLDOMElement xmlWorkspaceInfo_PathName;
			MSXML2.IXMLDOMElement xmlWorkspaceInfo_WorkspaceFactoryProgID;
			MSXML2.IXMLDOMAttribute rootAtt1;
			MSXML2.IXMLDOMAttribute rootAtt2;
			ESRI.ArcGIS.Geodatabase.IEnumFeatureSetup enumFeatureSetup;
			string xmlDatabase;

			// Retrieving the selected set of features
			enumFeature = null;
			feature = null;

			m_mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)m_application.Document;
			maps = m_mxDocument.Maps;
			int i = 0;
			while (i < maps.Count)
			{
				currentMap = maps.get_Item(i);
				enumFeature = (ESRI.ArcGIS.Geodatabase.IEnumFeature)currentMap.FeatureSelection;
				enumFeatureSetup = (ESRI.ArcGIS.Geodatabase.IEnumFeatureSetup)enumFeature;
				enumFeatureSetup.AllFields = true;
				feature = enumFeature.Next();
				if (feature != null) break;

				i += 1;
			}

			// if (there is no selected feature in the MxDocument, the procedure is interrupted
			if (feature == null)
			{
				MessageBox.Show("There is no feature selected. Select a set of features.", "Generate/Update XML diagrams", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				cancel = true;
				return;
			}

			//Checking the feature dataset related to the selected features
			ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass;
			string featureDatasetName;
			featureClass = (ESRI.ArcGIS.Geodatabase.IFeatureClass)feature.Class;
			featureDatasetName = featureClass.FeatureDataset.BrowseName;
			xmlDatabase = featureClass.FeatureDataset.Workspace.PathName;

			// if the selected features come from another feature dataset than the expected one, the procedure is interrupted
			if (featureDatasetName != DatasetName)
			{
				//More restrictive condition: if (xmlDatabase != "c:\Mybase.gdb" ) 
				MessageBox.Show("This component doesn't work from the selected set of features.");
				cancel = true;
				return;
			}

			// Writing the XML heading items in the DOMDocument
			xmlProcInstr = xmlDOMDocument.createProcessingInstruction("xml", "version='1.0'");
			xmlDOMDocument.appendChild(xmlProcInstr);
			xmlProcInstr = null;

			//-------- Diagrams Section START --------
			// Creating the root Diagrams element
			xmlDiagrams = xmlDOMDocument.createElement("Diagrams");
			xmlDOMDocument.documentElement = xmlDiagrams;
			rootAtt1 = xmlDOMDocument.createAttribute("xmlns:xsi");
			rootAtt1.text = "http://www.w3.org/2001/XMLSchema-instance";
			xmlDiagrams.attributes.setNamedItem(rootAtt1);

			// Creating the Diagram element for the diagram which is going to be generated
			xmlDiagram = xmlDOMDocument.createElement("Diagram");
			xmlDiagrams.appendChild(xmlDiagram);
			rootAtt1 = xmlDOMDocument.createAttribute("EnforceDiagramTemplateName");
			rootAtt1.text = "false";
			xmlDiagram.attributes.setNamedItem(rootAtt1);
			rootAtt2 = xmlDOMDocument.createAttribute("EnforceDiagramName");
			rootAtt2.text = "false";
			xmlDiagram.attributes.setNamedItem(rootAtt2);

			//-------- DataSources Section START --------
			// Creating the DataSources element 
			xmlDataSources = xmlDOMDocument.createElement("Datasources");
			xmlDiagram.appendChild(xmlDataSources);
			xmlDataSource = xmlDOMDocument.createElement("Datasource");
			xmlDataSources.appendChild(xmlDataSource);

			// Specifying the Namestring for the related Datasource element
			xmlDataSource_Namestring = xmlDOMDocument.createElement("NameString");
			xmlDataSource.appendChild(xmlDataSource_Namestring);
			xmlDataSource_Namestring.nodeTypedValue = "XMLDataSource";

			// Specifying the WorkspaceInfo for the related Datasource element
			xmlDataSource_WorkspaceInfo = xmlDOMDocument.createElement("WorkSpaceInfo");
			xmlDataSource.appendChild(xmlDataSource_WorkspaceInfo);
			xmlWorkspaceInfo_PathName = xmlDOMDocument.createElement("PathName");
			xmlDataSource_WorkspaceInfo.appendChild(xmlWorkspaceInfo_PathName);
			xmlWorkspaceInfo_PathName.nodeTypedValue = xmlDatabase;
			xmlWorkspaceInfo_WorkspaceFactoryProgID = xmlDOMDocument.createElement("WorkspaceFactoryProgID");
			xmlDataSource_WorkspaceInfo.appendChild(xmlWorkspaceInfo_WorkspaceFactoryProgID);
			xmlWorkspaceInfo_WorkspaceFactoryProgID.nodeTypedValue = "esriDataSourcesGDB.FileGDBWorkspaceFactory";
			//-------- DataSources Section END --------

			//-------- Features Section START --------
			xmlFeatures = xmlDOMDocument.createElement("Features");
			xmlDiagram.appendChild(xmlFeatures);
			while (feature != null)
			{
				switch (feature.FeatureType)
				{
					case ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimpleJunction:
						CreateXMLNodeElt(feature, ref xmlDOMDocument, ref xmlFeatures, feature.Class.AliasName);
						break;
					case ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimpleEdge:
						CreateXMLLinkElt(feature, ref xmlDOMDocument, ref xmlFeatures, feature.Class.AliasName);
						break;
				}
				feature = enumFeature.Next();

			}

			// output the XML we created
			xmlSource = xmlDOMDocument;
			cancel = false;
			//-------- Features Section END --------
			//-------- Diagrams Section END --------

		}
Пример #14
0
        public string InvokeU8Api(string method,string content)
        {
            string retstr = "";
            try
            {
                string AccCode = ReadXmlData("Detail", "AccCode");
                string User = ReadXmlData("Detail", "User");
                string Password = ReadXmlData("Detail", "Password");
                string Server = ReadXmlData("Detail", "Server");

                string ServiceURL = ReadXmlData("Detail", "ServiceURL");
                string ServiceName = "ZhengShanWsIPort";// ZhengShanWsIService ReadXmlData("Detail", "ServiceName");

                ulogin = new U8Login.clsLogin();
                U8Login.clsLogin u8Login = new U8Login.clsLogin();
               // string taskid = clslogin.GetTaskID("DP");
                String sSubId = "DP";//AS DP
                String sAccId = AccCode;
                String sYear = DateTime.Now.Year.ToString();
                String sUserID = User;
                String sPassword = Password;
                String sDate = DateTime.Now.ToShortDateString();
                String sServer = Server;//USER-20150630LA
                String sSerial = "";
                if (u8Login.Login(ref sSubId, ref sAccId, ref sYear, ref sUserID, ref sPassword, ref sDate, ref sServer, ref sSerial))
                {
                    setConnStr(u8Login.UfDbName);
                    //retstr = "login ok!";
                }
                else
                {
                    retstr = u8Login.ShareString;
                    Marshal.FinalReleaseComObject(u8Login);
                    return retstr;
                }
                if(method.Equals("secret"))
                    return u8Login.UfDbName;
                string api = "";
                if (method.Equals("TransVouchAdd"))//调拨单生成
                {
                    api = "U8API/TransVouch/Add";
                }
                else if (method.Equals("audit"))//调拨单审核
                {
                    api = "U8API/TransVouch/Audit";
                }
                else if (method.Equals("load"))//调拨申请单查询
                {
                    api = "U8API/TransRequestVouch/Load";
                }else
                if (method.Equals("OutboundOrderAdd"))
                    api = "U8API/saleout/Add";

                if (method.Equals("InventoryQTY"))
                {
                    DataTable dt = getSqlData("select cinvcode,cwhcode,iquantity,fAvaQuantity from currentstock where cinvcode='" + content + "'");
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.Append("<?xml version='1.0' encoding='UTF-8'?><DATA>");
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sb.Append("<RECORD>");

                            sb.Append("<CINVCODE>");
                            sb.Append(dt.Rows[i][0].ToString());
                            sb.Append("</CINVCODE>");

                            sb.Append("<CWHCODE>");
                            sb.Append(dt.Rows[i][1].ToString());
                            sb.Append("</CWHCODE>");

                            sb.Append("<IQUANTITY>");
                            sb.Append(dt.Rows[i][2].ToString());
                            sb.Append("</IQUANTITY>");

                            sb.Append("<FAVAQUANTITY>");
                            sb.Append(dt.Rows[i][3].ToString());
                            sb.Append("</FAVAQUANTITY>");

                            sb.Append("</RECORD>");
                        }
                        sb.Append("</DATA>");

                        //ZhengShanWsIClient c = new ZhengShanWsIClient(ServiceName, ServiceURL);//"http://192.168.1.122:8081/freshBeef/ws/zhengShanWs"
                        //string result = c.inventory(sb.ToString());
                        return sb.ToString();
                    }else
                    return "查不到现存量信息";
                }
                if (method.Equals("Inventory"))
                {
                    DataTable dt = getSqlData("select cinvcode,cinvname,cinvstd,cinvccode,cComunitcode,CBARCODE,null as CISGIFT,null as gd_is_gift,iInvSaleCost,null as GD_IS_GIFT from Inventory where cinvcode='" + content + "'");
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.Append("<DATA>");//<?xml version='1.0' encoding='UTF-8'?>
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sb.Append("<RECORD>");

                            sb.Append("<CINVCODE>");
                            sb.Append(dt.Rows[i][0].ToString());
                            sb.Append("</CINVCODE>");

                            sb.Append("<CINVNAME>");
                            sb.Append(dt.Rows[i][1].ToString());
                            sb.Append("</CINVNAME>");

                            sb.Append("<CINVSTD>");
                            sb.Append(dt.Rows[i][2].ToString());
                            sb.Append("</CINVSTD>");

                            sb.Append("<CINVCCODE>");
                            sb.Append(dt.Rows[i][3].ToString());
                            sb.Append("</CINVCCODE>");

                            sb.Append("<CCOMUNITCODE>");
                            sb.Append(dt.Rows[i][4].ToString());
                            sb.Append("</CCOMUNITCODE>");

                            sb.Append("<CBARCODE>");
                            sb.Append(dt.Rows[i][5].ToString());
                            sb.Append("</CBARCODE>");

                            sb.Append("<CISGIFT>");
                            sb.Append(dt.Rows[i][6].ToString());
                            sb.Append("</CISGIFT>");

                            sb.Append("<IINVSALECOST>");
                            sb.Append(dt.Rows[i][7].ToString());
                            sb.Append("</IINVSALECOST>");

                            sb.Append("<GD_IS_GIFT>");
                            sb.Append(dt.Rows[i][8].ToString());
                            sb.Append("</GD_IS_GIFT>");

                            sb.Append("</RECORD>");
                        }
                        sb.Append("</DATA>");
                        //ZhengShanWsIClient c = new ZhengShanWsIClient(ServiceName, ServiceURL);//"http://192.168.1.122:8081/freshBeef/ws/zhengShanWs"
                        //string result = c.inventory(sb.ToString());

                        return sb.ToString();
                    }
                    else
                        return "查不到存货信息";
                }
                if (method.Equals("InventoryClass"))
                {
                    DataTable dt = getSqlData("select CINVCCODE,CINVCNAME,(select cInvCCode from InventoryClass b where b.iInvCGrade+1=h.iInvCGrade and LEFT(h.cinvccode,LEN(b.cinvccode))=b.cinvccode) as CINVCCODE_F from inventoryclass h ");
                    string str = "";
                    str += "<DATA>";
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        str += "<RECORD>";
                        str += GetXmlTag("CINVCCODE", dt.Rows[i]["CINVCCODE"].ToString());
                        str += GetXmlTag("CINVCNAME", dt.Rows[i]["CINVCCODE"].ToString());
                        str += GetXmlTag("CINVCCODE_F", dt.Rows[i]["CINVCCODE_F"].ToString());
                        str += "</RECORD>";
                    }
                    str += "</DATA>";
                    //return PostData(null, content);
                    ZhengShanWsIClient c = new ZhengShanWsIClient(content, ServiceURL);//"http://192.168.1.122:8081/freshBeef/ws/zhengShanWs"
                    return c.InventoryClass(str);
                }

                U8EnvContext envContext = new U8EnvContext();
                envContext.U8Login = u8Login;

                //string method = "audit";

                U8ApiAddress myApiAddress = new U8ApiAddress(api);
                U8ApiBroker broker = new U8ApiBroker(myApiAddress, envContext);
                MSXML2.DOMDocument domMsg = new MSXML2.DOMDocument();
                if (method.Equals("TransVouchAdd"))
                {
                    broker.AssignNormalValue("sVouchType", "12");

                    BusinessObject DomHead = broker.GetBoParam("DomHead");
                    DomHead.RowCount = 1;

                    XmlDocument xml = new XmlDocument();
                    //xml.LoadXml(content.Trim());
                    xml.Load("c:\\DATA.xml");

                    XmlNodeList xnList = xml.SelectNodes("/DATA/ORDER/ORDERID/DETAIL");
                    foreach (XmlNode xn in xnList)
                    {
                        retstr += "开始读取XML";
                        string VOUCHID = xn["VOUCHID"].InnerText;
                        string VOUCHDATE = xn["VOUCHDATE"].InnerText;

                        //DomHead[0]["id"] = "2"; //主关键字段,int类型
                        DomHead[0]["ctvcode"] = VOUCHID; //单据号,string类型
                        DomHead[0]["dtvdate"] = VOUCHDATE;  //日期,DateTime类型
                        DataTable dt = getSqlData("select cwhcode from warehouse where cwhname='" + xn["OWHNAME"].InnerText+"'");
                        if (dt.Rows.Count > 0)
                            DomHead[0]["cowhcode"] = dt.Rows[0][0].ToString();
                        dt = getSqlData("select cwhcode from warehouse where cwhname='" + xn["IWHNAME"].InnerText + "'");
                        if (dt.Rows.Count > 0)
                            DomHead[0]["ciwhcode"] = dt.Rows[0][0].ToString();

                        DomHead[0]["cwhname"] = xn["OWHNAME"].InnerText; //转出仓库,string类型
                        DomHead[0]["cwhname_1"] = xn["IWHNAME"].InnerText; //转入仓库,string类型

                        //DomHead[0]["ciwhcode"] = "2";//转入仓库编码,string类型
                        //DomHead[0]["cowhcode"] = "1"; //转出仓库编码,string类型

                        //DomHead[0]["cordcode"] = "2"; //出库类别编码,string类型
                        //DomHead[0]["cirdcode"] = "1"; //入库类别编码,string类型

                        //DomHead[0]["crdname_1"] = "销售出库";//出库类别
                        //DomHead[0]["crdname"] = "采购入库";//入库类别

                        //DomHead[0]["cdepname_1"] = "采购部";
                        //DomHead[0]["cdepname"] = "销售部";
                        //DomHead[0]["codepcode"] = "1";
                        //DomHead[0]["cidepcode"] = "2";

                        //DomHead[0]["cpersoncode"] = "1";
                        DomHead[0]["cpersonname"] = xn["PERSON"].InnerText;//经手人
                        dt = getSqlData("select cPersonCode from Person where cPersonName='" + xn["PERSON"].InnerText + "'");
                        if (dt.Rows.Count > 0)
                            DomHead[0]["cpersoncode"] = dt.Rows[0][0].ToString();

                        //DomHead[0]["iamount"] = "";//现存量
                        DomHead[0]["dnmaketime"] = DateTime.Now;
                        DomHead[0]["ctvmemo"] = xn["MEMO"].InnerText;
                        DomHead[0]["cinvname"] = xn["CINVNAME"].InnerText;
                        //DomHead[0]["iavaquantity"] = "80"; 可用量

                        DomHead[0]["csource"] = "1"; //1 -- 库存 2 -- 零售 3 -- 预留
                        DomHead[0]["cmaker"] = User;
                        DomHead[0]["csource"] = "1";
                        DomHead[0]["itransflag"] = "正向";
                        DomHead[0]["vt_id"] = 89;
                        DomHead[0]["dnmaketime"] = DateTime.Now.ToLongDateString();
                        //DomHead[0]["ufts"] = "                      275.5169";
                        DomHead[0]["btransflag"] = false;

                        BusinessObject domBody = broker.GetBoParam("domBody");
                        domBody.RowCount = 1;

                        //domBody[0]["autoid"] = "2"; //主关键字段,int类型
                        domBody[0]["cinvcode"] = xn["CINVCODE"].InnerText;//存货编码,string类型
                        domBody[0]["cinvname"] = xn["CINVNAME"].InnerText;
                        //domBody[0]["cinvstd"] = "";

                        domBody[0]["itvquantity"] =getDouble(xn["QTY"].InnerText); //数量,double类型

                        DataTable dt3 = getSqlData("select cComUnitCode from inventory where cinvcode='" + xn["CINVCODE"].InnerText + "'");

                        //domBody[0]["itvnum"] = 0.1;

                        domBody[0]["ctvbatch"] = "";
                        if (dt3.Rows.Count > 0)
                        {
                            domBody[0]["cinvm_unit"] = dt3.Rows[0][0].ToString();
                            //domBody[0]["cinva_unit"] = "4";
                            //domBody[0]["cassunit"] = "4";
                        }

                        domBody[0]["iexpiratdatecalcu"] = 0;
                        domBody[0]["issotype"] = 0;
                        domBody[0]["idsotype"] = 0;
                        domBody[0]["isoseq"] = "";
                        domBody[0]["idsoseq"] = "";
                        domBody[0]["issodid"] = "";
                        domBody[0]["idsodid"] = "";
                        domBody[0]["cinvaddcode"] = "";
                        domBody[0]["corufts"] = "                              ";
                        domBody[0]["cdsocode"] = "";
                        domBody[0]["csocode"] = "";

                        domBody[0]["bcosting"] = "1";
                        domBody[0]["cposition"] = "";

                        //domBody[0]["iinvexchrate"] = 100;
                        domBody[0]["ctvcode"] = VOUCHID;
                        domBody[0]["fsalecost"] = getDouble(xn["UNITPRICE"].InnerText) * getDouble(xn["QTY"].InnerText);
                        domBody[0]["fsaleprice"] = getDouble(xn["UNITPRICE"].InnerText);
                        //domBody[0]["itvpcost"] = getDouble(xn["itvpcost"].InnerText);
            ;
                        domBody[0]["itvaprice"] = 0;
                        domBody[0]["itvpprice"] = 0;
                        domBody[0]["itvacost"] = 0;

                        //domBody[0]["igrossweight"] = "3";
                        //domBody[0]["inetweight"] = "1";

                        domBody[0]["editprop"] = "A";
                        retstr += "读取XML完成";
                    }

                    broker.AssignNormalValue("domPosition", null);
                    broker.AssignNormalValue("errMsg", "");
                    broker.AssignNormalValue("cnnFrom", null);
                    broker.AssignNormalValue("VouchId", "");
                    broker.AssignNormalValue("domMsg", domMsg);

                    broker.AssignNormalValue("bCheck", false);
                    broker.AssignNormalValue("bBeforCheckStock", false);
                    broker.AssignNormalValue("bIsRedVouch", false);
                    broker.AssignNormalValue("sAddedState", "");
                    broker.AssignNormalValue("bReMote", false);

                }
                if (method.Equals("OutboundOrderAdd"))
                {
                    broker.AssignNormalValue("sVouchType", "32");//新增0 修改1

                    broker.AssignNormalValue("domPosition", null);
                    broker.AssignNormalValue("errMsg", "");
                    broker.AssignNormalValue("cnnFrom", null);
                    broker.AssignNormalValue("VouchId", "");
                    broker.AssignNormalValue("domMsg", domMsg);

                    broker.AssignNormalValue("bCheck", false);
                    broker.AssignNormalValue("bBeforCheckStock", false);
                    broker.AssignNormalValue("bIsRedVouch", false);
                    broker.AssignNormalValue("sAddedState", "");
                    broker.AssignNormalValue("bReMote", false);

                    BusinessObject DomHead = broker.GetBoParam("DomHead");
                    DomHead.RowCount = 1;

                    XmlDocument xml = new XmlDocument();
                    xml.LoadXml(content.Trim());
                    XmlNodeList xnList = xml.SelectNodes("/DATA/ORDER/ORDERID/DETAIL");
                    foreach (XmlNode xn in xnList)
                    {

                        string VOUCHID = xn["VOUCHID"].InnerText;
                        string VOUCHDATE = xn["VOUCHDATE"].InnerText;

                    }

                    BusinessObject domBody = broker.GetBoParam("domBody");
                    domBody.RowCount = 1;

                }
                if (method.Equals("audit"))//调拨单审核
                {
                    DataTable dt = getSqlData("select CONVERT(money,ufts) as ufts from transvouch where cTVCode='" + content + "'");
                    double ufts = 0;
                    //string ts = "";
                    if (dt.Rows.Count > 0)
                    {
                        //DataTable dt2 = getSqlData("select convert(timestamp,CONVERT(money," + String.Format("{0,30}", String.Format("{0:0.0000}", ufts)) + ")) as ufts ");
                        ufts = double.Parse(dt.Rows[0][0].ToString());
                        //ts = dt2.Rows[0][0].ToString();
                    }
                    else
                        return "找不到此调拨单号:"+content;
                    broker.AssignNormalValue("sVouchType", "12");
                    broker.AssignNormalValue("VouchId", content);//单据号
                    broker.AssignNormalValue("errMsg", "");
                    broker.AssignNormalValue("cnnFrom", null);
                    broker.AssignNormalValue("TimeStamp", String.Format("{0,30}", String.Format("{0:0.0000}", ufts)));// "                      275.5210"
                    broker.AssignNormalValue("domMsg", domMsg);//new MSXML2.DOMDocument()
                    broker.AssignNormalValue("bCheck", false);
                    broker.AssignNormalValue("bBeforCheckStock", false);
                    broker.AssignNormalValue("bList", false);
                    broker.AssignNormalValue("MakeWheres", null);
                    broker.AssignNormalValue("sWebXml", "");
                    broker.AssignNormalValue("oGenVouchIds", null);
                }
                if (method.Equals("load"))
                {
                    broker.AssignNormalValue("sVouchType", "62");
                    broker.AssignNormalValue("sWhere", " VouchId='0000000001'");
                    broker.AssignNormalValue("bGetBlank", false);
                    broker.AssignNormalValue("sBodyWhere_Order", "cInvcode");
                    broker.AssignNormalValue("errMsg", "");
                    broker.AssignNormalValue("domPos", domMsg);
                    BusinessObject obj = broker.GetBoParam("domHead");
                    BusinessObject obj1 = broker.GetBoParam("domBody");
                }
                if (method.Equals("submitTransRequestBill"))
                {
                    string sql = "select h.cTVCode AS VOUCHID,h.dTVDate AS VOUCHDATE,wo.cwhname as OWHNAME,wo.cwhname as IWHNAME,h.cMaker as PERSON,B.CINVCODE,i.CINVNAME,B.ITVQUANTITY AS QTY,B.iUnitCost AS UNITPRICE,B.cbMemo AS MEMO";
                    sql += "from ST_AppTransVouch h,ST_AppTransVouchs b,Inventory i,warehouse wi,warehouse wo";
                    sql += "where h.ID = b.ID and i.cinvcode = b.cinvcode and wi.cwhcode = h.cIWhCode and wo.cwhcode = h.cOWhCode ";
                    sql += "and h.cTVCode='"+content+"'";
                    DataTable dt3 = getSqlData(sql);
                    if (dt3.Rows.Count == 0)
                        return "查不到调拨申请单:"+content;
                    string xml = "<?xml version='1.0' encoding='UTF-8'?>\n";
                    xml += "<DATA>\n";
                    xml += "<ORDER>\n";
                    xml += "<ORDERID>\n";
                    xml += "<DETAIL>\n";

                            xml += GetXmlTag("VOUCHID", IsNull(dt3.Rows[0]["VOUCHID"]));
                            xml += GetXmlTag("VOUCHDATE", IsNull(dt3.Rows[0]["VOUCHDATE"]));
                            xml += GetXmlTag("OWHNAME", IsNull(dt3.Rows[0]["OWHNAME"]));
                            xml += GetXmlTag("IWHNAME", IsNull(dt3.Rows[0]["IWHNAME"]));
                            xml += GetXmlTag("PERSON", IsNull(dt3.Rows[0]["PERSON"]));
                            xml += GetXmlTag("VOUCHID", IsNull(dt3.Rows[0]["VOUCHID"]));
                            xml += GetXmlTag("CINVCODE", IsNull(dt3.Rows[0]["CINVCODE"]));
                            xml += GetXmlTag("CINVNAME", IsNull(dt3.Rows[0]["CINVNAME"]));
                            xml += GetXmlTag("QTY", IsNull(dt3.Rows[0]["QTY"]));
                            xml += GetXmlTag("UNITPRICE", IsNull(dt3.Rows[0]["UNITPRICE"]));
                            xml += GetXmlTag("MEMO", IsNull(dt3.Rows[0]["MEMO"]));

                    xml += "\n</DETAIL>";
                    xml += "\n</ORDERID>";
                    xml += "\n</ORDER>";

                    xml += "\n</DATA>";

                    return PostData(null, content);
                    //ZhengShanWsIClient c = new ZhengShanWsIClient(ServiceName, ServiceURL);//"http://192.168.1.122:8081/freshBeef/ws/zhengShanWs"
                    //return c.ST_AppTransVouchAdd(xml);

                }
                retstr += "开始调用";
                if (!broker.Invoke())
                {
                    retstr += "调用失败:";
                    //错误处理
                    Exception apiEx = broker.GetException();
                    if (apiEx != null)
                    {
                        if (apiEx is MomSysException)
                        {
                            MomSysException sysEx = apiEx as MomSysException;
                            //Console.WriteLine("系统异常:" + sysEx.Message);
                            retstr = sysEx.Message + "[MomSysException]";
                            //todo:异常处理
                        }
                        else if (apiEx is MomBizException)
                        {
                            MomBizException bizEx = apiEx as MomBizException;
                            //Console.WriteLine("API异常:" + bizEx.Message);
                            retstr = bizEx.Message + "[MomBizException]";
                            //todo:异常处理
                        }
                    }
                    //结束本次调用,释放API资源
                    broker.Release();
                    //return;
                }
                else
                {
                    retstr += "调用成功:";
                    if (method.Equals("load"))
                    {
                        System.String result = broker.GetReturnValue() as System.String;
                        if (string.IsNullOrEmpty(result))
                        {
                            retstr += "加载调拨申请单成功!";
                            //Console.WriteLine("加载销售订单成功!");

                            //获取out/inout参数值
                            //MSXML2.XMLDocument xmlResult = broker.GetResult("domHead") as MSXML2.XMLDocument;
                            MSXML2.DOMDocumentClass xmlHead = broker.GetResult("DomHead") as MSXML2.DOMDocumentClass;
                            xmlHead.save("TransRequestVouchHead.xml");

                            //out参数domBody为BO对象(表体),此BO对象的业务类型为销售订单。BO参数均按引用传递,具体请参考服务接口定义
                            //如果要取原始的XMLDOM对象结果,请使用GetResult()
                            MSXML2.DOMDocumentClass xmlBody = broker.GetResult("domBody") as MSXML2.DOMDocumentClass;
                            xmlBody.save("TransRequestVouchBody.xml");
                        }
                        else
                        {
                            retstr += "加载调拨申请单失败!";
                            //Console.WriteLine("加载销售订单失败!");
                        }
                    }else
                    retstr+=broker.GetResult("errMsg");
                }
            }
            catch (Exception e)
            {
                retstr += "异常:" + e.Message+"\n"+e.StackTrace;
                return retstr;
                //throw;
            }
            return retstr;
        }