Exemple #1
0
        public static void FormatDom(ref MSXML2.DOMDocument SourceDom, string editprop)
        {
            //IXMLDOMElement element;
            //IXMLDOMElement ele_head;
            IXMLDOMElement ele_body;
            //IXMLDOMNode nd;
            //MSXML2.DOMDocument tempnd;
            IXMLDOMNodeList ndheadlist;
            IXMLDOMNodeList ndbodylist;
            //DistDom.loadXML("SourceDom.xml");
            String Filedname;

            //'格式部分
            ndheadlist = SourceDom.selectNodes("//s:Schema/s:ElementType/s:AttributeType");
            ndbodylist = SourceDom.selectNodes("//rs:data/z:row");
            if (ndbodylist.length == 0)
            {
                ele_body = SourceDom.createElement("z:row");
                SourceDom.selectSingleNode("//rs:data").appendChild(ele_body);
            }
            ndbodylist = SourceDom.selectNodes("//rs:data/z:row");
            foreach (IXMLDOMElement body in ndbodylist)
            {
                foreach (IXMLDOMElement head in ndheadlist)
                {
                    Filedname = head.attributes.getNamedItem("name").nodeValue + "";
                    if (body.attributes.getNamedItem(Filedname) == null)
                    {
                        //  '若没有当前元素,就增加当前元素
                        body.setAttribute(Filedname, "");
                    }
                    switch (head.lastChild.attributes.getNamedItem("dt:type").nodeValue.ToString())
                    {
                    case "number":
                    case "float":
                    case "boolean":
                        if (body.attributes.getNamedItem(Filedname).nodeValue.ToString().ToUpper() == "false".ToUpper())
                        {
                            body.setAttribute(Filedname, 0);
                        }
                        break;

                    default:


                        if (body.attributes.getNamedItem(Filedname).nodeValue.ToString().ToUpper() == "否".ToUpper())
                        {
                            body.setAttribute(Filedname, 0);
                        }
                        break;
                    }
                }
                if (editprop != "")
                {
                    body.setAttribute("editprop", editprop);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 激发API操作
        /// </summary>
        /// <param name="broker"></param>
        /// <returns></returns>
        public override Model.DealResult BrokerInvoker(UFIDA.U8.U8APIFramework.U8ApiBroker broker)
        {
            Model.DealResult        dr        = new Model.DealResult();
            MSXML2.IXMLDOMDocument2 domResult = new MSXML2.DOMDocument();

            MSXML2.IXMLDOMNodeList lstx;
            string sResult = "";

            if (!broker.Invoke())
            {
                //错误处理
                Exception apiEx = broker.GetException();
                if (apiEx != null)
                {
                    if (apiEx is MomSysException)
                    {
                        MomSysException sysEx = apiEx as MomSysException;
                        dr.ResultNum = -1;
                        dr.ResultMsg = "系统异常:" + sysEx.Message;
                    }
                    else if (apiEx is MomBizException)
                    {
                        MomBizException bizEx = apiEx as MomBizException;
                        dr.ResultNum = -1;
                        dr.ResultMsg = "API异常:" + bizEx.Message;
                    }

                    String exReason = broker.GetExceptionString();
                    if (exReason.Length != 0)
                    {
                        dr.ResultNum = -1;
                        dr.ResultMsg = " 异常原因:" + exReason;
                    }
                }

                broker.Release();

                return(dr);
            }
            System.String result    = broker.GetReturnValue() as System.String;
            string        vNewIDRet = broker.GetResult("vNewID") as string;

            broker.Release();


            if (result != null)
            {
                dr.ResultNum = -1;
                dr.ResultMsg = result;
                sResult      = result.ToString();

                //增加可用量不足的提示,通过读取返回的DOM信息解析可用量不足的信息
                if (sResult.IndexOf("<rs:data") > 0)
                {
                    string sInvCode = "";
                    string sInvName = "";
                    string sWhCode  = "";
                    string sWhName  = "";
                    string sError   = "";
                    sResult = sResult.Substring(sResult.IndexOf("<rs:data"));
                    if (domResult.loadXML(sResult) == true)
                    {
                        lstx = domResult.selectNodes("//z:row");
                        foreach (MSXML2.IXMLDOMNode xmle in lstx)
                        {
                            sInvCode = xmle.attributes.getNamedItem("cinvcode").nodeValue.ToString();
                            sInvName = xmle.attributes.getNamedItem("cinvname").nodeValue.ToString();
                            sWhCode  = xmle.attributes.getNamedItem("cwhcode").nodeValue.ToString();
                            sWhName  = xmle.attributes.getNamedItem("cwhname").nodeValue.ToString();

                            sError = sError + "存货编码[" + sInvCode + "] 存货名称[" + sInvName + "] 仓库[" + sWhName + "]\r\n";
                        }
                        if (sError != "")
                        {
                            sError       = sError + "可用量不足";
                            result       = sError;
                            dr.ResultMsg = result;
                        }
                    }
                }

                throw new Exception("API错误:" + result);
            }
            dr.VouchIdRet = vNewIDRet;
            return(dr);
        }